static void AddSensorTables(WordprocessingDocument Protocol, UserSession Session, TablesCreator Creator, string SensorType, CardData SensorCard, DateTime StartDateOfService, string DeviceTypeName) { string SensorNumber = SensorCard.GetDeviceNumber(); IEnumerable <VerificationProtocolTableLook> TablesCollection = Creator.VerificationProtokolSensorTablesCollection.Where(r => r.DeviceTypes.Any(s => s == SensorType)); if (TablesCollection.Count() == 0) { XtraMessageBox.Show("Для датчика '" + SensorType + "' не найден шаблон таблицы. Обратитесь к системному администратору."); } else { foreach (VerificationProtocolTableLook CurrentTable in TablesCollection) { WordprocessingDocument ParentDocument; string TempPath = ""; switch (CurrentTable.ParentDocumentCategory) { case VerificationProtocolTableLook.DocumentCategory.AcceptanceTestingProtocol: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.AcceptanceTestingProtocolCategoryID, out TempPath); break; case VerificationProtocolTableLook.DocumentCategory.CalibrationProtocol: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.CalibrationProtocolCategoryID, out TempPath); break; case VerificationProtocolTableLook.DocumentCategory.MeasuringData: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.MeasuringDataCategoryID, out TempPath); break; default: ParentDocument = null; break; } Table NewSensorTable = CurrentTable.GetSensorsTable(ParentDocument, SensorNumber, DeviceTypeName); AddNewTable(Protocol, NewSensorTable, Protocol.GetTable("Заключение:").ElementsBefore().Last()); if (ParentDocument != null) { ParentDocument.Close(); File.Delete(TempPath); } } } return; }
static void AddSensorTables(WordprocessingDocument Certificate, UserSession Session, TablesCreator Creator, string DeviceType, string DeviceNumber, CardData DeviceCard, DateTime StartDateOfService) { IEnumerable <CertificateTableLook> TablesCollection = Creator.CertificateSensorTablesCollection.Where(r => r.DeviceTypes.Any(s => s == DeviceType)); if (TablesCollection.Count() == 0) { XtraMessageBox.Show("Для датчика '" + DeviceType + "' не найден шаблон таблицы. Обратитесь к системному администратору."); } else { 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; } Certificate.MainDocumentPart.Document.Body.Append(CurrentTable.GetSensorsTable(ParentDocument, DeviceNumber)); //Certificate.MainDocumentPart.Document.Body.Append(CalibrationLib.NewParagraph(0, 0, JustificationValues.Left, 10)); if (ParentDocument != null) { ParentDocument.Close(); File.Delete(TempPath); } } } }
/// <summary> /// Добавить в протокол таблицу с данными измерений датчика. /// </summary> /// <param name="Protocol">Документ протокола</param> /// <param name="Session">пользовательская сессия.</param> /// <param name="Creator">Объект создателя таблиц.</param> /// <param name="SensorType">Тип датчика.</param> /// <param name="SensorCard">Карточка датчика.</param> /// <param name="StartDateOfService">Дата начала сервисного обслуживания.</param> static void AddSensorTables(WordprocessingDocument Protocol, UserSession Session, TablesCreator Creator, string SensorType, CardData SensorCard, DateTime StartDateOfService) { string SensorNumber = SensorCard.GetDeviceNumber(); IEnumerable <ProtocolTableLook> TablesCollection = Creator.ProtokolSensorTablesCollection.Where(r => r.DeviceTypes.Any(s => s == SensorType)); if (TablesCollection.Count() == 0) { XtraMessageBox.Show("Для датчика '" + SensorType + "' не найден шаблон таблицы. Обратитесь к системному администратору."); } else { foreach (ProtocolTableLook CurrentTable in TablesCollection) { WordprocessingDocument ParentDocument; string TempPath = ""; switch (CurrentTable.ParentDocumentCategory) { case ProtocolTableLook.DocumentCategory.AcceptanceTestingProtocol: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.AcceptanceTestingProtocolCategoryID, out TempPath); break; case ProtocolTableLook.DocumentCategory.CalibrationProtocol: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.CalibrationProtocolCategoryID, out TempPath); break; case ProtocolTableLook.DocumentCategory.MeasuringData: ParentDocument = CalibrationLib.GetDocument(Session, SensorCard, CalibrationLib.MeasuringDataCategoryID, out TempPath); break; default: ParentDocument = null; break; } Table NewSensorTable = CurrentTable.GetSensorsTable(ParentDocument, SensorNumber); /*if (Protocol.MainDocumentPart.Document.Body.Elements<Table>().Count() > 0) * { * List<OpenXmlElement> NewList = Protocol.MainDocumentPart.Document.Body.Elements().ToList(); * int Index = NewList.Count - 4; * NewList.Insert(Index, CalibrationLib.NewParagraph(-113, -133, JustificationValues.Left, 11)); * NewList.Insert(Index, (OpenXmlElement)NewSensorTable); * Protocol.MainDocumentPart.Document.Body.RemoveAllChildren(); * foreach (OpenXmlElement Element in NewList) * { Protocol.MainDocumentPart.Document.Body.Append(Element); } * } * else * { * SdtBlock Block = Protocol.MainDocumentPart.Document.Body.Elements<SdtBlock>().First(); * SdtContentBlock ContentBlock = Block.Elements<SdtContentBlock>().First(); * List<OpenXmlElement> NewList = ContentBlock.Elements().ToList(); * int Index = NewList.Count - 4; * NewList.Insert(Index, CalibrationLib.NewParagraph(-113, -133, JustificationValues.Left, 11)); * NewList.Insert(Index, (OpenXmlElement)NewSensorTable); * ContentBlock.RemoveAllChildren(); * foreach (OpenXmlElement Element in NewList) * { ContentBlock.Append(Element); } * }*/ AddNewTable(Protocol, NewSensorTable, Protocol.GetTable("Дата").ElementsBefore().Last()); if (ParentDocument != null) { ParentDocument.Close(); File.Delete(TempPath); } } } return; }