void cmdPreview_ServerClick(object sender, EventArgs e) { if (ValidateInput() == false) { return; } UpdateReportDesignView(); this.SaveDesignView(designView); ReportViewFacade rptFacade = new ReportViewFacade(this.DataProvider); ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider) this.DataProvider).PersistBroker.OpenConnection(); this.DataProvider.BeginTransaction(); try { // 保存 rptFacade.SaveDesignReportData(this.designView, this.GetUserCode()); // 生成报表文件 ReportGenerater rptGenerater = new ReportGenerater(this.DataProvider); string strFormatFile = Server.MapPath("ReportFormat.xml"); string strReportFile = Server.MapPath("../ReportFiles"); if (System.IO.Directory.Exists(strReportFile) == false) { System.IO.Directory.CreateDirectory(strReportFile); } strReportFile += "\\" + this.designView.ReportID + ".rdlc"; rptGenerater.Generate(this.designView, strFormatFile, strReportFile); this.designView.UploadFileName = strReportFile; string strRptFile = strReportFile.Substring(strReportFile.LastIndexOf("\\", strReportFile.LastIndexOf("\\") - 1) + 1); this.designView.DesignMain.ReportFileName = strRptFile; rptFacade.UpdateRptViewDesignMain(this.designView.DesignMain); // 脚本 string strScript = "window.open('FRptViewMP.aspx?reportid=" + this.designView.DesignMain.ReportID + "&preview=1');"; //this.ClientScript.RegisterStartupScript(typeof(string), "OpenPreviewWindow", strScript); ScriptManager.RegisterStartupScript(this, GetType(), "OpenPreviewWindow", strScript, true); this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider) this.DataProvider).PersistBroker.CloseConnection(); } for (int i = 0; i < this.gridWebGrid.Rows.Count; i++) { string strName = this.gridWebGrid.Rows[i].Items.FindItemByKey("ColumnName").Value.ToString(); System.Web.UI.WebControls.ListItem item = this.lstUnSelectColumn.Items.FindByValue(strName); if (item != null) { this.lstUnSelectColumn.Items.Remove(item); } } }
private void cmdPublish_ServerClick(object sender, EventArgs e) { string[] selectedUserGroup = this.rptSecuritySelect.SelectedUserGroup; if (selectedUserGroup.Length == 0) { ////Modified by allen on 20081104 for change security: functiongroup //throw new Exception("$ReportDesign_Select_UserGroup"); throw new Exception("$ReportDesign_Select_FunctionGroup"); } ////End Modified by allen on 20081104 for change security: functiongroup string strRptId = this.drpReportName.SelectedValue; string strFormatXml = Server.MapPath("ReportFormat.xml"); ReportGenerater rptGenerater = new ReportGenerater(this.DataProvider); string strFileName = System.Web.HttpContext.Current.Server.MapPath("../ReportFiles"); if (System.IO.Directory.Exists(strFileName) == false) { System.IO.Directory.CreateDirectory(strFileName); } if (strRptId != "") { strFileName += "\\" + strRptId + ".rdlc"; } else { strFileName += "\\" + System.Guid.NewGuid().ToString() + ".rdlc"; } rptGenerater.Generate(strRptId, strFormatXml, strFileName); string strRptFile = strFileName.Substring(strFileName.LastIndexOf("\\", strFileName.LastIndexOf("\\") - 1) + 1); ReportViewFacade rptFacade = new ReportViewFacade(this.DataProvider); DBDateTime dDate = FormatHelper.GetNowDBDateTime(this.DataProvider); RptViewDesignMain rptMain = (RptViewDesignMain)rptFacade.GetRptViewDesignMain(strRptId); rptMain.ReportFileName = strRptFile; rptMain.Status = ReportDesignStatus.Publish; rptMain.ParentReportFolder = this.drpReportFolder.SelectedValue; rptMain.PublishUser = this.GetUserCode(); rptMain.PublishDate = dDate.DBDate; rptMain.PublishTime = dDate.DBTime; rptMain.MaintainUser = this.GetUserCode(); rptMain.MaintainDate = dDate.DBDate; rptMain.MaintainTime = dDate.DBTime; ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider) this.DataProvider).PersistBroker.OpenConnection(); this.DataProvider.BeginTransaction(); try { rptFacade.UpdateRptViewDesignMain(rptMain); rptFacade.UpdateReportEntryPublish(rptMain, this.GetUserCode()); rptFacade.UpdateRptViewReportSecurity(strRptId, selectedUserGroup); this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider) this.DataProvider).PersistBroker.CloseConnection(); } InitSecurityList(strRptId); this.Session["PublishedReportId"] = strRptId; string alertInfo = string.Format("alert('{0}');", this.languageComponent1.GetString("$ReportDesign_Publish_Success")); // string.Format("<script language=javascript>alert('{0}');window.top.location.reload();</script>", this.languageComponent1.GetString("$ReportDesign_Publish_Success")); if (!this.ClientScript.IsClientScriptBlockRegistered("SaveSuccess")) { //this.ClientScript.RegisterClientScriptBlock(typeof(string), "SaveSuccess", alertInfo); ScriptManager.RegisterClientScriptBlock(this, GetType(), "SaveSuccess", alertInfo, true); } }