private void SidPersonChangesRequestForm_Load(object sender, System.EventArgs e) { this.loading = true; this.TypeDocFaset = FasetItemMapper.FindByFasetName("Документы, удостоверяющие личность"); this.TypeDocFaset.Add(FasetItem.Null.Name, FasetItem.Null); this.BenefitTypeDocFaset = FasetItemMapper.FindByFasetName("Тип документа подтверждающих право на льготу"); this.BenefitTypeDocFaset.Add(FasetItem.Null.Name, FasetItem.Null); this.bsBenefitTypeDocFaset.set_DataSource(this.BenefitTypeDocFaset.Values); this.StRodFaset = FasetItemMapper.FindByFasetName("Семейно-родственные отношения"); this.StRodFaset.Add(FasetItem.Null.Name, FasetItem.Null); this.bsStRodFaset.set_DataSource(this.StRodFaset.Values); this.TypeResidentsFaset = FasetItemMapper.FindByFasetName("Тип проживания"); this.TypeResidentsFaset.Add(FasetItem.Null.Name, FasetItem.Null); this.bsTypeResidentsFaset.set_DataSource(this.TypeResidentsFaset.Values); if (!this.IsGetDataPassporter) { string request = this.PrepareRequest(); string source = this.SendRequest(request); this.sidResponses = Serializer.FromXml<SidResponse>(source); } this.residents = ResidentPack.FindByApartment(this.apartment); this.equalityPersons = new System.Collections.Generic.List<EqualityPerson>(); this.ParseResponse(this.sidResponses); this.tabControl.set_SelectedTab(this.tabReg); this.loading = false; this.moving = false; this.bsSidPerson.set_DataSource(this.sidResponses.GetPersons()); this.bsSnPerson.set_DataSource(null); this.bsSnPerson.set_DataSource(this.residents); this.bsEqualityPerson.set_DataSource(null); this.bsEqualityPerson.set_DataSource(EqualityPerson.GetOriginalPersons(this.equalityPersons)); if (this.bsEqualityPerson.get_Count() > 0) { this.bsEqualityPerson.set_Position(0); } }
public SidPersonChangesRequestForm(Apartment apart, SidResponse response) : this() { this.InitializeParameters(apart); this.sidResponses = response; this.IsGetDataPassporter = true; }
private void ParseResponse(SidResponse sidResponses) { SidResponseType responseType = sidResponses.GetResponseType(); if ((responseType != null) && !responseType.Volidation()) { throw new System.ApplicationException("Некорректное поле 'Код запроса' в ответе.\nДолжно быть равно 50.\nПришло " + responseType.XmlType); } foreach (SidPerson person in sidResponses.GetPersons()) { person.Volidation(); SidPersonDocument[] documents = person.Documents; for (int i = 0; i < documents.Length; i = (int) (i + 1)) { SidPersonDocument document = documents[i]; document.Volidation(); if (this.TypeDocFaset.ContainsKey(document.Type ?? FasetItem.Null.Name)) { document.TypeDocFasetId = this.TypeDocFaset[document.Type ?? FasetItem.Null.Name].Id; } else { document.TypeDocFasetId = 0; } } SidPersonRegistration[] registrations = person.Registrations; for (int j = 0; j < registrations.Length; j = (int) (j + 1)) { SidPersonRegistration registration = registrations[j]; registration.Validation(); if (this.StRodFaset.ContainsKey((string) (registration.FamilyRelation ?? ""))) { registration.Relative = this.StRodFaset[(registration.FamilyRelation ?? "").Replace("Другая степень родства", "Прочие")].Id; } else { registration.Relative = this.StRodFaset["Прочие"].Id; } if ((registration.Type.Contains("Временно") && !this.TypeResidentsFaset.ContainsKey("Проживает")) && this.TypeResidentsFaset.ContainsKey("Временно зарегистрирован")) { registration.TypeResidents = this.TypeResidentsFaset["Временно зарегистрирован"].Id; } else { registration.TypeResidents = this.TypeResidentsFaset[registration.Type.Replace("Регистрация лица по месту жительства", "Прописан").Replace("Регистрация лица по месту пребывания", "Проживает").Replace("Временно", "Проживает").Replace("Постоянно", "Прописан")].Id; } } SidPersonBenefit[] benefits = person.Benefits; for (int k = 0; k < benefits.Length; k = (int) (k + 1)) { SidPersonBenefit benefit = benefits[k]; benefit.Validation(); if (this.BenefitTypeDocFaset.ContainsKey(benefit.DocType ?? FasetItem.Null.Name)) { benefit.TypeDocFasetId = this.BenefitTypeDocFaset[benefit.DocType ?? FasetItem.Null.Name].Id; } else { benefit.TypeDocFasetId = 0; } } } foreach (Person person2 in Person.FindByApartment(this.apartment)) { ResidentPack pack = new ResidentPack { Person = person2, apartmentResidents = ApartmentResident.FindByApartmentIdAndPersonId(this.apartment.Id, person2.Id), personBenefits = PersonBenefit.FindByPersonId(person2.Id), personBenefitDocuments = new ObjectList<PersonBenefitDocument>(), personBenefitDocumentLink = new System.Collections.Generic.Dictionary<PersonBenefitDocument, PersonBenefit>() }; foreach (PersonBenefit benefit2 in pack.personBenefits) { foreach (PersonBenefitDocument document2 in PersonBenefitDocument.FindByPersonBenefitId(benefit2.Id)) { pack.personBenefitDocuments.Add(document2); pack.personBenefitDocumentLink.Add(document2, benefit2); } } this.residents.Add(pack); } foreach (SidPerson person3 in sidResponses.GetPersons()) { foreach (ResidentPack pack2 in this.residents) { if ((EqualityPerson.FindByResidentPack(this.equalityPersons, pack2).get_Count() <= 0) || (EqualityPerson.FindBySidPerson(this.equalityPersons, person3).get_Count() <= 0)) { Person person4 = pack2.Person; EqualityPerson person5 = null; SidPersonDocument[] documentArray2 = person3.Documents; for (int m = 0; m < documentArray2.Length; m = (int) (m + 1)) { SidPersonDocument document3 = documentArray2[m]; if ((((((document3.Series != string.Empty) && (document3.Number != "")) && ((document3.Number != "0") && (document3.Org != string.Empty))) && (((person4.SerDoc != string.Empty) && (person4.NumDoc != "")) && ((person4.NumDoc != "0") && (person4.OrgDoc != string.Empty)))) && (document3.Series.Trim().ToUpper().Replace("Ё", "Е") == (person4.SerDoc ?? "").Trim().ToUpper().Replace("Ё", "Е"))) && (document3.Number.Trim().ToUpper().Replace("Ё", "Е") == (person4.NumDoc ?? "").Trim().ToUpper().Replace("Ё", "Е"))) { if (person5 == null) { person5 = new EqualityPerson(); } person5.matchColor = this.greenMatch; person5.MatchType = "по документу, удостоверяющему личность"; } } if (person5 == null) { if ((((person4.LName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.LastName.Trim().ToUpper().Replace("Ё", "Е")) && ((person4.MName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.MiddleName.Trim().ToUpper().Replace("Ё", "Е"))) && ((person4.FName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.FirstName.Trim().ToUpper().Replace("Ё", "Е"))) { if (person5 == null) { person5 = new EqualityPerson(); } person5.matchColor = this.greenMatch; person5.MatchType = "по ФИО и дате рождения"; } else if ((((person4.LName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.LastName.Trim().ToUpper().Replace("Ё", "Е")) && ((person4.MName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.MiddleName.Trim().ToUpper().Replace("Ё", "Е"))) && ((((person4.FName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.FirstName.Trim().ToUpper().Replace("Ё", "Е")) && (person4.BirthDate.Date == person3.BirthDate.Date)) && (person4.BirthDate != System.DateTime.MinValue))) { if (person5 == null) { person5 = new EqualityPerson(); } person5.matchColor = this.yellowMatch; person5.MatchType = "по ФИО"; } else if (((NameHash.MetaPhone((person4.LName ?? "").Trim().ToUpper().Replace("Ё", "Е")) == NameHash.MetaPhone(person3.LastName.Trim().ToUpper().Replace("Ё", "Е"))) && ((person4.MName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.MiddleName.Trim().ToUpper().Replace("Ё", "Е"))) && ((((person4.FName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.FirstName.Trim().ToUpper().Replace("Ё", "Е")) && (person4.BirthDate.Date == person3.BirthDate.Date)) && (person4.BirthDate != System.DateTime.MinValue))) { if (person5 == null) { person5 = new EqualityPerson(); } person5.matchColor = this.yellowMatch; person5.MatchType = "нечетким сравнением по фамилии, четким по ИО и дате рождения"; } else if (((person4.MName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.MiddleName.Trim().ToUpper().Replace("Ё", "Е")) && ((((person4.FName ?? "").Trim().ToUpper().Replace("Ё", "Е") == person3.FirstName.Trim().ToUpper().Replace("Ё", "Е")) && (person4.BirthDate.Date == person3.BirthDate.Date)) && (person4.BirthDate != System.DateTime.MinValue))) { if (person5 == null) { person5 = new EqualityPerson(); } person5.matchColor = this.redMatch; person5.MatchType = "по имени, отчеству и дате рождения"; } } if (person5 != null) { person5.sidPerson = person3; person3.matchColor = person5.matchColor; person3.equalityed = (int) (person3.equalityed + 1); pack2.matchColor = person5.matchColor; pack2.equalityed = (int) (pack2.equalityed + 1); person5.residentPack = pack2; person5.LName = person3.LastName.Trim().ToUpper(); person5.MName = person3.MiddleName.Trim().ToUpper(); person5.FName = person3.FirstName.Trim().ToUpper(); person5.BirthDate = person3.BirthDate; person5.IsAllowedPersonDataUsage = person3.IsAllowedPersonDataUsage; this.equalityPersons.Add(person5); } } } } foreach (EqualityPerson person6 in this.equalityPersons) { bool flag = true; while (flag) { flag = false; SidPersonRegistration[] registrationArray2 = person6.sidPerson.Registrations; for (int n = 0; n < registrationArray2.Length; n = (int) (n + 1)) { SidPersonRegistration registration2 = registrationArray2[n]; bool flag2 = false; if (registration2.FromDate != registration2.ToDate) { foreach (ApartmentResident resident in person6.residentPack.apartmentResidents) { if ((registration2.ToDate == System.DateTime.MinValue) && (resident.ToDate == System.DateTime.MinValue)) { flag2 = true; break; } if (((registration2.ToDate >= resident.FromDate) && (registration2.ToDate != System.DateTime.MinValue)) && (resident.ToDate == System.DateTime.MinValue)) { resident.ToDate = registration2.ToDate; AIS.SN.UI.Messages.ShowMessage(string.Concat((string[]) new string[] { "У человека '", person6.residentPack.Person.LName, " ", person6.residentPack.Person.FName, " ", person6.residentPack.Person.MName, "'\nавтоматически закрыта регистрация с ", registration2.FromDate.ToShortDateString(), ((registration2.ToDate == System.DateTime.MinValue) ? "" : ((string) (" по " + registration2.ToDate.ToShortDateString()))) })); flag2 = true; flag = true; break; } if ((!(registration2.ToDate == System.DateTime.MinValue) && !(resident.ToDate == System.DateTime.MinValue)) && ((registration2.ToDate >= resident.FromDate) && (resident.ToDate >= registration2.FromDate))) { System.DateTime time = (registration2.FromDate < resident.FromDate) ? registration2.FromDate : resident.FromDate; System.DateTime time2 = (registration2.FromDate < resident.FromDate) ? resident.FromDate : registration2.FromDate; System.DateTime time3 = (registration2.ToDate < resident.ToDate) ? registration2.ToDate : resident.ToDate; System.DateTime time4 = (registration2.ToDate < resident.ToDate) ? resident.ToDate : registration2.ToDate; long num = System.Math.Abs(((System.TimeSpan) (time3 - time2)).get_Ticks()); long num2 = System.Math.Abs(((System.TimeSpan) (time4 - time)).get_Ticks()); if (((((double) num) / ((double) num2)) >= 0.5) && ((((double) num) / ((double) num2)) > 0.5)) { flag2 = true; break; } } } if (!flag2) { ApartmentResident resident2 = new ApartmentResident { PersonId = person6.residentPack.Person.Id, ToDate = registration2.ToDate, FromDate = registration2.FromDate, Relative = registration2.Relative, TypeResidents = registration2.TypeResidents }; person6.residentPack.apartmentResidents.Add(resident2); AIS.SN.UI.Messages.ShowMessage(string.Concat((string[]) new string[] { "У человека '", person6.residentPack.Person.LName, " ", person6.residentPack.Person.FName, " ", person6.residentPack.Person.MName, "'\nавтоматически добавлена новая регистрация с ", registration2.FromDate.ToShortDateString(), ((registration2.ToDate == System.DateTime.MinValue) ? "" : ((string) (" по " + registration2.ToDate.ToShortDateString()))) })); flag = true; } } } } } }