Ejemplo n.º 1
0
        /*
         * События контрола
         */

        #region private void TextTimePeriodLeave(object sender, EventArgs e)
        /// <summary>
        /// Когда пользователь ввел интервал времени и уходит с контрола мы проверяем данные и приводим их в нужный формат - например удаляем лишние пробелы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextTimePeriodLeave(object sender, EventArgs e)
        {
            TimeSpan time1, time2;

            if (UsefulMethods.ParseTimePeriod(textTimePeriod.Text, out time1, out time2))
            {
                textTimePeriod.Text = UsefulMethods.TimePeriodToString(time1, time2);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Обновляет значения полей
 /// </summary>
 public override void FillControls()
 {
     BeginUpdate();
     if (Flight != null)
     {
         textOutIn.Text      = UsefulMethods.TimePeriodToString(Flight.OutTime, Flight.InTime);
         textTakeOffLDG.Text = UsefulMethods.TimePeriodToString(Flight.TakeOffTime, Flight.LdgTime);
     }
     else
     {
         textOutIn.Text = textTakeOffLDG.Text = "";
     }
     EndUpdate();
 }
Ejemplo n.º 3
0
        private string[] GetItemsString(AircraftFlight item)
        {
            Lifelength perMonth = GetPerMonth(sortedAircraftsFlights.IndexOf(item));
            Lifelength acTft    = GetAC_TFT(sortedAircraftsFlights.IndexOf(item));

            return(new[]
                   { item.FlightDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()),
                     item.FlightNo,
                     item.StationFrom + " - " + item.StationTo,
                     "",
                     "",
                     UsefulMethods.TimeToString(item.FlightTime) + " (" + UsefulMethods.TimePeriodToString(item.TakeOffTime, item.LdgTime) + ")",
                     perMonth == null ? "" : perMonth.ToHoursMinutesAndCyclesFormat(),
                     acTft == null ? "" : acTft.ToHoursAndCyclesFormat("hrs", "cyc") });
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Обновляет значения полей
 /// </summary>
 public override void FillControls()
 {
     BeginUpdate();
     if (Flight != null && Flight.FluidsCondition != null)
     {
         //textAdded.Text = Flight.FluidsCondition.HydraulicFluidAdded.ToString();
         //textOnBoard.Text = Flight.FluidsCondition.HydraulicFluidOnBoard.ToString();
         checkDeIce.Checked  = Flight.FluidsCondition.GroundDeIce;
         textTimePeriod.Text = UsefulMethods.TimePeriodToString(Flight.FluidsCondition.AntiIcingStartTime, Flight.FluidsCondition.AntiIcingEndTime);
         textFluidType.Text  = Flight.FluidsCondition.AntiIcingFluidType;
         textAEACode.Text    = Flight.FluidsCondition.AEACode;
     }
     else
     {
         //textAdded.Text = textOnBoard.Text = textTimePeriod.Text = textFluidType.Text = textAEACode.Text = "";
         checkDeIce.Checked = false;
     }
     EndUpdate();
 }
Ejemplo n.º 5
0
        protected override List <CustomCell> GetListViewSubItems(AircraftFlight item)
        {
            var subItems = new List <CustomCell>();

            var dateString = item.FlightDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var date       = item.FlightDate.Date.AddMinutes(item.OutTime);
            var aircraft   = $"{item.Aircraft} {item.Aircraft.Model.ShortName}";

            var route            = item.StationFromId.ShortName + " - " + item.StationToId.ShortName;
            var flightTimeString = UsefulMethods.TimeToString(new TimeSpan(0, 0, item.FlightTimeTotalMinutes, 0)) + " (" +
                                   UsefulMethods.TimePeriodToString(new TimeSpan(0, 0, item.TakeOffTime, 0),
                                                                    new TimeSpan(0, 0, item.LDGTime, 0)) + ")";

            var perDaysFlight = Lifelength.Zero;
            var perDaysBlock  = Lifelength.Zero;
            var flights       = Flights.Where(f => f.FlightDate.Date.AddMinutes(f.TakeOffTime) <=
                                              item.FlightDate.Date.AddMinutes(item.TakeOffTime)).ToList();

            foreach (var aircraftFlight in flights)
            {
                perDaysFlight.Add(aircraftFlight.FlightTimeLifelength);
                perDaysBlock.Add(aircraftFlight.BlockTimeLifelenght);
            }

            var author = GlobalObjects.CasEnvironment.GetCorrector(item);

            return(new List <CustomCell>
            {
                CreateRow(dateString, Tag = date),
                CreateRow(aircraft, item.Aircraft),
                CreateRow(item.Specialization.ToString(), item.Specialization),
                CreateRow(route, route),
                CreateRow(flightTimeString, item.FlightTime),
                CreateRow(UsefulMethods.TimeToString(item.BlockTime), item.BlockTime),
                CreateRow(perDaysFlight.ToHoursMinutesAndCyclesFormat("", ""), perDaysFlight),
                CreateRow(perDaysBlock.ToHoursMinutesAndCyclesFormat("", ""), perDaysBlock),
                CreateRow(item.NightTime.ToString(), item.NightTime),
                CreateRow(author, author)
            });
        }
Ejemplo n.º 6
0
        protected override List <CustomCell> GetListViewSubItems(AircraftFlight item)
        {
            //TODO (Evgenii Babak) : Вся логика должна быть в классе Calculator
            var subItems = new List <CustomCell>();

            var dateString = item.FlightDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var date       = item.FlightDate.Date.AddMinutes(item.OutTime);
            var atlb       = _atbs.GetItemById(item.ATLBId);
            var author     = GlobalObjects.CasEnvironment.GetCorrector(item);

            if (item.AtlbRecordType == AtlbRecordType.Flight)
            {
                var route            = item.StationFromId.ShortName + " - " + item.StationToId.ShortName;
                var flightTimeString = UsefulMethods.TimeToString(new TimeSpan(0, 0, item.FlightTimeTotalMinutes, 0)) + " (" +
                                       UsefulMethods.TimePeriodToString(new TimeSpan(0, 0, item.TakeOffTime, 0),
                                                                        new TimeSpan(0, 0, item.LDGTime, 0)) + ")";
                Color flightTimeColor;
                if (item.FlightTime.TotalMinutes == item.BlockTime.TotalMinutes)
                {
                    flightTimeColor = Color.Black;
                }
                else
                {
                    double persent = Math.Abs(1 - (item.FlightTime.TotalMinutes / item.BlockTime.TotalMinutes)) * 100;
                    if (persent <= 3)
                    {
                        flightTimeColor = Color.FromArgb(Highlight.Green.Color);
                    }
                    else if (persent <= 10)
                    {
                        flightTimeColor = Color.FromArgb(Highlight.Yellow.Color);
                    }
                    else
                    {
                        flightTimeColor = Color.FromArgb(Highlight.Red.Color);
                    }
                }
                var perDaysFlight = Lifelength.Zero;
                var perDaysBlock  = Lifelength.Zero;
                var flights       = _flights.Where(f => f.AtlbRecordType != AtlbRecordType.Maintenance && f.FlightDate.Date.AddMinutes(f.TakeOffTime) <=
                                                   item.FlightDate.Date.AddMinutes(item.TakeOffTime)).ToList();
                foreach (AircraftFlight aircraftFlight in flights)
                {
                    perDaysFlight.Add(aircraftFlight.FlightTimeLifelength);
                    perDaysBlock.Add(aircraftFlight.BlockTimeLifelenght);
                }

                var aircraftFlightLifelenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(item);
                var aircraftBlockLifelenght  = aircraftFlightLifelenght + (perDaysBlock - perDaysFlight);


                subItems.Add(CreateRow(item.PageNo, item.PageNo));
                subItems.Add(CreateRow(dateString, date));
                subItems.Add(CreateRow(item.FlightNumber.ToString(), item.FlightNumber));
                subItems.Add(CreateRow(route, route));
                subItems.Add(CreateRow(flightTimeString, item.FlightTime, flightTimeColor));
                subItems.Add(CreateRow(UsefulMethods.TimeToString(item.BlockTime), item.BlockTime, flightTimeColor));
                subItems.Add(CreateRow(perDaysFlight.ToHoursMinutesAndCyclesFormat("", ""), perDaysFlight));
                subItems.Add(CreateRow(perDaysBlock.ToHoursMinutesAndCyclesFormat("", ""), perDaysBlock));
                subItems.Add(CreateRow(aircraftFlightLifelenght.ToHoursMinutesAndCyclesFormat("", ""), aircraftFlightLifelenght));
                subItems.Add(CreateRow(aircraftBlockLifelenght.ToHoursMinutesAndCyclesFormat("", ""), aircraftFlightLifelenght));

                #region колонки для отображения наработок по двигателям и ВСУ

                foreach (BaseComponent baseComponent in _enginesAndAPU)
                {
                    bool shouldFillSubItems = false;

                    var baseComponentFlightLifeLenght = Lifelength.Null;
                    var baseComponentBlockLifeLenght  = Lifelength.Null;

                    var lastKnownTransferRecBeforFlight = baseComponent.TransferRecords.GetLastKnownRecord(item.FlightDate.Date);
                    if (lastKnownTransferRecBeforFlight != null &&
                        lastKnownTransferRecBeforFlight.DestinationObjectType == SmartCoreType.Aircraft &&
                        lastKnownTransferRecBeforFlight.DestinationObjectId == _parentAircraft.ItemId)
                    {
                        shouldFillSubItems = true;
                        var flightsWhichOccuredAfterInstallationOfBd = flights.Where(f => f.AtlbRecordType != AtlbRecordType.Maintenance && f.FlightDate.Date >= lastKnownTransferRecBeforFlight.RecordDate).ToList();

                        var perDaysFlightForBd = Lifelength.Zero;
                        var perDaysBlockForBd  = Lifelength.Zero;

                        foreach (var flight in flightsWhichOccuredAfterInstallationOfBd)
                        {
                            perDaysFlightForBd.Add(flight.FlightTimeLifelength);
                            perDaysBlockForBd.Add(flight.BlockTimeLifelenght);
                        }

                        baseComponentFlightLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(baseComponent, item);
                        baseComponentBlockLifeLenght  = baseComponentFlightLifeLenght + (perDaysBlockForBd - perDaysFlightForBd);
                    }

                    Color baseComponentTimeColor = Color.Black;

                    if (shouldFillSubItems && baseComponent.BaseComponentType != BaseComponentType.Apu)
                    {
                        var baseDetailFlightWorkTime = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(item, baseComponent);

                        if (item.FlightTime.TotalMinutes == Convert.ToDouble(baseDetailFlightWorkTime.TotalMinutes))
                        {
                            baseComponentTimeColor = Color.Black;
                        }
                        else
                        {
                            double persent = Math.Abs(1 - (Convert.ToDouble(baseDetailFlightWorkTime.TotalMinutes) / item.FlightTime.TotalMinutes)) * 100;
                            if (persent <= 3)
                            {
                                baseComponentTimeColor = Color.FromArgb(Highlight.Green.Color);
                            }
                            else if (persent <= 10)
                            {
                                baseComponentTimeColor = Color.FromArgb(Highlight.Yellow.Color);
                            }
                            else
                            {
                                baseComponentTimeColor = Color.FromArgb(Highlight.Red.Color);
                            }
                        }
                    }
                    var baseDetailHaveOverhaulDirective = BaseDetailHaveOverhaul(baseComponent);
                    var lastOverhaul = GetLastOverhaul(baseComponent);
                    if (baseComponent.BaseComponentType == BaseComponentType.Engine)
                    {
                        if (shouldFillSubItems)
                        {
                            subItems.Add(CreateListViewSubItem(baseComponentTimeColor, baseComponentFlightLifeLenght));
                            subItems.Add(CreateListViewSubItem(Color.Black, baseComponentBlockLifeLenght));
                            if (baseDetailHaveOverhaulDirective)
                            {
                                if (lastOverhaul != null)
                                {
                                    var sinceOverhaulFlight = baseComponentFlightLifeLenght.IsGreater(lastOverhaul.OnLifelength)
                                                                                ? baseComponentFlightLifeLenght - lastOverhaul.OnLifelength
                                                                                : Lifelength.Null;

                                    subItems.Add(CreateListViewSubItem(Color.Black, sinceOverhaulFlight));

                                    var sinceOverhaulBlock = baseComponentBlockLifeLenght.IsGreater(lastOverhaul.OnLifelength)
                                                                                ? baseComponentBlockLifeLenght - lastOverhaul.OnLifelength
                                                                                : Lifelength.Null;

                                    subItems.Add(CreateListViewSubItem(Color.Black, sinceOverhaulBlock));
                                }
                                else
                                {
                                    subItems.Add(CreateListViewSubItem("N/A"));
                                    subItems.Add(CreateListViewSubItem("N/A"));
                                }
                            }
                        }
                        else
                        {
                            subItems.Add(CreateListViewSubItem(string.Empty));
                            subItems.Add(CreateListViewSubItem(string.Empty));
                            if (baseDetailHaveOverhaulDirective)
                            {
                                subItems.Add(CreateListViewSubItem(string.Empty));
                                subItems.Add(CreateListViewSubItem(string.Empty));
                            }
                        }
                    }
                    else if (baseComponent.BaseComponentType == BaseComponentType.Apu)
                    {
                        if (shouldFillSubItems)
                        {
                            subItems.Add(CreateListViewSubItem(baseComponentTimeColor, baseComponentFlightLifeLenght));
                            if (baseDetailHaveOverhaulDirective)
                            {
                                if (lastOverhaul != null)
                                {
                                    var sinceOverhaulFlight = baseComponentFlightLifeLenght - lastOverhaul.OnLifelength;
                                    subItems.Add(CreateListViewSubItem(Color.Black, sinceOverhaulFlight));
                                }
                                else
                                {
                                    subItems.Add(CreateListViewSubItem("N/A"));
                                }
                            }
                        }
                        else
                        {
                            subItems.Add(CreateListViewSubItem(string.Empty));
                            if (baseDetailHaveOverhaulDirective)
                            {
                                subItems.Add(CreateListViewSubItem(string.Empty));
                            }
                        }
                    }
                }

                #endregion

                subItems.Add(CreateRow(atlb?.ATLBNo ?? "AtlB deleted", atlb?.ATLBNo));
                subItems.Add(CreateRow(item.ListViewChecksPerformed, item.ListViewChecksPerformed));
                subItems.Add(CreateRow(author, author));
            }
            else
            {
                subItems.Add(CreateRow(item.PageNo, item.PageNo));
                subItems.Add(CreateRow(dateString, date));
                subItems.Add(CreateRow(item.FlightNumber.ToString(), item.FlightNumber));
                subItems.Add(CreateRow(item.StationToId.ShortName, item.StationToId.ShortName));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow("", ""));
                subItems.Add(CreateRow("", ""));


                #region колонки для отображения наработок по двигателям и ВСУ

                foreach (var baseComponent in _enginesAndAPU)
                {
                    if (baseComponent.BaseComponentType == BaseComponentType.Engine)
                    {
                        subItems.Add(CreateRow("", ""));
                        subItems.Add(CreateRow("", ""));
                        if (baseComponent.ComponentDirectives.Count(dd => dd.DirectiveType == ComponentRecordType.Overhaul) > 0)
                        {
                            subItems.Add(CreateRow("", ""));
                            subItems.Add(CreateRow("", ""));
                        }
                    }
                    else if (baseComponent.BaseComponentType == BaseComponentType.Apu)
                    {
                        subItems.Add(CreateRow("", ""));
                        if (baseComponent.ComponentDirectives.Count(dd => dd.DirectiveType == ComponentRecordType.Overhaul) > 0)
                        {
                            subItems.Add(CreateRow("", ""));
                        }
                    }
                }

                #endregion

                subItems.Add(CreateRow(atlb?.ATLBNo, atlb?.ATLBNo));
                subItems.Add(CreateRow(item.ListViewChecksPerformed, item.ListViewChecksPerformed));
                subItems.Add(CreateRow(author, author));
            }


            return(subItems);
        }
Ejemplo n.º 7
0
        protected virtual void AddFlight(MonthlyUtilizationDataSet dataSet, AircraftFlight item, string groupName, int counter)
        {
            //TODO: (Evgenii Babak) сравнить подход в этом методе с подходом в MonthlyutilizationListView. Нужно вынести в отдельный метод BL
            var dateString       = item.FlightDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var route            = item.StationFromId.ShortName + " - " + item.StationToId.ShortName;
            var flightTimeString = UsefulMethods.TimeToString(new TimeSpan(0, 0, item.FlightTimeTotalMinutes, 0)) + " (" +
                                   UsefulMethods.TimePeriodToString(new TimeSpan(0, 0, item.TakeOffTime, 0),
                                                                    new TimeSpan(0, 0, item.LDGTime, 0)) + ")";
            var perDays = Lifelength.Zero;
            var flights = _currentFlights.Where(f => f.FlightDate.Date.AddMinutes(f.TakeOffTime) <=
                                                item.FlightDate.Date.AddMinutes(item.TakeOffTime)).ToList();

            foreach (var aircraftFlight in flights)
            {
                perDays.Add(aircraftFlight.FlightTimeLifelength);
            }
            var aircraftLifelenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(item);

            #region колонки для отображения наработок по двигателям и ВСУ

            var engine1 = "";
            var engine2 = "";
            var apu     = "";
            if (_engine1 != null)
            {
                engine1 = GetFlightLifelengthStringForBaseDetail(_engine1, item);
            }
            if (_engine2 != null)
            {
                engine2 = GetFlightLifelengthStringForBaseDetail(_engine2, item);
            }
            if (_apu != null)
            {
                apu = GetFlightLifelengthStringForBaseDetail(_apu, item);
            }

            #endregion

            var color = UsefulMethods.GetColorName(item);
            if (!item.Correct)
            {
                color = "White";
            }
            //if(color=="") color = aircraftFlight.Highlight.Name;


            dataSet.Items.AddItemsRow(dateString,
                                      item.FlightNumber.ToString(),
                                      route,
                                      "",
                                      item.Reference,
                                      item.PageNo,
                                      "",
                                      "",
                                      "1",
                                      flightTimeString,
                                      perDays.ToHoursMinutesAndCyclesFormat("", ""),
                                      aircraftLifelenght.ToHoursMinutesAndCyclesFormat("", ""),
                                      "",
                                      groupName,
                                      counter.ToString(), engine1, "", engine2, "", apu, "", color);
        }