public static SpecialAgent CreateSpecialAgentByZone(string clientNumber, string clientDivision, string zoneCode) { //Create a special agent by zone SpecialAgent specialAgent = null; try { //Use cached data specialAgent = (SpecialAgent)SpecialAgentsByZoneCached[clientNumber.Trim() + clientDivision.Trim() + zoneCode.Trim()]; if (specialAgent == null) { specialAgent = SpecialAgentDefault; } } catch (Exception ex) { throw new ApplicationException("Unexpected error while creating special agent by zone.", ex); } return(specialAgent); }
public static void RefreshCache() { //Refresh cached data try { //Get special agents from data store and cache results DataSet ds = Mediator.FillDataset(USP_SPECIALAGENT_DETAIL, TBL_SPECIALAGENT_DETAIL, null); if (ds == null) { throw new ApplicationException("Failed to cache special agents."); } else { //Cache special agents SpecialAgentsCached = new Hashtable(); SpecialAgentsByZoneCached = new Hashtable(); SpecialAgentDS specialAgentDS = new SpecialAgentDS(); specialAgentDS.Merge(ds); for (int i = 0; i < specialAgentDS.SpecialAgentTable.Rows.Count; i++) { SpecialAgent agent = null; if (specialAgentDS.SpecialAgentTable[i].ID == "0000") { agent = SpecialAgentDefault = new SpecialAgent(specialAgentDS.SpecialAgentTable[i]); } else if (specialAgentDS.SpecialAgentTable[i].ID == "0001") { agent = new StatSampleSpecialAgent(specialAgentDS.SpecialAgentTable[i]); } else if (specialAgentDS.SpecialAgentTable[i].ID.Substring(0, 2) == "04") { agent = new UPSSpecialAgent(specialAgentDS.SpecialAgentTable[i]); } else { agent = new SpecialAgent(specialAgentDS.SpecialAgentTable[i]); } SpecialAgentsCached.Add(agent.CLIENT_NUMBER.Trim() + agent.CLIENT_DIVISION.Trim() + agent.SAN_ID.Trim(), agent); SpecialAgentsByZoneCached.Add(agent.CLIENT_NUMBER.Trim() + agent.CLIENT_DIVISION.Trim() + agent.ZONE_CODE.Trim(), agent); } } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while caching SortFactory data.", ex); } }