예제 #1
0
        public static void RefreshCreators()
        {
            XDocument             doc      = XDocument.Load(CreatorsUrl);
            CreatorInfoCollection creators = new CreatorInfoCollection(doc.Element("creators").Elements("creatorInfo"));

            ZCache.InsertCache(CreatorsCacheKey, creators, CacheTime);
        }
예제 #2
0
        /// <summary>
        /// 通用单表型数据grid格式化 带缓存
        /// </summary>
        /// <param name="TableName"></param>
        /// <param name="IdField"></param>
        /// <param name="TextField"></param>
        /// <param name="ComboboxValue"></param>
        /// <param name="connName"></param>
        /// <returns></returns>
        public string GetComboboxFormatter_Single(string TableName = "", string IdField = "", string TextField = "", string ComboboxValue = "", string connName = "Mms")
        {
            var    result   = "";
            string cacheKey = TableName + "_" + IdField + "_" + TextField + "_" + connName;
            var    cache    = ZCache.GetCache(cacheKey);//获取缓存DataTable

            if (cache == null)
            {
                List <dynamic> SysCodelist = new List <dynamic>();
                using (var db = Db.Context(connName))
                {
                    SysCodelist = db.Sql(string.Format("select {0} as value,{1} as text from {2}", IdField, TextField, TableName)).QueryMany <dynamic>();
                }
                ZCache.SetCache(cacheKey, SysCodelist, DateTime.Now.AddMinutes(5), TimeSpan.Zero);//设置缓存DataTable
                cache = ZCache.GetCache(cacheKey);
            }
            var cacheList = (List <dynamic>)cache;

            if (cacheList.Count > 0)
            {
                if (cacheList.Where(c => c.value == ComboboxValue).ToList().Count > 0)
                {
                    result = cacheList.Where(c => c.value == ComboboxValue).ToList().First().text;
                }
            }
            return(result);
        }
    protected void PageWidget_Save_Click(object sender, EventArgs e)
    {
        PageWidget widget = Widgets.Fetch(new Guid(Request.QueryString["id"])) as PageWidget;

        if (widget == null)
        {
            throw new Exception("The widget does not exist");
        }

        try
        {
            List <int> postIds = new List <int>();
            foreach (Telligent.Glow.OrderedListItem item in existing_items.Items)
            {
                postIds.Add(int.Parse(item.Value));
            }

            widget.PostIds = postIds.ToArray();
            widget.Title   = txtTitle.Text;
            Widgets.Save(widget);
            ZCache.RemoveCache(widget.DataCacheKey);

            Response.Redirect("?ws=" + widget.Id);
        }
        catch (Exception ex)
        {
            Message.Text = "Your widget called not be saved. Reason: " + ex.Message;
            Message.Type = StatusType.Error;
            return;
        }
    }
예제 #4
0
        // GET api/menu
        public IEnumerable <dynamic> Get()
        {
            var UserCode = SysHelper.GetUserCode();
            var TenantId = SysHelper.GetTenantId();

            dynamic result = ZCache.GetCache("MenuData");

            if (result == null && !string.IsNullOrEmpty(UserCode) && !string.IsNullOrEmpty(TenantId))
            {
                var postdata = new
                {
                    AppCode        = "EPS",
                    ApiCode        = "GetUserMenuData",
                    TenantId       = TenantId,
                    UserCode       = UserCode,
                    RequestAppCode = "MiniMES"
                };

                result = HttpHelper.PostWebApi(ZConfig.GetConfigString("APIGatewayUrl"), JsonConvert.SerializeObject(postdata), 18000);

                ZCache.SetCache("MenuData", result);
            }

            return(result);
        }
예제 #5
0
        public void RefreshMessages()
        {
            XDocument             doc      = XDocument.Load(MessageUrl);
            MessageInfoCollection messages = new MessageInfoCollection(doc.Element("messages").Elements("messageInfo"));

            ZCache.InsertCache(MessageCacheKey, messages, Marketplace.CacheTime);
        }
