/// <summary>
        /// Изменение значения наработки агрегата с момента установки
        /// </summary>
        public void ChangeComponentTSNSinseInstall()
        {
            if (_isStore)
            {
                return;
            }
            //если отсутствует наработка агрегата на момент установки
            //то дальнейшее расчитать нельзя
            Lifelength aircraftCurrent =
                GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay((Aircraft)_currentAircraft, dateTimePickerDateAsOf.Value);

            if ((aircraftCurrent.IsNullOrZero() && AircraftTCSNOnInstall.IsNullOrZero()) ||
                (ComponentCurrentTSNCSN.IsNullOrZero() && ComponentTCSNOnInstall.IsNullOrZero()))
            {
                if (lifelengthViewerComponentTCSI.SystemCalculated)
                {
                    //если данные в наработку с момента установеи вводила система,
                    //а не пользователь, то их нужно обнулить
                    ComponentTCSI = Lifelength.Null;
                }
                return;
            }

            if (ComponentTCSI.IsNullOrZero() ||
                lifelengthViewerComponentTCSI.SystemCalculated)
            {
                //Если наработка агрегата с момента установки не введена или
                //введена системой, то её надо расчитать
                Lifelength temp;
                if (!aircraftCurrent.IsNullOrZero() &&
                    !AircraftTCSNOnInstall.IsNullOrZero())
                {
                    //если известна текущая наработка самолета и
                    //наработка самолета на момент установки
                    temp = new Lifelength(aircraftCurrent);
                    temp.Substract(AircraftTCSNOnInstall);
                    ComponentTCSI = temp;
                    lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true;
                    return;
                }

                if (!ComponentCurrentTSNCSN.IsNullOrZero() &&
                    !ComponentTCSNOnInstall.IsNullOrZero())
                {
                    //если известна текущая наработка агрегата и
                    //наработка агрегата на момент установки
                    temp = new Lifelength(ComponentCurrentTSNCSN);
                    temp.Substract(ComponentTCSNOnInstall);
                    ComponentTCSI = temp;
                    lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true;
                    return;
                }
                //иначе, наработку высчитать нельзя
                ComponentTCSI = Lifelength.Null;
                lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true;
            }
        }
Пример #2
0
        /// <summary>
        /// Считывает все контролы и формирует один Threshold
        /// </summary>
        protected override IThreshold GetThreshold()
        {
            DirectiveThreshold threshold = new DirectiveThreshold();

            // First performance
            Lifelength sinceNew     = new Lifelength(lifelengthViewer_SinceNew.Lifelength);
            Lifelength sinceEffDate = new Lifelength(lifelengthViewer_SinceEffDate.Lifelength);

            threshold.FirstPerformanceSinceNew           = sinceNew;
            threshold.FirstPerformanceSinceEffectiveDate = sinceEffDate;

            threshold.PerformSinceNew           = sinceNew.IsNullOrZero() ? false : true;
            threshold.PerformSinceEffectiveDate = sinceEffDate.IsNullOrZero() ? false : true;

            Lifelength nfp = new Lifelength(lifelengthViewer_FirstNotify.Lifelength);

            threshold.FirstNotification = nfp;

            if (radio_FirstWhicheverFirst.Checked)
            {
                threshold.FirstPerformanceConditionType = ThresholdConditionType.WhicheverFirst;
            }
            if (radio_FirstWhicheverLast.Checked)
            {
                threshold.FirstPerformanceConditionType = ThresholdConditionType.WhicheverLater;
            }

            // Repeat interval
            if (checkBoxRepeat.Checked)
            {
                // директива выполняется повторно
                Lifelength rp  = new Lifelength(lifelengthViewer_Repeat.Lifelength);
                Lifelength nrp = new Lifelength(lifelengthViewer_RepeatNotify.Lifelength);

                threshold.PerformRepeatedly  = true;
                threshold.RepeatInterval     = rp;
                threshold.RepeatNotification = nrp;

                if (radio_RepeatWhicheverFirst.Checked)
                {
                    threshold.RepeatPerformanceConditionType = ThresholdConditionType.WhicheverFirst;
                }
                if (radio_RepeatWhicheverLast.Checked)
                {
                    threshold.RepeatPerformanceConditionType = ThresholdConditionType.WhicheverLater;
                }
            }

            return(threshold);
        }
Пример #3
0
        /// <summary>
        /// Возвращает условие гарантии
        /// </summary>
        /// <returns></returns>
        private string WarrantyToString()
        {
            string res = "";

            if (!Warranty.IsNullOrZero())
            {
                res = LifelengthToString(Warranty, "war");
            }
            if (!WarrantyNotification.IsNullOrZero())
            {
                res += LifelengthToString(WarrantyNotification, "war.p");
            }

            return(res.Trim());
        }
Пример #4
0
        /// <summary>
        /// Возвращает условие повторного выполнения директивы
        /// </summary>
        /// <returns></returns>
        private string RepeatPerformanceToString()
        {
            //if (!PerformRepeatedly) return "and then close";
            //else if (PerformRepeatedly && (RepeatInterval == null || RepeatInterval.IsNullLifelength()))
            //    return "repeat interval depends on first performance";
            //else
            //{
            string res = "and then repeat every ";

            //    Lifelength repeat = new Lifelength();

            if (!RepeatInterval.IsNullOrZero())
            {
                res = LifelengthToString(RepeatInterval, "r.p");
            }
            if (!RepeatNotification.IsNullOrZero())
            {
                res += LifelengthToString(RepeatNotification, "r.p.n");
            }

            return(res.Trim());
            //}
        }
