Пример #1
0
        public bool CreateOrUpdateCategoriesXML(string fileLocation)
        {
            try
            {
                List <PostCategory> categories = QueryPostCategories();

                if (HLP.CheckIfFileExists(fileLocation))
                {
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>));
                    System.IO.FileStream file = System.IO.File.OpenWrite(fileLocation);
                    writer.Serialize(file, categories);
                    file.Close();
                }
                else
                {
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>));
                    System.IO.FileStream file = System.IO.File.Create(fileLocation);
                    writer.Serialize(file, categories);
                    file.Close();
                }

                return(true);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(false);
            }
        }
Пример #2
0
        public static List <SaUserDevice> QueryUserDevices(int userId)
        {
            try
            {
                List <SaUserDevice> userDevices = new List <SaUserDevice>();
                ListItemCollection  coll        = DAT.DataQuery.QueryListItems(SaUserModel.usersListSiteUrl, SaUserModel.userDetailsListName, string.Format(SaUserModel.userDevicesCamlQuery, userId));
                if (coll.Count > 0)
                {
                    foreach (ListItem item in coll)
                    {
                        SaUserDevice     device  = new SaUserDevice();
                        FieldLookupValue idValue = (FieldLookupValue)item["UserId"];
                        device.UserId   = Convert.ToInt32(idValue.LookupValue);
                        device.DeviceId = item["Title"].ToString();
                        userDevices.Add(device);
                    }
                }

                return(userDevices);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
        /* It includes methods related to SampleEntity */
        #endregion

        #region Methods
        // Retrieve Announcements
        //public static List<Announcement> QueryLatestAnnouncements()
        //{
        //    try
        //    {
        //        HttpWebRequest request = DataService.CreateRequest(DataStatics.DomainForService, DataStatics.UserNameForService, DataStatics.PasswordForService, AnnouncementModel.queryUrl , true, true, "application/json; charset=UTF-8", "application/json; odata=verbose", "GET");
        //        request.ContentLength = 0;

        //        WebResponse response = request.GetResponse();
        //        string returnString = DataService.RestfulReader(response);
        //        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Root));
        //        MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(returnString));
        //        Root obj = (Root)ser.ReadObject(stream);
        //        List<Announcement> announcements = (List<Announcement>)obj.Data.Results;
        //        return announcements;
        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }
        //}


        //public static List<Announcement> QueryLatestAnnouncements()
        //{
        //    try
        //    {
        //        List<Announcement> anns = new List<Announcement>();
        //        Microsoft.SharePoint.Client.ListItemCollection coll = DAT.DataQuery.QueryListItems(AnnouncementModel.announcementsSiteUrl, AnnouncementModel.sayfalarListName, AnnouncementModel.announcementsCamlQuery);
        //        if (coll.Count > 0)
        //        {
        //            foreach (SP.ListItem item in coll)
        //            {
        //                Announcement ann = new Announcement();
        //                ann.ID = Convert.ToInt32(item["ID"]);
        //                ann.Created = Convert.ToDateTime(item["Created"]);
        //                ann.Title = item["Title"].ToString();
        //                string imgUrl = HLP.GetImageUrlFromImgTag(item["ListImage"].ToString());
        //                string imagePath = imgUrl.Split('?')[0];
        //                string imageExtension = imagePath.Substring(imagePath.Length - 3);
        //                string base64 = HLP.RemoteImageUrlToBase64Converter(imgUrl);
        //                ann.ListImage = HLP.CreateImgTagWithBase64(base64,imageExtension,"width:100px;height:auto; border: 0px solid");
        //                anns.Add(ann);
        //            }
        //        }

        //        return anns;

        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }
        //}
        public static List <Announcement> QueryAnnouncementsLight()
        {
            try
            {
                List <Announcement>   anns = new List <Announcement>();
                SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(AnnouncementModel.announcementsSiteUrl, AnnouncementModel.sayfalarListName, AnnouncementModel.announcementsLightCamlQuery);
                if (coll.Count > 0)
                {
                    foreach (SP.ListItem item in coll)
                    {
                        Announcement ann = new Announcement();
                        ann.ID      = Convert.ToInt32(item["ID"]);
                        ann.Created = Convert.ToDateTime(item["Created"]);
                        ann.Title   = item["Title"].ToString();
                        anns.Add(ann);
                    }
                }

                return(anns);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #4
0
 public static News QueryNewsDetails(int newsId)
 {
     try
     {
         News news = new News();
         Microsoft.SharePoint.Client.ListItemCollection coll = DAT.DataQuery.QueryListItems(NewsModel.newsSiteUrl, NewsModel.sayfalarListName, string.Format(NewsModel.newsDetailCamlQuery, newsId));
         SP.ListItem item = coll[0];
         news.ID       = newsId;
         news.Modified = Convert.ToDateTime(item["Modified"]);
         news.Title    = item["Title"].ToString();
         string[] metaInfo = item["MetaInfo"].ToString().Split('\n');
         foreach (var i in metaInfo)
         {
             if (i.Contains("vti_cachedcustomprops"))
             {
                 continue;
             }
             if (i.Contains("PublishingPageContent:SW"))
             {
                 news.PublishingPageContent = HLP.TransformHtmlString(i.Split('|')[1].Replace("\r", ""));
             }
         }
         return(news);
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }
Пример #5
0
        public static List <PostCategory> QueryPostCategories(string postsMainSiteUrl, string categoryListName, string getCategoriesCamlQuery)
        {
            try
            {
                List <Saport2.Business.Entity.PostModel.PostCategory> categories = new List <Saport2.Business.Entity.PostModel.PostCategory>();
                SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(postsMainSiteUrl, categoryListName, getCategoriesCamlQuery);

                if (coll.Count > 0)
                {
                    foreach (SP.ListItem item in coll)
                    {
                        Saport2.Business.Entity.PostModel.PostCategory catgry = new Saport2.Business.Entity.PostModel.PostCategory();
                        catgry.CategoryName  = item["BlogUrl"].ToString();
                        catgry.CategoryTitle = item["Title"].ToString();
                        categories.Add(catgry);
                    }
                }

                return(categories);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #6
0
        public static List <News> QueryLatestNewsForXml(int amount)
        {
            try
            {
                List <News>           newss = new List <News>();
                SP.ListItemCollection coll  = DAT.DataQuery.QueryListItems(NewsModel.newsSiteUrl, NewsModel.sayfalarListName, string.Format(NewsModel.newsLimitedCamlQuery, amount));
                if (coll.Count > 0)
                {
                    foreach (SP.ListItem item in coll)
                    {
                        News news = new News();
                        news.ID        = Convert.ToInt32(item["ID"]);
                        news.Created   = Convert.ToDateTime(item["Created"]);
                        news.Title     = item["Title"].ToString().Replace("\u0003", " ");
                        news.ListImage = HLP.TransformImgHtmlStringAndGetBase64(item["ListImage"].ToString());
                        newss.Add(news);
                    }
                }

                return(newss.Take(amount).ToList());
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #7
0
        public static List <News> QueryLatestNews()
        {
            try
            {
                List <News>           newss = new List <News>();
                SP.ListItemCollection coll  = DAT.DataQuery.QueryListItems(NewsModel.newsSiteUrl, NewsModel.sayfalarListName, NewsModel.newsCamlQuery);
                if (coll.Count > 0)
                {
                    foreach (SP.ListItem item in coll)
                    {
                        News news = new News();
                        news.ID        = Convert.ToInt32(item["ID"]);
                        news.Created   = Convert.ToDateTime(item["Created"]);
                        news.Title     = item["Title"].ToString();
                        news.ListImage = HLP.TransformHtmlString(item["ListImage"].ToString());
                        newss.Add(news);
                    }
                }

                return(newss);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    #region Load Portalfeeds
                    List <PortalFeedsModel.PortalFeed> allFeeds = PortalFeedsService.DeserializeXMLToPortalFeedsLight(PortalFeedsModel.portalFeedsSaveFolder, PortalFeedsModel.portalFeedSavedFileName, 50);

                    int i = 0;
                    foreach (var item in allFeeds)
                    {
                        i++;
                        ltrMain.Text += string.Format(PortalFeedsModel.htmlForPortalFeedsPage, item.IconCode, PortalFeedsService.GetRedirectUrl(item.Category.ToString(), item.Id), HLP.GetDateTurkishCulture(Convert.ToDateTime(item.Created)), item.Title);
                        if (i == allFeeds.Count)
                        {
                            ViewState.Add("LastPortalFeedId", item.Id.ToString());
                            ViewState.Add("LastPortalFeedCategory", item.Category.ToString());
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
            }
        }
Пример #9
0
        /* It includes methods related to SampleEntity */
        #endregion

        #region Methods
        public static List <Advert> GetCategoryAdverts(string categoryName)
        {
            try
            {
                List <Advert>         ads  = new List <Advert>();
                SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(BillBoardModel.advertsSiteUrl, BillBoardModel.sayfalarListName, string.Format(BillBoardModel.categoryAdvertsCamlQuery, categoryName));
                if (coll.Count > 0)
                {
                    foreach (SP.ListItem item in coll)
                    {
                        Advert adv = new Advert();
                        adv.ID           = Convert.ToInt32(item["ID"]);
                        adv.Category     = categoryName;
                        adv.Created      = Convert.ToDateTime(item["Created"]);
                        adv.DefaultImage = item["DefaultImage"] != null ? item["DefaultImage"].ToString() : "";
                        adv.Title        = item["Title"].ToString();
                        ads.Add(adv);
                    }
                }

                return(ads);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #10
0
        public static List <Advert> QueryAdvertDetails(int id)
        {
            try
            {
                List <Advert>         adverts = new List <Advert>();
                SP.ListItemCollection coll    = DAT.DataQuery.QueryListItems(BillBoardModel.advertsSiteUrl, BillBoardModel.sayfalarListName, string.Format(BillBoardModel.advertDetailCamlQuery, id));
                if (coll.Count > 0)
                {
                    var    item = coll[0];
                    Advert adv  = new Advert();
                    adv.Category    = item["AdCategory"].ToString();
                    adv.ID          = id;
                    adv.Title       = item["Title"].ToString();
                    adv.Price       = Convert.ToDecimal(item["Price"]);
                    adv.Created     = Convert.ToDateTime(item["Created"]);
                    adv.Description = item["GenericDescription"].ToString();
                    adv.Detail      = item["GenericDetail"].ToString();

                    adverts.Add(adv);
                }

                return(adverts);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
        public static WeatherStatus DeserializeXMLToWeathers(string filefolder, string fileName, string cityName)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <WeatherStatus> weatherStatuses   = new List <WeatherStatus>();
                WeatherStatus        cityWeatherStatus = new WeatherStatus();

                if (HLP.CheckIfFileExists(fileLocation))
                {
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <WeatherStatus>));
                    System.IO.FileStream file = System.IO.File.OpenRead(fileLocation);
                    weatherStatuses   = (List <WeatherStatus>)writer.Deserialize(file);
                    cityWeatherStatus = weatherStatuses.Single(x => x.City == cityName);
                    file.Close();
                }
                else
                {
                    weatherStatuses = QueryAllWeatherStatusesForXml();
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <WeatherStatus>));
                    System.IO.FileStream file = System.IO.File.Create(fileLocation);
                    writer.Serialize(file, weatherStatuses);
                    file.Close();
                }

                return(weatherStatuses.Single(x => x.City == cityName));
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    string category = Request.QueryString["Cat"] != null ? Request.QueryString["Cat"].ToString() : string.Empty;

                    if (category != string.Empty)
                    {
                        ltrAdCat.Text = Request.QueryString["Cat"].ToString();

                        List <BillBoardModel.Advert> adverts = BillBoardService.DeserializeXMLToAdvertsLight(BillBoardModel.advertssSaveFolder, BillBoardService.GetSaveFileNameForGlobalAsax(category), 30, category);

                        foreach (var item in adverts)
                        {
                            ltrMain.Text += string.Format(BillBoardModel.advertListItemHTMLString, item.DetailPageUrl, item.DefaultImage, item.DetailPageUrl, item.Title);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
            }
        }
Пример #13
0
        public static List <PostCategory> DeserializeXMLToPostCategories(string filefolder, string fileName)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <PostCategory> categories = new List <PostCategory>();

                if (HLP.CheckIfFileExists(fileLocation))
                {
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>));
                    System.IO.FileStream file = System.IO.File.OpenRead(fileLocation);
                    categories = (List <PostCategory>)writer.Deserialize(file);
                    file.Close();
                }
                else
                {
                    categories = QueryPostCategories(PostModel.postsMainSiteUrl, PostModel.categoryListName, PostModel.getCategoriesCamlQuery);


                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>));
                    System.IO.FileStream file = System.IO.File.Create(fileLocation);
                    writer.Serialize(file, categories);
                    file.Close();
                }

                return(categories);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
        /* It includes methods related to SampleEntity */
        #endregion

        #region Methods
        public static WeatherStatus GetCityWeatherStatus(string cityName)
        {
            try
            {
                HttpWebRequest myReq8         = DAT.DataService.CreateRequest(DAT.DataStatics.DomainForService, DAT.DataStatics.UserNameForService, DAT.DataStatics.PasswordForService, DAT.DataStatics.saportServiceURL(DAT.DataStatics.saportServiceGetCityWeatherStatus), false, true, "application/json; charset=UTF-8", "application/json; odata=verbose", "POST");
                string         parsedContent8 = "{\"CityName\":\"" + (string.IsNullOrEmpty(cityName) ? weatherDefaultCity : cityName) + "\"}";
                UTF8Encoding   encoding8      = new UTF8Encoding();
                Byte[]         bytes8         = encoding8.GetBytes(parsedContent8);
                myReq8.ContentLength = bytes8.Length;
                Stream newStream8 = myReq8.GetRequestStream();
                newStream8.Write(bytes8, 0, bytes8.Length);
                newStream8.Close();
                WebResponse response8       = myReq8.GetResponse();
                string      responseString8 = DAT.DataService.RestfulReader(response8);

                var           serializer    = new JavaScriptSerializer();
                WeatherObject weatherObj    = serializer.Deserialize <WeatherObject>(responseString8);
                WeatherStatus weatherStatus = weatherObj.Data;

                if (weatherStatus == null)
                {
                    weatherStatus = GetDefaultWeatherStatus();
                }

                return(weatherStatus);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #15
0
        public static List <Post> DeserializeXMLToPostsLightForGlobalAsax(string filefolder, string fileName)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <Post> postsLight = new List <Post>();

                postsLight = QueryAllLatestPostsLight(filefolder, fileName);
                System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Post>));

                HLP.DeleteFile(filefolder, fileName);

                System.IO.FileStream file = System.IO.File.Create(fileLocation);
                writer.Serialize(file, postsLight);
                file.Close();

                return(postsLight);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #16
0
        public static List <Banner> DeserializeXMLToBannersLight(string filefolder, string fileName, int amount)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <Banner> bannersLight     = new List <Banner>();
                DateTime      fileCreationDate = System.IO.File.GetCreationTime(fileLocation);
                bool          isOld            = fileCreationDate < DateTime.Now.AddDays(-1) ? true : false;
                if (HLP.CheckIfFileExists(fileLocation))
                {
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Banner>));
                    System.IO.FileStream file = System.IO.File.OpenRead(fileLocation);
                    bannersLight = (List <Banner>)writer.Deserialize(file);
                    bannersLight = bannersLight.Take(amount).ToList();
                    file.Close();
                }
                else
                {
                    bannersLight = QueryLatestBannersForXml(amount);
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Banner>));
                    System.IO.FileStream file = System.IO.File.Create(fileLocation);
                    writer.Serialize(file, bannersLight);
                    file.Close();
                }

                return(bannersLight.Take(amount).ToList());
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #17
0
        public static List <Post> DeserializeXMLToPostsLight(string filefolder, string fileName, int amount)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <Post> postsLight = new List <Post>();

                if (HLP.CheckIfFileExists(fileLocation))
                {
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Post>));
                    System.IO.FileStream file = System.IO.File.OpenRead(fileLocation);
                    postsLight = (List <Post>)writer.Deserialize(file);
                    file.Close();
                }
                else
                {
                    postsLight = QueryAllLatestPostsLight();
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Post>));
                    System.IO.FileStream file = System.IO.File.Create(fileLocation);
                    writer.Serialize(file, postsLight);
                    file.Close();
                }

                return(postsLight.Take(amount).ToList());
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #18
0
        public static List <Announcement> QueryLatestAnnouncementsForXml(int amount)
        {
            try
            {
                List <Announcement>   anns = new List <Announcement>();
                SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(AnnouncementModel.announcementsSiteUrl, AnnouncementModel.sayfalarListName, string.Format(AnnouncementModel.announcementsCamlQuery, amount));
                if (coll.Count > 0)
                {
                    foreach (SP.ListItem item in coll)
                    {
                        Announcement ann = new Announcement();
                        ann.ID      = Convert.ToInt32(item["ID"]);
                        ann.Created = Convert.ToDateTime(item["Created"]);
                        ann.Title   = item["Title"].ToString();
                        string imgUrl = HLP.GetImageUrlFromImgTag(item["ListImage"].ToString());
                        //string imgFileName = HLP.SaveFileToTempFolder(HLP.GetNetworkCredential(), DAT.DataStatics.saportHostURL+ imgUrl,  System.Web.HttpContext.Current.Session.SessionID);
                        //ann.ListImage = HLP.CreateImgTag(imgFileName);
                        //ann.ListImage = HLP.TransformHtmlString(item["ListImage"].ToString());
                        ann.ListImage = HLP.RemoteImageUrlToBase64Converter(imgUrl, true);
                        anns.Add(ann);
                    }
                }

                return(anns);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #19
0
 // SERVİS GELDİĞİNDE DEĞİŞECEK
 public static SaUser QueryUserByEmail(string email)
 {
     try
     {
         SaUser             thisUser = new SaUser();
         ListItemCollection coll     = DAT.DataQuery.QueryListItems(SaUserModel.usersListSiteUrl, SaUserModel.usersListName, string.Format(SaUserModel.userCamlQueryByEmail, email));
         if (coll.Count > 0)
         {
             ListItem item = coll[0];
             thisUser.Id         = Convert.ToInt32(item["ID"]);
             thisUser.Name       = item["Title"].ToString();
             thisUser.LastName   = item["LastName"].ToString();
             thisUser.GsmNumber  = item["GsmNumber"] != null ? item["GsmNumber"].ToString() : string.Empty;
             thisUser.Email      = item["Email"] != null ? item["Email"].ToString() : string.Empty;
             thisUser.Password   = item["Password"].ToString();
             thisUser.UserActive = Convert.ToBoolean(item["UserActive"]);
             thisUser.LoginType  = LoginTypeName.Email;
             //thisUser.UserDevices = QueryUserDevices((int)thisUser.Id);
         }
         return(thisUser);
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }
Пример #20
0
        public static List <Banner> DeserializeXMLToBannersLightForGlobalAsax(string filefolder, string fileName, int amount)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <Banner> bannersLight = new List <Banner>();

                bannersLight = QueryLatestBannersForXml(amount);
                System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Banner>));

                HLP.DeleteFile(filefolder, fileName);

                System.IO.FileStream file = System.IO.File.Create(fileLocation);
                writer.Serialize(file, bannersLight);
                file.Close();

                return(bannersLight.Take(amount).ToList());
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #21
0
 public static List <Campaign> QueryLatestCampaignsForService(int amount)
 {
     try
     {
         List <Campaign>       camps = new List <Campaign>();
         SP.ListItemCollection coll  = DAT.DataQuery.QueryListItems(CampaignModel.campaignsSiteUrl, CampaignModel.sayfalarListName, string.Format(CampaignModel.campaignsCamlQueryForService, amount * 3));
         if (coll.Count > 0)
         {
             foreach (SP.ListItem item in coll)
             {
                 Campaign camp     = new Campaign();
                 string[] metaInfo = item["MetaInfo"].ToString().Split('\n');
                 foreach (var i in metaInfo)
                 {
                     if (i.Contains("vti_cachedcustomprops"))
                     {
                         continue;
                     }
                     if (i.Contains("PublishingPageContent:SW"))
                     {
                         camp.PublishingPageContent = HLP.TransformHtmlStringForMobile(i.Split('|')[1].Replace("\r", ""));
                     }
                     if (i.Contains("CampaignEndDate"))
                     {
                         camp.CampaignEndDate = Convert.ToDateTime(i.Split('|')[1].Replace("\r", ""));
                     }
                     if (i.Contains("ListImage"))
                     {
                         if (camp.CampaignEndDate != null && camp.CampaignEndDate >= DateTime.Now)
                         {
                             camp.ListImage = DAT.DataStatics.saportHostURL + HLP.TransformHtmlStringAndGetFileUrl(i.Split('|')[1].Replace("\r", ""));
                             break;
                         }
                     }
                 }
                 if (camp.CampaignEndDate >= DateTime.Now)
                 {
                     if (camp.ListImage != string.Empty)
                     {
                         camp.ListImage = "/mobile/" + HLP.ResizeAndSaveFileToMobileFolder(HLP.GetNetworkCredential(), camp.ListImage);
                     }
                     camp.ID    = Convert.ToInt32(item["ID"]);
                     camp.Title = item["Title"].ToString();
                     camps.Add(camp);
                 }
             }
         }
         return(camps.Take(amount).ToList());
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }
Пример #22
0
        /* It includes methods related to SampleEntity */
        #endregion

        #region Methods
        public static List <SearchModel> QuerySearchResults(string siteUrl, string queryText, string contentTypeId, int contentTypeCode, string contentTypeName, string redirectUrl)
        {
            try
            {
                List <SearchModel> searchResults = new List <SearchModel>();

                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(Data.DataStatics.UserNameForService, Data.DataStatics.PasswordForService, Data.DataStatics.DomainForService);


                ClientContext clientContext = new ClientContext(siteUrl);
                clientContext.Credentials = credentials;

                KeywordQuery keywordQuery = new KeywordQuery(clientContext);
                keywordQuery.QueryText = queryText;
                keywordQuery.SortList.Add("Created", SortDirection.Descending);
                string filter1 = "contenttypeid:equals(\"{0}\")";
                keywordQuery.RefinementFilters.Add(string.Format(filter1, contentTypeId));
                keywordQuery.SelectProperties.Add("ContentTypeId");
                keywordQuery.SelectProperties.Add("Title");
                keywordQuery.SelectProperties.Add("ListItemID");
                keywordQuery.RowLimit   = 10;
                keywordQuery.ClientType = "ContentSearchRegular";

                SearchExecutor searchExecutor = new SearchExecutor(clientContext);
                ClientResult <ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);
                clientContext.ExecuteQuery();

                IEnumerable <IDictionary <string, object> > resultTable = results.Value[0].ResultRows;

                if (resultTable != null)
                {
                    foreach (var resultRow in resultTable)
                    {
                        SearchModel newSearchItem = new SearchModel();
                        newSearchItem.Title           = resultRow["Title"].ToString();
                        newSearchItem.ListItemId      = resultRow["ListItemID"].ToString();
                        newSearchItem.ContentTypeId   = resultRow["ContentTypeId"].ToString();
                        newSearchItem.ContentTypeName = contentTypeName;
                        newSearchItem.ContentTypeCode = contentTypeCode;
                        newSearchItem.RedirectUrl     = redirectUrl;
                        searchResults.Add(newSearchItem);
                    }
                }

                clientContext.Dispose();

                return(searchResults);
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
                return(null);
            }
        }
Пример #23
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         Response.Redirect("Search.aspx");
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message + ex.StackTrace.ToString());
     }
 }
