Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, June 5, 2013

Setup guide for Umbraco


Setup guide for Umbraco
·        
       Create one empty database in SQL server.
·         Create folder “D:\Dev”
·         Copy “UmbracoCms.4.11.1.zip” into “D:\Dev” and Unzip all files of “UmbracoCms.4.11.1.zip”.
·         Cut and paste all files and folder of “D:\Dev \UmbracoCms.4.11.1” into “D:\Dev” and delete “UmbracoCms.4.11.1.zip” and “UmbracoCms.4.11.1” folder.
·         Give full permission to “Authenticated Users”, “Self account” and “IIS_IUSRS



·         Go to IIS and Right click on site and click on “Add Web Site…



·         Specify Site name, physical path and host name as below




·         Open “hosts” file from “C:\Windows\System32\drivers\etc” and add entry at last as
<IP Address> <Host name>
Example:  172.27.150.56 local.umbraco.com
·         Browse website from IIS


·         On Welcome screen click on “Lets Get Started” button
·         On license screen click on “Accept and Continue
·         On “Database configuration” screen fill the database info for empty created database


·         On next Umbraco install database and click “Continue”
·         On “Create User” screen, create new user as


·         On “Starter kits” screen select last kit “No Thanks”.


·         On “Install a Skin” screen, select skin.
·         On next screen,  click on “Setup your new Site



Note:
You can change DB and other installation steps from these URLs


Generate 8 digit random alphanumeric number as a initial password in SQL Server

-- generate 8 digit random alphanumeric number as a initial password

declare @alpha_numeric varchar(8)
      set @alpha_numeric=''
      select @alpha_numeric=@alpha_numeric+char(n) from
      (
      select top 8 number as n from master..spt_values
      where type='p' and (number between 48 and 57 or number between 65 and 90)
      order by newid()
      ) as t
      --select @alpha_numeric

OR

SELECT LEFT(CAST(NEWID() AS VARCHAR(100)), 8)

Stored Procedure To check whether User already exist or not

CREATE PROCEDURE [dbo].[Proc_User_IsDuplicate]  
 @UserID AS INT, 
 @LoginID AS VARCHAR(100) 
AS 
BEGIN 
 
 IF @UserID >
 BEGIN 
  IF (SELECT COUNT(*) FROM [User] WHERE LoginID = @LoginID AND UserID <> @UserID ) >
   SELECT 1 IsDuplicate 
  ELSE 
   SELECT 0 IsDuplicate 
 END 
 ELSE 
 BEGIN 
  IF (SELECT COUNT(*) FROM [User] WHERE LoginID = @LoginID  AND IsActive =1) >
   SELECT 1 IsDuplicate 
  ELSE 
   SELECT 0 IsDuplicate 
 END 
END

Stored Procedure to validate User Login and return the User Entity From SQL Server

-- ============================================= 
-- Description: Validate User Login and return the User Entity 
-- ============================================= 

CREATE PROCEDURE [dbo].[SP_User_Login]  
 @LoginID AS VARCHAR(20), 
 @Password AS VARCHAR(20) 
AS 
BEGIN 
 
 
 DECLARE @UserID AS INT 
 DECLARE @LastLogon AS DATETIME 
 
 SELECT @UserID = UserID, @LastLogon = LastLogon  
 FROM [User] 
 WHERE LOWER(LoginID) = LOWER(@LoginID) 
  AND Password = @Password AND IsActive =
 
 IF @UserID IS NOT NULL 
 BEGIN 
  
  UPDATE [User] 
  SET LastLogon = GETDATE() 
  WHERE UserID = @UserID 
 END 
  
 SELECT UserID, UserType, FirstName, LastName, LoginID, Designation,  
 PhoneOffice, PhoneResidence, PhoneMobile, PhoneOther, Email,  
 Title, @LastLogon AS LastLogon, IsActive 
 FROM [User] 
 WHERE UserID = @UserID 
 
END

Friday, April 26, 2013

How to get formatting string for number


How to get formatting string for number

string.Format("TEST_{0,2:D4}_{1,2:D4}", 3, 6); //TEST_0003_0006

Thursday, June 14, 2012

Retrieve Excel Workbook Sheet Names


C# - Retrieve Excel Workbook Sheet Names



Originally posted on 

/// <summary>
/// This mehtod retrieves the excel sheet names from an excel workbook.
/// </summary>
/// <param name="excelFile">The excel file.</param>
/// <returns>String[]</returns>
private String[] GetExcelSheetsNames(string excelFile)
{

    OleDbConnection objConn = null;
    System.Data.DataTable dt = null;

    try
    {
        // Connection String. Change the excel file to the file you will search.
        String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + excelFile + ";Extended Properties=Excel 8.0;";
        // Create connection object by using the preceding connection string.
        objConn = new OleDbConnection(connString);
        // Open connection with the database.
        objConn.Open();
        // Get the data table containg the schema guid.
        dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

        if (dt == null)
        {
            return null;
        }

        String[] excelSheets = new String[dt.Rows.Count];
        int i = 0;

        // Add the sheet name to the string array.
        foreach (DataRow row in dt.Rows)
        {
            excelSheets[i] = row["TABLE_NAME"].ToString();
            i++;
        }

        // Loop through all of the sheets if you want too...
        for (int j = 0; j < excelSheets.Length; j++)
        {
            // Query each excel sheet.
        }

        return excelSheets;
    }
    catch (Exception ex)
    {
        return null;
    }
    finally
    {
        // Clean up.
        if (objConn != null)
        {
            objConn.Close();
            objConn.Dispose();
        }
        if (dt != null)
        {
            dt.Dispose();
        }
    }
}

Wednesday, June 6, 2012

How to deploy web application that is using SAMS certificate to authenticate site


How to deploy web application that is using SAMS certificate to authenticate site



Permissions
1.       For Windows 2008 server, grant ‘read/write’ permission to user everyone for folder ‘C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys’.
2.       For Windows 2003 server, grant ‘read/write’ permission to user everyone for folder ‘C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys’.
3.       Allow firewall to access URL ‘https: //api.sams.itm.test.semantico.net’.  
Installation of client certificate in Personal folder

1.       Open a Command Prompt window.
2.       Type mmc and press the ENTER key. Note that to view certificates in the local machine store; you must be in the Administrator role.
3.       On the File menu, click Add/Remove Snap In.
4.       Click Add.
5.       In the Add Standalone Snap-in dialog box, select Certificates.
6.       Click Add.
7.       In the Certificates snap-in dialog box, select Computer account and click Next.
8.       Now highlight personal
9.       Right click all tasks import.
10.    Select p12 certificate given by Semantico.

Installation of client certificate in Trusted Root Certification Authorities folder

1.       Open a Command Prompt window.
2.       Type mmc and press the ENTER key. Note that to view certificates in the local machine store; you must be in the Administrator role.
3.       On the File menu, click Add/Remove Snap In.
4.       Click Add.
5.       In the Add Standalone Snap-in dialog box, select Certificates.
6.       Click Add.
7.       In the Certificates snap-in dialog box, select Computer account and click Next.
8.       Now highlight Trusted Root Certification Authorities
9.       Right click Certificates, all tasks import.
10.    Select p12 certificate given by Semantico


Installation of MSXML4