public static void unir2() { // If using Professional version, put your serial key below. ComponentInfo.SetLicense("DHPL-8V4A-TLKO-SHIZ"); string pathToResources = @"C:\Astrologia\"; DocumentModel document = DocumentModel.Load(pathToResources + "Final.rtf"); DocumentModel sourceDocument = DocumentModel.Load(Path.Combine(pathToResources, "DocumentoEditado.rtf"), GemBox.Document.LoadOptions.RtfDefault); // Reuse same mapping for importing all sections to improve performance. var mapping = new ImportMapping(sourceDocument, document, false); // Import all sections from source document. foreach (GemBox.Document.Section sourceSection in sourceDocument.Sections) { GemBox.Document.Section destinationSection = document.Import(sourceSection, true, mapping); document.Sections.Add(destinationSection); } document.Save(pathToResources + "DocumentoEditadoFinal.rtf"); }
static void Main() { // If using Professional version, put your serial key below. ComponentInfo.SetLicense("FREE-LIMITED-KEY"); var destinationDocument = DocumentModel.Load("Invoice.docx"); var sourceDocument = DocumentModel.Load("Reading.docx"); // 1. The following is the easiest way how to import content from source to destination, // it will automatically imports the document's elements. //destinationDocument.Content.End.InsertRange(sourceDocument.Content); // 2. The following enables various customization. // For instance, we can change that the imported content doesn't start from new page // by setting "SectionStart.Continuous" on first destination section. // Reuse the same mapping for importing to improve performance. var mapping = new ImportMapping(sourceDocument, destinationDocument, false); // Import all sections from source document to destination document. foreach (var sourceSection in sourceDocument.Sections) { var destinationSection = destinationDocument.Import(sourceSection, true, mapping); destinationDocument.Sections.Add(destinationSection); } destinationDocument.Save("Importing.docx"); }
internal EntityMapper( IXmlNamespaceResolver namespaceResolver, CvlRepository cvlCachedRepository, ImportMapping importMapping) { _namespaceResolver = namespaceResolver; _xPathCompiler = new CachedXPathCompiler(_namespaceResolver); _fieldParserFactory = new FieldParserFactory(cvlCachedRepository, _xPathCompiler, importMapping); }
private void buttonAddMapping_Click(object sender, EventArgs e) { try { ImportMapping mapping = new ImportMapping(); mapping.Type = "HTL"; importMappingBindingSource.Add(mapping); BindMappings(); gridViewMapping.FocusedRowHandle = importMappingBindingSource.Count - 1; } catch (Exception ex) { this.DisplayError(ex); } }
public FieldParserFactory( CvlRepository cvlRepository, CachedXPathCompiler xPathCompiler, ImportMapping importMapping) { _cvlRepository = cvlRepository; _xPathCompiler = xPathCompiler; _cachedFieldParsers = new Dictionary <string, IFieldParser>(); _supportedCultures = importMapping.Languages?.ToDictionary( lang => lang.Original, lang => CultureInfo.GetCultureInfo(lang.InRiver)); }
private void buttonDeleteMapping_Click(object sender, EventArgs e) { try { if (gridViewMapping.FocusedRowHandle >= 0) { ImportMapping mapping = (ImportMapping)gridViewMapping.GetFocusedRow(); importMappingBindingSource.Remove(mapping); BindMappings(); } } catch (Exception ex) { this.DisplayError(ex); } }
static void Example2() { // Word files that will be combined into one file. string[] files = { "MergeFile01.docx", "MergeFile02.docx", "MergeFile03.docx" }; var destination = new DocumentModel(); var firstSourceDocument = true; foreach (var file in files) { var source = DocumentModel.Load(file); var firstSourceSection = true; // Reuse the same mapping for importing to improve performance. var mapping = new ImportMapping(source, destination, false); foreach (var sourceSection in source.Sections) { // Import section from source document to destination document. var destinationSection = destination.Import(sourceSection, true, mapping); destination.Sections.Add(destinationSection); // Set the first section to start on the same page as the previous section. // In other words, the source content continues to flow with the current destination content. if (firstSourceSection) { destinationSection.PageSetup.SectionStart = SectionStart.Continuous; firstSourceSection = false; } } // Set the destination's default formatting to first source's default formatting. // Note, a single document can only have one default formatting. if (firstSourceDocument) { destination.DefaultCharacterFormat = source.DefaultCharacterFormat.Clone(); destination.DefaultParagraphFormat = source.DefaultParagraphFormat.Clone(); firstSourceDocument = false; } } // Save joined sections into one file. destination.Save("Merged Sections.docx"); }
public override void Visit(ImportMapping importMapping) { var writer = serviceLocator.GetWriter <ImportMapping>(); var import = writer.Write(importMapping); var newNode = document.ImportNode(import.DocumentElement, true); if (document.DocumentElement.ChildNodes.Count > 0) { document.DocumentElement.InsertBefore(newNode, document.DocumentElement.ChildNodes[0]); } else { document.DocumentElement.AppendChild(newNode); } }
private void InitializeMapping(string mappingDocument) { var serializer = new XmlSerializer(typeof(ImportMapping)); using (TextReader reader = new StringReader(mappingDocument)) { _importMapping = (ImportMapping)serializer.Deserialize(reader); } foreach (var ns in _importMapping.XmlNamespaces) { _namespaceResolver.AddNamespace(ns.Prefix, ns.Uri); } _entityMapper = new EntityMapper(_namespaceResolver, _cvlRepository, _importMapping); }
static void Main(string[] args) { // If using Professional version, put your serial key below. ComponentInfo.SetLicense("FREE-LIMITED-KEY"); DocumentModel document = DocumentModel.Load("Invoice.docx"); string pathToFileDirectory = "Resources"; DocumentModel sourceDocument = DocumentModel.Load(Path.Combine(pathToFileDirectory, "Reading.docx"), LoadOptions.DocxDefault); // Reuse same mapping for importing all sections to improve performance. var mapping = new ImportMapping(sourceDocument, document, false); // Import all sections from source document. foreach (Section sourceSection in sourceDocument.Sections) { Section destinationSection = document.Import(sourceSection, true, mapping); document.Sections.Add(destinationSection); } document.Save("Importing.docx"); }
public virtual void ProcessImport(ImportMapping importMapping) { }
public virtual void Visit(ImportMapping importMapping) { }
private HRATES PopulateHRates(ImportMapping mapping, string special, DateTime date, decimal newRate, decimal currentRate, decimal markupPct, decimal markupFlat) { string[] rateplan = Array.Empty <string>(); if (!string.IsNullOrEmpty(special)) { rateplan = special.Split('-'); } HRATES hrate = new HRATES(); hrate.CODE = mapping.HOTEL.CODE; hrate.CAT = mapping.Cat; hrate.START_DATE = date; hrate.END_DATE = date; hrate.AGENCY = _sys.Settings.DefaultAgency; hrate.LAST_UPD = DateTime.Now; hrate.RATE_DESC = mapping.HOTEL.NAME; hrate.UPD_INIT = _sys.User.Name; if (rateplan.Length > 0) { if (rateplan[0].Trim().Length <= 16) { hrate.SpecialValue_Code = rateplan[0].Trim(); } else if (rateplan[0].Trim().Length <= 64) { //Use the code as the description by default hrate.COMMENT1 = rateplan[0].Trim(); hrate.COMMENT2 = rateplan[0].Trim(); } } //Overwrite the description with a description if there is one, and if the comment fields //are not required to hold the code (which would be if the code is longer than 16 chars) if (rateplan.Length > 1 && rateplan[0].Trim().Length <= 16 && rateplan[1].Trim().Length <= 64) { hrate.COMMENT1 = rateplan[1].Trim(); hrate.COMMENT2 = rateplan[1].Trim(); } hrate.YEAR = date.Year; if (dateEditEffectiveDate.EditValue != null) { hrate.ResDate_Start = dateEditEffectiveDate.DateTime; } if (dateEditExpirationDate.EditValue != null) { hrate.ResDate_End = dateEditExpirationDate.DateTime; } string day = date.ToString("ddd").ToLower(); bool isWeekend = mapping.WeekendDays.ToLower().Contains(day); decimal taxRate = (decimal)((mapping.HOTEL.TAXRATE ?? 0) / 100); decimal baseCostBeforeTax = newRate > 0 ? newRate : currentRate; if (isWeekend) { baseCostBeforeTax += mapping.WeekendSurcharge ?? 0; } else { baseCostBeforeTax += mapping.WeekdaySurcharge ?? 0; } //We don't actually know whether CHD's markups are inclusive of tax, but probably not so add the tax //If there is a flat amount it is per room, so it will need to be divided by persons later decimal baseMarkupAfterTax = (markupFlat + (baseCostBeforeTax * (markupPct / 100))) * (1 + taxRate); decimal baseCostAfterTax = baseCostBeforeTax * (1 + taxRate); decimal surchargeBeforeTax = mapping.PerPersonSurcharge ?? 0; decimal surchargeAfterTax = surchargeBeforeTax * (1 + taxRate); decimal surchargeMarkupWithTax = (surchargeBeforeTax * (markupPct / 100)) * (1 + taxRate); decimal perPersonCostBeforeTax = baseCostBeforeTax; decimal perPersonCostAfterTax = baseCostAfterTax; int occupancy = 1; hrate.SglCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.SGL_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.SGL_GRATE = (float)Math.Round(perPersonCostAfterTax + baseMarkupAfterTax, 2); occupancy = 2; //costBeforeTax = baseCostBeforeTax / occupancy; //costAfterTax = baseCostAfterTax / occupancy; //Find out at what occupancy the per person surcharge kicks in and multiply by the difference //in number of occupants for this occupancy level int perPersonMultiplier = occupancy - (mapping.BaseRateOccupancy ?? 1); perPersonCostBeforeTax = (baseCostBeforeTax + (surchargeBeforeTax * perPersonMultiplier)) / occupancy; perPersonCostAfterTax = (baseCostAfterTax + (surchargeAfterTax * perPersonMultiplier)) / occupancy; hrate.DblCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.DBL_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.DBL_GRATE = (float)Math.Round(perPersonCostAfterTax + ((baseMarkupAfterTax + (surchargeMarkupWithTax * perPersonMultiplier)) / occupancy), 2); occupancy = 3; //costBeforeTax = baseCostBeforeTax / occupancy; //costAfterTax = baseCostAfterTax / occupancy; perPersonMultiplier = occupancy - (mapping.BaseRateOccupancy ?? 1); perPersonCostBeforeTax = (baseCostBeforeTax + (surchargeBeforeTax * perPersonMultiplier)) / occupancy; perPersonCostAfterTax = (baseCostAfterTax + (surchargeAfterTax * perPersonMultiplier)) / occupancy; hrate.TplCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.TPL_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.TPL_GRATE = (float)Math.Round(perPersonCostAfterTax + ((baseMarkupAfterTax + (surchargeMarkupWithTax * perPersonMultiplier)) / occupancy), 2); occupancy = 4; //costBeforeTax = baseCostBeforeTax / occupancy; //costAfterTax = baseCostAfterTax / occupancy; perPersonMultiplier = occupancy - (mapping.BaseRateOccupancy ?? 1); perPersonCostBeforeTax = (baseCostBeforeTax + (surchargeBeforeTax * perPersonMultiplier)) / occupancy; perPersonCostAfterTax = (baseCostAfterTax + (surchargeAfterTax * perPersonMultiplier)) / occupancy; hrate.QuaCostBeforeTax = Math.Round(perPersonCostBeforeTax, 2); hrate.QUA_NRATE = (float)Math.Round(perPersonCostAfterTax, 2); hrate.QUA_GRATE = (float)Math.Round(perPersonCostAfterTax + ((baseMarkupAfterTax + (surchargeMarkupWithTax * perPersonMultiplier)) / occupancy), 2); hrate.CHD_LIMIT = mapping.FreeAgeLimit.ToString(); //If the rate was marked up by an import rule, don't apply further markups in availability checks hrate.MarkupAllowed = !(markupFlat > 0 || markupPct > 0); //Pull the max occs from the hotel if nothing is specified on the import if ((mapping.MaxOccupancy ?? 0) > 0) { hrate.MAX_SGL = mapping.MaxOccupancy; hrate.MAX_DBL = mapping.MaxOccupancy; hrate.MAX_TPL = mapping.MaxOccupancy; hrate.MAX_QUA = mapping.MaxOccupancy; } else { hrate.MAX_SGL = mapping.HOTEL.MAX_SGL; hrate.MAX_DBL = mapping.HOTEL.MAX_DBL; hrate.MAX_TPL = mapping.HOTEL.MAX_TPL; hrate.MAX_QUA = mapping.HOTEL.MAX_QUA; } DefaultUnusedFields(hrate); return(hrate); }
public void UjPeldany(string peldany, string eredetiVMasolat) { DocumentModel document; using (var msDocx = new MemoryStream()) { msDocx.Write(Szamlakep, 0, Szamlakep.Count()); document = DocumentModel.Load(msDocx, LoadOptions.DocxDefault); } var fejMezok = new { BizonylatFejlec, Peldany = peldany, EredetiVMasolat = eredetiVMasolat, SzallitoNev, SzallitoCim, SzallitoAdoszam, SzallitoBankszamla1, SzallitoBankszamla2, VevoNev, VevoCim, VevoAdoszam, BizonylatKelte, TeljesitesKelte, FizetesiMod, FizetesiHatarido, Bizonylatszam, MegjegyzesFej, Brutto, Penznem, Arfolyam, Azaz, AfaFt, Keszitette, Verzio }; document.MailMerge.Execute(fejMezok); Table[] Tables = document.GetChildElements(true, ElementType.Table).Cast <Table>().ToArray(); Table TetelTable = Tables[1]; TableRow TetelMinta = TetelTable.Rows[1].Clone(true); TableRow TetelMintaMegjegyzes = TetelTable.Rows[2].Clone(true); TetelTable.Rows.RemoveAt(2); TetelTable.Rows.RemoveAt(1); Table AfaTable = Tables[2]; TableRow AfaMinta = AfaTable.Rows[1].Clone(true); AfaTable.Rows.RemoveAt(1); Table OsszesitoTable = Tables[3]; if (Penznem == "HUF" || (BizonylatTipus != BizonylatTipus.Szamla && BizonylatTipus != BizonylatTipus.ElolegSzamla)) { OsszesitoTable.Rows.RemoveAt(2); } TableRow LastRow; foreach (var Tetel in LstTetel) { TetelTable.Rows.Add(TetelMinta.Clone(true)); LastRow = TetelTable.Rows.Last(); DocxUtils.SetCellValue(LastRow, 0, Tetel.Megnevezes); DocxUtils.SetCellValue(LastRow, 1, Tetel.Mennyiseg); DocxUtils.SetCellValue(LastRow, 2, Tetel.Me); DocxUtils.SetCellValue(LastRow, 3, Tetel.Egysegar); DocxUtils.SetCellValue(LastRow, 4, Tetel.AfaKulcs); DocxUtils.SetCellValue(LastRow, 5, Tetel.Netto); DocxUtils.SetCellValue(LastRow, 6, Tetel.Afa); DocxUtils.SetCellValue(LastRow, 7, Tetel.Brutto); if (!string.IsNullOrEmpty(Tetel.Megjegyzes)) { TetelTable.Rows.Add(TetelMintaMegjegyzes.Clone(true)); LastRow = TetelTable.Rows.Last(); DocxUtils.SetCellValue(LastRow, 1, Tetel.Megjegyzes); } if (!string.IsNullOrEmpty(Tetel.Termekdij) && (BizonylatTipus == BizonylatTipus.Szamla || BizonylatTipus == BizonylatTipus.ElolegSzamla || BizonylatTipus == BizonylatTipus.Szallito)) { TetelTable.Rows.Add(TetelMintaMegjegyzes.Clone(true)); LastRow = TetelTable.Rows.Last(); DocxUtils.SetCellValue(LastRow, 1, Tetel.Termekdij); } } LastRow = TetelTable.Rows.Last(); DocxUtils.SetCellBorder(TetelTable.Rows[0], MultipleBorderTypes.Bottom, 0, 7); DocxUtils.SetCellBorder(LastRow, MultipleBorderTypes.Bottom, 0, LastRow.Cells.Count - 1); foreach (var afa in LstAfa) { AfaTable.Rows.Add(AfaMinta.Clone(true)); LastRow = AfaTable.Rows.Last(); DocxUtils.SetCellValue(LastRow, 0, afa.AfaKulcs); DocxUtils.SetCellValue(LastRow, 1, afa.Netto); DocxUtils.SetCellValue(LastRow, 2, afa.Afa); DocxUtils.SetCellValue(LastRow, 3, afa.Brutto); } AfaTable.Rows.Add(AfaMinta.Clone(true)); LastRow = AfaTable.Rows.Last(); DocxUtils.SetCellValue(LastRow, 0, ""); DocxUtils.SetCellValue(LastRow, 1, Netto); DocxUtils.SetCellValue(LastRow, 2, Afa); DocxUtils.SetCellValue(LastRow, 3, Brutto); DocxUtils.SetCellBorder(AfaTable.Rows[0], MultipleBorderTypes.Bottom, 0, 3); DocxUtils.SetCellBorder(LastRow, MultipleBorderTypes.Top, 0, 3); Table termekdijTable = Tables[4]; TableRow termekdijMinta = termekdijTable.Rows[1].Clone(true); termekdijTable.Rows.RemoveAt(1); if (!TermekdijNulla && (BizonylatTipus == BizonylatTipus.Szamla || BizonylatTipus == BizonylatTipus.ElolegSzamla || BizonylatTipus == BizonylatTipus.Szallito)) { foreach (var termekdij in LstTermekdij) { termekdijTable.Rows.Add(termekdijMinta.Clone(true)); LastRow = termekdijTable.Rows.Last(); DocxUtils.SetCellValue(LastRow, 0, termekdij.TermekdijKT); DocxUtils.SetCellValue(LastRow, 1, termekdij.OssztomegKg); DocxUtils.SetCellValue(LastRow, 2, termekdij.TermekdijEgysegar); DocxUtils.SetCellValue(LastRow, 3, termekdij.Termekdij); } termekdijTable.Rows.Add(termekdijMinta.Clone(true)); LastRow = termekdijTable.Rows.Last(); DocxUtils.SetCellValue(LastRow, 0, ""); DocxUtils.SetCellValue(LastRow, 1, ""); DocxUtils.SetCellValue(LastRow, 2, ""); DocxUtils.SetCellValue(LastRow, 3, Termekdij); DocxUtils.SetCellBorder(termekdijTable.Rows[0], MultipleBorderTypes.Bottom, 0, 3); DocxUtils.SetCellBorder(LastRow, MultipleBorderTypes.Top, 0, 3); } else { termekdijTable.Rows.RemoveAt(0); } var mapping = new ImportMapping(document, _outputDoc, false); foreach (var sourceSection in document.Sections) { var destinationSection = _outputDoc.Import(sourceSection, true, mapping); _outputDoc.Sections.Add(destinationSection); } }
public ImportMappingController(ImportMapping importMapping, ILog logger) { _importMapping = importMapping; this.logger = logger; }
public string ImportMappingExcel(string requestParam) { string RetVal = string.Empty; string[] Params; string DbNid, LanguageCode, UserNId, AgeCodeListGID, SexCodeListGId, LocationCodeListGID, FilePath; int MappingType = 0; ImportMapping ObjImpMap = null; string ParamDel = string.Empty; //Param string should be in the format of DBNID[****]LangauageCode[****]UserNId[****]AgeCodeListGID[****]SexCodeListGId[****]LocationCodeListGID based on mapping type string ImpMappingParam = string.Empty; try { ParamDel = Constants.Delimiters.ParamDelimiter; Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter); DbNid = Params[0].ToString().Trim(); LanguageCode = Params[1].ToString().Trim(); UserNId = Params[2].ToString().Trim(); AgeCodeListGID = Params[3].ToString().Trim(); SexCodeListGId = Params[4].ToString().Trim(); LocationCodeListGID = Params[5].ToString().Trim(); FilePath = Params[6].ToString().Trim(); MappingType = Convert.ToInt32(Params[7].ToString().Trim()); ObjImpMap = new ImportMapping(); switch (MappingType) { case 0: //ImpMappingParam = DbNid + ParamDel + LanguageCode + ParamDel + UserNId; ImpMappingParam = DbNid + ParamDel + LanguageCode + ParamDel + UserNId + ParamDel + AgeCodeListGID + ParamDel + SexCodeListGId + ParamDel + LocationCodeListGID + ParamDel; RetVal = ObjImpMap.ImportMapppingFile(EnumHelper.MappingType.CodeList, ImpMappingParam, LanguageCode, DbNid, FilePath); break; case 1: //ImpMappingParam = DbNid + ParamDel + LanguageCode + ParamDel + UserNId + ParamDel + AgeCodeListGID + ParamDel + SexCodeListGId + ParamDel + LocationCodeListGID; ImpMappingParam = DbNid + ParamDel + LanguageCode + ParamDel + UserNId + ParamDel; RetVal = ObjImpMap.ImportMapppingFile(EnumHelper.MappingType.IUS, ImpMappingParam, LanguageCode, DbNid, FilePath); break; case 2: //ImpMappingParam = DbNid + ParamDel + LanguageCode + ParamDel + UserNId; ImpMappingParam = DbNid + ParamDel + LanguageCode + ParamDel + UserNId + ParamDel; RetVal = ObjImpMap.ImportMapppingFile(EnumHelper.MappingType.Metadata, ImpMappingParam, LanguageCode, DbNid, FilePath); break; default: RetVal = string.Empty; break; } } catch (Exception ex) { RetVal = string.Empty; Global.CreateExceptionString(ex, null); } return RetVal; }