public static OffnetAttributes Get(long id, DateTime effectiveDate) { OffnetAttributes atts; atts = _Cache.CheckCache(id.ToString()); if (atts == null) { atts.ListAttributes = OffnetDataAccess.GetServiceAttributes(id, effectiveDate); } _Cache.StoreCache(id.ToString(), atts); return(atts); }
public static OffnetServiceConfiguration Get(long id, DateTime effectiveDate) { var sKey = id.ToString(); var configs = _Cache.CheckCache(sKey); OffnetServiceConfiguration sc; if (configs == null) { try { sc = OffnetDataAccess.GetServiceConfig(id, effectiveDate); _Cache.StoreCache(id.ToString(), new List <OffnetServiceConfiguration>() { sc }); } catch (Exception e) { sc = new OffnetServiceConfiguration(); throw new ApplicationException("Error fetching service configuration :" + e.Message); } } else { sc = configs.FirstOrDefault(c => c.IsEffective(effectiveDate)); if (sc == null) { try { sc = OffnetDataAccess.GetServiceConfig(id, effectiveDate); configs.Add(sc); } catch (Exception e) { sc = new OffnetServiceConfiguration(); throw new ApplicationException("Error fetching service configuration :" + e.Message); } } _Cache.StoreCache(id.ToString(), new List <OffnetServiceConfiguration>() { sc }); } return(sc); }
public PartnerServiceConfig Get(PartnerKeyWeb Key) { PartnerServiceConfig config; config = _Cache.CheckCache(Key.PartnerOrderId.ToString()); if (config == null) { try { config = OffnetDataAccess.GetPartnerServiceConfig(Key.PartnerOrderId); } catch (Exception e) { throw new ApplicationException("Error Fetching the PartnerServiceConfig :" + e.Message); } } _Cache.StoreCache(Key.PartnerOrderId.ToString(), config); return(config); }
public PartnerKeyWeb Get(int vendorId, string vendorName, string source) { PartnerKeyWeb key; key = _Cache.CheckCache(vendorId + vendorName + source); if (key == null) { try { var queryRes = OffnetDataAccess.GetPartnerAttribuesByVendor(vendorId, vendorName, source); key = queryRes.ToWeb(); } catch (Exception e) { e.Data.Add("Custom Msg", "Error while fetching Partner attributes;"); throw (e); } } _Cache.StoreCache(vendorId + vendorName + source, key); return(key); }
public static OffnetAttributeSourcesInfoWeb GetAttributes(OffnetServiceKey key, bool populateLists) { AttributeInfoWeb list; OffnetAttributeInfoWeb[] info; OffnetAttributeSourceInfo source; OffnetAttributeSourceInfo[] sources; OffnetAttributeSourcesInfoWeb infoWeb; if (key == null) { infoWeb = new OffnetAttributeSourcesInfoWeb { ErrorString = "Key cannot be null" }; return(infoWeb); } try { var atts = Get(key, populateLists); var srcs = OffnetDataAccess.GetOffnetAttributeSource(key); string name = null; string value = null; string partnerOrderId = null; info = new OffnetAttributeInfoWeb[atts.Count]; var i = 0; foreach (var att in atts) { name = att.Name; value = att.GetValue(); list = new AttributeInfoWeb(att); info[i++] = new OffnetAttributeInfoWeb(name, value, list); if (name == "PartnerOrderId") { partnerOrderId = value; } } //var attributes= srcs.Where(x => x.PartnerOrderId.ToString() == partnerOrderId && x.OffnetServiceId == key.Id).Select(x => x.AttributeName).ToList(); List <string> filteredSrcs = new List <string>(); filteredSrcs = srcs.Where(x => x.PartnerOrderId.ToString() == partnerOrderId && x.OffnetServiceId == key.Id).Select(x => x.AttributeSource).Distinct().ToList(); sources = new OffnetAttributeSourceInfo[filteredSrcs.Count]; var j = 0; foreach (var s in filteredSrcs) { var attributes = new List <string>(srcs.Where(x => x.PartnerOrderId.ToString() == partnerOrderId && x.OffnetServiceId == key.Id && x.AttributeSource == s) .Select(x => x.AttributeName).ToList()); Dictionary <string, string> keyValuePairs = new Dictionary <string, string>(); foreach (var a in attributes) { var attrList = info.ToList(); var v = attrList.Where(x => x.AttributeProperties.Name.Equals(a)).Select(x => x.AttributeProperties.Value).FirstOrDefault(); keyValuePairs.Add(a, v); } source = new OffnetAttributeSourceInfo { Source = s, OffnetServiceId = key.Id, PartnerOrderId = partnerOrderId, Attributes = keyValuePairs }; sources[j++] = source; } infoWeb = new OffnetAttributeSourcesInfoWeb(sources, info); } catch (Exception e) { infoWeb = new OffnetAttributeSourcesInfoWeb { ErrorString = e.Message }; } return(infoWeb); }