コード例 #1
0
        /// <summary>
        /// При установке галочки "Готов к выгрузке"
        /// </summary>
        /// <param name="user"></param>
        /// <param name="id"></param>
        /// <param name="isReady"></param>
        /// <param name="message"></param>
        public void ClientVisit_SetReadyToFundSubmitRequest(User user, long id, bool isReady, string message)
        {
            if (isReady)
            {
                ClientVisit clientVisit = clientBusinessLogic.ClientVisit_Get(id);
                if (clientVisit.IsReadyToFundSubmitRequest)
                {
                    return;
                }
                ClientVisit.SaveData data = ClientVisit.SaveData.BuildSaveData(clientVisit);
                IEnumerable <ReconciliationFundResponse> responses = FundProcessingDao.Instance.FundResponse_GetList(id).OrderByDescending(item => item.CreateDate).OfType <ReconciliationFundResponse>();
                ClientVisit firstClientVisit = clientBusinessLogic.ClientVisit_GetFirstClientVisitInGroup(clientVisit.VisitGroupId);

                //ClientVisitOldDataBuilder oldDataBuilder = new ClientVisitOldDataBuilder(data, responses.OfType<IReconciliationFundResponse>().ToList());
                ClientVisitNewDataBuilder newDataBuilder = new ClientVisitNewDataBuilder(data, firstClientVisit, responses);
                //data = oldDataBuilder.Process();
                data = newDataBuilder.Process();

                //если установлена дата начала полиса и НЕ установлена дата окончания
                if (data.OldPolicy.StartDate.HasValue && !data.OldPolicy.EndDate.HasValue)
                {
                    data.OldPolicy.EndDate = new DateTime(2099, 12, 31);
                }
                if (data.NewPolicy.StartDate.HasValue && !data.NewPolicy.EndDate.HasValue)
                {
                    data.NewPolicy.EndDate = new DateTime(2099, 12, 31);
                }

                clientBusinessLogic.ClientVisit_Save(user, data);
            }
            FundProcessingDao.Instance.ClientVisit_SetReadyToFundSubmitRequest(id, isReady, message, DateTime.Now);
        }
コード例 #2
0
        public List <FundResponse.UploadReportData> UploadFundResponse(User user, string zipPath, bool runScenario)
        {
            List <FundResponse.UploadReportData> report = new List <FundResponse.UploadReportData>();
            string zipDirectoryName = Path.Combine(ConfiguraionProvider.FileStorageFolder, Path.GetFileNameWithoutExtension(zipPath));

            ZipHelper.UnZipFiles(zipPath, zipDirectoryName);
            FundResponseCreateDataBuilder builder = new FundResponseCreateDataBuilder();
            var      responsesToCreate            = GetResponsesFromArchive(builder, zipDirectoryName);
            var      responsesByclientVisitId     = GroupByClientVisitId(report, responsesToCreate);
            DateTime date = DateTime.Now;

            foreach (var pack in responsesByclientVisitId)
            {
                long        clientVisitId = pack.Key;
                ClientVisit clientVisit   = ClientDao.Instance.ClientVisit_Get(clientVisitId);
                if (clientVisit == null)
                {
                    foreach (var response in pack.Value)
                    {
                        report.Add(new FundResponse.UploadReportData()
                        {
                            Recid            = response.Recid,
                            ClientVisitId    = clientVisitId,
                            ResponseTypeName = response.GetResponseTypeName(),
                            UploadResult     = "Не найдена соответствующая заявка"
                        });
                    }
                    continue;
                }
                ClientVisit   lastClientVisitInGroup = ClientDao.Instance.ClientVisit_GetLastClientVisitInGroup(clientVisit.VisitGroupId);
                ReferenceItem lastCurrentStatus      = clientVisit.Status;
                DateTime      lastClientStatusDate   = clientVisit.StatusDate;
                long?         lastClientVisitId      = null;
                if (lastClientVisitInGroup.Status.Id == ClientVisitStatuses.FundError.Id ||
                    lastClientVisitInGroup.Status.Id == ClientVisitStatuses.AnswerPending.Id ||
                    lastClientVisitInGroup.Status.Id == ClientVisitStatuses.Processed.Id)
                {
                    clientBusinessLogic.ClientVisit_SetStatus(user, lastClientVisitInGroup.Id, ClientVisitStatuses.Reconciliation.Id, true);
                    lastCurrentStatus    = ClientVisitStatuses.Reconciliation;
                    lastClientStatusDate = date;
                }
                if (lastClientVisitInGroup.Status.Id == ClientVisitStatuses.SubmitPending.Id)
                {
                    ClientVisit.SaveData newClientVisitData = new ClientVisit.SaveData(lastClientVisitInGroup);
                    newClientVisitData.Status     = ClientVisitStatuses.Reconciliation.Id;
                    lastCurrentStatus             = ClientVisitStatuses.Reconciliation;
                    newClientVisitData.StatusDate = date;
                    lastClientStatusDate          = date;
                    newClientVisitData.IsActual   = true;
                    var saveResult = clientBusinessLogic.ClientVisit_Save(user, newClientVisitData, date);
                    lastClientVisitId = saveResult.ClientVisitID;
                }
                foreach (var response in pack.Value)
                {
                    FundProcessingDao.Instance.FundResponse_Create(response, date);
                    report.Add(AddReportItem(clientVisit, response, lastClientVisitId, lastCurrentStatus, lastClientStatusDate));
                }
                if (runScenario)
                {
                    clientVisit = ClientDao.Instance.ClientVisit_GetLastClientVisitInGroup(clientVisit.VisitGroupId);
                    ScenarioResolver     resolver         = new ScenarioResolver(clientVisit, pack.Value.OfType <ReconciliationFundResponse.CreateData>().ToList());
                    ReferenceItem        resolvedScenario = resolver.GetResolvedScenario();
                    ClientVisit.SaveData data             = ClientVisit.SaveData.BuildSaveData(clientVisit);
                    if (resolvedScenario != null)
                    {
                        data.ScenarioId = resolvedScenario.Id;
                        data.FundResponseApplyingMessage = string.Format("Сценарий изменён с {0} на {1}",
                                                                         clientVisit.Scenario != null ? clientVisit.Scenario.Code : string.Empty, resolvedScenario.Code);
                        data.IsReadyToFundSubmitRequest = true;
                        ClientVisitOldDataBuilder oldDataBuilder = new ClientVisitOldDataBuilder(data,
                                                                                                 pack.Value.OfType <IReconciliationFundResponse>().ToList());
                        ClientVisit firstClientVisit             = clientBusinessLogic.ClientVisit_GetFirstClientVisitInGroup(clientVisit.VisitGroupId);
                        ClientVisitNewDataBuilder newDataBuilder = new ClientVisitNewDataBuilder(data, firstClientVisit,
                                                                                                 pack.Value.OfType <IReconciliationFundResponse>().ToList());
                        data = oldDataBuilder.Process();
                        data = newDataBuilder.Process();
                    }
                    clientBusinessLogic.ClientVisit_Save(user, data);
                }
            }
            return(report);
        }