public override void FillControls() { hangarWorkPackageView.ViewedType = typeof(BaseEntityObject); _resultDirectiveArray.Clear(); _resultDirectiveArray.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackages(null, WorkPackageStatus.Published).ToArray()); comboBoxWorkPackage.Items.Clear(); IEnumerable <IGrouping <Aircraft, WorkPackage> > wpGroupByAircraft = _resultDirectiveArray.GroupBy(wp => wp.Aircraft); foreach (IGrouping <Aircraft, WorkPackage> groupByAircraft in wpGroupByAircraft) { foreach (WorkPackage workPackage in groupByAircraft) { comboBoxWorkPackage.Items.Add(workPackage); } } textBoxCustomer.Text = GlobalObjects.CasEnvironment.Operators[0].Name; extendableRichContainer.Caption = "Select Work Package:"; }
protected override async void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e) { _initial.Clear(); _result.Clear(); AnimatedThreadWorker.ReportProgress(0, "load Activities"); try { var activity = GlobalObjects.AuditContext.AuditCollection .FindSync(i => i.Date >= dateTimePickerDateFrom.Value && i.Date <= dateTimePickerDateTo.Value) .ToList(); var users = GlobalObjects.CasEnvironment.ApiProvider.GetAllUsersAsync(); foreach (var bsonElement in activity) { Enum.TryParse(bsonElement.Action, out AuditOperation myStatus); var userr = users.FirstOrDefault(i => i.ItemId == bsonElement.UserId); _initial.Add(new ActivityDTO() { Date = bsonElement.Date, User = userr != null ? new User(userr): new User() { Name = $"Deleted User with Id:{bsonElement.UserId}" }, Operation = myStatus, ObjectId = bsonElement.ObjectId, Type = SmartCoreType.GetSmartCoreTypeById(bsonElement.ObjectTypeId), Information = bsonElement.AdditionalParameters?.Count > 0 ? string.Join(",", bsonElement.AdditionalParameters.Select(i => i.Value.ToString())) : "" }); } AnimatedThreadWorker.ReportProgress(50, "load Parents"); foreach (var obj in _initial.GroupBy(i => i.Type?.ItemId)) { if (obj.Key == SmartCoreType.WorkPackage.ItemId) { var ids = obj.Select(i => i.ObjectId); var wps = GlobalObjects.CasEnvironment.NewLoader.GetObjectList <WorkPackageDTO, WorkPackage>(new Filter("ItemId", ids), getDeleted: true); foreach (var dto in obj) { var wp = wps.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (wp == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(wp.ParentId); dto.Title = wp.Title; } } else if (obj.Key == SmartCoreType.WorkPackageRecord.ItemId) { var ids = obj.Select(i => i.ObjectId); var wpr = GlobalObjects.CasEnvironment.NewLoader.GetObjectList <WorkPackageRecordDTO, WorkPackageRecord>(new Filter("ItemId", ids), getDeleted: true); var wpIds = wpr.Select(i => i.WorkPakageId); var wps = GlobalObjects.CasEnvironment.NewLoader.GetObjectList <WorkPackageDTO, WorkPackage>(new Filter("ItemId", wpIds), getDeleted: true); foreach (var dto in obj) { var wp = wps.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (wp == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(wp.ParentId); dto.Title = wp.Title; } } else if (obj.Key == SmartCoreType.MaintenanceDirective.ItemId) { var ids = obj.Select(i => i.ObjectId); var mpds = GlobalObjects.CasEnvironment.Loader.GetObjectList <MaintenanceDirective>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); foreach (var dto in obj) { var mpd = mpds.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (mpd == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(mpd.ParentBaseComponent.ParentAircraftId); dto.Title = mpd.Title; } } else if (obj.Key == SmartCoreType.Directive.ItemId) { var ids = obj.Select(i => i.ObjectId); var directives = GlobalObjects.CasEnvironment.Loader.GetObjectList <Directive>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); foreach (var dto in obj) { var directive = directives.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (directive == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(directive.ParentBaseComponent.ParentAircraftId); dto.Title = directive.Title; } } else if (obj.Key == SmartCoreType.DirectiveRecord.ItemId) { var ids = obj.Select(i => i.ObjectId); var directiveRecords = GlobalObjects.CasEnvironment.Loader.GetObjectList <DirectiveRecord>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); var directiveIds = directiveRecords.Select(i => i.ParentId); var directives = GlobalObjects.CasEnvironment.Loader.GetObjectList <Directive>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, directiveIds.ToArray()), getDeleted: true); foreach (var dto in obj) { var directive = directives.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (directive == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(directive.ParentBaseComponent.ParentAircraftId); dto.Title = directive.Title; } } else if (obj.Key == SmartCoreType.BaseComponent.ItemId) { var ids = obj.Select(i => i.ObjectId); var baseComponents = GlobalObjects.CasEnvironment.Loader.GetObjectList <BaseComponent>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); foreach (var dto in obj) { var baseComponent = baseComponents.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (baseComponent == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(baseComponent.ParentAircraftId); dto.Title = baseComponent.SerialNumber; } } else if (obj.Key == SmartCoreType.Component.ItemId) { var ids = obj.Select(i => i.ObjectId); var components = GlobalObjects.CasEnvironment.Loader.GetObjectList <SmartCore.Entities.General.Accessory.Component>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); foreach (var dto in obj) { var component = components.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (component == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(component.ParentAircraftId); dto.Title = component.SerialNumber; } } else if (obj.Key == SmartCoreType.ComponentDirective.ItemId) { var ids = obj.Select(i => i.ObjectId); var componentDirectives = GlobalObjects.CasEnvironment.Loader.GetObjectList <ComponentDirective>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); var componentIds = componentDirectives.Select(i => i.ComponentId); var components = GlobalObjects.CasEnvironment.Loader.GetObjectList <SmartCore.Entities.General.Accessory.Component>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, componentIds.ToArray()), getDeleted: true); foreach (var dto in obj) { var component = components.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (component == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(component.ParentAircraftId); dto.Title = component.SerialNumber; } } else if (obj.Key == SmartCoreType.AircraftFlight.ItemId) { var ids = obj.Select(i => i.ObjectId); var flights = GlobalObjects.CasEnvironment.Loader.GetObjectList <AircraftFlight>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); foreach (var dto in obj) { var flight = flights.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (flight == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(flight.AircraftId); dto.Title = flight.ToString(); } } else if (obj.Key == SmartCoreType.Discrepancy.ItemId) { var ids = obj.Select(i => i.ObjectId); var discrepancies = GlobalObjects.CasEnvironment.Loader.GetObjectList <Discrepancy>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), getDeleted: true); var flIds = discrepancies.Select(i => i.FlightId); var flights = GlobalObjects.CasEnvironment.Loader.GetObjectList <AircraftFlight>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, flIds.ToArray()), getDeleted: true); foreach (var dto in obj) { var flight = flights.FirstOrDefault(i => i.ItemId == dto.ObjectId); if (flight == null) { continue; } dto.Aircraft = GlobalObjects.AircraftsCore.GetAircraftById(flight.AircraftId); dto.Title = flight.ToString(); } } } } catch (Exception ex) { Program.Provider.Logger.Log("Error while load documents", ex); } AnimatedThreadWorker.ReportProgress(70, "filter documents"); FilterItems(_initial, _result); AnimatedThreadWorker.ReportProgress(100, "Complete"); }