예제 #6
0
        public void RefreshItems()
        {
            XDocument          doc   = XDocument.Load(ItemUrl);
            ItemInfoCollection items = new ItemInfoCollection(this, doc.Element("items").Elements("itemInfo"));

            ZCache.InsertCache(ItemCacheKey, items, Marketplace.CacheTime);
        }
예제 #7
0
        /// <summary>
        /// 通用字典型数据grid格式化 带缓存
        /// </summary>
        /// <param name="CodeType"></param>
        /// <param name="ComboboxValue"></param>
        /// <returns></returns>
        public string GetComboboxFormatter(string CodeType = "", string ComboboxValue = "")
        {
            string result   = "";
            string cacheKey = "dictionary_" + CodeType;
            var    cache    = ZCache.GetCache(cacheKey);//获取缓存DataTable

            if (cache == null)
            {
                List <dynamic> SysCodelist = new List <dynamic>();
                using (var db = Db.Context("Sys"))
                {
                    SysCodelist = db.Sql(string.Format("select Value as value,Text as text from sys_code where CodeType in('{0}')", CodeType)).QueryMany <dynamic>();
                }
                ZCache.SetCache(cacheKey, SysCodelist, DateTime.Now.AddMinutes(5), TimeSpan.Zero);//设置缓存DataTable
                cache = ZCache.GetCache(cacheKey);
            }
            var cacheList = (List <dynamic>)cache;

            if (cacheList.Count() > 0)
            {
                if (cacheList.Where(c => c.value == ComboboxValue).ToList().Count > 0)
                {
                    result = cacheList.Where(c => c.value == ComboboxValue).ToList().First().text;
                }
            }
            return(result);
        }
예제 #8
0
        private static Dictionary <string, string> GetTableKeys(string table)
        {
            var tableKeys = ZCache.GetCache(String.Format("currentkey_{0}", table)) as Dictionary <string, string> ??
                            new Dictionary <string, string>();

            return(tableKeys);
        }
예제 #9
0
        public static void RefreshCatalogs()
        {
            XDocument             doc      = XDocument.Load(CatalogsUrl);
            CatalogInfoCollection catalogs = new CatalogInfoCollection(doc.Element("catalogs").Elements("catalogInfo"));

            ZCache.InsertCache(CatalogsCacheKey, catalogs, CacheTime);
        }
예제 #10
0
        public void RefreshCategories()
        {
            XDocument doc = XDocument.Load(CategoryUrl);
            CategoryInfoCollection categories = new CategoryInfoCollection(this, doc.Element("categories").Elements("categoryInfo"));

            ZCache.InsertCache(CategoryCacheKey, categories, Marketplace.CacheTime);
        }
예제 #11
0
        private static void SetCacheKey(string table, string field, string key)
        {
            var tableKeys = GetTableKeys(table);
            var fieldKeys = GetFieldKeys(tableKeys, field);

            tableKeys[field] = ZConvert.ToString(MaxOfAllKey(fieldKeys, key));
            ZCache.SetCache(String.Format("currentkey_{0}", table), tableKeys);
        }
