Exemple #1
0
 /// <summary>
 /// Deserializes workflow markup into an tUrl object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output tUrl object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out tUrl obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(tUrl);
     try {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
Exemple #2
0
 public static bool LoadFromFile(string fileName, out tUrl obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
Exemple #3
0
 public static bool LoadFromFile(string fileName, out tUrl obj, out System.Exception exception)
 {
     return(LoadFromFile(fileName, Encoding.UTF8, out obj, out exception));
 }
Exemple #4
0
 /// <summary>
 /// Deserializes xml markup from file into an tUrl object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output tUrl object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out tUrl obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(tUrl);
     try {
         obj = LoadFromFile(fileName, encoding);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
Exemple #5
0
 public static bool Deserialize(string xml, out tUrl obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }
        private void BuildSiteMap()
        {
            urlset sitemap = new urlset();

            //Guid siteId = SPContext.Current.Site.ID;
            //Guid webId = SPContext.Current.Web.ID;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteId))
                {
                    using (SPWeb web = site.OpenWeb(webId))
                    {
                        foreach (SPList list in web.Lists)
                        {
                            if (ContainsWebPageTypes(list))
                            {
                                SPListItemCollection items = null;

                                SPQuery query        = new SPQuery();
                                query.ViewAttributes = "Scope=\"Recursive\"";
                                query.Query          = "<Where><IsNotNull><FieldRef Name=\"PublishingPageDesign\" /></IsNotNull></Where>";
                                query.ViewFields     = "<FieldRef Name=\"Title\"/><FieldRef Name=\"EncodedAbsUrl\"/><FieldRef Name=\"FileRef\"/><FieldRef Name=\"ContentType\"/><FieldRef Name=\"Created\"/><FieldRef Name=\"Modified\"/>";
                                items = list.GetItems(query);

                                foreach (SPListItem item in items)
                                {
                                    List <SemanticUrl> entries = new List <SemanticUrl>();
                                    if (item.File.Exists && item.File.Level == SPFileLevel.Published)
                                    {
                                        entries = CheckSemantics(item.File.ServerRelativeUrl.ToLower().ToString());

                                        if (entries != null && entries.Count > 0)
                                        {
                                            foreach (SemanticUrl surl in entries)
                                            {
                                                tUrl url = new tUrl();
                                                url.changefreqSpecified = true;
                                                url.changefreq          = DetermineFrequency(item["Created"].ToString(), item["Modified"].ToString(), item.Versions.Count);
                                                url.lastmod             = DateTime.Parse(item["Modified"].ToString()).ToString("yyyy-MM-dd");//,.ToShortDateString();
                                                url.loc = surl.Semantic;
                                                url.prioritySpecified = true;
                                                url.priority          = new decimal(0.5f);
                                                if (!sitemap.url.Contains(url))
                                                {
                                                    sitemap.url.Add(url);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            tUrl url = new tUrl();
                                            url.changefreqSpecified = true;
                                            url.changefreq          = DetermineFrequency(item["Created"].ToString(), item["Modified"].ToString(), item.Versions.Count);
                                            url.lastmod             = DateTime.Parse(item["Modified"].ToString()).ToString("yyyy-MM-dd");//,.ToShortDateString();
                                            url.loc = item["EncodedAbsUrl"].ToString();
                                            url.prioritySpecified = true;
                                            url.priority          = new decimal(0.5f);
                                            if (!sitemap.url.Contains(url))
                                            {
                                                sitemap.url.Add(url);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });

            textWriter.Append(sitemap.Serialize(Encoding.UTF8));
        }