private void attach_RbStatusObservationClientTypes_CreatePersonId(RbStatusObservationClientType entity) { this.SendPropertyChanging("RbStatusObservationClientTypes_CreatePersonId"); entity.Person_CreatePersonId = this; }
private void detach_RbStatusObservationClientTypes_ModifyPersonId(RbStatusObservationClientType entity) { this.SendPropertyChanging("RbStatusObservationClientTypes_ModifyPersonId"); entity.Person_ModifyPersonId = null; }
public static void SetColorMakers(IBackgroundContext context, LpuExecParams executorParams) { ClearColorMakers(context, null); context.ProgressSeparator(); context.ReportProgress(@"УСТАНОВКА МАРКЕРОВ НЕДЕЙСТВИТЕЛЬНЫХ ПОЛИСОВ"); context.ProgressSeparator(); using (var dataContext = new SetColorMakersDataContext(context)) { dataContext.Load(context); var invMarkerType = getInvMarkerType(dataContext); if (invMarkerType == null) { invMarkerType = new RbStatusObservationClientType(); invMarkerType.Code = InvalidPolicyMarkerCode; invMarkerType.Color = InvalidPolicyMarkerColor; invMarkerType.Name = InvalidPolicyMarkerName; dataContext.VistaMed.SubmitChanges(); } invMarkerType = getInvMarkerType(dataContext); if (invMarkerType != null) { context.ReportProgress(@""); foreach (var smoPacient in dataContext.SmoPacients.TakeWhile(x => !context.CancellationPending)) { var smoCode = smoPacient.Key; var smoPolicyNumbers = new HashSet<string>(); // smoPacient.Value.Select(x => x.SerialNum).Distinct().ToList().ForEach(z => smoPolicyNumbers.Add(z)); // 14/01/14 поиск по более полному ключу smoPacient.Value.Select(x => x.Key).Distinct().ToList().ForEach(z => smoPolicyNumbers.Add(z)); var smo = dataContext.VistaMed.Organisations.FirstOrDefault(x => x.MiacCode == smoCode && x.IsInsurer); if(smo != null) { var smoId = smo.Id; context.ReportProgress(@"СМО {0}", smo.FullName); try { var allPolicies = from p in dataContext.VistaMed.ClientPolicies where p.InsurerId == smoId && p.Id == dataContext.VistaMed.GetClientPolicyId(p.ClientId, 1) select new { p.Id, p.ClientId, p.Serial, p.Number, p.Client.LastName, p.Client.FirstName, p.Client.PatrName, p.Client.BirthDate }; context.ReportProgress(@"Проверяем полисы"); var invalidPolicies = new List<Tuple<int,int>>(); int i = 1; foreach (var policy in allPolicies) { if (context.CancellationPending) break; // 14/01/14 поиск по полному ключу var policyKey = (policy.Serial + "|" + policy.Number + "|" + policy.LastName + "|" + policy.FirstName + "|" + policy.PatrName + "|" + policy.BirthDate.ToShortDateString()).ToUpper(); if (!smoPolicyNumbers.Contains(policyKey)) invalidPolicies.Add(new Tuple<int, int>(policy.Id, policy.ClientId)); if(i % 50000 == 0) context.ReportProgress(); i++; } if(invalidPolicies.Count == 0) context.ReportProgress(@"Недействительные полисы не найдены"); else { context.ReportProgress(@"Обнаружено {0} недействительных полисов", invalidPolicies.Count); var invalidClients = invalidPolicies.Select(x => x.Item2).Distinct(); var batch = new List<int>(); context.ReportProgress(@"Простановка маркеров"); foreach (var invalidClient in invalidClients) { batch.Add(invalidClient); execBatch(context, dataContext, batch, invMarkerType.Id); } execBatch(context, dataContext, batch, invMarkerType.Id, true); } } catch (Exception exception) { context.ReportError(exception.Message); } context.ProgressSeparator('+'); } else context.ReportError(@"СМО с кодом МИАЦ {0} не найдена в БД ВистаМед", smoCode); } } else { context.ReportError(@"Тип маркера недействительного полиса не найден в БД ВистаМед"); } } context.ProgressSeparator('-'); }