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 BuildNewsMap()
        {
            News.urlset newsmap = new News.urlset();

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

            string geo_location = string.Format("{0},{1},{2}", company.City, company.State, company.Country);;

            geo_location = geo_location.TrimStart(new char[] { ',' });
            geo_location = geo_location.TrimEnd(new char[] { ',' });

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteId))
                {
                    SPWebCollection webs = site.AllWebs;

                    foreach (SPWeb aweb in webs)
                    {
                        using (SPWeb web = site.OpenWeb(aweb.ID))
                        {
                            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=\"keywords\"/><FieldRef Name=\"EncodedAbsUrl\"/><FieldRef Name=\"FileRef\"/><FieldRef Name=\"ContentType\"/><FieldRef Name=\"Created\"/>";
                                    items = list.GetItems(query);

                                    try
                                    {
                                        foreach (SPListItem item in items)
                                        {
                                            List <SemanticUrl> entries = new List <SemanticUrl>();

                                            if (item.File.Exists && item.File.Level == SPFileLevel.Published && (item.File.TimeLastModified >= (DateTime.Now.AddDays(-3))))
                                            {
                                                try
                                                {
                                                    CultureInfo info = new CultureInfo((int)SPContext.Current.Web.RegionalSettings.LocaleId);
                                                    //CultureInfo info = System.Globalization.CultureInfo.GetCultureInfo((int)web.Language);
                                                    entries = CheckSemantics(item.File.ServerRelativeUrl.ToLower().ToString());

                                                    if (entries != null && entries.Count > 0)
                                                    {
                                                        foreach (SemanticUrl surl in entries)
                                                        {
                                                            News.tUrl url            = new News.tUrl();
                                                            url.loc                  = surl.Semantic;
                                                            url.news.accessSpecified = false;
                                                            url.news.genres          = DetermineGenres(item);

                                                            if (item.Fields.ContainsField("keywords"))
                                                            {
                                                                object words = item["keywords"];
                                                                if (words != null)
                                                                {
                                                                    url.news.keywords += GetAutoKeywords(words.ToString(), item);
                                                                }
                                                            }

                                                            url.news.publication.name     = web.Title.ToString();
                                                            url.news.accessSpecified      = false;
                                                            url.news.publication.language = info.TwoLetterISOLanguageName;
                                                            url.news.publication_date     = DateTime.Parse(item[SPBuiltInFieldId.Modified].ToString()).ToString("yyyy-MM-dd");

                                                            if (!String.IsNullOrEmpty(company.Stock))
                                                            {
                                                                url.news.stock_tickers = company.Stock;
                                                            }

                                                            if (!string.IsNullOrEmpty(geo_location))
                                                            {
                                                                url.news.geo_location = geo_location;
                                                            }

                                                            url.news.title = item[SPBuiltInFieldId.Title].ToString();
                                                            newsmap.url.Add(url);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        News.tUrl url            = new News.tUrl();
                                                        url.loc                  = item["EncodedAbsUrl"].ToString();
                                                        url.news.accessSpecified = false;
                                                        url.news.genres          = DetermineGenres(item);

                                                        if (item.Fields.ContainsField("keywords"))
                                                        {
                                                            object words = item["keywords"];
                                                            if (words != null)
                                                            {
                                                                url.news.keywords += GetAutoKeywords(words.ToString(), item);
                                                            }
                                                        }

                                                        url.news.publication.name     = web.Title.ToString();
                                                        url.news.accessSpecified      = false;
                                                        url.news.publication.language = info.TwoLetterISOLanguageName;
                                                        url.news.publication_date     = DateTime.Parse(item[SPBuiltInFieldId.Modified].ToString()).ToString("yyyy-MM-dd");

                                                        if (!String.IsNullOrEmpty(company.Stock))
                                                        {
                                                            url.news.stock_tickers = company.Stock;
                                                        }

                                                        if (!string.IsNullOrEmpty(geo_location))
                                                        {
                                                            url.news.geo_location = geo_location;
                                                        }

                                                        url.news.title = item[SPBuiltInFieldId.Title].ToString();
                                                        newsmap.url.Add(url);
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    ex.ToString();
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        ex.ToString();
                                    }
                                }
                            }
                        }
                        //<Query><Where><Geq><FieldRef Name="Modified" /><Value Type="DateTime">[4/12/2012 11:53:33 AM-30Day(s)]</Value></Geq></Where></Query>
                        //<Query><Where><And><Geq><FieldRef Name="Modified" /><Value Type="DateTime">[4/12/2012 11:28:42 AM-2Day(s)]</Value></Geq><IsNotNull><FieldRef Name=\"PublishingPageDesign\" /></IsNotNull><And></Where></Query>
                    }
                }
            });

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