コード例 #1
0
        //关闭当前文档
        private bool CloseMainDoc()
        {
            //TODO 提示保存

            //清理内部变量
            _activeVM = null;
            _doc      = null;
            FileName  = "";
            _open_docs.Clear();
            return(true);
        }
コード例 #2
0
 public Outcome setMainDocument(string usernName, string sPassword, MainDocument oMainDoc, string sGuidCard)
 {
     #region Inizializzazione oggetti
     Outcome esito = new Outcome();
     #endregion
     using (var wsAction = new WsAction("setMainDocument"))
     {
         esito = wsAction.setMainDocument(usernName, sPassword, oMainDoc, sGuidCard);
     }
     return(esito);
 }
コード例 #3
0
        /// <summary>
        /// Adds end of record indicator to the end of the report
        /// </summary>
        private void AddEndOfRecordIndicator()
        {
            // Adds END OF RECORD statement to the end of the document
            Paragraph EndOfRecord = new Paragraph();

            EndOfRecord.Add("*** END OF RECORD ***");
            EndOfRecord.SetHorizontalAlignment(HorizontalAlignment.CENTER);
            EndOfRecord.SetTextAlignment(TextAlignment.CENTER);
            EndOfRecord.SetFont(m_FONT_CourierBold);
            EndOfRecord.SetFontSize(10);
            MainDocument.Add(EndOfRecord);
        }
コード例 #4
0
        public Outcome base64ToPdfA(MainDocument mainDoc, out MainDocument mainDocOut)
        {
            #region Inizializzazione oggetti

            mainDocOut = null;
            Outcome esito = new Outcome();
            #endregion
            using (var wsAction = new WsAction("base64ToPdfA"))
            {
                esito = wsAction.base64ToPdfA(mainDoc, out mainDocOut);
            }
            return(esito);
        }
コード例 #5
0
        public Outcome getCRC32bFromFilePdf(MainDocument filePdf, out string CRC32b)
        {
            #region Inizializzazione oggetti

            CRC32b = "";
            Outcome esito = new Outcome();
            #endregion
            using (var wsAction = new WsAction("getCRC32bFromFilePdf"))
            {
                esito = wsAction.getCRC32bFromFilePdf(filePdf, out CRC32b);
            }
            return(esito);
        }
コード例 #6
0
/*
 *      1.	26/10/2018: Rilascio comprensivo di test dei servizi: setMainDoc; setAttachment; setInternalAttachment;
 *      2.	29/10/2018: Eventuale assistenza alla integrazione;
 *      3.	06/11/2018: Rilascio comprensivo di test dei servizi: getIndexConfigFromTypeDocument; getSignCheck; base64ToPdfA (*);
 *      4.	07/11/2018: Eventuale assistenza alla integrazione;
 *      5.	12/11/2018: Rilascio comprensivo di test dei servizi: createPdfAFromTemplate; setCard; getCard;
 *      6.	13/11/2018: eventuale assistenza alla integrazione;
 *      7.	14/11/2018: Test di integrazione complessivi;
 *
 * Per i test di questi servizi e necessaria l’installazione della libreria Easy PDF 8 e del pacchetto Office 2016.
 *
 *      Note generali
 *      •	E’ necessario creare una utenza di servizio (Archiflow), che verrà utilizzata dall’esterno per la login in AF e la fruizione dei servizi.
 *      •	Nel secondo rilascio (punto 3) sono incluse le modifiche ed i test ai processi massivi per l’utilizzo di easyPdf8 tramite servizio.
 */
        public Outcome getSignCheck(MainDocument mainDoc, string sCRC32, List <String> lNIN, bool bGetDocWithoutSign, out MainDocumentChecked mainDocOut)
        {
            #region Inizializzazione oggetti

            mainDocOut = null;
            Outcome esito = new Outcome();
            #endregion
            using (var wsAction = new WsAction("SignCheck"))
            {
                esito = wsAction.getSignCheck(mainDoc, sCRC32, lNIN, bGetDocWithoutSign, out mainDocOut);
            }
            return(esito);
        }
