当前位置: 首页>>代码示例>>C#>>正文


C# IUser.HasPermission方法代码示例

本文整理汇总了C#中IUser.HasPermission方法的典型用法代码示例。如果您正苦于以下问题:C# IUser.HasPermission方法的具体用法?C# IUser.HasPermission怎么用?C# IUser.HasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUser的用法示例。


在下文中一共展示了IUser.HasPermission方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartPageForUser

        private RedirectToRouteResult StartPageForUser(IUser user)
        {
            if (user.HasPermission(PermissionNames.CanViewAlarmManager))
            {
                return RedirectToAction("Index", "AlarmManager");
            }

            if (user.HasPermission(PermissionNames.CanViewReports))
            {
                return RedirectToAction("Index", "Reports");
            }

            if (user.HasPermission(PermissionNames.CanEditSystemSettings))
            {
                return RedirectToAction("Index", "ReportServerConfiguration");
            }

            return RedirectToAction("Index", "Unauthorized");
        }
开发者ID:shayaneumar,项目名称:gabbar,代码行数:19,代码来源:AccountController.cs

示例2: CallAndTransformErrors

        private ActionResult CallAndTransformErrors(Func<ActionResult> func, IUser user)
        {
            UserExtensions.PopulateViewBag(user, ViewBag);
            ReportsErrorModel model;

            try
            {
                return func();
            }
            catch (ReportingEndpointException)
            {
                // Invalid Report Server Uri Format or Endpoint
                model = new ReportsErrorModel(Resources.ReportingEndpointException, user.HasPermission(PermissionNames.CanEditReportsServerSettings));
            }
            catch (ReportingAuthenticationException)
            {
                // Invalid Credentials
                model = new ReportsErrorModel(Resources.ReportingAuthenticationException, user.HasPermission(PermissionNames.CanEditReportsServerSettings));
            }

            return View("Error", model);
        }
开发者ID:shayaneumar,项目名称:gabbar,代码行数:22,代码来源:ReportsController.cs

示例3: ProxyModifyScheduled

        private ActionResult ProxyModifyScheduled(ReportSchedulerModel model, IUser user)
        {
            if (model != null)
            {
                using (var reportingClient = _reportingClientFactory.CreateClient(user))
                {
                    string errorMessage;
                    List<ParameterValue> parameterValues = null;

                    try
                    {
                        if (ModelState.IsValid)
                        {
                            Debug.Assert(model.ReportFrequency != null, "model.ReportFrequency != null");
                            string scheduleId;
                            //TODO:Fix this controller, controllers should not be accessing the http context like this
                            parameterValues = Request.Form.ToReportParameters().ToList();
                            if (!string.IsNullOrWhiteSpace(Request.Form["NewSchedule"]))
                            {
                                //This is very poorly designed. Updates and creations should not be handled by the same action
                                //as a result of this design we now have to check permissions inside of an action. Permissions
                                //should always be handled by filters not actions.
                                if(!user.HasPermission(PermissionNames.CanScheduleReports)) return new HttpStatusCodeResult(403);
                                scheduleId = reportingClient.ScheduleReport(
                                    model.ReportId, model.Description,
                                    parameterValues.Concat(
                                        DateTimeRangeParameterArrayForReportFrequency(model.ReportFrequency.Value)),
                                    ScheduleDefinitionFromReportSchedulerModel(model),
                                    DeliverySettingsFromReportSchedulerModel(model));
                            }
                            else
                            {
                                scheduleId = model.ScheduleId;

                                reportingClient.UpdateSubscription(
                                    model.ScheduleId, model.Description,
                                    parameterValues.Concat(
                                        DateTimeRangeParameterArrayForReportFrequency(model.ReportFrequency.Value)),
                                    ScheduleDefinitionFromReportSchedulerModel(model),
                                    DeliverySettingsFromReportSchedulerModel(model));
                            }

                            return RedirectToAction("ScheduledReport", new {scheduleId, reportId = model.ReportId});
                        }

                        errorMessage = GetModelStateErrorMessages();
                    }
                    catch (ReportingLocationException)
                    {
                        errorMessage = Resources.SchedulerReportLocationInvalidErrorMessage;
                    }
                    catch (ReportingUnexpectedException ex)
                    {
                        Log.Error("{0}\n{1}", ex.Message, ex.StackTrace);
                        errorMessage = Resources.SchedulerReportUnexpectedErrorMessage;
                    }
                    catch (HttpRequestValidationException)
                    {
                        errorMessage = Resources.SchedulerReportUnacceptableValueMessage;
                    }
                    
                    try
                    {
                        model.Parameters = new ReportParameters(reportingClient.GetParameters(model.ReportId, DefaultReportDataSouce, parameterValues), true);
                    }
                    catch (HttpRequestValidationException)
                    {
                        model.Parameters = new ReportParameters(reportingClient.GetParameters(model.ReportId, DefaultReportDataSouce, null), true, parameterValues);
                        errorMessage = Resources.SchedulerReportUnacceptableValueMessage;
                    }

                    model.ParametersView = DynamicParameters;
                    SetMessage(model, MessageType.Error, errorMessage);

                    return View("ModifyScheduled", model);
                }
            }

            return View("Scheduled");
        }
开发者ID:shayaneumar,项目名称:gabbar,代码行数:80,代码来源:ReportsController.cs


注:本文中的IUser.HasPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。