Пример #5
0
        protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item)
        {
            var subItems = new List <CustomCell>();
            var author   = GlobalObjects.CasEnvironment.GetCorrector(item);

            DateTime?  approx;
            Lifelength remains = Lifelength.Null, next;
            AtaChapter ata;
            MaintenanceControlProcess maintenanceType;
            DateTime   transferDate;
            Lifelength firstPerformance = Lifelength.Null,
                       lastPerformance = Lifelength.Null,
                       warranty, repeatInterval = Lifelength.Null;
            string partNumber,
                   description,
                   serialNumber,
                   position,
                   mpdString             = "",
                   mpdNumString          = "",
                   lastPerformanceString = "",
                   type        = getGroupName(item),
                   classString = "",
                   kitRequieredString,
                   remarks,
                   hiddenRemarks,
                   workType    = "",
                   zone        = "",
                   destination = "",
                   access      = "",
                   ndtString   = "";
            double manHours,
                   cost,
                   costServiceable = 0,
                   costOverhaul    = 0;

            if (item is Component)
            {
                Component componentItem = (Component)item;
                approx = componentItem.NextPerformanceDate;
                next   = componentItem.NextPerformanceSource;

                destination = GlobalObjects.AircraftsCore.GetAircraftById(componentItem.ParentBaseComponent?.ParentAircraftId ?? -1)?.ToString();

                var selectedCategory = componentItem.ChangeLLPCategoryRecords.GetLast()?.ToCategory;
                if (selectedCategory != null)
                {
                    var llp = componentItem.LLPData.GetItemByCatagory(selectedCategory);
                    remains = llp?.Remain;
                }



                ata              = componentItem.Model != null ? componentItem.Model.ATAChapter : componentItem.ATAChapter;
                partNumber       = componentItem.PartNumber;
                description      = componentItem.Model != null ? componentItem.Model.Description : componentItem.Description;
                serialNumber     = componentItem.SerialNumber;
                position         = componentItem.TransferRecords.GetLast().Position.ToUpper();
                maintenanceType  = componentItem.MaintenanceControlProcess;
                transferDate     = componentItem.TransferRecords.GetLast().TransferDate;
                firstPerformance = componentItem.LifeLimit;
                warranty         = componentItem.Warranty;
                classString      = componentItem.GoodsClass != null?componentItem.GoodsClass.ToString() : "";

                kitRequieredString = componentItem.Kits.Count + " kits";
                manHours           = componentItem.ManHours;
                cost            = componentItem.Cost;
                costOverhaul    = componentItem.CostOverhaul;
                costServiceable = componentItem.CostServiceable;
                remarks         = componentItem.Remarks;
                hiddenRemarks   = componentItem.HiddenRemarks;
            }
            else
            {
                ComponentDirective dd = (ComponentDirective)item;


                destination = GlobalObjects.AircraftsCore.GetAircraftById(dd.ParentComponent.ParentBaseComponent?.ParentAircraftId ?? -1)?.ToString();

                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    firstPerformance = dd.Threshold.FirstPerformanceSinceNew;
                }
                if (dd.LastPerformance != null)
                {
                    lastPerformanceString =
                        SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate) + " " +
                        dd.LastPerformance.OnLifelength;
                    lastPerformance = dd.LastPerformance.OnLifelength;
                }
                if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    repeatInterval = dd.Threshold.RepeatInterval;
                }
                //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd, out next, out remains, out approx, out cond);
                //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd);
                approx     = dd.NextPerformanceDate;
                next       = dd.NextPerformanceSource;
                remains    = dd.Remains;
                ata        = dd.ParentComponent.Model != null ? dd.ParentComponent.Model.ATAChapter : dd.ParentComponent.ATAChapter;
                partNumber = "    " + dd.PartNumber;
                var desc = dd.ParentComponent.Model != null
                                        ? dd.ParentComponent.Model.Description
                                        : dd.ParentComponent.Description;

                description     = "    " + desc;
                serialNumber    = "    " + dd.SerialNumber;
                position        = "    " + dd.ParentComponent.TransferRecords.GetLast().Position.ToUpper();
                transferDate    = dd.ParentComponent.TransferRecords.GetLast().TransferDate;
                maintenanceType = dd.ParentComponent.MaintenanceControlProcess;
                warranty        = dd.Threshold.Warranty;
                classString     = dd.ParentComponent.GoodsClass != null?dd.ParentComponent.GoodsClass.ToString() : "";

                kitRequieredString = dd.Kits.Count + " kits";
                manHours           = dd.ManHours;
                cost          = dd.Cost;
                zone          = dd.ZoneArea;
                access        = dd.AccessDirective;
                remarks       = dd.Remarks;
                hiddenRemarks = dd.HiddenRemarks;
                workType      = dd.DirectiveType.ToString();
                ndtString     = dd.NDTType.ShortName;
                if (dd.MaintenanceDirective != null)
                {
                    mpdString    = dd.MaintenanceDirective.TaskNumberCheck;
                    mpdNumString = dd.MaintenanceDirective.TaskCardNumber;
                }
            }

            subItems.Add(CreateRow(destination, destination));
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(partNumber, partNumber));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(workType, workType));
            subItems.Add(CreateRow(serialNumber, serialNumber));
            subItems.Add(CreateRow(mpdString, mpdString));
            subItems.Add(CreateRow(mpdNumString, mpdNumString));
            subItems.Add(CreateRow(position, position));
            subItems.Add(CreateRow(maintenanceType.ShortName, maintenanceType));
            subItems.Add(CreateRow(zone, zone));
            subItems.Add(CreateRow(access, access));
            subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime()
                                ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate));
            subItems.Add(CreateRow(firstPerformance?.ToString(), firstPerformance));
            subItems.Add(CreateRow(repeatInterval.ToString(), repeatInterval));
            subItems.Add(CreateRow(approx == null ? "" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)approx) + " " + next,
                                   approx == null ? DateTimeExtend.GetCASMinDateTime() : (DateTime)approx));
            subItems.Add(CreateRow(remains != null && !remains.IsNullOrZero() ? remains.ToString() : "",
                                   remains ?? Lifelength.Null));
            subItems.Add(CreateRow(lastPerformanceString, lastPerformance));
            subItems.Add(CreateRow(warranty.ToString(), warranty));
            subItems.Add(CreateRow(classString, classString));
            subItems.Add(CreateRow(kitRequieredString, kitRequieredString));
            subItems.Add(CreateRow(ndtString, ndtString));
            subItems.Add(CreateRow(manHours.ToString(), manHours));
            subItems.Add(CreateRow(cost.ToString(), cost));
            subItems.Add(CreateRow(costOverhaul.ToString(), costOverhaul));
            subItems.Add(CreateRow(costServiceable.ToString(), costServiceable));
            subItems.Add(CreateRow(remarks, remarks));
            subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