コード例 #7
0
ファイル: WsAction.cs プロジェクト: OcfSiav/apflibrary904
        public Outcome base64ToPdfA(MainDocument mainDoc, out MainDocument mainDocOut)
        {
            string strMessage = "";

            mainDocOut = new MainDocument();
            Outcome esito = new Outcome();

            esito.iCode          = 1;
            esito.sTransactionId = LogId;
            try
            {
                if (mainDoc.Validate(out strMessage))
                {
                    Logger.WriteOnLog(LogId, "Oggetto da convertire: " + mainDoc.ToXml(), 3);
                    Convert2PdfManager oConvert2PdfManager = new Convert2PdfManager();
                    oConvert2PdfManager.ConvertMainDoc(mainDoc, Logger, sWorkingFolder, LogId, out mainDocOut);
                }
                else
                {
                    Logger.WriteOnLog(LogId, "Oggetto NON Convertito: " + mainDoc.ToXml(), 3);
                    esito.iCode = 0;
                }
            }
            catch (Exception e)
            {
                esito.iCode = 0;
                strMessage  = e.Message;
                Logger.WriteOnLog(LogId, e.Source + " -> " + e.StackTrace + " -> " + e.Message, 3);
            }
            finally
            {
                Logger.WriteOnLog(LogId, "Fine elaborazione", 3);
                esito.sDescription = strMessage;
                if (esito.iCode == 1)
                {
                    Logger.WriteOnLog(LogId, esito.iCode + " - " + strMessage, 3);
                    Logger.RenameFileLog(LogId, "OK_" + LogId);
                }
                else
                {
                    Logger.WriteOnLog(LogId, esito.iCode + " - " + strMessage, 3);
                    Logger.RenameFileLog(LogId, "KO_" + LogId);
                }
            }
            return(esito);
        }
コード例 #8
0
        public HelpWindow()
        {
            InitializeComponent();

            Version version = typeof(MainWindow).Assembly.GetName().Version;

            Version.Inlines.Clear();
            Version.Inlines.Add(new Run($"Version: {version.Major}.{version.Minor}.{version.Build}"));

            // Generate copyright text based on the current year.
            //Copyright.Text = $"Copyright \u00a9 {DateTime.Now.Year.ToString()} Ryan Smith";
            Copyright.Inlines.Clear();
            Copyright.Inlines.Add(new Run($"Copyright \u00a9 {DateTime.Now.Year.ToString()} Ryan Smith"));

            // Set initial focus to scrollviewer.  That way you can scroll the help window with the keyboard
            // without having to first click in the window.
            MainDocument.Focus();
        }
コード例 #9
0
        //创建一个空文件
        private MainDocument GetNewMainDoc()
        {
            var mdoc = new MainDocument();

            foreach (var m in _ms.Values)
            {
                var fs = m.GetNewFiles();
                if (fs == null)
                {
                    continue;
                }
                foreach (var f in fs)
                {
                    mdoc.AddFileContent(f);
                }
            }

            return(mdoc);
        }
コード例 #10
0
        /// <summary>
        /// Generates the header that will be assigned to our <see cref="MainDocument"/>
        /// </summary>
        private void HeaderGenerator()
        {
            // Adds date to header if the Report indicates that it should be done
            AddDateToHeader();

            // Create table that will hold header
            Table HeaderContent = new Table(1);

            HeaderContent.SetWidth(UnitValue.CreatePercentValue(95));
            HeaderContent.SetBorder(Border.NO_BORDER);
            HeaderContent.SetHorizontalAlignment(HorizontalAlignment.CENTER);
            HeaderContent.SetMarginBottom(20);

            // Create cell that will hold header paragraph
            Cell HeaderContentTextCell = new Cell();

            HeaderContentTextCell.SetHorizontalAlignment(HorizontalAlignment.CENTER);
            HeaderContentTextCell.SetBorder(Border.NO_BORDER);

            // Create paragraph that will hold header text
            Paragraph HeaderContentParagraph = new Paragraph();

            // Set up paragraph
            HeaderContentParagraph.SetBorder(Border.NO_BORDER);
            HeaderContentParagraph.SetTextAlignment(TextAlignment.CENTER);
            HeaderContentParagraph.Add(Report.HeaderText);
            HeaderContentParagraph.SetHorizontalAlignment(HorizontalAlignment.CENTER);
            HeaderContentParagraph.SetVerticalAlignment(VerticalAlignment.MIDDLE);
            HeaderContentParagraph.SetFont(m_FONT_Courier);
            HeaderContentParagraph.SetFontSize(10);

            // Combine elements and add to main document
            HeaderContentTextCell.Add(HeaderContentParagraph);
            HeaderContent.AddCell(HeaderContentTextCell);
            MainDocument.Add(HeaderContent);
        }
