public void HandleMachineSetUpFile(MergeEx merger) { try { if (!String.IsNullOrEmpty(this.MachineSetUpFile)) { if (System.IO.File.Exists(this.MachineSetUpFile)) { merger.AddFile(this.MachineSetUpFile); } else { string filenotfound = System.Configuration.ConfigurationManager.AppSettings["machinesetupfilenotfound"]; if (System.IO.File.Exists(filenotfound)) { merger.AddFile(filenotfound); } } } } catch (Exception ex) { string filenotfound = System.Configuration.ConfigurationManager.AppSettings["machinesetupfilenotfound"]; if (System.IO.File.Exists(filenotfound)) { merger.AddFile(filenotfound); } } }
public void HandleAdditionalFile(MergeEx merger) { try { if (!String.IsNullOrEmpty(this.AdditionalFilePath)) { if (System.IO.File.Exists(this.AdditionalFilePath)) { merger.AddFile(this.AdditionalFilePath); } else { string filenotfound = System.Configuration.ConfigurationManager.AppSettings["additionalfilenotfound"]; if (System.IO.File.Exists(filenotfound)) { merger.AddFile(filenotfound); } } } } catch (Exception ex) { string filenotfound = System.Configuration.ConfigurationManager.AppSettings["additionalfilenotfound"]; if (System.IO.File.Exists(filenotfound)) { merger.AddFile(filenotfound); } } }
public void HandleDrawingFile(MergeEx merger) { try { if (!String.IsNullOrEmpty(this.DrawingFilePath)) { if (File.Exists(this.DrawingFilePath)) { merger.AddFile(this.DrawingFilePath); } else { string filenotfound = System.Configuration.ConfigurationManager.AppSettings["drawingfilenotfound"]; if (System.IO.File.Exists(filenotfound)) { merger.AddFile(filenotfound); } } } } catch (Exception ex) { this.UserMessage = "An error occurred when the system attempted to merge a Drawing file to the Travel Card. " + ex.ToString(); } }
public void HandleDeviation2File(MergeEx merger) { try { //handle deviation file number 2. //1. If the current date is withn the start and end dates then print it. //2. If not in effect don't print it. //3 If not found print the "not found page". if (!String.IsNullOrEmpty(this.DeviationFile2Path)) { DateTime?startdate = this.DeviationFile2StartDte; DateTime?enddate = this.DeviationFile2EndDte; bool ineffecterange = IsInDateRange(startdate, enddate); if (System.IO.File.Exists(this.DeviationFile2Path) && ineffecterange) { merger.AddFile(this.DeviationFile2Path); } if (System.IO.File.Exists(this.DeviationFile2Path) == false && ineffecterange) { string filenotfound = System.Configuration.ConfigurationManager.AppSettings["deviationfilenum2notfound"]; if (System.IO.File.Exists(filenotfound)) { merger.AddFile(filenotfound); } } } } catch (Exception ex) { string filenotfound = System.Configuration.ConfigurationManager.AppSettings["deviationfilenum2notfound"]; if (System.IO.File.Exists(filenotfound)) { merger.AddFile(filenotfound); } } }
public void CreatePdfFiles(PdfConverter pdfConverter, string htmlString) { string pdfWorkFilePath = System.Configuration.ConfigurationManager.AppSettings["pdfWorkFilePath"]; MergeEx merger = new MergeEx(); string existingpdf = pdfWorkFilePath + this.OutputFileName.ToString() + ".pdf"; string[] Files = System.IO.Directory.GetFiles(pdfWorkFilePath); int count = 0; string filename = this.OutputFileName.ToString() + ".pdf"; string finalfilename = this.OutputFileName.ToString() + "MergedDocs.pdf"; pdfConverter.SavePdfFromHtmlStringToFile(htmlString, pdfWorkFilePath + filename); merger.DestinationFile = pdfWorkFilePath + this.PartID.ToString() + "Merged.pdf"; merger.SourceFolder = pdfWorkFilePath + filename; if (this.NumofCopies > 0) { //save html for CC Card string htmlCC = htmlString; htmlCC = htmlString.Replace("<SPAN id=FRONTPAGEBEGIN></SPAN>", "<H2>CONTINUATION TRAVEL CARD for " + this.PartID + "</H2>"); htmlCC = htmlCC.Replace("<SPAN id=ccMessage></SPAN>", "<SPAN id=ccMessage> CONTINUATION CARD</SPAN>"); htmlCC = htmlCC.Replace("<SPAN id=ccMessage2></SPAN>", "<SPAN id=ccMessage> CONTINUATION CARD</SPAN>"); string ccfilename = this.OutputFileName.ToString() + "Continuation.pdf"; PdfConverter ccPdf = new PdfConverter(this.Width, this.Height); ccPdf.PdfDocumentOptions.PdfPageSize = Winnovative.WnvHtmlConvert.PdfPageSize.Letter; //NOTE: Users did not want the front page of the travel card to printing out on continuation card. I was able to blank out the content on the first page could not figure out to eliminate //the first page. It is probably possible and may be a good thing to refactor in the future. ccPdf.HtmlExcludedRegionsOptions.HtmlElementIds = new string[] { "CONTENTONFRONT", "BREAKFIRSTPAGE", "FRONTCONTENT" }; if (System.Configuration.ConfigurationManager.AppSettings["htmltopdf.licensekey"] != String.Empty) { ccPdf.LicenseKey = System.Configuration.ConfigurationManager.AppSettings["htmltopdf.licensekey"]; } ccPdf.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.NoCompression; ccPdf.PdfDocumentOptions.PdfPageOrientation = Winnovative.WnvHtmlConvert.PDFPageOrientation.Landscape; ccPdf.PdfDocumentOptions.ShowHeader = false; ccPdf.PdfDocumentOptions.ShowFooter = false; ccPdf.PdfDocumentOptions.InternalLinksEnabled = false; ccPdf.PdfDocumentOptions.JpegCompressionEnabled = false; ccPdf.PdfDocumentOptions.StretchToFit = true; ccPdf.OptimizeMemoryUsage = false; ccPdf.PdfDocumentOptions.LiveUrlsEnabled = true; ccPdf.PdfDocumentOptions.LeftMargin = 9; ccPdf.PdfDocumentOptions.RightMargin = 9; ccPdf.PdfDocumentOptions.TopMargin = 9; ccPdf.PdfDocumentOptions.BottomMargin = 9; ccPdf.SavePdfFromHtmlStringToFile(htmlCC, pdfWorkFilePath + ccfilename); merger.AddFile(pdfWorkFilePath + filename); int counter = 0; do { counter++; if (counter > 5) { //don't get stuck in a loop. //users agreed at 5 cards printed at a time would be enough 1/2012 break; } merger.AddFile(pdfWorkFilePath + ccfilename); } while (counter < this.NumofCopies + 1); } else { merger.AddFile(pdfWorkFilePath + filename); } if (this.DrawingFilePath != null || this.DrawingFilePath != String.Empty) { HandleDrawingFile(merger); } if (this.DeviationFile1Path != null || this.DeviationFile1Path != String.Empty) { HandleDeviation1File(merger); } if (this.DeviationFile2Path != null || this.DeviationFile2Path != String.Empty) { HandleDeviation2File(merger); } if (this.QualityAlert1File != null || this.QualityAlert1File != String.Empty) { HandleQualityAlert1File(merger); } if (this.QualityAlert2File != null || this.QualityAlert2File != String.Empty) { HandleQualityAlert2File(merger); } if (this.MachineSetUpFile != null || this.MachineSetUpFile != String.Empty) { HandleMachineSetUpFile(merger); } if (this.AdditionalFilePath != null || this.AdditionalFilePath != String.Empty) { HandleAdditionalFile(merger); } if (this.DieSetUpFilePath != null || this.DieSetUpFilePath != String.Empty) { HandleDieSetUpInstructions(merger); } count++; merger.Execute(); }