Beispiel #1
0
        protected override List <CustomCell> GetListViewSubItems(MaintenanceDirective item)
        {
            var subItems = new List <CustomCell>();

            //////////////////////////////////////////////////////////////////////////////////////
            //         Определение последнего выполнения директивы и KitRequiered               //
            //////////////////////////////////////////////////////////////////////////////////////
            var defaultDateTime          = DateTimeExtend.GetCASMinDateTime();
            var lastComplianceDate       = defaultDateTime;
            var nextComplianceDate       = defaultDateTime;
            var lastComplianceLifeLength = Lifelength.Zero;
            //Lifelength nextComplianceLifelength = Lifelength.Null;

            string lastPerformanceString, firstPerformanceString = "N/A";

            var tcnColor = radGridView1.ForeColor;
            var kitColor = radGridView1.BackColor;
            var ata      = item.ATAChapter;

            if (item.LastPerformance != null)
            {
                lastComplianceDate       = item.LastPerformance.RecordDate;
                lastComplianceLifeLength = item.LastPerformance.OnLifelength;
            }
            if (item.Threshold.FirstPerformanceSinceNew != null && !item.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
            {
                firstPerformanceString = "s/n: " + item.Threshold.FirstPerformanceSinceNew;
            }
            if (item.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                !item.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
            {
                if (firstPerformanceString != "N/A")
                {
                    firstPerformanceString += " or ";
                }
                else
                {
                    firstPerformanceString = "";
                }
                firstPerformanceString += "s/e.d: " + item.Threshold.FirstPerformanceSinceEffectiveDate;
            }

            if (item.NextPerformanceDate != null && item.NextPerformanceDate > defaultDateTime)
            {
                nextComplianceDate = Convert.ToDateTime(item.NextPerformanceDate);
            }

            var author              = GlobalObjects.CasEnvironment.GetCorrector(item);
            var kitRequieredString  = item.KitsApplicable ? item.Kits.Count + " EA" : "N/A";
            var ndtString           = item.NDTType.ShortName;
            var skillString         = item.Skill.ShortName;
            var categoryString      = item.Category.ShortName;
            var remarksString       = item.Remarks;
            var hiddenRemarksString = item.HiddenRemarks;

            if (lastComplianceDate <= defaultDateTime)
            {
                lastPerformanceString = "N/A";
            }
            else
            {
                lastPerformanceString = lastComplianceLifeLength.ToString();
            }

            var lastDate = (lastComplianceDate <= defaultDateTime)
                                ? ""
                                : SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate);

            var repeat = item.Threshold.RepeatInterval.ToString();

            if (item.APUCalc)
            {
                firstPerformanceString = firstPerformanceString.Replace("FH", "AH");
                repeat = repeat.Replace("FH", "AH");
            }

            //////////////////////////////////////////////////////////////////////////////////////
            var description = item.Description != "" ? item.Description : "N/A";
            var app         = item.IsApplicability ? $"APL {item.Applicability}" : $"N/A {item.Applicability}";
            var taskNumber  = item.MPDTaskNumber != "" ? item.MPDTaskNumber : "N/A";
            var taskCheck   = item.TaskNumberCheck != "" ? item.TaskNumberCheck : "N/A";
            var maintManual = item.MaintenanceManual != "" ? item.MaintenanceManual : "N/A";
            var mrb         = item.MRB != "" ? item.MRB : "N/A";
            var check       = item.MaintenanceCheck != null ? item.MaintenanceCheck.Name : "N/A";
            var status      = item.Status;
            var condition   = !string.IsNullOrEmpty(firstPerformanceString) ? (item.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                ? "/WF"
                                : "/WL") : "";
            var conditionRepeat = !item.Threshold.RepeatInterval.IsNullOrZero() ? (item.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                ? "/WF"
                                : "/WL") : "";

            if (!item.HasTaskCardFile)
            {
                tcnColor = Color.MediumVioletRed;
            }

            if (item.KitsApplicable && item.Kits.Count == 0)
            {
                kitColor = Color.FromArgb(Highlight.Red.Color);
            }

            subItems.Add(CreateRow(item.ParentAircraft?.ToString() ?? "", item.ParentAircraft));
            subItems.Add(CreateRow(item.ScheduleItem, item.ScheduleItem));
            subItems.Add(CreateRow(taskCheck, taskCheck));
            subItems.Add(CreateRow(item.TaskCardNumber, item.TaskCardNumber, tcnColor));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(item.Program.ToString(), item.Program));
            subItems.Add(CreateRow(item.ProgramIndicator.ShortName, item.ProgramIndicator));
            subItems.Add(CreateRow(item.WorkType.ToString(), item.WorkType));
            subItems.Add(CreateRow(check, check));
            subItems.Add(CreateRow(item.APUCalc ? "Yes" : "No", item.APUCalc));
            subItems.Add(CreateRow($"{firstPerformanceString} {condition}", firstPerformanceString));
            subItems.Add(CreateRow($"{repeat} {conditionRepeat}", item.Threshold.RepeatInterval));
            subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.PerformanceDate), item.NextPerformance?.PerformanceDate));
            subItems.Add(CreateRow(item.NextPerformance?.PerformanceSource.ToString(), item.NextPerformance?.PerformanceSource));
            subItems.Add(CreateRow(item.NextPerformance?.Remains.ToString(), item.NextPerformance?.Remains));
            subItems.Add(CreateRow(item.NextPerformance?.NextLimit.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.NextPerformanceDateNew) : "", item.NextPerformance?.NextPerformanceDateNew));
            subItems.Add(CreateRow(item.NextPerformance?.NextLimit.ToString(), item.NextPerformance?.NextLimit.ToString()));
            subItems.Add(CreateRow(item.NextPerformance?.RemainLimit.ToString(), item.NextPerformance?.RemainLimit.ToString()));
            subItems.Add(CreateRow(lastDate, lastComplianceDate));
            subItems.Add(CreateRow(lastPerformanceString, lastComplianceDate));
            subItems.Add(CreateRow(item.Zone, item.Zone));
            subItems.Add(CreateRow(item.Workarea, item.Workarea));
            subItems.Add(CreateRow(item.Access, item.Access));
            subItems.Add(CreateRow(status.ToString(), status));
            subItems.Add(CreateRow(taskNumber, taskNumber));
            subItems.Add(CreateRow(maintManual, maintManual));
            subItems.Add(CreateRow(mrb, mrb));
            subItems.Add(CreateRow(item.TaskCardNumber, item.TaskCardNumber));
            subItems.Add(CreateRow(item.CriticalSystem.ToString(), item.CriticalSystem));
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(kitRequieredString, kitRequieredString, kitColor));
            subItems.Add(CreateRow(ndtString, ndtString));
            subItems.Add(CreateRow(skillString, skillString));
            subItems.Add(CreateRow(categoryString, categoryString));
            subItems.Add(CreateRow(item.Elapsed <= 0 ? "" : item.Elapsed.ToString(), item.Elapsed));
            subItems.Add(CreateRow(item.ManHours <= 0 ? "" : item.ManHours.ToString(), item.ManHours));
            subItems.Add(CreateRow(item.Cost <= 0 ? "" : item.Cost.ToString(), item.Cost));
            subItems.Add(CreateRow(app, app));
            subItems.Add(CreateRow(remarksString, remarksString));
            subItems.Add(CreateRow(hiddenRemarksString, hiddenRemarksString));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }