예제 #1
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            var arguments = (object[])e.Argument;
            var solutions = (List <Entity>)arguments[2];
            var rm        = new RuleManager(entityName, service, connectionDetail);

            if (DisplaySystemView)
            {
                var query = new QueryExpression("savedquery")
                {
                    ColumnSet = new ColumnSet(true),
                    Criteria  = new FilterExpression
                    {
                        Conditions =
                        {
                            new ConditionExpression("querytype", ConditionOperator.Equal, 0),
                            new ConditionExpression("fetchxml",  ConditionOperator.NotNull)
                        }
                    }
                };

                if (arguments.Length > 1 && arguments[1] != null)
                {
                    query.Criteria.AddCondition("returnedtypecode", ConditionOperator.Equal, arguments[1].ToString());
                }
                else if (solutions.Count > 0)
                {
                    var emds = MetadataHelper.RetrieveEntities(service, solutions.Select(s => s.Id).ToList());
                    if (emds.Count > 0)
                    {
                        query.Criteria.AddCondition("returnedtypecode", ConditionOperator.In, emds.Select(emd => emd.LogicalName).ToArray());
                    }
                }

                e.Result = service.RetrieveMultiple(query);
            }
            else
            {
                string expectedReturnTypeCode = arguments.Length > 1 && arguments[1] != null ? arguments[1].ToString() : string.Empty;

                if (DisplaySystemRules)
                {
                    e.Result = rm.GetRules(new[] { 16, 256 }, expectedReturnedType: expectedReturnTypeCode, worker: (BackgroundWorker)sender);
                }
                else if (DisplayRulesTemplate)
                {
                    e.Result = rm.GetRules(new[] { 131072, 8192 }, expectedReturnedType: expectedReturnTypeCode, worker: (BackgroundWorker)sender);
                }
                else
                {
                    e.Result = rm.GetRules(new[] { 16, 256 }, (List <Entity>)arguments[0], worker: (BackgroundWorker)sender);
                }
            }
        }
예제 #2
0
        private void CreateNewRuleManager()
        {
            List <DualMonitor.Entities.Rule> rules = RuleManager.Clone(TaskbarPropertiesManager.Instance.Properties.Rules);

            _ruleManager = new RuleManager(rules, null);

            lbRules.Items.Clear();
            foreach (Rule r in _ruleManager.GetRules())
            {
                lbRules.Items.Add(r);
            }
        }
예제 #3
0
        private void RefreshRules()
        {
            tsMessage.Text = "Loading rules...";
            Application.DoEvents();

            if (tbAccountName.Text != null)
            {
                rm.Url = UrlBuilder.RuleUrl(
                    tbAccountName.Text,
                    tbStreamName.Text,
                    cbPowerTrack20.Checked,
                    cbReplay.Checked);
                rm.Username = tbUsername.Text;
                rm.Password = tbPassword.Text;

                DataLoading = true;
                ruleData    = rm.GetRules();
                if (ruleData == null)
                {
                    tsMessage.Text = "Error loading rules: " + rm.ErrorMessage;
                }

                else
                {
                    dsRules.Tables["Rules"].Clear();
                    foreach (var r in ruleData)
                    {
                        var nr = dsRules.Tables["Rules"].NewRow();
                        nr["tag"]   = r.tag;
                        nr["value"] = r.value;

                        dsRules.Tables["Rules"].Rows.Add(nr);
                    }

                    dsRules.AcceptChanges();

                    // dgRules.Show();
                    // tsMessage.Text = "Rules loaded.";
                }
                DataLoading = false;
            }
            else
            {
                tsMessage.ForeColor = Color.Red;
                tsMessage.Text      = "No Rules URL set.  Check settings.";
            }
        }