public override void ItemUpdated(SPItemEventProperties properties)
{
base.ItemUpdated(properties);
try
{
if (properties.List.Title == "SampleLibrary")
{
SPSite oSite = new SPSite("http://sharepoint:4747/");
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["SampleLibrary"];
SPQuery spQuery = new SPQuery();
spQuery.Query = "<Where><Eq><FieldRef Name='Status' /><Value Type='Text'>Approved</Value></Eq></Where>";
SPListItemCollection items = oList.GetItems(spQuery);
string s = items.Count.ToString();
SPQuery spQuery1 = new SPQuery();
spQuery1.Query = "<Where><Eq><FieldRef Name='Status' /><Value Type='Text'>Approval Rejected</Value></Eq></Where>";
SPListItemCollection items1 = oList.GetItems(spQuery1);
string s1 = items1.Count.ToString();
SPQuery spQuery2 = new SPQuery();
spQuery2.Query = "<Where><Eq><FieldRef Name='Status' /><Value Type='Text'>Draft In Progress</Value></Eq></Where>";
SPListItemCollection items2 = oList.GetItems(spQuery2);
string s2 = items2.Count.ToString();
SPList oList1 = oWeb.Lists["SampleList"];
SPListItem itemToUpdate = oList1.GetItemById(5);
itemToUpdate["Status"] = "Approved";
itemToUpdate["Count"] = s;
itemToUpdate.Update();
SPListItem itemToUpdate1 = oList1.GetItemById(6);
itemToUpdate1["Status"] = "Approval Rejected";
itemToUpdate1["Count"] = s1;
itemToUpdate1.Update();
SPListItem itemToUpdate2 = oList1.GetItemById(7);
itemToUpdate2["Status"] = "Draft In Progress";
itemToUpdate2["Count"] = s2;
itemToUpdate2.Update();
}
}
catch (Exception exe)
{
throw (exe);
}
}
}
}
Thursday, 14 July 2011
Copy the Items from Top Level Site Document Library to Sub Site Document Libtrary through Event Receiver
public override void ItemUpdated(SPItemEventProperties properties)
{
base.ItemUpdated(properties);
try
{
if (properties.List.Title == "SorceLibrary")
{
{
SPSite site1 = new SPSite("http://sharepoint:4747/");
SPWeb web1 = site1.OpenWeb();
SPListItem myitem = properties.ListItem;
if (myitem.File != null)
{
//string libName = "DestLibrary";
SPSite site = new SPSite("http://sharepoint:4747/Products/");
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
// Copy the document to the library
SPFolder library = web.Folders["DestLibrary"];
library.Files.Add(myitem.Name, myitem.File.OpenBinary());
library.Update();
web.AllowUnsafeUpdates = false;
}
}
}
}
catch (Exception exe)
{
throw (exe);
}
}
}
{
base.ItemUpdated(properties);
try
{
if (properties.List.Title == "SorceLibrary")
{
{
SPSite site1 = new SPSite("http://sharepoint:4747/");
SPWeb web1 = site1.OpenWeb();
SPListItem myitem = properties.ListItem;
if (myitem.File != null)
{
//string libName = "DestLibrary";
SPSite site = new SPSite("http://sharepoint:4747/Products/");
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
// Copy the document to the library
SPFolder library = web.Folders["DestLibrary"];
library.Files.Add(myitem.Name, myitem.File.OpenBinary());
library.Update();
web.AllowUnsafeUpdates = false;
}
}
}
}
catch (Exception exe)
{
throw (exe);
}
}
}
What is SharePoint?
"SharePoint is a Microsoft's product to develop portals …. And it can be used also to search information in many places (Notes, SAP, …) … and gives you a complete collaboration environment… And includes some advanced functionality like workflows, web forms, excels on web… "
Subscribe to:
Comments (Atom)