# Thursday, May 28, 2009

posted on Thursday, May 28, 2009 11:23:31 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Sunday, May 24, 2009
sitesWebServiceLists.Lists listService = new sitesWebServiceLists.Lists();
listService.Credentials =
System.Net.CredentialCache.DefaultCredentials;

listService.Url = http://MyServer/sites/MySiteCollection/_vti_bin/Lists.asmx;
System.Xml.XmlNode ndListView = listService.GetListAndView("MyList", "");
string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
batchElement.SetAttribute("OnError", "Continue");
batchElement.SetAttribute("ListVersion", "1");

batchElement.SetAttribute("ViewName", strViewID);
batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
   "<Field Name='ID'>6</Field>" +
   "<Field Name='Title'>Modified sixth item</Field></Method>" +
   "<Method ID='2' Cmd='Update'><Field Name='ID'>7</Field>" +
   "<Field Name='Title'>Modified seventh item</Field></Method>" +
   "<Method ID='3' Cmd='Delete'><Field Name='ID'>5</Field>" +
   "</Method><Method ID='4' Cmd='New'>" +
   "<Field Name='Title'>Added item</Field></Method>";

try
{
   listService.UpdateListItems(strListID, batchElement);
}
catch (SoapServerException ex)
{
   MessageBox.Show(ex.Message);
}
posted on Sunday, May 24, 2009 11:22:32 AM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
# Friday, May 22, 2009

listsWS. Lists   listService = new listsWS. Lists() ;
listService.Url =  "http://litwareportal/<your_site>/_vti_bin/lists.asmx" ;
listService.Credentials =  new  System.Net.NetworkCredential( "Administrator" ,  "Pa$$w0rd" , "LITWAREINC" );

XmlDocument   doc =  new   XmlDocument () ;
XmlNode   viewFieldsParent = doc.CreateElement( "ViewFields" );
viewFieldsParent.InnerXml =
"<FieldRef Name=\"Author\"/>" +
"<FieldRef Name=\"BookName\"/>" +
"<FieldRef Name=\"PageCount\"/>";


XmlNode listItems = listService.GetListItems( "Books" ,  "" , null, viewFieldsParent,  "0" , null,  "" );

foreach  ( XmlNode   item  in  listItems.SelectNodes( "//*[local-name()='row']" ))
{
Console .WriteLine( "Author: "  + item.Attributes.GetNamedItem( "ows_Author" ).Value);
Console .WriteLine( "Book Name: "  + item.Attributes.GetNamedItem( "ows_BookName" ).Value);
Console .WriteLine( "Page Count: "  + item.Attributes.GetNamedItem( "ows_PageCount" ).Value);
Console .WriteLine( "#####################################" );
}

Console .ReadLine();

posted on Friday, May 22, 2009 11:22:04 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Wednesday, May 20, 2009
SPWeb objWeb = SPContext.Current.Web;
SPNavigationNodeCollection topNavigationNodes = objWeb.Navigation.TopNavigationBar;
SPNavigationNode objItem = new SPNavigationNode("Başlık", "Adres", false);
topNavigationNodes.AddAsFirst(objItem); objWeb.Update();
posted on Wednesday, May 20, 2009 11:21:40 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Monday, May 18, 2009

If you want to modify your sharepoint view to only show items created in the current month, you can create two calculated columns that returns "First Day of Month" and "Last Day of Month". And then add a filter on your view to create filtered view that shows only the current month's items. 

In calculated fields you can use the following formulas to get first day of month and last day of month.

First Day of Current Month Formula

=DATE(YEAR([Created]), MONTH([Created]), 1) 

Last Day of Current Month Formula 

=DATE(YEAR([Created]), MONTH([Created])+1,1)-1

posted on Monday, May 18, 2009 11:20:58 AM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
# Sunday, May 17, 2009
public void  UploadFile(string srcUrl, string destUrl)
{
    if (!File.Exists(srcUrl))
    {
        throw new ArgumentException(String.Format("{0} does not exist", srcUrl), "srcUrl");
    }
 
      

   
SPWeb site = new SPSite(destUrl).OpenWeb();
 
    
    
FileStream fStream = File.OpenRead(srcUrl);
    byte[] contents = new byte[fStream.Length];
    fStream.Read(contents, 0, (int)fStream.Length);
    fStream.Close();
     EnsureParentFolder(site, destUrl);
    site.Files.Add(destUrl, contents);
}
posted on Sunday, May 17, 2009 11:20:18 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Saturday, May 16, 2009
SPSite mySite = SPContext.Current.Site;
SPWebCollection allWebs = mySite.AllWebs;
 

foreach (SPWeb web in allWebs)
{
    SPListCollection allLists = web.Lists;
 
    

    
for (int i=0; i<allLists.Count; i++)
    {
        SPList list = allLists[i];
 
        

        
if (list.Title == TextBox1.Text)
        {
            Guid listGuid = list.ID;
            allLists.Delete(listGuid);
        }
    }
}
posted on Saturday, May 16, 2009 11:19:47 AM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
# Sunday, May 10, 2009
string listTitle = TextBox1.Text.ToString();
string listDescription = TextBox2.Text.ToString();
SPSite mySite = SPContext.Current.Site;
SPWebCollection allWebs = mySite.AllWebs;
 

