Sunday, 25 December 2016

Find a string by searching all tables in SQL Server


CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN

    CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

    SET NOCOUNT ON

    DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
    SET  @TableName = ''
    SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

    WHILE @TableName IS NOT NULL

    BEGIN
        SET @ColumnName = ''
        SET @TableName =
        (
            SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
            FROM     INFORMATION_SCHEMA.TABLES
            WHERE         TABLE_TYPE = 'BASE TABLE'
                AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
                AND    OBJECTPROPERTY(
                        OBJECT_ID(
                            QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                             ), 'IsMSShipped'
                               ) = 0
        )

        WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)

        BEGIN
            SET @ColumnName =
            (
                SELECT MIN(QUOTENAME(COLUMN_NAME))
                FROM     INFORMATION_SCHEMA.COLUMNS
                WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2)
                    AND    TABLE_NAME    = PARSENAME(@TableName, 1)
                    AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar', 'int', 'decimal')
                    AND    QUOTENAME(COLUMN_NAME) > @ColumnName
            )

            IF @ColumnName IS NOT NULL

            BEGIN
                INSERT INTO #Results
                EXEC
                (
                    'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
                    FROM ' + @TableName + 'WITH (NOLOCK) ' +
                    ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
                )
            END
        END  
    END

    SELECT ColumnName, ColumnValue FROM #Results
END

Then call store proc
exec SearchAllTables '843DE4FEAF494C59A656B4CD4AAB7669'

then delete  store proc and temp tables

Monday, 12 December 2016

ASP.NET MVC makes use of some basic naming conventions for folder names

ASP.NET MVC makes use of some basic naming conventions for folder names:
Folder
Purpose
/Controllers
Controllers respond to input from the browser, decide what to do with it, and return response to the user.
/Views
Views hold our UI templates
/Models
Models hold and manipulate data
/Content
This folder holds our images, CSS, and any other static content
/Scripts
This folder holds our JavaScript files

Monday, 28 November 2016

RDF

Resource Description Framework (RDF) Model and Syntax Specification

https://www.w3.org/TR/1999/REC-rdf-syntax-19990222/#intro

Monday, 21 November 2016

PowerShell Need leading zero

Problem:
SET Today=%date:~4,2%%date:~7,2%%date:~10,4%%time:~0,2%%time:~3,2%%time:~6,5%.log
 echo %today%

If you run above script, you will get space, if the system time is AM.
Solution:
set hour=%time: =0%
SET Today=%date:~-4%%date:~4,2%%date:~7,2%_%hour:~0,2%%time:~3,2%%time:~6,2%.log
echo %Today%

Thursday, 17 November 2016

powershell PSScriptRoot one folder up

$ParentRootPath = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent # This one will give parent parent path
$RootPath = Split-Path $PSScriptRoot -Parent # This one will give parent path

Monday, 14 November 2016

C# Interview

Interview Questions
 1st Interview Questions
1. What are the differences between Abstract class and interface?
2. Why we need to use interface while abstract class is there?
3. Scenarios that we use Abstract class and interface?
4. What is lazy binding and early binding in C#? in other words tell about polymorphism.
5. What are the security mechanisms you follow to secure your application, DB and services?
6. What is SQL injection? and how to prevent it?
7. What are design patterns why we have to use them?
8. Explain three design patterns that you used in recent projects.
9. How do you ensure that you are writing an effective and error free code?
10. How you write your test project?
11. What is the Fake mechanism you use in the test project?
12. What are the the test frameworks you used so far?
13. How do you test the WCF services?
14. What is Agile methodology?
15. What is sprint?
16. How do you estimate your project?
17. How do you identify which sprint has to be delivered first?
19. What is memory leak?
20. What is Garbage collector?
21. Should we have to invoke the Garbage collector?
22. What would happen if the Garbage collector is not there?
23. How do you prevent class from being inherited?
24. Give me an algorithm for sorting mechanism?
25. Explain me about the bubble sort?
26. Is the bubble sort is efficient, if not what other algorithm should we use?
27. How do you ensure that your application is using resources effectively?
28. What are the security mechanism you follow in SQL SERVER?
29. Explain about different security mechanism available in Azure.
30. Have you used Nunit test framework? how did you implement your test project in that?
31. What is MVC?
32. Explain MVC architecture
33. Explain MVC life cycle.
34. Why i should go for MVC?
35. Explain Recursive algorithm
Questions
C# Questions

