/// <summary> /// The write prz buff. /// </summary> /// <param name="st"> /// The st. /// </param> /// <param name="log"> /// The log. /// </param> /// <param name="sessionAtl"> /// The session atl. /// </param> /// <param name="medicalInsurance"> /// The medical insurance. /// </param> /// <param name="op"> /// The op. /// </param> /// <returns> /// The <see cref="Przbuf"/>. /// </returns> private Przbuf WritePrzBuff( StatementMaximum st, Przlog log, ISession sessionAtl, MedicalInsurance medicalInsurance, string op) { var contentManager = ObjectFactory.GetInstance <IContentManager>(); var personData = st.InsuredPersonData; var documentUdl = st.DocumentUdl; var address = st.Address; var address2 = st.Address2 ?? st.Address; var documentResidency = st.ResidencyDocument; ////if (documentResidency == null && (st.InsuredPersonData.Citizenship == null || st.InsuredPersonData.Citizenship.Id != Country.RUS)) ////{ //// documentResidency = documentUdl; ////} var contactInfo = st.ContactInfo; var pvp = st.PointDistributionPolicy; var smo = pvp.Parent; var foto = contentManager.GetFoto(st.InsuredPersonData.Id); var signature = contentManager.GetSignature(st.InsuredPersonData.Id); var okatoRn = GetOkatoRn(address, sessionAtl) ?? string.Empty; var okatoPrn = GetOkatoRn(address2, sessionAtl) ?? string.Empty; var regulatoryAddress = address.Regulatory(); var regulatoryAddress2 = address2.Regulatory(); var przBuff = new Przbuf { Fam = personData.LastName, Im = personData.FirstName, Ot = personData.MiddleName, W = int.Parse(personData.Gender.Code), Dr = personData.Birthday, Dra = personData.IsIncorrectDate, Drt = personData.BirthdayType.HasValue ? personData.BirthdayType.Value : 1, Mr = personData.Birthplace, Ss = !string.IsNullOrEmpty(personData.Snils) ? SnilsChecker.SsToLong(personData.Snils) : null, Cn = personData.Citizenship != null ? personData.Citizenship.Code : "Б/Г", Kateg = int.Parse(personData.Category.Code), BirthOksm = personData.OldCountry != null ? personData.OldCountry.Code : null, // Документ УДЛ Doctp = documentUdl.DocumentType.Code, Docs = documentUdl.Series, Docn = documentUdl.Number, Docdt = documentUdl.DateIssue, Docend = documentUdl.DateExp, Docorg = documentUdl.IssuingAuthority, // Адрес регистрации Subj = !string.IsNullOrEmpty(address.Okato) ? address.Okato.Substring(0, Math.Min(2, address.Okato.Length)) + "000" : okatoRn.Substring(0, Math.Min(2, okatoRn.Length)) + "000", Rn = okatoRn, Indx = address.Postcode, Rnname = address.Area, City = address.City, Np = !string.IsNullOrEmpty(address.Town) ? address.Town : !string.IsNullOrEmpty(address.City) ? address.City : address.Subject, Ul = address.Street, Dom = address.House, Kor = address.Housing, Kv = address.Room.HasValue ? address.Room.Value.ToString(CultureInfo.InvariantCulture) : string.Empty, Dmj = address.DateRegistration, Kladrg = regulatoryAddress != null ? regulatoryAddress.Code : null, // Адрес проживания Psubj = !string.IsNullOrEmpty(address2.Okato) ? address2.Okato.Substring(0, Math.Min(2, address2.Okato.Length)) + "000" : okatoPrn.Substring(0, Math.Min(2, okatoPrn.Length)) + "000", Prn = okatoPrn, Pindx = address2.Postcode, Prnname = address2.Area, Pcity = address2.City, Pnp = !string.IsNullOrEmpty(address2.Town) ? address2.Town : !string.IsNullOrEmpty(address2.City) ? address2.City : address2.Subject, Pul = address2.Street, Pdom = address2.House, Pkor = address2.Housing, Pkv = address2.Room.HasValue ? address2.Room.Value.ToString(CultureInfo.InvariantCulture) : string.Empty, Pdmj = address2.DateRegistration, Kladrp = regulatoryAddress2 != null ? regulatoryAddress2.Code : null, // Документ регистрации // Контактная информация Email = contactInfo.Email, Phone = contactInfo.HomePhone, Enp = medicalInsurance.Enp ?? st.NumberPolicy, Q = smo.Code, Qogrn = smo.Ogrn, Prz = st.PointDistributionPolicy.Code, Dviz = st.DateFiling, Meth = int.Parse(st.ModeFiling.Code), Sp = personData.Category.Code, Petition = st.HasPetition, Photo = foto ?? string.Empty, Signat = signature ?? string.Empty, PRZLOG = log, Op = op, Opdoc = GetPolisType(medicalInsurance.PolisType.Id), Spol = !string.IsNullOrEmpty(medicalInsurance.PolisSeria) ? medicalInsurance.PolisSeria : null, Npol = medicalInsurance.PolisNumber, Dbeg = medicalInsurance.DateFrom, Dend = medicalInsurance.DateTo, Dstop = medicalInsurance.DateStop }; var repr = st.Representative; if (repr != null) { przBuff.Fiopr = string.Format("{0} {1} {2}", repr.FirstName, repr.LastName, repr.MiddleName).Crop(60); przBuff.Contact = repr.HomePhone; przBuff.Zphone = repr.WorkPhone; przBuff.Zt = repr.RelationType.Id - 317; przBuff.Zfam = repr.LastName; przBuff.Zim = repr.FirstName; przBuff.Zot = repr.MiddleName; if (repr.Document != null && repr.Document.DocumentType != null) { var doc = repr.Document; przBuff.Zdoctp = doc.DocumentType.Code; przBuff.Zdocs = doc.Series; przBuff.Zdocn = doc.Number; przBuff.Zdocdt = doc.DateIssue; przBuff.Zdocorg = doc.IssuingAuthority; przBuff.Zdr = doc.DateExp; } } if (address.IsHomeless.HasValue && address.IsHomeless.Value) { przBuff.Bomj = address.IsHomeless; przBuff.Subj = smo.Parent.Okato.Substring(0, Math.Min(2, smo.Parent.Okato.Length)) + "000"; przBuff.Psubj = smo.Parent.Okato.Substring(0, Math.Min(2, smo.Parent.Okato.Length)) + "000"; } if (st.PreviousStatement != null) { if (st.PreviousStatement.InsuredPersonData != null) { var oldpersonData = st.PreviousStatement.InsuredPersonData; przBuff.Oldfam = oldpersonData.LastName; przBuff.Oldim = oldpersonData.FirstName; przBuff.Oldot = oldpersonData.MiddleName; przBuff.Oldw = int.Parse(oldpersonData.Gender.Code); przBuff.Olddr = oldpersonData.Birthday; przBuff.Oldmr = oldpersonData.Birthplace; przBuff.Oldss = !string.IsNullOrEmpty(oldpersonData.Snils) ? SnilsChecker.SsToLong(oldpersonData.Snils) : null; } // Документ УДЛ if (st.PreviousStatement.DocumentUdl != null) { var olddoc = st.PreviousStatement.DocumentUdl; przBuff.Olddoctp = olddoc.DocumentType.Code; przBuff.Olddocs = olddoc.Series; przBuff.Olddocn = olddoc.Number; przBuff.Olddocdt = olddoc.DateIssue; przBuff.Olddocend = olddoc.DateExp; przBuff.Olddocorg = olddoc.IssuingAuthority; } // Документ УДЛ if (st.PreviousStatement.ResidencyDocument != null && st.PreviousStatement.ResidencyDocument.DocumentType != null) { var olddoc = st.PreviousStatement.ResidencyDocument; przBuff.Oldrdoctp = olddoc.DocumentType.Code; przBuff.Oldrdocs = olddoc.Series; przBuff.Oldrdocn = olddoc.Number; przBuff.Oldrdocdt = olddoc.DateIssue; przBuff.Oldrdocend = olddoc.DateExp; przBuff.Oldrdocorg = olddoc.IssuingAuthority; } } if (przBuff.Dend == new DateTime(2200, 1, 1)) { przBuff.Dend = null; } if (przBuff.Dstop == new DateTime(2200, 1, 1)) { przBuff.Dstop = null; } if (st.FormManufacturing != null) { przBuff.Polvid = GetPolisVid(st.FormManufacturing.Id); } if (documentResidency != null && documentResidency.DocumentType != null) { // Документ на право проживания в РФ przBuff.Rdoctp = documentResidency.DocumentType.Code; przBuff.Rdocs = documentResidency.Series; przBuff.Rdocn = documentResidency.Number; przBuff.Rdocdt = documentResidency.DateIssue; przBuff.Rdocorg = documentResidency.IssuingAuthority; przBuff.Rdocend = documentResidency.DateExp; } // Помечаем заявление созданные через нашу систему // Будет использовать впоследствии при импорте из СРЗ przBuff.Num = "-1"; // Помечаем адреса структурированный/не структурированный var args = address.IsNotStructureAddress.HasValue ? Convert.ToInt16(address.IsNotStructureAddress.Value) .ToString(CultureInfo.InvariantCulture) : "0"; var s = address2.IsNotStructureAddress.HasValue ? Convert.ToInt16(address2.IsNotStructureAddress.Value) .ToString(CultureInfo.InvariantCulture) : "0"; przBuff.Zaddr = string.Format("{0}{1}", args, s); sessionAtl.Save(przBuff); log.Reccount++; logger.Trace(przBuff); return(przBuff); }
/// <summary> /// The get person. /// </summary> /// <param name="statement"> /// The statement. /// </param> /// <returns> /// The <see cref="PersonType"/> . /// </returns> protected virtual PersonType GetPerson(Statement statement) { var conceptManager = ObjectFactory.GetInstance <IConceptCacheManager>(); var deadManager = ObjectFactory.GetInstance <IDeadInfoManager>(); var insuredPersonData = statement.InsuredPersonData; var person = new PersonType(); // ФИО person.FAM = insuredPersonData.LastName; person.IM = insuredPersonData.FirstName; person.OT = insuredPersonData.MiddleName; // Пол person.W = conceptManager.Unproxy(insuredPersonData.Gender).Code; // ДР if (insuredPersonData.Birthday.HasValue) { person.DR = insuredPersonData.Birthday.Value.ToShortDateString(); } // Место рождения person.MR = insuredPersonData.Birthplace; // Гражданство, без гражданства, беженец person.C_OKSM = !insuredPersonData.IsNotCitizenship ? conceptManager.Unproxy(insuredPersonData.Citizenship).Code : "Б/Г"; // Категория person.KATEG = insuredPersonData.Category != null?conceptManager.Unproxy(insuredPersonData.Category).Code : null; person.SS = !string.IsNullOrEmpty(insuredPersonData.Snils) ? SnilsChecker.SsToLong(statement.InsuredPersonData.Snils) : null; // Контактная информация if (statement.ContactInfo != null) { person.PHONE = statement.ContactInfo.WorkPhone; person.PHONE_WORK = statement.ContactInfo.WorkPhone; person.EMAIL = statement.ContactInfo.Email; } // Информация о представителе if (statement.Representative != null) { var repr = statement.Representative; person.FIOPR = string.Format("{0} {1} {2}", repr.LastName, repr.FirstName, repr.MiddleName); person.CONTACT = string.Format("{0};{1}", repr.HomePhone, repr.WorkPhone); } // Дата смерти if (statement.InsuredPerson.DeadInfo != null) { person.DDEATH = deadManager.GetById(statement.InsuredPerson.DeadInfo.Id).DateDead.ToShortDateString(); } // Код надёжности идентификации person.DOST = GetDost(statement); // Представитель person.PR = GetAssignee(statement.Representative); return(person); }