private void OpenShellWithProjects() { try { var d = new DocWindow(true); d.ShowDialog(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } }
private void Button_Click(object sender, RoutedEventArgs e) { _context.Configuration.ProxyCreationEnabled = false; var t = warningsSelector.SelectedValue; var projectDoc = new ProjectDoc { list_of_barrier = barrierSelector.SelectedItems.Cast <barrier>().ToList <barrier>(), list_of_protect_mech = protect_mechSelector.SelectedItems.Cast <protect_mech>().ToList <protect_mech>(), list_of_warnings = warningsSelector.SelectedItems.Cast <warnings>().ToList <warnings>(), list_of_objects = objectSelector.SelectedItems.Cast <@object>().ToList <@object>(), list_of_weakness = weaknessSelector.SelectedItems.Cast <weakness>().ToList <weakness>(), calc_type = Type3.IsChecked == false ? 1 : 0, name = edtName.Text, description = edtDesc.Text, object_type = (int)indust_objectComboBox.SelectedValue }; //если есть связь с окружением - оставляем //иначе - удаляем var tem = projectDoc.list_of_protect_mech.Select(pm => pm.id).ToList(); projectDoc.list_of_warnings = projectDoc.list_of_warnings.Where <warnings>(w => _context.war_to_prot.Where(wtp => wtp.warcode == w.id && tem.Contains(wtp.protcode)).Count() > 0).ToList <warnings>(); tem = projectDoc.list_of_warnings.Select(pm => pm.id).ToList(); if (projectDoc.calc_type == 1) { var tem2 = projectDoc.list_of_barrier.Select(pm => pm.id).ToList(); projectDoc.list_of_protect_mech = projectDoc.list_of_protect_mech.Where <protect_mech>(p => _context.war_to_prot.Where(wtp => wtp.protcode == p.id && tem.Contains(wtp.warcode)).Count() > 0 || _context.prot_to_bar.Where(ptb => ptb.protcode == p.id && tem2.Contains(ptb.barcode)).Count() > 0 ).ToList <protect_mech>(); tem = projectDoc.list_of_protect_mech.Select(pm => pm.id).ToList(); tem2 = projectDoc.list_of_weakness.Select(pm => pm.id).ToList(); projectDoc.list_of_barrier = projectDoc.list_of_barrier.Where <barrier>(b => _context.prot_to_bar.Where(ptb => ptb.barcode == b.id && tem.Contains(ptb.protcode)).Count() > 0 || _context.bar_to_weak.Where(btw => btw.barcode == b.id && tem2.Contains(btw.weakcode)).Count() > 0 ).ToList <barrier>(); tem = projectDoc.list_of_barrier.Select(pm => pm.id).ToList(); tem2 = projectDoc.list_of_objects.Select(pm => pm.id).ToList(); projectDoc.list_of_weakness = projectDoc.list_of_weakness.Where <weakness>(we => _context.bar_to_weak.Where(btw => btw.weakcode == we.id && tem.Contains(btw.barcode)).Count() > 0 || _context.weak_to_object.Where(wto => wto.weakcode == we.id && tem2.Contains(wto.objcode)).Count() > 0 ).ToList <weakness>(); tem = projectDoc.list_of_weakness.Select(pm => pm.id).ToList(); projectDoc.list_of_objects = projectDoc.list_of_objects.Where <@object>(o => _context.weak_to_object.Where(wto => wto.objcode == o.id && tem.Contains(wto.weakcode)).Count() > 0).ToList <@object>(); } else { var tem2 = projectDoc.list_of_objects.Select(pm => pm.id).ToList(); projectDoc.list_of_protect_mech = projectDoc.list_of_protect_mech.Where <protect_mech>(p => _context.war_to_prot.Where(wtp => wtp.protcode == p.id && tem.Contains(wtp.warcode)).Count() > 0 || _context.prot_to_obj.Where(pto => pto.protcode == p.id && tem2.Contains(pto.objcode)).Count() > 0 ).ToList <protect_mech>(); tem = projectDoc.list_of_protect_mech.Select(pm => pm.id).ToList(); projectDoc.list_of_objects = projectDoc.list_of_objects.Where <@object>(o => _context.prot_to_obj.Where(pto => pto.objcode == o.id && tem.Contains(pto.protcode)).Count() > 0).ToList <@object>(); } this.Close(); if (fromShell) { ((DocWindow)((Grid)((DockingManager)sendForm).Parent).Parent).OpenGraphForm(projectDoc); } else { var d = new DocWindow(projectDoc); d.ShowDialog(); } }