1.What is Run time polymorphism?
2.What is Compile Time polymorphism?
3.What is the difference between compile time and run time polymorphism?
4.How do you implement run time polymorphism?
5.What if you don't use virtual keyword?Can the method be overridden without using virtual keyword,if yes how?
6.Generics:Very in depth questions on generics ,where it  is inherited from etc.
7.Array declaration syntax.
8.Where is int data type derived from?


LINQ questions
1.Can you use LINQ with arrays.
Yes
Scenario : We have an array with 5 numbers:1,2,3,4,5.How do you write a LINQ query to return numbers >3
2.Do you use LINQ with only Entity Framework?
3.Where can you use LINQ?

Web Services

1.Difference between WCF and REST?
2.Why REST is more advantageous than normal web services, Comparision between web services,WCF and RESTFUL web services?
3.How do you add a web service to your project?
4.Service contract and operation contract differences.
5.What is fault contract?
6.How to access WSDL files?
7.What is WSDL?
8.Questions on svcutil.exe
9.Have you created WSDL files if yes how and how do you access them?
10.In what format data can be returned by WCF services.
11.You have web service which need to return data in two different formats to different clients .How do you do that?
12.You said restful web services don't return unnecessary information like metadata,What is the advantage.Anyways you will only call the methods when you need by creating a proxy and call the corresponding methods then what if metadata is available or not.

Testing:
1.Have you worked with automation testing and how?
2.Difference between TDD AND DDD.Very in depth questions on how you implement it in your project etc.
3.Questions on automation testing.
4.How do you make sure you have written enough test cases to test a particular scenario?
For example : I have a class and method to do simple addition,How many test cases you write and how do you know that you have written appropriate number of test cases.
5.What methods you use to compare the results in test cases?
6.Have you used any tool to verify whether you have written appropriate number of test cases?

General Questions:
1.Why did you mention you are expert in creating web services?
2.How many years of experience you have in web services?
3.Tell me about the projects you have done and technologies you worked with?

 2nd Interview questions

1. What is responsive design?
2. Why we have to use bootstrap?
3. Does angularjs support responsive design?
4. why we have to use angularJs?
5. Does angularJs support javascript?
6. What are the design pattern you worked on?
7. Why we have to go for TDD?
8. Is 100% code coverage possible in TDD? Justify
9. Is 100% code coverage possible in Agile? Justify
10. Why Agile? Justify
11. What is Scrum? 
12. Have you used Inversion of Control? and many arguments on this. Justify
13. What is dependency injection and explain me the scenarios you used it? and why you used it? again arguments on this.
14. What is difference between Async and await and how both are different from Task parallel library?
15. Are we able to use lamba expressions in TPL? if so then TPL is related to LINQ? Justify
16. What are the concepts you worked on Azure? 
17. Is azure deployment is tough, then what else you learned in Azure? Justify
18. What is Azure BLOB and Azure SQL and explain me how you used them in your projects?
19. Many discussions and questions on Interface, classes, properties, inheritance and how you deal with them.
20. What is TypeScript?
21. How you used ajax in MVC?
22. Questions about Repository patterns and its implementations in MVC.
23. What is SOLID principles?
24. What is Open/Close principle? many arguments on this
25. How are you sure that you are writing a good performance code?
26. Is documentation while writing the code is necessary? What if i give self explanatory names for classes and methods
    instead of writing comments? Justify. argument started again
