Esempio n. 1
0
        private static void SetPrintSettings(FastReport.Report report, long lReportTemplateID)
        {
            DataRow   drReport         = null;
            DataTable dtReportTemplate = ReportHelper.GetReportTemplateByID(lReportTemplateID);

            if (dtReportTemplate.Rows.Count > 0)
            {
                drReport = dtReportTemplate.Rows[0];
            }
            //DataTable dtReportTemplate = ExecuteSQL.CallView(105, "", "ReportTemplateID=" + lReportTemplateID, "");
            if (drReport != null)
            {
                //DataRow drReport = dtReportTemplate.Rows[0];
                string strPrinterName    = drReport["PrinterName"].ToString().TrimEnd();
                string strPaperType      = drReport["PaperType"].ToString().TrimEnd();
                int    PaperSizeHeight   = LBConverter.ToInt32(drReport["PaperSizeHeight"]);
                int    PaperSizeWidth    = LBConverter.ToInt32(drReport["PaperSizeWidth"]);
                bool   IsManualPaperType = LBConverter.ToBoolean(drReport["IsManualPaperType"]); //自动识别纸张类型
                bool   IsManualPaperSize = LBConverter.ToBoolean(drReport["IsManualPaperSize"]); //自动识别纸张大小
                bool   IsPaperTransverse = LBConverter.ToBoolean(drReport["IsPaperTransverse"]); //是否纵向打印

                if (strPrinterName != "")
                {
                    report.PrintSettings.Printer = strPrinterName;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新本地报表以及参数
        /// </summary>
        /// <param name="lReportTemplateID"></param>
        public static void ResetLocalReport(long lReportTemplateID, DataSet dsSource, DataRow drRecord)
        {
            DataTable dtReportTemplateConfig = ReportHelper.GetReportTemplateByID(lReportTemplateID);

            if (dtReportTemplateConfig.Rows.Count == 0)
            {
                return;
            }
            DataRow drReportTemplateConfig = dtReportTemplateConfig.Rows[0];

            byte[]   reportTempleData         = (byte[])drReportTemplateConfig["TemplateData"];
            long     lReportTypeID            = Convert.ToInt64(drReportTemplateConfig["ReportTypeID"]);
            DateTime dtTemplateFileTime       = DateTime.Parse(drReportTemplateConfig["TemplateFileTime"].ToString());
            string   strReportTemplateName    = drReportTemplateConfig["ReportTemplateName"].ToString().Trim();
            string   strReportTemplateNameExt = drReportTemplateConfig["ReportTemplateNameExt"].ToString().Trim();
            //检测本地是否存在报表文件,如果不存在或者与服务器比本地文件新时更新本地文件
            string strFileFullName = WriteReportWithCheck(lReportTemplateID, strReportTemplateName, dtTemplateFileTime, reportTempleData, strReportTemplateNameExt);

            ReportRequestArgs args = new ReportRequestArgs(lReportTemplateID, lReportTypeID, dsSource, drRecord);

            using (FastReport.Report report = new FastReport.Report())
            {
                report.Load(strFileFullName);
                BuildParmsAndData(args, report, enBuildParmsAndDataActionType.ReSet);
                report.Save(strFileFullName);
                File.SetLastWriteTime(strFileFullName, DateTime.Now);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 更新本地FastReport报表文件,先判断本地是否最新,如果非最新或者不存在,则更新本地文件
        /// </summary>
        /// <param name="lReportTemplateID"></param>
        public static bool RefleshClientReport(long lReportTemplateID, out string strReportFileName)
        {
            bool bolExists = false;

            strReportFileName = "";
            //DataTable dtReportTemp = ExecuteSQL.CallView(105, "", "ReportTemplateID=" + lReportTemplateID, "");

            DataRow   drReportTemp     = null;
            DataTable dtReportTemplate = ReportHelper.GetReportTemplateByID(lReportTemplateID);

            if (dtReportTemplate.Rows.Count > 0)
            {
                drReportTemp = dtReportTemplate.Rows[0];
            }
            if (drReportTemp != null)
            {
                string   strReportTemplateName    = drReportTemp["ReportTemplateName"].ToString().TrimEnd();
                DateTime dTemplateFileTime        = Convert.ToDateTime(drReportTemp["TemplateFileTime"]);
                string   strReportTemplateNameExt = drReportTemp["ReportTemplateNameExt"].ToString().TrimEnd();
                byte[]   bTemplateData            = drReportTemp["TemplateData"] as byte[];

                string strReportFullName = Path.Combine(ReportPath, strReportTemplateName + strReportTemplateNameExt);
                if (File.Exists(strReportFullName))
                {
                    FileInfo fiReport = new FileInfo(strReportFullName);
                    if (fiReport.LastWriteTime < dTemplateFileTime)//服务器报表更新时间与本地时间不一样时,先更新本地报表
                    {
                        /*if (LB.WinFunction.LBCommonHelper.ConfirmMessage("本地报表与服务器不一致,是否更新本地报表文件?", "提示", MessageBoxButtons.YesNo)==
                         *  DialogResult.Yes)
                         * {
                         *  File.Delete(strReportFullName);
                         *  ConvertToReportFile(bTemplateData, strReportFullName, dTemplateFileTime);
                         * }*/
                        File.Delete(strReportFullName);
                        ConvertToReportFile(bTemplateData, strReportFullName, dTemplateFileTime);
                        bolExists = true;
                    }
                    else
                    {
                        bolExists = true;
                    }
                }
                else
                {
                    ConvertToReportFile(bTemplateData, strReportFullName, dTemplateFileTime);
                    bolExists = true;
                }
                strReportFileName = strReportFullName;
            }
            else
            {
                throw new Exception("该报表不存在!");
            }
            return(bolExists);
        }
Esempio n. 4
0
        public static FastReport.Report GetReport(ReportRequestArgs e)
        {
            DataTable dtReportTemplateConfig = ReportHelper.GetReportTemplateByID(e.ReportTemplateID);

            if (dtReportTemplateConfig.Rows.Count == 0)
            {
                return(null);
            }
            DataRow drReportTemplateConfig = dtReportTemplateConfig.Rows[0];

            e.ReportTemplateConfig = drReportTemplateConfig;

            long lReportTemplateID = Convert.ToInt64(e.ReportTemplateConfig["ReportTemplateID"]);

            byte[]   reportTempleData         = (byte[])e.ReportTemplateConfig["TemplateData"];
            DateTime dtTemplateFileTime       = DateTime.Parse(e.ReportTemplateConfig["TemplateFileTime"].ToString());
            string   strReportTemplateName    = e.ReportTemplateConfig["ReportTemplateName"].ToString().Trim();
            string   strReportTemplateNameExt = e.ReportTemplateConfig["ReportTemplateNameExt"].ToString().Trim();
            //检测本地是否存在报表文件,如果不存在或者与服务器比本地文件新时更新本地文件
            string strFileFullName = WriteReportWithCheck(lReportTemplateID, strReportTemplateName, dtTemplateFileTime, reportTempleData, strReportTemplateNameExt);

            ProcessStep.AddStep("WriteReportWithCheck_End", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);

            // 加载模板
            FastReport.Report report = null;

            //Form frm = null;
            try
            {
                //frm = new Form();
                report = new FastReport.Report();
                ProcessStep.AddStep("Report_New", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                report.FinishReport += Report_FinishReport;
                report.Load(strFileFullName);
                ProcessStep.AddStep("Report_Load", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                // 纸张设置
                //SetPaperAuto(report, iReportTemplateID);

                BuildParmsAndData(e, report, enBuildParmsAndDataActionType.SetValue);
                ProcessStep.AddStep("BuildParmsAndData", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
                //ReportPreviewer previewer = new Report.ReportPreviewer(report);

                SetPrintSettings(report, lReportTemplateID);
                ProcessStep.AddStep("SetPrintSettings", DateTime.Now.ToString("MMdd HH:mm:ss ") + DateTime.Now.Millisecond);
            }
            catch (Exception ex)
            {
            }
            return(report);
        }
Esempio n. 5
0
        private void ReadFieldValue()
        {
            DataTable dtReport = ReportHelper.GetReportTemplateByID(mReportArgs.ReportTemplateID);

            if (dtReport.Rows.Count > 0)
            {
                DataRow drReport = dtReport.Rows[0];
                this.txtReportTemplateName.Text   = drReport["ReportTemplateName"].ToString();
                this.txtDescription.Text          = drReport["Description"].ToString();
                this.txtPrinterName.SelectedValue = drReport["PrinterName"].ToString().TrimEnd();
                this.txtPaperType.SelectedValue   = drReport["PaperType"].ToString().TrimEnd();
                this.txtPaperSizeHeight.Text      = drReport["PaperSizeHeight"].ToString().TrimEnd();
                this.txtPaperSizeWidth.Text       = drReport["PaperSizeWidth"].ToString().TrimEnd();
                this.rbManualPaperType.Checked    = drReport["IsManualPaperType"] == DBNull.Value ?
                                                    false : Convert.ToBoolean(drReport["IsManualPaperType"]);
                this.rbManualPaperSize.Checked = drReport["IsManualPaperSize"] == DBNull.Value ?
                                                 false : Convert.ToBoolean(drReport["IsManualPaperSize"]);
                this.rbPaperTransverse.Checked = drReport["IsPaperTransverse"] == DBNull.Value ?
                                                 false : Convert.ToBoolean(drReport["IsPaperTransverse"]);
                this.txtPrintCount.Text = drReport["PrintCount"].ToString().TrimEnd();
                //this.txtReportPath.Text = Path.Combine(ReportHelper.ReportPath, drReport["ReportTemplateName"].ToString() + ".frx");
            }
        }