internal static DlpPolicyState RuleStateToDlpState(RuleState state, RuleMode mode) { if (state == RuleState.Disabled && mode == RuleMode.Audit) { return(DlpPolicyState.Disabled_Audit); } if (state == RuleState.Disabled && mode == RuleMode.AuditAndNotify) { return(DlpPolicyState.Disabled_AuditAndNotify); } if (state == RuleState.Disabled && mode == RuleMode.Enforce) { return(DlpPolicyState.Disabled_Enforce); } if (state == RuleState.Enabled && mode == RuleMode.Audit) { return(DlpPolicyState.Enabled_Audit); } if (state == RuleState.Enabled && mode == RuleMode.AuditAndNotify) { return(DlpPolicyState.Enabled_AuditAndNotify); } if (state == RuleState.Enabled && mode == RuleMode.Enforce) { return(DlpPolicyState.Enabled_Enforce); } return(DlpPolicyState.Disabled_Audit); }
public bool IsValid(RuleMode mode) { return(mode switch { RuleMode.Part1 => _part1Rule(), RuleMode.Part2 => _part2Rule(), _ => throw new NotSupportedException() });
protected void UpdateRules(RuleState state, RuleMode mode) { bool flag = this.taskObject.TargetItem.IsModified(ADObjectSchema.Name); ADRuleStorageManager adruleStorageManager; IEnumerable <TransportRuleHandle> transportRuleHandles = DlpUtils.GetTransportRuleHandles(base.DataSession, out adruleStorageManager); foreach (TransportRule transportRule in (from handle in transportRuleHandles select handle.Rule).Where(new Func <TransportRule, bool>(this.RuleDlpPolicyIdMatches))) { transportRule.Enabled = state; transportRule.Mode = mode; if (flag) { transportRule.SetDlpPolicy(this.taskObject.TargetItem.ImmutableId, this.taskObject.TargetItem.Name); } } adruleStorageManager.UpdateRuleHandles(transportRuleHandles); }
public static DashboardDatasourceFilterList CreateDashboardDatasourceFilterList( this DevExpress.DashboardCommon.Dashboard dashboard, IDashboardDefinition dashboardDefinition, RuleMode ruleMode, XafApplication application) { var objectSpace = application.CreateObjectSpace(typeof(DashboardDatasourceFilter)); var dashboardDatasourceFilterList = new DashboardDatasourceFilterList(); var dataSources = dashboard.GetDataSources(ruleMode, dashboardDefinition, application.Model); foreach (var item in dataSources.OrderBy(tuple => tuple.ModelDataSource.Index)) { if (item.ModelDataSource is IModelDashboardDataSourceFilter modelFilter && modelFilter.ShowInPopupView) { var filter = objectSpace.CreateObject <DashboardDatasourceFilter>(); filter.ID = item.ModelDataSource.Id(); filter.Filter = modelFilter.Filter; filter.DataSourceName = item.DataSource.Name; filter.TopReturnedRecords = modelFilter.TopReturnedRecords; filter.ShowPersistentMembersOnly = modelFilter.ShowPersistentMembersOnly; dashboardDatasourceFilterList.Filters.Add(filter); } } return(dashboardDatasourceFilterList); }
public override bool ShouldExecute(RuleMode mode, RulesEvaluationContext context) { return(base.ShouldExecute(mode, context) || RuleMode.AuditAndNotify == mode); }
public Rule(string value, RuleMode mode, RuleTarget target) { _value = value; _mode = mode; _target = target; }
/// <summary> /// Возвращает первое Правило с имеющимся определением из цепочки шаблонов, либо NULL /// </summary> /// <param name="rule"></param> /// <param name="serializer"></param> /// <returns></returns> private (ITemplateHavingEntity, RootContainer) GetFirstExistingRule(ITemplateHavingEntity rule, RuleMode ruleMode) { ITemplateHavingEntity r = null; var cont = (ruleMode == RuleMode.Rule) ? rule.GetRule <RootContainer>(_ruleSerializer) : rule.GetModRule <RootContainer>(_ruleSerializer); if (cont != null) { r = rule; } else if (rule.Template != null) { return(GetFirstExistingRule(rule.Template, ruleMode)); } return(r, cont); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!base.IsPostBack) { this.CheckIfCopyMode(); if (!string.IsNullOrEmpty(base.Request.QueryString["mode"])) { RuleMode ruleMode = (RuleMode)Enum.Parse(typeof(RuleMode), base.Request.QueryString["mode"], true); if (ruleMode == RuleMode.Audit || ruleMode == RuleMode.AuditAndNotify) { this.transportRuleEditor.AdvModeDialogMinSize = new Size(780, 575); this.transportRuleEditor.ForceDisclaimerOnNew = true; } this.transportRuleEditor.DlpPolicyMode = ruleMode.ToString(); } if (!string.IsNullOrEmpty(base.Request.QueryString["name"])) { this.transportRuleEditor.DlpPolicy = HttpUtility.UrlDecode(base.Request.QueryString["name"]); } if (!string.IsNullOrEmpty(base.Request.QueryString["preconfig"])) { string text = base.Request.QueryString["preconfig"].ToLower(); if (!string.IsNullOrEmpty(text)) { List <string> list = new List <string>(); List <string> list2 = new List <string>(); this.transportRuleEditor.DefaultValues.Add("SentToScope", ToUserScope.NotInOrganization.ToString()); string a; if ((a = text) != null) { if (!(a == "notifysender")) { if (!(a == "rejectwithoverride")) { if (!(a == "rejectnooverride")) { if (a == "rejectmessageallowoverrides") { list.AddRange(new string[] { "SentToScope", "MessageContainsDataClassifications" }); list2.AddRange(new string[] { "NotifySender", "GenerateIncidentReport" }); this.transportRuleEditor.DefaultValues.Add("IncidentReportOriginalMail", IncidentReportOriginalMail.IncludeOriginalMail.ToString()); this.transportRuleEditor.DefaultValues.Add("SenderNotifySettings", new SenderNotifySettings { NotifySender = NotifySenderType.RejectUnlessSilentOverride.ToString() }.ToJsonString(null)); } } else { list.AddRange(new string[] { "SentToScope", "MessageContainsDataClassifications" }); list2.AddRange(new string[] { "GenerateIncidentReport", "NotifySender" }); this.transportRuleEditor.DefaultValues.Add("IncidentReportOriginalMail", IncidentReportOriginalMail.IncludeOriginalMail.ToString()); this.transportRuleEditor.DefaultValues.Add("SenderNotifySettings", new SenderNotifySettings { NotifySender = NotifySenderType.RejectMessage.ToString() }.ToJsonString(null)); } } else { list.AddRange(new string[] { "SentToScope", "MessageContainsDataClassifications" }); list2.AddRange(new string[] { "GenerateIncidentReport", "NotifySender" }); this.transportRuleEditor.DefaultValues.Add("IncidentReportOriginalMail", IncidentReportOriginalMail.IncludeOriginalMail.ToString()); this.transportRuleEditor.DefaultValues.Add("SenderNotifySettings", new SenderNotifySettings { NotifySender = NotifySenderType.RejectUnlessExplicitOverride.ToString() }.ToJsonString(null)); } } else { list.AddRange(new string[] { "SentToScope", "MessageContainsDataClassifications" }); list2.AddRange(new string[] { "GenerateIncidentReport", "NotifySender" }); this.transportRuleEditor.DefaultValues.Add("IncidentReportOriginalMail", IncidentReportOriginalMail.IncludeOriginalMail.ToString()); this.transportRuleEditor.DefaultValues.Add("SenderNotifySettings", new SenderNotifySettings { NotifySender = NotifySenderType.NotifyOnly.ToString() }.ToJsonString(null)); } } this.transportRuleEditor.DefaultConditions = list.ToArray(); this.transportRuleEditor.DefaultActions = list2.ToArray(); } } } }
private static void ConfigureDashboard(IDashboardDefinition dashboardDefinition, RuleMode ruleMode, IXpandDashboardDataSourceFillService dashboardCollectionDataSourceFillService, DataSourceOptionsContainer options, Action <DevExpress.DashboardCommon.Dashboard> editParameters, DashboardDatasourceFilterList datasourceFilterList, DevExpress.DashboardCommon.Dashboard dashboard) { var canEditParameters = new[] { ruleMode, RuleMode.Always }.Contains(dashboardDefinition.EditParameters); if (canEditParameters) { editParameters(dashboard); } dashboardCollectionDataSourceFillService.FillService.DatasourceCreating += (sender, args) => { var filter = datasourceFilterList.Filters.LastOrDefault(_ => _.DataSourceName == args.TargetType.Name); if (filter != null) { dashboardCollectionDataSourceFillService.TopReturnedRecords = filter.TopReturnedRecords; dashboardCollectionDataSourceFillService.ShowPersistentMembersOnly = filter.ShowPersistentMembersOnly; } }; if (options != null) { options.ObjectDataSourceLoadingBehavior = DocumentLoadingBehavior.LoadAsIs; } }
private static bool CanApply(IModelDashboardDataSource modelDashboardDataSource, RuleMode ruleMode, IDashboardDefinition template) { if (modelDashboardDataSource.NodeEnabled && new[] { RuleMode.Always, ruleMode }.Contains(modelDashboardDataSource.Enabled)) { if (modelDashboardDataSource is IModelDashboardDataSourceFilter modelDashboardDataSourceFilter) { var objectSpace = XPObjectSpace.FindObjectSpaceByObject(template); var isObjectFitForCriteria = objectSpace.IsObjectFitForCriteria(template, CriteriaOperator.Parse(modelDashboardDataSourceFilter.DashboardDefinitionCriteria)); return(isObjectFitForCriteria.HasValue && isObjectFitForCriteria.Value); } return(true); } return(false); }
public static IEnumerable <(IDashboardDataSource DataSource, IModelDashboardDataSource ModelDataSource)> GetDataSources(this DevExpress.DashboardCommon.Dashboard dashboard, RuleMode ruleMode, IDashboardDefinition template, IModelApplication model) { var modelDashboardModule = ((IModelDashboardModuleDataSources)((IModelApplicationDashboardModule)model).DashboardModule); return(modelDashboardModule.DataSources .Where(source => source.NodeEnabled && CanApply(source, ruleMode, template)).Select(modelDataSource => { var dataSource = dashboard.DataSources.FirstOrDefault(source => Regex.IsMatch(source.Name, modelDataSource.DataSourceName, RegexOptions.IgnoreCase) && Regex.IsMatch(source.GetType().Name, modelDataSource.DatasourceType, RegexOptions.IgnoreCase)); return (DataSource: dataSource, ModelDataSource: modelDataSource); }).Where(tuple => tuple.DataSource != null && tuple.ModelDataSource != null)); }
public static DevExpress.DashboardCommon.Dashboard GetDashboard(this IDashboardDefinition dashboardDefinition, XafApplication application, RuleMode ruleMode, IXpandDashboardDataSourceFillService dashboardDataSourceFillService = null, DataSourceOptionsContainer options = null, Action <DevExpress.DashboardCommon.Dashboard> editParameters = null, Action modeParametersEdited = null) { var dashboard = dashboardDefinition.GetDashboard(); dashboard.ApplyModel(ruleMode, dashboardDefinition, application.Model); var datasourceFilterList = dashboard.CreateDashboardDatasourceFilterList(dashboardDefinition, ruleMode, application); var dashboardDatasourceFilter = datasourceFilterList.Filters.FirstOrDefault(); if (modeParametersEdited != null) { if (dashboardDatasourceFilter != null) { var detailView = application.CreateDetailView(dashboardDatasourceFilter.ObjectSpace, datasourceFilterList); detailView.ViewEditMode = ViewEditMode.Edit; application.ShowViewStrategy.ShowViewInPopupWindow(detailView, () => { SaveModel(datasourceFilterList, application); modeParametersEdited(); }); } return(dashboard); } ConfigureDashboard(dashboardDefinition, ruleMode, dashboardDataSourceFillService, options, editParameters, datasourceFilterList, dashboard); return(dashboard); }
public static void ApplyModel(this DevExpress.DashboardCommon.Dashboard dashboard, RuleMode ruleMode, IDashboardDefinition template, IModelApplication model) { var dataSources = GetDataSources(dashboard, ruleMode, template, model); foreach (var adapter in dataSources) { if (adapter.ModelDataSource is IModelDashboardDataSourceFilter filter) { var criteria = ApplyFilter(filter.Filter, adapter.DataSource.Filter); adapter.DataSource.Filter = criteria?.ToString(); if (adapter.DataSource is DashboardSqlDataSource dashboardSqlDataSource) { foreach (var selectQuery in dashboardSqlDataSource.Queries.OfType <SelectQuery>().Where(query => Regex.IsMatch(query.Name, filter.TableName))) { if (filter.TopReturnedRecords > 0) { selectQuery.Top = filter.TopReturnedRecords; } selectQuery.FilterString = criteria?.ToString(); } } } else if (adapter.ModelDataSource is IModelDashboardDataSourceParameter parameter) { parameter.ApplyValue(dashboard.Parameters[parameter.ParameterName]); } } }