예제 #12
0
        public JsonResult GetCommonSearchList_Cache(string keyword = "", string tableName = "", string searchField = "", string firstFightField = "", string whereSql = "", string CacheKey = "", int CacheTime = 5, string connName = "Mms")
        {
            //ZCache.RemoveCache(CacheKey);
            var       cache          = ZCache.GetCache(CacheKey);//获取缓存DataTable
            DataTable CacheDataTable = new DataTable();

            if (cache == null)
            {
                DataTable SearchDT = GetComboGridList(tableName, searchField, firstFightField, whereSql, connName);
                ZCache.SetCache(CacheKey, SearchDT, DateTime.Now.AddMinutes(CacheTime), TimeSpan.Zero);//设置缓存DataTable
                CacheDataTable = SearchDT;
            }
            else
            {
                CacheDataTable = (DataTable)cache;
            }

            string SearchSelect = "1=1";

            if (searchField != "" && keyword != "") //如果查询字段不为空 并且 关键字keyword查询不为空 则模糊查询
            {
                SearchSelect = "";
                foreach (var item in searchField.Split(',')) //查询字段的拼接
                {
                    SearchSelect += string.Format(" {0} like '%{1}%' or", item, keyword);
                }
                if (firstFightField != "") //首拼字段的拼接
                {
                    for (int i = 0; i < firstFightField.Split(',').Length; i++)
                    {
                        SearchSelect += string.Format(" {0} like '%{1}%' or", "firstFight_" + i.ToString(), keyword);
                    }
                }
                SearchSelect = SearchSelect.Substring(0, SearchSelect.Length - 2);
            }

            DataTable SearchCacheDataRows = new DataTable();

            if (CacheDataTable.Select(SearchSelect).Count() > 0)
            {
                SearchCacheDataRows = CacheDataTable.Select(SearchSelect).Take(50).CopyToDataTable();
            }

            List <Dictionary <string, string> > combogridList = new List <Dictionary <string, string> >();

            foreach (DataRow dr in SearchCacheDataRows.Rows)
            {
                Dictionary <string, string> dct = new Dictionary <string, string>();
                foreach (DataColumn dc in SearchCacheDataRows.Columns)
                {
                    dct.Add(dc.ColumnName, dr[dc.ColumnName].ToString());
                }
                combogridList.Add(dct);
            }
            return(Json(new { total = combogridList.Count(), rows = combogridList }, JsonRequestBehavior.AllowGet));
        }
예제 #13
0
        public ActionResult Index()
        {
            ViewBag.CnName = "STD MiniMES系统";
            ViewBag.EnName = "STD MiniMES System";

            var Token = Request["Token"];

            if (!string.IsNullOrEmpty(Token))
            {
                string APIGatewayUrl = ZConfig.GetConfigString("APIGatewayUrl");
                var    data          = new
                {
                    AppCode = "EPS",
                    ApiCode = "PostValidateToken",
                    Token   = Token
                };

                var result = HttpHelper.PostWebApi(APIGatewayUrl, JsonConvert.SerializeObject(data), 18000);
                if (result != null)
                {
                    if (result.status == true)
                    {
                        var UserInfo = result.UserInfo;

                        //调用框架中的登录机制
                        var loginer = new LoginerBase
                        {
                            UserId   = UserInfo.UserId,
                            UserType = "2",
                            TenantId = UserInfo.TenantId,
                            UserCode = UserInfo.UserCode,
                            UserName = UserInfo.UserName,
                            ShiftId  = UserInfo.ShiftId
                        };

                        var effectiveHours = ZConfig.GetConfigInt("LoginEffectiveHours");
                        FormsAuth.SignIn(loginer.UserCode, loginer, 60 * effectiveHours);

                        ZCache.SetCache("MenuData", result.MenuData);

                        return(Redirect("Home"));
                    }
                }

                //return View("授权Token验证失败!单击<a href='" + ZConfig.GetConfigString("GatewayServer") + "'>这里</a>返回登录页面。");
                return(Redirect(ZConfig.GetConfigString("GatewayServer") + "/Login"));
            }
            else
            {
                //return View("授权参数错误!单击<a href='" + ZConfig.GetConfigString("GatewayServer") + "'>这里</a>返回登录页面。");
                //return View();
                return(Redirect(ZConfig.GetConfigString("GatewayServer") + "/Login"));
            }
        }
예제 #14
0
        private static Dictionary <string, string> getTableKeys(string table)
        {
            var tableKeys = ZCache.GetCache(String.Format("currentkey_{0}", table)) as Dictionary <string, string>;

            if (null == tableKeys)
            {
                tableKeys = new Dictionary <string, string>();
            }

            return(tableKeys);
        }
예제 #15
0
        protected object GetPostsByTag(string key, GraffitiContext graffitiContext)
        {
            PostCollection pc = ZCache.Get <PostCollection>("Tags-" + TagName);

            if (pc == null)
            {
                pc = Post.FetchPostsByTag(TagName);
                ZCache.InsertCache("Tags-" + TagName, pc, 60);
            }

            return(pc);
        }
예제 #16
0
        public void RefreshCreators()
        {
            CreatorInfoCollection creators = new CreatorInfoCollection();

            foreach (ItemInfo item in Items.Values)
            {
                if (!creators.ContainsKey(item.CreatorId))
                {
                    creators.Add(item.CreatorId, item.Creator);
                }
            }
            ZCache.InsertCache(CreatorCacheKey, creators, Marketplace.CacheTime);
        }
