private static object GetPortalDictionaryCallback(CacheItemArgs cacheItemArgs)
 {
     Dictionary<int, int> portalDic = new Dictionary<int, int>();
     if (Host.Host.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
     {
         int intField = 0;
         IDataReader dr = DataProvider.Instance().GetTabPaths(Null.NullInteger);
         try
         {
             while (dr.Read())
             {
                 portalDic[Convert.ToInt32(Null.SetNull(dr["TabID"], intField))] = Convert.ToInt32(Null.SetNull(dr["PortalID"], intField));
             }
         }
         catch (Exception exc)
         {
             Exceptions.LogException(exc);
         }
         finally
         {
             CBO.CloseDataReader(dr, true);
         }
     }
     return portalDic;
 }
 private static object GetPortalCallback(CacheItemArgs cacheItemArgs)
 {
     int portalID = (int)cacheItemArgs.ParamList[0];
     string cultureCode = (string)cacheItemArgs.ParamList[1];
     object objPortal = null;
     if (Localization.ActiveLanguagesByPortalID(portalID) == 1)
     {
         //only 1 language active, no need for fallback check
         return CBO.FillObject<PortalInfo>(DataProvider.Instance().GetPortal(portalID, cultureCode));
     }
     else
     {
         System.Data.IDataReader dr = default(System.Data.IDataReader);
         dr = DataProvider.Instance().GetPortal(portalID, cultureCode);
         objPortal = CBO.FillObject<PortalInfo>(dr);
         if (objPortal == null)
         {
             //Get Fallback language
             string fallbackLanguage = string.Empty;
             Locale userLocale = Localization.GetLocale(cultureCode);
             if (userLocale != null && !string.IsNullOrEmpty(userLocale.Fallback))
             {
                 fallbackLanguage = userLocale.Fallback;
             }
             dr = DataProvider.Instance().GetPortal(portalID, fallbackLanguage);
             objPortal = CBO.FillObject<PortalInfo>(dr);
             if (objPortal == null)
             {
                 objPortal = CBO.FillObject<PortalInfo>(DataProvider.Instance().GetPortal(portalID, PortalController.GetActivePortalLanguage(portalID)));
             }
             //if we cannot find any fallback, it mean's it's a non portal default langauge
             DataProvider.Instance().EnsureLocalizationExists(portalID, PortalController.GetActivePortalLanguage(portalID));
             objPortal = CBO.FillObject<PortalInfo>(DataProvider.Instance().GetPortal(portalID, PortalController.GetActivePortalLanguage(portalID)));
             dr.Close();
             dr.Dispose();
         }
     }
     return objPortal;
 }
 private object GetVocabulariesCallBack(CacheItemArgs cacheItemArgs)
 {
     return CBO.FillQueryable<Vocabulary>(_DataService.GetVocabularies());
 }
 private static object GetServersCallBack(CacheItemArgs cacheItemArgs)
 {
     return CBO.FillCollection<ServerInfo>(dataProvider.GetServers());
 }
예제 #5
0
 public static TObject GetCachedObject <TObject>(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired, bool saveInDictionary)
 {
     return(DataCache.GetCachedData <TObject>(cacheItemArgs, cacheItemExpired, saveInDictionary));
 }
 private static object GetDesktopModulePermissionsCallBack(CacheItemArgs cacheItemArgs)
 {
     return FillDesktopModulePermissionDictionary(provider.GetDesktopModulePermissions());
 }
 private static object GetPortalAliasLookupCallBack(CacheItemArgs cacheItemArgs)
 {
     return new PortalAliasController().GetPortalAliases();
 }
예제 #8
0
 private static Dictionary<string, string> LoadResourceFileCallback(CacheItemArgs cacheItemArgs)
 {
     string fileName = (string)cacheItemArgs.ParamList[0];
     string filePath = HttpContext.Current.Server.MapPath(fileName);
     Dictionary<string, string> dicResources = new Dictionary<string, string>();
     if (File.Exists(filePath))
     {
         XPathDocument doc = null;
         try
         {
             doc = new XPathDocument(filePath);
             foreach (XPathNavigator nav in doc.CreateNavigator().Select("root/data"))
             {
                 if (nav.NodeType != XPathNodeType.Comment)
                 {
                     dicResources[nav.GetAttribute("name", string.Empty)] = nav.SelectSingleNode("value").Value;
                 }
             }
         }
         catch
         {
         }
     }
     return dicResources;
 }
예제 #9
0
 private static object ValidIDLookupCallback(CacheItemArgs cacheItemArgs)
 {
     return new Dictionary<string, string>();
 }
예제 #10
0
 private object GetTermsCallBack(CacheItemArgs cacheItemArgs)
 {
     int vocabularyId = (int)cacheItemArgs.ParamList[0];
     return CBO.FillQueryable<Term>(_DataService.GetTermsByVocabulary(vocabularyId));
 }
 private static object GetModuleControlsCallBack(CacheItemArgs cacheItemArgs)
 {
     return CBO.FillDictionary<int, ModuleControlInfo>(key, dataProvider.GetModuleControls(), new Dictionary<int, ModuleControlInfo>());
 }
예제 #12
0
        internal static TObject GetCachedData <TObject>(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired, bool storeInDictionary)
        {
            //declare local object and try and retrieve item from the cache

            object objObject = null;

            if (!storeInDictionary)
            {
                objObject = GetCache(cacheItemArgs.CacheKey);
            }
            else if (dictionaryCache.ContainsKey(cacheItemArgs.CacheKey))
            {
                objObject = dictionaryCache[cacheItemArgs.CacheKey];
            }
            if (objObject == null)
            {
                object @lock = GetUniqueLockObject(cacheItemArgs.CacheKey);
                lock (@lock)
                {
                    if (!storeInDictionary)
                    {
                        objObject = GetCache(cacheItemArgs.CacheKey);
                    }
                    else if (dictionaryCache.ContainsKey(cacheItemArgs.CacheKey))
                    {
                        objObject = dictionaryCache[cacheItemArgs.CacheKey];
                    }
                    if (objObject == null)
                    {
                        try
                        {
                            objObject = cacheItemExpired(cacheItemArgs);
                        }
                        catch (Exception ex)
                        {
                            objObject = null;
                            Exceptions.LogException(ex);
                        }
                        if (storeInDictionary)
                        {
                            dictionaryCache[cacheItemArgs.CacheKey] = objObject;
                        }
                        else
                        {
                            // set cache timeout
                            int timeOut = cacheItemArgs.CacheTimeOut * Convert.ToInt32(Host.PerformanceSetting);
                            if (objObject != null && timeOut > 0)
                            {
                                //DataCache.SetCache(cacheItemArgs.CacheKey, objObject, cacheItemArgs.CacheDependency, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(timeOut), cacheItemArgs.CachePriority, cacheItemArgs.CacheCallback);
                                //if (DataCache.GetCache(cacheItemArgs.CacheKey) == null)
                                //{
                                //    LogInfo objEventLogInfo = new LogInfo();
                                //    objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.CACHE_OVERFLOW.ToString();
                                //    objEventLogInfo.LogProperties.Add(new LogDetailInfo(cacheItemArgs.CacheKey, "Overflow - Item Not Cached"));
                                //    EventLogController objEventLog = new EventLogController();
                                //    objEventLog.AddLog(objEventLogInfo);
                                //}
                            }
                        }
                        RemoveUniqueLockObject(cacheItemArgs.CacheKey);
                    }
                }
            }
            if (objObject == null)
            {
                return(default(TObject));
            }
            else
            {
                return((TObject)objObject);
            }
        }
예제 #13
0
 public static TObject GetCachedData <TObject>(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired)
 {
     return(GetCachedData <TObject>(cacheItemArgs, cacheItemExpired, false));
 }
예제 #14
0
 private object GetListInfoDictionaryCallBack(CacheItemArgs cacheItemArgs)
 {
     int portalId = (int)cacheItemArgs.ParamList[0];
     return FillListInfoDictionary(DataProvider.Instance().GetLists(portalId));
 }
예제 #15
0
 private static object GetResourceFileLookupDictionary(CacheItemArgs cacheItemArgs)
 {
     return new Dictionary<string, bool>();
 }
 private static object GetAuthenticationServicesCallBack(CacheItemArgs cacheItemArgs)
 {
     return CBO.FillCollection<AuthenticationInfo>(provider.GetAuthenticationServices());
 }
예제 #17
0
 private static object GetResourceFileCallBack(CacheItemArgs cacheItemArgs)
 {
     string cacheKey = cacheItemArgs.CacheKey;
     Dictionary<string, string> resources = null;
     Dictionary<string, bool> resourceFileExistsLookup = GetResourceFileLookupDictionary();
     if ((!resourceFileExistsLookup.ContainsKey(cacheKey)) || resourceFileExistsLookup[cacheKey])
     {
         string filePath = null;
         if (cacheKey.Contains(":\\") && Path.IsPathRooted(cacheKey))
         {
             if (File.Exists(cacheKey))
             {
                 filePath = cacheKey;
             }
         }
         if (filePath == null)
         {
             filePath = System.Web.Hosting.HostingEnvironment.MapPath(Globals.ApplicationPath + cacheKey);
         }
         if (File.Exists(filePath))
         {
             XPathDocument doc = null;
             doc = new XPathDocument(filePath);
             resources = new Dictionary<string, string>();
             foreach (XPathNavigator nav in doc.CreateNavigator().Select("root/data"))
             {
                 if (nav.NodeType != XPathNodeType.Comment)
                 {
                     resources[nav.GetAttribute("name", string.Empty)] = nav.SelectSingleNode("value").Value;
                 }
             }
             cacheItemArgs.CacheDependency = new CacheDependency(filePath);
             resourceFileExistsLookup[cacheKey] = true;
         }
         else
         {
             resourceFileExistsLookup[cacheKey] = false;
         }
     }
     return resources;
 }
예제 #18
0
 private static object GetTabsByPortalCallBack(CacheItemArgs cacheItemArgs)
 {
     int portalID = (int)cacheItemArgs.ParamList[0];
     List<TabInfo> tabs = CBO.FillCollection<TabInfo>(provider.GetTabs(portalID));
     return new TabCollection(tabs);
 }
 private static object GetTabModulesCallBack(CacheItemArgs cacheItemArgs)
 {
     int tabID = (int)cacheItemArgs.ParamList[0];
     return CBO.FillDictionary<int, ModuleInfo>("ModuleID", dataProvider.GetTabModules(tabID), new Dictionary<int, ModuleInfo>());
 }
예제 #20
0
 private static object GetTabPathDictionaryCallback(CacheItemArgs cacheItemArgs)
 {
     int portalID = (int)cacheItemArgs.ParamList[0];
     Dictionary<string, int> tabpathDic = new Dictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
     IDataReader dr = DataProvider.Instance().GetTabPaths(portalID);
     try
     {
         while (dr.Read())
         {
             tabpathDic[Null.SetNullString(dr["TabPath"])] = Null.SetNullInteger(dr["TabID"]);
         }
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
     finally
     {
         CBO.CloseDataReader(dr, true);
     }
     return tabpathDic;
 }
 private object GetScopeTypesCallBack(CacheItemArgs cacheItemArgs)
 {
     return CBO.FillQueryable<ScopeType>(_DataService.GetScopeTypes());
 }
예제 #22
0
 private static object GetSecureHostSettingsDictionaryCallBack(CacheItemArgs cacheItemArgs)
 {
     Dictionary<string, string> dicSettings = new Dictionary<string, string>();
     IDataReader dr = DataProvider.Instance().GetHostSettings();
     try
     {
         while (dr.Read())
         {
             if (Convert.ToInt32(dr[2]) < 1)
             {
                 string settingName = dr.GetString(0);
                 if (settingName.ToLower().IndexOf("password") == -1)
                 {
                     if (!dr.IsDBNull(1))
                     {
                         dicSettings.Add(settingName, dr.GetString(1));
                     }
                     else
                     {
                         dicSettings.Add(settingName, "");
                     }
                 }
             }
         }
     }
     finally
     {
         CBO.CloseDataReader(dr, true);
     }
     return dicSettings;
 }
예제 #23
0
 public static TObject GetCachedObject <TObject>(CacheItemArgs cacheItemArgs, CacheItemExpiredCallback cacheItemExpired)
 {
     return(DataCache.GetCachedData <TObject>(cacheItemArgs, cacheItemExpired));
 }
 private static object GetDesktopModulesByPortalCallBack(CacheItemArgs cacheItemArgs)
 {
     int portalId = (int)cacheItemArgs.ParamList[0];
     return CBO.FillDictionary<int, DesktopModuleInfo>("DesktopModuleID", dataProvider.GetDesktopModulesByPortal(portalId), new Dictionary<int, DesktopModuleInfo>());
 }
예제 #25
0
 private static object GetSkinDefaultsCallback(CacheItemArgs cacheItemArgs)
 {
     SkinDefaultType defaultType = (SkinDefaultType)cacheItemArgs.ParamList[0];
     return new SkinDefaults(defaultType);
 }
 private static object GetPortalDesktopModulesByPortalIDCallBack(CacheItemArgs cacheItemArgs)
 {
     int portalId = (int)cacheItemArgs.ParamList[0];
     return CBO.FillDictionary<int, PortalDesktopModuleInfo>("PortalDesktopModuleID", DataProvider.Instance().GetPortalDesktopModules(portalId, Null.NullInteger), new Dictionary<int, PortalDesktopModuleInfo>());
 }
 private static object GetFoldersSortedCallBack(CacheItemArgs cacheItemArgs)
 {
     int portalID = (int)cacheItemArgs.ParamList[0];
     return CBO.FillSortedList<string, FolderInfo>("FolderPath", DataProvider.Instance().GetFoldersByPortal(portalID));
 }
예제 #28
0
 private static object GetLocalesCallBack(CacheItemArgs cacheItemArgs)
 {
     try
     {
         int portalID = (int)cacheItemArgs.ParamList[0];
         Dictionary<string, Locale> locales;
         if (portalID > Null.NullInteger)
         {
             locales = CBO.FillDictionary<string, Locale>("CultureCode", DataProvider.Instance().GetLanguagesByPortal(portalID), new Dictionary<string, Locale>());
         }
         else
         {
             locales = CBO.FillDictionary<string, Locale>("CultureCode", DataProvider.Instance().GetLanguages(), new Dictionary<string, Locale>());
         }
         return locales;
     }
     catch
     {
         return null;
     }
 }
예제 #29
0
 private static object GetCachedUserByPortalCallBack(CacheItemArgs cacheItemArgs)
 {
     int portalId = (int)cacheItemArgs.ParamList[0];
     string username = (string)cacheItemArgs.ParamList[1];
     return memberProvider.GetUserByUserName(portalId, username);
 }
 private static object GetPortalSettingsDictionaryCallback(CacheItemArgs cacheItemArgs)
 {
     int portalID = (int)cacheItemArgs.ParamList[0];
     Dictionary<string, string> dicSettings = new Dictionary<string, string>();
     IDataReader dr = DataProvider.Instance().GetPortalSettings(portalID, PortalController.GetActivePortalLanguage(portalID));
     try
     {
         while (dr.Read())
         {
             if (!dr.IsDBNull(1))
             {
                 dicSettings.Add(dr.GetString(0), dr.GetString(1));
             }
         }
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
     finally
     {
         CBO.CloseDataReader(dr, true);
     }
     return dicSettings;
 }