27. Have you used Fake mechanism, and how you implemented it?
28. Explain me complex scenarios in your project? and many scenarios on that.
29. Explain me how you used Async and await in your project.
30. Explain me performance intensive scenarios in your project and how you handled it?
31. How Agile is different from Waterfall?
32. Why i should go for angularJS while javascript is there?
33. What is promise in Javascript?
34. More scenario questions and arguments on C#.
35. More performance questions on .Net and C#.
36. Various implementation scenarios and justifications.

Tuesday, 18 October 2016

cannot convert system collections generic list to type system.web.http.IHttpActionResult web

Your return value is not in right type...
Refer below samples...I am using Item class, which is having 3 properties
public class Item
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public double Price{ get; set; }
    }
---------------------------------------------------------------

private IEnumerable<Item> items = new List<Item>()
        {
            new Item{Id=1,Name="Item1",Price=20.1},
            new Item{Id=2,Name="Item2",Price=20.2},
            new Item{Id=3,Name="Item3",Price=20.3}      
        };
        public IHttpActionResult Get()
        {
            return Ok(items);
        }
        public IHttpActionResult Get(int iid)
        {
            return Ok(items.Where(x => x.Id == iid));
        }
--------------------------------------------------------------
or
--------------------------------------------------------------
  public IEnumerable<Item> Get()
        {
            return items.ToList();
        }
        public IHttpActionResult Get(int id)
        {
            var vitem=items.Where(x => x.Id == id);
            if(vitem==null)
            {
                return NotFound();
            }else
            {
                return Ok(vitem);
            }        
        }

Thursday, 6 October 2016

k2 blackpearl deployment package -Administartor

https://www.youtube.com/watch?v=74-A7EJwX5w

http://www.k2.com/video/shell-oil-workflow-center-of-excellence

K2 blackpearl tutorial leave request

https://www.youtube.com/watch?v=k9XCg0_PDCo
https://www.youtube.com/watch?v=Uiv_P-01YAc

Monday, 19 September 2016

The property item_number must be common to all sources or the property item_number has inappropriate data type

Solution: With poly items, each property called out in the poly item must exist in all of the item types added to it and have the same type in all of the item types

Ex: If you are adding Part, Manufacturer Part and Manufacturer as Poly Sources for Poly item.
Then you should delete Item_number, manufacturer_id and Name from properties under Poly Item.
Mean you should add properties which are common to all Poly Items

Saturday, 10 September 2016

SharePoint Online Pull values from a lookup column using SPServices()

SharePoint Change Order of form items in DispForm.aspx and NewForm.aspx



Open SharePoint Site
Go to the Custom List then Settings-->List Settings
In the settings page Under General Settings section--> Advanced Settings
Under "Content Types"
Select Radio button: Yes (Allow Management of content types-->click OK)
Go back to List Settings page
Under Content Types click on item
You will see: List Content Type page
You see: Column order
Click on "Column order"
Now change the column order

Tuesday, 23 August 2016

AngularJS controller as vs Scope


https://www.youtube.com/watch?v=F6BIxHkiHjc&list=PL6n9fhu94yhWKHkcL7RJmmXyxkuFB3KSl&index=34

Monday, 8 August 2016

SharePoint create folder batch by batch

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;

