static void AddDeviceTables(WordprocessingDocument Certificate, UserSession Session, TablesCreator Creator, string DeviceType, CardData DeviceCard, DateTime StartDateOfService) { //WordprocessingDocument CalibrationProtocol = GetDocument(Session, DeviceCard, StartDateOfService, CalibrationProtocolCategoryID); //XtraMessageBox.Show("DeviceType = " + DeviceType); IEnumerable <CertificateTableLook> TablesCollection = Creator.CertificateDeviceTablesCollection.Where(r => r.DeviceTypes.Any(s => s == DeviceType)); if (TablesCollection.Count() == 0) { XtraMessageBox.Show("Для прибра '" + DeviceType + "' не найден шаблон таблицы. Обратитесь к системному администратору."); } else { Dictionary <String, Table> TablesList = new Dictionary <String, Table>(); foreach (CertificateTableLook CurrentTable in TablesCollection) { WordprocessingDocument ParentDocument; string TempPath = ""; switch (CurrentTable.ParentDocumentCategory) { case CertificateTableLook.DocumentCategory.AcceptanceTestingProtocol: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.AcceptanceTestingProtocolCategoryID, out TempPath); break; case CertificateTableLook.DocumentCategory.CalibrationProtocol: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.CalibrationProtocolCategoryID, out TempPath); break; case CertificateTableLook.DocumentCategory.MeasuringData: ParentDocument = CalibrationLib.GetDocument(Session, DeviceCard, CalibrationLib.MeasuringDataCategoryID, out TempPath); break; default: ParentDocument = null; break; } if (TablesList.Any(r => r.Key == CurrentTable.TableName)) { CurrentTable.AdditionDeviceTable(ParentDocument, TablesList.First(r => r.Key == CurrentTable.TableName).Value); } else { TablesList.Add(CurrentTable.TableName, CurrentTable.GetDeviceTable(ParentDocument)); } //Certificate.MainDocumentPart.Document.Body.Append(CurrentTable.GetDeviceTable(ParentDocument)); //Certificate.MainDocumentPart.Document.Body.Append(CalibrationLib.NewParagraph(0, 0, JustificationValues.Left, 10)); if (ParentDocument != null) { ParentDocument.Close(); File.Delete(TempPath); } } foreach (KeyValuePair <String, Table> T in TablesList) { Certificate.MainDocumentPart.Document.Body.Append(T.Value); } } }
static void AddAdditionalTables(WordprocessingDocument Certificate, TablesCreator Creator, string DeviceType) { IEnumerable <CertificateTableLook> TablesCollection = Creator.CertificateAdditionalTablesCollection.Where(r => r.DeviceTypes.Any(s => s == DeviceType)); if (TablesCollection.Count() > 0) { foreach (CertificateTableLook CurrentTable in TablesCollection) { Certificate.MainDocumentPart.Document.Body.Append(CurrentTable.GetDeviceTable(null)); //Certificate.MainDocumentPart.Document.Body.Append(CalibrationLib.NewParagraph(0, 0, JustificationValues.Left, 10)); } } }
static void AddDeviceTables(WordprocessingDocument Protocol, UserSession Session, TablesCreator Creator, string DeviceType, CardData DeviceCard, DateTime StartDateOfService) { // Определение точек вставки таблиц для протоколов поверки разных типов приборов IEnumerable <VerificationProtocolTableLook> TablesCollection = Creator.VerifyProtokolDeviceTablesCollection.Where(r => r.DeviceTypes.Any(s => s == DeviceType)); if (TablesCollection.Count() > 0) { OpenXmlElement IncertElement = Protocol.GetTable("Заключение:").ElementsBefore().Last(); switch (DeviceType) { case "ПКВ/М7": IncertElement = Protocol.GetTable("Определение основной абсолютной погрешности измерений интервалов времени").ElementsBefore().Last(); break; case "ПКВ/У3.0": IncertElement = Protocol.GetTable("Определение основной абсолютной погрешности измерений интервалов времени").ElementsBefore().Last(); break; case "ПКВ/У3.1": IncertElement = Protocol.GetTable("Определение основной абсолютной погрешности измерений интервалов времени").ElementsBefore().Last(); break; case "ПКВ/У3.0-01": IncertElement = Protocol.GetTable("Определение основной абсолютной погрешности измерений интервалов времени").ElementsBefore().Last(); break; /*case "МИКО-2.2": * IncertElement = Protocol.GetTable("Определение метрологических характеристик").ElementsAfter().First(); * break; * case "МИКО-2.3": * IncertElement = Protocol.GetTable("Определение метрологических характеристик").ElementsAfter().First(); * break;*/ case "МИКО-7": IncertElement = Protocol.GetTable("7. Проверка ограничения выходной мощности").ElementsBefore().Last(); break; /*case "МИКО-21": * IncertElement = Protocol.GetTable("Заключение:").ElementsAfter().First(); * break;*/ } //OpenXmlElement IncertElement = Protocol.GetTable("Определение основной абсолютной погрешности измерений силы постоянного электрического тока каналами ВКЛ и ОТКЛ силового коммутатора").ElementsAfter().First(); Dictionary <String, Table> TablesList = new Dictionary <String, Table>(); foreach (VerificationProtocolTableLook CurrentTable in TablesCollection) { //WordprocessingDocument ParentDocument; string ParentDocumentPath = ""; switch (CurrentTable.ParentDocumentCategory) { case VerificationProtocolTableLook.DocumentCategory.AcceptanceTestingProtocol: ParentDocumentPath = CalibrationLib.GetDocumentPath(Session, DeviceCard, CalibrationLib.AcceptanceTestingProtocolCategoryID); break; case VerificationProtocolTableLook.DocumentCategory.CalibrationProtocol: ParentDocumentPath = CalibrationLib.GetDocumentPath(Session, DeviceCard, CalibrationLib.CalibrationProtocolCategoryID); break; case VerificationProtocolTableLook.DocumentCategory.MeasuringData: ParentDocumentPath = CalibrationLib.GetDocumentPath(Session, DeviceCard, CalibrationLib.MeasuringDataCategoryID); break; default: ParentDocumentPath = ""; break; } if (ParentDocumentPath.EndsWith(".docx")) { WordprocessingDocument ParentDocument = WordprocessingDocument.Open(ParentDocumentPath, true); if (TablesList.Any(r => r.Key == CurrentTable.TableName)) { CurrentTable.AdditionDeviceTable(ParentDocument, TablesList.First(r => r.Key == CurrentTable.TableName).Value); } else { TablesList.Add(CurrentTable.TableName, CurrentTable.GetDeviceTable(ParentDocument)); } if (ParentDocument != null) { ParentDocument.Close(); } } if (ParentDocumentPath.EndsWith(".json")) { string fileContent = File.ReadAllText(ParentDocumentPath); RootObject MeashureData = JsonConvert.DeserializeObject <RootObject>(fileContent); TablesList.Add(CurrentTable.TableName, CurrentTable.GetDeviceTable(MeashureData)); } File.Delete(ParentDocumentPath); } foreach (KeyValuePair <String, Table> T in TablesList) { AddNewTable(Protocol, T.Value, IncertElement); } } }