/// <summary> /// Gets the arc status. /// </summary> /// <param name="statusId">The status id.</param> /// <returns></returns> public static int GetArcStatus(int statusId) { string cacheKey = CmsCache.CreateCacheKey("workflow-archive-status"); // check cache first object cachedObject = CmsCache.Get(cacheKey); if (cachedObject != null) { return((int)cachedObject); } DataCommand cmd = ContentDataHelper.CreateDataCommand("[cms_WorkflowStatus_GetArcStatus]"); cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("StatusId", statusId, DataParameterType.Int)); cmd.Parameters.Add(new DataParameter("ApplicationId", AppContext.Current.ApplicationId, DataParameterType.UniqueIdentifier)); int status = DataService.RunReturnInteger(cmd); // Insert to the cache collection CmsCache.Insert(cacheKey, status, CmsConfiguration.Instance.Cache.WorkflowTimeout); return(status); }
/// <summary> /// Gets the variable. /// </summary> /// <param name="key">The key.</param> /// <param name="siteId">The site id.</param> /// <returns></returns> public static string GetVariable(string key, Guid siteId) { string cacheKey = CmsCache.CreateCacheKey("var", key, siteId.ToString()); // check cache first object cachedObject = CmsCache.Get(cacheKey); if (cachedObject != null) { return((string)cachedObject); } string val = String.Empty; using (IDataReader reader = GetGlobalVariablesReader(key, siteId)) { if (reader.Read()) { val = (string)reader["Value"]; } reader.Close(); } CmsCache.Insert(cacheKey, val, CmsConfiguration.Instance.Cache.SiteVariablesTimeout); return(val); }
/// <summary> /// Gets the URL. Results are cached using MenuTimeout setting. /// </summary> /// <param name="cmdName">Name of the CMD.</param> /// <param name="pars">The pars.</param> /// <param name="vals">The vals.</param> /// <returns></returns> public static string GetUrl(string cmdName, List <string> pars, List <string> vals) { string cacheKey = CmsCache.CreateCacheKey("commands", cmdName, MakeParams(pars, vals)); // check cache first object cachedObject = CmsCache.Get(cacheKey); if (cachedObject != null) { return((string)cachedObject); } using (IDataReader reader = GetItemByName(cmdName)) { if (reader.Read()) { if (!CheckParams((int)reader["ItemId"], pars)) { reader.Close(); throw new Exception("Some parameters for NavigationCommand = " + cmdName + " are invalid"); } using (IDataReader reader2 = GetCommandByItemId((int)reader["ItemId"])) { if (reader2.Read()) { if (!String.IsNullOrEmpty(reader2["Params"] as string) && !String.IsNullOrEmpty(MakeParams(pars, vals))) { string url = GetUrlByUID((string)reader2["UrlUID"], MakeParams(pars, vals) + "&" + (string)reader2["Params"]); reader2.Close(); reader.Close(); CmsCache.Insert(cacheKey, url, CmsConfiguration.Instance.Cache.MenuTimeout); return(url); } else { string url = GetUrlByUID((string)reader2["UrlUID"], MakeParams(pars, vals)); reader2.Close(); reader.Close(); CmsCache.Insert(cacheKey, url, CmsConfiguration.Instance.Cache.MenuTimeout); return(url); } } reader2.Close(); } } reader.Close(); } CmsCache.Insert(cacheKey, String.Empty, CmsConfiguration.Instance.Cache.MenuTimeout); return(String.Empty); }
/// <summary> /// Gets the last. /// </summary> /// <returns></returns> public static int GetLast() { string cacheKey = CmsCache.CreateCacheKey("workflow-published-status"); // check cache first object cachedObject = CmsCache.Get(cacheKey); if (cachedObject != null) { return((int)cachedObject); } int status = GetLast(-1); // Insert to the cache collection CmsCache.Insert(cacheKey, status, CmsConfiguration.Instance.Cache.WorkflowTimeout); return(status); }
/// <summary> /// Loads the language information. Results are cached usiong CmsConfiguration.Instance.Cache.SiteVariablesTimeout. /// </summary> private void LoadLanguage() { string cacheKey = CmsCache.CreateCacheKey("languages", CMSContext.Current.ApplicationId.ToString(), Thread.CurrentThread.CurrentCulture.Name); // check cache first object cachedObject = CmsCache.Get(cacheKey); if (cachedObject != null) { _languageId = Int32.Parse(((string[])cachedObject)[0]); _languageName = (string)((string[])cachedObject)[1]; return; } using (IDataReader reader = Language.GetLangByName(Thread.CurrentThread.CurrentCulture.Name)) { if (reader.Read()) { _languageId = (int)reader["LangId"]; _languageName = reader["LangName"].ToString(); } else { using (IDataReader reader2 = Language.GetAllLanguages()) { while (reader2.Read()) { if ((bool)reader2["IsDefault"]) { _languageName = reader2["LangName"].ToString(); _languageId = (int)reader2["LangId"]; } } reader2.Close(); } } reader.Close(); } // Save cache CmsCache.Insert(cacheKey, new string[] { _languageId.ToString(), _languageName }, CmsConfiguration.Instance.Cache.SiteVariablesTimeout); }