namespace CreateFolders
{
 
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the URL");
            string strWebURL = Console.ReadLine();
            Console.WriteLine(strWebURL);
            ClientContext objContext = new ClientContext(strWebURL);
            List objList = objContext.Web.Lists.GetByTitle("Programs");
            ListItemCollection objListColl = objList.GetItems(new CamlQuery());
            string[] entityCollection = { "List1", "List2", "List3" }; //List Name
            objContext.Load(objListColl);
            objContext.ExecuteQuery();
            int batchCount = 30;
            foreach (string entityName in entityCollection)
            {
                int i = 0;

                List eachList = objContext.Web.Lists.GetByTitle(entityName);
                ListItemCollection eachItemcollection = objContext.Web.Lists.GetByTitle(entityName).GetItems(new CamlQuery());
                objContext.Load(eachList);
                objContext.Load(eachItemcollection);
                objContext.ExecuteQuery();

                foreach (ListItem programItem in objListColl)
                {

                    string itemid = programItem["ID"].ToString();
                    string title = programItem["Title"].ToString();

                    IEnumerable<ListItem> tempItem = eachItemcollection.AsEnumerable().Where(x => (x["Title"] != null && x["Title"].ToString() == itemid));
                    if (tempItem.Count() == 0)
                    {
                        ListItemCreationInformation itemInfo = new ListItemCreationInformation();
                        itemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
                        itemInfo.LeafName = itemid;
                        ListItem tempListItem = eachList.AddItem(itemInfo);
                        tempListItem["Title"] = itemid;
                        tempListItem["Program"] = itemid + ";#" + title;
                        tempListItem["Author"] = programItem["Author"];
                        tempListItem["Editor"] = programItem["Editor"];
                        tempListItem.Update();
                        i++;
                        if (i % batchCount == 0)
                        {
                            objContext.ExecuteQuery();
                        }
                    }

                }
                if (i % batchCount != 0)
                {
                    objContext.ExecuteQuery();
                }
            }

        }
    }
}

Thursday, 4 August 2016

Aras good tool

Download .exe
Connect to your Aras Innovator instance
You can write AMLs
Run
Get the result

Good one: https://github.com/erdomke/InnovatorAdmin


Sunday, 31 July 2016

C# and condition

C# and condition

&& Operator
This one will validate left had side value, if that value is false then it will not call (or validate) right hand side value. After that, it will validate and condition

& Operator

This one will validate left hand and right hand values, then validate and condition

class LogicalAnd
{
    static void Main()
    {
        // Each method displays a message and returns a Boolean value. 
        // Method1 returns false and Method2 returns true. When & is used,
        // both methods are called. 
        Console.WriteLine("Regular AND:");
        if (Method1() & Method2())
            Console.WriteLine("Both methods returned true.");
        else
            Console.WriteLine("At least one of the methods returned false.");

        // When && is used, after Method1 returns false, Method2 is 
        // not called.
        Console.WriteLine("\nShort-circuit AND:");
        if (Method1() && Method2())
            Console.WriteLine("Both methods returned true.");
        else
            Console.WriteLine("At least one of the methods returned false.");
    }

    static bool Method1()
    {
        Console.WriteLine("Method1 called.");
        return false;
    }

    static bool Method2()
    {
        Console.WriteLine("Method2 called.");
        return true;
    }
}

Thursday, 21 July 2016

Merge multiple rows into one row in a SQL Server

CREATE TABLE ProductsDemo
(
ID INT PRIMARY KEY,
Sno VARCHAR(100),
ProdType VARCHAR(100),
ProdQuantity Int
)
GO


INSERT INTO ProductsDemo
VALUES
(1, '1', 'Dell',2),
(2, '1', 'Lenovo',3) ,
(3, '1', 'Nokia',1),
(4, '1', 'Apple',4),
(5, '1', 'Samsung',1) ,
(6, '2', 'Microsoft',2) ,
(7, '2', 'Logitech',3)
GO

select * from ProductsDemo

 --Dynamic output
SELECT
    Sno,
    STUFF((SELECT CAST(',' AS varchar(max)) + ProdType
            FROM ProductsDemo  as b
            WHERE b.Sno = a.Sno
            FOR XML PATH(''), TYPE
            ).value('.', 'varchar(max)'
         ),1, 1,'') AS ProdType
FROM
    (SELECT DISTINCT Sno FROM ProductsDemo ) AS a;
GO

----Update only ProdType

--UPDATE ProductsDemo SET
-- ProdType=
-- STUFF((SELECT CAST(',' AS varchar(max)) + ProdType
--            FROM ProductsDemo  as b
--            WHERE  ID = 1 or ID=2 or ID=3 or ID=4 or ID= 5
--            FOR XML PATH(''), TYPE
--            ).value('.', 'varchar(max)'
--         ),1, 1,'')
-- WHERE ID = 1

