Example #1
0
        ///<summary>
        ///обновление информации в контроле
        ///</summary>
        private void UpdateInformation()
        {
            if (_currentAircraft == null)
            {
                return;
            }

            var list = GlobalObjects.CasEnvironment.GetDictionary <LLPLifeLimitCategory>()
                       .OfType <LLPLifeLimitCategory>()
                       .Where(llp => llp.AircraftModel?.ItemId == _currentAircraft.Model?.ItemId)
                       .ToList();

            if (list.Count == 0)
            {
                var a = new LLPLifeLimitCategory(LLPLifeLimitCategoryType.A, "", _currentAircraft.Model);
                var b = new LLPLifeLimitCategory(LLPLifeLimitCategoryType.B, "", _currentAircraft.Model);
                var c = new LLPLifeLimitCategory(LLPLifeLimitCategoryType.C, "", _currentAircraft.Model);
                var d = new LLPLifeLimitCategory(LLPLifeLimitCategoryType.D, "", _currentAircraft.Model);
                list = new List <LLPLifeLimitCategory>(new[] { a, b, c, d });
            }
            //LINQ запрос для сортировки записей по дате;
            var sortrecords = (from record in list
                               orderby GetChar(record) ascending
                               select record).ToList();

            foreach (var llc in sortrecords)
            {
                var newKitControl = new LifeLimitCategoriesFormItem(llc);
                _llItems.Add(newKitControl);
                flowLayoutPanelCharts.Controls.Add(newKitControl);
            }
        }
 /// <summary>
 /// Конструктор создает объект с параметрами по умолчанию
 /// </summary>
 public ComponentLLPCategoryData(ComponentLLPCategoryData copyData) : this()
 {
     ComponentId    = copyData.ComponentId;
     ParentCategory = copyData.ParentCategory;
     LLPLifelength  = new Lifelength(copyData.LLPLifelength);
     LLPLifeLimit   = new Lifelength(copyData.LLPLifeLimit);
     Notify         = new Lifelength(copyData.Notify);
     Remain         = new Lifelength(copyData.Remain);
     ParentCategory = copyData.ParentCategory;
 }
 /// <summary>
 /// Конструктор создает объект с параметрами по умолчанию
 /// </summary>
 public ComponentLLPCategoryData()
 {
     ItemId              = -1;
     ComponentId         = -1;
     ParentCategory      = LLPLifeLimitCategory.Unknown;
     LLPLifeLimit        = Lifelength.Null;
     LLPLifelength       = Lifelength.Null;
     Notify              = Lifelength.Null;
     SmartCoreObjectType = SmartCoreType.ComponentLLPCategoryData;
 }
Example #4
0
 public static LifeLimitCategorieDTO Convert(this LLPLifeLimitCategory lifelimitcategorie)
 {
     return(new LifeLimitCategorieDTO
     {
         ItemId = lifelimitcategorie.ItemId,
         IsDeleted = lifelimitcategorie.IsDeleted,
         Updated = lifelimitcategorie.Updated,
         CorrectorId = lifelimitcategorie.CorrectorId,
         CategoryType = lifelimitcategorie.CategoryType.ItemId.ToString(),
         CategoryName = lifelimitcategorie.Category,
         AircraftModelId = lifelimitcategorie.AircraftModel?.ItemId,
         AccessoryDescription = lifelimitcategorie.AircraftModel?.Convert()
     });
 }
Example #5
0
        ///<summary>
        ///</summary>
        public ComponentLifeLimitControlItem(ComponentLLPCategoryData llpData, bool mainLimit) : this()
        {
            lifelengthViewerLifeLimit.EnabledHours    = false;
            lifelengthViewerLifeLimit.EnabledCalendar = false;
            lifelengthViewerNotify.EnabledHours       = false;
            lifelengthViewerNotify.EnabledCalendar    = false;
            lifelengthViewerRemain.EnabledHours       = false;
            lifelengthViewerRemain.EnabledCalendar    = false;

            _currentCategory = llpData.ParentCategory;
            _llpData         = llpData;
            _limit           = llpData.LLPLifeLimit;
            _remain          = llpData.Remain;
            _mainLimit       = mainLimit;
            UpdateContol();
            UpdateInformation();
        }
Example #6
0
 ///<summary>
 /// возвращает первую букву из типа категории
 ///</summary>
 ///<param name="lifelimitCategory"></param>
 ///<returns></returns>
 public char GetChar(LLPLifeLimitCategory lifelimitCategory)
 {
     return(lifelimitCategory.GetChar());
 }
Example #7
0
 ///<summary>
 /// Конструктор, принимающий KIT для отображения
 ///</summary>
 public LifeLimitCategoriesFormItem(LLPLifeLimitCategory category)
 {
     _currentCategory = category;
     InitializeComponent();
     UpdateInformation();
 }
