public static void RemoveFromPrivateDictionary(string DnnCacheKey) { using (dictionaryCache.GetWriteLock()) { dictionaryCache.Remove(CleanCacheKey(DnnCacheKey)); } }
public void SecondTimer() { foreach (var client in SyncClients) { client.SecondTimer(); } // Run through socket connections lock (Connections) foreach (var socket in Connections) { socket.SecondTimer(); } var deadSockets = Connections.Where(c => c.State == TcpState.Closed).ToList(); foreach (var socket in deadSockets) { Connections.Remove(socket); string message = "Connection to " + socket.ToString() + " Removed"; if (socket.ByeMessage != null) { message += ", Reason: " + socket.ByeMessage; } Log(message); SyncClients.Remove(socket); if (socket == ServerConnection) { ServerConnection = null; } // socket.TcpSocket = null; causing endrecv to fail on disconnect } }
private static void AddToTabDict(SharedDictionary<string, string> tabIndex, Dictionary<string, DupKeyCheck> dupCheckDict, string httpAlias, string tabPath, string rewrittenPath, int tabId, UrlEnums.TabKeyPreference keyDupAction, ref int tabPathDepth, bool checkForDupUrls, bool isDeleted) { //remove leading '/' and convert to lower for all keys string tabPathSimple = tabPath.Replace("//", "/").ToLower(); //the tabpath depth is only set if it's higher than the running highest tab path depth int thisTabPathDepth = tabPathSimple.Length - tabPathSimple.Replace("/", "").Length; if (thisTabPathDepth > tabPathDepth) { tabPathDepth = thisTabPathDepth; } if ((tabPathSimple.Length > 0 && tabPathSimple[0] == '/')) { tabPathSimple = tabPathSimple.Substring(1); } //Contruct the tab key for the dictionary. Using :: allows for separation of portal alias and tab path. string tabKey = (httpAlias + "::" + tabPathSimple).ToLower(); //construct the duplicate key check string dupKey = (httpAlias + "/" + tabPathSimple).ToLower(); if (dupKey[dupKey.Length - 1] != '/') { dupKey += "/"; } //now make sure there is NEVER a duplicate key exception by testing for existence first using (tabIndex.GetWriteLock()) { if (tabIndex.ContainsKey(tabKey)) { //it's possible for a tab to be deleted and the tab path repeated. //the dictionary must be checked to ascertain whether the existing tab //should be replaced or not. If the action is 'TabOK' it means //replace the entry regardless. If the action is 'TabRedirected' it means //replace the existing dictionary ONLY if the existing dictionary entry is a //deleted tab. bool replaceTab = (keyDupAction == UrlEnums.TabKeyPreference.TabOK); //default, replace the tab if (replaceTab == false) { //ok, the tab to be added is either a redirected or deleted tab //get the existing entry //775 : don't assume that the duplicate check dictionary has the key if (dupCheckDict.ContainsKey(dupKey)) { DupKeyCheck foundTab = dupCheckDict[dupKey]; //a redirected tab will replace a deleted tab if (foundTab.IsDeleted && keyDupAction == UrlEnums.TabKeyPreference.TabRedirected) { replaceTab = true; } if (foundTab.TabIdOriginal == "-1") { replaceTab = true; } } } if (replaceTab && !isDeleted) //don't replace if the incoming tab is deleted { //remove the previous one tabIndex.Remove(tabKey); //add the new one tabIndex.Add(tabKey, Globals.glbDefaultPage + rewrittenPath); } } else { //just add the tabkey into the dictionary tabIndex.Add(tabKey, Globals.glbDefaultPage + rewrittenPath); } } //checking for duplicates means throwing an exception when one is found, but this is just logged to the event log if (dupCheckDict.ContainsKey(dupKey)) { DupKeyCheck foundTAb = dupCheckDict[dupKey]; if ((foundTAb.IsDeleted == false && isDeleted == false) //found is not deleted, this tab is not deleted && keyDupAction == UrlEnums.TabKeyPreference.TabOK && foundTAb.TabIdOriginal != "-1") //-1 tabs are login, register, privacy etc { //check whether to log for this or not if (checkForDupUrls && foundTAb.TabIdOriginal != tabId.ToString()) //dont' show message for where same tab is being added twice) { //there is a naming conflict where this alias/tab path could be mistaken int tabIdOriginal; string tab1Name = "", tab2Name = ""; if (int.TryParse(foundTAb.TabIdOriginal, out tabIdOriginal)) { Dictionary<int, int> portalDic = PortalController.GetPortalDictionary(); int portalId = -1; if (portalDic != null && portalDic.ContainsKey(tabId)) { portalId = portalDic[tabId]; } var tc = new TabController(); TabInfo tab1 = tc.GetTab(tabIdOriginal, portalId, false); TabInfo tab2 = tc.GetTab(tabId, portalId, false); if (tab1 != null) { tab1Name = tab1.TabName + " [" + tab1.TabPath + "]"; } if (tab2 != null) { tab2Name = tab2.TabName + " [" + tab2.TabPath + "]"; } } string msg = "Page naming conflict. Url of (" + foundTAb.TabPath + ") resolves to two separate pages (" + tab1Name + " [tabid = " + foundTAb.TabIdOriginal + "], " + tab2Name + " [tabid = " + tabId.ToString() + "]). Only the second page will be shown for the url."; const string msg2 = "PLEASE NOTE : this is an information message only, this message does not affect site operations in any way."; //771 : change to admin alert instead of exception var elc = new EventLogController(); //log a host alert var logValue = new LogInfo { LogTypeKey = "HOST_ALERT" }; logValue.AddProperty("Advanced Friendly URL Provider Duplicate URL Warning", "Page Naming Conflict"); logValue.AddProperty("Duplicate Page Details", msg); logValue.AddProperty("Warning Information", msg2); logValue.AddProperty("Suggested Action", "Rename one or both of the pages to ensure a unique URL"); logValue.AddProperty("Hide this message", "To stop this message from appearing in the log, uncheck the option for 'Produce an Exception in the Site Log if two pages have the same name/path?' in the Advanced Url Rewriting settings."); logValue.AddProperty("Thread Id", Thread.CurrentThread.ManagedThreadId.ToString()); elc.AddLog(logValue); } } else { dupCheckDict.Remove(dupKey); //add this tab to the duplicate key dictionary dupCheckDict.Add(dupKey, new DupKeyCheck(dupKey, tabId.ToString(), dupKey, isDeleted)); } } else { //add this tab to the duplicate key dictionary - the dup key check dict is always maintained //regardless of whether checking is employed or not dupCheckDict.Add(dupKey, new DupKeyCheck(dupKey, tabId.ToString(), dupKey, isDeleted)); } }