Exemplo n.º 1
0
 public static bool Save(PortalStyle data)
 {
     try
     {
         if (data != null)
         {
             System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
             string jsondata = javaScriptSerializer.Serialize(data);
             if (!string.IsNullOrEmpty(jsondata))
             {
                 using (System.IO.StreamWriter sw = new System.IO.StreamWriter(FilePath))
                 {
                     sw.Write(jsondata);
                     sw.Close();
                 }
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public static PortalStyle Read()
        {
            PortalStyle rv = null;

            try
            {
                //if (HttpContext.Current.Cache["portalStyle"] == null)
                using (System.IO.StreamReader sr = new System.IO.StreamReader(FilePath))
                {
                    System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                    rv = javaScriptSerializer.Deserialize <PortalStyle>(sr.ReadToEnd());
                    //HttpContext.Current.Cache["PortalStyles"] = rv;
                    sr.Close();
                }
                //else
                //    rv = HttpContext.Current.Cache["portalStyle"] as Portal;
            }
            catch (Exception)
            {
                return(new PortalStyle());
            }
            return(rv);
        }