Esempio n. 1
0
        private ProcessedDateCategory CalculateProcessedDateCategory(ProcessType processType, int caId, DateTime eventDate)
        {
            DateTime?  targetDate   = new DateTime();
            DateTime?  criticalDate = new DateTime();
            CaTimeline caTimeline   = _context.CaTimeline.SingleOrDefault(ctv => ctv.CaId == caId);

            if (caTimeline == null)
            {
                return(ProcessedDateCategory.Missing);
            }

            switch (processType)
            {
            case ProcessType.Scrubbing:
                targetDate   = caTimeline.ScrubbingTarget;
                criticalDate = caTimeline.ScrubbingCritical;
                break;

            case ProcessType.Notification:
                targetDate   = caTimeline.NotificationTarget;
                criticalDate = caTimeline.NotificationCritical;
                break;

            case ProcessType.Response:
                targetDate   = caTimeline.ResponseTarget;
                criticalDate = caTimeline.ResponseCritical;
                break;

            case ProcessType.Instruction:
                targetDate   = caTimeline.InstructionTarget;
                criticalDate = caTimeline.InstructionCritical;
                break;

            case ProcessType.Payment:
                targetDate   = caTimeline.PaymentTarget;
                criticalDate = caTimeline.PaymentCritical;
                break;
            }

            if (!targetDate.HasValue || !criticalDate.HasValue)
            {
                return(ProcessedDateCategory.Missing);
            }

            return(GetProcessedDateCategory(eventDate, targetDate.Value, criticalDate.Value));
        }
Esempio n. 2
0
        public IHttpActionResult GetCaTimeline(int caId)
        {
            CaTimelineViewModel caTimelineModel = new CaTimelineViewModel {
                CaId = caId, TimelineDateFields = new List <TimelineField>(), CaProcessViewModels = new List <CaProcessViewModel>()
            };

            CaTimeline caTimeline = _context.CaTimeline.FirstOrDefault(ct => ct.CaId == caId);

            if (caTimeline != null)
            {
                caTimelineModel.TimelineRegions = caTimeline;
            }

            AppendCaProcessViewModels(caId, caTimelineModel.CaProcessViewModels);

            AppendRelevantCaTimelineFields(caId, caTimelineModel.TimelineDateFields);

            return(Ok(caTimelineModel));
        }