--select * from ProductsDemo

--UPDATE ProductsDemo SET ProdType=
-- STUFF((SELECT CAST(',' AS varchar(max)) + ProdType
--            FROM ProductsDemo  as b
--            WHERE  ID = 6 or ID=7
--            FOR XML PATH(''), TYPE
--            ).value('.', 'varchar(max)'
--         ),1, 1,'')
-- WHERE ID = 6

--select * from ProductsDemo
---------------------------

--Update ProdType With quantity
select * from ProductsDemo
 --Dynamic output
SELECT
    Sno,
    STUFF((SELECT CAST(',' AS varchar(max)) + ProdType
            FROM ProductsDemo  as b
            WHERE b.Sno = a.Sno
            FOR XML PATH(''), TYPE
            ).value('.', 'varchar(max)'
         ),1, 1,'') AS ProdType,
(SELECT  Sum(c.ProdQuantity) from ProductsDemo c
WHERE c.Sno = a.Sno) as RollupQ
FROM
    (SELECT DISTINCT Sno FROM ProductsDemo ) AS a;
GO
select * from ProductsDemo

--Update actual table for ProdType and quantity
UPDATE ProductsDemo SET
ProdType=
 STUFF((SELECT CAST(',' AS varchar(max)) + ProdType
            FROM ProductsDemo  as b
            WHERE  ID = 1 or ID=2 or ID=3 or ID=4 or ID= 5
            FOR XML PATH(''), TYPE
            ).value('.', 'varchar(max)'
         ),1, 1,''),
ProdQuantity=(SELECT  Sum(c.ProdQuantity) from ProductsDemo c
WHERE ID = 1 or ID=2 or ID=3 or ID=4 or ID= 5)
WHERE ID = 1

 select * from ProductsDemo

UPDATE ProductsDemo SET ProdType=
 STUFF((SELECT CAST(',' AS varchar(max)) + ProdType
            FROM ProductsDemo  as b
            WHERE  ID = 6 or ID=7
            FOR XML PATH(''), TYPE
            ).value('.', 'varchar(max)'
         ),1, 1,''),
ProdQuantity=(SELECT  Sum(c.ProdQuantity) from ProductsDemo c
WHERE ID = 6 or ID=7 )
WHERE ID = 6


select * from ProductsDemo

delete from ProductsDemo where ID=7
delete from ProductsDemo where ID=2 or ID=3 or ID=4 or ID=5
select * from ProductsDemo

--delete ProductsDemo
--Drop table ProductsDemo

Note: Problem with above update query, it will merge duplicate ProdTypes, if u want to handle duplicate ProdTypes then change the query.

Monday, 18 July 2016

SQL Server Management Studio path

SQL Server Management Studio path
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft SQL Server 2012

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft SQL Server 2014

Sunday, 3 July 2016

c# web.config connection string .Net 4.5

<connectionStrings>
    <add name="ConnStr" connectionString="server=SQLServerName;User ID=sa;Password=test123&;database=SampleDB;" providerName="SQLOLEDB.1"/>
  </connectionStrings>

Wednesday, 22 June 2016

AngularJS tutorial

https://www.youtube.com/watch?v=zKkUN-mJtPQ&list=PL6n9fhu94yhWKHkcL7RJmmXyxkuFB3KSl

Tuesday, 24 May 2016

c# node.selectnodes add attribute

   Item objItem = _inn.newItem("Identity", "get");
            Item logicItm = objItem.newOR();

            logicItm.setProperty("name", "%Admin%");
            logicItm.setProperty("name", "%Author%");

            Item iChildren = objItem.getLogicalChildren();
            for (int i = 0; i < iChildren.getItemCount(); i++)
            {
                Item iChild = iChildren.getItemByIndex(i);
   
                XmlDocument objXDoc = new XmlDocument();
                XmlAttribute objNewAtt = objXDoc.CreateAttribute("condition");
                objNewAtt.Value = "like";

                XmlNodeList allNames = iChild.node.SelectNodes("name");
                foreach (XmlNode eachName in allNames)
                {
                    eachName.Attributes.SetNamedItem(objNewAtt);
                }

            }
            Item retItm = objItem.apply();