Пример #6
0
        protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item)
        {
            var subItems = new List <CustomCell>();
            var author   = GlobalObjects.CasEnvironment.GetCorrector(item);

            AtaChapter ata;
            MaintenanceControlProcess maintenanceType;
            DateTime   transferDate;
            DateTime?  lastPerformanceDate = null;
            DateTime?  nextEstimated       = null;
            DateTime?  nextLimit           = null;
            Lifelength firstPerformance    = Lifelength.Null,
                       lastPerformance     = Lifelength.Null,
                       lastPerformanceC    = Lifelength.Null,
                       expiryRemain        = Lifelength.Null,
                       nextEstimatedData   = Lifelength.Null,
                       nextEstimatedDataC  = Lifelength.Null,
                       remainEstimated     = Lifelength.Null,
                       nextLimitData       = Lifelength.Null,
                       nextLimitDataC      = Lifelength.Null,
                       remainLimit         = Lifelength.Null,
                       remainLimitC        = Lifelength.Null,
                       IDD = Lifelength.Null,
                       IDDC = Lifelength.Null,
                       warranty, repeatInterval = Lifelength.Null;
            string partNumber,
                   description,
                   serialNumber,
                   position,
                   mpdString             = "",
                   mpdNumString          = "",
                   lastPerformanceString = "",
                   type        = getGroupName(item),
                   classString = "",
                   kitRequieredString,
                   remarks,
                   hiddenRemarks,
                   workType        = "",
                   zone            = "",
                   ad              = "",
                   access          = "",
                   expiryDate      = "",
                   condition       = "",
                   conditionRepeat = "",
                   ndtString       = "";
            double manHours,
                   cost,
                   costServiceable = 0,
                   costOverhaul    = 0;
            bool isRVSM            = false,
                 isETOPS           = false;

            if (item is Component)
            {
                Component componentItem = (Component)item;

                if (componentItem.LLPCategories)
                {
                    nextEstimated      = componentItem.NextPerformance?.PerformanceDate;
                    nextEstimatedData  = componentItem.NextPerformance?.PerformanceSource;
                    nextEstimatedDataC = componentItem.NextPerformance?.PerformanceSourceC;
                    remainEstimated    = componentItem.NextPerformance?.Remains;

                    nextLimit      = componentItem.NextPerformance?.NextPerformanceDateNew;
                    nextLimitData  = componentItem.NextPerformance?.NextLimit;
                    nextLimitDataC = componentItem.NextPerformance?.NextLimitC;
                    remainLimit    = componentItem.NextPerformance?.RemainLimit;
                    remainLimitC   = componentItem.NextPerformance?.RemainLimitC;

                    IDD  = componentItem.NextPerformance?.IDD;
                    IDDC = componentItem.NextPerformance?.IDDC;
                }


                ata              = componentItem.Model != null ? componentItem.Model.ATAChapter : componentItem.ATAChapter;
                partNumber       = componentItem.PartNumber;
                description      = componentItem.Model != null ? componentItem.Model.Description : componentItem.Description;
                serialNumber     = componentItem.SerialNumber;
                position         = componentItem.TransferRecords.GetLast().Position.ToUpper();
                maintenanceType  = componentItem.MaintenanceControlProcess;
                transferDate     = componentItem.TransferRecords.GetLast().TransferDate;
                firstPerformance = componentItem.LifeLimit;
                warranty         = componentItem.Warranty;
                classString      = componentItem.GoodsClass != null?componentItem.GoodsClass.ToString() : "";

                kitRequieredString = componentItem.Kits.Count + " kits";
                manHours           = componentItem.ManHours;
                cost            = componentItem.Cost;
                costOverhaul    = componentItem.CostOverhaul;
                costServiceable = componentItem.CostServiceable;
                remarks         = componentItem.Remarks;
                hiddenRemarks   = componentItem.HiddenRemarks;
                isRVSM          = componentItem.IsRVSM;
                isETOPS         = componentItem.IsETOPS;
                expiryDate      = " ";
                expiryRemain    = Lifelength.Null;
                condition       = !firstPerformance.IsNullOrZero() ? (componentItem.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";
                conditionRepeat = !componentItem.Threshold.RepeatInterval.IsNullOrZero() ? (componentItem.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";
            }
            else
            {
                ComponentDirective dd = (ComponentDirective)item;
                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    firstPerformance = dd.Threshold.FirstPerformanceSinceNew;
                }

                if (dd.LastPerformance != null)
                {
                    lastPerformanceString = SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate);
                    lastPerformance       = dd.LastPerformance?.OnLifelength;
                    lastPerformanceC      = dd.NextPerformance?.LastDataC;
                    lastPerformanceDate   = dd.LastPerformance?.RecordDate;
                }
                if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    repeatInterval = dd.Threshold.RepeatInterval;
                }
                nextEstimated      = dd.NextPerformance?.PerformanceDate;
                nextEstimatedData  = dd.NextPerformance?.PerformanceSource;
                nextEstimatedDataC = dd.NextPerformance?.PerformanceSourceC;
                remainEstimated    = dd.NextPerformance?.Remains;

                nextLimit      = dd.NextPerformance?.NextPerformanceDateNew;
                nextLimitData  = dd.NextPerformance?.NextLimit;
                nextLimitDataC = dd.NextPerformance?.NextLimitC;
                remainLimit    = dd.NextPerformance?.RemainLimit;
                remainLimitC   = dd.NextPerformance?.RemainLimitC;


                IDD  = dd.NextPerformance?.IDD;
                IDDC = dd.NextPerformance?.IDDC;

                ata        = dd.ParentComponent.Model != null ? dd.ParentComponent.Model.ATAChapter : dd.ParentComponent.ATAChapter;
                partNumber = "    " + dd.PartNumber;
                var desc = dd.ParentComponent.Model != null
                                        ? dd.ParentComponent.Model.Description
                                        : dd.ParentComponent.Description;

                description     = "    " + desc;
                serialNumber    = "    " + dd.SerialNumber;
                position        = "    " + dd.ParentComponent.TransferRecords.GetLast().Position.ToUpper();
                transferDate    = dd.ParentComponent.TransferRecords.GetLast().TransferDate;
                maintenanceType = dd.ParentComponent.MaintenanceControlProcess;
                warranty        = dd.Threshold.Warranty;
                classString     = dd.ParentComponent.GoodsClass != null?dd.ParentComponent.GoodsClass.ToString() : "";

                kitRequieredString = dd.Kits.Count + " kits";
                manHours           = dd.ManHours;
                cost          = dd.Cost;
                zone          = dd.ZoneArea;
                access        = dd.AccessDirective;
                remarks       = dd.Remarks;
                hiddenRemarks = dd.HiddenRemarks;
                workType      = dd.DirectiveType.ToString();
                ndtString     = dd.NDTType.ShortName;
                isRVSM        = dd.ParentComponent.IsRVSM;
                isETOPS       = dd.ParentComponent.IsETOPS;
                condition     = !firstPerformance.IsNullOrZero() ? (dd.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";
                conditionRepeat = !dd.Threshold.RepeatInterval.IsNullOrZero() ? (dd.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                        ? "/WF"
                                        : "/WL") : "";

                ad = dd.LinkAd;

                if (dd.IsExpiry)
                {
                    expiryDate   = dd.IsExpiry ? (dd.ExpiryDate.HasValue ? SmartCore.Auxiliary.Convert.GetDateFormat(dd.ExpiryDate.Value) : "") : "";
                    expiryRemain = dd.IsExpiry ? new Lifelength((int)(dd.ExpiryDate.Value - DateTime.Today).TotalDays, 0, 0) : Lifelength.Null;
                }

                if (dd.MaintenanceDirective != null)
                {
                    mpdString    = dd.MaintenanceDirective.TaskNumberCheck;
                    mpdNumString = dd.MaintenanceDirective.TaskCardNumber;
                }
            }
            if (ShowGroup)
            {
                subItems.Add(CreateRow(type, type));
            }
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(partNumber, partNumber));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(workType, workType));
            subItems.Add(CreateRow(serialNumber, serialNumber));
            subItems.Add(CreateRow(mpdString, mpdString));
            subItems.Add(CreateRow(mpdNumString, mpdNumString));
            subItems.Add(CreateRow(position, position));
            subItems.Add(CreateRow(maintenanceType.ShortName, maintenanceType));
            subItems.Add(CreateRow(zone, zone));
            subItems.Add(CreateRow(access, access));
            subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime()
                                ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate));
            subItems.Add(CreateRow(IDD?.ToString(), IDD));
            subItems.Add(CreateRow(IDDC?.ToString(), IDDC));
            subItems.Add(CreateRow($"{firstPerformance} {condition}", firstPerformance));
            subItems.Add(CreateRow($"{repeatInterval} {conditionRepeat}", repeatInterval));


            subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(nextEstimated), nextEstimated));
            subItems.Add(CreateRow(nextEstimatedData?.ToString(), nextEstimatedData));
            subItems.Add(CreateRow(nextEstimatedDataC?.ToString(), nextEstimatedDataC));
            subItems.Add(CreateRow(remainEstimated?.ToString(), remainEstimated));
            subItems.Add(CreateRow(nextLimitData?.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(nextLimit) : "", nextLimit));
            subItems.Add(CreateRow(nextLimitData?.ToString(), nextLimitData));
            subItems.Add(CreateRow(nextLimitDataC?.ToString(), nextLimitDataC));
            subItems.Add(CreateRow(remainLimit?.ToString(), remainLimit));
            subItems.Add(CreateRow(remainLimitC?.ToString(), remainLimitC));
            subItems.Add(CreateRow(lastPerformanceString, lastPerformanceDate));
            subItems.Add(CreateRow(lastPerformanceC?.ToString(), lastPerformanceC));
            subItems.Add(CreateRow(lastPerformance?.ToString(), lastPerformance));


            subItems.Add(CreateRow(expiryDate, expiryDate));
            subItems.Add(CreateRow(!expiryRemain.IsNullOrZero() ? $"{expiryRemain?.Days}d" : "", expiryRemain));
            subItems.Add(CreateRow(warranty.ToString(), warranty));
            subItems.Add(CreateRow(classString, classString));
            subItems.Add(CreateRow(kitRequieredString, kitRequieredString));
            subItems.Add(CreateRow(ndtString, ndtString));
            subItems.Add(CreateRow(isRVSM ? "Yes" : "No", isRVSM));
            subItems.Add(CreateRow(isETOPS ? "Yes" : "No", isETOPS));
            subItems.Add(CreateRow(manHours.ToString(), manHours));
            subItems.Add(CreateRow(cost.ToString(), cost));
            subItems.Add(CreateRow(costOverhaul.ToString(), costOverhaul));
            subItems.Add(CreateRow(costServiceable.ToString(), costServiceable));
            subItems.Add(CreateRow(ad, ad));
            subItems.Add(CreateRow(remarks, remarks));
            subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
