/// <summary> /// Добавление дополнительной информации /// </summary> /// <param name="destinationDateSet"></param> private void AddAdditionalDataToDataSet(ForecastKitsDataSet destinationDateSet) { string reportFooter = new GlobalTermsProvider()["ReportFooter"].ToString(); string reportFooterPrepared = new GlobalTermsProvider()["ReportFooterPrepared"].ToString(); string reportFooterLink = new GlobalTermsProvider()["ProductWebsite"].ToString(); destinationDateSet.AdditionalDataTAble.AddAdditionalDataTAbleRow(_reportTitle, _operatorLogotype, _filterSelection, DateAsOf, reportFooter, reportFooterPrepared, reportFooterLink); }
protected virtual void AddForecastToDataSet(ForecastKitsDataSet destinationDataSet) { ForecastData fd = _forecast != null?_forecast.GetForecastDataFrame() : null; if (fd == null) { destinationDataSet.ForecastTable.AddForecastTableRow(0, 0, "", 0, 0, 0, ""); return; } double avgUtilizationCycles = fd.AverageUtilization.Cycles; double avgUtilizationHours = fd.AverageUtilization.Hours; string avgUtilizationType = fd.AverageUtilization.SelectedInterval.ToString(); int forecastCycles = fd.ForecastLifelength.Cycles != null ? (int)fd.ForecastLifelength.Cycles : 0; int forecastHours = fd.ForecastLifelength.Hours != null ? (int)fd.ForecastLifelength.Hours : 0; int forecastDays = fd.ForecastLifelength.Days != null ? (int)fd.ForecastLifelength.Days : 0; string forecastDate = ""; if (fd.SelectedForecastType == ForecastType.ForecastByDate) { forecastDate = SmartCore.Auxiliary.Convert.GetDateFormat(fd.ForecastDate); } else if (fd.SelectedForecastType == ForecastType.ForecastByPeriod) { forecastDate = SmartCore.Auxiliary.Convert.GetDateFormat(fd.LowerLimit) + " - " + SmartCore.Auxiliary.Convert.GetDateFormat(fd.ForecastDate); } else if (fd.SelectedForecastType == ForecastType.ForecastByCheck) { if (fd.NextPerformanceByDate) { forecastDate = fd.NextPerformanceString; } else { forecastDate = $"{fd.CheckName}. {SmartCore.Auxiliary.Convert.GetDateFormat(Convert.ToDateTime(fd.NextPerformance.PerformanceDate))}"; } } destinationDataSet.ForecastTable.AddForecastTableRow(avgUtilizationCycles, avgUtilizationHours, avgUtilizationType, forecastCycles, forecastHours, forecastDays, forecastDate); }
/// <summary> /// Построить источник данных (DataSet) для вывода в отчет /// </summary> /// <returns></returns> protected virtual DataSet GenerateDataSet() { ForecastKitsDataSet dataset = new ForecastKitsDataSet(); AddAircraftToDataset(dataset); AddDirectivesToDataSet(dataset); AddAdditionalDataToDataSet(dataset); AddForecastToDataSet(dataset); return(dataset); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddAircraftToDataset(ForecastKitsDataSet destinationDataSet) { if (_reportedAircraft == null) { destinationDataSet.AircraftDataTable.AddAircraftDataTableRow("", "", -1, -1, "", "", "", "", -1, -1, ""); return; } var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft); var manufactureDate = _reportedAircraft.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var serialNumber = _reportedAircraft.SerialNumber; var model = _reportedAircraft.Model.ToString(); var sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var registrationNumber = _reportedAircraft.RegistrationNumber; int averageUtilizationHours; int averageUtilizationCycles; string averageUtilizationType; if (_forecast == null) { var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(_reportedAircraft.AircraftFrameId); var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); averageUtilizationHours = (int)averageUtilization.Hours; averageUtilizationCycles = (int)averageUtilization.Cycles; averageUtilizationType = averageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } else { averageUtilizationHours = (int)_forecast.ForecastDatas[0].AverageUtilization.Hours; averageUtilizationCycles = (int)_forecast.ForecastDatas[0].AverageUtilization.Cycles; averageUtilizationType = _forecast.ForecastDatas[0].AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } var lineNumber = _reportedAircraft.LineNumber; var variableNumber = _reportedAircraft.VariableNumber; destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(serialNumber, manufactureDate, sinceNewHours, sinceNewCycles, registrationNumber, model, lineNumber, variableNumber, averageUtilizationHours, averageUtilizationCycles, averageUtilizationType); }
/// <summary> /// Добавление директив в таблицу данных /// </summary> /// <param name="dataset">Таблица, в которую добавляются данные</param> protected virtual void AddDirectivesToDataSet(ForecastKitsDataSet dataset) { //группировка по родительскому самолету IEnumerable <IGrouping <Product, AbstractAccessory> > products = _reportedDirectives.GroupBy(ak => ak.Product ?? new Product { GoodsClass = ak.GoodsClass, Standart = ak.Standart, PartNumber = ak.ParentString, Description = ak.Description }); foreach (IGrouping <Product, AbstractAccessory> product in products) { string type = GetAccessoryTypeString(product.First()); double quantity = 0; double totalProductCost = 0; if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.Tools) || product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ProductionAuxiliaryEquipment)) { quantity = product.Max(p => p.Quantity); totalProductCost = 0; } else if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ComponentsAndParts)) { foreach (AbstractAccessory accessoryRequired in product) { int qty = accessoryRequired.Quantity < 1 ? 1 : (int)accessoryRequired.Quantity; quantity += qty; totalProductCost += (qty * accessoryRequired.CostNew); } } else { foreach (AbstractAccessory accessoryRequired in product) { quantity += accessoryRequired.Quantity; totalProductCost += (accessoryRequired.Quantity * accessoryRequired.CostNew); } } dataset.KitsTable.AddKitsTableRow(product.Key.ToString(), $"{Math.Round(quantity, 2)} {product.Key.Measure.ShortName}", totalProductCost, _reportedAircraft != null ? _reportedAircraft + " " + _reportedAircraft.Model : "Unk", type); } }
/// <summary> /// Добавление директив в таблицу данных /// </summary> /// <param name="dataset">Таблица, в которую добавляются данные</param> protected virtual void AddDirectivesToDataSet(ForecastKitsDataSet dataset) { //группировка по родительскому самолету IEnumerable <IGrouping <Aircraft, BaseEntityObject> > groupByAircraft = _reportedDirectives.GroupBy(GlobalObjects.AircraftsCore.GetParentAircraft) .OrderBy(g => g.Key.ToString() + " " + g.Key.Model.ToString()); _filterSelection = ""; if (GlobalObjects.AircraftsCore.GetAircraftsCount() == groupByAircraft.Count()) { _filterSelection = "All"; } else { foreach (IGrouping <Aircraft, BaseEntityObject> byAircraft in groupByAircraft) { _filterSelection += (byAircraft.Key + "; "); } } List <AbstractAccessory> aircraftKits = _reportedDirectives.Select(GetParent) .Where(i => i is IKitRequired) .SelectMany(i => ((IKitRequired)i).Kits) .Cast <AbstractAccessory>() .ToList(); IEnumerable <IGrouping <Product, AbstractAccessory> > products = aircraftKits.GroupBy(ak => ak.Product ?? new Product { GoodsClass = ak.GoodsClass, Standart = ak.Standart, PartNumber = ak.ParentString, Description = ak.Description }); foreach (IGrouping <Product, AbstractAccessory> product in products) { string type = GetAccessoryTypeString(product.First()); double quantity = 0; double totalProductCost = 0; if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.Tools) || product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ControlTestEquipment)) { quantity = product.Max(p => p.Quantity); totalProductCost = 0; } else if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ComponentsAndParts)) { foreach (AbstractAccessory accessoryRequired in product) { int qty = accessoryRequired.Quantity < 1 ? 1 : (int)accessoryRequired.Quantity; quantity += qty; totalProductCost += (qty * accessoryRequired.CostNew); } } else { foreach (AbstractAccessory accessoryRequired in product) { quantity += accessoryRequired.Quantity; totalProductCost += (accessoryRequired.Quantity * accessoryRequired.CostNew); } } dataset.KitsTable.AddKitsTableRow(product.Key.ToString(), quantity.ToString(), totalProductCost, _reportedAircraft != null ? _reportedAircraft + " " + _reportedAircraft.Model : "Unk", type); } }