コード例 #11
0
 //从对象打开文档
 private void OpenMainDoc(MainDocument doc)
 {
     //TODO 判断文件版本 如果需要进行升级处理
     _doc = doc;
     //TODO 打开文件内容
 }
コード例 #12
0
        public string ConvertMainDoc(MainDocument oMainDoc, Util.LOLIB logger, string sWorkingFolder, string LogId, out MainDocument oMainDocPdf)
        {
            string sFileContentPdf = string.Empty;

            oMainDocPdf = new MainDocument();
            try
            {
                sFileContentPdf = string.Empty;
                Byte[] sResult;
                using (Printer oPrinter = new Printer())
                {
                    string sFileExtension = Path.GetExtension(oMainDoc.Filename).ToUpper();
                    logger.WriteOnLog(LogId, "Estensione: " + sFileExtension, 3);
                    if ("BMP,GIF,JPEG,PNG,TIFF,TIF,WMF,EMF".IndexOf(sFileExtension) > -1)
                    {
                        logger.WriteOnLog(LogId, "Entro conversione image: " + sFileExtension, 3);
                        //ImagePrintJob oPrintJob = oPrinter.ImagePrintJob;
                        //oPrintJob.NativeOfficePDF = true;
                        //oPrintJob.NativeOfficeStandardPDFA = true;
                        //sResult = oPrintJob.PrintOut3(oMainDoc.oByte, sFileExtension);
                        var oPDFSetting = oPrinter.PrinterSetting;
                        oPDFSetting.LayoutPaperSize = (int)prnPaperSize.PRN_PAPER_A4;

                        //oPDFSetting.LayoutPaperOrientation = prnPaperOrientation.PRN_PAPER_ORIENT_LANDSCAPE;
                        oPDFSetting.FontEmbedding = prnFontEmbedding.PRN_FONT_EMBED_NONE;
                        oPDFSetting.Save();
                        oPrinter.PrintJob.PDFSetting.StandardPdfAConformance = prnPdfAConformance.PRN_PDFA_CONFORM_1B_TC1;
                        oPrinter.PrintJob.PDFSetting.StandardPdfXConformance = prnPdfXConformance.PRN_PDFX_CONFORM_NONE;
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        sResult         = oPrinter.PrintJob.PrintOut3(temp_backToBytes, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    else if ("PPTX,PPS".IndexOf(sFileExtension) > -1)
                    {
                        logger.WriteOnLog(LogId, "Entro conversione power point: " + sFileExtension, 3);
                        PowerPointPrintJobEx oPrintJob = oPrinter.PowerPointPrintJobEx;
                        //oPrintJob.NativeOfficePDF = true;
                        //oPrintJob.NativeOfficeStandardPDFA = true;
                        oPrintJob.FrameSlides = true;
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        sResult         = oPrintJob.PrintOut3(temp_backToBytes, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    else if ("HTML,HTM,XHTML,XML".IndexOf(sFileExtension) > -1)
                    {
                        logger.WriteOnLog(LogId, "Entro conversione HTML: " + sFileExtension, 3);
                        IEExtendedPrintJob oPrintJob  = oPrinter.IEExtendedPrintJob;
                        IEExtendedSetting  oIESetting = oPrintJob.IEExtendedSetting;

                        oIESetting.DisableScriptDebugger          = true;
                        oIESetting.DisplayErrorDialogOnEveryError = false;
                        oIESetting.Save();

                        oPrintJob.PageWidth  = 11.93;
                        oPrintJob.PageHeight = 15.98;
                        //oPrintJob.ContentOrientation = prnContentOrientation.;
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        sResult         = oPrintJob.PrintOut3(temp_backToBytes, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    else if ("EML".IndexOf(sFileExtension) > -1)
                    {
                        logger.WriteOnLog(LogId, "Entro conversione eml: " + sFileExtension, 3);
                        PrintJob oPrintJob = oPrinter.PrintJob;
                        //oPrintJob.QueueWaitTimeout = 100000;
                        //sResult = oPrintJob.PrintOut3(oMainDoc.oByte, sFileExtension);
                        //sFileContentPdf = Convert.ToBase64String(sResult);

                        string sPathFileTemp = sWorkingFolder + "\\test." + sFileExtension;
                        logger.WriteOnLog(LogId, "path file di input: " + sPathFileTemp, 3);
                        string sPathPDFTemp = sWorkingFolder + "\\test.pdf";
                        logger.WriteOnLog(LogId, "path file di output: " + sPathPDFTemp, 3);
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        File.WriteAllBytes(@sPathFileTemp, temp_backToBytes);
                        logger.WriteOnLog(LogId, "File di input creato : " + sPathFileTemp, 3);
                        System.Threading.Thread.Sleep(5000);
                        oPrintJob.PrintOut(@sPathFileTemp, @sPathPDFTemp);
                        logger.WriteOnLog(LogId, "File di output creato : " + sPathPDFTemp, 3);
                        sResult = File.ReadAllBytes(@sPathPDFTemp);
                        //sResult = oPrintJob.PrintOut3(oMainDoc.oByte, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    else if ("DOCX,RTF".IndexOf(sFileExtension) > -1)
                    {
                        logger.WriteOnLog(LogId, "Entro conversione word: " + sFileExtension, 3);
                        WordPrintJobEx oPrintJob = oPrinter.WordPrintJobEx;
                        oPrintJob.NativeOfficePDF          = true;
                        oPrintJob.NativeOfficeStandardPDFA = true;
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        sResult         = oPrintJob.PrintOut3(temp_backToBytes, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    else if ("ODT,SWX,WPD,ODS,SXC,ODP,SXI,ODG,SXD".IndexOf(sFileExtension) > -1)
                    {
                        logger.WriteOnLog(LogId, "Entro conversione Open Offices: " + sFileExtension, 3);
                        OpenOfficePrintJob oPrintJob = oPrinter.OpenOfficePrintJob;
                        oPrintJob.ConvertBookmarks = true;
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        sResult         = oPrintJob.PrintOut3(temp_backToBytes, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    else if ("XLSX,CSV".IndexOf(sFileExtension) > -1)
                    {
                        logger.WriteOnLog(LogId, "Entro conversione excel: " + sFileExtension, 3);
                        ExcelPrintJobEx oPrintJob = oPrinter.ExcelPrintJobEx;
                        //oPrintJob.NativeOfficePDF = true;
                        //oPrintJob.NativeOfficeStandardPDFA = true;
                        oPrintJob.PrintAllSheets  = true;
                        oPrintJob.NativeOfficePDF = true;
                        string sPathFileTemp = sWorkingFolder + "\\test." + sFileExtension;
                        logger.WriteOnLog(LogId, "path file di input: " + sPathFileTemp, 3);
                        string sPathPDFTemp = sWorkingFolder + "\\test.pdf";
                        logger.WriteOnLog(LogId, "path file di output: " + sPathPDFTemp, 3);
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        File.WriteAllBytes(@sPathFileTemp, temp_backToBytes);
                        logger.WriteOnLog(LogId, "File di input creato : " + sPathPDFTemp, 3);
                        oPrintJob.PrintOut(@sPathFileTemp, @sPathPDFTemp);
                        logger.WriteOnLog(LogId, "File di output creato : " + sPathPDFTemp, 3);
                        sResult = File.ReadAllBytes(@sPathPDFTemp);
                        //sResult = oPrintJob.PrintOut3(oMainDoc.oByte, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                        //oPrinter.PrintJob.PDFSetting.StandardPdfAConformance = prnPdfAConformance.PRN_PDFA_CONFORM_1B_TC1;
                        //oPrinter.PrintJob.PDFSetting.Save();
                        //sResult = oPrinter.PrintJob.PrintOut3(oMainDoc.oByte, sFileExtension);
                        //sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    else
                    {
                        logger.WriteOnLog(LogId, "Entro conversione generica: " + sFileExtension, 3);
                        var oPrintJob   = oPrinter.PrintJob;
                        var oPDFSetting = oPrintJob.PDFSetting;
                        oPDFSetting.FontEmbedding           = prnFontEmbedding.PRN_FONT_EMBED_NONE;
                        oPDFSetting.StandardPdfAConformance = prnPdfAConformance.PRN_PDFA_CONFORM_NONE;
                        oPDFSetting.StandardPdfXConformance = prnPdfXConformance.PRN_PDFX_CONFORM_NONE;
                        oPDFSetting.Save();
                        byte[] temp_backToBytes = Convert.FromBase64String(oMainDoc.BinaryContent);
                        sResult         = oPrintJob.PrintOut3(temp_backToBytes, sFileExtension);
                        sFileContentPdf = Convert.ToBase64String(sResult);
                    }
                    oMainDocPdf.Filename      = Path.GetFileNameWithoutExtension(oMainDoc.Filename) + ".pdf";
                    oMainDocPdf.BinaryContent = Convert.ToBase64String(sResult);
                }
            }
            catch (Exception ex)
            { throw ex; }
            finally
            {
            }
            return(sFileContentPdf);
        }
コード例 #13
0
        public Outcome createPdfAFromTemplate(string[][] aReplaceNameValue, string sGuidCard, out MainDocument mainDocOut)
        {
            #region Inizializzazione oggetti

            mainDocOut = null;
            Outcome esito = new Outcome();
            #endregion
            using (var wsAction = new WsAction("createPdfAFromTemplate"))
            {
                esito = wsAction.createPdfAFromTemplate(aReplaceNameValue, sGuidCard, out mainDocOut);
            }
            return(esito);
        }
コード例 #14
0
        /// <summary>
        /// Adds all body content to the report
        /// </summary>
        private void AddBodyContent()
        {
            // Create a table to hold the body of the report
            // NOTE: Set column count to that of the Report DataTable
            Table BodyContent = new Table(Report.ReportData.Columns.Count);

            // Sets the table width
            BodyContent.SetWidth(UnitValue.CreatePercentValue(95));

            // Set table positioning
            BodyContent.SetHorizontalAlignment(HorizontalAlignment.CENTER);

            // Sets the spacing after the table
            BodyContent.SetMarginBottom(5);


            // For each column in the Report Data, add a header cell with the column's name
            foreach (DataColumn column in Report.ReportData.Columns)
            {
                // Create cell
                Cell HeaderCell = new Cell();
                // Set cell background and border
                HeaderCell.SetBackgroundColor(ColorConstants.LIGHT_GRAY);
                HeaderCell.SetBorder(Border.NO_BORDER);
                // Create a paragraph to hold the header cell text
                Paragraph HeaderCellText = new Paragraph(column.ColumnName);
                // Set up the text formatting in the header cell paragraph
                HeaderCellText.SetFont(m_FONT_CourierBold);
                HeaderCellText.SetFontSize(8);
                HeaderCellText.SetTextAlignment(TextAlignment.CENTER);
                // Add paragraph to cell
                HeaderCell.Add(HeaderCellText);
                // Add cell to Header row in Body Content
                BodyContent.AddHeaderCell(HeaderCell);
            }

            // Creates each row based on data in table
            foreach (DataRow dr in Report.ReportData.Rows)
            {
                for (int i = 0; i < Report.ReportData.Columns.Count; i++)
                {
                    // Create cell and paragraph to hold text
                    Cell      CellContent     = new Cell();
                    Paragraph CellContentText = new Paragraph();

                    // Set up cell for proper formatting
                    CellContent.SetBorder(Border.NO_BORDER);
                    CellContent.SetFontSize(8);
                    CellContent.SetHorizontalAlignment(HorizontalAlignment.LEFT);

                    // If particular column is indicated in the Report's ColumnsToTreatAsDateTime array
                    // Attempt to parse column as a DateTime, if fails, take value as is
                    // NOTE: This operation will always default to raw data if the column is not
                    // indicated in the array
                    if (Report.ColumnsToTreatAsDateTime.Contains(i))
                    {
                        DateTime outputDateTime;
                        if (DateTime.TryParse(dr[i].ToString(), out outputDateTime))
                        {
                            CellContentText.Add(outputDateTime.ToShortDateString());
                            CellContent.Add(CellContentText);
                            BodyContent.AddCell(CellContent);
                        }
                        else
                        {
                            CellContentText.Add(dr[i].ToString());
                            CellContent.Add(CellContentText);
                            BodyContent.AddCell(CellContent);
                        }
                    }
                    // Default if the column is not listed in the DateTime checking array
                    else
                    {
                        CellContentText.Add(dr[i].ToString());
                        CellContent.Add(CellContentText);
                        BodyContent.AddCell(CellContent);
                    }
                }
            }

            // Adds the body content to the document
            MainDocument.Add(BodyContent);
        }