Exemplo n.º 1
0
        // 从报表配置文件中获得各种配置信息
        // return:
        //      -1  出错
        //      0   没有找到配置文件
        //      1   成功
        internal static int GetReportConfig(string strCfgFile,
                                            out ReportConfigStruct config,
                                            out string strError)
        {
            strError = "";
            config   = new ReportConfigStruct();

            XmlDocument dom = new XmlDocument();

            try
            {
                dom.Load(strCfgFile);
            }
            catch (FileNotFoundException)
            {
                strError = "配置文件 '" + strCfgFile + "' 没有找到";
                return(0);
            }
            catch (Exception ex)
            {
                strError = "报表配置文件 " + strCfgFile + " 打开错误: " + ex.Message;
                return(-1);
            }

            XmlNode nodeProperty = dom.DocumentElement.SelectSingleNode("property");

            if (nodeProperty != null)
            {
                bool bValue = false;
                int  nRet   = DomUtil.GetBooleanParam(nodeProperty,
                                                      "fresh",
                                                      false,
                                                      out bValue,
                                                      out strError);
                if (nRet == -1)
                {
                    return(-1);
                }
                config.Fresh = bValue;
            }

            config.ColumnSortStyle = DomUtil.GetElementText(dom.DocumentElement,
                                                            "columnSortStyle");

            config.TypeName   = DomUtil.GetElementText(dom.DocumentElement, "typeName");
            config.CreateFreq = DomUtil.GetElementText(dom.DocumentElement, "createFrequency");

            return(1);
        }
Exemplo n.º 2
0
        void FillReportTypeList()
        {
            if (this.comboBox_reportType.Items.Count > 0)
            {
                return;
            }

            string        strCfgDir = Path.Combine(Program.MainForm.UserDir, "report_def");
            DirectoryInfo di        = new DirectoryInfo(strCfgDir);

            List <FileInfo> array = new List <FileInfo>();

            array.AddRange(di.GetFiles("???.xml"));
            array.AddRange(di.GetFiles("????.xml"));
            FileInfo[] fis = array.ToArray();
            Array.Sort(fis, new FileInfoCompare());

            foreach (FileInfo fi in fis)
            {
                ReportConfigStruct config = null;

                string strError = "";
                string strName  = "";
                // 从报表配置文件中获得各种配置信息
                // return:
                //      -1  出错
                //      0   没有找到配置文件
                //      1   成功
                int nRet = ReportDefForm.GetReportConfig(fi.FullName,
                                                         out config,
                                                         out strError);
                if (nRet == -1 || nRet == 0)
                {
                    strName = strError;
                }
                else
                {
                    string strNumber = "";
                    StringUtil.ParseTwoPart(config.TypeName, " ", out strNumber, out strName);
                }

                this.comboBox_reportType.Items.Add(Path.GetFileNameWithoutExtension(fi.Name) + "\t" + strName);
            }
        }
Exemplo n.º 3
0
        // 从报表配置文件中获得各种配置信息
        // return:
        //      -1  出错
        //      0   没有找到配置文件
        //      1   成功
        internal static int GetReportConfig(string strCfgFile,
            out ReportConfigStruct config,
            out string strError)
        {
            strError = "";
            config = new ReportConfigStruct();

            XmlDocument dom = new XmlDocument();
            try
            {
                dom.Load(strCfgFile);
            }
            catch (FileNotFoundException)
            {
                strError = "配置文件 '" + strCfgFile + "' 没有找到";
                return 0;
            }
            catch (Exception ex)
            {
                strError = "报表配置文件 " + strCfgFile + " 打开错误: " + ex.Message;
                return -1;
            }

            XmlNode nodeProperty = dom.DocumentElement.SelectSingleNode("property");
            if (nodeProperty != null)
            {
                bool bValue = false;
                int nRet = DomUtil.GetBooleanParam(nodeProperty,
                    "fresh",
                    false,
                    out bValue,
                    out strError);
                if (nRet == -1)
                    return -1;
                config.Fresh = bValue;
            }

            config.ColumnSortStyle = DomUtil.GetElementText(dom.DocumentElement,
                "columnSortStyle");

            config.TypeName = DomUtil.GetElementText(dom.DocumentElement, "typeName");
            config.CreateFreq = DomUtil.GetElementText(dom.DocumentElement, "createFrequency");

            return 1;
        }
