private static FundResponse.UploadReportData AddReportItem( ClientVisit clientVisit, FundResponse.CreateData response, long?newClientVisitId, ReferenceItem status = null, DateTime?statusDate = null, string message = "Загружена сверка") { return(new FundResponse.UploadReportData() { Recid = response.Recid, ClientVisitId = newClientVisitId ?? clientVisit.Id, Birthday = clientVisit.NewClientInfo.Birthday, ClientId = clientVisit.ClientId, VisitGroupId = clientVisit.VisitGroupId, DeliveryCenter = clientVisit.DeliveryCenter, Fullname = clientVisit.NewClientInfo.Fullname, PolicyNumber = clientVisit.NewPolicy.Number, PolicySeries = clientVisit.NewPolicy.Series, PolicyParty = clientVisit.PolicyPartyNumber, Sex = clientVisit.NewClientInfo.Sex, Status = status ?? clientVisit.Status, StatusDate = statusDate ?? clientVisit.StatusDate, TemporaryPolicyDate = clientVisit.TemporaryPolicyDate, TemporaryPolicyNumber = clientVisit.TemporaryPolicyNumber, UnifiedPolicyNumber = clientVisit.NewPolicy.UnifiedPolicyNumber, ResponseTypeName = response.GetResponseTypeName(), UploadResult = message }); }
public ActionResult AddToClient(long?id, long?CopyVisitId, bool?newGroup) { ClientVisitSaveDataModel model = new ClientVisitSaveDataModel(CurrentUser, id); if (CopyVisitId.HasValue && CopyVisitId.Value != 0) { ClientVisit clientVisit = clientBusinessLogic.ClientVisit_Get(CopyVisitId.Value); model = new ClientVisitSaveDataModel(CurrentUser, clientVisit, true); model.ClearIds(); if (newGroup.HasValue && !newGroup.Value) { model.VisitGroupId = clientVisit.VisitGroupId; } else { model.TemporaryPolicyDate = null; model.IssueDate = null; model.TemporaryPolicyNumber = null; } } model.DeliveryCenterId = CurrentUser.Department.Id; model.DeliveryPointId = CurrentUser.DeliveryPoint.Id; model.Registrator = new UserModel(userBusinessLogic.User_GetByLogin(this.HttpContext.User.Identity.Name)); model.Messages.Clear(); model.MessagesNotCritical.Clear(); return(PartialView(model)); }
public void ApplyResponse(User user, FundResponseCopyFields fundResponseCopyFields) { ClientVisit lastClientVisit = clientBusinessLogic.ClientVisit_GetLastClientVisitInGroup(fundResponseCopyFields.ClientVisitGroupId); if (lastClientVisit.Status.Id == ClientVisitStatuses.FundError.Id || lastClientVisit.Status.Id == ClientVisitStatuses.Processed.Id || lastClientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id) { clientBusinessLogic.ClientVisit_SetStatus(user, lastClientVisit.Id, ClientVisitStatuses.Reconciliation.Id, true); lastClientVisit = clientBusinessLogic.ClientVisit_GetLastClientVisitInGroup(fundResponseCopyFields.ClientVisitGroupId); } else if (lastClientVisit.Status.Id != ClientVisitStatuses.Reconciliation.Id) { ClientVisit.SaveData newClientVisitData = new ClientVisit.SaveData(lastClientVisit); newClientVisitData.Status = ClientVisitStatuses.Reconciliation.Id; newClientVisitData.IsActual = true; var saveResult = clientBusinessLogic.ClientVisit_Save(user, newClientVisitData, DateTime.Now); lastClientVisit = clientBusinessLogic.ClientVisit_GetLastClientVisitInGroup(fundResponseCopyFields.ClientVisitGroupId); } if (lastClientVisit.Status.Id == ClientVisitStatuses.Reconciliation.Id) { FundResponse response = FundProcessingDao.Instance.FundResponse_Get(fundResponseCopyFields.ResponseId); ClientVisit.SaveData data = ClientVisit.SaveData.BuildSaveData(lastClientVisit); response.Apply(data, fundResponseCopyFields.NewFields, fundResponseCopyFields.OldFields); clientBusinessLogic.ClientVisit_Save(user, data); } }
/// <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); }
public ActionResult BSOHistory(long id) { BSO bso = bsoBusinessLogic.BSO_GetByID(id); BSOBaseModel model = new BSOBaseModel(bso); if (bso.VisitGroupId != null) { ClientVisit clientVisit = clientBusinessLogic.ClientVisit_GetLastClientVisitInGroup((long)bso.VisitGroupId); model.ClientVisitId = clientVisit.Id; model.ClientId = clientVisit.ClientId; } foreach (var a in model.HistoryModel) { if (model.UserId != null) { User user = userBusinessLogic.User_Get((long)a.UserId); if (user != null) { a.UserName = user.Lastname + " " + user.Firstname.Remove(1) + "." + " " + user.Secondname.Remove(1) + "."; } } if (a.ResponsibleID != null) { User user = userBusinessLogic.User_Get((long)a.ResponsibleID); if (user != null) { a.ResponsibleName = user.Lastname + " " + user.Firstname.Remove(1) + "." + " " + user.Secondname.Remove(1) + "."; } } } return(View(model)); }
public void ClientVisitCreate_NewUser() { Client.CreateData clientCreateData = ClientGenerator.GetClientCreateData("Иван", "Иванович", "Иванов", "1"); ClientBusinessLogic bll = new ClientBusinessLogic(); ClientVisit.SaveData data = ClientGenerator.GetClientVisitSaveDataForNewUser(); long clientId = bll.ClientVisit_Save(new User() { Roles = new List <Role>() { Role.Administrator } }, data).ClientID; Client client = bll.Client_Get(new User() { Roles = new List <Role>() { Role.Administrator } }, clientId); long visitId = client.Visits.OrderByDescending(item => item.StatusDate).FirstOrDefault().Id; ClientVisit visit = bll.ClientVisit_Get(visitId); Assert.IsNotNull(visit); Assert.IsNotNull(visit.LivingAddress); Assert.IsNotNull(visit.RegistrationAddress); Assert.IsNotNull(visit.OldClientInfo); Assert.IsNotNull(visit.NewClientInfo); Assert.IsNotNull(visit.OldDocument); Assert.IsNotNull(visit.NewDocument); Assert.IsNotNull(visit.NewPolicy); Assert.IsNotNull(visit.OldPolicy); }
public ActionResult DuplicateApplication(int id) { ClientVisit visit = clientBusinessLogic.ClientVisit_Get(id); DuplicateApplication printedForm = new DuplicateApplication(visit); return(File(printedForm.GetExcel(), System.Net.Mime.MediaTypeNames.Application.Octet, "Заявление на дубликат.xls")); }
public ActionResult ChangeInsuranceCompanyApplication(int id) { ClientVisit visit = clientBusinessLogic.ClientVisit_Get(id); ChangeInsuranceCompanyApplication printedForm = new ChangeInsuranceCompanyApplication(visit); return(File(printedForm.GetExcel(), System.Net.Mime.MediaTypeNames.Application.Octet, "Заявление о выборе/замене страховой компании.xls")); }
public ActionResult TemporaryPolicyBSO(int id) { ClientVisit visit = clientBusinessLogic.ClientVisit_Get(id); TemporaryPolicyBSO printedForm = new TemporaryPolicyBSO(visit); return(File(printedForm.GetExcel(), System.Net.Mime.MediaTypeNames.Application.Octet, "БСО.xls")); }
public ClientVisit ClientVisit_GetFirstClientVisitInGroup(long id) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.AddInputParameter("@ClientVisitGroupID", SqlDbType.BigInt, id); ClientVisit client = Execute_Get(ClientVisitMaterializer.Instance, "ClientVisit_GetFirstClientVisitInGroup", parameters); return(client); }
/// <summary> /// Returnes first client visit by visit group identifier Id /// </summary> /// <param name="id">Identifier of specified visit group</param> /// <returns>Instance of client visit</returns> public ClientVisit ClientVisit_GetFirstClientVisitInGroup(long clientVisitGroupId) { ClientVisit clientVisit = ClientDao.Instance.ClientVisit_GetFirstClientVisitInGroup(clientVisitGroupId); if (clientVisit == null) { throw new DataObjectNotFoundException(string.Format("Группа обращений с идентификатором {0} не найдена", clientVisitGroupId)); } return(clientVisit); }
/// <summary> /// Returnes client visit by identifier /// </summary> /// <param name="id">Identifier of specified client visit</param> /// <returns>Instance of client visit</returns> public ClientVisit ClientVisit_Get(long id) { ClientVisit clientVisit = ClientDao.Instance.ClientVisit_Get(id); if (clientVisit == null) { throw new DataObjectNotFoundException(string.Format("Обращение клиента с идентификатором {0} не найдено", id)); } return(clientVisit); }
public ScenarioSpecification(ClientVisit clientVisit, List <ReconciliationFundResponse.CreateData> responses) { this.clientVisit = clientVisit; this.responses = responses; newS5 = responses.OfType <S5FundResponse.CreateData>().FirstOrDefault(item => item.DataTypeId == (int)EntityType.New && item.Order == 1); oldS5 = responses.OfType <S5FundResponse.CreateData>().FirstOrDefault(item => item.DataTypeId == (int)EntityType.Old && item.Order == 1); s6 = responses.OfType <S6FundResponse.CreateData>().FirstOrDefault(item => item.Order == 1 && item.FundAnswer == S6FundResponse.OK_Answer); s9 = responses.OfType <S9FundResponse.CreateData>().FirstOrDefault(item => item.Order == 1 && item.FundAnswer == S9FundResponse.OK_Answer); snils = responses.OfType <SnilsFundResponse.CreateData>().FirstOrDefault(item => item.Order == 1 && item.FundAnswer == SnilsFundResponse.OK_Answer); }
public void ClientVisit_Find() { Client.CreateData clientCreateData = ClientGenerator.GetClientCreateData("Иван", "Иванович", "Иванов", "1"); ClientBusinessLogic bll = new ClientBusinessLogic(); ClientVisit.SaveData data = ClientGenerator.GetClientVisitSaveDataForNewUser(); long clientId = bll.ClientVisit_Save(new User() { Roles = new List <Role>() { Role.Administrator } }, data).ClientID; Client client = bll.Client_Get(new User() { Roles = new List <Role>() { Role.Administrator } }, clientId); long visitId = client.Visits.OrderByDescending(item => item.StatusDate).FirstOrDefault().Id; ClientVisit visit = bll.ClientVisit_Get(visitId); ClientVisitSearchCriteria criteria = new ClientVisitSearchCriteria(); criteria.Firstname = data.NewClientInfo.Firstname; criteria.Secondname = data.NewClientInfo.Secondname; criteria.Lastname = data.NewClientInfo.Lastname; criteria.Birthday = data.NewClientInfo.Birthday; criteria.DeliveryCenterIds = new List <long>(); if (data.DeliveryCenterId.HasValue) { criteria.DeliveryCenterIds.Add(data.DeliveryCenterId.Value); } criteria.Id = visitId; criteria.PolicyDateTo = visit.IssueDate; criteria.PolicyNumber = visit.NewPolicy.Number; criteria.PolicySeries = visit.NewPolicy.Series; criteria.StatusIds = new List <long>(); if (data.Status.HasValue) { criteria.StatusIds.Add(data.Status.Value); } criteria.TemporaryPolicyDateTo = visit.TemporaryPolicyDate; criteria.TemporaryPolicyNumber = visit.TemporaryPolicyNumber; DataPage <ClientVisitInfo> list = bll.ClientVisit_Find( criteria, new List <SortCriteria <ClientVisitSortField> >(), new PageRequest() { PageNumber = 1, PageSize = 10 }); Assert.AreEqual(list.Count, 1); }
public JsonResult ClientVisitStatus(int id) { ClientVisit cv = clientBusinessLogic.ClientVisit_Get(id); return(Json( new { ClientVisitId = cv.Id, StatusId = cv.Status.Id, StatusValue = cv.Status.Name }, JsonRequestBehavior.AllowGet)); }
private void ValidateChangeVisitGroupId(BSOSaveDataModel bsoSaveDataModel, BSO bso) { if (bsoSaveDataModel.VisitGroupId != bso.VisitGroupId && bsoSaveDataModel.VisitGroupId != null) { BusinessLogic.ClientBusinessLogic clientBusinessLogic = new BusinessLogic.ClientBusinessLogic(); try { ClientVisit cv = clientBusinessLogic.ClientVisit_GetFirstClientVisitInGroup((long)bsoSaveDataModel.VisitGroupId); } catch { isValid = false; this.Messages.Add(string.Format("Вы ввели несуществующий идентификатор обращения {0}!", bsoSaveDataModel.VisitGroupId)); } } }
public ScenarioResolver(ClientVisit clientVisit, List <ReconciliationFundResponse.CreateData> responses) { specs.Add(new NBScenarioSpecification(clientVisit, responses)); specs.Add(new CIScenarioSpecification(clientVisit, responses)); specs.Add(new RIScenarioSpecification(clientVisit, responses)); specs.Add(new PIScenarioSpecification(clientVisit, responses)); specs.Add(new PRIScenarioSpecification(clientVisit, responses)); specs.Add(new CTScenarioSpecification(clientVisit, responses)); specs.Add(new RTScenarioSpecification(clientVisit, responses)); specs.Add(new PTScenarioSpecification(clientVisit, responses)); specs.Add(new PRTScenarioSpecification(clientVisit, responses)); specs.Add(new DPScenarioSpecification(clientVisit, responses)); specs.Add(new CRScenarioSpecification(clientVisit, responses)); specs.Add(new CPScenarioSpecification(clientVisit, responses)); specs.Add(new PRScenarioSpecification(clientVisit, responses)); }
/// <summary> /// Set status PolicyExtradition for clientVisit with IssueDate /// </summary> /// <param name="saveData">Data to dave policy</param> private void SetStatusForReceivedPolicies(User user, ClientVisit.SaveData saveData) { if (saveData.ClientId.HasValue && saveData.Id.HasValue) { ClientVisit clientVisit = ClientVisit_Get(saveData.Id.Value); if (clientVisit.Status.Id == ClientVisitStatuses.PolicyReadyForClient.Id //&& saveData.IssueDate.HasValue && saveData.ScenarioId == ClientVisitScenaries.PolicyExtradition.Id) { if (!saveData.IssueDate.HasValue) { saveData.IssueDate = DateTime.Now; } ClientVisit_SetStatus(user, clientVisit.Id, ClientVisitStatuses.PolicyIssued.Id, true); } } }
public List <FundResponse.UploadReportData> Upload_SecondStepReconciliationPack(User user, string zipPath) { 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); foreach (var response in pack.Value) { FundProcessingDao.Instance.FundResponse_Create(response, date); report.Add(AddReportItem(lastClientVisitInGroup, response, lastClientVisitInGroup.Id)); } ClientVisit.SaveData data = ClientVisit.SaveData.BuildSaveData(lastClientVisitInGroup); SecondStepReconciliationProcessor processor = new SecondStepReconciliationProcessor(data, pack.Value.OfType <ReconciliationFundResponse.CreateData>().ToList()); processor.Process(); if (processor.IsChanged) { clientBusinessLogic.ClientVisit_Save(user, data); } } return(report); }
public ClientVisitSaveDataModel(User user, ClientVisit clientVisit, bool replaceNewOld) : this(user, clientVisit) { if (replaceNewOld) { OldClientInfo = new ClientVersionEditModel(clientVisit.NewClientInfo, EntityType.Old); NewClientInfo = new ClientVersionEditModel(EntityType.New); OldDocument = new DocumentModel(clientVisit.NewDocument, DocumentType.Old); NewDocument = new DocumentModel(DocumentType.New); NewForeignDocument = new DocumentModel(DocumentType.NewForeign); OldForeignDocument = new DocumentModel(clientVisit.NewForeignDocument, DocumentType.OldForeign); OldPolicy = new PolicyInfoClientVisitSaveModel(clientVisit.NewPolicy, EntityType.Old); NewPolicy = new PolicyInfoClientVisitSaveModel(EntityType.New); Registrator = new UserModel(user); StatusDate = new DateTime(); StatusId = 1; Comment = user.Fullname; } }
public ClientVisitNewDataBuilder(ClientVisit.SaveData clientVisit, ClientVisit firstClientVisit, IEnumerable <IReconciliationFundResponse> responses) { this.clientVisit = clientVisit; this.firstClientVisit = firstClientVisit; dataProcessors = new Dictionary <long, Action>(); newS5 = responses.FirstOrDefault(item => (item.GetType() == typeof(S5FundResponse.CreateData) || item.GetType() == typeof(S5FundResponse)) && item.DataType == EntityType.New && item.Order == 1); oldS5 = responses.FirstOrDefault(item => (item.GetType() == typeof(S5FundResponse.CreateData) || item.GetType() == typeof(S5FundResponse)) && item.DataType == EntityType.Old && item.Order == 1); s6 = responses.FirstOrDefault(item => (item.GetType() == typeof(S6FundResponse.CreateData) || item.GetType() == typeof(S6FundResponse)) && item.Order == 1); s9 = responses.FirstOrDefault(item => (item.GetType() == typeof(S9FundResponse.CreateData) || item.GetType() == typeof(S9FundResponse)) && item.Order == 1); snils = responses.FirstOrDefault(item => (item.GetType() == typeof(SnilsFundResponse.CreateData) || item.GetType() == typeof(SnilsFundResponse)) && item.Order == 1); this.clientVisit = clientVisit; dataProcessors.Add(ClientVisitScenaries.FirstRequestENP.Id, ProcessNB); dataProcessors.Add(ClientVisitScenaries.ReregistrationMoscowENPWithoutFIO.Id, ProcessCI); dataProcessors.Add(ClientVisitScenaries.ReregistrationRegionalENPWithoutFIO.Id, ProcessCT); dataProcessors.Add(ClientVisitScenaries.NewUnifiedPolicyNumberByKMSOtherSMO.Id, ProcessPI); dataProcessors.Add(ClientVisitScenaries.ReregistrationRegionalOldPolicyWithoutFIO.Id, ProcessPT); dataProcessors.Add(ClientVisitScenaries.ReregistrationMoscowENPWithFIO.Id, ProcessRI); dataProcessors.Add(ClientVisitScenaries.ReregistrationRegionalENPWithFIO.Id, ProcessRT); dataProcessors.Add(ClientVisitScenaries.NewUnifiedPolicyNumberByKMSOtherSMOWithFIO.Id, ProcessPRI); dataProcessors.Add(ClientVisitScenaries.ReregistrationRegionalOldPolicyWithFIO.Id, ProcessPRT); dataProcessors.Add(ClientVisitScenaries.RequestENPSameSMOChangeFIO.Id, ProcessCR); dataProcessors.Add(ClientVisitScenaries.NewUnifiedPolicyNumberByKMS.Id, ProcessCP); dataProcessors.Add(ClientVisitScenaries.LostENPWithoutFIO.Id, ProcessDP); dataProcessors.Add(ClientVisitScenaries.NewUnifiedPolicyNumberByOldPolicy.Id, ProcessPR); dataProcessors.Add(ClientVisitScenaries.PolicyMerge.Id, ProcessMP); dataProcessors.Add(ClientVisitScenaries.PolicySeparation.Id, ProcessRD); dataProcessors.Add(ClientVisitScenaries.ChangeDocument.Id, ProcessCD); dataProcessors.Add(ClientVisitScenaries.RemoveFromRegister.Id, ProcessCLR); dataProcessors.Add(ClientVisitScenaries.PolicyExtradition.Id, ProcessPOK); dataProcessors.Add(ClientVisitScenaries.PolicyRecovery.Id, ProcessAD); }
public List <FundResponse.UploadReportData> UploadSubmitFundResponse(User user, string zipPath) { List <FundResponse.UploadReportData> report = new List <FundResponse.UploadReportData>(); string zipDirectoryName = Path.Combine(ConfiguraionProvider.FileStorageFolder, Path.GetFileNameWithoutExtension(zipPath)); ZipHelper.UnZipFiles(zipPath, zipDirectoryName); var responsesToCreate = new List <FundResponse.CreateData>(); FundResponseCreateDataBuilder builder = new FundResponseCreateDataBuilder(); foreach (var file in Directory.GetFiles(zipDirectoryName)) { System.IO.FileInfo fInfo = new System.IO.FileInfo(file); DataTable dataTable = DBFProcessor.GetDataTable(fInfo.FullName, string.Format("select * from \"{0}\";", fInfo.FullName)); if (fInfo.Name.StartsWith("errp2", StringComparison.InvariantCultureIgnoreCase)) { dataTable.TableName = Path.GetFileNameWithoutExtension(fInfo.Name); IEnumerable <FundResponse.CreateData> list = builder.BuildList(FundErrorResponse.Name, dataTable); responsesToCreate.AddRange(list); } if (fInfo.Name.StartsWith("zP2", StringComparison.InvariantCultureIgnoreCase)) { IEnumerable <FundResponse.CreateData> list = builder.BuildList(GoznakResponse.Name, dataTable); responsesToCreate.AddRange(list); } } DateTime date = DateTime.Now; var responsesByclientVisitId = new Dictionary <long, List <FundResponse.CreateData> >(); List <FundRequestRecid> recids = FundProcessingDao.Instance.ClientVisitId_GetByFundRequesetRecid(responsesToCreate.Where(item => item.Recid.HasValue).Select(item => item.Recid.Value)); Dictionary <long, FundRequestRecid> recidsByRecid = recids.ToDictionary(item => item.Recid); foreach (FundResponse.CreateData response in responsesToCreate) { FundRequestRecid recid; if (response.Recid.HasValue && recidsByRecid.TryGetValue(response.Recid.Value, out recid)) { response.ClientVisitId = recid.ClientVisitId; } if (response.ClientVisitId != 0) { if (!responsesByclientVisitId.ContainsKey(response.ClientVisitId)) { responsesByclientVisitId.Add(response.ClientVisitId, new List <FundResponse.CreateData>()); } responsesByclientVisitId[response.ClientVisitId].Add(response); } else { report.Add(new FundResponse.UploadReportData() { Recid = response.Recid, Fullname = response.GetFullname(), ResponseTypeName = response.GetResponseTypeName(), UploadResult = "Не найдена соответствующая заявка" }); } } foreach (var pack in responsesByclientVisitId) { long clientVisitId = pack.Key; ClientVisit clientVisit = clientBusinessLogic.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 lastClientVisit = clientBusinessLogic.ClientVisit_GetLastClientVisitInGroup(clientVisit.VisitGroupId); foreach (var response in pack.Value) { FundProcessingDao.Instance.FundResponse_Create(response, date); } foreach (FundErrorResponse.CreateData response in pack.Value.OfType <FundErrorResponse.CreateData>().Cast <FundErrorResponse.CreateData>()) { if (string.IsNullOrEmpty(response.ErrorCode) && string.IsNullOrEmpty(response.ErrorText)) { if (lastClientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id) { if (lastClientVisit.Scenario.Id == ClientVisitScenaries.PolicyExtradition.Id) { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.PolicyIssuedAndSentToTheFond.Id, true, date); report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, ClientVisitStatuses.PolicyIssuedAndSentToTheFond, date, "Загружен ответ фонда")); } else { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.Processed.Id, true, date); report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, ClientVisitStatuses.Processed, date, "Загружен ответ фонда")); } } else if (lastClientVisit.Status.Id == ClientVisitStatuses.FundError.Id) { ClientVisit.SaveData newClientVisitData = new ClientVisit.SaveData(clientVisit); newClientVisitData.Status = ClientVisitStatuses.Processed.Id; newClientVisitData.StatusDate = date; newClientVisitData.IsActual = true; var saveResult = clientBusinessLogic.ClientVisit_Save(user, newClientVisitData, date); report.Add(AddReportItem(clientVisit, response, saveResult.ClientVisitID, ClientVisitStatuses.Processed, date, "Загружен ответ фонда")); } } else { if (lastClientVisit.Status.Id == ClientVisitStatuses.Reconciliation.Id || lastClientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id) { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.FundError.Id, true, date); ClientVisit.SaveData newClientVisitData = new ClientVisit.SaveData(clientVisit); newClientVisitData.Status = ClientVisitStatuses.FundError.Id; newClientVisitData.StatusDate = date; newClientVisitData.IsActual = true; var saveResult = clientBusinessLogic.ClientVisit_Save(user, newClientVisitData, date); report.Add(AddReportItem(clientVisit, response, saveResult.ClientVisitID, ClientVisitStatuses.FundError, date, "Загружен ответ фонда")); } else { report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, lastClientVisit.Status, date, "Статус не изменен")); } } } foreach (GoznakResponse.CreateData response in pack.Value.OfType <GoznakResponse.CreateData>().Cast <GoznakResponse.CreateData>()) { if (lastClientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id || lastClientVisit.Status.Id == ClientVisitStatuses.Processed.Id || lastClientVisit.Status.Id == ClientVisitStatuses.FundError.Id) { ClientDao.Instance.ClientVisit_SetStatus(user.Id, lastClientVisit.Id, ClientVisitStatuses.SentToGoznak.Id, true, date); report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, ClientVisitStatuses.SentToGoznak, date)); } else { report.Add(AddReportItem(clientVisit, response, lastClientVisit.Id, lastClientVisit.Status, date, "Статус не изменен")); } } } return(report); }
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); }
private ClientVisit.SaveData BuildUpdatedClientVisitSaveData(ClientVisit.UpdateData updateClientVisitItem, ClientVisit visit) { ClientVisit.SaveData data = new ClientVisit.SaveData(visit); data.Blanc = updateClientVisitItem.Blanc; data.N_KOR = updateClientVisitItem.N_KOR; data.DATA_FOND = updateClientVisitItem.DATA_FOND; data.NZ_GOZNAK = updateClientVisitItem.NZ_GOZNAK; data.PolicyPartyNumber = updateClientVisitItem.PolicyPartyNumber.Trim(); data.NewPolicy.UnifiedPolicyNumber = updateClientVisitItem.UnifiedPolicyNumber.Trim(); data.NewPolicy.OGRN = updateClientVisitItem.OGRN.Trim(); data.NewClientInfo.Lastname = updateClientVisitItem.Lastname.Trim(); data.NewClientInfo.Firstname = updateClientVisitItem.Firstname.Trim(); data.NewClientInfo.Secondname = updateClientVisitItem.Secondname.Trim(); data.NewClientInfo.Birthday = updateClientVisitItem.Birthday; data.Dat_U = updateClientVisitItem.Dat_U; data.Dat_S = updateClientVisitItem.Dat_S; return(data); }
public ClientVisit FindLastClientVisit(ClientVisit cv) { DataPage <ClientVisitInfo> foundClientVisits = new DataPage <ClientVisitInfo>(); ClientVisit lastClientVisit = null; ClientVisitSearchCriteria clientVisitSC = new ClientVisitSearchCriteria(); clientVisitSC.Firstname = cv.NewClientInfo.Firstname; clientVisitSC.Secondname = cv.NewClientInfo.Secondname; clientVisitSC.Lastname = cv.NewClientInfo.Lastname; clientVisitSC.Birthday = cv.NewClientInfo.Birthday; if (cv.TemporaryPolicyDate.HasValue) { clientVisitSC.TemporaryPolicyDateFrom = cv.TemporaryPolicyDate; clientVisitSC.TemporaryPolicyDateTo = cv.TemporaryPolicyDate; foundClientVisits = ClientVisit_Find( clientVisitSC, new List <SortCriteria <ClientVisitSortField> >(), new PageRequest() { PageNumber = 1, PageSize = 10 }); clientVisitSC.TemporaryPolicyDateFrom = null; clientVisitSC.TemporaryPolicyDateTo = null; if (foundClientVisits.Count != 0) { long clientVisitId = foundClientVisits.OrderBy(item => item.StatusDate).ThenBy(item => item.Id).LastOrDefault().Id; return(ClientVisit_Get(clientVisitId)); } } if (!string.IsNullOrEmpty(cv.NewClientInfo.SNILS)) { clientVisitSC.SNILS = cv.NewClientInfo.SNILS; foundClientVisits = ClientVisit_Find( clientVisitSC, new List <SortCriteria <ClientVisitSortField> >(), new PageRequest() { PageNumber = 1, PageSize = 10 }); clientVisitSC.SNILS = null; } if (cv.NewDocument.DocumentType != null && !string.IsNullOrEmpty(cv.NewDocument.Number)) { clientVisitSC.DocumentTypeId = cv.NewDocument.DocumentType.Id; clientVisitSC.DocumentSeries = cv.NewDocument.Series; clientVisitSC.DocumentNumber = cv.NewDocument.Number; foundClientVisits = ClientVisit_Find(clientVisitSC, new List <SortCriteria <ClientVisitSortField> >(), new PageRequest() { PageNumber = 1, PageSize = 10 }); clientVisitSC.DocumentTypeId = null; clientVisitSC.DocumentSeries = null; clientVisitSC.DocumentNumber = null; } if (!string.IsNullOrEmpty(cv.NewPolicy.Series) && !string.IsNullOrEmpty(cv.NewPolicy.Number)) { clientVisitSC.PolicySeries = cv.NewPolicy.Series; clientVisitSC.PolicyNumber = cv.NewPolicy.Number; foundClientVisits = ClientVisit_Find(clientVisitSC, new List <SortCriteria <ClientVisitSortField> >(), new PageRequest() { PageNumber = 1, PageSize = 10 }); clientVisitSC.PolicySeries = null; clientVisitSC.PolicyNumber = null; } if (!string.IsNullOrEmpty(cv.NewPolicy.UnifiedPolicyNumber)) { clientVisitSC.UnifiedPolicyNumber = cv.NewPolicy.UnifiedPolicyNumber; foundClientVisits = ClientVisit_Find(clientVisitSC, new List <SortCriteria <ClientVisitSortField> >(), new PageRequest() { PageNumber = 1, PageSize = 10 }); clientVisitSC.UnifiedPolicyNumber = null; } ClientVisitInfo clientVisitInfo = foundClientVisits.OrderBy(item => item.StatusDate).LastOrDefault(); if (clientVisitInfo == null) { return(null); } lastClientVisit = ClientVisit_Get(clientVisitInfo.Id); return(lastClientVisit); }
public DuplicateApplication(ClientVisit visit) { TemplatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "Templates", "DuplicateApplication.xls"); this.ClientVisit = visit; }
public ClientVisitSaveDataModel(User user, ClientVisit clientVisit) : this(user) { VisitId = clientVisit.Id; ClientId = clientVisit.ClientId; VisitGroupId = clientVisit.VisitGroupId; SignatureFileName = clientVisit.SignatureFileName ?? Guid.NewGuid().ToString(); PhotoFileName = clientVisit.PhotoFileName ?? Guid.NewGuid().ToString(); DeliveryCenterId = clientVisit.DeliveryCenter.Id; ScenarioId = clientVisit.Scenario != null ? clientVisit.Scenario.Id : new long?(); TemporaryPolicyDate = clientVisit.TemporaryPolicyDate; TemporaryPolicyNumber = clientVisit.TemporaryPolicyNumber; TemporaryPolicyExpirationDate = clientVisit.TemporaryPolicyExpirationDate; StatusId = clientVisit.Status.Id; StatusDate = clientVisit.StatusDate; StatusEnabled = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG); DisableAll = clientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id && !(user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG)); OldClientInfo = new ClientVersionEditModel(clientVisit.OldClientInfo, EntityType.Old); NewClientInfo = new ClientVersionEditModel(clientVisit.NewClientInfo, EntityType.New); OldDocument = new DocumentModel(clientVisit.OldDocument, DocumentType.Old); NewDocument = new DocumentModel(clientVisit.NewDocument, DocumentType.New); NewForeignDocument = new DocumentModel(clientVisit.NewForeignDocument, DocumentType.NewForeign); OldForeignDocument = new DocumentModel(clientVisit.OldForeignDocument, DocumentType.OldForeign); LivingAddress = new AddressModel(clientVisit.LivingAddress, AddressType.Living); RegistrationAddress = new AddressModel(clientVisit.RegistrationAddress, AddressType.Registration); RegistrationAddressDate = clientVisit.RegistrationAddressDate; OldPolicy = new PolicyInfoClientVisitSaveModel(clientVisit.OldPolicy, EntityType.Old); NewPolicy = new PolicyInfoClientVisitSaveModel(clientVisit.NewPolicy, EntityType.New); Registrator = new UserModel(clientVisit.Registrator); Representative = new RepresentativeEditModel(clientVisit.Representative); CarrierId = clientVisit.CarrierId; ApplicationMethodId = clientVisit.ApplicationMethodId; Comment = clientVisit.Comment; GOZNAKDate = clientVisit.GOZNAKDate; GOZNAKTypeId = clientVisit.GOZNAKType != null ? clientVisit.GOZNAKType.Id : default(long?); ClientCategoryId = clientVisit.ClientCategoryId == 0 ? new long() : clientVisit.ClientCategoryId; DeliveryPointId = clientVisit.DeliveryPointId == 0 ? new long() : clientVisit.DeliveryPointId; ClientAcquisitionEmployee = clientVisit.ClientAcquisitionEmployee; ClientContacts = clientVisit.ClientContacts; Phone = clientVisit.Phone; Email = clientVisit.Email; IssueDate = clientVisit.IssueDate; UralsibCard = clientVisit.UralsibCard; IsActual = clientVisit.IsActual; Scenaries = ReferencesProvider.GetReferences(Constants.ScenarioRef, user.Roles, DateTime.Now, null, true); DeliveryPoints = ReferencesProvider.GetReferences(Constants.DeliveryPointRef, user.Roles, DateTime.Now, null, true); ListClientAcquisitionEmployee = ReferencesProvider.GetListClientAcquisitionEmployee(null, true); PolicyBlanc = clientVisit.PolicyBlanc; if (ScenarioId != 0 && !Scenaries.Exists(item => item.Value == ScenarioId.ToString())) { Scenaries.Add(ReferencesProvider.GetReferences(Constants.ScenarioRef).FirstOrDefault(item => item.Value == ScenarioId.ToString())); } if (DeliveryPointId.HasValue && !DeliveryPoints.Exists(item => item.Value == DeliveryPointId.Value.ToString())) { DeliveryPoints.Add(ReferencesProvider.GetReferences(Constants.DeliveryPointRef).FirstOrDefault(item => item.Value == DeliveryPointId.Value.ToString())); } if (ClientCategoryId.HasValue && !UralsibClientCategories.Exists(item => item.Value == ClientCategoryId.Value.ToString())) { UralsibClientCategories.Add(ReferencesProvider.GetReferences(Constants.UralsibClientCategoryRef).FirstOrDefault(item => item.Value == ClientCategoryId.Value.ToString())); } IssueDateEnabled = (user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG)) || (StatusId == ClientVisitStatuses.PolicyReadyForClient.Id && user.Roles.Contains(Role.Registrator)); IsReadyToFundSubmitRequestEnabled = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG); PolicyPartyNumber = clientVisit.PolicyPartyNumber; FundResponseApplyingMessage = clientVisit.FundResponseApplyingMessage; IsReadyToFundSubmitRequest = clientVisit.IsReadyToFundSubmitRequest; CreateDate = clientVisit.CreateDate; UpdateDate = clientVisit.UpdateDate; IsDifficultCase = clientVisit.IsDifficultCase; AttachmentDate = clientVisit.AttachmentDate; AttachmentTypeId = clientVisit.AttachmentType != null ? clientVisit.AttachmentType.Id : new long?(); MedicalCentreId = clientVisit.MedicalCentre != null ? clientVisit.MedicalCentre.Id : new long?(); }
public TemporaryPolicyBSO(ClientVisit visit) { TemplatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "Templates", "TemporaryPolicyBSO.xls"); this.ClientVisit = visit; }
public CPScenarioSpecification(ClientVisit clientVisit, List <ReconciliationFundResponse.CreateData> responses) : base(clientVisit, responses) { }
/// <summary> /// Method to update visit group and create a new client visit for fund /// </summary> /// <param name="dbfFilePath">DBF file that contains information to update</param> /// <returns>Result of updating</returns> public List <ClientVisit.UpdateResultData> ClientVisit_UpdateFundDbf(User user, string dbfFilePath) { BSOBusinessLogic bsoBusinessLogic = new BSOBusinessLogic(); List <ClientVisit.UpdateData> dataToUpdate = ClientVisitReportDao.Instance.GetUpdateDataFromDbf(dbfFilePath); List <ClientVisit.UpdateResultData> results = new List <ClientVisit.UpdateResultData>(); foreach (var updateClientVisitItem in dataToUpdate) { var clientVisits = FindClientVisitsToUpdate(updateClientVisitItem); ClientVisitInfo lastClientVisitInfo = clientVisits.OrderBy(v => v.Id).LastOrDefault(); if (lastClientVisitInfo != null && (lastClientVisitInfo.Status.Id == ClientVisitStatuses.AnswerPending.Id || lastClientVisitInfo.Status.Id == ClientVisitStatuses.AnswerPending.Id || lastClientVisitInfo.Status.Id == ClientVisitStatuses.SubmitPending.Id || lastClientVisitInfo.Status.Id == ClientVisitStatuses.SentToGoznak.Id || lastClientVisitInfo.Status.Id == ClientVisitStatuses.Processed.Id || lastClientVisitInfo.Status.Id == ClientVisitStatuses.Comment.Id)) { ClientVisit visit = ClientVisit_Get(lastClientVisitInfo.Id); // create new clientVisit to update policy information in the fund if (visit.Status.Id != ClientVisitStatuses.PolicyReadyForClient.Id) { ClientVisit.SaveData data = BuildUpdatedClientVisitSaveData(updateClientVisitItem, visit); ClientVisitSaveResult updatingResult = ClientVisit_Save(user, data); //если bso будет найден - ему меняем статус на "Выдан клиенту" BSO bso = new BSO(); bso = bsoBusinessLogic.BSO_GetByNumber(updateClientVisitItem.TemporaryPolicyNumber); if (bso != null) { if (bso.Status.Id == (long)ListBSOStatusID.OnDelivery || bso.Status.Id == (long)ListBSOStatusID.OnStorage) { bso.Status.Id = (long)ListBSOStatusID.OnClient; bso.UserId = user.Id; bso.DeliveryPointId = data.DeliveryPointId == null ? bso.DeliveryPointId : data.DeliveryPointId; //Если точка пустая - оставляем Точку, кот. была в БСО bso.StatusDate = data.TemporaryPolicyDate == null ? data.StatusDate : data.TemporaryPolicyDate; bso.Comment = string.Format("Изменение статуса при загрузке DBF (Загрузить DBF из фонда)"); bso.VisitGroupId = updatingResult.VisitGroupId; } else { //если bso уже выдан клиенту - то дальнейшие действия с БСО не имеют значения bso = null; } } // set status for created client visit ClientVisit_SetStatus(user, updatingResult.ClientVisitID, ClientVisitStatuses.PolicyReadyForClient.Id, true); if (bso != null) { bsoBusinessLogic.BSO_Save(new BSO.SaveData(bso)); } results.Add(new ClientVisit.UpdateResultData(updateClientVisitItem, true, "Успешно", visit) { Status = ClientVisitStatuses.PolicyReadyForClient }); } else { results.Add(new ClientVisit.UpdateResultData(updateClientVisitItem, true, "Заявка на выдачу была создана ранее", visit)); } } else { results.Add(new ClientVisit.UpdateResultData(updateClientVisitItem, true, "Заявка в подходящем статусе не найдена")); } } return(results); }