Ejemplo n.º 1
0
        public void GetPrimaryData()
        {
            if (TreatyExposure)
            {
                throw new InvalidOperationException("Cannot use this method to get exposure data for reinsurance contract");
            }

            EDSDataExtract.ExtractRiteMap();

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            var LocationGroups = EDSDataExtract.CoverageIdAttrMap.GroupBy(pair => pair.Value.RITExposureId);

            foreach (var LocGroup in LocationGroups)
            {
                RITE newRITE = BuildRITE(LocGroup.First());
                _rites.Add(newRITE);
                _ritesDict.Add(LocGroup.Key, newRITE);

                foreach (KeyValuePair <long, RiskItemCharacteristicIDAttributes> pair in LocGroup)
                {
                    RITCharacteristic newRITChar = BuildRITCharacteristic(pair);
                    _characteristics.Add(newRITChar);
                    _characteristicsDict.Add(pair.Key, newRITChar);
                    newRITE.AddCharacteristic(newRITChar);
                }
            }


            foreach (KeyValuePair <string, Subschedule> EDSschedule in EDSDataExtract.SubSchedule)
            {
                ScheduleOfRITEs newSchedule;
                HashSet <long>  Ids = (EDSschedule.Value.Ids != null) ? EDSschedule.Value.Ids : new HashSet <long>(EDSschedule.Value.CompressedIds.Enumerable());
                if (EDSschedule.Value.Type == SubscheduleType.RITCHARACTERISTICS)
                {
                    newSchedule = BuildScheduleFromRITChars2(EDSschedule.Key, Ids);
                }
                else if (EDSschedule.Value.Type == SubscheduleType.RITEXPOSURES)
                {
                    newSchedule = BuildScheduleFromRITs2(EDSschedule.Key, Ids);
                }
                else
                {
                    throw new InvalidOperationException("Cannot support building schedules of type: " + EDSschedule.Value.Type.ToString());
                }

                _schedules.Add(newSchedule);
                _schedulesDict.Add(newSchedule.Name, newSchedule);
            }

            stopwatch.Stop();

            ////////////////////////OLD OLD OLD Version//////////////////////////////////
            //_schedules.Clear();
            //_rites.Clear();
            //_characteristics.Clear();

            //stopwatch.Reset();
            //stopwatch.Start();

            //foreach (KeyValuePair<long, RiskItemCharacteristicIDAttributes> RiteAttribute in EDSDataExtract.RiskItemCharacteristicIDAttributeMap)
            //{
            //    RITCharacteristic newRITChar = BuildRITCharacteristic(RiteAttribute);
            //    _characteristics.Add(newRITChar);
            //    RITE parentRITE = _rites.Where(rite => rite.ExposureID == RiteAttribute.Value.RITExposureId).FirstOrDefault();

            //    if (parentRITE != null)
            //    {
            //        parentRITE.AddCharacteristic(newRITChar);
            //    }
            //    else
            //    {
            //        RITE newRITE = BuildRITE(RiteAttribute);
            //        _rites.Add(newRITE);
            //        newRITE.AddCharacteristic(newRITChar);
            //    }

            //}

            //foreach (KeyValuePair<string, Subschedule> EDSschedule in EDSDataExtract.SubSchedule)
            //{
            //    ScheduleOfRITEs newSchedule;
            //    HashSet<long> Ids = (EDSschedule.Value.Ids != null) ? EDSschedule.Value.Ids : new HashSet<long>(EDSschedule.Value.CompressedIds.Enumerable());
            //    if (EDSschedule.Value.Type == SubscheduleType.RITCHARACTERISTICS)
            //        newSchedule = BuildScheduleFromRITChars(EDSschedule.Key, Ids);
            //    else if (EDSschedule.Value.Type == SubscheduleType.RITEXPOSURES)
            //        newSchedule = BuildScheduleFromRITs(EDSschedule.Key, Ids);
            //    else
            //        throw new InvalidOperationException("Cannot support building schedules of type: " + EDSschedule.Value.Type.ToString());

            //    _schedules.Add(newSchedule);
            //}

            //stopwatch.Stop();
        }
