public void ExtractRiteMap() { if (AreMapsExtracted()) { return; } try { bool flag0 = false, flag1 = false, flag2 = false; CoverageIdAttrMap = null; if (ConExp != null) { #region Extraction of Subschedule and preparation of ResolvedSchedule if (null != ConExp.Subschedules) { var ser = new ProtoCompressedSerializer(); Dictionary <string, Subschedule> dss = ser.Deserialize <Dictionary <string, Subschedule> >(ConExp.Subschedules, 0, ConExp.Subschedules.Length); if (null != dss) { SubSchedule = dss.Where(p => p.Value != null && p.Value.Type != null && (p.Value.Ids != null || p.Value.CompressedIds != null)) .ToDictionary(p => p.Key, p => p.Value); ResolvedSchedule = SubSchedule.ToDictionary(p => p.Key, p => ((p.Value.Ids != null) ? p.Value.Ids : new HashSet <long>(p.Value.CompressedIds.Enumerable()))); } if (ResolvedSchedule == null || ResolvedSchedule.Count() == 0) { BugLog("Error: Contract Exposure Schedules couldn't be deserialized."); } } else { BugLog("Error: Contract Exposure doesn't contain Schedules."); } #endregion #region Extraction of Rite Attributes if (ConExp.ContractSubjectExposures != null) { flag0 = true; foreach (ContractSubjectExposureOfRiteSchedule cseRites in ConExp.ContractSubjectExposures) { if (null != cseRites.RITECollectionExposure && null != cseRites.RITECollectionExposure.RITExposures) { flag1 = true; foreach (RITExposure ritExposure in cseRites.RITECollectionExposure.RITExposures) { if (ritExposure.RiskitemCharacteristicsList != null && ritExposure.RiskitemCharacteristicsList.Items != null) { flag2 = true; foreach (RiskItemCharacteristicsValuation idxEntry in ritExposure.RiskitemCharacteristicsList.Items) { if (null == CoverageIdAttrMap) { CoverageIdAttrMap = new Dictionary <long, RITEAttributes>(); } if (!CoverageIdAttrMap.ContainsKey(idxEntry.Id)) { var P = new RITEAttributes(); P.ExposureType = idxEntry.RiteTypeId; P.NumBuildings = ritExposure.CommonCharacteristics.NumBuildings; P.RITExposureId = ritExposure.ExposureID; P.Value = idxEntry.RITExposureValuationList.First().Value; CoverageIdAttrMap.Add(idxEntry.Id, P); } } } } } } } else { BugLog("Error: Contract Exposure Subject isn't exist."); } #endregion } if (!flag0) { BugLog("Error: Contract Exposure data wasn't uploaded from extract file."); } else if (!flag1) { BugLog("Error: Contract Exposure Risk Item Collection isn't exist."); } else if (!flag2) { BugLog("Error: Contract Exposure Risk Item Characteristics List isn't exist."); } #region Check //HashSet<long> coverageIDs1 = null, coverageIDs2 = null; //if (null != ResolvedSchedule) // coverageIDs1 = // ResolvedSchedule.Aggregate(new HashSet<long>(), (a, b) => { a.UnionWith(b.Value); return a; }); //if (null != CoverageIdAttrMap) // coverageIDs2 = new HashSet<long>(CoverageIdAttrMap.Keys); //int n1 = (null != coverageIDs1) ? coverageIDs1.Count() : 0; //int n2 = (null != coverageIDs2) ? coverageIDs2.Count() : 0; //if (n1 != n2) //{ // string msg = string.Format("Number of RITEs({0}) in Subschedules is not equal to number of RITEs({1}) in Collection of ContractSubjectExposures", n1, n2); // throw new Exception(msg); //} #endregion } catch (Exception ex) { BugLog("Error: " + ex.Message); } }
public void ExtractRiteMap() { if (AreMapsExtracted()) { return; } try { bool flag0 = false, flag1 = false, flag2 = false; CoverageIdAttrMap = null; if (ConExp != null) { #region Extraction of Subschedule and preparation of ResolvedSchedule if (null != ConExp.Subschedules) { var ser = new ProtoCompressedSerializer(); Dictionary <string, Subschedule> dss = ser.Deserialize <Dictionary <string, Subschedule> >(ConExp.Subschedules, 0, ConExp.Subschedules.Length); if (null != dss) { SubSchedule = dss.Where(p => p.Value != null && p.Value.Type != null && (p.Value.Ids != null || p.Value.CompressedIds != null)) .ToDictionary(p => p.Key, p => p.Value); ResolvedSchedule = SubSchedule.ToDictionary(p => p.Key, p => ((p.Value.Ids != null) ? p.Value.Ids : new HashSet <long>(p.Value.CompressedIds.Enumerable()))); } if (ResolvedSchedule == null || ResolvedSchedule.Count() == 0) { BugLog("Error: Contract Exposure Schedules couldn't be deserialized."); } } else { BugLog("Error: Contract Exposure doesn't contain Schedules."); } #endregion #region Extraction of Rite Attributes if (ConExp.ContractSubjectExposures != null) { flag0 = true; FactorGenerator generator = new FactorGenerator(); foreach (ContractSubjectExposureOfRiteSchedule cseRites in ConExp.ContractSubjectExposures) { if (null != cseRites.RITECollectionExposure && null != cseRites.RITECollectionExposure.RITExposures) { flag1 = true; foreach (RITExposure ritExposure in cseRites.RITECollectionExposure.RITExposures) { if (ritExposure.RiskitemCharacteristicsList != null && ritExposure.RiskitemCharacteristicsList.Items != null) { flag2 = true; foreach (RiskItemCharacteristicsValuation idxEntry in ritExposure.RiskitemCharacteristicsList.Items) { if (null == CoverageIdAttrMap) { CoverageIdAttrMap = new Dictionary <long, ExtractRITCharInfo>(); } if (!CoverageIdAttrMap.ContainsKey(idxEntry.Id)) { var P = new ExtractRITCharInfo(); P.ExposureType = idxEntry.RiteTypeId; P.NumBuildings = ritExposure.CommonCharacteristics.NumBuildings; P.RITExposureId = ritExposure.ExposureID; P.Value = idxEntry.RITExposureValuationList.First().Value; P.OriginalRITECharacteristicId = idxEntry.ParentId; P.NumSamples = generator.GetFactor(ritExposure).NumOfSamples; //P.NumSamples = generator.GetNumOfSamples(ritExposure); P.Factor = generator.GetFactor(ritExposure).Factor; //needed for NumSamples algorithm P.NumUnits = ritExposure.CommonCharacteristics.NumUnits; P.HazardScaleFactor = ritExposure.CommonCharacteristics.TaxValue; P.OriginWeightsGeoIDLookupIntCode = ritExposure.CommonCharacteristics.FireAlarm; P.OriginWEightsLOBLookupCode = ritExposure.CommonCharacteristics.FirePlace; P.DisAggResolutionIntCode = ritExposure.CommonCharacteristics.NumberOfEscalators; P.Address = ritExposure.Address; //-- if (ritExposure.ClonedExposureId != null) { P.OriginalRITExposureId = (long)ritExposure.ClonedExposureId; } //else // throw new InvalidOperationException("Clone Exposure ID is null!"); CoverageIdAttrMap.Add(idxEntry.Id, P); } } } } } } } else { BugLog("Error: Contract Exposure Subject isn't exist."); } #endregion } if (!flag0) { BugLog("Error: Contract Exposure data wasn't uploaded from extract file."); } else if (!flag1) { BugLog("Error: Contract Exposure Risk Item Collection isn't exist."); } else if (!flag2) { BugLog("Error: Contract Exposure Risk Item Characteristics List isn't exist."); } #region Check //HashSet<long> coverageIDs1 = null, coverageIDs2 = null; //if (null != ResolvedSchedule) // coverageIDs1 = // ResolvedSchedule.Aggregate(new HashSet<long>(), (a, b) => { a.UnionWith(b.Value); return a; }); //if (null != RiskItemCharacteristicIDAttributeMap) // coverageIDs2 = new HashSet<long>(RiskItemCharacteristicIDAttributeMap.Keys); //int n1 = (null != coverageIDs1) ? coverageIDs1.Count() : 0; //int n2 = (null != coverageIDs2) ? coverageIDs2.Count() : 0; //if (n1 != n2) //{ // string msg = string.Format("Number of RITEs({0}) in Subschedules is not equal to number of RITEs({1}) in Collection of ContractSubjectExposures", n1, n2); // throw new Exception(msg); //} #endregion } catch (Exception ex) { BugLog("Error: " + ex.Message); } }