Пример #1
0
        static public ServerRule Insert(IUpdateContext update, ServerRule entity)
        {
            var broker        = update.GetBroker <IServerRuleEntityBroker>();
            var updateColumns = new ServerRuleUpdateColumns();

            updateColumns.RuleName                = entity.RuleName;
            updateColumns.ServerPartitionKey      = entity.ServerPartitionKey;
            updateColumns.ServerRuleTypeEnum      = entity.ServerRuleTypeEnum;
            updateColumns.ServerRuleApplyTimeEnum = entity.ServerRuleApplyTimeEnum;
            updateColumns.Enabled     = entity.Enabled;
            updateColumns.DefaultRule = entity.DefaultRule;
            updateColumns.ExemptRule  = entity.ExemptRule;
            updateColumns.RuleXml     = entity.RuleXml;
            ServerRule newEntity = broker.Insert(updateColumns);

            return(newEntity);
        }
Пример #2
0
 static public ServerRule Insert(ServerRule entity)
 {
     using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
     {
         ServerRule newEntity = Insert(update, entity);
         update.Commit();
         return newEntity;
     }
 }
Пример #3
0
 static public ServerRule Insert(IUpdateContext update, ServerRule entity)
 {
     var broker = update.GetBroker<IServerRuleEntityBroker>();
     var updateColumns = new ServerRuleUpdateColumns();
     updateColumns.RuleName = entity.RuleName;
     updateColumns.ServerPartitionKey = entity.ServerPartitionKey;
     updateColumns.ServerRuleTypeEnum = entity.ServerRuleTypeEnum;
     updateColumns.ServerRuleApplyTimeEnum = entity.ServerRuleApplyTimeEnum;
     updateColumns.Enabled = entity.Enabled;
     updateColumns.DefaultRule = entity.DefaultRule;
     updateColumns.ExemptRule = entity.ExemptRule;
     updateColumns.RuleXml = entity.RuleXml;
     ServerRule newEntity = broker.Insert(updateColumns);
     return newEntity;
 }
Пример #4
0
        private void SaveData()
        {
            if (_rule == null)
            {
                _rule = new ServerRule();
            }


            if (RuleXmlTextBox.Text.Length > 0)
            {
                _rule.RuleXml = new XmlDocument();
                _rule.RuleXml.Load(new StringReader(RuleXmlTextBox.Text));
            }

            _rule.RuleName = RuleNameTextBox.Text;

            _rule.ServerRuleTypeEnum = ServerRuleTypeEnum.GetEnum(RuleTypeDropDownList.SelectedItem.Value);

            var ep = new SampleRuleExtensionPoint();
            object[] extensions = ep.CreateExtensions();

            Dictionary<ServerRuleTypeEnum, IList<ServerRuleApplyTimeEnum>> ruleTypeList = LoadRuleTypes(extensions);

            if (ruleTypeList.ContainsKey(_rule.ServerRuleTypeEnum))
            {
                string val = Request[RuleApplyTimeDropDownList.UniqueID];
                foreach (ServerRuleApplyTimeEnum applyTime in ruleTypeList[_rule.ServerRuleTypeEnum])
                {
                    _rule.ServerRuleApplyTimeEnum = applyTime;
                    if (val.Equals(applyTime.Lookup))
                    {
                        _rule.ServerRuleApplyTimeEnum = applyTime;
                        break;
                    }
                }
            }

            _rule.Enabled = EnabledCheckBox.Checked;
            _rule.DefaultRule = DefaultCheckBox.Checked;
            _rule.ServerPartitionKey = Partition.GetKey();
            _rule.ExemptRule = ExemptRuleCheckBox.Checked;
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                if (ViewState["_EditMode"] != null)
                    _editMode = (bool) ViewState["_EditMode"];

                if (ViewState["_ServerPartition"] != null)
                    _partition = (ServerPartition) ViewState["_ServerPartition"];

                if (ViewState["_EdittedRule"] != null)
                {
                    var ruleKey = ViewState["_EdittedRule"] as ServerEntityKey;
                    _rule = ServerRule.Load(ruleKey);
                }
            }
        }
