コード例 #1
0
        /// <summary>
        /// This method update the comment for a specified check box
        /// </summary>
        /// <param name="id">check item id</param>
        /// <param name="comment">updated comment</param>
        public void UpdateCheckItemComment(int id, CommentViewModel comment)
        {
            var targetCheckItem = CheckItems.Where(c => c.Id == id).FirstOrDefault();

            if (targetCheckItem != null)
            {
                targetCheckItem.Comment = comment;
            }
        }
コード例 #2
0
        private void ButtonRegisterActualStateClick(object sender, EventArgs e)
        {
            List <MaintenanceCheckRecord> records =
                CheckItems.Where(c => c.Grouping)
                .SelectMany(c => c.PerformanceRecords)
                .ToList();
            List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>();

            foreach (MaintenanceCheckRecord record in records)
            {
                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);
                }
            }

            MaintenanceProgramChangeDialog actualStateDialog =
                new MaintenanceProgramChangeDialog(_currentAircraft, maintenanceCheckRecordGroups)
            {
                Text = "Add new Maintenance program change record"
            };

            actualStateDialog.ShowDialog();
            if (actualStateDialog.DialogResult == DialogResult.OK)
            {
                InvokeComplianceAdded(null);
            }
        }
コード例 #3
0
        private void FindNextCheck()
        {
            //вычисление самого последнего выполненного чека, вне зависимости от типа
            //последний выполненый чек по типу может нессответствовать текущему типу программы
            //в случае переключения
            MaintenanceCheck lastComplianceCheck = CheckItems.Where(c => c.LastPerformance != null).OrderByDescending(c => c.LastPerformance.RecordDate).FirstOrDefault();

            if (lastComplianceCheck != null && lastComplianceCheck.Schedule != Schedule && Schedule)
            {
                //тип программмы Maintenance был переключен, переключение с Unschedule на Schedule
                //вычисление самого последнего выполненного чека, заданного типа
                MaintenanceCheck lastComplianceScheduleTypeCheck =
                    CheckItems.Where(c => c.LastPerformance != null && c.Schedule == Schedule).OrderByDescending(c => c.LastPerformance.RecordDate).FirstOrDefault();

                MaintenanceCheckGroupByType group = new List <MaintenanceCheck>(CheckItems).GetNextCheckBySourceDifference(lastComplianceScheduleTypeCheck, TsnCsn.Days);
                //название чеков
                MaintenanceCheck maxIntervalCheckInGroup = group.GetMaxIntervalCheck();
                string           tNext = maxIntervalCheckInGroup.Name + " (";
                tNext += group.Checks.Aggregate(tNext, (current, maintenanceCheck) => current + (maintenanceCheck.Name + " "));
                tNext += ") ";
                string tNextDate = UsefulMethods.NormalizeDate(group.GroupComplianceDate);

                group.GroupComplianceLifelength.Cycles = group.GroupComplianceLifelength.Hours = null;
                string tNextLl = group.GroupComplianceLifelength.ToRepeatIntervalsFormat();

                group.GroupComplianceLifelength.Substract(TsnCsn);
                group.GroupComplianceLifelength.Cycles = group.GroupComplianceLifelength.Hours = null;
                string tRemainLl = Convert.ToInt32(group.GroupComplianceLifelength.Days).ToString();

                Action <string, string, string, string> addLast = AddNextCheckItem;
                if (InvokeRequired)
                {
                    Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl);
                }
                else
                {
                    addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl);
                }
            }
            else
            {
                if (_complianceGroupCollection == null)
                {
                    _complianceGroupCollection = CheckItems.GetNextComplianceCheckGroups(Schedule).OrderBy(GetNextComplianceDate);
                }

                foreach (MaintenanceCheckComplianceGroup complianceGroup in _complianceGroupCollection)
                {
                    string           tNext, tNextDate, tNextLl, tRemainLl;
                    MaintenanceCheck maxIntervalCheckInGroup;
                    if ((maxIntervalCheckInGroup = complianceGroup.GetMaxIntervalCheck()) == null)
                    {
                        continue;
                    }
                    complianceGroup.Sort();

                    string prefix = complianceGroup.GetGroupName();

                    if (complianceGroup.Grouping)
                    {
                        MaintenanceCheck lastOrMinCheck =
                            complianceGroup.GetLastComplianceChecks().FirstOrDefault() != null
                                ? complianceGroup.GetLastComplianceChecks().First()
                                : complianceGroup.GetMinIntervalCheck();


                        //дата следующего выполнения группы чеков
                        if (lastOrMinCheck.Interval.Days != null && lastOrMinCheck.Interval.Days > 0)
                        {
                            DateTime nextDate = lastOrMinCheck.NextPerformances.Count != 0 && lastOrMinCheck.NextPerformances[0].PerformanceDate != null
                                                    ? lastOrMinCheck.NextPerformances[0].PerformanceDate.Value
                                                    : lastOrMinCheck.LastPerformance != null
                                                          ? lastOrMinCheck.LastPerformance.RecordDate.AddDays(Convert.ToInt32(lastOrMinCheck.Interval.Days))
                                                          : lastOrMinCheck.ParentAircraft.ManufactureDate.AddDays(Convert.ToInt32(lastOrMinCheck.Interval.Days));

                            tNextDate = UsefulMethods.NormalizeDate(nextDate);

                            if (lastOrMinCheck.NextPerformances.Count != 0 &&
                                lastOrMinCheck.NextPerformances[0].Remains != null)
                            {
                                //Остаток до выполнения
                                Lifelength remains = lastOrMinCheck.NextPerformances[0].Remains;
                                tRemainLl = remains.IsNullOrZero() ? "N/A" : remains.ToString();
                            }
                            else
                            {
                                tRemainLl = " N/A ";
                            }
                        }
                        else
                        {
                            tNextDate = lastOrMinCheck.NextPerformances.Count != 0 &&
                                        lastOrMinCheck.NextPerformances[0].PerformanceDate != null
                                ? " approx. " + UsefulMethods.NormalizeDate(lastOrMinCheck.NextPerformances[0].PerformanceDate.Value)
                                : " N/A ";

                            if (lastOrMinCheck.NextPerformances.Count != 0 &&
                                lastOrMinCheck.NextPerformances[0].Remains != null)
                            {
                                //Остаток до выполнения
                                Lifelength remains = lastOrMinCheck.NextPerformances[0].Remains;
                                tRemainLl = remains.IsNullOrZero() ? "N/A" : remains.ToString();
                            }
                            else
                            {
                                tRemainLl = " N/A ";
                            }
                        }
                        //ресурс, на котором надо поризвести выполнение
                        //след выполнение
                        Lifelength next =
                            lastOrMinCheck.NextPerformances.Count != 0
                                ? lastOrMinCheck.NextPerformances[0].PerformanceSource
                                : Lifelength.Null;
                        next.Resemble(maxIntervalCheckInGroup.Interval);
                        tNextLl = next.IsNullOrZero() ? "N/A" : next.ToString();
                        //название чеков
                        tNext = prefix;
                        if (lastOrMinCheck.ParentAircraft != null &&
                            lastOrMinCheck.ParentAircraft.MSG < MSG.MSG3)
                        {
                            tNext += " (";
                            tNext  = complianceGroup.Checks.Aggregate(tNext, (current, maintenanceCheck) => current + (maintenanceCheck.Name + " "));
                            tNext += ") ";
                        }

                        Action <string, string, string, string> addLast = AddNextCheckItem;
                        if (InvokeRequired)
                        {
                            Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl);
                        }
                        else
                        {
                            addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl);
                        }
                    }
                    else
                    {
                        foreach (MaintenanceCheck maintenanceCheck in complianceGroup.Checks)
                        {
                            DateTime nextDate;
                            if (maintenanceCheck.Interval.Days != null && maintenanceCheck.Interval.Days > 0)
                            {
                                nextDate =
                                    maintenanceCheck.NextPerformances.Count != 0 && maintenanceCheck.NextPerformances[0].PerformanceDate != null
                                                    ? maintenanceCheck.NextPerformances[0].PerformanceDate.Value
                                                    : maintenanceCheck.LastPerformance != null
                                                          ? maintenanceCheck.LastPerformance.RecordDate.AddDays(Convert.ToInt32(maintenanceCheck.Interval.Days))
                                                          : maintenanceCheck.ParentAircraft.ManufactureDate.AddDays(Convert.ToInt32(maintenanceCheck.Interval.Days));

                                tNextDate = "\n" + UsefulMethods.NormalizeDate(nextDate);

                                if (maintenanceCheck.NextPerformances.Count != 0 &&
                                    maintenanceCheck.NextPerformances[0].Remains != null)
                                {
                                    //Остаток до выполнения
                                    Lifelength remains = maintenanceCheck.NextPerformances[0].Remains;
                                    tRemainLl = "\n" + (remains.IsNullOrZero() ? "N/A" : remains.ToString());
                                }
                                else
                                {
                                    tRemainLl = "\n N/A ";
                                }
                            }
                            else
                            {
                                if (maintenanceCheck.NextPerformanceDate != null)
                                {
                                    nextDate  = maintenanceCheck.NextPerformanceDate.Value;
                                    tNextDate = "\n approx. " + UsefulMethods.NormalizeDate(nextDate);
                                }
                                else
                                {
                                    tNextDate = "\n (N/A) ";
                                }

                                if (maintenanceCheck.NextPerformances.Count != 0 &&
                                    maintenanceCheck.NextPerformances[0].Remains != null)
                                {
                                    //Остаток до выполнения
                                    Lifelength remains = maintenanceCheck.NextPerformances[0].Remains;
                                    tRemainLl = "\n" + (remains.IsNullOrZero() ? "N/A" : remains.ToString());
                                }
                                else
                                {
                                    tRemainLl = "\n (N/A) ";
                                }
                            }
                            //след выполнение
                            Lifelength next =
                                maintenanceCheck.NextPerformances.Count != 0
                                    ? maintenanceCheck.NextPerformances[0].PerformanceSource
                                    : Lifelength.Null;
                            tNextLl = "\n" + (next.IsNullOrZero() ? "N/A" : next.ToString());

                            //название чеков
                            tNext = "\n" + maintenanceCheck.Name + " ";

                            Action <string, string, string, string> addLast = AddNextCheckItem;
                            if (InvokeRequired)
                            {
                                Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl);
                            }
                            else
                            {
                                addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void Edit()
        {
            DialogResult dlgResult = DialogResult.None;

            if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["overdue"])
            {
                MaintenanceComplainceForm complainceForm =
                    new MaintenanceComplainceForm(_currentAircraft, (MaintenanceCheckGroupByType)listViewCompliance.SelectedItems[0].Tag);
                dlgResult = complainceForm.ShowDialog(this);
            }
            else if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["next"])
            {
                if (listViewCompliance.SelectedItems[0].Tag is NextPerformance)
                {
                    NextPerformance np = (NextPerformance)listViewCompliance.SelectedItems[0].Tag;
                    //if (np.Condition != ConditionState.Overdue || np.PerformanceDate > DateTime.Now)
                    //{
                    //    MessageBox.Show("You can not enter a record for not delayed performance",
                    //                    (string)new GlobalTermsProvider()["SystemName"],
                    //                    MessageBoxButtons.OK,
                    //                    MessageBoxIcon.Warning,
                    //                    MessageBoxDefaultButton.Button1);
                    //    return;
                    //}
                    if (np.BlockedByPackage != null)
                    {
                        MessageBox.Show("Perform of the task:" + listViewCompliance.SelectedItems[0].Text +
                                        "\nblocked by Work Package:" +
                                        "\n" + np.BlockedByPackage.Title,
                                        (string)new GlobalTermsProvider()["SystemName"],
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button1);
                        return;
                    }
                }

                if (listViewCompliance.SelectedItems[0].Tag is MaintenanceNextPerformance)
                {
                    MaintenanceNextPerformance mnp = listViewCompliance.SelectedItems[0].Tag as MaintenanceNextPerformance;
                    if (mnp.PerformanceGroup == null)
                    {
                        return;
                    }
                    MaintenanceCheckGroupByType pg             = mnp.PerformanceGroup;
                    MaintenanceComplainceForm   complainceForm = new MaintenanceComplainceForm(_currentAircraft, pg);
                    dlgResult = complainceForm.ShowDialog(this);
                }
                else if (listViewCompliance.SelectedItems[0].Tag is NextPerformance)
                {
                    NextPerformance np = listViewCompliance.SelectedItems[0].Tag as NextPerformance;
                    if (np.Parent == null)
                    {
                        return;
                    }
                    MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm(_currentAircraft, np);
                    dlgResult = complainceForm.ShowDialog(this);
                }
            }
            else if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["last"])
            {
                if (listViewCompliance.SelectedItems[0].Tag is List <MaintenanceCheckRecord> )
                {
                    MaintenanceComplainceForm complainceForm =
                        new MaintenanceComplainceForm(_currentAircraft, (List <MaintenanceCheckRecord>)listViewCompliance.SelectedItems[0].Tag);
                    dlgResult = complainceForm.ShowDialog(this);
                }
                else if (listViewCompliance.SelectedItems[0].Tag is MaintenanceProgramChangeRecord)
                {
                    List <MaintenanceCheckRecord> records =
                        CheckItems.Where(c => c.Grouping)
                        .SelectMany(c => c.PerformanceRecords)
                        .ToList();
                    List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>();

                    foreach (MaintenanceCheckRecord record in records)
                    {
                        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);
                        }
                    }
                    MaintenanceProgramChangeDialog complainceForm =
                        new MaintenanceProgramChangeDialog((MaintenanceProgramChangeRecord)listViewCompliance.SelectedItems[0].Tag,
                                                           maintenanceCheckRecordGroups);
                    dlgResult = complainceForm.ShowDialog(this);
                }
                //MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm
                //{
                //    PerformanceRecords = ((List<MaintenanceCheckRecord>)
                //                     listViewCompliance.SelectedItems[0].Tag),
                //    CurrentAircraft = this.CurentAircraft,
                //    NumGroup = ((List<MaintenanceCheckRecord>)
                //        listViewCompliance.SelectedItems[0].Tag)[0].NumGroup
                //};
                // dlgResult = complainceForm.ShowDialog(this);
            }
            if (dlgResult == DialogResult.OK)
            {
                InvokeComplianceAdded(null);
            }
        }