Пример #7
0
        /// <summary>
        /// Добавляет элементы в ListView
        /// </summary>
        /// <param name="itemsArray"></param>
        //protected override void AddItems(IBaseCoreObject[] itemsArray)
        //{
        //    ColumnHeader ch = ColumnHeaderList.FirstOrDefault(h => h.Text == "Performances");
        //    if (ch == null)
        //    {
        //        base.AddItems(itemsArray);
        //        return;
        //    }

        //    if(itemsArray == null || itemsArray.Length == 0)
        //    {
        //        ch.Width = 0;
        //        base.AddItems(itemsArray);
        //        return;
        //    }
        //    ch.Width = itemsArray.OfType<IDirective>()
        //                         .Count(d => d.NextPerformances != null && d.NextPerformances.Count > 1) > 0 ? 100 : 0;

        //    base.AddItems(itemsArray);
        //}

        #endregion

        #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(IBaseCoreObject item)

        protected override List <CustomCell> GetListViewSubItems(IBaseEntityObject item)
        {
            var subItems = new List <CustomCell>();

            DateTime?  approx = null;
            AtaChapter ata;
            string     maintenanceTypeString = "";
            DateTime   transferDate = DateTimeExtend.GetCASMinDateTime();
            bool       isPool = false, IsDangerous = false;
            Lifelength firstPerformance = Lifelength.Null,
                       lastPerformance  = Lifelength.Null,
                       remains = null,
                       next = null,
                       warranty = Lifelength.Null, warrantyRemain = Lifelength.Null, repeatInterval = Lifelength.Null;
            string partNumber            = "",
                   description           = "",
                   altPartNumber         = "",
                   standart              = "",
                   name                  = "",
                   refference            = "",
                   effectivity           = "",
                   serialNumber          = "",
                   code                  = "",
                   classString           = "",
                   batchNumber           = "",
                   idNumber              = "",
                   supplier              = "";
            string status                = "",
                   location              = "",
                   facility              = "",
                   lastPerformanceString = "",
                   kitRequieredString    = "",
                   remarks               = "",
                   hiddenRemarks         = "",
                   workType              = "",
                   timesString,
                   quantityString        = "",
                   currentString         = "",
                   shouldBeOnStockString = "",
                   from = "",
                   id = "",
                   quantityInString = "",
                   author = "",
                   currency = "";
            double manHours = 0,
                   unitPrice = 0,
                   totalPrice = 0,
                   shipPrice = 0,
                   subTotal = 0,
                   tax1 = 0,
                   tax2 = 0,
                   tax3 = 0,
                   total = 0,
                   quantity = 0,
                   current = 0,
                   quantityIn = 0,
                   shouldBeOnStock = 0, needWpQuantity = 0, reserve = 0;
            int times,

                kitCount        = 0;
            string     position = ComponentStorePosition.UNK.ToString();
            IDirective parent;

            if (item is NextPerformance)
            {
                NextPerformance np = (NextPerformance)item;
                parent = np.Parent;

                int index = np.Parent.NextPerformances.IndexOf(np);
                timesString = index == 0 ? np.Parent.TimesToString : "#" + (index + 1);
                times       = index == 0 ? np.Parent.Times : index + 1;
            }
            else
            {
                parent = item as IDirective;
                if (parent == null)
                {
                    return(subItems);
                }
                timesString = parent.TimesToString;
                times       = parent.Times;
            }

            if (parent is Component)
            {
                Component componentItem = (Component)parent;
                id                    = componentItem.ItemId.ToString();
                author                = GlobalObjects.CasEnvironment.GetCorrector(componentItem);
                approx                = componentItem.NextPerformanceDate;
                next                  = componentItem.NextPerformanceSource;
                remains               = componentItem.Remains;
                ata                   = componentItem.Product?.ATAChapter ?? componentItem.ATAChapter;
                partNumber            = componentItem.Product?.PartNumber ?? componentItem.PartNumber;
                altPartNumber         = componentItem.Product?.AltPartNumber ?? componentItem.ALTPartNumber;
                standart              = componentItem.Product?.Standart?.ToString() ?? componentItem.Standart?.ToString();
                refference            = componentItem.Product?.Reference;
                effectivity           = componentItem.Product?.IsEffectivity;
                name                  = componentItem.Product?.Name;
                description           = componentItem.Description;
                serialNumber          = componentItem.SerialNumber;
                code                  = componentItem.Product != null ? componentItem.Product.Code :componentItem.Code;
                classString           = componentItem.GoodsClass.ToString();
                batchNumber           = componentItem.BatchNumber;
                idNumber              = componentItem.IdNumber;
                position              = componentItem.TransferRecords.GetLast()?.State?.ToString();
                status                = componentItem.ComponentStatus.ToString();
                location              = componentItem.Location.ToString();
                facility              = componentItem.Location.LocationsType?.ToString() ?? LocationsType.Unknown.ToString();
                maintenanceTypeString =
                    componentItem.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ComponentsAndParts)
                                                ? componentItem.MaintenanceControlProcess.ShortName
                                                : componentItem.LifeLimit.IsNullOrZero()
                                                        ? ""
                                                        : MaintenanceControlProcess.HT.ShortName;
                transferDate       = componentItem.TransferRecords.GetLast().TransferDate;
                firstPerformance   = componentItem.LifeLimit;
                warranty           = componentItem.Warranty;
                warrantyRemain     = componentItem.NextPerformance?.WarrantlyRemains ?? Lifelength.Null;
                kitRequieredString = componentItem.Kits.Count > 0 ? componentItem.Kits.Count + " kits" : "";
                kitCount           = componentItem.Kits.Count;
                bool isComponent =
                    componentItem.GoodsClass.IsNodeOrSubNodeOf(new IDictionaryTreeItem[]
                {
                    GoodsClass.ComponentsAndParts,
                    GoodsClass.ProductionAuxiliaryEquipment,
                });

                quantity              = isComponent && componentItem.ItemId > 0 ? 1 : componentItem.Quantity;
                quantityString        = quantity.ToString();
                quantityIn            = isComponent && componentItem.ItemId > 0 ? 1 : componentItem.QuantityIn;
                quantityInString      = $"{quantityIn:0.##}" + (componentItem.Measure != null ? " " + componentItem.Measure + "(s)" : "") + componentItem.Packing;
                needWpQuantity        = Math.Round(componentItem.NeedWpQuantity, 2);
                reserve               = quantity - needWpQuantity;
                shouldBeOnStock       = componentItem.ShouldBeOnStock;
                shouldBeOnStockString = componentItem.ShouldBeOnStock > 0 ? "Yes" : "No";
                manHours              = componentItem.ManHours;
                remarks               = componentItem.Remarks;
                hiddenRemarks         = componentItem.HiddenRemarks;
                isPool      = componentItem.IsPOOL;
                IsDangerous = componentItem.IsDangerous;
                supplier    = componentItem.FromSupplier.ToString();

                if (componentItem.ProductCosts.Count > 0)
                {
                    var productost = componentItem.ProductCosts.FirstOrDefault();
                    unitPrice  = productost.UnitPrice;
                    totalPrice = productost.TotalPrice;
                    shipPrice  = productost.ShipPrice;
                    subTotal   = productost.SubTotal;
                    tax1       = productost.Tax;
                    tax2       = productost.Tax1;
                    tax3       = productost.Tax2;
                    total      = productost.Total;
                    currency   = productost.Currency.ToString();
                }


                TransferRecord tr = componentItem.TransferRecords.GetLast();
                if (tr.FromAircraftId == 0 &&
                    tr.FromBaseComponentId == 0 &&
                    tr.FromStoreId == 0 &&
                    tr.FromSupplierId == 0 &&
                    tr.FromSpecialistId == 0)
                {
                    from = componentItem.Suppliers.ToString();
                }
                else
                {
                    from = DestinationHelper.FromObjectString(tr);
                }
            }
            else if (parent is ComponentDirective)
            {
                ComponentDirective dd = (ComponentDirective)parent;
                author = GlobalObjects.CasEnvironment.GetCorrector(dd);
                if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
                {
                    firstPerformance = dd.Threshold.FirstPerformanceSinceNew;
                }
                if (dd.LastPerformance != null)
                {
                    lastPerformanceString =
                        SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate) + " " +
                        dd.LastPerformance.OnLifelength;
                    lastPerformance = dd.LastPerformance.OnLifelength;
                }
                if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero())
                {
                    repeatInterval = dd.Threshold.RepeatInterval;
                }
                approx  = dd.NextPerformanceDate;
                next    = dd.NextPerformanceSource;
                remains = dd.Remains;
                ata     = dd.ParentComponent.Product?.ATAChapter ?? dd.ParentComponent.ATAChapter;
                maintenanceTypeString = dd.ParentComponent.MaintenanceControlProcess.ShortName;
                warranty           = dd.Threshold.Warranty;
                kitRequieredString = dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : "";
                kitCount           = dd.Kits.Count;
                manHours           = dd.ManHours;
                remarks            = dd.Remarks;
                hiddenRemarks      = dd.HiddenRemarks;
                workType           = dd.DirectiveType.ToString();
                position           = "    " + dd.ParentComponent.TransferRecords.GetLast()?.State?.ToString();
                isPool             = dd.IsPOOL;
                IsDangerous        = dd.IsDangerous;
                partNumber         = "    " + (dd.ParentComponent.Product?.PartNumber ?? dd.ParentComponent.PartNumber);
                altPartNumber      = "    " + (dd.ParentComponent.Product?.AltPartNumber ?? dd.ParentComponent.ALTPartNumber);
                standart           = dd.ParentComponent.Product?.Standart?.ToString() ?? dd.ParentComponent.Standart?.ToString();
                name           = "    " + dd.ParentComponent.Product?.Name;
                description    = "    " + dd.ParentComponent.Description;
                serialNumber   = "    " + dd.ParentComponent.SerialNumber;
                classString    = dd.ParentComponent.GoodsClass.ToString();
                warrantyRemain = dd.NextPerformance?.WarrantlyRemains ?? Lifelength.Null;
            }
            else
            {
                ata = (AtaChapter)GlobalObjects.CasEnvironment.GetDictionary <AtaChapter>().GetItemById(21);
            }

            subItems.Add(CreateRow(id, id));
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(refference, refference));
            subItems.Add(CreateRow(partNumber, partNumber));
            subItems.Add(CreateRow(altPartNumber, altPartNumber));
            subItems.Add(CreateRow(standart, standart));
            subItems.Add(CreateRow(name, name));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(serialNumber, serialNumber));
            subItems.Add(CreateRow(classString, classString));
            subItems.Add(CreateRow(batchNumber, batchNumber));
            subItems.Add(CreateRow(idNumber, idNumber));
            subItems.Add(CreateRow(position.ToUpper(), position));
            subItems.Add(CreateRow(status, status));
            subItems.Add(CreateRow(location, location));
            subItems.Add(CreateRow(facility, facility));
            subItems.Add(CreateRow(from, from));
            subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime()
                                ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate));
            subItems.Add(CreateRow(workType, workType));
            subItems.Add(CreateRow(needWpQuantity.ToString(), needWpQuantity));
            subItems.Add(CreateRow(reserve.ToString(), reserve));
            subItems.Add(CreateRow(quantityString, quantity));
            subItems.Add(CreateRow(shouldBeOnStockString, shouldBeOnStock));
            subItems.Add(CreateRow(quantityInString, quantityIn));
            subItems.Add(CreateRow(unitPrice.ToString(), unitPrice));
            subItems.Add(CreateRow(totalPrice.ToString(), totalPrice));
            subItems.Add(CreateRow(shipPrice.ToString(), shipPrice));
            subItems.Add(CreateRow(subTotal.ToString(), subTotal));
            subItems.Add(CreateRow(tax1.ToString(), tax1));
            subItems.Add(CreateRow(tax2.ToString(), tax2));
            subItems.Add(CreateRow(tax3.ToString(), tax3));
            subItems.Add(CreateRow(total.ToString(), total));
            subItems.Add(CreateRow(currency, currency));
            subItems.Add(CreateRow(supplier, supplier));
            subItems.Add(CreateRow(code, code));
            subItems.Add(CreateRow(remarks, remarks));
            subItems.Add(CreateRow(effectivity, effectivity));
            subItems.Add(CreateRow(isPool ? "Yes" : "No", isPool));
            subItems.Add(CreateRow(IsDangerous ? "Yes" : "No", IsDangerous));
            subItems.Add(CreateRow(maintenanceTypeString, maintenanceTypeString));
            subItems.Add(CreateRow(manHours.ToString(), manHours));
            subItems.Add(CreateRow(firstPerformance.ToString(), firstPerformance));
            subItems.Add(CreateRow(repeatInterval.ToString(), repeatInterval));
            subItems.Add(CreateRow(timesString, times));
            subItems.Add(CreateRow(approx != null
                                ? SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)approx) + " " + next
                                : next != null && !next.IsNullOrZero()
                                        ? next.ToString()
                                        : "", approx == null ? DateTimeExtend.GetCASMinDateTime() : (DateTime)approx));
            subItems.Add(CreateRow(remains != null && !remains.IsNullOrZero()
                                ? remains.ToString()
                                : "", remains ?? Lifelength.Null));
            subItems.Add(CreateRow(lastPerformanceString, lastPerformance));
            subItems.Add(CreateRow(warranty.ToString(), warranty));
            subItems.Add(CreateRow(warrantyRemain.ToString(), warrantyRemain));
            subItems.Add(CreateRow(kitRequieredString, kitCount));
            subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