예제 #17
0
        private void ReadCache()
        {
            ZCache Cache = Shared.ZCacheDb.GetCache(CacheId);

            if (Cache != null)
            {
                ZoneMap      = new DbDictionary();
                ZoneMap.Data = Cache.Data.StringValue;
            }
            else if (ZoneMap == null)
            {
                ZoneMap = new DbDictionary();
            }
        }
예제 #18
0
        /// <summary>
        /// Process the request for the feed.
        /// </summary>
        /// <param name="context">The HTTP context for the request.</param>
        public virtual void ProcessRequest(HttpContext context)
        {
            Context = context;

            string feed = ZCache.Get <string>(this.CacheKey);

            if (feed == null)
            {
                feed = BuildFeed();

                ZCache.InsertCache(this.CacheKey, feed, this.CacheTime);
            }

            WriteFeed(feed);
        }
예제 #19
0
        public void SendPings(object state)
        {
            if (pingServiceUrls == null || pingServiceUrls.Length == 0)
            {
                return;
            }

            foreach (string pingUrl in pingServiceUrls)
            {
                if (!string.IsNullOrEmpty(pingUrl))
                {
                    this.Url = pingUrl.Trim();
                    bool   result       = false;
                    string errorMessage = string.Empty;

                    // Try to remember if the last ping to this URL supported the ExtendedPing spec, so we don't send out unnecessary pings repeatdly
                    bool   isExtendedPing = true;
                    string lastPingResult = ZCache.Get <string>(CacheKey(pingUrl));
                    if (!string.IsNullOrEmpty(lastPingResult))
                    {
                        try { isExtendedPing = bool.Parse(lastPingResult); }
                        catch { }
                    }

                    if (isExtendedPing)
                    {
                        try
                        {
                            PingResult response = ExtendedPing(this.siteName, this.siteUrl, this.siteUrl, this.siteFeedUrl);
                            if (response.flerror != null && response.flerror == true)
                            {
                                if (string.IsNullOrEmpty(response.message))
                                {
                                    errorMessage = "Remote weblogUpdates.extendedPing service indicated an error but provided no error message.";
                                }
                                else
                                {
                                    errorMessage = response.message;
                                }
                            }
                            else
                            {
                                result = true;
                            }
                        }
                        catch (CookComputing.XmlRpc.XmlRpcException ex)
                        {
                            errorMessage = ex.Message;
                        }
                        catch (System.Exception ex)
                        {
                            errorMessage = ex.Message;
                        }

                        // If the ExtendedPing request failed, try a basic ping to this url
                        if (!result)
                        {
                            isExtendedPing = false;
                        }
                    }

                    if (!isExtendedPing)
                    {
                        try
                        {
                            PingResult response = BasicPing(this.siteName, this.siteUrl);
                            if (response.flerror != null && response.flerror == true)
                            {
                                if (string.IsNullOrEmpty(response.message))
                                {
                                    errorMessage = "Remote weblogUpdates.ping service indicated an error but provided no error message.";
                                }
                                else
                                {
                                    errorMessage = response.message;
                                }
                            }
                            else
                            {
                                result = true;
                            }
                        }
                        catch (CookComputing.XmlRpc.XmlRpcException ex)
                        {
                            errorMessage = ex.Message;
                        }
                        catch (System.Exception ex)
                        {
                            errorMessage = ex.Message;
                        }
                    }


                    // Log succcess or failure to EventLog
                    if (result)
                    {
                        // Remember whether extended or basic ping worked for this url in the future
                        ZCache.InsertCache(CacheKey(pingUrl), isExtendedPing.ToString(), 43200);

                        string message = String.Format("Blog Ping sent to {0}.", pingUrl);
                        Log.Info("Ping Sent", message);
                    }
                    else
                    {
                        string message = String.Format("Blog Ping attempt to the url {0} failed. Error message returned was: {1}.", pingUrl, errorMessage);
                        Log.Warn("Ping Error", message);
                    }
                }
            }
        }