예제 #1
0
        /// <summary>
        /// Determines if a user can access the report specified
        /// </summary>
        /// <param name="reportName">The report name</param>
        /// <param name="userInfo">The user information</param>
        /// <returns>True, if the user can access the report; otherwise false</returns>
        private bool CanUserAccessReport
        (
            string reportName,
            ReportUserInfo userInfo
        )
        {
            var assignments = GetAssignmentsForReport
                              (
                reportName
                              );

            if (assignments.Count == 0)
            {
                return(true);
            }
            else
            {
                if (userInfo.Roles == null || userInfo.Roles.Count() == 0)
                {
                    return(false);
                }
                else
                {
                    return(assignments.Any
                           (
                               a => userInfo.Roles.Any
                               (
                                   role => role.Equals(a.RoleName, StringComparison.OrdinalIgnoreCase)
                               )
                           ));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Gets all registered reports for a single user
        /// </summary>
        /// <param name="userInfo">The user information</param>
        /// <param name="options">The globalization options (optional)</param>
        /// <returns>A collection of registered reports</returns>
        public IEnumerable <RegisteredReport> GetReportsForUser
        (
            ReportUserInfo userInfo,
            GlobalizationOptions options = null
        )
        {
            Validate.IsNotNull(userInfo);

            if (userInfo.Roles == null)
            {
                throw new ArgumentException
                      (
                          "No user roles have been defined."
                      );
            }

            var assignments = _roleAssignmentRepository.GetAssignmentsForRoles
                              (
                userInfo.Roles
                              );

            var reportNames = assignments.Select
                              (
                a => a.ReportName
                              );

            reportNames = reportNames.Distinct();

            var allReports = _reportRepository.GetAllReports();

            // Get reports that match the role assignments
            var matchingReports = allReports.Where
                                  (
                report => reportNames.Any
                (
                    name => report.Name.Equals(name, StringComparison.OrdinalIgnoreCase)
                )
                                  );

            // Get reports without roles and merge them with the matching reports
            var reportsWithoutRoles = GetReportsWithoutRoles();

            var userReports = new List <RegisteredReport>
                              (
                matchingReports
                              );

            userReports.AddRange(reportsWithoutRoles);

            userReports.Localize
            (
                _translator,
                options
            );

            return(userReports.OrderBy
                   (
                       r => r.Name
                   ));
        }
예제 #3
0
        public ActionResult Report()
        {
            var reportInfo = new ReportUserInfo();

            reportInfo.ReportInfo = new List <Report>();
            ViewBag.Reports       = GetTypeOfReport();
            return(View(reportInfo));
        }
예제 #4
0
        /// <summary>
        /// 根据参数信息获取Mstr报表地址
        /// </summary>
        /// <param name="pReportID">报表标识</param>
        /// <param name="pQueryParameter">查询条件信息</param>
        public string GetMstrUrl(PromptAnswerItem[] pQueryParameter, DataRigthHierachy pDataRigthHierachy)
        {
            var userInfo = new ReportUserInfo()
            {
                UserID = CurrentUserInfo.UserID, ClientID = CurrentUserInfo.ClientID
            };;
            var mstrReportUtil = new MstrReportUtil((int)Session["MstrSSO_MstrIntegrationSessionID"], this.MstrReportGuid, userInfo);

            return(mstrReportUtil.GetMstrUrl(pQueryParameter, null));
        }
예제 #5
0
 /// <summary>
 /// 获取报表访问路径
 /// </summary>
 /// <param name="pMstrIntegrationSessionID">Mstr集成组件生成的会话标识</param>
 /// <param name="pReportGuid">报表标识</param>
 /// <param name="pClientId">客户标识</param>
 /// <param name="pUserId">用户标识</param>
 /// <param name="pPromptAnswers">提问回答信息</param>
 /// <param name="pDataRigthHierachy">数据权限信息</param>
 /// <returns>Mstr报表访问Url</returns>
 public string GetMstrReportUrl(int pMstrIntegrationSessionID, string pReportGuid, string pClientId, string pUserId, MstrPromptAnswerItem[] pPromptAnswers, MstrDataRigthPromptAnswerItem[] pDataRigthPromptAnswers)
 {
     JIT.Utility.Log.Loggers.Debug(new JIT.Utility.Log.DebugLogInfo()
     {
         ClientID = pClientId, UserID = pUserId, Message = "接收到请求.获取报表访问路径:[" + pMstrIntegrationSessionID + "]"
     });
     try
     {
         PromptAnswerItem[] promptAnswers;
         if (pPromptAnswers == null)
         {
             promptAnswers = new PromptAnswerItem[0] {
             }
         }
         ;
         else
         {
             promptAnswers = new PromptAnswerItem[pPromptAnswers.Length];
         }
         //foreach (var item in pPromptAnswers)
         for (int i = 0; i < pPromptAnswers.Length; i++)
         {
             var item = pPromptAnswers[i];
             PromptAnswerItem promptAnswerItem = new PromptAnswerItem();
             promptAnswerItem.PromptCode     = item.PromptCode;
             promptAnswerItem.PromptType     = 0;
             promptAnswerItem.QueryCondition = item.QueryCondition;
             promptAnswers[i] = promptAnswerItem;
         }
         DataRigthHierachy dataRigthHierachy = new DataRigthHierachy();
         if (pDataRigthPromptAnswers != null)
         {
             foreach (var item in pDataRigthPromptAnswers)
             {
                 dataRigthHierachy.Add(item.Level, item.Values);
             }
         }
         ReportUserInfo userInfo = new ReportUserInfo();
         userInfo.ClientID = pClientId;
         userInfo.UserID   = pUserId;
         MstrReportUtil mstrReportUtil = new MstrReportUtil(pMstrIntegrationSessionID, pReportGuid, userInfo);
         var            mstrUrl        = mstrReportUtil.GetMstrUrl(promptAnswers, dataRigthHierachy);;
         JIT.Utility.Log.Loggers.Debug(new JIT.Utility.Log.DebugLogInfo()
         {
             ClientID = pClientId, UserID = pUserId, Message = "处理请求完成.mstrUrl:[" + mstrUrl + "]"
         });
         return(mstrUrl);
     }
     catch (Exception ex)
     {
         JIT.Utility.Log.Loggers.Exception(new JIT.Utility.Log.ExceptionLogInfo(ex));
     }
     return(string.Empty);
 }
예제 #6
0
파일: JitMstrSSO.cs 프로젝트: radtek/crm
        ///// <summary>
        ///// Web端注销后,删除单点登录表中的记录
        ///// </summary>
        ///// <param name="pHttpSessionState">Web平台当前会话</param>
        ///// <param name="pSQLHelper">数据库操作类</param>
        //public void Logout(HttpSessionState pHttpSessionState, ISQLHelper pSQLHelper)
        //{
        //    if (pHttpSessionState["MstrSSO_Logout"] != null && (bool)pHttpSessionState["MstrSSO_Logout"])
        //        return;//已手工注销
        //    var userID = (string)pHttpSessionState["MstrSSO_UserID"];
        //    var clientID = (string)pHttpSessionState["MstrSSO_ClientID"];
        //    var userInfo = new ReportUserInfo() { ClientID = clientID, UserID = userID };
        //    MSTRIntegrationUserSessionBLL mstrIntegrationUserSessionBLL = new MSTRIntegrationUserSessionBLL(userInfo, pSQLHelper);
        //    MSTRIntegrationUserSessionEntity mstrIntegrationUserSessionQueryEntity = new MSTRIntegrationUserSessionEntity();
        //    mstrIntegrationUserSessionQueryEntity.SessionID = Convert.ToInt32(pHttpSessionState["MstrSSO_SessionID"]);
        //    mstrIntegrationUserSessionBLL.Delete(mstrIntegrationUserSessionQueryEntity);
        //    pHttpSessionState["MstrSSO_Logout"] = true;
        //}

        /// <summary>
        /// Web端注销后,删除单点登录表中的记录
        /// </summary>
        /// <param name="pHttpSessionState">Web平台当前会话</param>
        public void Logout(string pClientId, string pUserId, int pSessionID)
        {
            var sqlHelper = new JIT.Utility.DataAccess.DefaultSQLHelper(ConfigurationManager.AppSettings["MstrIntegrationConn"]);
            var userInfo  = new ReportUserInfo()
            {
                ClientID = pClientId, UserID = pUserId
            };
            MSTRIntegrationUserSessionBLL    mstrIntegrationUserSessionBLL         = new MSTRIntegrationUserSessionBLL(userInfo, sqlHelper);
            MSTRIntegrationUserSessionEntity mstrIntegrationUserSessionQueryEntity = new MSTRIntegrationUserSessionEntity();

            mstrIntegrationUserSessionQueryEntity.SessionID = pSessionID;
            mstrIntegrationUserSessionBLL.Delete(mstrIntegrationUserSessionQueryEntity);
        }
예제 #7
0
파일: JitMstrSSO.cs 프로젝트: radtek/crm
        /// <summary>
        /// IP、是否检查IP或区域信息改变
        /// </summary>
        /// <param name="pHttpSessionState">Web平台当前会话</param>
        /// <param name="pSQLHelper">数据库操作类</param>
        /// <param name="pIP">新的IP地址(如果未改变,则传入NULL)</param>
        /// <param name="pIsCheckIP">新的 【是否检查IP】 字段值 (如果未改变,则传入NULL)</param>
        /// <param name="pLanguage">新的语言(如果未改变,则传入NULL)</param>
        public void ContextChange(string pClientId, string pUserId, int pMstrIntegrationSessionID, int pLanguageLCID)
        {
            var userInfo = new ReportUserInfo()
            {
                ClientID = pClientId, UserID = pUserId
            };
            var sqlHelper = new JIT.Utility.DataAccess.DefaultSQLHelper(ConfigurationManager.AppSettings["MstrIntegrationConn"]);
            MSTRIntegrationUserSessionBLL    mstrIntegrationUserSessionBLL         = new MSTRIntegrationUserSessionBLL(userInfo, sqlHelper);
            MSTRIntegrationUserSessionEntity mstrIntegrationUserSessionQueryEntity = mstrIntegrationUserSessionBLL.GetByID(pMstrIntegrationSessionID);

            mstrIntegrationUserSessionQueryEntity.IsChange = 1;
            mstrIntegrationUserSessionQueryEntity.LCID     = pLanguageLCID;
            mstrIntegrationUserSessionBLL.Update(mstrIntegrationUserSessionQueryEntity);
        }
예제 #8
0
파일: JitMstrSSO.cs 프로젝트: radtek/crm
        /// <summary>
        /// 单点登录
        /// </summary>
        /// <param name="pLanguageLCID">Web平台当前语言(中文:2052,英文:1033。)</param>
        /// <param name="pClientIP">客户端IP地址</param>
        /// <param name="pClientID">登录用户所属客户标识</param>
        /// <param name="pUserID">登录用户标识</param>
        /// <param name="pWebSiteSessionId">Web站点的会话标识</param>
        public int Login(int pLanguageLCID, string pClientIP, string pClientID, string pUserID, string pWebSiteSessionId)
        {
            //TO-DO:登录成功后,准备记录MSTR集成组件所使用的单点登录信息。
            var sqlHelper = new JIT.Utility.DataAccess.DefaultSQLHelper(ConfigurationManager.AppSettings["MstrIntegrationConn"]);
            //1.根据客户获取报表服务器及项目相关信息
            var userInfo = new ReportUserInfo()
            {
                ClientID = pClientID, UserID = pUserID
            };
            MSTRProjectEntity mstrProjectQueryEntity = new MSTRProjectEntity();

            mstrProjectQueryEntity.ClientID = pClientID;
            MSTRProjectBLL mstrProjectBLL = new MSTRProjectBLL(userInfo, sqlHelper);

            MSTRProjectEntity[] mstrProjectEntities = mstrProjectBLL.QueryByEntity(mstrProjectQueryEntity, null);
            if (mstrProjectEntities == null || mstrProjectEntities.Length == 0)
            {
                JIT.Utility.Log.Loggers.Exception(new JIT.Utility.Log.ExceptionLogInfo(new Exception("未找到客户ID为[" + pClientID + "]的MSTR项目信息.")));
                return(-1);

                throw new Exception("未找到客户ID为[" + pClientID + "]的MSTR项目信息.");
            }
            var mstrProjectInfo = mstrProjectEntities[0];
            //2.记录用户会话记录
            MSTRIntegrationUserSessionBLL    mstrIntegrationUserSessionBLL         = new MSTRIntegrationUserSessionBLL(userInfo, sqlHelper);
            MSTRIntegrationUserSessionEntity mstrIntegrationUserSessionQueryEntity = new MSTRIntegrationUserSessionEntity();

            mstrIntegrationUserSessionQueryEntity.UserID    = pUserID;
            mstrIntegrationUserSessionQueryEntity.ClientID  = pClientID;
            mstrIntegrationUserSessionQueryEntity.IP        = pClientIP;
            mstrIntegrationUserSessionQueryEntity.IsChange  = 0;
            mstrIntegrationUserSessionQueryEntity.IsCheckIP = 0;

            mstrIntegrationUserSessionQueryEntity.LCID             = pLanguageLCID;
            mstrIntegrationUserSessionQueryEntity.MSTRIServerName  = mstrProjectInfo.IServerName;
            mstrIntegrationUserSessionQueryEntity.MSTRIServerPort  = mstrProjectInfo.IServerPort;
            mstrIntegrationUserSessionQueryEntity.MSTRProjectName  = mstrProjectInfo.ProjectName;
            mstrIntegrationUserSessionQueryEntity.WebSessionID     = pWebSiteSessionId;
            mstrIntegrationUserSessionQueryEntity.MSTRUserName     = mstrProjectInfo.MSTRUserName;
            mstrIntegrationUserSessionQueryEntity.MSTRUserPassword = mstrProjectInfo.MSTRUserPassword;
            mstrIntegrationUserSessionBLL.Create(mstrIntegrationUserSessionQueryEntity);
            //记录单点登录表中的自增主键
            //HttpContext.Current.Session["MstrSSO_SessionID"] = mstrIntegrationUserSessionQueryEntity.SessionID.Value;
            //HttpContext.Current.Session["MstrSSO_UserID"] = pUserID;
            //HttpContext.Current.Session["MstrSSO_ClientID"] = pClientID;
            //HttpContext.Current.Session["MstrSSO_LCID"] = pLanguageLCID;
            return(mstrIntegrationUserSessionQueryEntity.SessionID.Value);
        }
예제 #9
0
        /// <summary>
        /// Generates a report from a registered report and filter values
        /// </summary>
        /// <param name="reportName">The report name</param>
        /// <param name="filterValues">The filter values</param>
        /// <param name="userInfo">The user information</param>
        /// <returns>The generated result</returns>
        public ReportGenerationResult Generate
        (
            string reportName,
            SubmittedReportFilterValues filterValues,
            ReportUserInfo userInfo
        )
        {
            var task = GenerateAsync
                       (
                reportName,
                filterValues,
                userInfo
                       );

            return(task.WaitAndUnwrapException());
        }
예제 #10
0
        /// <summary>
        /// Gets all registered reports for a user and category
        /// </summary>
        /// <param name="userInfo">The user information</param>
        /// <param name="categoryName">The category string</param>
        /// <param name="options">The globalization options (optional)</param>
        /// <returns>A collection of registered reports</returns>
        public IEnumerable <RegisteredReport> GetReportsForUser
        (
            ReportUserInfo userInfo,
            string categoryName,
            GlobalizationOptions options = null
        )
        {
            Validate.IsNotNull(userInfo);
            Validate.IsNotEmpty(categoryName);

            var category = _categoryRepository.GetCategory
                           (
                categoryName
                           );

            var reportNames = category.AssignedReports.Select
                              (
                a => a.ReportName
                              )
                              .ToList();

            var userReports = GetReportsForUser
                              (
                userInfo
                              );

            userReports = userReports.Where
                          (
                report => reportNames.Any
                (
                    name => name.Equals(report.Name, StringComparison.OrdinalIgnoreCase)
                )
                          );

            userReports.Localize
            (
                _translator,
                options
            );

            return(userReports.OrderBy
                   (
                       r => r.Name
                   ));
        }
예제 #11
0
        public ActionResult Report(ReportUserInfo reportUserInfo)
        {
            ViewBag.Reports = GetTypeOfReport();
            var reports = new List <Report>();

            if (reportUserInfo.TypeOfReport == 0)
            {
                ViewBag.Error             = "Please Select the Type";
                reportUserInfo.ReportInfo = reports;
                return(View(reportUserInfo));
            }
            var entityContext = new EntityContext();
            var fromDate      = Convert.ToDateTime(reportUserInfo.FromDate);
            var toDate        = Convert.ToDateTime(reportUserInfo.ToDate);

            if (fromDate != DateTime.MinValue && toDate != DateTime.MinValue)
            {
                if (reportUserInfo.TypeOfReport == 1)
                {
                    reports = entityContext.reportInfo.Where(q => EntityFunctions.TruncateTime(q.Date) >= fromDate && EntityFunctions.TruncateTime(q.Date) <= toDate && q.TypeOfReport == Constants.SystemDonation).ToList();
                }
                else if (reportUserInfo.TypeOfReport == 2)
                {
                    reports = entityContext.reportInfo.Where(q => EntityFunctions.TruncateTime(q.Date) >= fromDate && EntityFunctions.TruncateTime(q.Date) <= toDate && q.TypeOfReport == Constants.PayPal).ToList();
                }
                else if (reportUserInfo.TypeOfReport == 3)
                {
                    reports = entityContext.reportInfo.Where(q => EntityFunctions.TruncateTime(q.Date) >= fromDate && EntityFunctions.TruncateTime(q.Date) <= toDate && q.TypeOfReport == Constants.KindBase).ToList();
                }
                else
                {
                    reports = entityContext.reportInfo.Where(q => EntityFunctions.TruncateTime(q.Date) >= fromDate && EntityFunctions.TruncateTime(q.Date) <= toDate && q.TypeOfReport == Constants.PriestService && q.Net != "0").ToList();
                }
            }
            reportUserInfo.ReportInfo = reports;
            return(View(reportUserInfo));
        }
예제 #12
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public MSTRIntegrationUserSessionDAO(ReportUserInfo pUserInfo, ISQLHelper pSQLHelper)
     : base(pUserInfo, true, pSQLHelper)
 {
 }
예제 #13
0
파일: MSTRReportBLL.cs 프로젝트: radtek/crm
 /// <summary>
 /// 构造函数
 /// </summary>
 public MSTRReportBLL(ReportUserInfo pUserInfo, ISQLHelper pSQLHelper)
 {
     this.CurrentUserInfo = pUserInfo;
     this._currentDAO     = new MSTRReportDAO(pUserInfo, pSQLHelper);
 }
예제 #14
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public MSTRIntegrationUserSessionBLL(ReportUserInfo pUserInfo, ISQLHelper pSQLHelper)
 {
     this.CurrentUserInfo = pUserInfo;
     this._currentDAO     = new MSTRIntegrationUserSessionDAO(pUserInfo, pSQLHelper);
 }
예제 #15
0
        /// <summary>
        /// Builds a report filter from the filter values specified
        /// </summary>
        /// <param name="registeredReport">The registered report</param>
        /// <param name="reportDefinition">The report definition</param>
        /// <param name="filterValues">The filter values</param>
        /// <param name="userInfo">The user information</param>
        /// <returns>The report filter</returns>
        private ReportFilter BuildReportFilter
        (
            RegisteredReport registeredReport,
            ReportDefinition reportDefinition,
            SubmittedReportFilterValues filterValues,
            ReportUserInfo userInfo
        )
        {
            var submittedParameterValues = filterValues.ParameterValues;
            var convertedParameterValues = new Dictionary <string, object>();

            var filter = new ReportFilter
                         (
                reportDefinition.Parameters.ToArray()
                         );

            // Process the parameter values submitted and convert them to their expected types
            if (submittedParameterValues != null && submittedParameterValues.Any())
            {
                var groupedValues = new Dictionary <string, List <object> >();

                foreach (var submittedValue in submittedParameterValues)
                {
                    var parameterName = submittedValue.ParameterName;

                    if (String.IsNullOrEmpty(parameterName))
                    {
                        throw new InvalidOperationException
                              (
                                  "The submitted parameter name cannot be null."
                              );
                    }

                    var convertedValue = ConvertParameterValue
                                         (
                        filter,
                        submittedValue
                                         );

                    if (groupedValues.ContainsKey(parameterName))
                    {
                        groupedValues[parameterName].Add
                        (
                            convertedValue
                        );
                    }
                    else
                    {
                        groupedValues.Add
                        (
                            parameterName,
                            new List <object> {
                            convertedValue
                        }
                        );
                    }
                }

                // Flatten the grouped values into individual parameter values
                foreach (var pair in groupedValues)
                {
                    if (pair.Value.Count > 1)
                    {
                        convertedParameterValues.Add
                        (
                            pair.Key,
                            pair.Value.ToArray()
                        );
                    }
                    else
                    {
                        convertedParameterValues.Add
                        (
                            pair.Key,
                            pair.Value.First()
                        );
                    }
                }
            }

            // Add any missing parameter values by using the definition defaults
            foreach (var definition in filter.ParameterDefinitions)
            {
                var parameter = definition.Parameter;

                var matchFound = convertedParameterValues.Any
                                 (
                    pair => pair.Key.Equals
                    (
                        parameter.Name,
                        StringComparison.InvariantCultureIgnoreCase
                    )
                                 );

                if (false == matchFound)
                {
                    convertedParameterValues.Add
                    (
                        parameter.Name,
                        parameter.DefaultValue
                    );
                }
            }

            var constrainedParameters = CompileParameterConstraints
                                        (
                registeredReport,
                userInfo
                                        );

            filter.SetParameterValues
            (
                convertedParameterValues,
                constrainedParameters
            );

            if (filterValues.SortingRules != null)
            {
                foreach (var submittedRule in filterValues.SortingRules)
                {
                    filter.SetSortingRule
                    (
                        submittedRule.SectionType,
                        submittedRule.ComponentName,
                        submittedRule.ColumnName,
                        submittedRule.Direction
                    );
                }
            }

            return(filter);
        }
예제 #16
0
        /// <summary>
        /// Compiles filter parameter constraints for the user specified
        /// </summary>
        /// <param name="registeredReport">The registered report</param>
        /// <param name="userInfo">The user information</param>
        /// <param name="parameterValues">The existing parameter values</param>
        /// <param name="constrainedParameters">The constrained parameters</param>
        /// <returns>
        /// The parameter constraints (parameter name and constrain value)
        /// </returns>
        /// <remarks>
        /// The parameter constraints defined by role assignments force certain
        /// report filter parameter values to be used over those submitted.
        ///
        /// In this method, we ensure any constraints are adhered to.
        /// </remarks>
        private Dictionary <string, object> CompileParameterConstraints
        (
            RegisteredReport registeredReport,
            ReportUserInfo userInfo
        )
        {
            var constrainedParameters = new Dictionary <string, object>();

            // NOTE:
            // We don't apply constraints when a user has no roles.

            if (userInfo.Roles.Any())
            {
                var assignments = GetAssignmentsForReport
                                  (
                    registeredReport.Name
                                  );

                assignments = assignments.Where
                              (
                    a => userInfo.Roles.Any
                    (
                        role => role.Equals(a.RoleName, StringComparison.OrdinalIgnoreCase)
                    )
                              )
                              .ToList();

                if (assignments.Any())
                {
                    var constraints = assignments.SelectMany
                                      (
                        assignment => assignment.ParameterConstraints
                                      );

                    foreach (var constraint in constraints.ToList())
                    {
                        var applyConstraint = assignments.All
                                              (
                            a => a.ParameterConstraints.Any
                            (
                                c => c.ParameterName.Equals(constraint.ParameterName, StringComparison.OrdinalIgnoreCase)
                            )
                                              );

                        // Only apply the constraint if all role assignments have it
                        if (applyConstraint)
                        {
                            var parameterName = constraint.ParameterName;

                            var value = constraint.ResolveValue
                                        (
                                userInfo
                                        );

                            constrainedParameters[parameterName] = value;
                        }
                    }
                }
            }

            return(constrainedParameters);
        }
예제 #17
0
        /// <summary>
        /// Asynchronously generates a report from a registered report and filter values
        /// </summary>
        /// <param name="reportName">The report name</param>
        /// <param name="filterValues">The filter values</param>
        /// <param name="userInfo">The user information</param>
        /// <returns>The generation result</returns>
        public async Task <ReportGenerationResult> GenerateAsync
        (
            string reportName,
            SubmittedReportFilterValues filterValues,
            ReportUserInfo userInfo
        )
        {
            Validate.IsNotEmpty(reportName);
            Validate.IsNotNull(filterValues);
            Validate.IsNotNull(userInfo);

            var watch = Stopwatch.StartNew();

            var hasAccess = CanUserAccessReport
                            (
                reportName,
                userInfo
                            );

            if (false == hasAccess)
            {
                watch.Stop();

                return(new ReportGenerationResult
                       (
                           null,
                           watch.ElapsedMilliseconds,
                           "The user is not authorized to generate the report."
                       ));
            }

            var registeredReport = _reportRepository.GetReport
                                   (
                reportName
                                   );

            if (registeredReport.Disabled)
            {
                watch.Stop();

                return(new ReportGenerationResult
                       (
                           null,
                           watch.ElapsedMilliseconds,
                           "The report cannot be generated because it is disabled."
                       ));
            }

            var reportDefinition = _definitionBuilder.Build
                                   (
                registeredReport,
                _queryRepository
                                   );

            var reportFilter = BuildReportFilter
                               (
                registeredReport,
                reportDefinition,
                filterValues,
                userInfo
                               );

            var options = new ReportGenerationOptions()
            {
                Culture           = userInfo.Culture,
                PreferredLanguage = userInfo.PreferredLanguage
            };

            var task = _reportGenerator.GenerateAsync
                       (
                reportDefinition,
                reportFilter,
                options
                       );

            var result = await task.ConfigureAwait
                         (
                false
                         );

            return(result);
        }
예제 #18
0
파일: MSTRPromptDAO.cs 프로젝트: radtek/crm
 /// <summary>
 /// 构造函数
 /// </summary>
 public MSTRPromptDAO(ReportUserInfo pUserInfo, ISQLHelper pSQLHelper)
     : base(pUserInfo, true, pSQLHelper)
 {
 }