Example #1
0
        /// <summary>
        /// 打开指定的报表模板或者报表模板文件对应的脚本
        /// </summary>
        /// <param name="reportTemplet">报表模板信息</param>
        /// <param name="szHndfFile">报表模板文件</param>
        /// <returns>是否成功</returns>
        public bool Open(ReportType reportTemplet, string szHndfFile)
        {
            this.IsModified      = false;
            this.m_hndfFile      = szHndfFile;
            this.m_reportTemplet = reportTemplet;
            this.RefreshFormText();

            ReportFileParser parser = new ReportFileParser();

            this.textEditor1.Text = parser.GetScriptData(szHndfFile);

            if (GlobalMethods.Misc.IsEmptyString(this.textEditor1.Text))
            {
                string szDefaultHndfFile = string.Format("{0}\\Templet\\Default.hrdt"
                                                         , GlobalMethods.Misc.GetWorkingPath());
                this.textEditor1.Text = parser.GetScriptData(szDefaultHndfFile);
            }
            this.IsModified = false;
            return(true);
        }
Example #2
0
        /// <summary>
        /// 保存当前正在编辑的模板文件
        /// </summary>
        /// <returns>bool</returns>
        internal bool SaveReport()
        {
            DesignEditForm designForm = this.ActiveReport;
            ScriptEditForm scriptForm = this.ActiveScript;

            if (scriptForm == null && designForm == null)
            {
                return(false);
            }

            if (designForm != null)
            {
                scriptForm = this.GetScriptForm(designForm);
            }
            else if (scriptForm != null)
            {
                designForm = this.GetDesignForm(scriptForm);
            }

            ReportFileParser parser       = new ReportFileParser();
            string           szScriptData = null;

            if (scriptForm != null)
            {
                szScriptData = scriptForm.Save();
            }
            else
            {
                szScriptData = parser.GetScriptData(designForm.HndfFile);
            }

            string szDesignData = null;

            if (designForm != null)
            {
                designForm.Save(ref szDesignData);
            }
            else
            {
                szDesignData = parser.GetDesignData(scriptForm.HndfFile);
            }

            byte[] byteTempletData = null;
            parser.MakeReportData(szDesignData, szScriptData, out byteTempletData);

            DialogResult result = MessageBoxEx.ShowQuestion("是否提交到服务器?"
                                                            + "\r\n提交到服务器,请点击“是”按钮!\r\n仅保存到本地,请点击“否”按钮!");

            if (result == DialogResult.Cancel)
            {
                return(false);
            }
            bool success = true;

            if (result == DialogResult.No)
            {
                success = this.SaveReportToLocal(byteTempletData);
            }
            else
            {
                success = this.SaveReportToServer(byteTempletData);
            }
            if (success)
            {
                if (designForm != null)
                {
                    designForm.IsModified = false;
                }
                if (scriptForm != null)
                {
                    scriptForm.IsModified = false;
                }
            }
            return(success);
        }
Example #3
0
        internal void ShowScriptTestForm()
        {
            DesignEditForm designForm = this.ActiveReport;
            ScriptEditForm scriptForm = this.ActiveScript;

            if (scriptForm == null && designForm == null)
            {
                return;
            }

            if (designForm != null)
            {
                scriptForm = this.GetScriptForm(designForm);
            }
            else if (scriptForm != null)
            {
                designForm = this.GetDesignForm(scriptForm);
            }

            ReportFileParser parser       = new ReportFileParser();
            string           szScriptData = null;

            if (scriptForm != null)
            {
                szScriptData = scriptForm.Save();
            }
            else
            {
                szScriptData = parser.GetScriptData(designForm.HndfFile);
            }

            string szDesignData = null;

            if (designForm != null)
            {
                designForm.Save(ref szDesignData);
            }
            else
            {
                szDesignData = parser.GetDesignData(scriptForm.HndfFile);
            }

            //编译脚本
            ScriptProperty scriptProperty = new ScriptProperty();

            scriptProperty.ScriptText = szScriptData;
            CompileResults results = null;

            results = ScriptCompiler.Instance.CompileScript(scriptProperty);
            if (!results.HasErrors)
            {
                this.MainForm.ShowCompileErrorForm(null);
            }
            else
            {
                if (scriptForm == null)
                {
                    this.OpenScriptEditForm(designForm);
                }
                this.MainForm.ShowCompileErrorForm(this.GetCompileErrors(results));
                MessageBoxEx.Show("编译失败,无法启动测试程序!");
                return;
            }

            ScriptTestForm scriptTestForm = new ScriptTestForm();

            scriptTestForm.ScriptData = szScriptData;
            scriptTestForm.DesignData = szDesignData;
            scriptTestForm.ShowDialog();
        }