Tuesday, 17 May 2016

How can I get column names from a table in SQL Server?

SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('dbo.yourTableName')


or

  SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
     TABLE_NAME  ='MyTable'
      AND
      TABLE_CATALOG='MyDBName'

Wednesday, 4 May 2016

Friday, 8 April 2016

XSLT Converting Lowercase to Uppercase or Vice Versa

XML Code
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
                <cd>
                                <title>Empire Burlesque</title>
                                <artist>Bob Dylan</artist>
                                <country>USA</country>
                                <company>Columbia</company>
                                <price>10.90</price>
                                <year>1985</year>
                </cd>
                <cd>
                                <title>Hide your heart</title>
                                <artist>Bonnie Tyler</artist>
                                <country>UK</country>
                                <company>CBS Records</company>
                                <price>9.90</price>
                                <year>1988</year>
                </cd>
               
</catalog>

Before XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
      </tr>
      <tr>
        <td><xsl:value-of select="catalog/cd/title"/></td>
        <td><xsl:value-of select="catalog/cd/artist"/></td>
      </tr>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

Added below marked lines of code
After XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
  <html>
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
      </tr>
      <tr>
        <td><xsl:value-of select="catalog/cd/title"/></td>
        <td><xsl:value-of select="catalog/cd/artist"/></td>
<td><xsl:value-of select="translate(catalog/cd/artist, $smallcase, $uppercase)"/></td>
<td><xsl:value-of select="translate(catalog/cd/artist, $uppercase,$smallcase)"/></td>
      </tr>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>



Thursday, 7 April 2016

Open a port in Windows Firewall

http://windows.microsoft.com/en-us/windows/open-port-windows-firewall#1TC=windows-7

Wednesday, 6 April 2016

C# How to convert WSDL to SVC



Assuming you are having .wsdl file at location "E:\" for ease in access further.
Prepare the command for each .wsdl file as: E:\YourServiceFileName.wsdl
Permissions: Assuming you are having the Administrative rights to perform permissions. Open directory : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin
Right click to amd64 => Security => Edit => Add User => Everyone Or Current User => Allow all permissions => OK.
Prepare the Commands for each file in text editor as: wsdl.exe E:\YourServiceFileName.wsdl /l:CS /server.
Now open Visual studio command prompt from : C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\VS2013 x64 Native Tools Command Prompt.
Execute above command.
Go to directory : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64, Where respective .CS file should be generated.
Move generated CS file to appropriate location.

Thursday, 24 March 2016

c# nested dictionary foreach key value pair

 Dictionary<string, Dictionary<string, string>> objData = new Dictionary<string, Dictionary<string, string>>();

//Assign data to  nested dictionary
                        objData.Add("A1", new Dictionary<string, string>() { { "motor1", "A1" } });
                        objData["A1"].Add("motor2", "A2");
                        objData["A1"].Add("motor3", "A3");

                        objData.Add("B1", new Dictionary<string, string>() { { "motorb1", "B1" } });
                        objData["B1"].Add("motorb2", "B2");
                        objData["B1"].Add("motorb3", "B3");


//Read data from  nested dictionary
                        foreach (var outerDict in objData)
                        {
                            var innerDict = outerDict.Value;

                            foreach (var innerDictValue in innerDict)
                            {
                                Console.WriteLine(outerDict.Key + " " + innerDictValue.Key + " " + innerDictValue.Value);
                            }
                        }

Sunday, 20 March 2016

C# .Net execute from command line



Open CMD.
c:\users\test\Documents>
Open Notepad. Ex:
c:\users\test\Documents>notepad hello.cs

Write sample code.
Ex:

using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello");
}
}

