Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master

Tuesday, September 2, 2025

How to configure Prestashop to send e-mails

By default, Prestashop is configured to use the PHP mail() function for sending e-mails. However SMTP is better at handling messages and can also be used to send e-mails from a third party mail provider if necessary.


To configure your Prestashop to use SMTP, access the application’s back office, then click on Advanced Parameters -> E-Mail. Select the Set my own SMTP parameters (for advanced users ONLY) option and enter the following settings in the new section that appears:


Email domain name – leave blank;

SMTP server – check the exact hostname to use with each of your mail accounts in your Site Tools > Email > Accounts, choose the preferred email account and go to kebab menu > Mail Configuration and select Manual Settings tab;

SMTP username – your full e-mail address, i.e. contact@yourdomainname.com;

SMTP password – the password for the e-mail address;

Encryption – SSL;

Port – 465.

Click Save to apply the new settings.


You can confirm the functionality of the e-mail service by sending a message to yourself from Test your email configuration section.

Thursday, March 31, 2022

Access Website Hosted In IIS On Windows 10 From Any PC On LAN

 

Introduction

 
In this article, we will learn about Access Website Hosted In IIS On Windows 10 From Any PC On LAN.
 
Prerequisites
  • Windows 10 PC with IIS installed. (In this example IIS version is 10 )
  • Basic knowledge of website hosting on IIS.

Create a website in IIS

 
Open run (windows key + R) and type inetmgr and press enter or in Cortana Search type IIS.







IIS Manager opens.
 
Then right click on Sites and click on Add Website. The Add website dialog opens.




  • Fill in required details and select folder where compiled code is located. Eg: C:\Nigel\Publish
  • Select required port , default is 80. I will be using 7500.
  • Do not enter host name details if you are testing or using on LAN. 
Then click ok. A website gets created and it will show under Sites.




Now right click on website name then Manage website and then click browse.





The link should be in the form on http://localhost:7500/  if you used port 7500 and selected http.
 

Locate your IP Address

 
Now open command prompt. Type cmd in run.




Type ipconfig and press enter. Now locate your PC's IP address on the LAN.


    


Now in your website link replace localhost with 192.168.0.24 (IP address) so your URL will be - http://192.168.0.24:7500/
Try it in your browser to make sure it works.
 

Change Firewall Rules

 
In Cortana search type firewall then click on Windows firewall with advanced security.




The firewall window opens.




Click on Inbound rules on the left. Then click new Rule in the right side menu.




The New inbound rule wizard will open. What type of rule would you like to create? Select Port and click Next.



In Does this rule apply to TCP or UDP? Select TCP. Then enter port number (7500) in specific local ports textbox. Then click Next >.



Then the Action form opens. Select Allow the connection and click Next .


Then the profile form opens. In the When does this rule apply? - Select required ones , if not sure then select all. Click Next.


Give this Firewall rule a Name and Description, so you know for what purpose you created this. Then click finish.
 



Now if you share the link we created earlier with someone else on your LAN it should open your website.
 
Link example: http://192.168.0.24:7500/
 
Note
  • Be careful when changing Firewall setting otherwise you may leave your PC vulnerable to online attacks.
  • Only use ports in non standard range (preferably after 9000).
  • Once you are done using the website you can delete the Firewall rule. 

Tuesday, January 4, 2022

Learn to Fix React Native JVM Heap Space Is Exhausted

 Add the below lines into the gradle.properties file. Below memory size can be configured based on the RAM availability

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2560m

Through GUI:

In the Settings, search for 'Memory Settings' and increase the IDE max heap size and Daemon max heap size as per the system RAM availability.





Tuesday, December 28, 2021

How to show json data in flatlist in react native

 1. Create json data. Format is given below


    JsonData.json


