Beispiel #1
0
        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()
                                                  ));
                }
            }
        }
Beispiel #2
0
        public static void LoadListsFromSite()
        {
            // We may get called to reload the information.  Clear any existing stuff.
            Common.ApplicationDS.dtLists.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 listCollectionNode = null;

                try
                {
                    listCollectionNode = listService.GetListCollection().GetXElement();

                    foreach (XElement node in listCollectionNode.DescendantNodes())
                    {
                        Data.ApplicationDS.dtListsRow dtListRow = Common.ApplicationDS.dtLists.NewdtListsRow();
                        PopulateListRow(node, dtListRow);
                        Common.ApplicationDS.dtLists.AdddtListsRow(dtListRow);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Exception: {0}.{1}() - {2}",
                                                  System.Reflection.Assembly.GetExecutingAssembly().FullName,
                                                  System.Reflection.MethodInfo.GetCurrentMethod().Name,
                                                  ex.ToString()
                                                  ));
                }
            }
        }
Beispiel #3
0
        public static XElement GetAllListItems(SharePointWS_Lists.Lists listsService, string listName)
        {
            string viewName = null;

            XElement query      = new XElement("Query");
            XElement viewFields = new XElement("ViewFields");

            // TODO: This is a hack.  Not sure what to do if the list has more than 1000 rows.
            // If you don't specify the rowLimit it defaults to what the "default" view allows unless you
            // specify a different view.

            string rowLimit = "1000";

            XElement queryOptions = new XElement("QueryOptions");
            string   webID        = null;

            try
            {
                return(listsService.GetListItems(listName, viewName, query.GetXmlNode(), viewFields.GetXmlNode(), rowLimit, queryOptions.GetXmlNode(), webID).GetXElement());
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Exception: {0}.{1}() - {2}",
                                              System.Reflection.Assembly.GetExecutingAssembly().FullName,
                                              System.Reflection.MethodInfo.GetCurrentMethod().Name,
                                              ex.ToString()
                                              ));
                return(null);
            }
        }
Beispiel #4
0
        public void FillComboBoxWithListItems(System.Windows.Forms.ComboBox comboBox, string listName)
        {
            // Empty the list first in case already populated.
            comboBox.Items.Clear();

            using (SharePointWS_Lists.Lists listsService = new SharePointWS_Lists.Lists())
            {
                listsService.Credentials = System.Net.CredentialCache.DefaultCredentials;
                listsService.Url         = string.Format("{0}/_vti_bin/Lists.asmx", ucSharePointSites1.Url);;

                //XElement listItems = GetAllListItems(listsService, listName);

                XElement foo         = GetAllListItems(listsService, listName);
                var      elements    = foo.Elements(XName.Get("row", "#RowsetSchema"));
                var      descendents = foo.Descendants(XName.Get("row", "#RowsetSchema"));

                //foreach(XElement node in GetAllListItems(listsService, listName).Elements(XName.Get("row", "#RowsetSchema")))
                //{
                //    comboBox.Items.Add((string)node.Value);
                //}

                foreach (XElement node in descendents)
                {
                    Common.WriteToDebugWindow(String.Format("Title:{0}   Created:{1}   IIPRC Filing?:{2}",
                                                            (string)node.Attribute("ows_Title"), (string)node.Attribute("ows_Created")));
                    comboBox.Items.Add((string)node.Attribute("ows_Title"));
                }
            }
        }
Beispiel #5
0
        // TODO: Consider passing additional arguments to support LocalCheckOut and LastModified time args

        public static void CheckOutFile(string pageUrl)
        {
            using (SharePointWS_Lists.Lists listsService = new SharePointWS_Lists.Lists())
            {
                listsService.Credentials = System.Net.CredentialCache.DefaultCredentials;
                listsService.Url         = string.Format("{0}/_vti_bin/Lists.asmx", SiteURL);

                listsService.CheckOutFile(pageUrl, "false", null);
            }
        }
Beispiel #6
0
 public static XmlNode GetAllListContentTypes(SharePointWS_Lists.Lists listsService, string listName)
 {
     try
     {
         return(listsService.GetListContentTypes(listName, "0x01"));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #7
0
        // TODO: This is not called from anywhere.  Need to test.  Create a test then switch to LINQ
        public static XmlNode GetContentTypeInfo(SharePointWS_Lists.Lists listService, string listName, string contentTypeName)
        {
            XmlNode  contentTypes  = GetAllListContentTypes(listService, listName);
            XElement contentTypes2 = contentTypes.GetXElement();

            string contentTypeID = "";

            foreach (XmlNode node in contentTypes)
            {
                //Common.WriteToDebugWindow(string.Format("Name:{0} ID:{1}", node.Attributes["Name"].Value, node.Attributes["ID"].Value));

                if (node.Attributes["Name"].Value == contentTypeName)
                {
                    contentTypeID = node.Attributes["ID"].Value;
                    break;
                }
            }

            try
            {
                return(listService.GetListContentType(listName, contentTypeID));
            }
            catch (Exception)
            {
                return(null);
            }

            //XmlNode contentTypes = GetAllListContentTypes(listService, listName);
            //string contentTypeID = "";

            //foreach(XmlNode node in contentTypes)
            //{
            //    //Common.WriteToDebugWindow(string.Format("Name:{0} ID:{1}", node.Attributes["Name"].Value, node.Attributes["ID"].Value));

            //    if(node.Attributes["Name"].Value == contentTypeName)
            //    {
            //        contentTypeID = node.Attributes["ID"].Value;
            //        break;
            //    }
            //}

            //try
            //{
            //    return listService.GetListContentType(listName, contentTypeID);
            //}
            //catch(Exception)
            //{
            //    return null;
            //}
        }
Beispiel #8
0
        public static void FillComboBoxWithListItems(System.Windows.Forms.ComboBox comboBox, string listName)
        {
            // Empty the list first in case already populated.
            comboBox.Items.Clear();

            using (SharePointWS_Lists.Lists listsService = new SharePointWS_Lists.Lists())
            {
                listsService.Credentials = System.Net.CredentialCache.DefaultCredentials;
                listsService.Url         = string.Format("{0}/_vti_bin/Lists.asmx", SiteURL);;

                //XElement listItems = GetAllListItems(listsService, listName);

                foreach (XElement node in GetAllListItems(listsService, listName).Elements(XName.Get("row", "#RowsetSchema")))
                {
                    comboBox.Items.Add((string)node.Value);
                }
            }
        }
Beispiel #9
0
        public static void CheckInFile(string pageUrl, string comments, string checkInType)
        {
            using (SharePointWS_Lists.Lists listsService = new SharePointWS_Lists.Lists())
            {
                listsService.Credentials = System.Net.CredentialCache.DefaultCredentials;
                listsService.Url         = string.Format("{0}/_vti_bin/Lists.asmx", SiteURL);

                try
                {
                    listsService.CheckInFile(pageUrl, comments, checkInType);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Exception: {0}.{1}() - {2}",
                                                  System.Reflection.Assembly.GetExecutingAssembly().FullName,
                                                  System.Reflection.MethodInfo.GetCurrentMethod().Name,
                                                  ex.ToString()
                                                  ));
                }
            }
        }