Пример #8
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);
                            }
                        }
                    }
                }
            }
        }
        public void CalculateLifeLength()
        {
            //изменение значения наработки агрегата на момент установки
            if (ComponentTCSNOnInstall.IsNullOrZero())
            {
                return;                                       //разбанить поля
            }
            //if (ComponentCurrentTSNCSN != Lifelength.Null)
            //{
            //    Lifelength tempLifelength = new Lifelength(ComponentCurrentTSNCSN);
            //    tempLifelength.Substract(ComponentTCSNOnInstall);
            //    ComponentTCSI = tempLifelength;
            //}

            Lifelength aircraftCurrentTSN =
                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((Aircraft)_currentAircraft);
            Lifelength tempLifelength = null;

            //Расчитывание текущей наработки агрегата
            if (!ComponentTCSI.IsNullOrZero())
            {
                tempLifelength = new Lifelength(ComponentTCSI);
            }
            else if (!AircraftTCSNOnInstall.IsNullOrZero() && _currentAircraft is Aircraft)
            {
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(AircraftTCSNOnInstall);
            }

            if (tempLifelength != null && !tempLifelength.IsNullOrZero())
            {
                tempLifelength.Add(ComponentTCSNOnInstall);
                ComponentCurrentTSNCSN = tempLifelength;
            }
            else
            {
                ComponentCurrentTSNCSN = Lifelength.Null;
            }

            //расчет наработки с момента установки
            if (!ComponentTCSNOnInstall.IsNullOrZero() && !ComponentCurrentTSNCSN.IsNullOrZero())
            {
                tempLifelength = new Lifelength(ComponentCurrentTSNCSN);
                tempLifelength.Substract(ComponentTCSNOnInstall);
                ComponentTCSI = tempLifelength;
            }
            else if (!AircraftTCSNOnInstall.IsNullOrZero() && !aircraftCurrentTSN.IsNullOrZero())
            {
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(AircraftTCSNOnInstall);
                ComponentTCSI = tempLifelength;
            }
            else
            {
                ComponentTCSI = Lifelength.Null;
            }

            //расчет наработки самолета на момент установки
            if (!ComponentTCSI.IsNullOrZero())
            {
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(ComponentTCSI);
                AircraftTCSNOnInstall = tempLifelength;
            }
            else if (!ComponentCurrentTSNCSN.IsNullOrZero() && !ComponentTCSNOnInstall.IsNullOrZero())
            {
                Lifelength temp2 = new Lifelength(ComponentCurrentTSNCSN);
                temp2.Substract(ComponentTCSNOnInstall);
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(temp2);
                AircraftTCSNOnInstall = tempLifelength;
            }
            else
            {
                AircraftTCSNOnInstall = Lifelength.Null;
            }
        }
