/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(object reportedDirective, ComponentListDataSet destinationDataSet) { //if (!DefaultFilter.Acceptable(directive)) // return; Component component; ComponentDirective directive; NextPerformance nextDueAtAircraftUtilization = null; DirectiveRecord lastPerformance = null; string positionString = ""; string remarks = "", condition = ""; string workType = "", lastComplianceDate = "", nextComplianceDate = "", ampReference = ""; double mansHours = 0, cost = 0; DateTime installationDate = DateTimeExtend.GetCASMinDateTime(); string kits = "", equipment = "", status = ""; Lifelength lifeLimit, componentCurrent = Lifelength.Null; Lifelength repeat = Lifelength.Null, lastCompliance = Lifelength.Null; Lifelength used = Lifelength.Null, nextPerformanceSource = Lifelength.Null, remain = Lifelength.Null; if (reportedDirective is ComponentDirective) { directive = (ComponentDirective)reportedDirective; component = directive.ParentComponent; positionString = component.TransferRecords.GetLast().Position; installationDate = component.TransferRecords.GetLast().TransferDate; componentCurrent = directive.ParentComponent.IsBaseComponent ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((BaseComponent)component) : GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(component); remarks = directive.Remarks; workType = directive.DirectiveType.ToString(); repeat = directive.Threshold.RepeatInterval; lifeLimit = component.LifeLimit; //nextCompliance = GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(directive); GlobalObjects.PerformanceCalculator.GetNextPerformance(directive); nextPerformanceSource = directive.NextPerformanceSource; if (directive.MaintenanceDirective != null) { ampReference = directive.MaintenanceDirective.TaskNumberCheck; } if (nextPerformanceSource != null && directive.Status != DirectiveStatus.Closed) { nextComplianceDate = directive.NextPerformanceDate != null ? ((DateTime)directive.NextPerformanceDate).ToString( new GlobalTermsProvider()["DateFormat"].ToString()) : ""; remain.Add(nextPerformanceSource); remain.Substract(componentCurrent); used.Add(componentCurrent); if (_reportedAircraft != null) { nextDueAtAircraftUtilization = new NextPerformance { PerformanceDate = directive.NextPerformanceDate, PerformanceSource = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft) }; nextDueAtAircraftUtilization.PerformanceSource.Add(remain); } } else { nextPerformanceSource = Lifelength.Null; } if (directive.LastPerformance != null && directive.Status != DirectiveStatus.Closed) { lastPerformance = directive.LastPerformance; lastComplianceDate = directive.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastCompliance = directive.LastPerformance.OnLifelength; used.Substract(lastCompliance); used.Resemble(directive.Threshold.RepeatInterval); remain.Resemble(directive.Threshold.RepeatInterval); if (nextDueAtAircraftUtilization != null) { nextDueAtAircraftUtilization.PerformanceSource.Resemble(directive.Threshold.RepeatInterval); } } else { used.Resemble(directive.Threshold.FirstPerformanceSinceNew); remain.Resemble(directive.Threshold.FirstPerformanceSinceNew); if (nextDueAtAircraftUtilization != null) { nextDueAtAircraftUtilization.PerformanceSource.Resemble(directive.Threshold.FirstPerformanceSinceNew); } } int num = 1; foreach (AccessoryRequired kit in directive.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } condition = directive.Condition.ToString(); } //Если объект является деталью или базовой деталью с директивами //то надо возвратится, т.к. данные по детали/базовой детали будут //добавлены при добавлении их директив в набор данных //Если деталь.базовая деталь без директив, тогда в набор данных надо добавить и данные сразу else if (reportedDirective is Component) { component = (Component)reportedDirective; lifeLimit = component.LifeLimit; if (component.ComponentDirectives.Count != 0) { return; } } else { throw new ArgumentException(); } Lifelength lifeLimitUsed = Lifelength.Null; lifeLimitUsed.Add(componentCurrent); lifeLimitUsed.Resemble(lifeLimit); Lifelength lifeLimitRemain = Lifelength.Null; lifeLimitRemain.Add(lifeLimit); lifeLimitRemain.Substract(componentCurrent); lifeLimitRemain.Resemble(lifeLimit); //string status = ""; //if (.Status == DirectiveStatus.Closed) status = "C"; //if (directive.Status == DirectiveStatus.Open) status = "O"; //if (directive.Status == DirectiveStatus.Repetative) status = "R"; //if (directive.Status == DirectiveStatus.NotApplicable) status = "N/A"; destinationDataSet.ItemsTable.AddItemsTableRow(component.ATAChapter.ShortName, ampReference, component.PartNumber, component.SerialNumber, positionString, component.Description, component.MaintenanceControlProcess.ToString(), installationDate, lifeLimit.Days != null ? lifeLimit.Days.ToString() : "", lifeLimit.Hours != null ? lifeLimit.Hours.ToString() : "", lifeLimit.Cycles != null ? lifeLimit.Cycles.ToString() : "", lifeLimitUsed.Days != null ? lifeLimitUsed.Days.ToString() : "", lifeLimitUsed.Hours != null ? lifeLimitUsed.Hours.ToString() : "", lifeLimitUsed.Cycles != null ? lifeLimitUsed.Cycles.ToString() : "", lifeLimitRemain.Days != null ? lifeLimitRemain.Days.ToString() : "", lifeLimitRemain.Hours != null ? lifeLimitRemain.Hours.ToString() : "", lifeLimitRemain.Cycles != null ? lifeLimitRemain.Cycles.ToString() : "", workType, repeat.Days != null ? repeat.Days.ToString() : "", repeat.Hours != null ? repeat.Hours.ToString() : "", repeat.Cycles != null ? repeat.Cycles.ToString() : "", repeat.ToHoursMinutesAndCyclesStrings(" FH", " FC"), lastComplianceDate, lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "", lastCompliance.Cycles != null ? lastCompliance.Cycles.ToString() : "", lastPerformance != null ? lastPerformance.ToStrings("/") : "", used.Days != null ? used.Days.ToString() : "", used.Hours != null ? used.Hours.ToString() : "", used.Cycles != null ? used.Cycles.ToString() : "", nextComplianceDate, nextPerformanceSource.Hours != null ? nextPerformanceSource.Hours.ToString() : "", nextPerformanceSource.Cycles != null ? nextPerformanceSource.Cycles.ToString() : "", nextDueAtAircraftUtilization != null ? nextDueAtAircraftUtilization.ToStrings("/") : "", remain.Days != null ? remain.Days.ToString() : "", remain.Hours != null ? remain.Hours.ToString() : "", remain.Cycles != null ? remain.Cycles.ToString() : "", remain.ToHoursMinutesAndCyclesStrings(" FH", " FC"), condition, mansHours, cost, kits, equipment, remarks, status); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedComponentобавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(Component reportedComponent, LandingGearStatusDataSet destinationDataSet) { Lifelength total = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(reportedComponent); string domTtsnTcsn = SmartCore.Auxiliary.Convert.GetDateFormat(reportedComponent.ManufactureDate, "/"); if (domTtsnTcsn != "") { domTtsnTcsn += "\n"; } domTtsnTcsn += total.ToHoursMinutesAndCyclesStrings("FH", "FC"); string position = reportedComponent.Position; string pos = ""; string dwgItem = ""; string pattern = @"\d+"; Regex r = new Regex(pattern); Match m = r.Match(position); if (m.Success) { pos = position.Substring(0, m.Index); dwgItem = position.Substring(m.Index); } ComponentRecordType workType = ComponentRecordType.Unknown; ComponentDirective overhaul = reportedComponent.ComponentDirectives.FirstOrDefault(dd => dd.DirectiveType == ComponentRecordType.Overhaul); Lifelength interval = Lifelength.Null; Lifelength used = Lifelength.Null; Lifelength remain = Lifelength.Null; string lastPerformanceDateString = ""; string lastPerformanceHours = ""; string lastPerformanceCycles = ""; if (overhaul != null) { if (overhaul.LastPerformance != null) { DirectiveRecord lastPerformance = overhaul.LastPerformance; interval = overhaul.Threshold.RepeatInterval; lastPerformanceDateString = SmartCore.Auxiliary.Convert.GetDateFormat(lastPerformance.RecordDate, "/"); lastPerformanceHours = lastPerformance.OnLifelength.ToHoursMinutesFormat("FH"); lastPerformanceCycles = lastPerformance.OnLifelength.Cycles != null && lastPerformance.OnLifelength.Cycles != 0 ? lastPerformance.OnLifelength.Cycles.ToString() : ""; used = total - lastPerformance.OnLifelength; used.Resemble(interval); } else { interval = overhaul.Threshold.FirstPerformanceSinceNew; used = new Lifelength(total); used.Resemble(interval); } workType = overhaul.DirectiveType; remain = new Lifelength(overhaul.Remains); } destinationDataSet.ItemsTable.AddItemsTableRow( dwgItem, reportedComponent.ATAChapter.ToString(), reportedComponent.PartNumber, reportedComponent.SerialNumber, pos, reportedComponent.Description, reportedComponent.MaintenanceControlProcess.ToString(), SmartCore.Auxiliary.Convert.GetDateFormat(reportedComponent.TransferRecords.GetLast().TransferDate, "/"), reportedComponent.LifeLimit.ToHoursMinutesAndCyclesStrings("FH", "FC"), total.ToHoursMinutesAndCyclesStrings("FH", "FC"), reportedComponent.Remains.ToHoursMinutesAndCyclesStrings("FH", "FC"), workType.ToString(), interval.ToHoursMinutesAndCyclesStrings("FH", "FC"), lastPerformanceDateString, lastPerformanceHours, lastPerformanceCycles, used.Days != null ? used.Days.ToString() : "", used.Hours != null ? used.Hours.ToString() : "", used.Cycles != null ? used.Cycles.ToString(): "", used.ToHoursMinutesAndCyclesStrings("FH", "FC"), "", "", "", remain.ToHoursMinutesAndCyclesStrings("FH", "FC"), reportedComponent.Condition.ToString(), reportedComponent.ManHours, reportedComponent.Cost, reportedComponent.Kits.ToString(), "", reportedComponent.Remarks, reportedComponent.Status.ToString(), domTtsnTcsn); }