コード例 #1
0
        private void UpdateScrubbingInfo(ScrubCaCommand command)
        {
            CaTimelineView timeline = _context.CaTimelineViews.First(t => t.CaId == command.CaId);

            ScrubbingInfo info = null;

            if (command.Fields != null)
            {
                foreach (KeyValuePair <int, string> caField in command.Fields)
                {
                    info = _context.ScrubbingInfo.Single(s => s.FieldRegistryId == caField.Key && s.CaId == command.CaId && s.OptionNumber == null && s.PayoutNumber == null);

                    info.PayoutTypeId          = command.CaTypeId;
                    info.FieldDisplay          = info.FieldDisplay.Substring(0, info.FieldDisplay.Length - 4) + " (CO)";
                    info.ProcessedDateCategory = GetProcessedDateCategory(@command.EventDate, timeline.ScrubbingTarget, timeline.ScrubbingCritical);
                    info.IsSrubbed             = true;
                }
            }

            if (command.Options != null)
            {
                foreach (OptionDto optionDto in command.Options)
                {
                    if (optionDto.Fields != null)
                    {
                        foreach (KeyValuePair <int, string> optionField in optionDto.Fields)
                        {
                            info = _context.ScrubbingInfo.Single(s => s.FieldRegistryId == optionField.Key && s.CaId == command.CaId && s.OptionNumber == optionDto.OptionNumber && s.PayoutNumber == null);

                            info.PayoutTypeId          = GetOptionTypeId(command.CaId, optionDto.OptionNumber);
                            info.FieldDisplay          = info.FieldDisplay.Substring(0, info.FieldDisplay.Length - 4) + " (CO)";
                            info.ProcessedDateCategory = GetProcessedDateCategory(@command.EventDate, timeline.ScrubbingTarget, timeline.ScrubbingCritical);
                            info.IsSrubbed             = true;
                        }
                    }

                    if (optionDto.Payouts != null)
                    {
                        foreach (PayoutDto payoutDto in optionDto.Payouts)
                        {
                            if (payoutDto.Fields != null)
                            {
                                foreach (KeyValuePair <int, string> payoutField in payoutDto.Fields)
                                {
                                    info = _context.ScrubbingInfo.Single(s => s.FieldRegistryId == payoutField.Key && s.CaId == command.CaId && s.OptionNumber == optionDto.OptionNumber && s.PayoutNumber == payoutDto.PayoutNumber);

                                    info.PayoutTypeId          = GetPayoutTypeId(command.CaId, optionDto.OptionNumber, payoutDto.PayoutNumber);
                                    info.FieldDisplay          = info.FieldDisplay.Substring(0, info.FieldDisplay.Length - 4) + " (CO)";
                                    info.ProcessedDateCategory = GetProcessedDateCategory(@command.EventDate, timeline.ScrubbingTarget, timeline.ScrubbingCritical);
                                    info.IsSrubbed             = true;
                                }
                            }
                        }
                    }
                }
            }

            _context.SaveChanges();
        }
コード例 #2
0
        private ProcessedDateCategory CalculateProcessedDateCategory(ProcessType processType, int caId, DateTime eventDate)
        {
            DateTime       targetDate   = new DateTime();
            DateTime       criticalDate = new DateTime();
            CaTimelineView caTimeline   = _context.CaTimelineViews.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;
            }

            return(GetProcessedDateCategory(eventDate, targetDate, criticalDate));
        }