コード例 #1
0
 public MaintenanceInterval(
     MaintenanceType maintenanceType,
     MeasureUnit measureUnit,
     int?minUsage          = null,
     int?maxUsage          = null,
     int quantityInCycle   = 1,
     TimePeriod?timePeriod = null,
     int?periodQuantity    = null
     )
 {
     MaintenanceType = maintenanceType;
     MeasureUnit     = measureUnit;
     TimePeriod      = timePeriod;
     PeriodQuantity  = periodQuantity;
     MinUsage        = minUsage;
     QuantityInCycle = quantityInCycle;
     MaxUsage        = maxUsage;
 }
コード例 #2
0
 internal LastMaintenance(MaintenanceType maintenanceType, DateTime?date, int?usage = null)
 {
     MaintenanceType          = maintenanceType;
     LastMaintenanceDate      = date;
     UsageFromLastMaintenance = usage;
 }
コード例 #3
0
        public MaintenancePlan(MaintenanceObject maintenanceObject, MaintenanceType maintenanceType, DateTime date, bool isTransfer = false, bool isOffer = false, MaintenanceReason offer = null)
        {
            Object          = maintenanceObject;
            MaintenanceType = maintenanceType;
            MaintenanceDate = date;
            IsOffer         = isOffer;
            OfferReason     = offer;
            IsTransfer      = isTransfer;

            var map = Object.LastMaintenance.ToDictionary(x => x.MaintenanceType.Id);

            //фиксируем наработку для плана
            if (map.ContainsKey(maintenanceType.Id))
            {
                UsageForPlan = map[maintenanceType.Id].UsageFromLastMaintenance;
            }

            //Фиксируем предыдущий ремонт
            var previous = Object.Maintenance.OrderBy(x => x.StartMaintenance).LastOrDefault();

            if (previous != null)
            {
                var last = map[previous.MaintenanceType.Id];

                PreviousDate            = last.LastMaintenanceDate;
                PreviousMaintenanceType = last.MaintenanceType;
                PreviousUsage           = last.UsageFromLastMaintenance;
            }
            //Если предыдущего обслуживания мы не нашли, то пытаемся взять дату предыдущего обслуживания в данных с последних ремонтов LastMaintenance
            else
            {
                var intervals = Object.Intervals.ToList();
                intervals.Sort();

                int?     type     = null;
                DateTime?lastDate = null;

                intervals.ForEach(x =>
                {
                    if (type != null && lastDate != null)
                    {
                        var _date = map[x.MaintenanceType.Id].LastMaintenanceDate;

                        if (_date != null && _date > lastDate)
                        {
                            type     = x.MaintenanceType.Id;
                            lastDate = _date;
                        }
                    }
                    else
                    {
                        type     = x.MaintenanceType.Id;
                        lastDate = map[type.Value].LastMaintenanceDate;
                    }
                });

                if (type != null && lastDate != null)
                {
                    PreviousDate            = map[type.Value].LastMaintenanceDate;
                    PreviousMaintenanceType = map[type.Value].MaintenanceType;
                    PreviousUsage           = map[type.Value].UsageFromLastMaintenance;
                }
            }
        }