protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { labelTitle.Text = ""; labelTitle.Status = Statuses.NotActive; _directivesViewer.SetItemsArray(_resultDirectiveArray.ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); }
private void UpdateInformation() { SetEnableControl(false); comboBoxLevel.Items.Clear(); comboBoxLevel.Items.AddRange(_levels.ToArray()); comboBoxLevel.Items.Add(FindingLevels.Unknown); comboBoxLevel.SelectedItem = FindingLevels.Unknown; comboBoxRevision.Items.Clear(); comboBoxRevision.Items.AddRange(_currentRevisions.ToArray()); if (_currentRevisions.Any()) { comboBoxRevision.SelectedIndex = 0; } _fromcheckListView.SetItemsArray(_addedChecks.ToArray()); _tocheckListView.SetItemsArray(_updateChecks.ToArray()); }
protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { return; } _directivesViewer.SetItemsArray(_itemsArray.ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); }
private void UpdateInformation() { comboBoxAuditor.Items.Clear(); comboBoxAuditor.Items.AddRange(pelSpec.Where(i => i.Specialist.Operator == AllOperators.Unknown).ToArray()); comboBoxAuditee.Items.Clear(); if (_audit.OperatorId == AllOperators.Unknown.ItemId) { comboBoxAuditee.Items.AddRange(pelSpec.Where(i => i.Specialist.Operator == AllOperators.Unknown).ToArray()); } else { comboBoxAuditee.Items.AddRange(pelSpec.Where(i => i.Specialist.Operator != AllOperators.Unknown).ToArray()); } _fromcheckRevisionListView.SetItemsArray(_addedChecks.ToArray()); _tocheckRevisionListView.SetItemsArray(_updateChecks.ToArray()); }
private void ButtonAdd_Click(object sender, EventArgs e) { if (_fromcheckListView.SelectedItems.Count > 0) { foreach (var item in _fromcheckListView.SelectedItems.ToArray()) { _updateChecks.Add(item); _addedChecks.Remove(item); GlobalObjects.CaaEnvironment.NewKeeper.Save(new CheckListRevisionRecord { CheckListId = item.ItemId, ParentId = _parent.ItemId }); } _fromcheckListView.SetItemsArray(_addedChecks.ToArray()); _tocheckListView.SetItemsArray(_updateChecks.ToArray()); } }
public PelItemForm(int auditId, int operatorId, CommonCollection <CheckLists> initialDocumentArray) { InitializeComponent(); _auditId = auditId; _operatorId = operatorId; _addedChecks.AddRange(initialDocumentArray.ToArray()); _animatedThreadWorker.DoWork += AnimatedThreadWorkerDoLoad; _animatedThreadWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerLoadCompleted; _animatedThreadWorker.RunWorkerAsync(); }
private void BuildControls() { WorkPackage wp = comboBoxWorkPackage.SelectedItem as WorkPackage; string caption = wp != null ? (wp.Aircraft != null ? wp.Aircraft.RegistrationNumber + " " + wp.Number : wp.Number) : "Select Work Package"; extendableRichContainer.labelCaption.Text = caption; labelProcess.Text = ""; hangarWorkPackageView.SetItemsArray(_itemsArray.ToArray()); hangarWorkPackageView.Focus(); }
public void UpdateControl(Dictionary <int, Lifelength> groupLifelengths, CommonCollection <IMtopCalc> maintenanceDirectives, List <MTOPCheck> maintenanceChecks) { Controls.Clear(); mtopDirectiveListView1 = new MTOPDirectiveListView(groupLifelengths, maintenanceChecks) { Location = new Point(0, 0), Size = new Size(1310, 400) }; Controls.Add(mtopDirectiveListView1); mtopDirectiveListView1.SetItemsArray(maintenanceDirectives.ToArray()); mtopDirectiveListView1.radGridView1.MasterTemplate.CollapseAllGroups(); }
/// <summary> /// Производит действия после работы над списком элементов /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (CurrentOperator != null) { labelTitle.Text = "Date as of: " + SmartCore.Auxiliary.Convert.GetDateFormat(DateTime.Today); } else { labelTitle.Text = ""; labelTitle.Status = Statuses.NotActive; } _directivesViewer.SetItemsArray(_resultDirectiveArray.ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); }
protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (CurrentAircraft != null) { labelTitle.Text = "Date as of: " + SmartCore.Auxiliary.Convert.GetDateFormat(DateTime.Today) + " Aircraft TSN/CSN: " + GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(CurrentAircraft); } else { labelTitle.Text = ""; labelTitle.Status = Statuses.NotActive; } _directivesViewer.SetItemsArray(_resultDirectiveArray.ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); }
protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { return; } //TODO:(Evgenii Babak) создать метод для получения названия ATLB по FlightId var last = GlobalObjects.AircraftFlightsCore.GetLastAircraftFlight(CurrentAircraft.ItemId); if (last != null) { var lastAtlb = _itemsArray.GetItemById(last.ATLBId); labelDateAsOf.Text = lastAtlb != null ? "Current ATLB: " + lastAtlb : ""; } _directivesViewer.SetItemsArray(_itemsArray.ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); }
private void BackgroundWorkerRunWorkerLoadCompleted(object sender, RunWorkerCompletedEventArgs e) { listViewTasksForSelect.SetItemsArray(_itemsForSelect.ToArray()); listViewBindedTasks.SetItemsArray(_bindedItems.ToArray()); comboBoxRelationType.DisplayMember = "Key"; comboBoxRelationType.ValueMember = "Value"; comboBoxRelationType.DataSource = EnumHelper.GetDisplayValueMemberDict <WorkItemsRelationTypeUI>(); comboBoxRelationType.SelectedIndexChanged -= ComboBoxRelationType_SelectedIndexChanged; _selectedRelationTypeUI = _maintenanceDirective.ItemRelations.Count == 0 ? WorkItemsRelationTypeUI.ThisItemAffectOnAnother : ItemRelationHelper.ConvertBLItemRelationToUIITem(_maintenanceDirective.WorkItemsRelationType, _maintenanceDirective.IsFirst.HasValue && _maintenanceDirective.IsFirst.Value); comboBoxRelationType.SelectedValue = _selectedRelationTypeUI; comboBoxRelationType.SelectedIndexChanged += ComboBoxRelationType_SelectedIndexChanged; }
protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { _directivesViewer.SetItemsArray(_resultDocumentArray.ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); if (_toolStripMenuItemsWorkPackages != null) { foreach (var item in _toolStripMenuItemsWorkPackages.Items) { item.Click -= AddToWorkPackageItemClick; } _toolStripMenuItemsWorkPackages.Items.Clear(); foreach (var workPackage in _openPubWorkPackages) { var item = new RadMenuItem($"{workPackage.Title}"); item.Click += AddToWorkPackageItemClick; item.Tag = workPackage; _toolStripMenuItemsWorkPackages.Items.Add(item); } } if (_toDate.HasValue) { labelTitle.Visible = true; labelTitle.Text = $"Schedule Period : {_schedule}"; } else { labelTitle.Visible = false; } _toolStripMenuItemComposeWorkPackage.Visibility = _toolStripMenuItemsWorkPackages.Visibility = _toolStripMenuItemsWShowWP.Visibility = _toDate.HasValue ? ElementVisibility.Collapsed : ElementVisibility.Visible; }
/// <summary> /// Обновляет значения полей /// </summary> public override void FillControls() { BeginUpdate(); _documents.Clear(); _documents.AddRange(GlobalObjects.DocumentCore. GetDocuments(ProcedureDocumentReference.Procedure.ParentOperator, DocumentType.Other, true)); comboBoxDocument.Items.Clear(); comboBoxDocument.Items.AddRange(_documents.ToArray()); if (ProcedureDocumentReference != null) { if (ProcedureDocumentReference.ItemId > 0) { comboBoxDocument.SelectedItem = _documents.GetItemById(ProcedureDocumentReference.Document != null ? ProcedureDocumentReference.Document.ItemId : -1); } } EndUpdate(); }
private void BackgroundWorkerRunWorkerLoadCompleted(object sender, RunWorkerCompletedEventArgs e) { comboBoxCustomer.Items.Clear(); comboBoxCustomer.Items.AddRange(_supplierArray.ToArray()); comboBoxCustomer.Items.Add(Supplier.Unknown); comboBoxCustomer.SelectedItem = _flightTrack.Supplier; foreach (var flightNumber in _resultFlightsArray.OrderBy(f => f.FlightNo.FullName)) { var periods = _resultPeriodArray.Where(f => f.FlightNumberId == flightNumber.ItemId); if (periods.Any()) { _resultArray.Add(flightNumber); foreach (var period in periods) { _resultArray.Add(period); } } } flightNumberListViewAll.SetItemsArray(_resultArray.ToArray()); flightNumberListView2.SetItemsArray(_addedItems.ToArray()); }
private void BackgroundWorkerRunWorkerLoadCompleted(object sender, RunWorkerCompletedEventArgs e) { listViewTasksForSelect.SetItemsArray(_mpdForSelect.ToArray()); listViewBindedTasks.SetItemsArray(_recordsTasks.ToArray()); }
protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e) { var temp = new CommonCollection <CAAEducationManagment>(); _initialDocumentArray.Clear(); _resultDocumentArray.Clear(); AnimatedThreadWorker.ReportProgress(0, "load directives"); var specialists = new List <Specialist>(); var educations = new List <SmartCore.CAA.CAAEducation.CAAEducation>(); var records = new List <CAAEducationRecord>(); var occupation = GlobalObjects.CaaEnvironment?.GetDictionary <Occupation>().ToArray(); educations.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <EducationDTO, SmartCore.CAA.CAAEducation.CAAEducation>(new Filter("OperatorId", _operatorId), loadChild: true)); specialists.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <CAASpecialistDTO, Specialist>(new Filter("OperatorId", _operatorId))); records.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <EducationRecordsDTO, CAAEducationRecord>(new Filter("OperatorId", _operatorId))); foreach (var specialist in specialists) { FillCollection(educations, specialist.Occupation, specialist, records, false); foreach (Occupation dict in occupation) { if (specialist.Combination != null && specialist.Combination.Contains(dict.FullName)) { FillCollection(educations, dict, specialist, records); } } } AnimatedThreadWorker.ReportProgress(40, "filter directives"); if (_openPubWorkPackages == null) { _openPubWorkPackages = new CommonCollection <SmartCore.CAA.CAAWP.CoursePackage>(); } _openPubWorkPackages.Clear(); if (_operatorId == -1) { _openPubWorkPackages.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <CoursePackageDTO, SmartCore.CAA.CAAWP.CoursePackage>(new List <Filter>() { new Filter("Status", 0) })); } else { _openPubWorkPackages.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <CoursePackageDTO, SmartCore.CAA.CAAWP.CoursePackage>( new List <Filter>() { new Filter("Status", 0), new Filter("OperatorId", _operatorId) } )); } if (_toDate.HasValue) { temp.AddRange(_initialDocumentArray.ToArray()); _initialDocumentArray.Clear(); foreach (var t in temp) { if (t.Record.Settings.NextCompliances != null && t.Record.Settings.NextCompliances.Any()) { foreach (var next in t.Record.Settings.NextCompliances) { var newItem = t.DeepClone(); newItem.Record.Settings.NextCompliance = next; _initialDocumentArray.Add(newItem); } } else { var newItem = t.DeepClone(); newItem.Record.Settings.NextCompliance = new NextCompliance(); _initialDocumentArray.Add(t); } } } FilterItems(_initialDocumentArray, _resultDocumentArray); AnimatedThreadWorker.ReportProgress(100, "Complete"); }
protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { return; } labelDateAsOf.Text = "Audit Status: " + _currentDirective.Status; switch (_currentDirective.Status) { case WorkPackageStatus.Published: { buttonAddNonRoutineJob.Enabled = false; buttonPublish.Enabled = false; buttonClose.Enabled = true; if (_currentDirective.CanClose == false) { buttonClose.ShowToolTip = true; buttonClose.ToolTipText = "This audit can not be closed"; } else { buttonClose.ShowToolTip = false; buttonClose.ToolTipText = ""; } break; } case WorkPackageStatus.Closed: { buttonAddNonRoutineJob.Enabled = false; buttonPublish.Enabled = true; if (_currentDirective.CanPublish == false) { buttonPublish.ShowToolTip = true; buttonPublish.ToolTipText = "This audit can not be republished"; } else { buttonPublish.ShowToolTip = false; buttonPublish.ToolTipText = ""; } break; } default: { buttonAddNonRoutineJob.Enabled = true; buttonPublish.Enabled = true; buttonClose.Enabled = true; if (_currentDirective.CanClose == false) { buttonClose.ShowToolTip = true; buttonClose.ToolTipText = "This audit can not be closed"; } else { buttonClose.ShowToolTip = false; buttonClose.ToolTipText = ""; } break; } } _directivesViewer.SetItemsArray(_itemsArray.ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); }
private void MoveToCommand() { if (_directivesViewer.SelectedItems.Count == 0) { return; } if (GlobalObjects.AircraftsCore.GetAircraftsCount() == 0 && GlobalObjects.CasEnvironment.Stores.Count == 0) { MessageBox.Show("You dont remove this component because you dont have a aircrafts", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var components = new CommonCollection <Component>(); foreach (var o in _directivesViewer.SelectedItems) { IDirective dir; if (o is NextPerformance) { dir = ((NextPerformance)o).Parent; } else { dir = o as IDirective; } if (dir == null) { continue; } if (dir is ComponentDirective && !components.Contains(((ComponentDirective)dir).ParentComponent)) { components.Add(((ComponentDirective)dir).ParentComponent); } else if (dir is Component && !components.Contains((Component)dir)) { components.Add((Component)dir); } } if (components.Count <= 0) { return; } var dlg = new MoveComponentForm(components.ToArray(), CurrentStore); dlg.Text = "Move " + (components.Count > 1 ? "components" : "component " + components[0].Description) + " to aircraft"; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoWork; //AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoFilteringWork; AnimatedThreadWorker.DoWork += AnimatedThreadWorkerDoWork; AnimatedThreadWorker.RunWorkerAsync(); } }
private void BackgroundWorkerRunWorkerLoadCompleted(object sender, RunWorkerCompletedEventArgs e) { listViewTasksForSelect.SetItemsArray(_itemsForSelect.ToArray()); }
protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { comboBoxWorkPackage.Items.Clear(); comboBoxWorkPackage.Items.AddRange(_workPackages.ToArray()); comboBoxWorkPackage.DisplayMember = "Number"; }
/// <summary> /// Обновляет значения полей /// </summary> public override void FillControls() { BeginUpdate(); ataChapterComboBox.UpdateInformation(); TemplateComboBox.Items.Clear(); TemplateComboBox.Items.AddRange(_discrepancies.ToArray()); TemplateComboBox.SelectedItem = _discrepancies.FirstOrDefault( d => d.ATAChapter != null && d.ATAChapter.Equals(Discrepancy.ATAChapter) && d.CertificateOfReleaseToService != null && d.CertificateOfReleaseToService.AuthorizationB1.Equals(d.CertificateOfReleaseToService.AuthorizationB1) && d.CertificateOfReleaseToService.AuthorizationB2.Equals(d.CertificateOfReleaseToService.AuthorizationB2) && d.CertificateOfReleaseToService.Station.Equals(d.CertificateOfReleaseToService.Station) && d.CorrectiveAction != null && d.CorrectiveAction.Description.Equals(d.CorrectiveAction.Description) && d.CorrectiveAction.PartNumberOff.Equals(d.CorrectiveAction.PartNumberOff) && d.CorrectiveAction.PartNumberOn.Equals(d.CorrectiveAction.PartNumberOn) && d.CorrectiveAction.SerialNumberOff.Equals(d.CorrectiveAction.SerialNumberOff) && d.CorrectiveAction.SerialNumberOn.Equals(d.CorrectiveAction.SerialNumberOn)); #region lookupComboboxDeferred if (Discrepancy != null) { var aircraft = GlobalObjects.AircraftsCore.GetAircraftById(Discrepancy.ParentFlight.AircraftId); string displayerText = aircraft.RegistrationNumber + ". " + DirectiveType.DeferredItems.CommonName; } #endregion #region lookupComboboxFlight if (Discrepancy != null && Discrepancy.ItemId > 0 && Discrepancy.DirectiveId > 0) { var aircraft = GlobalObjects.AircraftsCore.GetAircraftById(Discrepancy.ParentFlight.AircraftId); ATLB parentAtlb = null; try { parentAtlb = GlobalObjects.CasEnvironment.NewLoader.GetObjectById <ATLBDTO, ATLB>(Discrepancy.ParentFlight.ATLBId); } catch (Exception ex) { Program.Provider.Logger.Log("Error while load linked ATLB fo Discrepancy", ex); } } #endregion _specialists.Clear(); try { _specialists.AddRange(GlobalObjects.CasEnvironment.Loader.GetObjectListAll <Specialist>(loadChild: true).Where(i => i.Occupation?.Department?.FullName == "Line Maintenance")); } catch (Exception ex) { Program.Provider.Logger.Log("Error while load Specialist fo Discrepancy", ex); } if (Discrepancy != null) { comboSpecialist1.Items.AddRange(_specialists.ToArray()); comboSpecialist2.Items.AddRange(_specialists.ToArray()); radioCrew.Checked = Discrepancy.FilledBy == false; // DiscrepancyFilledByEnum.Crew; radioMaintenanceStaff.Checked = Discrepancy.FilledBy; //DiscrepancyFilledByEnum.MaintenanceStaff; ataChapterComboBox.ATAChapter = Discrepancy.ATAChapter; // radioOpen.Checked = Discrepancy.correctiveAction.Status == CorrectiveActionStatus.Open; // radioClose.Checked = Discrepancy.correctiveAction.Status == CorrectiveActionStatus.Close; textDescription.Text = Discrepancy.Description ?? "No"; checkBoxReliability.Checked = Discrepancy.IsReliability; if (Discrepancy.Num > numericUpDownIndex.Maximum) { numericUpDownIndex.Value = numericUpDownIndex.Maximum; } else if (Discrepancy.Num < numericUpDownIndex.Minimum) { numericUpDownIndex.Value = numericUpDownIndex.Minimum; } else { numericUpDownIndex.Value = Discrepancy.Num; } if (Discrepancy.DeferredItem != null) { ataChapterComboBox.Enabled = false; ataChapterComboBox.ATAChapter = Discrepancy.DeferredItem.ATAChapter; _showDeferredInfoPanel = true; } else { _showDeferredInfoPanel = false; } if (Discrepancy.CorrectiveAction != null) { textCorrectiveAction.Text = Discrepancy.CorrectiveAction.Description ?? "No"; textPNOff.Text = Discrepancy.CorrectiveAction.PartNumberOff; textSNOff.Text = Discrepancy.CorrectiveAction.SerialNumberOff; textPNOn.Text = Discrepancy.CorrectiveAction.PartNumberOn; textSNOn.Text = Discrepancy.CorrectiveAction.SerialNumberOn; } else { textCorrectiveAction.Text = "No"; textPNOff.Text = textSNOff.Text = textPNOn.Text = textSNOn.Text = ""; } if (Discrepancy.CertificateOfReleaseToService != null) { textStation.Text = Discrepancy.CertificateOfReleaseToService.Station; dateTimePickerRTSDate.Value = Discrepancy.CertificateOfReleaseToService.RecordDate; if (Discrepancy.CertificateOfReleaseToService.AuthorizationB1 != null) { Specialist selectedSpec = _specialists.GetItemById(Discrepancy.CertificateOfReleaseToService.AuthorizationB1.ItemId); if (selectedSpec != null) { comboSpecialist1.SelectedItem = selectedSpec; } else { //Искомый специалист недействителен comboSpecialist1.Items.Add(Discrepancy.CertificateOfReleaseToService.AuthorizationB1); comboSpecialist1.SelectedItem = Discrepancy.CertificateOfReleaseToService.AuthorizationB1; } comboSpecialist1.BackColor = ((Specialist)comboSpecialist1.SelectedItem).IsDeleted ? Color.FromArgb(Highlight.Red.Color) : Color.White; } if (Discrepancy.CertificateOfReleaseToService.AuthorizationB2 != null) { Specialist selectedSpec = _specialists.GetItemById(Discrepancy.CertificateOfReleaseToService.AuthorizationB2.ItemId); if (selectedSpec != null) { comboSpecialist2.SelectedItem = selectedSpec; } else { //Искомый специалист недействителен comboSpecialist2.Items.Add(Discrepancy.CertificateOfReleaseToService.AuthorizationB2); comboSpecialist2.SelectedItem = Discrepancy.CertificateOfReleaseToService.AuthorizationB2; } comboSpecialist2.BackColor = ((Specialist)comboSpecialist2.SelectedItem).IsDeleted ? Color.FromArgb(Highlight.Red.Color) : Color.White; } } else { textStation.Text = ""; comboSpecialist1.SelectedItem = null; comboSpecialist2.SelectedItem = null; dateTimePickerRTSDate.Value = DateTime.Today; } } else { dateTimePickerRTSDate.Value = DateTime.Today; comboSpecialist1.SelectedItem = null; comboSpecialist2.SelectedItem = null; textDescription.Text = "What Where When Extent"; } SetExtendableControlCaption(); EndUpdate(); }
private void UpdateInformation() { _addedChecks = new CommonCollection <CheckLists>(_addedChecks.Except(_updateChecks)); _fromcheckListView.SetItemsArray(_addedChecks.ToArray()); _tocheckListView.SetItemsArray(_updateChecks.ToArray()); }
protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e) { #region Загрузка элементов AnimatedThreadWorker.ReportProgress(0, "load directives"); try { GlobalObjects.CaaEnvironment.NewLoader.ReloadDictionary(typeof(Occupation), typeof(LocationsType)); if (_currentItem.ItemId > 0) { _currentItem = GlobalObjects.CaaEnvironment.NewLoader.GetObjectById <CAASpecialistDTO, Specialist>(_currentItem.ItemId, true); } var links = GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <CAAItemFileLinkDTO, ItemFileLink>(new List <Filter>() { new Filter("ParentId", _currentItem.ItemId), new Filter("ParentTypeId", _currentItem.SmartCoreObjectType.ItemId) }, true); var fileIds = links.Where(i => i.FileId.HasValue).Select(i => i.FileId.Value); if (fileIds.Any()) { var files = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <CAAAttachedFileDTO, AttachedFile>(new Filter("ItemId", values: fileIds)); foreach (var file in links) { var f = files.FirstOrDefault(i => i.ItemId == file.FileId)?.GetCopyUnsaved(false); if (f == null) { continue; } f.ItemId = file.FileId.Value; file.File = (AttachedFile)f; } } _currentItem.Files.Clear(); _currentItem.Files.AddRange(links); var ds = GlobalObjects.CaaEnvironment.Execute($@"select r.ItemId from [dbo].[CourseRecords] r inner join [dbo].[CoursePackage] p on p.ItemId = r.WorkPackageId where p.Status >= 1 and r.IsDeleted = 0 and p.IsDeleted = 0 and r.SpecialistId = {_currentItem.ItemId}"); var data = ds.Tables[0].AsEnumerable().Select(dataRow => new { ItemId = dataRow.Field <int>("ItemId") }); var courses = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <CAADocumentDTO, SmartCore.Entities.General.Document>(new Filter("ParentID", data.Select(i => i.ItemId))); _currentItem.EmployeeDocuments.AddRange(courses); if (_currentItem.EmployeeDocuments.Any()) { var docIds = _currentItem.EmployeeDocuments.Select(i => i.ItemId); links = GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <CAAItemFileLinkDTO, ItemFileLink>(new List <Filter>() { new Filter("ParentId", docIds), new Filter("ParentTypeId", SmartCoreType.Document.ItemId) }, false); foreach (var document in _currentItem.EmployeeDocuments) { document.Parent = _currentItem; document.Files = new CommonCollection <ItemFileLink>(links.Where(i => i.ParentId == document.ItemId)); } } _currentItem.MedicalRecord = GlobalObjects.CaaEnvironment.NewLoader.GetObject <CAASpecialistMedicalRecordDTO, SpecialistMedicalRecord>(new Filter("SpecialistId", _currentItem.ItemId)); var types = new[] { SmartCoreType.SpecialistTraining.ItemId, SmartCoreType.SpecialistMedicalRecord.ItemId, SmartCoreType.SpecialistCAA.ItemId, SmartCoreType.SpecialistLicense.ItemId }; var documents = GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <CAADocumentDTO, SmartCore.Entities.General.Document>(new Filter("ParentTypeId", types), true); if (documents.Count > 0) { if (_currentItem.MedicalRecord != null) { var crs = GlobalObjects.CaaEnvironment.GetDictionary <DocumentSubType>().GetByFullName("Medical Records") as DocumentSubType; var personalTraining = documents.FirstOrDefault(d => d.ParentId == _currentItem.MedicalRecord.ItemId && d.ParentTypeId == SmartCoreType.SpecialistMedicalRecord.ItemId && d.DocumentSubType == crs); if (personalTraining != null) { _currentItem.MedicalRecord.Document = personalTraining; _currentItem.MedicalRecord.Document.Parent = _currentItem.MedicalRecord; } } foreach (var license in _currentItem.Licenses) { var crs = GlobalObjects.CaaEnvironment.GetDictionary <DocumentSubType>().GetByFullName("Personnel License") as DocumentSubType; var p = documents.FirstOrDefault(d => d.ParentId == license.ItemId && d.ParentTypeId == SmartCoreType.SpecialistLicense.ItemId && d.DocumentSubType == crs); if (p != null) { license.Document = p; license.Document.Parent = license; } foreach (var caa in license.CaaLicense) { var personalTraining = documents.FirstOrDefault(d => d.ParentId == caa.ItemId && d.ParentTypeId == SmartCoreType.SpecialistCAA.ItemId && d.DocumentSubType == crs); if (personalTraining != null) { caa.Document = personalTraining; caa.Document.Parent = caa; } } } foreach (var training in _currentItem.SpecialistTrainings) { var crs = GlobalObjects.CaaEnvironment.GetDictionary <DocumentSubType>().GetByFullName("Personnel Training") as DocumentSubType; var personalTraining = documents.FirstOrDefault(d => d.ParentId == training.ItemId && d.ParentTypeId == SmartCoreType.SpecialistTraining.ItemId && d.DocumentSubType == crs); if (personalTraining != null) { training.Document = personalTraining; training.Document.Parent = training; } } } _suppliers.Clear(); _suppliers.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <CAASupplierDTO, SmartCore.Purchase.Supplier>()); aircraftModels.Clear(); aircraftModels.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <CAAAccessoryDescriptionDTO, AircraftModel>(new Filter("ModelingObjectTypeId", 7))); foreach (var training in _currentItem.SpecialistTrainings) { if (training.AircraftTypeID > 0) { training.AircraftType = aircraftModels.FirstOrDefault(a => a.ItemId == training.AircraftTypeID); } } foreach (var license in _currentItem.Licenses) { if (license.AircraftTypeID > 0) { license.AircraftType = aircraftModels.FirstOrDefault(a => a.ItemId == license.AircraftTypeID); } } } catch (Exception ex) { Program.Provider.Logger.Log("Error while loading directives", ex); } if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion #region Калькуляция состояния директив AnimatedThreadWorker.ReportProgress(40, "calculation of directives"); if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion #region Фильтрация директив AnimatedThreadWorker.ReportProgress(70, "filter directives"); if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion #region Сравнение с рабочими пакетами AnimatedThreadWorker.ReportProgress(90, "comparison with the Work Packages"); if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion #region Training _initialDocumentArray.Clear(); var educations = new List <SmartCore.CAA.CAAEducation.CAAEducation>(); _records.Clear(); var occupation = GlobalObjects.CaaEnvironment?.GetDictionary <Occupation>().ToArray(); educations.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <EducationDTO, SmartCore.CAA.CAAEducation.CAAEducation>(new Filter("OperatorId", _opearatorId), loadChild: true)); _records.AddRange(GlobalObjects.CaaEnvironment.NewLoader .GetObjectListAll <EducationRecordsDTO, CAAEducationRecord>(new [] { new Filter("OperatorId", _opearatorId), new Filter("SpecialistId", _currentItem.ItemId), })); FillCollection(educations, _currentItem.Occupation, _currentItem, _records, false); foreach (Occupation dict in occupation) { if (_currentItem.Combination != null && _currentItem.Combination.Contains(dict.FullName)) { FillCollection(educations, dict, _currentItem, _records); } } var temp = new CommonCollection <CAAEducationManagment>(); if (_toDate.HasValue) { temp.AddRange(_initialDocumentArray.ToArray()); _initialDocumentArray.Clear(); foreach (var t in temp) { if (t.Record.Settings.NextCompliances != null && t.Record.Settings.NextCompliances.Any()) { foreach (var next in t.Record.Settings.NextCompliances) { var newItem = t.DeepClone(); newItem.Record.Settings.NextCompliance = next; _initialDocumentArray.Add(newItem); } } else { var newItem = t.DeepClone(); newItem.Record.Settings.NextCompliance = new NextCompliance(); _initialDocumentArray.Add(t); } } } #endregion AnimatedThreadWorker.ReportProgress(100, "Complete"); }