예제 #1
0
        protected virtual void AddListViewItem(NextPerformance np)
        {
            string[] subs =
                new[]
            {
                np.WorkType,
                np.PerformanceDate != null
                                                ? SmartCore.Auxiliary.Convert.GetDateFormat(np.PerformanceDate)
                                                : "N/A",
                np.PerformanceSource.ToString(),
                np.PerformanceSourceC.ToString(),
                np?.NextLimit.Days != null?SmartCore.Auxiliary.Convert.GetDateFormat(np?.NextPerformanceDateNew) : "",
                    np.NextLimit.ToString(),
                    np.NextLimitC.ToString(),
                    "",
            };

            ListViewItem newItem = new ListViewItem(subs)
            {
                BackColor = UsefulMethods.GetColor(np),
                Group     = listViewCompliance.Groups[0],
                Tag       = np,
            };

            listViewCompliance.Items.Add(newItem);
        }
        protected override void AddListViewItem(NextPerformance np)
        {
            string[] subs =
                new[]
            {
                np.WorkType,
                np.PerformanceDate != null
                        ? SmartCore.Auxiliary.Convert.GetDateFormat(np.PerformanceDate)
                        : "N/A",
                np.PerformanceSource.ToString(),
                np?.NextLimit.Days != null?SmartCore.Auxiliary.Convert.GetDateFormat(np?.NextPerformanceDateNew) : "",
                    np.NextLimit.ToString(),
                    "",
            };

            ListViewItem newItem = new ListViewItem(subs)
            {
                Group = listViewCompliance.Groups[0],
                Tag   = np,
            };

            newItem.BackColor = _currentDirective.MaintenanceCheck != null
                ? Color.FromArgb(Highlight.Grey.Color)
                : UsefulMethods.GetColor(np);

            listViewCompliance.Items.Add(newItem);
        }
예제 #3
0
        protected override void AddListViewItem(NextPerformance np)
        {
            Directive d = np.Parent as Directive;

            string[] subs =
                new[]
            {
                np.WorkType + (d == null ? "" : " §:" + d.Paragraph),
                np.PerformanceDate != null
                            ? SmartCore.Auxiliary.Convert.GetDateFormat(np.PerformanceDate)
                            : "N/A",
                np.PerformanceSource.ToString(),
                np?.NextLimit.Days != null?SmartCore.Auxiliary.Convert.GetDateFormat(np?.NextPerformanceDateNew) : "",
                    np.NextLimit.ToString(),
                    "",
            };

            ListViewItem newItem = new ListViewItem(subs)
            {
                BackColor = UsefulMethods.GetColor(np),
                Group     = listViewCompliance.Groups[0],
                Tag       = np,
            };

            listViewCompliance.Items.Add(newItem);
        }
예제 #4
0
        protected override void SetItemColor(ListViewItem listViewItem, BaseEntityObject item)
        {
            if (item is ComponentDirective)
            {
                listViewItem.ForeColor = Color.Gray;

                ComponentDirective dd = item as ComponentDirective;
                listViewItem.BackColor = dd.ItemRelations.Count > 0
                    ? Color.FromArgb(Highlight.Grey.Color)
                    : UsefulMethods.GetColor(item);
            }
            if (item is Component)
            {
                listViewItem.ForeColor = Color.Black;
                listViewItem.BackColor = UsefulMethods.GetColor(item);
            }
            if (item.IsDeleted)
            {
                //запись так же может быть удаленной

                //шрифт серым цветом
                listViewItem.ForeColor = Color.Gray;
                if (listViewItem.ToolTipText.Trim() != "")
                {
                    listViewItem.ToolTipText += "\n";
                }
                listViewItem.ToolTipText += $"This {item.SmartCoreObjectType} is deleted";
            }
        }
예제 #5
0
 protected override void SetItemColor(GridViewRowInfo listViewItem, FlightPlanOpsRecords item)
 {
     foreach (GridViewCellInfo cell in listViewItem.Cells)
     {
         cell.Style.CustomizeFill = true;
         cell.Style.BackColor     = UsefulMethods.GetColor(item);
     }
 }
예제 #6
0
        protected override void SetItemColor(GridViewRowInfo listViewItem, MaintenanceDirective item)
        {
            var itemBackColor = UsefulMethods.GetColor(item);
            var itemForeColor = Color.Black;

            foreach (GridViewCellInfo cell in listViewItem.Cells)
            {
                cell.Style.DrawFill      = true;
                cell.Style.CustomizeFill = true;
                var listViewForeColor = cell.Style.ForeColor;

                if (listViewForeColor != Color.MediumVioletRed)
                {
                    cell.Style.ForeColor = itemForeColor;
                }

                cell.Style.BackColor = itemBackColor;
            }
        }