foreach (SPWeb web in allWebs)
{
    SPListCollection allLists = web.Lists;
    allLists.Add(listTitle,listDescription, SPListTemplateType.GenericList);
}
posted on Sunday, May 10, 2009 11:19:19 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Friday, May 08, 2009
SPWeb mySite = SPContext.Current.Web;
SPListItemCollection listItems = mySite.Lists[TextBox1.Text].Items;
int itemCount = listItems.Count;
 

for (int k=0; k<itemCount; k++)
{
    SPListItem item = listItems[k];
 
    

   
if (TextBox2.Text==item["Employee"].ToString())
    {
        listItems.Delete(k);
    }
}
posted on Friday, May 08, 2009 11:18:45 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Wednesday, May 06, 2009
SPWeb mySite = SPContext.Current.Web;
SPListItemCollection listItems = mySite.Lists[TextBox1.Text].Items;
 
SPListItem item = listItems.Add(); item["Title"] = TextBox2.Text;
item["Stock"] = Convert.ToInt32(TextBox3.Text);
item["Return Date"] = Convert.ToDateTime(TextBox4.Text);
item["Employee"] = TextBox5.Text;
item.Update();
posted on Wednesday, May 06, 2009 11:18:15 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Tuesday, May 05, 2009

SPWeb mySite = SPContext.Current.Web;
SPListCollection lists = mySite.Lists;

string listTitle = TextBox1.Text;
string listDescription = TextBox2.Text;
string listType = ListBox1.SelectedItem.Text;

SPListTemplateType listTemplateType = new SPListTemplateType();

switch(listType)
{
    case "Generic List":
    {
        listTemplateType = SPListTemplateType.GenericList;
        break;
    }

    case "Events":
    {
        listTemplateType = SPListTemplateType.Events;
        break;
    }

    case "Announcements":
    {
        listTemplateType = SPListTemplateType.Announcements;
        break;
    }
}

lists.Add(listTitle, listDescription, listTemplateType);

posted on Tuesday, May 05, 2009 11:17:57 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Monday, May 04, 2009

SP 2 for Microsoft Office Sharepoint Server 2007 and Windows Sharepoint Services 3.0 has been released.

KB Article Links

Description of Windows SharePoint Services 3.0 SP2 and of Windows SharePoint Services 3.0 Language Pack SP2 
http://support.microsoft.com/kb/953338  
Description of 2007 Microsoft Office servers Service Pack 2 (SP2) and of 2007 Microsoft Office servers Language Pack Service Pack 2 (SP2) 
http://support.microsoft.com/kb/953334

Download Links

Service Pack 2 for Windows SharePoint Services 3.0, x86 & x64 
http://www.microsoft.com/downloads/details.aspx?FamilyId=79BADA82-C13F-44C1-BDC1-D0447337051B&displaylang=en

Service Pack 2 for Office SharePoint Server 2007, x86 & x64 
http://www.microsoft.com/downloads/details.aspx?FamilyId=B7816D90-5FC6-4347-89B0-A80DEB27A082&displaylang=en

Slipstream Builds For Windows SharePoint Services 3.0

Windows SharePoint Services 3.0 with SP2, x64 
http://www.microsoft.com/downloads/details.aspx?FamilyId=9FB41E51-CB03-4B47-B89A-396786492CBA&displaylang=en  
Windows SharePoint Services 3.0 with SP2, x86 

http://www.microsoft.com/downloads/details.aspx?FamilyId=EF93E453-75F1-45DF-8C6F-4565E8549C2A&displaylang=en  

You can find detailed information on Microsoft Sharepoint Team's Blog 

posted on Monday, May 04, 2009 11:28:10 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Saturday, May 02, 2009
sitesWebServiceLists.Lists listService = new sitesWebServiceLists.Lists();
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
listService.Url = "http://MyServer/sites/MySiteCollection/_vti_bin/Lists.asmx";  
System.Xml.XmlNode ndListView = listService.GetListAndView("MyList", "");
string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;
 
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement batchElement = doc.CreateElement("Batch");

batchElement.SetAttribute("OnError", "Continue");
batchElement.SetAttribute("ListVersion", "1");

batchElement.SetAttribute("ViewName", strViewID);
  batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
   "<Field Name='ID'>6</Field>" +
   "<Field Name='Title'>Modified sixth item</Field></Method>" +
   "<Method ID='2' Cmd='Update'><Field Name='ID'>7</Field>" +
   "<Field Name='Title'>Modified seventh item</Field></Method>" +
   "<Method ID='3' Cmd='Delete'><Field Name='ID'>5</Field>" +
   "</Method><Method ID='4' Cmd='New'>" +
   "<Field Name='Title'>Added item</Field></Method>";

try
{
   listService.UpdateListItems(strListID, batchElement);
}
catch (SoapServerException ex)
{
   MessageBox.Show(ex.Message);
}
posted on Saturday, May 02, 2009 11:16:52 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Friday, May 01, 2009
Web_Reference.Lists myservice = new Web_Reference.Lists();
myservice.Credentials = System.Net.CredentialCache.DefaultCredentials;
listService.Url = "http://Server_Name/Subsite_Name/_vti_bin/Lists.asmx";
System.Xml.XmlNode node = myservice.GetListCollection();
 

foreach(System.Xml.XmlNode xmlnode in node) 
{
   label1.Text+=xmlnode.Attributes["Title"].Value + "\n";
}
posted on Friday, May 01, 2009 11:16:31 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback