/// <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); }
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(); }