/// <summary> /// Найти таблицы в колонтитулах /// </summary> private IResultAppCollection <IStamp> FindStamps(ConvertingSettingsApp convertingSettings) => _document.Sections.ToEnumerable(). SelectMany(section => section.Footers.ToEnumerable()). SelectMany(SearchInRange.GetTablesFromFooter). ToList(). Map(GetTableStampTypes). ResultValueBad(tableStamp => tableStamp.Concat(GetTableStampTypes(_document.Tables.ToEnumerable()).Value ?? Enumerable.Empty <TableStampType>()). ToList()). ResultValueOkBind(tableStamp => GetStampsInOrder(tableStamp, convertingSettings)). ToResultCollection();
/// <summary> /// Найти штампы в модели /// </summary> public IEnumerable <IStamp> FindStamps(int modelIndex, ConvertingSettingsApp convertingSettings) => GetModelElements(new List <ElementMicrostationType>() { ElementMicrostationType.CellElement }). Where(element => StampFieldMain.IsStampName(element.AsCellElement.Name)). Select((element, stampIndex) => new CellElementMicrostation(element.AsCellElement, ToOwnerMicrostation()). Map(cellMicrostation => new StampFullMicrostation(cellMicrostation, new StampSettings(new StampIdentifier(modelIndex, stampIndex), convertingSettings.PersonId, convertingSettings.PdfNamingType, convertingSettings.UseDefaultSignature), ApplicationMicrostation.MicrostationResources.SignaturesSearching))). Cast <IStamp>();
/// <summary> /// Поучить штампы в порядке их сортировки /// </summary> private IResultAppCollection <IStamp> GetStampsInOrder(IList <TableStampType> tablesStamp, ConvertingSettingsApp convertingSettings) => StampCreating.GetMainStamp(tablesStamp[0].StampType, tablesStamp[0].TableWord, StampCreating.GetStampSettingsWord(0, convertingSettings, PaperSize, OrientationType), ApplicationOffice.ResourcesWord.SignaturesSearching, Tables). Map(mainStamp => new ResultAppCollection <IStamp>(new List <IStamp>() { mainStamp }). ConcatResult(GetShortStamps(tablesStamp.Where(tableStamp => tableStamp.StampType == StampType.Shortened). Select(tableStamp => tableStamp.TableWord), mainStamp, convertingSettings)));
/// <summary> /// Список штампов /// </summary> public IStampContainer GetStampContainer(ConvertingSettingsApp convertingSettings) => _stampContainer ??= new StampContainer(FindStamps(convertingSettings), StampContainerType.United);
/// <summary> /// Получить сокращенные штампы /// </summary> private IResultAppCollection <IStamp> GetShortStamps(IEnumerable <ITableElementWord> tablesStamp, IStamp fullStamp, ConvertingSettingsApp convertingSettings) => StampCreating.GetShortStamps(fullStamp, tablesStamp, StampCreating.GetStampSettingsWord(1, convertingSettings, PaperSize, OrientationType), ApplicationOffice.ResourcesWord.SignaturesSearching);
/// <summary> /// Найти штампы во всех моделях и листах /// </summary> private static IResultAppCollection <IStamp> FindStamps(IEnumerable <IModelMicrostation> modelsMicrostation, ConvertingSettingsApp convertingSettings) => modelsMicrostation.SelectMany((model, modelIndex) => model.FindStamps(modelIndex, convertingSettings)). Map(stamps => new ResultAppCollection <IStamp>(stamps, new ErrorApplication(ErrorApplicationType.StampNotFound, "Штампы не найдены")));
/// <summary> /// Контейнер штампов /// </summary> public IStampContainer GetStampContainer(ConvertingSettingsApp convertingSettings) => _stampContainer ??= new StampContainer(FindStamps(ModelsMicrostation, convertingSettings), StampContainerType.United);