public static void LoadPagesFromSite() { // We may get called to reload the information. Clear any existing stuff. Common.ApplicationDS.dtPages.Clear(); using (SharePointWS_Lists.Lists listService = new SharePointWS_Lists.Lists()) { listService.Credentials = System.Net.CredentialCache.DefaultCredentials; listService.Url = string.Format("{0}/_vti_bin/Lists.asmx", SiteURL); XElement pagesXElement = null; try { pagesXElement = GetAllListItems(listService, "Pages"); foreach (XElement page in pagesXElement.Descendants(XName.Get("row", "#RowsetSchema"))) { Data.ApplicationDS.dtPagesRow pageRow = Common.ApplicationDS.dtPages.NewdtPagesRow(); PopulatePageRow(page, pageRow); Common.ApplicationDS.dtPages.AdddtPagesRow(pageRow); } } catch (Exception ex) { MessageBox.Show(string.Format("Exception: {0}.{1}() - {2}", System.Reflection.Assembly.GetExecutingAssembly().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.ToString() )); } } }
public static void PopulatePageRow(XElement page, Data.ApplicationDS.dtPagesRow pageRow) { //// TODO: Until we figure out how to determine if page is checked out, just default this to false //pageRow.CheckedOut = false; //pageRow.ContentTypeId = (string)page.Attribute("ows_ContentTypeId"); //pageRow.ContentTypeId = (string)page.Attribute("ows_ContentTypeId"); //pageRow.FileLeafRef = (string)page.Attribute("ows_FileLeafRef"); //pageRow.ModifiedBy = (string)page.Attribute("ows_Modified_x0020_By"); //pageRow.CreatedBy = (string)page.Attribute("ows_Created_x0020_By"); //pageRow.FileType = (string)page.Attribute("ows_File_x0020_Type"); //pageRow.Title = (string)page.Attribute("ows_Title"); //pageRow.PublishingContact = (string)page.Attribute("ows_PublishingContact"); //pageRow.PublishingPageLayout = (string)page.Attribute("ows_PublishingPageLayout"); //pageRow.ContentType = (string)page.Attribute("ows_ContentType"); //// Not all values are populated //// TODO: Read about casting versus .Value. Casting seems to quietly deal with the not present problem. //try //{ // pageRow.PageType = (string)page.Attribute("ows_PageType"); //} //catch //{ // pageRow.PageType = "<none>"; //} //try //{ // pageRow.AppName = (string)page.Attribute("ows_AppName"); //} //catch //{ // pageRow.AppName = ""; //} //try //{ // pageRow.Project = (string)page.Attribute("ows_Project"); //} //catch //{ // pageRow.Project = ""; //} //try //{ // pageRow.Release = (string)page.Attribute("ows_Release"); //} //catch //{ // pageRow.Release = ""; //} //try //{ // pageRow.TeamName = (string)page.Attribute("ows_TeamName"); //} //catch //{ // pageRow.TeamName = ""; //} //pageRow.BusinessOwner = (string)page.Attribute("ows_Business_x0020_Owner"); //pageRow.PageState = (string)page.Attribute("ows_Page_x0020_State"); //pageRow.ID = (string)page.Attribute("ows_ID"); //pageRow.Created = (string)page.Attribute("ows_Created"); //pageRow.Author = (string)page.Attribute("ows_Author"); //pageRow.Modified = (string)page.Attribute("ows_Modified"); //pageRow.Editor = (string)page.Attribute("ows_Editor"); //pageRow.ModerationStatus = (string)page.Attribute("ows__ModerationStatus"); //pageRow.FileRef = (string)page.Attribute("ows_FileRef"); //pageRow.FileDirRef = (string)page.Attribute("ows_FileDirRef"); //pageRow.LastModified = (string)page.Attribute("ows_Last_x0020_Modified"); //pageRow.CreatedDate = (string)page.Attribute("ows_Created_x0020_Date"); //pageRow.FileSize = (string)page.Attribute("ows_File_x0020_Size"); //pageRow.FSObjType = (string)page.Attribute("ows_FSObjType"); //pageRow.PermMask = (string)page.Attribute("ows_PermMask"); //pageRow.CheckedOutUserId = (string)page.Attribute("ows_CheckedOutUserId"); //pageRow.IsCheckedoutToLocal = (string)page.Attribute("ows_IsCheckedoutToLocal"); //pageRow.UniqueId = (string)page.Attribute("ows_UniqueId"); //pageRow.ProgId = (string)page.Attribute("ows_ProgId"); //pageRow.ScopeId = (string)page.Attribute("ows_ScopeId"); //pageRow.VirusStatus = (string)page.Attribute("ows_VirusStatus"); //pageRow.CheckedOutTitle = (string)page.Attribute("ows_CheckedOutTitle"); //pageRow.CheckinComment = (string)page.Attribute("ows__CheckinComment"); //pageRow.EditMenuTableStart = (string)page.Attribute("ows__EditMenuTableStart"); //pageRow.EditMenuTableEnd = (string)page.Attribute("ows__EditMenuTableEnd"); //pageRow.LinkFilenameNoMenu = (string)page.Attribute("ows_LinkFilenameNoMenu"); //pageRow.LinkFilename = (string)page.Attribute("ows_LinkFilename"); //pageRow.DocIcon = (string)page.Attribute("ows_DocIcon"); //pageRow.ServerUrl = (string)page.Attribute("ows_ServerUrl"); //pageRow.EncodedAbsUrl = (string)page.Attribute("ows_EncodedAbsUrl"); //pageRow.BaseName = (string)page.Attribute("ows_BaseName"); //pageRow.FileSizeDisplay = (string)page.Attribute("ows_FileSizeDisplay"); //pageRow.MetaInfo = (string)page.Attribute("ows_MetaInfo"); //pageRow.Level = (string)page.Attribute("ows__Level"); //pageRow.IsCurrentVersion = (string)page.Attribute("ows__IsCurrentVersion"); //pageRow.SelectTitle = (string)page.Attribute("ows_SelectTitle"); //pageRow.SelectFilename = (string)page.Attribute("ows_SelectFilename"); //pageRow.owshiddenversion = (string)page.Attribute("ows_owshiddenversion"); //pageRow.UIVersion = (string)page.Attribute("ows__UIVersion"); //pageRow.UIVersionString = (string)page.Attribute("ows__UIVersionString"); //pageRow.Order = (string)page.Attribute("ows_Order"); //pageRow.GUID = (string)page.Attribute("ows_GUID"); //pageRow.WorkflowVersion = (string)page.Attribute("ows_WorkflowVersion"); //pageRow.ParentVersionString = (string)page.Attribute("ows_ParentVersionString"); //pageRow.ParentLeafName = (string)page.Attribute("ows_ParentLeafName"); //pageRow.Combine = (string)page.Attribute("ows_Combine"); //pageRow.RepairDocument = (string)page.Attribute("ows_RepairDocument"); // Not sure how this could have every worked as there is no xmlns:z attribute?? //try //{ // pageRow.xmlnsz = node.Attributes["xmlns:z"].Value; //} //catch(Exception) //{ // pageRow.xmlnsz = ""; //} //try //{ // Common.WriteToDebugWindow(String.Format(" CheckedOutUserId:{0}", node.Attributes["ows_CheckedOutUserId"].Value)); // try // { // Common.WriteToDebugWindow(string.Format(" CheckoutUser:{0}", node.Attributes["ows_CheckoutUser"].Value)); // pageRow.CheckedOut = true; // } // catch (Exception) // { // pageRow.CheckedOut = false; // } //} }