예제 #7
0
        protected override void SetItemColor(GridViewRowInfo listViewItem, CourseRecord item)
        {
            var itemBackColor = UsefulMethods.GetColor(item);
            var itemForeColor = Color.Gray;

            foreach (GridViewCellInfo cell in listViewItem.Cells)
            {
                cell.Style.DrawFill      = true;
                cell.Style.CustomizeFill = true;
                cell.Style.BackColor     = UsefulMethods.GetColor(item.Parent);

                var listViewForeColor = cell.Style.ForeColor;

                if (listViewForeColor != Color.MediumVioletRed)
                {
                    cell.Style.ForeColor = itemForeColor;
                }
                cell.Style.BackColor = itemBackColor;
            }
        }
예제 #8
0
 protected override void SetItemColor(GridViewRowInfo listViewItem, BaseEntityObject item)
 {
     if (item is ComponentDirective)
     {
         foreach (GridViewCellInfo cell in listViewItem.Cells)
         {
             cell.Style.CustomizeFill = true;
             cell.Style.ForeColor     = Color.Gray;
             cell.Style.BackColor     = UsefulMethods.GetColor(item);
         }
     }
     if (item is Component)
     {
         foreach (GridViewCellInfo cell in listViewItem.Cells)
         {
             cell.Style.CustomizeFill = true;
             cell.Style.ForeColor     = Color.Black;
             cell.Style.BackColor     = UsefulMethods.GetColor(item);
         }
     }
 }
예제 #9
0
 protected override void SetItemColor(GridViewRowInfo listViewItem, IBaseEntityObject item)
 {
     if (item is SupplierPrice)
     {
         foreach (GridViewCellInfo cell in listViewItem.Cells)
         {
             cell.Style.CustomizeFill = true;
             cell.Style.ForeColor     = Color.Gray;
             cell.Style.BackColor     = UsefulMethods.GetColor(item);
         }
     }
     if (item is RequestForQuotationRecord)
     {
         foreach (GridViewCellInfo cell in listViewItem.Cells)
         {
             cell.Style.CustomizeFill = true;
             cell.Style.ForeColor     = Color.Black;
             cell.Style.BackColor     = UsefulMethods.GetColor(item);
         }
     }
 }
예제 #10
0
        public void UpdateControl(List <MTOPCheck> maintenanceChecks, List <MTOPCheck> maintenanceChecksDeleted,
                                  Aircraft currentAircraft, AverageUtilization averageUtilization)
        {
            _averageUtilization = averageUtilization;
            _currentAircraft    = currentAircraft;
            listViewCompliance.Items.Clear();

            ListViewItem newItem;

            string[] subs;

            var mtopCheckRecords = new List <MTOPCheckRecord>();

            mtopCheckRecords.AddRange(maintenanceChecksDeleted.SelectMany(i => i.PerformanceRecords));
            mtopCheckRecords.AddRange(maintenanceChecks.SelectMany(i => i.PerformanceRecords));

            var nps = maintenanceChecks.SelectMany(i => i.NextPerformances);

            foreach (var np in nps.OrderByDescending(i => i.PerformanceSource.Days))
            {
                string perfDate = "";
                if (np.PerformanceDate.HasValue)
                {
                    perfDate = UsefulMethods.NormalizeDate(np.PerformanceDate.Value);
                }

                var group = np.ParentCheck.IsZeroPhase ? $"0{np.Group}" : np.Group.ToString();


                subs = new[]  {
                    group,
                    np.ParentCheck.Name,
                    perfDate,
                    np.PerformanceSource.ToRepeatIntervalsFormat(),
                    $"HRS/DAY: {Math.Round(np.ParentCheck.AverageUtilization.Hours, 2)} CYC/DAY: {Math.Round((double) (np.ParentCheck?.AverageUtilization?.Hours / np.ParentCheck.AverageUtilization?.CyclesPerDay), 2)}",
                    ""
                };

                newItem = new ListViewItem(subs)
                {
                    Group     = listViewCompliance.Groups["next"],
                    Tag       = np,
                    BackColor = UsefulMethods.GetColor(np)
                };

                listViewCompliance.Items.Add(newItem);
            }

            foreach (var record in mtopCheckRecords.OrderByDescending(i => i.CalculatedPerformanceSource.Days))
            {
                var group = record.Parent.IsZeroPhase ? $"0{record.GroupName}" : record.GroupName.ToString();

                subs = new[]  {
                    group,
                    record.CheckName,
                    UsefulMethods.NormalizeDate(record.RecordDate),
                    record.CalculatedPerformanceSource.ToRepeatIntervalsFormat(),
                    record.AverageUtilization != null ? $"HRS/DAY: {Math.Round(record.AverageUtilization.Hours, 2)} CYC/DAY: {Math.Round((double) (record.AverageUtilization?.Hours / record.AverageUtilization?.CyclesPerDay), 2)}" : "",
                    record.Remarks
                };

                newItem = new ListViewItem(subs)
                {
                    Group = listViewCompliance.Groups["last"],
                    Tag   = record
                };

                listViewCompliance.Items.Add(newItem);
            }
        }