Пример #10
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="reportedDirective">Добавлямая директива</param>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddDirectiveToDataset(Directive reportedDirective, DirectivesListDataSet destinationDataSet)
        {
            string references = reportedDirective.Paragraph;
            string title;
            string eo;
            string sb;

            string s1 = reportedDirective.Title;

            if (!string.IsNullOrEmpty(reportedDirective.Paragraph.Trim()))
            {
                s1 += "\n§ " + reportedDirective.Paragraph;
            }

            if (_directiveType == DirectiveType.EngineeringOrders)
            {
                title = reportedDirective.EngineeringOrders;
                sb    = s1;
                eo    = reportedDirective.ServiceBulletinNo;
            }
            else if (_directiveType == DirectiveType.SB)
            {
                title = reportedDirective.ServiceBulletinNo;
                sb    = s1;
                eo    = reportedDirective.EngineeringOrders;
            }
            else
            {
                title = s1;
                eo    = reportedDirective.EngineeringOrders;
                sb    = reportedDirective.ServiceBulletinNo;
            }
            Lifelength sinceNewThreshold = Lifelength.Null, sinceEffDateThreshold = Lifelength.Null;
            Lifelength sinceEffDateCompliance = Lifelength.Null;
            Lifelength sinceNewRemain = Lifelength.Null, sinceEffDateRemain = Lifelength.Null;
            Lifelength firstCompliance = Lifelength.Null,
                       lastCompliance = Lifelength.Null,
                       repeatInterval = Lifelength.Null, remain = Lifelength.Null;
            string firstComplianceDate = "",
                   lastComplianceDate = "", sinceNewComplianceDate = "";
            Lifelength used = Lifelength.Null;

            string remarks  = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks;
            string performanceType = reportedDirective.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                         ? "W.O.F"
                                         : "W.O.L";
            string effectivityDate = reportedDirective.Threshold.EffectiveDate.ToString("dd.MM.yyyy");
            string equipment       = reportedDirective.NDTType.ShortName;
            string kits            = "";
            int    num             = 1;

            foreach (AccessoryRequired kit in reportedDirective.Kits)
            {
                kits += num + ": " + kit.PartNumber + "\n";
                num++;
            }
            //TODO:(Evgenii Babak) расчетом ресурсов должен заниматься калькулятор
            //расчет остатка с даты производства и с эффективной даты
            //расчет остатка от выполнения с даты производтсва
            if (reportedDirective.Threshold.FirstPerformanceSinceNew != null)
            {
                sinceNewThreshold = reportedDirective.Threshold.FirstPerformanceSinceNew;
                if (sinceNewThreshold.Days != null)
                {
                    sinceNewComplianceDate =
                        _manufactureDate.AddDays(sinceNewThreshold.Days.Value).ToString(
                            new GlobalTermsProvider()["DateFormat"].ToString());
                }
                if (reportedDirective.LastPerformance == null)
                {
                    sinceNewRemain.Add(reportedDirective.Threshold.FirstPerformanceSinceNew);
                    sinceNewRemain.Substract(_current);
                    sinceNewRemain.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew);
                }
            }
            if (reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate != null)
            {
                sinceEffDateThreshold = reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate;
                if (reportedDirective.Threshold.EffectiveDate < DateTime.Today)
                {
                    sinceEffDateCompliance =
                        GlobalObjects.CasEnvironment.Calculator.
                        GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, reportedDirective.Threshold.EffectiveDate);
                }

                sinceEffDateCompliance.Add(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate);
                sinceEffDateCompliance.Resemble(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate);


                sinceEffDateRemain.Add(reportedDirective.Remains);
            }

            GlobalObjects.PerformanceCalculator.GetNextPerformance(reportedDirective);
            if (reportedDirective.LastPerformance != null)
            {
                firstComplianceDate =
                    reportedDirective.PerformanceRecords[0].RecordDate.ToString(
                        new GlobalTermsProvider()["DateFormat"].ToString());
                firstCompliance = reportedDirective.PerformanceRecords[0].OnLifelength;

                if (reportedDirective.Threshold.RepeatInterval != null)
                {
                    repeatInterval = reportedDirective.Threshold.RepeatInterval;
                }

                lastComplianceDate =
                    reportedDirective.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
                lastCompliance = reportedDirective.LastPerformance.OnLifelength;

                used.Add(_current);
                used.Substract(reportedDirective.LastPerformance.OnLifelength);

                if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero())
                {
                    remain.Add(reportedDirective.NextPerformanceSource);
                    remain.Substract(_current);
                    remain.Resemble(reportedDirective.Threshold.RepeatInterval);
                }
            }

            string nextComplianceDate =
                reportedDirective.NextPerformanceDate != null
                    ? ((DateTime)reportedDirective.NextPerformanceDate).ToString(new GlobalTermsProvider()["DateFormat"].ToString())
                    : "";


            if (!firstCompliance.IsNullOrZero() && repeatInterval.IsNullOrZero())
            {
                lastComplianceDate = "";
                lastCompliance     = Lifelength.Zero;
            }

            if (!firstCompliance.IsNullOrZero())
            {
                //remain = Lifelength.Zero;
                sinceEffDateRemain = Lifelength.Zero;
            }

            Lifelength      nextCompliance = reportedDirective.NextPerformanceSource;
            NextPerformance np             = reportedDirective.NextPerformance;

            destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.Applicability,
                                                           reportedDirective.IsApplicability ? $"Applicable / {reportedDirective.Remarks}" : $"Not Applicable / {reportedDirective.Remarks}",
                                                           reportedDirective.HiddenRemarks,
                                                           reportedDirective.Description,
                                                           reportedDirective.Title,
                                                           references,
                                                           reportedDirective.WorkType.ToString(),
                                                           reportedDirective.Status.FullName,
                                                           effectivityDate,
                                                           sinceNewThreshold.Hours ?? 0,
                                                           sinceNewThreshold.Cycles ?? 0,
                                                           sinceNewComplianceDate,
                                                           performanceType,
                                                           sinceNewRemain.Hours ?? 0,
                                                           sinceNewRemain.Cycles ?? 0,
                                                           sinceNewRemain.Days ?? 0,
                                                           sinceEffDateThreshold.Hours ?? 0,
                                                           sinceEffDateThreshold.Cycles ?? 0,
                                                           sinceEffDateThreshold.Days != null ? sinceEffDateThreshold.Days.ToString() : "",
                                                           performanceType,
                                                           sinceEffDateRemain.Hours ?? 0,
                                                           sinceEffDateRemain.Cycles ?? 0,
                                                           sinceEffDateRemain.Days ?? 0,
                                                           firstComplianceDate,
                                                           firstCompliance.Hours ?? 0,
                                                           firstCompliance.Cycles ?? 0,
                                                           reportedDirective.Threshold.FirstPerformanceToStrings(),
                                                           repeatInterval.Days ?? 0,
                                                           repeatInterval.Hours ?? 0,
                                                           repeatInterval.Cycles ?? 0,
                                                           repeatInterval.ToStrings(),
                                                           lastComplianceDate,
                                                           lastCompliance.Hours ?? 0,
                                                           lastCompliance.Cycles ?? 0,
                                                           reportedDirective.LastPerformance != null
                                                                ? reportedDirective.LastPerformance.ToStrings("/")
                                                                : "",
                                                           used.Days ?? 0,
                                                           used.Hours ?? 0,
                                                           used.Cycles ?? 0,
                                                           nextComplianceDate,
                                                           nextCompliance.Hours ?? 0,
                                                           nextCompliance.Cycles ?? 0,
                                                           np != null ? np.ToStrings("/") : "",
                                                           remain.Days != null ? remain.Days.ToString() : "",
                                                           remain.Hours ?? 0,
                                                           remain.Cycles ?? 0,
                                                           reportedDirective.Remains.ToStrings(),
                                                           reportedDirective.Condition.ToString(),
                                                           reportedDirective.Cost,
                                                           reportedDirective.ManHours,
                                                           kits,
                                                           equipment,
                                                           reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.ShortName : "",
                                                           reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.FullName : "",
                                                           reportedDirective.ADType == ADType.Airframe ? "AF" : "AP",
                                                           sb,
                                                           eo != "" ?'(' + eo + ')' : "", "", "");
        }
