public bool UpdateServerRule(ServerRule rule)
        {
            ServerRuleUpdateColumns parms = new ServerRuleUpdateColumns();

            parms.DefaultRule             = rule.DefaultRule;
            parms.Enabled                 = rule.Enabled;
            parms.RuleName                = rule.RuleName;
            parms.RuleXml                 = rule.RuleXml;
            parms.ServerPartitionKey      = rule.ServerPartitionKey;
            parms.ServerRuleApplyTimeEnum = rule.ServerRuleApplyTimeEnum;
            parms.ServerRuleTypeEnum      = rule.ServerRuleTypeEnum;
            parms.ExemptRule              = rule.ExemptRule;

            return(_adaptor.Update(rule.Key, parms));
        }
        public ServerRulesResponsePacket(byte[] data)
            : base(SteamPacketTypes.S2A_RULES, data)
        {
            if (reader.Length == 0) {
                throw new Exception("Wrong formatted S2A_RULES response packet.");
            }

            short numRules = reader.ReadShort();
            ServerRules = new ServerRule[(int)numRules];

            for (short i = 0; i < numRules; i++) {
                string cvar  = reader.ReadString();
                string value = reader.ReadString();

                ServerRules[i] = new ServerRule(cvar, value);
            }
        }
        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;
        }
        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;
        }
        public ServerRulesResponsePacket(byte[] data)
            : base(SteamPacketTypes.S2A_RULES, data)
        {
            if (reader.Length == 0)
            {
                throw new Exception("Wrong formatted S2A_RULES response packet.");
            }

            short numRules = reader.ReadShort();

            ServerRules = new ServerRule[(int)numRules];

            for (short i = 0; i < numRules; i++)
            {
                string cvar  = reader.ReadString();
                string value = reader.ReadString();

                ServerRules[i] = new ServerRule(cvar, value);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                if (ViewState["_Mode"] != null)
                {
                    _mode = (AddEditDataRuleDialogMode)ViewState["_Mode"];
                }

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

                if (ViewState["_EdittedRule"] != null)
                {
                    var ruleKey = ViewState["_EdittedRule"] as ServerEntityKey;
                    _rule = ServerRule.Load(ruleKey);
                }
            }
        }
Beispiel #7
0
        private List <string> GetReferences(ServerRule rule)
        {
            List <string> references = new List <string>();

            //
            // Add global references
            //
            foreach (AssemblyReference reference in Module._Options.GlobalReferences)
            {
                FileInfo info = new FileInfo(reference.Name);

                if (info.Extension.ToLower() != ".dll")
                {
                    references.Add(reference.Name + ".dll");
                }
                else
                {
                    references.Add(reference.Name);
                }
            }

            //
            // Add script references
            //
            foreach (AssemblyReference reference in rule.References)
            {
                FileInfo info = new FileInfo(reference.Name);

                if (info.Extension.ToLower() != ".dll")
                {
                    references.Add(reference.Name + ".dll");
                }
                else
                {
                    references.Add(reference.Name);
                }
            }

            return(references);
        }
        protected override void OnPreRender(EventArgs e)
        {
            ServerRule rule = ServerRuleGridViewControl.SelectedRule;

            if (rule == null)
            {
                // no rule being selected

                EditServerRuleButton.Enabled = false;

                DeleteServerRuleButton.Enabled = false;
            }
            else
            {
                EditServerRuleButton.Enabled = true;

                DeleteServerRuleButton.Enabled = !rule.DefaultRule;
            }

            base.OnPreRender(e);
            Refresh();
        }
 public ServerRulesResponsePacket(ServerRule[] rules)
     : base(SteamPacketTypes.S2A_RULES)
 {
     ServerRules = rules;
 }
Beispiel #10
0
        private List <string> GetNamespaces(ServerRule rule)
        {
            List <string> namespaces = Module._Options.GlobalNamespaces.Concat(rule.Namespaces).ToList();

            return(namespaces);
        }
Beispiel #11
0
 public bool DeleteServerRule(ServerRule rule)
 {
     return(_adaptor.Delete(rule.Key));
 }