https://www.youtube.com/watch?v=F6BIxHkiHjc&list=PL6n9fhu94yhWKHkcL7RJmmXyxkuFB3KSl&index=34
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();
}
}
}
}
}
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
&& 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.
(
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
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>
<add name="ConnStr" connectionString="server=SQLServerName;User ID=sa;Password=test123&;database=SampleDB;" providerName="SQLOLEDB.1"/>
</connectionStrings>
Subscribe to:
Posts (Atom)