Example #8
0
        protected override void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            backgroundWorker.ReportProgress(50);

            try
            {
                Invoke(new Action(() => listViewCompliance.Items.Clear()));
            }
            catch (Exception)
            {
            }

            if (_currentComponent == null)
            {
                e.Cancel = true;
                return;
            }
            var parentAircraft   = GlobalObjects.AircraftsCore.GetParentAircraft(_currentComponent);
            var lastRecords      = new List <AbstractRecord>();
            var nextPerformances = new List <NextPerformance>();

            var allWorkPackagesIncludedTask     = new CommonCollection <WorkPackage>();
            var openPubWorkPackagesIncludedTask = new CommonCollection <WorkPackage>();
            var closedWorkPackages           = new CommonCollection <WorkPackage>();
            var taskThatIncludeInWorkPackage = new List <IDirective>();

            lastRecords.AddRange(_currentComponent.TransferRecords.ToArray());
            lastRecords.AddRange(_currentComponent.ChangeLLPCategoryRecords.ToArray());
            lastRecords.AddRange(_currentComponent.ActualStateRecords.ToArray());

            //Объекты для в котороые будет извлекаться информация
            //из записеи о перемещении
            var lastDestination = "";
            //прогнозируемый ресурс
            //если известна родительская деталь данной директивы,
            //то ее текущая наработка и средняя утилизация
            //используются в качестве ресурсов прогноза
            //для расчета всех просроченных выполнений
            var forecastData = new ForecastData(DateTime.Now,
                                                GlobalObjects.AverageUtilizationCore.GetAverageUtillization(_currentComponent),
                                                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentComponent));

            foreach (var directive in _currentComponent.ComponentDirectives)
            {
                if (directive.IsAffect().GetValueOrDefault(true))
                {
                    //расчет след. выполнений директивы.
                    //если известен ресурс прогноза, то будут расчитаны все просрочнные выполнения
                    //если неизвестне, то только первое
                    //GlobalObjects.PerformanceCalculator.GetNextPerformance(directive, forecastData);
                    nextPerformances.AddRange(directive.NextPerformances);
                    lastRecords.AddRange(directive.PerformanceRecords.ToArray());

                    if (backgroundWorker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                    taskThatIncludeInWorkPackage.Add(directive);
                }
                else
                {
                    var bindedItems = GlobalObjects.BindedItemsCore.GetBindedItemsFor(parentAircraft.ItemId, directive);
                    foreach (var bindedItem in bindedItems)
                    {
                        if (bindedItem is MaintenanceDirective)
                        {
                            var mpd = (MaintenanceDirective)bindedItem;
                            //прогнозируемый ресурс
                            //если известна родительская деталь данной директивы,
                            //то ее текущая наработка и средняя утилизация
                            //используются в качестве ресурсов прогноза
                            //для расчета всех просроченных выполнений
                            //расчет след. выполнений директивы.
                            //если известен ресурс прогноза, то будут расчитаны все просрочнные выполнения
                            //если неизвестне, то только первое
                            GlobalObjects.PerformanceCalculator.GetNextPerformance(mpd, forecastData);
                            nextPerformances.AddRange(mpd.NextPerformances);
                            lastRecords.AddRange(mpd.PerformanceRecords.ToArray());

                            taskThatIncludeInWorkPackage.Add(mpd);
                        }
                    }
                }
            }

            //загрузка рабочих пакетов для определения
            //перекрытых ими выполнений задач
            if (_openPubWorkPackages == null)
            {
                _openPubWorkPackages = new CommonCollection <WorkPackage>();
            }
            _openPubWorkPackages.Clear();

            //загрузка рабочих пакетов для определения
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(parentAircraft, WorkPackageStatus.Opened));
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(parentAircraft, WorkPackageStatus.Published));

            allWorkPackagesIncludedTask.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(parentAircraft, WorkPackageStatus.All, taskThatIncludeInWorkPackage));

            #region Добавление в список просроченных выполнений

            //и сравнение их с открытыми и опубликованными рабочими пакетами
            openPubWorkPackagesIncludedTask.AddRange(
                allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Opened ||
                                                  wp.Status == WorkPackageStatus.Published));
            //сбор всех записей рабочих пакетов для удобства фильтрации
            var openPubWpRecords =
                openPubWorkPackagesIncludedTask.SelectMany(wp => wp.WorkPakageRecords).ToList();
            //LINQ запрос для сортировки записей по дате
            var sortNextRecords = (from record in nextPerformances
                                   orderby GetDate(record) descending
                                   select record).ToList();
            for (int i = 0; i < sortNextRecords.Count; i++)
            {
                if (backgroundWorker.CancellationPending)
                {
                    allWorkPackagesIncludedTask.Clear();
                    openPubWorkPackagesIncludedTask.Clear();
                    closedWorkPackages.Clear();

                    e.Cancel = true;
                    return;
                }

                //поиск записи в рабочих пакетах по данному чеку
                //чей номер группы выполнения (по записи) совпадает с расчитанным
                var parentDirective = sortNextRecords[i].Parent;
                //номер выполнения
                int parentCountPerf;
                if (parentDirective.LastPerformance != null)
                {
                    parentCountPerf = parentDirective.LastPerformance.PerformanceNum <= 0
                                                ? 1
                                                : parentDirective.LastPerformance.PerformanceNum;
                }
                else
                {
                    parentCountPerf = 0;
                }
                parentCountPerf += parentDirective.NextPerformances.IndexOf(sortNextRecords[i]);
                parentCountPerf += 1;

                var wpr = openPubWpRecords.FirstOrDefault(r => r.PerformanceNumFromStart == parentCountPerf &&
                                                          r.WorkPackageItemType == parentDirective.SmartCoreObjectType.ItemId &&
                                                          r.DirectiveId == parentDirective.ItemId);
                if (wpr != null)
                {
                    var wp = openPubWorkPackagesIncludedTask.GetItemById(wpr.WorkPakageId);
                    //запись о выполнении блокируется найденым пакетом
                    sortNextRecords[i].BlockedByPackage = wp;
                    //последующие записи о выполнении так же должны быть заблокированы
                    for (int j = i - 1; j >= 0; j--)
                    {
                        //блокировать нужно все рабочие записи, или до первой записи,
                        //заблокированной другим рабочим пакетом
                        if (sortNextRecords[j].BlockedByPackage != null ||
                            sortNextRecords[j].Condition != ConditionState.Overdue)
                        {
                            break;
                        }
                        if (sortNextRecords[j].Parent == parentDirective)
                        {
                            sortNextRecords[j].BlockedByPackage = wp;
                            Invoke(new Action <int, Color>(SetItemColor), j, Color.FromArgb(Highlight.GrayLight.Color));
                        }
                    }
                }
                Invoke(new Action <NextPerformance>(AddListViewItem), sortNextRecords[i]);
            }

            #endregion

            #region Добавление в список записей о произведенных выполнениях

            //и сравнение их с закрытыми рабочими пакетами
            closedWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Closed));

            //LINQ запрос для сортировки записей по дате
            var sortLastRecords = (from record in lastRecords
                                   orderby record.RecordDate ascending
                                   select record).ToList();

            var items = new List <KeyValuePair <AbstractRecord, string[]> >();

            for (int i = 0; i < sortLastRecords.Count; i++)
            {
                if (backgroundWorker.CancellationPending)
                {
                    allWorkPackagesIncludedTask.Clear();
                    openPubWorkPackagesIncludedTask.Clear();
                    closedWorkPackages.Clear();

                    e.Cancel = true;
                    return;
                }

                string[] subs;
                if (sortLastRecords[i] is DirectiveRecord)
                {
                    var directiveRecord = (DirectiveRecord)sortLastRecords[i];
                    subs = new[]
                    {
                        directiveRecord.WorkType,
                        UsefulMethods.NormalizeDate(directiveRecord.RecordDate),
                        directiveRecord.OnLifelength != null
                                                                        ? directiveRecord.OnLifelength.ToString()
                                                                        : "",
                        "",
                        "",
                        directiveRecord.Remarks
                    };
                }
                else if (sortLastRecords[i] is TransferRecord)
                {
                    TransferRecord transferRecord = (TransferRecord)sortLastRecords[i];

                    string currentDestination, destinationObject;
                    DestinationHelper.GetDestination(transferRecord, out currentDestination, out destinationObject);

                    subs = new[]
                    {
                        lastDestination != ""
                                                                        ? "Transfered " + destinationObject + " from " + lastDestination + " to " + currentDestination
                                                                        : "Transfered " + destinationObject + " to " + currentDestination,
                        UsefulMethods.NormalizeDate(transferRecord.TransferDate),
                        transferRecord.OnLifelength.ToString(),
                        "",
                        "",
                        transferRecord.Remarks,
                    };
                    lastDestination = currentDestination;
                }
                else if (sortLastRecords[i] is ComponentLLPCategoryChangeRecord)
                {
                    ComponentLLPCategoryChangeRecord llpRecord  = (ComponentLLPCategoryChangeRecord)sortLastRecords[i];
                    LLPLifeLimitCategory             toCategory = llpRecord.ToCategory;
                    subs = new[]
                    {
                        "Changed to " + toCategory,
                        UsefulMethods.NormalizeDate(llpRecord.RecordDate),
                        llpRecord.OnLifelength.ToString(),
                        "",
                        "",
                        llpRecord.Remarks,
                    };
                }
                else if (sortLastRecords[i] is ActualStateRecord)
                {
                    ActualStateRecord actualStateRecord = (ActualStateRecord)sortLastRecords[i];
                    subs = new[]
                    {
                        "Actual state:",
                        UsefulMethods.NormalizeDate(actualStateRecord.RecordDate.Date),
                        actualStateRecord.OnLifelength != null
                                                                        ? actualStateRecord.OnLifelength.ToString()
                                                                        : "",
                        "",
                        "",
                        actualStateRecord.Remarks,
                    };
                }
                else
                {
                    subs = new[]
                    {
                        "Unknown record ",
                        UsefulMethods.NormalizeDate(sortLastRecords[i].RecordDate),
                        sortLastRecords[i].OnLifelength.ToString(),
                        "",
                        "",
                        sortLastRecords[i].Remarks,
                    };
                }
                items.Add(new KeyValuePair <AbstractRecord, string[]>(sortLastRecords[i], subs));
            }

            #endregion

            for (int i = items.Count - 1; i >= 0; i--)
            {
                WorkPackage workPackage = null;
                if (items[i].Key is AbstractPerformanceRecord)
                {
                    var apr = items[i].Key as AbstractPerformanceRecord;
                    workPackage = closedWorkPackages.FirstOrDefault(wp => wp.ItemId == apr.DirectivePackageId);
                }
                Invoke(new Action <AbstractRecord, string[], WorkPackage>(AddListViewItem), items[i].Key, items[i].Value, workPackage);
            }

            allWorkPackagesIncludedTask.Clear();
            openPubWorkPackagesIncludedTask.Clear();
            closedWorkPackages.Clear();

            backgroundWorker.ReportProgress(100);
        }