Example #4
0
        /// <summary>
        /// 在所有报表中查找指定的文本
        /// </summary>
        /// <param name="szFindText">文本</param>
        /// <param name="bMatchCase">是否匹配大小写</param>
        public void FindTextInAllTemplet(string szFindText, bool bMatchCase)
        {
            if (!bMatchCase)
            {
                szFindText = szFindText.ToLower();
            }
            List <ReportType> lstReportTypeData = new List <ReportType>();

            ReportTypeAccess.Instance.GetReportTypes(ref lstReportTypeData);
            if (lstReportTypeData.Count <= 0)
            {
                return;
            }

            List <FindResult> Result = new List <FindResult>();
            int    indextext         = 0; //索引号
            int    indexLine         = 0; //行号
            int    i            = 0;      //正在比对的字符序号
            int    indexCol     = 0;
            char   chFindText   = new char();
            string sztextFormat = string.Empty;

            char[]           arrFindText = szFindText.Trim().ToCharArray();
            ReportFileParser parser      = new ReportFileParser();

            for (int index = 0; index < lstReportTypeData.Count; index++)
            {
                if (lstReportTypeData[index].IsFolder)
                {
                    continue;
                }
                if (lstReportTypeData[index].REPORT_DATA == null)
                {
                    continue;
                }

                parser = new ReportFileParser();
                string   szScripData  = parser.GetScriptData(lstReportTypeData[index].REPORT_DATA);
                string[] arrScripText = szScripData.Split(new Char[] { '\n' }, StringSplitOptions.None);

                indexLine = 0; //行号清零
                indextext = 0; //索引号清零
                foreach (string sztext in arrScripText)
                {
                    if (string.IsNullOrEmpty(sztext))
                    {
                        continue;
                    }
                    if (!bMatchCase)
                    {
                        sztextFormat = sztext.ToLower();
                    }
                    else
                    {
                        sztextFormat = sztext;
                    }
                    char[] arrCtext = sztextFormat.ToCharArray();
                    i = 0;//正在比对的字符序号
                    for (indexCol = 0; indexCol < arrCtext.Length; indexCol++)
                    {
                        chFindText = arrCtext[indexCol];
                        indextext++;
                        if (i != 0 && chFindText != arrFindText[i])
                        {
                            indexCol -= i - 1; indextext -= i - 1; i = 0; continue;
                        }
                        if (chFindText != arrFindText[i])
                        {
                            i = 0; continue;
                        }
                        if (i == arrFindText.Length - 1)
                        {
                            Result.Add(new FindResult(indextext - szFindText.Trim().Length
                                                      , szFindText.Trim().Length
                                                      , indexLine
                                                      , sztext
                                                      , lstReportTypeData[index].ReportTypeID
                                                      , lstReportTypeData[index].ReportTypeName
                                                      , SystemData.FileType.REPORT));
                            i = 0;
                            continue;
                        }
                        i++;
                    }
                    indextext++;//修正分行去掉'\n'产生的偏移量
                    indexLine++;
                }
            }

            if (this.MainForm != null && !this.MainForm.IsDisposed)
            {
                this.MainForm.ShowFindResultForm(this, szFindText, Result, true);
            }
        }