[
    {
        "id" : 1,
        "FirstName" : "Sandeep",
        "LastName" : "Rauniyar",
        "DOB" : "4-7-1990",
        "CovidVaccine" : "Pfizer BioNTech",
        "FirstDose" : "EN6888",
        "SecondDose" : "ER8861",
        "image": "https://bootdey.com/img/Content/avatar/avatar1.png"
    },
    {
        "id" : 2,
        "FirstName" : "Mukesh",
        "LastName" : "Verma",
        "DOB" : "10/29/1995",
        "CovidVaccine" : "JANSSEN",
        "FirstDose" : "2030020",
        "SecondDose" : "",
        "image": "https://bootdey.com/img/Content/avatar/avatar2.png"
    }
]


2. import JsonData.json

import PostData from "../Data/JsonData.json";


3. Set data


    const [data, setData] = useState(PostData.filter(item=>item.id ==1 ));
 


4. 


<FlatList
   data={data}
   keyExtractor= {(item) => {
   return item.id;
   }}
   renderItem={({item}) => {
   return (
     <View>
        <View style={styles.box}>
           <Image style={styles.icon1} source={{uri: item.image}} />
           <View style={styles.boxContent}>
           <Text style={styles.title}>First Name : {item.FirstName}</Text>
            <Text style={styles.description}>Last Name :  {item.LastName}</Text>
            <Text style={styles.description}>DOB :  {item.DOB}</Text>
        <Text style={styles.description}>Covid-19 Vaccine : {item.CovidVaccine}</Text>   
             </View>
                </View>
             
            </View>
          )
        }}/>







Tuesday, December 21, 2021

new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method

 To fix, add this to RNFSManager.java


// Required for rn built in EventEmitter Calls.
    @ReactMethod
    public void addListener(String eventName) {

    }

    @ReactMethod
    public void removeListeners(Integer count) {

    }

Example: for fix warning in react-native-fs add functions to 
node_modules\react-native-fs\android\src\main\java\com\rnfs\RNFSManager.java file.
Snapshots is given below.





Thursday, December 16, 2021

Log message Request and Response in ASP.NET WebAPI

There are multiple approaches to generically handle Request/Response logging for every WebAPI method calls:

1.    ActionFilterAttribute: One can write custom ActionFilterAttribute and decorate the controller/action methods to enable logging.

Con: You need to decorate every controller/methods (still you can do it on base controller, but still it doesn't address cross cutting concerns.

2.    Override BaseController and handle logging there.

Con: We are expecting/forcing the controllers to inherit from a custom base controller.

3.    Using DelegatingHandler.

Advantage: We are not touching controller/method here with this approach. Delegating handler sits in isolation and gracefully handles the request/response logging.



I would recommend using a DelegatingHandler. Then you will not need to worry about any logging code in your controllers.

public class LogRequestAndResponseHandler : DelegatingHandler
{
    protected override async Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request, CancellationToken cancellationToken)
    {
        if (request.Content != null)
        {
            // log request body
            string requestBody = await request.Content.ReadAsStringAsync();
            Trace.WriteLine(requestBody);
        }
        // let other handlers process the request
        var result = await base.SendAsync(request, cancellationToken);

        if (result.Content != null)
        {
            // once response body is ready, log it
            var responseBody = await result.Content.ReadAsStringAsync();
            Trace.WriteLine(responseBody);
        }

        return result;
    }
}

Just replace Trace.WriteLine with your logging code and register the handler in WebApiConfig like this:



For more indepth article, refer this http://weblogs.asp.net/fredriknormen/log-message-request-and-response-in-asp-net-webapi


Thursday, November 11, 2021

Package has been Ignored because it contains Invalid Configuration React Native Error Fix

 As a react native developer we face many kind of react native errors while developing apps. Sometimes you may come up with a warning in the terminal as given below:




This react native warning will finally leads to build error while trying to run your application. So, how to fix this particular error? All you need is to run npm install command on your terminal from your project folder. After that try running your project again using either react-native run-android or react-native run-ios command.





Monday, October 25, 2021

ReactNative Metro Bundler not starting automatically

 Replace the code with this one. The path of the file is -

node_modules\metro-config\src\defaults\blacklist.js


var sharedBlacklist = [

  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,

  /website\/node_modules\/.*/,

  /heapCapture\/bundle\.js/,

  /.*\/__tests__\/.*/

];


