public AddEditReportModel(Tab tab) { mTab = tab; ReportLinkInstance = new ReportLink(); ReportLinkInstance.TabId = mTab.Id; ReportURL = @"/CMS/Issue/[enter report name]"; OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler); RolesPickerCommand = new DelegateCommand<object>(RolesPickerHandler, CanExecuteRolesPickerHandler); }
private void RunFilteredListReport(ReportLink reportLink, List<int> idList) { var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); Guid batchId = Guid.NewGuid(); //string reportName = String.Format("{0}{1}", Utils.REPORTNAME_QUERYSTRING_PART1, reportLink.ReportURL); var reportPath = reportLink.ReportURL; if (mTab.Id == (int) CommonUtils.TabId.Documents) { DocumentExportFilter documentExportFilter = ((App) Application.Current).DocumentExportFilter; if (documentExportFilter.Filter != CommonUtils.DocumentVersionFilter.All) { reportPath = SetDocReportName(documentExportFilter, reportPath); } } cmsWebServiceClient.SaveReportParametersCompleted += (s1, e1) => { Dictionary<string, string> nameValue = new Dictionary<string, string>(); nameValue.Add("batchid", batchId.ToString()); if (reportLink.SetReportFilterString) { nameValue.Add("ReportFilterString", mExportControlParameters.ReportFilterString); } Utils.OpenReport(reportPath, nameValue); cmsWebServiceClient.CleanUpOldReportParametersAsync(30); if (ShowBusyIndicator != null) { ShowBusyIndicator(false, ""); } }; cmsWebServiceClient.SaveReportParametersAsync(batchId.ToString(), idList); }
public Report Load(ISqlConnectionInfo connection, SqlQueryParameters parameters) { IDatabase database = connection.Database; if (database == null) { throw new ArgumentNullException("database", "Error initializing database connection."); } if (parameters == null) { throw new ArgumentNullException("parameters"); } string sqlCmdText = string.Empty; try { sqlCmdText = "SELECT {0} " + ReportTable.GetColumnNames("[r]") + (this.Depth > 0 ? "," + ReportLinkTable.GetColumnNames("[r_rl]") : string.Empty) + (this.Depth > 1 ? "," + ReportLinkGroupTable.GetColumnNames("[r_rl_rlg]") : string.Empty) + " FROM [core].[Report] AS [r] "; if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[ReportLink] AS [r_rl] ON [r].[ReportLinkID] = [r_rl].[ReportLinkID] "; } if (this.Depth > 1) { sqlCmdText += "INNER JOIN [core].[ReportLinkGroup] AS [r_rl_rlg] ON [r_rl].[ReportLinkGroupID] = [r_rl_rlg].[ReportLinkGroupID] "; } parameters.Top = 1; sqlCmdText = parameters.BuildQuery(sqlCmdText); SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand; foreach (KeyValuePair <string, object> argument in parameters.Arguments) { sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value); } SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader; if (!sqlReader.HasRows || !sqlReader.Read()) { IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("r", "customload", "notfound"), "Report could not be loaded using custom logic as it was not found.", sqlCmdText, this, connection, parameters); if (this.Logger.IsDebugEnabled) { this.Logger.Debug(builder.ToString()); } sqlReader.Close(); return(null); } SqlQuery query = new SqlQuery(sqlReader); ReportTable rTable = new ReportTable(query); ReportLinkTable r_rlTable = (this.Depth > 0) ? new ReportLinkTable(query) : null; ReportLinkGroupTable r_rl_rlgTable = (this.Depth > 1) ? new ReportLinkGroupTable(query) : null; ReportLinkGroup r_rl_rlgObject = (this.Depth > 1) ? r_rl_rlgTable.CreateInstance() : null; ReportLink r_rlObject = (this.Depth > 0) ? r_rlTable.CreateInstance(r_rl_rlgObject) : null; Report rObject = rTable.CreateInstance(r_rlObject); sqlReader.Close(); return(rObject); } catch (Exception ex) { database.HandleException(ex); IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("r", "customload", "exception"), "Report could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters); if (this.Logger.IsErrorEnabled) { this.Logger.Error(builder.ToString(), ex); } throw new DataOperationException(DataOperation.Load, "Report", "Exception while loading (custom/single) Report object from database. See inner exception for details.", ex); } }
private bool CanUserOpenReport(ReportLink reportLink) { if (reportLink.Restricted) { var allowedRoleIds = reportLink.ReportLinkRoles.Select(x => x.RoleId).ToList(); if (!allowedRoleIds.Contains(CMS.User.RoleId)) { var dialog = new PopupDialog(PopupDialogType.Error, "Access is restricted due to report content – please contact the System Administrator.", "Restricted Content Issue"); dialog.Show(); return false; } } return true; }
protected override Report LoadInternal(ISqlConnectionInfo connection, int id) { IDatabase database = connection.Database; if (database == null) { throw new ArgumentNullException("database", "Error initializing database connection."); } string sqlCmdText = string.Empty; try { sqlCmdText = "SELECT " + ReportTable.GetColumnNames("[r]") + (this.Depth > 0 ? "," + ReportLinkTable.GetColumnNames("[r_rl]") : string.Empty) + (this.Depth > 1 ? "," + ReportLinkGroupTable.GetColumnNames("[r_rl_rlg]") : string.Empty) + " FROM [core].[Report] AS [r] "; if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[ReportLink] AS [r_rl] ON [r].[ReportLinkID] = [r_rl].[ReportLinkID] "; } if (this.Depth > 1) { sqlCmdText += "INNER JOIN [core].[ReportLinkGroup] AS [r_rl_rlg] ON [r_rl].[ReportLinkGroupID] = [r_rl_rlg].[ReportLinkGroupID] "; } sqlCmdText += "WHERE [r].[ReportID] = @ReportID;"; SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand; sqlCmd.Parameters.AddWithValue("@ReportID", id); SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader; if (!sqlReader.HasRows || !sqlReader.Read()) { IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("r", "loadinternal", "notfound"), "Report could not be loaded by id as it was not found.", sqlCmdText, this, connection, id); if (this.Logger.IsWarnEnabled) { this.Logger.Warn(builder.ToString()); } sqlReader.Close(); return(null); } SqlQuery query = new SqlQuery(sqlReader); ReportTable rTable = new ReportTable(query); ReportLinkTable r_rlTable = (this.Depth > 0) ? new ReportLinkTable(query) : null; ReportLinkGroupTable r_rl_rlgTable = (this.Depth > 1) ? new ReportLinkGroupTable(query) : null; ReportLinkGroup r_rl_rlgObject = (this.Depth > 1) ? r_rl_rlgTable.CreateInstance() : null; ReportLink r_rlObject = (this.Depth > 0) ? r_rlTable.CreateInstance(r_rl_rlgObject) : null; Report rObject = rTable.CreateInstance(r_rlObject); sqlReader.Close(); return(rObject); } catch (Exception ex) { database.HandleException(ex); IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("r", "loadinternal", "exception"), "Report could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id); if (this.Logger.IsErrorEnabled) { this.Logger.Error(builder.ToString(), ex); } throw new DataOperationException(DataOperation.Load, "Report", "Exception while loading Report object from database. See inner exception for details.", ex); } }