Exemple #1
0
        public static WebbReport LoadReport(string i_ReportID)
        {
            if (i_ReportID == null || i_ReportID == string.Empty)
            {
                return(null);
            }

            string m_FilePath = ReportTemplate.GetTemplateFilePath(i_ReportID);

            WebbReport m_Report = new WebbReport();

            if (File.Exists(m_FilePath))
            {
                m_Report.LoadLayout(m_FilePath);
            }

            return(m_Report);
        }
Exemple #2
0
        public Webb.Reports.WebbReport CreateReport(string exePath, string templatePath)
        {
            if (!this._IsCommandInitialized)
            {
                return(null);
            }

            string strXtraReportFilePath = templatePath;

            WebbReport m_Report = null;

            bool ClickEvent = VideoPlayBackManager.ClickEvent;

            if (strXtraReportFilePath != string.Empty)
            {
                m_Report = new WebbReport();

                if (File.Exists(strXtraReportFilePath))
                {
                    Webb.Utility.ReplaceRefPathInRepxFile(strXtraReportFilePath, exePath);                      //Modify template file

                    m_Report.LoadLayout(strXtraReportFilePath);

                    Webb.Utility.CurFileName = strXtraReportFilePath;                  //06-23-2008@Scott

                    #region Modify codes at 2009-4-9 10:26:35@Simon                    //
                    string strWebbReportTemplateFilePath = strXtraReportFilePath.Replace(Webb.Utility.ReportExt, Webb.Utility.WebbReportExt);

                    if (strWebbReportTemplateFilePath.EndsWith(Webb.Utility.WebbReportExt) && File.Exists(strWebbReportTemplateFilePath))
                    {
                        File.Delete(strWebbReportTemplateFilePath);
                    }
                    #endregion                            //End Modify
                }
            }
            VideoPlayBackManager.ClickEvent = ClickEvent;

            return(m_Report);
        }
        public Webb.Reports.WebbReport CreateReport(string exePath, string templatePath)
        {
            if (!this._IsCommandInitialized)
            {
                return(null);
            }

            string strXtraReportFilePath = templatePath;

            WebbReport m_Report = null;

            if (strXtraReportFilePath != string.Empty)
            {
                m_Report = new WebbReport();

                if (File.Exists(strXtraReportFilePath))
                {
                    Webb.Utility.ReplaceRefPathInRepxFile(strXtraReportFilePath, exePath);                      //Modify template file

                    m_Report.LoadLayout(strXtraReportFilePath);

                    Webb.Utility.CurFileName = strXtraReportFilePath;                           //06-23-2008@Scott

                    string strWebbReportTemplateFilePath = strXtraReportFilePath.Replace(Webb.Utility.ReportExt, Webb.Utility.WebbReportExt);

                    if (File.Exists(strWebbReportTemplateFilePath))
                    {
                        WebbReportTemplate template = new WebbReportTemplate();

                        template.Load(strWebbReportTemplateFilePath);

                        m_Report.ApplyTemplate(template);
                    }
                }
            }

            return(m_Report);
        }
        //10-14-2011 Scott Read
        public string CreatePlayerReport(DataSet ds, string strDestineFile, string dllpath, string strUserFolder, string[] templateFiles)
        {
            WebbLog.Instance.WriteLog("AdjustPDFFile");

            strDestineFile = AdjustPDFFile(strDestineFile);

            WebbLog.Instance.WriteLog("AdjustPDFFile Complete");

            if (!strUserFolder.EndsWith(@"\"))
            {
                strUserFolder += @"\";
            }

            WebbLog.Instance.WriteLog("new WebbReport");

            XtraReport[] preparedReports = new WebbReport[templateFiles.Length];

            WebbLog.Instance.WriteLog("new WebbReport Complete");

            try
            {
                if (System.IO.File.Exists(strDestineFile))
                {
                    System.IO.File.Delete(strDestineFile);
                }

                WebbLog.Instance.WriteLog("ReplaceImagePathAndUnionTable");

                ds = this.ReplaceImagePathAndUnionTable(ds, strUserFolder);

                WebbLog.Instance.WriteLog("ReplaceImagePathAndUnionTable Complete");

                DBSourceConfig dBSourceConfig = new DBSourceConfig();

                dBSourceConfig.WebbDBType = WebbDBTypes.CoachCRM;

                Webb.Reports.DataProvider.VideoPlayBackManager.PublicDBProvider = new WebbDataProvider(dBSourceConfig);

                WebbLog.Instance.WriteLog("for");

                for (int i = 0; i < templateFiles.Length; i++)
                {
                    WebbLog.Instance.WriteLog("1");

                    templateFiles[i] = templateFiles[i].Replace(@"/", @"\");

                    string strTemplate = strUserFolder + templateFiles[i];

                    if (strTemplate != string.Empty)
                    {
                        WebbLog.Instance.WriteLog("2");

                        WebbDataSource m_DBSource = new WebbDataSource();

                        m_DBSource.DataSource = ds.Copy();

                        WebbLog.Instance.WriteLog("3");

                        ArrayList m_Fields = new ArrayList();

                        foreach (System.Data.DataColumn m_col in m_DBSource.DataSource.Tables[0].Columns)
                        {
                            if (m_col.Caption == "{EXTENDCOLUMNS}" && m_col.ColumnName.StartsWith("C_"))
                            {
                                continue;
                            }

                            m_Fields.Add(m_col.ColumnName);
                        }

                        WebbLog.Instance.WriteLog("5");

                        Webb.Data.PublicDBFieldConverter.SetAvailableFields(m_Fields);

                        WebbLog.Instance.WriteLog("6");

                        Webb.Reports.DataProvider.VideoPlayBackManager.DataSource = m_DBSource.DataSource;      //Set dataset for click event

                        WebbReport m_Report = new WebbReport();

                        WebbLog.Instance.WriteLog("7");

                        Webb.Utility.ReplaceRefPathInRepxFile(strTemplate, dllpath);    //Modify template file

                        WebbLog.Instance.WriteLog("8");

                        m_Report.LoadLayout(strTemplate);

                        WebbLog.Instance.WriteLog("9");

                        Webb.Utility.CurFileName = strTemplate; //06-23-2008@Scott

                        m_Report.SetDataSource(m_DBSource);

                        preparedReports[i] = m_Report;

                        WebbLog.Instance.WriteLog("10");
                    }
                }

                WebbLog.Instance.WriteLog("for complete");
            }
            catch (Exception ex)
            {
                return("Failed:in create report|" + ex.Message);
            }

            try
            {
                WebbLog.Instance.WriteLog("11");

                if (preparedReports.Length == 1)
                {
                    WebbLog.Instance.WriteLog("22");

                    preparedReports[0].CreatePdfDocument(strDestineFile);

                    WebbLog.Instance.WriteLog("33");
                }
                else
                {
                    WebbLog.Instance.WriteLog("44");

                    XtraReport.UnionReportsToPdf(preparedReports, strDestineFile);

                    WebbLog.Instance.WriteLog("55");
                }
            }
            catch (Exception ex2)
            {
                return("Failed:in create PDf Document|" + ex2.Message);
            }
            if (!System.IO.File.Exists(strDestineFile))
            {
                return("Failed:Undestine Pdf Error in create PDF");
            }

            return(strDestineFile);
        }
        public string CreateReport(DataSet ds, string strDestineFile, string dllpath, string strUserFolder, string TemplateFileName, int[] TablesIndex)
        {
            strDestineFile = AdjustPDFFile(strDestineFile);

            if (!strUserFolder.EndsWith(@"\"))
            {
                strUserFolder += @"\";
            }

            string[] templateFiles = TemplateFileName.Split(new char[] { ',' });

            XtraReport[] preparedReports = new WebbReport[templateFiles.Length];

            if (System.IO.File.Exists(strDestineFile))
            {
                System.IO.File.Delete(strDestineFile);
            }

            try
            {
                for (int i = 0; i < templateFiles.Length; i++)
                {
                    templateFiles[i] = strUserFolder + templateFiles[i];

                    string strTemplate = templateFiles[i];

                    if (strTemplate != string.Empty)
                    {
                        int index = 0;

                        if (i < TablesIndex.Length)
                        {
                            index = TablesIndex[i];
                        }

                        DataTable table = ds.Tables[index].Copy();

                        WebbDataSource m_DBSource = new WebbDataSource();

                        m_DBSource.DataSource.Tables.Add(table);

                        ArrayList m_Fields = new ArrayList();

                        foreach (System.Data.DataColumn m_col in m_DBSource.DataSource.Tables[0].Columns)
                        {
                            if (m_col.Caption == "{EXTENDCOLUMNS}" && m_col.ColumnName.StartsWith("C_"))
                            {
                                continue;
                            }

                            m_Fields.Add(m_col.ColumnName);
                        }

                        Webb.Data.PublicDBFieldConverter.SetAvailableFields(m_Fields);

                        Webb.Reports.DataProvider.VideoPlayBackManager.DataSource = m_DBSource.DataSource;      //Set dataset for click event

                        WebbReport m_Report = new WebbReport();

                        Webb.Utility.ReplaceRefPathInRepxFile(strTemplate, dllpath);    //Modify template file

                        m_Report.LoadLayout(strTemplate);

                        Webb.Utility.CurFileName = strTemplate; //06-23-2008@Scott

                        m_Report.SetDataSource(m_DBSource);

                        preparedReports[i] = m_Report;
                    }
                }
            }
            catch (Exception ex)
            {
                return("Failed:in create report|" + ex.Message);
            }

            try
            {
                if (preparedReports.Length == 1)
                {
                    preparedReports[0].CreatePdfDocument(strDestineFile);
                }
                else
                {
                    XtraReport.UnionReportsToPdf(preparedReports, strDestineFile);
                }
            }
            catch (Exception ex2)
            {
                return("Failed:in create PDf Document|" + ex2.Message);
            }
            if (!System.IO.File.Exists(strDestineFile))
            {
                return("Failed:Undestine Pdf Error in create PDF");
            }

            return(strDestineFile);
        }