Save hello.cs
c:\users\test\Documents>

Now in the CMD execute .net exe.

Ex: C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe

now call hello.exe
c:\users\test\Documents> hello.exe

You will get the output Hello



Tuesday, 8 March 2016

I have 300K records in SQL, out of that 1k records are having wrong data in one column. How you are going to fix it.



Try this...You may have better approach, but this is one approach.

1.Get right data from Source System to flat file with primary key value and column value.
EX: Employee Location is wrong, in this scenario, prepare a flat file with Epmid and EmpLocation.
2.Import above data in to same DB where your 300k records table is there
3.Now you are having 2 tables (One is actual and another one is imported table)
4.Now compare the 2 tables to find are there any data difference.
5.If you find data difference, now update actual table (300k) with imported table
6.Now compare the 2 tables to find are there any data difference, it should give 0 differences..

Monday, 7 March 2016

Using HTTP Methods (GET, POST, PUT, etc.) in Web API

http://www.exceptionnotfound.net/using-http-methods-correctly-in-asp-net-web-api/

HTTP Overview


The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. This is the foundation for data communication for the World Wide Web (i.e. internet) since 1990. HTTP is a generic and stateless protocol which can be used for other purposes as well using extensions of its request methods, error codes, and headers.
Basically, HTTP is a TCP/IP based communication protocol, that is used to deliver data (HTML files, image files, query results, etc.) on the World Wide Web. The default port is TCP 80, but other ports can be used as well. It provides a standardized way for computers to communicate with each other. HTTP specification specifies how clients' request data will be constructed and sent to the server, and how the servers respond to these requests.

Basic Features

There are three basic features that make HTTP a simple but powerful protocol:
  • HTTP is connectionless: The HTTP client, i.e., a browser initiates an HTTP request and after a request is made, the client disconnects from the server and waits for a response. The server processes the request and re-establishes the connection with the client to send a response back.
  • HTTP is media independent: It means, any type of data can be sent by HTTP as long as both the client and the server know how to handle the data content. It is required for the client as well as the server to specify the content type using appropriate MIME-type.
  • HTTP is stateless: As mentioned above, HTTP is connectionless and it is a direct result of HTTP being a stateless protocol. The server and client are aware of each other only during a current request. Afterwards, both of them forget about each other. Due to this nature of the protocol, neither the client nor the browser can retain information between different requests across the web pages.
HTTP/1.0 uses a new connection for each request/response exchange, where as HTTP/1.1 connection may be used for one or more request/response exchanges.

Basic Architecture

The following diagram shows a very basic architecture of a web application and depicts where HTTP sits:
HTTP Architecture
The HTTP protocol is a request/response protocol based on the client/server based architecture where web browsers, robots and search engines, etc. act like HTTP clients, and the Web server acts as a server.

Client

The HTTP client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like message containing request modifiers, client information, and possible body content over a TCP/IP connection.

Server

The HTTP server responds with a status line, including the message's protocol version and a success or error code, followed by a MIME-like message containing server information, entity meta information, and possible entity-body content.

Ref: http://www.tutorialspoint.com/http/http_overview.htm

Sunday, 6 March 2016

Web API

http://www.c-sharpcorner.com/UploadFile/4d9083/how-to-create-web-api-in-Asp-Net-mvc/
http://www.c-sharpcorner.com/UploadFile/2b481f/testing-of-Asp-Net-web-api-method/

Friday, 4 March 2016

Aras ApplySQL

Open AML Studio
Connect any Aras instance
Select "ApplySQL"
Use below sample query to run SQL statements
<sql>
  update MANUFACTURER_PART with (rowlock) set MODIFIED_ON = '2009-03-27 11:05:00.000' where id = '12345#######'
</sql>

Tuesday, 1 March 2016

Aras Item update using AML

Step 1 lock: It will lock all revs of documents
<Item type="Document" action="lock" where="[Document].item_number='ABC'"></Item>