Exemplo n.º 4
0
        // 自动增全报表配置
        // return:
        //      -1  出错
        //      >=0 新增的报表类型个数
        public int AutoAppend(
            out string strError)
        {
            strError = "";

            string strCfgFileDir = Path.Combine(this.MainForm.UserDir, "report_def");   //  Path.Combine(this.MainForm.UserDir, "report_def");

            DirectoryInfo di = new DirectoryInfo(strCfgFileDir);

            FileInfo[] fis = di.GetFiles("???.xml");
            Array.Sort(fis, new FileInfoCompare());

            List <string> types = new List <string>();

            foreach (FileInfo fi in fis)
            {
                string strName = Path.GetFileNameWithoutExtension(fi.Name);

                ListViewItem dup = ListViewUtil.FindItem(this.listView_reports, strName, COLUMN_REPORT_TYPE);
                if (dup != null)
                {
                    continue;
                }

                types.Add(strName);
            }

            int nCount = 0;
            int i      = 0;

            foreach (string strType in types)
            {
                string strFileName      = strType + ".xml";
                string strLocalFilePath = Path.Combine(this.MainForm.UserDir, "report_def\\" + strFileName);

                ReportConfigStruct config = null;

                // 从报表配置文件中获得各种配置信息
                // return:
                //      -1  出错
                //      0   没有找到配置文件
                //      1   成功
                int nRet = ReportDefForm.GetReportConfig(strLocalFilePath,
                                                         out config,
                                                         out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                string strReportName = "";
                if (string.IsNullOrEmpty(config.TypeName) == false &&
                    config.TypeName.Length > 3)
                {
                    strReportName = config.TypeName.Substring(3).Trim();
                }
                else
                {
                    strReportName = strType + "_" + (i + 1).ToString();
                }

                string strNameTable = "";
                if (strType == "102")
                {
                    strNameTable = "";  // TODO: 根据现有数据创建名称表
                }
                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAME, strReportName);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_FREQ, config.CreateFreq);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_TYPE, strType);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_CFGFILE, strLocalFilePath);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAMETABLE, strNameTable);
                this.listView_reports.Items.Add(item);

                i++;
                nCount++;
            }

            return(nCount);
        }
Exemplo n.º 5
0
        // 自动创建全部报表配置
        public int AutoCreate(
            string strLibraryCode,
            out string strError)
        {
            strError = "";

            this.Clear();

            // 基本参数
            this.comboBox_general_libraryCode.Text = strLibraryCode;

            // 创建每种类型的报表
#if NO
            string[] types = new string[] {
                "101",
                "102",
                "111",
                "121",
                "131",
                "201",
                "202",
                "212",
                "301",
                "441",
                "442",
                "443",
            };
#endif

            string strCfgFileDir = Path.Combine(this.MainForm.UserDir, "report_def");   //  Path.Combine(this.MainForm.UserDir, "report_def");

            DirectoryInfo di  = new DirectoryInfo(strCfgFileDir);
            FileInfo[]    fis = di.GetFiles("???.xml");
            Array.Sort(fis, new FileInfoCompare());

            List <string> types = new List <string>();
            foreach (FileInfo fi in fis)
            {
                types.Add(Path.GetFileNameWithoutExtension(fi.Name));
            }

            int i = 0;
            foreach (string strType in types)
            {
                // 从 dp2003.com 下载配置文件
                string strFileName      = strType + ".xml";
                string strLocalFilePath = Path.Combine(this.MainForm.UserDir, "report_def\\" + strFileName);

#if NO
                int nRet = DownloadDataFile(
                    this,
                    strFileName,
                    strCfgFileDir,
                    out strLocalFilePath,
                    out strError);
                if (nRet == -1)
                {
                    return(-1);
                }
#endif

                ReportConfigStruct config = null;

                // 从报表配置文件中获得各种配置信息
                // return:
                //      -1  出错
                //      0   没有找到配置文件
                //      1   成功
                int nRet = ReportDefForm.GetReportConfig(strLocalFilePath,
                                                         out config,
                                                         out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                string strReportName = "";
                if (string.IsNullOrEmpty(config.TypeName) == false &&
                    config.TypeName.Length > 3)
                {
                    strReportName = config.TypeName.Substring(3).Trim();
                }
                else
                {
                    strReportName = strType + "_" + (i + 1).ToString();
                }

                string strNameTable = "";
                if (strType == "102")
                {
                    strNameTable = "";  // TODO: 根据现有数据创建名称表
                }
                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAME, strReportName);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_FREQ, config.CreateFreq);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_TYPE, strType);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_CFGFILE, strLocalFilePath);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAMETABLE, strNameTable);
                this.listView_reports.Items.Add(item);

                i++;
            }

            return(0);
        }
Exemplo n.º 6
0
        // 自动填充面板上的 报表名和创建频率
        void AutoFillReportName()
        {
#if NO
            // 用配置文件中的 typeName 填充报表名称
            if (string.IsNullOrEmpty(this.textBox_reportName.Text) == false)
            {
                return;
            }
#endif

            string strError = "";

            string strLocalFilePath = this.textBox_cfgFileName.Text;

            if (string.IsNullOrEmpty(strLocalFilePath) == true)
            {
                return;
            }
            if (File.Exists(strLocalFilePath) == false)
            {
                return;
            }

#if NO
            string strTypeName = "";
            // 获得 typeName
            // return:
            //      -1  出错
            //      0   配置文件没有找到
            //      1   成功
            int nRet = ReportDefForm.GetReportTypeName(
                strLocalFilePath,
                out strTypeName,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }
#endif
            ReportConfigStruct config = null;

            // 从报表配置文件中获得各种配置信息
            // return:
            //      -1  出错
            //      0   没有找到配置文件
            //      1   成功
            int nRet = ReportDefForm.GetReportConfig(strLocalFilePath,
                                                     out config,
                                                     out strError);
            if (nRet == -1 || nRet == 0)
            {
                goto ERROR1;
            }

            if (string.IsNullOrEmpty(config.TypeName) == false &&
                config.TypeName.Length > 3)
            {
                this.textBox_reportName.Text = config.TypeName.Substring(GetNumberPrefix(config.TypeName).Length).Trim();
            }

            if (string.IsNullOrEmpty(this.checkedComboBox_createFreq.Text) == true)
            {
                this.checkedComboBox_createFreq.Text = config.CreateFreq;
            }

            return;

ERROR1:
            MessageBox.Show(this, strError);
        }