Пример #6
0
        private void SaveData()
        {
            if (_rule == null)
            {
                _rule = new ServerRule
                            {
                                ServerRuleApplyTimeEnum = ServerRuleApplyTimeEnum.StudyProcessed
                            };
            }
            

            if (RuleXmlTextBox.Text.Length > 0)
            {
                StudyDataAccessController controller = new StudyDataAccessController();

                _rule.RuleXml = new XmlDocument();

                StringBuilder sb = new StringBuilder();
                sb.Append("<rule>");
                sb.Append(RuleXmlTextBox.Text);
                sb.Append("<action>");
                foreach (ListItem item in AuthorityGroupCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        sb.AppendFormat("<grant-access authorityGroupOid=\"{0}\"/>", item.Value);
                        // Add if it doesn't exist to the DataAccessGroup table
                        controller.AddDataAccessIfNotExists(item.Value);
                    }
                }
                sb.Append("</action>");
                sb.Append("</rule>");

                _rule.RuleXml.Load(new StringReader(sb.ToString()));
            }

            _rule.RuleName = RuleNameTextBox.Text;

            _rule.ServerRuleTypeEnum = ServerRuleTypeEnum.DataAccess;

            _rule.Enabled = EnabledCheckBox.Checked;
            _rule.DefaultRule = DefaultCheckBox.Checked;
            _rule.ServerPartitionKey = Partition.GetKey();
            _rule.ExemptRule = ExemptRuleCheckBox.Checked;
        }
Пример #7
0
 /// <summary>
 /// Displays a popup dialog box for users to add a new rule
 /// </summary>
 /// <param name="rule"></param>
 /// <param name="partition"></param>
 public void OnAddRule(ServerRule rule, ServerPartition partition)
 {
     AddEditServerRuleControl.EditMode = false;
     AddEditServerRuleControl.ServerRule = null;
     AddEditServerRuleControl.Partition = partition;
     AddEditServerRuleControl.Show();
 }
Пример #8
0
 /// <summary>
 /// Displays a popup dialog box for users to delete a rule
 /// </summary>
 /// <param name="rule"></param>
 /// <param name="partition"></param>
 public void OnDeleteRule(ServerRule rule, ServerPartition partition)
 {
     ConfirmDialog.Message = string.Format(SR.AdminServerRules_DeleteDialog_AreYouSure,rule.RuleName, partition.AeTitle);
     ConfirmDialog.MessageType = MessageBox.MessageTypeEnum.YESNO;
     ConfirmDialog.Data = rule.GetKey();
     ConfirmDialog.Show();
 }
Пример #9
0
 /// <summary>
 /// Displays a popup dialog box for users to edit a rule
 /// </summary>
 /// <param name="rule"></param>
 /// <param name="partition"></param>
 public void OnEditRule(ServerRule rule, ServerPartition partition)
 {
     AddEditServerRuleControl.EditMode = true;
     AddEditServerRuleControl.ServerRule = rule;
     AddEditServerRuleControl.Partition = partition;
     AddEditServerRuleControl.Show();
 }
Пример #10
0
 /// <summary>
 /// Displays a popup dialog box for users to add a new rule
 /// </summary>
 /// <param name="rule"></param>
 /// <param name="partition"></param>
 public void OnAddRule(ServerRule rule, ServerPartition partition)
 {
     AddEditDataRuleControl.Mode = AddEditDataRuleDialogMode.New;
     AddEditDataRuleControl.ServerRule = null;
     AddEditDataRuleControl.Partition = partition;
     AddEditDataRuleControl.Show();
 }
Пример #11
0
        /// <summary>
        /// Displays a popup dialog box for users to edit a rule
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="partition"></param>
        public void OnCopyRule(ServerRule rule, ServerPartition partition)
        {
            var copiedRule = new ServerRule(rule.RuleName + " (Copy)",rule.ServerPartitionKey,rule.ServerRuleTypeEnum, rule.ServerRuleApplyTimeEnum, rule.Enabled, rule.DefaultRule, rule.ExemptRule, (XmlDocument)rule.RuleXml.CloneNode(true));

            // Store a dummy entity key
            copiedRule.SetKey(new ServerEntityKey("ServerRule",Guid.NewGuid()));
 
            AddEditDataRuleControl.Mode = AddEditDataRuleDialogMode.Copy;
            AddEditDataRuleControl.ServerRule = copiedRule;
            AddEditDataRuleControl.Partition = partition;
            AddEditDataRuleControl.Show();
        }
Пример #12
0
 /// <summary>
 /// Displays a popup dialog box for users to edit a rule
 /// </summary>
 /// <param name="rule"></param>
 /// <param name="partition"></param>
 public void OnEditRule(ServerRule rule, ServerPartition partition)
 {
     AddEditDataRuleControl.Mode = AddEditDataRuleDialogMode.Edit;
     AddEditDataRuleControl.ServerRule = rule;
     AddEditDataRuleControl.Partition = partition;
     AddEditDataRuleControl.Show();
 }