Пример #11
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddBaseDetailToDataset(AircraftTechicalConditionDataSet destinationDataSet)
        {
            if (_reportedAircraft == null)
            {
                return;
            }

            int engineNum = 1;

            foreach (BaseComponent baseDetail in _aircraftBaseDetails.Where(bd => bd.BaseComponentType == BaseComponentType.Engine ||
                                                                            bd.BaseComponentType == BaseComponentType.Apu))
            {
                if (baseDetail.BaseComponentType == BaseComponentType.Frame)
                {
                    continue;
                }

                string position = "";
                if (baseDetail.BaseComponentType == BaseComponentType.Engine)
                {
                    position = engineNum.ToString();
                    engineNum++;
                }
                else if (baseDetail.BaseComponentType == BaseComponentType.Apu)
                {
                    position = "ВСУ";
                }
                Lifelength currentDetailSource =
                    GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(baseDetail);

                string status        = baseDetail.Serviceable ? "Serviceable" : "Unserviceable";
                string sinceNewHours = currentDetailSource.Hours != null?currentDetailSource.Hours.ToString() : "";

                string sinceNewCycles = currentDetailSource.Cycles != null?currentDetailSource.Cycles.ToString() : "";

                string sinceNewDays = currentDetailSource.Days != null?currentDetailSource.Days.ToString() : "";

                Lifelength lifeLimit      = baseDetail.LifeLimit;
                string     lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : "";

                string lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : "";

                string lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : "";

                Lifelength remain = Lifelength.Null;
                if (!lifeLimit.IsNullOrZero())
                {
                    remain = new Lifelength(lifeLimit);
                    remain.Substract(currentDetailSource);
                    remain.Resemble(lifeLimit);
                }
                string remainHours = remain.Hours != null?remain.Hours.ToString() : "";

                string remainCycles = remain.Cycles != null?remain.Cycles.ToString() : "";

                string remainDays = remain.Days != null?remain.Days.ToString() : "";

                Lifelength betweenOverhaul = Lifelength.Null, lastCompliance = Lifelength.Null;
                DateTime   lastOverhaulDate = DateTime.MinValue;

                string lastOverhaulDateString = "", lastOverhaulHours = "", lastOverhaulCycles = "";
                string remainOverhaulDays = "", remainOverhaulHours = "", remainOverhaulCycles = "";
                string type = "";

                if (baseDetail.BaseComponentType == BaseComponentType.LandingGear)
                {
                    type = "Part C: Landing Gears";
                }
                if (baseDetail.BaseComponentType == BaseComponentType.Engine)
                {
                    type = "Part B: Engines";
                }
                if (baseDetail.BaseComponentType == BaseComponentType.Apu)
                {
                    type = "Part D: Auxiliary Power Unit ";
                }

                #region поиск последнего ремонта и расчет времени, прошедшего с него
                //поиск директив деталей
                List <ComponentDirective> directives = GlobalObjects.ComponentCore.GetComponentDirectives(baseDetail, true);
                //поиск директивы ремонта
                List <ComponentDirective> overhauls =
                    directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList();
                //поиск последнего ремонта
                if (overhauls.Count != 0)
                {
                    ComponentDirective lastOverhaul = null;
                    foreach (ComponentDirective d in overhauls)
                    {
                        if (d.LastPerformance == null || d.LastPerformance.RecordDate <= lastOverhaulDate)
                        {
                            continue;
                        }

                        lastOverhaulDate = d.LastPerformance.RecordDate;
                        lastOverhaul     = d;
                    }

                    if (lastOverhaul != null)
                    {
                        betweenOverhaul        = lastOverhaul.Threshold.RepeatInterval;
                        lastOverhaulDateString = lastOverhaulDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
                        lastOverhaulHours      = lastOverhaul.LastPerformance.OnLifelength.Hours != null
                                                ? lastOverhaul.LastPerformance.OnLifelength.Hours.ToString()
                                                : "";

                        lastOverhaulCycles = lastOverhaul.LastPerformance.OnLifelength.Cycles != null
                                                ? lastOverhaul.LastPerformance.OnLifelength.Cycles.ToString()
                                                : "";

                        if (lastOverhaul.NextPerformance != null)
                        {
                            NextPerformance np = lastOverhaul.NextPerformance;
                            remainOverhaulHours = np.Remains.Hours != null?np.Remains.Hours.ToString() : "";

                            remainOverhaulCycles = np.Remains.Cycles != null?np.Remains.Cycles.ToString() : "";

                            remainOverhaulDays = np.Remains.Days != null?np.Remains.Days.ToString() : "";
                        }

                        GlobalObjects.PerformanceCalculator.GetNextPerformance(lastOverhaul);
                        if (lastOverhaul.NextPerformanceDate != null)
                        {
                            remainOverhaulHours = lastOverhaul.Remains.Hours != null?lastOverhaul.Remains.Hours.ToString() : "";

                            remainOverhaulCycles = lastOverhaul.Remains.Cycles != null?lastOverhaul.Remains.Cycles.ToString() : "";

                            remainOverhaulDays = lastOverhaul.Remains.Days != null?lastOverhaul.Remains.Days.ToString() : "";
                        }
                    }
                    else
                    {
                        betweenOverhaul = overhauls[0].Threshold.RepeatInterval;
                    }
                }

                ComponentDirective lastPerformance = directives.Where(d => d.LastPerformance != null).
                                                     OrderBy(d => d.LastPerformance.RecordDate).LastOrDefault();
                if (lastPerformance != null)
                {
                    lastCompliance.Add(currentDetailSource);
                    lastCompliance.Substract(lastPerformance.LastPerformance.OnLifelength);
                }
                #endregion

                destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(baseDetail.PartNumber,
                                                                         baseDetail.SerialNumber,
                                                                         baseDetail.Model != null ? baseDetail.Model.ToString() : "",
                                                                         type,
                                                                         baseDetail.GetParentAircraftRegNumber(),
                                                                         position,
                                                                         status,
                                                                         lifeLimitHours,
                                                                         lifeLimitCycles,
                                                                         lifeLimitDays,
                                                                         sinceNewHours,
                                                                         sinceNewCycles,
                                                                         sinceNewDays,
                                                                         remainCycles,
                                                                         remainHours,
                                                                         remainDays,
                                                                         lastOverhaulDateString,
                                                                         lastOverhaulHours,
                                                                         lastOverhaulCycles,
                                                                         betweenOverhaul.Days != null ? betweenOverhaul.Days.ToString() : "",
                                                                         betweenOverhaul.Hours != null ? betweenOverhaul.Hours.ToString() : "",
                                                                         betweenOverhaul.Cycles != null ? betweenOverhaul.Hours.ToString() : "",
                                                                         remainOverhaulDays,
                                                                         remainOverhaulHours,
                                                                         remainOverhaulCycles,
                                                                         lastCompliance.Days != null ? lastCompliance.Days.ToString() : "",
                                                                         lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "",
                                                                         lastCompliance.Cycles != null ? lastCompliance.Hours.ToString() : "",
                                                                         baseDetail.ManufactureDate.ToString("dd.MM.yyyy"));
            }
        }