Esempio n. 3
0
        public void CalculateAndUpdateCaTimeline(ScrubCaCommand command)
        {
            CaTimeline caTimeline = _context.CaTimeline.FirstOrDefault(ct => ct.CaId == command.CaId);

            if (caTimeline != null)
            {
                _context.CaTimeline.Remove(caTimeline);
                _context.SaveChanges();
            }

            CaTimeline newTimeline = new CaTimeline();

            newTimeline.CaId = command.CaId;

            //Scrubbing Process Dates
            CaTypeDateConfiguration caTypeStartDateConfiguration    = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Scrubbing && dc.DateType.Equals("S", StringComparison.CurrentCultureIgnoreCase));
            CaTypeDateConfiguration caTypeTargetDateConfiguration   = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Scrubbing && dc.DateType.Equals("T", StringComparison.CurrentCultureIgnoreCase));
            CaTypeDateConfiguration caTypeCriticalDateConfiguration = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Scrubbing && dc.DateType.Equals("C", StringComparison.CurrentCultureIgnoreCase));

            newTimeline.ScrubbingStart    = DateTime.Parse(command.Fields[caTypeStartDateConfiguration.FieldRegistryId]).AddDays(caTypeStartDateConfiguration.DateOffset);
            newTimeline.ScrubbingTarget   = DateTime.Parse(command.Fields[caTypeTargetDateConfiguration.FieldRegistryId]).AddDays(caTypeTargetDateConfiguration.DateOffset);
            newTimeline.ScrubbingCritical = DateTime.Parse(command.Fields[caTypeCriticalDateConfiguration.FieldRegistryId]).AddDays(caTypeCriticalDateConfiguration.DateOffset);

            //Notification Process Dates
            caTypeStartDateConfiguration    = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Notification && dc.DateType.Equals("S", StringComparison.CurrentCultureIgnoreCase));
            caTypeTargetDateConfiguration   = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Notification && dc.DateType.Equals("T", StringComparison.CurrentCultureIgnoreCase));
            caTypeCriticalDateConfiguration = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Notification && dc.DateType.Equals("C", StringComparison.CurrentCultureIgnoreCase));

            newTimeline.NotificationStart    = DateTime.Parse(command.Fields[caTypeStartDateConfiguration.FieldRegistryId]).AddDays(caTypeStartDateConfiguration.DateOffset);
            newTimeline.NotificationTarget   = DateTime.Parse(command.Fields[caTypeTargetDateConfiguration.FieldRegistryId]).AddDays(caTypeTargetDateConfiguration.DateOffset);
            newTimeline.NotificationCritical = DateTime.Parse(command.Fields[caTypeCriticalDateConfiguration.FieldRegistryId]).AddDays(caTypeCriticalDateConfiguration.DateOffset);

            if (command.VolManCho.Equals("M", StringComparison.CurrentCultureIgnoreCase))
            {
                newTimeline.ResponseStart    = null;
                newTimeline.ResponseTarget   = null;
                newTimeline.ResponseCritical = null;

                newTimeline.InstructionStart    = null;
                newTimeline.InstructionTarget   = null;
                newTimeline.InstructionCritical = null;
            }
            else
            {
                //Response Process Dates
                caTypeStartDateConfiguration    = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Response && dc.DateType.Equals("S", StringComparison.CurrentCultureIgnoreCase));
                caTypeTargetDateConfiguration   = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Response && dc.DateType.Equals("T", StringComparison.CurrentCultureIgnoreCase));
                caTypeCriticalDateConfiguration = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Response && dc.DateType.Equals("C", StringComparison.CurrentCultureIgnoreCase));

                List <DateTime> optionDates = new List <DateTime>();
                command.Options.ForEach(opt => FindDate(opt.Fields, caTypeStartDateConfiguration.FieldRegistryId, optionDates));
                newTimeline.ResponseStart = optionDates.Min().AddDays(caTypeStartDateConfiguration.DateOffset);

                optionDates = new List <DateTime>();
                command.Options.ForEach(opt => FindDate(opt.Fields, caTypeTargetDateConfiguration.FieldRegistryId, optionDates));
                newTimeline.ResponseTarget = optionDates.Min().AddDays(caTypeTargetDateConfiguration.DateOffset);

                optionDates = new List <DateTime>();
                command.Options.ForEach(opt => FindDate(opt.Fields, caTypeCriticalDateConfiguration.FieldRegistryId, optionDates));
                newTimeline.ResponseCritical = optionDates.Min().AddDays(caTypeCriticalDateConfiguration.DateOffset);

                //Instruction Process Dates
                caTypeStartDateConfiguration    = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Instruction && dc.DateType.Equals("S", StringComparison.CurrentCultureIgnoreCase));
                caTypeTargetDateConfiguration   = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Instruction && dc.DateType.Equals("T", StringComparison.CurrentCultureIgnoreCase));
                caTypeCriticalDateConfiguration = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Instruction && dc.DateType.Equals("C", StringComparison.CurrentCultureIgnoreCase));

                optionDates = new List <DateTime>();
                command.Options.ForEach(opt => FindDate(opt.Fields, caTypeStartDateConfiguration.FieldRegistryId, optionDates));
                newTimeline.InstructionStart = optionDates.Min().AddDays(caTypeStartDateConfiguration.DateOffset);

                optionDates = new List <DateTime>();
                command.Options.ForEach(opt => FindDate(opt.Fields, caTypeTargetDateConfiguration.FieldRegistryId, optionDates));
                newTimeline.InstructionTarget = optionDates.Min().AddDays(caTypeTargetDateConfiguration.DateOffset);

                optionDates = new List <DateTime>();
                command.Options.ForEach(opt => FindDate(opt.Fields, caTypeCriticalDateConfiguration.FieldRegistryId, optionDates));
                newTimeline.InstructionCritical = optionDates.Min().AddDays(caTypeCriticalDateConfiguration.DateOffset);
            }

            //Payment Process Dates
            caTypeStartDateConfiguration    = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Payment && dc.DateType.Equals("S", StringComparison.CurrentCultureIgnoreCase));
            caTypeTargetDateConfiguration   = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Payment && dc.DateType.Equals("T", StringComparison.CurrentCultureIgnoreCase));
            caTypeCriticalDateConfiguration = _context.DatesConfigurations.FirstOrDefault(dc => dc.CaType == command.CaTypeId && dc.ProcessType == ProcessType.Payment && dc.DateType.Equals("C", StringComparison.CurrentCultureIgnoreCase));

            List <DateTime> payoutDates = new List <DateTime>();

            command.Options.ForEach(opt => opt.Payouts.ForEach(pt => FindDate(pt.Fields, caTypeStartDateConfiguration.FieldRegistryId, payoutDates)));
            newTimeline.PaymentStart = payoutDates.Min().AddDays(caTypeStartDateConfiguration.DateOffset);

            payoutDates = new List <DateTime>();
            command.Options.ForEach(opt => opt.Payouts.ForEach(pt => FindDate(pt.Fields, caTypeTargetDateConfiguration.FieldRegistryId, payoutDates)));
            newTimeline.PaymentTarget = payoutDates.Min().AddDays(caTypeTargetDateConfiguration.DateOffset);

            payoutDates = new List <DateTime>();
            command.Options.ForEach(opt => opt.Payouts.ForEach(pt => FindDate(pt.Fields, caTypeCriticalDateConfiguration.FieldRegistryId, payoutDates)));
            newTimeline.PaymentCritical = payoutDates.Min().AddDays(caTypeCriticalDateConfiguration.DateOffset);

            _context.CaTimeline.Add(newTimeline);
            _context.SaveChanges();
        }