Step 2 Find user locked_by_id:
<Item action="get" type="Document"" where="[Document"].item_number='ABC'" select="locked_by_id">
</Item>

Now- you will get the result as below:

<locked_by_id keyed_name="test User" type="User">USERID456</locked_by_id>

Note down this Id, you will use in step 4

Step 3 update document with different owned_by_id:

<Item type="Document" action="update" version="0" where="[Document].item_number='ABC' and [Document].generation='1'"><owned_by_id>GUID123</owned_by_id></Item>

Note: Use: version="0", so that it will not generate new rev.

Step 4 unlock the item: It will unlock all revs
<Item type="document" action="unlock" where="[document].locked_by_id='USERID456'"></Item>

Monday, 29 February 2016

Saturday, 27 February 2016

Jumpstart KnockoutJS with ASP.NET MVC/Web Api


http://www.codeproject.com/Articles/755386/Jumpstart-KnockoutJS-with-ASP-NET-MVC-Web-Api
http://www.devcurry.com/2013/08/building-knockoutjs-based-client-for_16.html

Friday, 26 February 2016

Single Page Application with ASP.NET Web API and Angular.js


http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/build-a-single-page-application-spa-with-aspnet-web-api-and-angularjs


C# Tutorials

https://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx

Thursday, 25 February 2016

C# Single Page Application

Single Page Application: KnockoutJS
http://www.asp.net/single-page-application/overview/introduction/knockoutjs-template


Single Page Application (SPA) Using AngularJS
http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/single-page-application-spa-using-angularjs-web-api-and-m/

Monday, 22 February 2016

C# WEB API

http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api

https://msdn.microsoft.com/en-us/library/hh833994(v=vs.108).aspx

Sunday, 21 February 2016

Accenture .Net interview questions

Data Structure & Algorithms
c# exceptional handling
Structured Exception Handling in C#
abstract class and interface difference
c# must implement method
c# must inherit
advantages of using interfaces c#
c# stack and heap
c# how to change stack to head
c# how to change heap to stack
c# struct vs class
c# struct data type
c# finalize vs dispose
c# close and dispose
c# generics
c# garbage collector
if i write custom class, should i use dispose or not? Why?
c# using
c# idisposable
c# asynchronous programming
C# how to wait for asynchronous method response in main method
asp.net viewstate
asp.net how to hide view state
how to find duplicate values in Array, write logic
asp.net session management
asp.net page life cycle
asp.net global.asax
How can i capture exception in asp.net global.asax

Wednesday, 17 February 2016

C# difference between connection.close() and connection.Dispose()

conn.Close(); //If you use this, no need to initialize SqlConnection , you can open using conn.Open();

//conn.Dispose();//If you use this, it completely release the connection object and cannot be reopen just calling Open method. We will have re-initialize the Connection object


So always use conn.Close();

Sample code............


using System;using System.Data;using System.Data.SqlClient;/// <summary>
///
 Demonstrates how to work with SqlConnection objects/// </summary>class SqlConnectionDemo
{
    static void Main()
    {
        // 1. Instantiate the connection        SqlConnection conn = new SqlConnection(
            
"Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI");

        SqlDataReader rdr = 
null;
        try
        {            // 2. Open the connection            conn.Open();
            // 3. Pass the connection to a command object
            SqlCommand cmd = new SqlCommand("select * from Customers", conn);
            //
            // 4. Use the connection
            //

            // get query results
            rdr = cmd.ExecuteReader();
            // print the CustomerID of each record
            while (rdr.Read())
            {
                
Console.WriteLine(rdr[0]);
            }
        }
        finally        {            // close the reader            if (rdr != null)
            {
                rdr.Close();
            }

            // 5. Close the connection
            if (conn != null)
            {
                
conn.Close(); //If you use this, no need to initialize SqlConnection , you can open using conn.Open();

//conn.Dispose();//If you use this, it completely release the connection object and cannot be reopen just calling Open method. We will have re-initialize the Connection object
            }
        }
    }
}