예제 #11
0
        private void UpdateInformation()
        {
            if (_contextMenuStrip == null)
            {
                InitToolStripMenuItems();
            }

            listViewCompliance.Items.Clear();

            if (CheckItems == null)
            {
                return;
            }

            var lastRecords      = new List <MaintenanceCheckRecord>();
            var nextPerformances = new List <NextPerformance>();

            //Поиск и заполнение просроченных директив и записей о перемещении
            //Объекты для в которые будет извлекаться информация
            //из записеи о перемещении

            string[]     subs;
            ListViewItem newItem;

            var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(_currentAircraft.AircraftFrameId);
            //прогнозируемый ресурс
            var forecastData = new ForecastData(DateTime.Now, aircraftFrame.AverageUtilization,
                                                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentAircraft));

            //GlobalObjects.CasEnvironment.Calculator.GetNextPerformanceGroup(CheckItems, _currentAircraft.Schedule, forecastData);

            foreach (MaintenanceCheck check in CheckItems)
            {
                if (check.Grouping)
                {
                    foreach (MaintenanceNextPerformance mnp in check.GetPergormanceGroupWhereCheckIsSenior())
                    {
                        //Добавляются все выполнения, дата которых меньше нынешней
                        //плюс еще одно выполнение дата которого выше нынешней
                        nextPerformances.Add(mnp);

                        if (mnp.PerformanceDate != null && mnp.PerformanceDate > DateTime.Now)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    foreach (NextPerformance mnp in check.NextPerformances)
                    {
                        //Добавляются все выполнения, дата которых меньше нынешней
                        //плюс еще одно выполнение дата которого выше нынешней
                        nextPerformances.Add(mnp);

                        if (mnp.PerformanceDate != null && mnp.PerformanceDate > DateTime.Now)
                        {
                            break;
                        }
                    }
                }

                lastRecords.AddRange(check.PerformanceRecords.ToArray());

                foreach (MaintenanceDirective mpd in check.BindMpds)
                {
                    GlobalObjects.PerformanceCalculator.GetNextPerformance(mpd, forecastData);
                }
            }
            ////////////////////////////////////////////
            //загрузка рабочих пакетов для определения
            //перекрытых ими выполнений задач
            if (_openPubWorkPackages == null)
            {
                _openPubWorkPackages = new CommonCollection <WorkPackage>();
            }
            _openPubWorkPackages.Clear();
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.Opened));
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.Published));

            var allWorkPackagesIncludedTask = new CommonCollection <WorkPackage>();
            var openPubWorkPackages         = new CommonCollection <WorkPackage>();
            var closedWorkPackages          = new CommonCollection <WorkPackage>();

            allWorkPackagesIncludedTask.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft,
                                                                                                   WorkPackageStatus.All,
                                                                                                   CheckItems.Select(m => (IDirective)m).ToList()));

            #region Добавление в список просроченных выполнений
            //и сравнение их с открытыми и опубликованными рабочими пакетами
            openPubWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Opened ||
                                                                           wp.Status == WorkPackageStatus.Published));
            //сбор всех записей рабочих пакетов для удобства фильтрации
            List <WorkPackageRecord> openPubWPRecords = new List <WorkPackageRecord>();
            foreach (WorkPackage openWorkPackage in openPubWorkPackages)
            {
                openPubWPRecords.AddRange(openWorkPackage.WorkPakageRecords);
            }

            //LINQ запрос для сортировки записей по дате
            List <NextPerformance> sortNextRecords = (from record in nextPerformances
                                                      orderby record.GetPerformanceDateOrDefault() descending
                                                      select record).ToList();

            for (int i = 0; i < sortNextRecords.Count; i++)
            {
                //поиск записи в рабочих пакетах по данному чеку
                //чей номер группы выполнения (по записи) совпадает с расчитанным
                MaintenanceCheck check = (MaintenanceCheck)sortNextRecords[i].Parent;

                //if (check.Name == "5C")
                //{

                //}
                //номер выполнения
                int parentCountPerf;
                if (check.LastPerformance != null)
                {
                    parentCountPerf = check.LastPerformance.NumGroup <= 0
                        ? 1
                        : check.LastPerformance.NumGroup;
                }
                else
                {
                    parentCountPerf = 0;
                }

                if (check.Grouping)
                {
                    MaintenanceNextPerformance mnp = sortNextRecords[i] as MaintenanceNextPerformance;
                    if (mnp != null)
                    {
                        parentCountPerf = mnp.PerformanceGroupNum;
                    }
                    else
                    {
                        parentCountPerf += check.NextPerformances.IndexOf(sortNextRecords[i]);
                        parentCountPerf += 1;
                    }
                }
                else
                {
                    parentCountPerf += check.NextPerformances.IndexOf(sortNextRecords[i]);
                    parentCountPerf += 1;
                }

                WorkPackageRecord wpr =
                    openPubWPRecords.Where(r => r.PerformanceNumFromStart == parentCountPerf &&
                                           r.WorkPackageItemType == check.SmartCoreObjectType.ItemId &&
                                           r.DirectiveId == check.ItemId).FirstOrDefault();
                if (wpr != null)
                {
                    WorkPackage wp = openPubWorkPackages.GetItemById(wpr.WorkPakageId);
                    //запись о выполнении блокируется найденым пакетом
                    sortNextRecords[i].BlockedByPackage = wp;
                    //последующие записи о выполнении так же должны быть заблокированы
                    for (int j = i - 1; j >= 0; j--)
                    {
                        //блокировать нужно все рабочие записи, или до первой записи,
                        //заблокированной другим рабочим пакетом
                        if (sortNextRecords[j].BlockedByPackage != null &&
                            sortNextRecords[j].Parent == check ||
                            sortNextRecords[j].Condition != ConditionState.Overdue)
                        {
                            break;
                        }
                        if (sortNextRecords[j].Parent == check)
                        {
                            sortNextRecords[j].BlockedByPackage   = wp;
                            listViewCompliance.Items[j].BackColor = Color.FromArgb(Highlight.GrayLight.Color);
                        }
                    }
                }

                string type        = check.Schedule ? " (Schedule) " : " (Store) ";
                string resource    = check.Resource.ToString();
                string grouping    = check.Grouping ? " (Group)" : "";
                string stringNumGr = (sortNextRecords[i] is MaintenanceNextPerformance
                    ? ((MaintenanceNextPerformance)sortNextRecords[i]).PerformanceGroupNum.ToString()
                    : "N/A") + type + resource + grouping;

                subs = new[]  {
                    stringNumGr,
                    sortNextRecords[i].Title,
                    sortNextRecords[i].PerformanceDate != null
                                       ? UsefulMethods.NormalizeDate((DateTime)sortNextRecords[i].PerformanceDate)
                                       : "N/A",
                    sortNextRecords[i].PerformanceSource.ToString(),
                    "",
                };
                newItem = new ListViewItem(subs)
                {
                    Group     = listViewCompliance.Groups["next"],
                    Tag       = sortNextRecords[i],
                    BackColor = UsefulMethods.GetColor(sortNextRecords[i])
                };

                listViewCompliance.Items.Add(newItem);
            }
            #endregion

            #region Добавление в список записей о произведенных выполнениях
            //и сравнение их с закрытыми рабочими пакетами
            closedWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Closed));
            //сбор всех записей рабочих пакетов для удобства фильтрации
            List <WorkPackageRecord> closedWPRecords = new List <WorkPackageRecord>();
            foreach (WorkPackage closedWorkPackage in closedWorkPackages)
            {
                closedWPRecords.AddRange(closedWorkPackage.WorkPakageRecords);
            }

            List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>();

            foreach (MaintenanceCheckRecord record in lastRecords)
            {
                //Поиск коллекции групп, в которую входят группы с нужными критериями
                //по плану, группировка и основному ресурсу
                if (record.ParentCheck.Grouping)
                {
                    MaintenanceCheckRecordGroup recordGroup = maintenanceCheckRecordGroups
                                                              .FirstOrDefault(g => g.Schedule == record.ParentCheck.Schedule &&
                                                                              g.Grouping == record.ParentCheck.Grouping &&
                                                                              g.Resource == record.ParentCheck.Resource &&
                                                                              g.GroupComplianceNum == record.NumGroup);
                    if (recordGroup != null)
                    {
                        //Коллекция найдена
                        //Поиск в ней группы чеков с нужным типом
                        recordGroup.Records.Add(record);
                    }
                    else
                    {
                        //Коллекции с нужными критериями нет
                        //Созадние и добавление
                        recordGroup =
                            new MaintenanceCheckRecordGroup(record.ParentCheck.Schedule, record.ParentCheck.Grouping,
                                                            record.ParentCheck.Resource, record.NumGroup);
                        recordGroup.Records.Add(record);
                        maintenanceCheckRecordGroups.Add(recordGroup);
                    }
                }
                else
                {
                    MaintenanceCheckRecordGroup recordGroup =
                        new MaintenanceCheckRecordGroup(record.ParentCheck.Schedule, record.ParentCheck.Grouping,
                                                        record.ParentCheck.Resource);
                    recordGroup.Records.Add(record);
                    maintenanceCheckRecordGroups.Add(recordGroup);
                }
            }

            List <object> tempRecords = new List <object>();
            tempRecords.AddRange(maintenanceCheckRecordGroups.ToArray());
            tempRecords.AddRange(_currentAircraft.MaintenanceProgramChangeRecords.ToArray());

            List <object> sortLastRecords =
                tempRecords.OrderByDescending(tr => (tr is MaintenanceCheckRecordGroup
                                                        ? ((MaintenanceCheckRecordGroup)tr).LastGroupComplianceDate
                                                        : tr is AbstractRecord
                                                            ? ((AbstractRecord)tr).RecordDate
                                                            : DateTimeExtend.GetCASMinDateTime()))
                .ToList();
            foreach (object t in sortLastRecords)
            {
                if (t is MaintenanceCheckRecordGroup)
                {
                    MaintenanceCheckRecordGroup mcrg            = (MaintenanceCheckRecordGroup)t;
                    MaintenanceCheckRecord      directiveRecord = mcrg.Records.First();
                    MaintenanceCheck            parentDirective = (MaintenanceCheck)directiveRecord.Parent;
                    newItem = GetListViewItem(mcrg);

                    WorkPackage workPackage =
                        closedWorkPackages.Where(wp => wp.ItemId == directiveRecord.DirectivePackageId).FirstOrDefault();
                    if (workPackage != null)
                    {
                        //запись о выполнении блокируется найденым пакетом
                        directiveRecord.DirectivePackage = workPackage;
                        newItem.BackColor   = Color.FromArgb(Highlight.Grey.Color);
                        newItem.ToolTipText =
                            "Perform of the task:" + parentDirective.Name +
                            "\nadded by Work Package:" +
                            "\n" + directiveRecord.DirectivePackage.Title +
                            "\nTo remove a performance of task, you need to exclude task from this work package," +
                            "\nor delete the work package ";
                    }
                    listViewCompliance.Items.Add(newItem);
                }
                else if (t is MaintenanceProgramChangeRecord)
                {
                    MaintenanceProgramChangeRecord mpcr = (MaintenanceProgramChangeRecord)t;
                    subs = new[]
                    {
                        "N/A",
                        "Changet to " + mpcr.MSG,
                        UsefulMethods.NormalizeDate(mpcr.RecordDate),
                        mpcr.OnLifelength.ToString(),
                        "",
                    };
                    newItem = new ListViewItem(subs)
                    {
                        Group     = listViewCompliance.Groups["last"],
                        Tag       = mpcr,
                        BackColor = Color.FromArgb(Highlight.GrayLight.Color)
                    };

                    listViewCompliance.Items.Add(newItem);
                }
            }
            #endregion

            if (_toolStripMenuItemsWorkPackages != null)
            {
                foreach (ToolStripMenuItem item in _toolStripMenuItemsWorkPackages.DropDownItems)
                {
                    item.Click -= AddToWorkPackageItemClick;
                }

                _toolStripMenuItemsWorkPackages.DropDownItems.Clear();

                foreach (WorkPackage workPackage in _openPubWorkPackages)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem(workPackage.Title);
                    item.Click += AddToWorkPackageItemClick;
                    item.Tag    = workPackage;
                    _toolStripMenuItemsWorkPackages.DropDownItems.Add(item);
                }
            }

            ButtonAdd.Enabled = false;
        }