Пример #24
0
 public static string SaveRemoteImageToTemp(string imageUrl)
 {
     try
     {
         string imageBase64 = HLP.RemoteImageUrlToBase64Converter(imageUrl, false);
         return(imageBase64);
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }
Пример #25
0
 public static string GetRedirectUrl(string category, int?id)
 {
     try
     {
         string redUrl = category == FeedCategory.Announcement.ToString() ? string.Format(redirectToAnnouncementDetailUrl, id) : (category == FeedCategory.Campaign.ToString() ? string.Format(redirectToCampaignDetailUrl, id) : (category == FeedCategory.News.ToString() ? string.Format(redirectToNewsDetailUrl, id) : ""));
         return(redUrl);
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }
Пример #26
0
 protected void btnBackToLoginScreen_Click(object sender, EventArgs e)
 {
     try
     {
         pnlLogin.Visible          = true;
         pnlForgetPassword.Visible = false;
         divNotification.Visible   = false;
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
     }
 }
Пример #27
0
 public static string WrapPostItem(Post post)
 {
     try
     {
         string wrappedString = "<a href=\"" + string.Format(PostModel.postDetailUrl, post.Id.ToString(), post.CategoryName.ToString()) + "\">" + post.Title + "</a>" + " | " + post.PublishedDate.ToShortDateString() + " | " + post.CategoryName + " | " + post.Author + " | " + post.Body;
         return(wrappedString);
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }
Пример #28
0
 public static string WrapPostItemNoLink(Post post)
 {
     try
     {
         string wrappedString = post.Title + " | " + post.PublishedDate.ToShortDateString() + " | " + post.CategoryName + " | " + post.Author + " | " + post.Body;
         return(wrappedString);
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }
Пример #29
0
 public static bool SetPageTitle(Page thisPage, string pageTitle)
 {
     try
     {
         thisPage.Title = pageTitle;
         return(true);
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(false);
     }
 }
 public static string GetWeatherImageUrl(WeatherStatus weatherStat)
 {
     try
     {
         string periodOfDay = (DateTime.Now.Hour > 19 && DateTime.Now.Hour <= 23) || (DateTime.Now.Hour >= 0 && DateTime.Now.Hour <= 5) ? "pm" : "am";
         return(string.Format(weatherImgeUrl, periodOfDay == "am" ? "day" : "night", weatherStat.WeatherInfo.StatusImage, weatherStat.WeatherInfo.Status));
     }
     catch (Exception ex)
     {
         EXP.RedirectToErrorPage(ex.Message);
         return(null);
     }
 }