Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
            }
        }
        public static void DeserializeXMLToAnnouncementsForGlobalAsax(string filefolder, string fileName)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <Announcement> anns = new List <Announcement>();
                anns = QueryLatestAnnouncementsForXml(100);
                System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Announcement>));

                HLP.DeleteFile(filefolder, fileName);

                System.IO.FileStream file = System.IO.File.Create(fileLocation);
                writer.Serialize(file, anns);
                file.Close();
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
            }
        }
        public static void DeserializeXMLToAdvertsForGlobalAsax(string filefolder, string fileName, int amount, string category)
        {
            try
            {
                string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName;

                List <Advert> advsLight = new List <Advert>();
                advsLight = QueryLatestCategoryAdvertsForXml(amount, category);
                System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Advert>));

                if (System.IO.File.Exists(fileLocation))
                {
                    HLP.DeleteFile(filefolder, fileName);
                }

                System.IO.FileStream file = System.IO.File.Create(fileLocation);
                writer.Serialize(file, advsLight);
                file.Close();
            }
            catch (Exception ex)
            {
                EXP.RedirectToErrorPage(ex.Message);
            }
        }