Snapshots is given below:



ERROR:'keytool' is not recognized as an internal or external command, operable program or batch file

 Try C:\Program Files\Java\jre1.8.0_111\bin>keytool -genkey -v -keystore D:\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 






React Native Task :app:validateSigningDebug FAILED

 The problem is that the build is looking for the debug keystore and cannot find it.

Keystore file /home/sandeep/react native/react-native-redux/android/app/debug.keystore not found for signing config 'debug'.

There's an issue with the same problem in React Native GitHub. According to the page, you can solve it by creating a debug keystore. Quote from the thread:

You can generate the debug keystore by running this command in the android/app/ directory: 

keytool -genkey -v -keystore D:\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000


Copy the file from D drive and put in below location

/home/sandeep/react native/react-native-redux/android/app/debug.keystore

Thursday, August 27, 2020

SELECT LAST ITEM IN LISTBOX

 Use the following code but select the element before the last

 LIST_ITEM.TopIndex = LIST_ITEM.Items.Count - 1

Monday, June 22, 2020

Get only Saturday and Sunday dates of month in SQL Server

If you want to generate the data, then a CTE is the way to go

DECLARE
     @MONTH INT
    ,@YEAR INT
;

SET @MONTH = 6;
SET @YEAR = 2020;

WITH CTE AS
(
    SELECT CAST(CAST(@MONTH AS VARCHAR(2)) + '/01/' + CAST(@YEAR AS VARCHAR(4)) AS [Date]) AS DATE
        UNION ALL
    SELECT DATEADD(DAY,1,[Date])
    FROM CTE
    WHERE DATE <= CAST(@MONTH AS VARCHAR(2)) + 
        CASE 
            WHEN @MONTH IN (9,4,6,11) 
                THEN '/30/'
            WHEN @MONTH IN (1,3,5,7,8,10,12) 
                THEN '/31/'
            WHEN @MONTH = 2 AND @YEAR/4.00 = @YEAR/4 
                THEN '/29/'
            ELSE '/28/'
        END
        + CAST(@YEAR AS VARCHAR(4))
)
SELECT 
     [Date]
    ,CASE DATEPART(dw,[Date])
        WHEN 1 THEN 'Sunday'
        WHEN 2 THEN 'Monday'
        WHEN 3 THEN 'Tuesday'
        WHEN 4 THEN 'Wednesday'
        WHEN 5 THEN 'Thursday'
        WHEN 6 THEN 'Friday'
        WHEN 7 THEN 'Saturday'
    END
FROM CTE
WHERE DATEPART(dw,[Date]) IN (1,7)
OPTION (MAXRECURSION 0)
;

Output : 

How can I select the Last day of a month in SQL?

Simple Query:


SELECT     EOMONTH(getdate())

How can I select the first day of a month in SQL?

Simple Query:

SELECT DATEADD(m, DATEDIFF(m, 0, GETDATE()), 0) 
-- Instead of GetDate you can put any date.

How to calculate work days except Saturday and Sunday

Script shows the complete definition for a user defined function that calculates working days by mostly using the DATEDIFF function.

CREATE FUNCTION [dbo].[fn_GetTotalWorkingDays]
(
    @DateFrom Date,
    @DateTo Date
)
RETURNS INT
AS
BEGIN
    DECLARE @TotDays INT= DATEDIFF(DAY, @DateFrom, @DateTo) + 1;
    DECLARE @TotWeeks INT= DATEDIFF(WEEK, @DateFrom, @DateTo) * 2;
    DECLARE @IsSunday INT= CASE
WHEN DATENAME(WEEKDAY, @DateFrom) = 'Sunday'
THEN 1
ELSE 0
  END;
    DECLARE @IsSaturday INT= CASE
   WHEN DATENAME(WEEKDAY, @DateTo) = 'Saturday'
   THEN 1
   ELSE 0
    END;
    DECLARE @TotWorkingDays INT= @TotDays - @TotWeeks - @IsSunday + @IsSaturday;
    RETURN @TotWorkingDays;
END
 
Example :