Ejemplo n.º 2
0
        //public ExposureDataAdaptor(ContractExposure contractExposure, NGFMPrototype _ParsingAPI)
        //{
        //    //ParsingAPI = _ParsingAPI;
        //    UseJSContext = false;
        //    _contractExposure = contractExposure;

        //    _contractJSON = GetJSONForContract();
        //    EDSDataExtract = new ExposureDataExtractor(_contractExposure);

        //    _characteristics = new HashSet<RITCharacteristic>();
        //    _rites = new HashSet<RITE>();
        //    _schedules = new HashSet<ScheduleOfRITEs>();
        //    _characteristicsDict = new Dictionary<long, RITCharacteristic>();
        //    _ritesDict = new Dictionary<long, RITE>();
        //    _schedulesDict = new Dictionary<string, ScheduleOfRITEs>();

        //    if (_contractExposure.ContractType.IsReinsuranceContract())
        //        TreatyExposure = true;
        //    else
        //        TreatyExposure = false;
        //}

        public void GetPrimaryData()
        {
            if (TreatyExposure)
            {
                throw new InvalidOperationException("Cannot use this method to get exposure data for reinsurance contract");
            }

            EDSDataExtract.ExtractRiteMap();

            Dictionary <long, ExtractRITCharInfo> CoverageIdAttrMap = EDSDataExtract.CoverageIdAttrMap;

            if (UseAggregatedRITEs)
            {
                CoverageIdAttrMap = AggregateRITChars(CoverageIdAttrMap);
            }
            else
            {
                foreach (KeyValuePair <long, ExtractRITCharInfo> pair in CoverageIdAttrMap)
                {
                    RiskCharIDtoAggregateID.Add(pair.Key, pair.Key);
                    AggregateIDtoDisaggIDs.Add(pair.Key, new HashSet <long> {
                        pair.Key
                    });
                }
            }

            #region old RITE aggreagation code


            //foreach (var LocGroup in LocationGroups)
            //{
            //    if (UseAggregatedRITEs)
            //    {
            //        long RiteID = LocGroup.First().Value.RITExposureId;
            //        long OriginalRiteID = (long)LocGroup.First().Value.OriginalRITExposureId;

            //        if (RiteID == OriginalRiteID)
            //        {
            //            RITE newRITE = BuildRITE(LocGroup.First());
            //            _rites.Add(newRITE);
            //            _ritesDict.Add(LocGroup.Key, newRITE);

            //            foreach (KeyValuePair<long, ExtractRITCharInfo> pair in LocGroup)
            //            {
            //                RITCharacteristic newRITChar = BuildRITCharacteristic(pair);
            //                _characteristics.Add(newRITChar);
            //                _characteristicsDict.Add(pair.Key, newRITChar);
            //                newRITE.AddCharacteristic(newRITChar);
            //            }
            //        }
            //        else
            //        {
            //            foreach (KeyValuePair<long, ExtractRITCharInfo> pair in LocGroup)
            //            {
            //                RiskCharIDtoAggregateID.Add(pair.Key, (long)pair.Value.OriginalRITECharacteristicId);
            //            }
            //        }
            //    }
            //    else
            //    {
            //        RITE newRITE = BuildRITE(LocGroup.First());
            //        _rites.Add(newRITE);
            //        _ritesDict.Add(LocGroup.Key, newRITE);

            //        foreach (KeyValuePair<long, ExtractRITCharInfo> pair in LocGroup)
            //        {
            //            RITCharacteristic newRITChar = BuildRITCharacteristic(pair);
            //            _characteristics.Add(newRITChar);
            //            _characteristicsDict.Add(pair.Key, newRITChar);
            //            newRITE.AddCharacteristic(newRITChar);
            //        }
            //    }
            //}

            #endregion

            var LocationGroups = CoverageIdAttrMap.GroupBy(pair => pair.Value.RITExposureId);

            foreach (var LocGroup in LocationGroups)
            {
                RITE newRITE = BuildRITE(LocGroup.First());
                _rites.Add(newRITE);
                _ritesDict.Add(LocGroup.Key, newRITE);

                foreach (KeyValuePair <long, ExtractRITCharInfo> pair in LocGroup)
                {
                    RITCharacteristic newRITChar = BuildRITCharacteristic(pair);
                    _characteristics.Add(newRITChar);
                    _characteristicsDict.Add(pair.Key, newRITChar);
                    newRITE.AddCharacteristic(newRITChar);
                }
            }


            foreach (KeyValuePair <string, Subschedule> EDSschedule in EDSDataExtract.SubSchedule)
            {
                ScheduleOfRITEs newSchedule;
                HashSet <long>  Ids = (EDSschedule.Value.Ids != null) ? EDSschedule.Value.Ids : new HashSet <long>(EDSschedule.Value.CompressedIds.Enumerable());

                if (EDSschedule.Value.Type == SubscheduleType.RITCHARACTERISTICS) //|| EDSschedule.Value.Name == "Blanket_FL" || EDSschedule.Value.Name == "Blanket_EQ" || EDSschedule.Value.Name == "Blanket_WS")    //Sunny Hack
                {
                    newSchedule = BuildScheduleFromRITChars2(EDSschedule.Key, Ids);
                }
                else if (EDSschedule.Value.Type == SubscheduleType.RITEXPOSURES)
                {
                    try { newSchedule = BuildScheduleFromRITs2(EDSschedule.Key, Ids); }
                    catch (IndexOutOfRangeException exp)
                    {
                        newSchedule = BuildScheduleFromRITChars2(EDSschedule.Key, Ids);
                    }
                }
                else
                {
                    throw new InvalidOperationException("Cannot support building schedules of type: " + EDSschedule.Value.Type.ToString());
                }

                _schedules.Add(newSchedule);
                _schedulesDict.Add(newSchedule.Name, newSchedule);
            }
        }