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 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; }
/// <summary> /// Заполнить данные свидетельства о поверке. /// </summary> /// <param name="Certificate"> Файл свидетельства о поверке.</param> /// <param name="CardScript">Скрипт.</param> /// <param name="Context">Объектный контекст.</param> /// <param name="DeviceCard">Карточка прибора.</param> /// <param name="ClientName">Название клиента.</param> /// <param name="VerificationDate">Дата поверки.</param> /// <param name="AdditionalWaresList">Перечень дополнительных изделий.</param> /// <param name="StartDateOfService">Дата поступления на поверку.</param> /// <param name="PreviousVerifySerialNumber">Дата поступления на поверку.</param> public static void FillData(WordprocessingDocument Certificate, ScriptClassBase CardScript, ObjectContext Context, CardData DeviceCard, string ClientName, DateTime VerificationDate, List <CardData> AdditionalWaresList, DateTime StartDateOfService, string PreviousVerifySerialNumber) { // Формирование сертификата Guid DeviceTypeID = DeviceCard.Sections[CardOrd.Properties.ID].FindRow("@Name = 'Прибор'").GetString(CardOrd.Properties.Value).ToGuid(); string DeviceTypeName = ApplicationCard.UniversalCard.GetItemName(DeviceTypeID); string DeviceNumber = DeviceCard.GetDeviceNumber(); DeviceNumber = DeviceNumber.Contains("/") == true?DeviceNumber.Replace("/", " (") + " г)" : DeviceNumber; // Данные для заполнения закладочных полей string FullDeviceType = ApplicationCard.UniversalCard.GetItemPropertyValue(DeviceTypeID, "Полное название").ToString() + " " + DeviceTypeName + ","; string VerificationDateString = VerificationDate.ToLongDateString(); int VerificationInterval = CalibrationLib.GetVerificationInterval(ApplicationCard.UniversalCard, DeviceTypeID); string ValidUntil = VerificationDate.AddMonths(VerificationInterval).AddDays(-1).ToLongDateString(); string VerificationMethods = ApplicationCard.UniversalCard.GetItemPropertyValue(DeviceTypeID, "Методика поверки").ToString(); string VerificationScope = ApplicationCard.UniversalCard.GetItemPropertyValue(DeviceTypeID, "Объем поверки") == null ? "в полном объеме" : ApplicationCard.UniversalCard.GetItemPropertyValue(DeviceTypeID, "Объем поверки").ToString(); string Suitability = ApplicationCard.UniversalCard.GetItemPropertyValue(DeviceTypeID, "Пригодность к применению") == null ? "" : " " + ApplicationCard.UniversalCard.GetItemPropertyValue(DeviceTypeID, "Пригодность к применению").ToString(); string RegNum = "ГР №" + ApplicationCard.UniversalCard.GetItemPropertyValue(DeviceTypeID, "Номер в Госреестре").ToString(); string AdditionalWares = (AdditionalWaresList.Count > 0 ? "c датчиками " : "-") + AdditionalWaresList.Select(r => ApplicationCard.UniversalCard.GetItemName(r.Sections[CardOrd.Properties.ID].FindRow("@Name = 'Прибор'").GetString(CardOrd.Properties.Value).ToGuid()) + " № " + (r.GetDeviceNumber().Contains("/") == true ? r.GetDeviceNumber().Replace("/", " (") + " г)" : r.GetDeviceNumber())).Aggregate(AdditionalWaresList.Count == 2 ? " и " : ", "); string VerificationMeans = CalibrationLib.GetListOfMeasures(CardScript.Session, DeviceTypeID, false, true); // ФИО текущего сотрудника определяется из справочника сотрудников (строка отображения) string StaffName = Context.GetCurrentEmployee().FirstName.Substring(0, 1) + "." + Context.GetCurrentEmployee().MiddleName.Substring(0, 1) + ". " + Context.GetCurrentEmployee().LastName; // ФИО руководителя отдела Метрологической лаборатории определяется из справочника сотрудников по должности StaffEmployee MetrologicalLabManagerEmployee = Context.GetEmployeeByPosition(SKB.Base.Ref.RefServiceCard.Roles.MetrologicalLabManager); string ManagerName = MetrologicalLabManagerEmployee != null?MetrologicalLabManagerEmployee.FirstName.Substring(0, 1) + "." + MetrologicalLabManagerEmployee.MiddleName.Substring(0, 1) + ". " + MetrologicalLabManagerEmployee.LastName : ""; // Условия поверки string TempPath = ""; WordprocessingDocument ParentDocument = CalibrationLib.GetDocument(CardScript.Session, DeviceCard, CalibrationLib.VerificationProtocolCategoryID, out TempPath); Table ParentTable = ParentDocument == null ? null : ParentDocument.GetTable("при следующих значениях влияющих факторов:"); List <string> Collection = new List <string>(); if (ParentTable != null) { for (int i = 1; i < ParentTable.Elements <TableRow>().Count(); i++) { Collection.Add(ParentTable.GetCellValue(i, 1) + ": " + ParentTable.GetCellValue(i, 2) + " " + ParentTable.GetCellValue(i, 3) + " "); } } string Factors = Collection.Count() > 0 ? Collection.Aggregate() : ""; string Factors2 = ""; if (Factors.Length > 27) { int i = Factors.Substring(0, 27).LastIndexOf(" "); if (i > 0) { Factors2 = Factors.Substring(i); Factors = Factors.Substring(0, i); } } // Заполнение закладочный полей FillBookmarks(Certificate, ValidUntil, FullDeviceType, RegNum, AdditionalWares, PreviousVerifySerialNumber, DeviceNumber, VerificationMethods, VerificationScope, Suitability, VerificationMeans, Factors, Factors2, VerificationDateString, StaffName, ManagerName); // Добавление дополнительных данных return; }