コード例 #1
0
        static void PorcessReportJob()
        {
            while (true)
            {
                while (ReportJobQueue.Count > 0)
                {
                    ReportJobDesc aReportJobDesc = ReportJobQueue.Dequeue();
                    string        atgements      = aReportJobDesc.ReportJobName + "," + aReportJobDesc.UId + "," + aReportJobDesc.AllReportFileNmae + "," + aReportJobDesc.PdmRequestRegisterID + "," + aReportJobDesc.DataSourceType;
                    Process       process        = new Process();
                    process.StartInfo.FileName = reportExecPrintLocaltion;
                    //   process.StartInfo.Arguments = GetPdfCompressionSetting(FileNameOrigin, FileNameDestination, DDSetup.ReorptSetup.PdfCompressionSetting);
                    process.StartInfo.Arguments       = atgements;
                    process.StartInfo.UseShellExecute = true;
                    process.StartInfo.WindowStyle     = ProcessWindowStyle.Hidden;
                    process.StartInfo.CreateNoWindow  = true;
                    process.Start();
                    process.WaitForExit();
                }

                Thread.Sleep(10 * 1000);
            }
        }
コード例 #2
0
        static void PorcessReportJob()
        {
            while (true)
            {
                while (ReportJobQueue.Count > 0)
                {
                    ReportJobDesc aReportJobDesc = ReportJobQueue.Dequeue();
                    //string arguments =  "\""+ aReportJobDesc.ReportJobName + "," + aReportJobDesc.UId + "," + aReportJobDesc.AllReportFileNmae + "," + aReportJobDesc.ProductReferenceId + "," + aReportJobDesc.PdmRequestRegisterID + "," + aReportJobDesc.DataSourceType + "\"";
                    string  arguments = "\"" + aReportJobDesc.ReportJobName + "," + aReportJobDesc.UId + "," + aReportJobDesc.AllReportFileNmae + "," + aReportJobDesc.PdmRequestRegisterID + "," + aReportJobDesc.DataSourceType + "," + aReportJobDesc.MainReferenceID + "," + aReportJobDesc.MasterReferenceID + "\"";
                    Process process   = new Process();
                    process.StartInfo.FileName        = reportExecPrintLocaltion;
                    process.StartInfo.Arguments       = arguments;
                    process.StartInfo.UseShellExecute = true;
                    process.StartInfo.WindowStyle     = ProcessWindowStyle.Hidden;
                    process.StartInfo.CreateNoWindow  = true;
                    process.Start();
                    process.WaitForExit();
                }

                Thread.Sleep(10 * 1000);
            }
        }
コード例 #3
0
        internal static void PrintUserReportJob(ReportJobDesc aReportJobDesc)
        {
            string reportJobName = aReportJobDesc.ReportJobName;
            int?   aUId          = aReportJobDesc.UId;
            string allReportFileNameAndReferenceID = aReportJobDesc.AllReportFileNmae;
            // string productReferenceId = aReportJobDesc.ProductReferenceId;
            string PdmRequestRegisterID = aReportJobDesc.PdmRequestRegisterID;
            string dataSourceType       = aReportJobDesc.DataSourceType;

            string mainReferenceID   = aReportJobDesc.MainReferenceID;
            string masterReferenceID = aReportJobDesc.MasterReferenceID;



            if (allReportFileNameAndReferenceID != string.Empty)
            {
                // only create once !!

                // var dictReportNameAndFileName = DDSetup.GetDictUserReportNameAndFileNameReports(aUId.Value);

                string[] reportnames = allReportFileNameAndReferenceID.Split('|');

                List <Stream> pdfFileStream = new List <Stream>();

                foreach (String reportFileNameWithRef in reportnames)
                {
                    if (string.IsNullOrEmpty(reportFileNameWithRef))
                    {
                        continue;
                    }

                    string[] reportNameAndRef = reportFileNameWithRef.Split('^');
                    if (reportNameAndRef.Length != 2)
                    {
                        continue;
                    }

                    string reportName = reportNameAndRef[0];

                    string reportFileName = DDSetup.GetUserReportFileName(aUId.Value, reportName);

                    if (string.IsNullOrEmpty(reportFileName))
                    {
                        continue;
                    }



                    string reportRefId = reportNameAndRef[1];



                    // Cyrstal report
                    if (reportFileName.EndsWith(".rpt") || reportFileName.EndsWith(".RPT"))
                    {
                        Stream result = CystalReportExport.GetCrystalPdfStream(reportFileName, aUId, reportRefId, PdmRequestRegisterID, dataSourceType, mainReferenceID, masterReferenceID);
                        if (result != null)
                        {
                            pdfFileStream.Add(result);
                        }
                    }
                    // Data Dynamics
                    else if (reportFileName.EndsWith(".rdlx") || reportFileName.EndsWith(".RDLX"))
                    {
                        Stream result = DataDynamicsExport.GetDataDynamicPdfStream(reportFileName, aUId, reportRefId, PdmRequestRegisterID, dataSourceType, mainReferenceID, masterReferenceID);

                        if (result != null)
                        {
                            pdfFileStream.Add(result);
                        }
                    }
                }



                string fileID = Guid.NewGuid().ToString();
                string needToSaveDBFileName = string.Empty;
                string FileNameOrigin       = string.Empty;

                using (PdfDocument outputDocument = new PdfDocument())
                {
                    foreach (Stream stream in pdfFileStream)
                    {
                        // Open the document to import pages from it.

                        if (stream.Length > 0)
                        {
                            using (PdfDocument inputDocument = PdfReader.Open(stream, PdfDocumentOpenMode.Import))
                            {
                                // Iterate pages
                                int count = inputDocument.PageCount;
                                for (int idx = 0; idx < count; idx++)
                                {
                                    // Get the page from the external document...
                                    PdfPage page = inputDocument.Pages[idx];
                                    // ...and add it to the output document.
                                    outputDocument.AddPage(page);
                                }
                                stream.Close();
                                stream.Dispose();
                            }
                        }
                    }

                    FileNameOrigin       = DDSetup.ReorptSetup.ReportPdfCompressPath + "Origin_" + fileID + ".pdf";
                    needToSaveDBFileName = FileNameOrigin;
                    outputDocument.Save(FileNameOrigin);
                }

                if (DDSetup.ReorptSetup.IsReportCompressionActivate)
                {
                    string FileNameDestination = DDSetup.ReorptSetup.ReportPdfCompressPath + "Dest_" + fileID + ".pdf";

                    bool result = ReportJobManagement.PdfCompression(FileNameOrigin, FileNameDestination);
                    if (result)
                    {
                        File.Delete(FileNameOrigin);
                        needToSaveDBFileName = FileNameDestination;
                    }
                }

                using (SqlConnection conn = new SqlConnection(DDSetup.PLMConnectionString))
                {
                    conn.Open();
                    string insertsql = "Insert into [pdmPrintJob] (CreatedBy,CreatedDate,Name,FileName) VALUES( @CreatedBy, @CreatedDate,@Name, @FileName)";

                    SqlCommand insertCmd = new SqlCommand(insertsql, conn);

                    insertCmd.Parameters.Add("@CreatedBy", aUId);

                    insertCmd.Parameters.Add("@CreatedDate", System.DateTime.UtcNow);

                    insertCmd.Parameters.Add("@Name", reportJobName);

                    insertCmd.Parameters.Add("@FileName", needToSaveDBFileName);

                    insertCmd.ExecuteNonQuery();

                    conn.Close();
                }
            }
        }