Example #9
0
        /// <summary>
        /// Обновление информации ЭУ
        /// </summary>
        public void UpdateInformation()
        {
            fileControl.UpdateInfo(null, "Adobe PDF Files|*.pdf",
                                   "This record does not contain a file proving the compliance. Enclose PDF file to prove the compliance.",
                                   "Attached file proves the compliance.");

            if (_currentRecord == null)
            {
                return;
            }
            fileControl.AttachedFile = _currentRecord.AttachedFile;

            #region Обработка категорий для LLPCategoryComboBox
            List <LLPLifeLimitCategory> categories = null;
            var aircraft = GlobalObjects.AircraftsCore.GetAircraftById(_currentComponent.ParentAircraftId); //TODO:(Evgenii Babak) надо пересмотреть т.к из Aircraft тут используется только Model

            if (aircraft != null)                                                                           //деталь находится на самолете
            {
                var llps = GlobalObjects.CasEnvironment.GetDictionary <LLPLifeLimitCategory>();
                categories = llps
                             .OfType <LLPLifeLimitCategory>()
                             .Where(c => c.AircraftModel?.ItemId == aircraft.Model.ItemId)
                             .ToList();
            }
            else             //деталь на складу
            {
                LLPLifeLimitCategory current = _currentComponent.ChangeLLPCategoryRecords.GetLast().ToCategory;
                if (current != null)
                {
                    var llps = GlobalObjects.CasEnvironment.GetDictionary <LLPLifeLimitCategory>();
                    categories = llps
                                 .OfType <LLPLifeLimitCategory>()
                                 .Where(c => c.AircraftModel == current.AircraftModel)
                                 .ToList();
                }
            }
            if (categories != null && categories.Count > 0)
            {
                comboBoxCategories.Items.AddRange(categories.ToArray());
                comboBoxCategories.SelectedItem = _currentRecord.ToCategory;
            }
            #endregion

            textBox_Remarks.Text = _currentRecord.Remarks ?? "";

            //DateTime StartDate = new DateTime(1950, 1, 1);
            if (_currentRecord.RecordDate < DateTimeExtend.GetCASMinDateTime())
            {
                dateTimePicker1.Value = DateTime.Today;
            }
            else
            {
                dateTimePicker1.Value = _currentRecord.RecordDate;
            }

            if (_currentRecord.OnLifelength.IsNullOrZero())
            {
                if (_currentRecord.ParentComponent != null)
                {
                    lifelengthViewer_LastCompliance.Lifelength =
                        GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentRecord.ParentComponent);
                }
            }
            else
            {
                lifelengthViewer_LastCompliance.Lifelength = _currentRecord.OnLifelength;
            }
        }
 /// <summary>
 /// Возвращает директиву  с указанным номером, либо null если директива не был найден в коллекции
 /// </summary>
 /// <param name="llpLifeLimitCategory"></param>
 /// <returns></returns>
 public ComponentLLPCategoryData GetItemByCatagory(LLPLifeLimitCategory llpLifeLimitCategory)
 {
     return(Items.FirstOrDefault(llp => llp.ParentCategory.Category.ToLower().Trim().Equals(llpLifeLimitCategory.Category.ToLower().Trim())));
 }