public void WriteConditionXmlNullConditionTest( )
        {
            var       writerText = new StringBuilder( );
            XmlWriter writer     = XmlWriter.Create(writerText, new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            });

            ConditionHelper.WriteConditionXml("condition", null, writer);
        }
Example #2
0
        public RuleSetBrowserDialog(Activity activity, string name) : base(activity, name)
        {
            RuleDefinitions definitions = ConditionHelper.Load_Rules_DT(activity.Site, Helpers.GetRootActivity(activity));

            if (definitions != null)
            {
                this.ruleSetCollection = definitions.RuleSets;
            }
            base.InitializeListView(this.ruleSetCollection, name);
        }
        public void WriteConditionXmlEmptyElementNameTest( )
        {
            var       writerText = new StringBuilder( );
            XmlWriter writer     = XmlWriter.Create(writerText, new XmlWriterSettings
            {
                OmitXmlDeclaration = true
            });

            ConditionHelper.WriteConditionXml(string.Empty, new Condition( ), writer);
        }
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
        {
            if (typeDescriptorContext == null)
            {
                throw new ArgumentNullException("typeDescriptorContext");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            object obj2 = o;
            WorkflowDesignerLoader loader = serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;

            if ((loader != null) && loader.InDebugMode)
            {
                throw new InvalidOperationException(Messages.DebugModeEditsDisallowed);
            }
            RuleSetReference instance = typeDescriptorContext.Instance as RuleSetReference;

            if (((instance == null) || (instance.RuleSetName == null)) || (instance.RuleSetName.Length <= 0))
            {
                throw new ArgumentException(Messages.RuleSetNameNotSet);
            }
            Activity          component = null;
            IReferenceService service   = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;

            if (service != null)
            {
                component = service.GetComponent(typeDescriptorContext.Instance) as Activity;
            }
            RuleSetCollection ruleSets    = null;
            RuleDefinitions   definitions = ConditionHelper.Load_Rules_DT(serviceProvider, System.Workflow.Activities.Common.Helpers.GetRootActivity(component));

            if (definitions != null)
            {
                ruleSets = definitions.RuleSets;
            }
            if ((ruleSets != null) && !ruleSets.Contains(instance.RuleSetName))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Messages.RuleSetNotFound, new object[] { instance.RuleSetName }));
            }
            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (this.editorService != null)
            {
                RuleSet ruleSet = ruleSets[instance.RuleSetName];
                using (RuleSetDialog dialog = new RuleSetDialog(component, ruleSet))
                {
                    if (DialogResult.OK == this.editorService.ShowDialog(dialog))
                    {
                        obj2 = dialog.RuleSet;
                    }
                }
            }
            return(obj2);
        }
        public override void SetValue(object component, object value)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            RuleConditionReference conditionDecl = component as RuleConditionReference;

            if (conditionDecl == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Messages.NotARuleConditionReference, "component"), "component");
            }

            string conditionName = value as string;

            if ((conditionName == null) || (conditionName.TrimEnd().Length == 0))
            {
                conditionName = string.Empty;
            }

            ISite site = PropertyDescriptorUtils.GetSite(this.ServiceProvider, component);

            if (site == null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.MissingService, typeof(ISite).FullName);
                throw new InvalidOperationException(message);
            }

            RuleConditionCollection conditionDefinitions = null;
            RuleDefinitions         rules = ConditionHelper.Load_Rules_DT(site, Helpers.GetRootActivity(site.Component as Activity));

            if (rules != null)
            {
                conditionDefinitions = rules.Conditions;
            }

            if (conditionDefinitions != null && conditionName.Length != 0 && !conditionDefinitions.Contains(conditionName))
            {
                //in this case, RuleExpressionCondition is the only type allowed in the ruleConditionCollection
                RuleExpressionCondition newCondition = new RuleExpressionCondition();
                newCondition.Name = conditionName;
                conditionDefinitions.Add(newCondition);
                ConditionHelper.Flush_Rules_DT(site, Helpers.GetRootActivity(site.Component as Activity));
            }

            // Cause component change events to be fired.
            PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(component)["ConditionName"];

            if (propertyDescriptor != null)
            {
                PropertyDescriptorUtils.SetPropertyValue(site, propertyDescriptor, component, conditionName);
            }
        }
Example #6
0
        private void OnComponentChanged()
        {
            ISite serviceProvider           = this.activity.Site;
            IComponentChangeService service = (IComponentChangeService)serviceProvider.GetService(typeof(IComponentChangeService));

            if (service != null)
            {
                service.OnComponentChanged(this.activity, null, null, null);
            }
            ConditionHelper.Flush_Rules_DT(serviceProvider, Helpers.GetRootActivity(this.activity));
        }
Example #7
0
        public async Task <IActionResult> GetAllImageList(DetailTypeSSOT detailType)
        {
            TempData["PageType"] = detailType;
            var conditions = new ConditionHelper <ContentEntityDTO>();

            conditions.AddCondition(p => p.BlogContentEntityType == BlogContentEntityTypeSSOT.Image);

            var list = await _ContentManagementRepository.GetAll(conditions.GetConditionList());

            return(View("MainView", list));
        }
        protected override void DoDefaultAction()
        {
            base.DoDefaultAction();
            WorkflowDesignerLoader service = this.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;

            if ((service != null) && service.InDebugMode)
            {
                throw new InvalidOperationException(Messages.DebugModeEditsDisallowed);
            }
            PolicyActivity activity = (PolicyActivity)base.Activity;

            if (!System.Workflow.Activities.Common.Helpers.IsActivityLocked(activity))
            {
                RuleDefinitions definitions = ConditionHelper.Load_Rules_DT(this, System.Workflow.Activities.Common.Helpers.GetRootActivity(activity));
                if (definitions != null)
                {
                    RuleSetCollection ruleSets         = definitions.RuleSets;
                    RuleSetReference  ruleSetReference = activity.RuleSetReference;
                    RuleSet           ruleSet          = null;
                    string            key = null;
                    if ((ruleSetReference != null) && !string.IsNullOrEmpty(ruleSetReference.RuleSetName))
                    {
                        key = ruleSetReference.RuleSetName;
                        if (ruleSets.Contains(key))
                        {
                            ruleSet = ruleSets[key];
                        }
                    }
                    else
                    {
                        key = ruleSets.GenerateRuleSetName();
                    }
                    using (RuleSetDialog dialog = new RuleSetDialog(activity, ruleSet))
                    {
                        if (DialogResult.OK == dialog.ShowDialog())
                        {
                            if (ruleSet != null)
                            {
                                ruleSets.Remove(key);
                            }
                            else
                            {
                                dialog.RuleSet.Name       = key;
                                activity.RuleSetReference = new RuleSetReference(key);
                            }
                            ruleSets.Add(dialog.RuleSet);
                            ConditionHelper.Flush_Rules_DT(this, System.Workflow.Activities.Common.Helpers.GetRootActivity(activity));
                        }
                    }
                }
                TypeDescriptor.GetProperties(activity)["RuleSetReference"].SetValue(activity, activity.RuleSetReference);
            }
        }
Example #9
0
        public ConditionBrowserDialog(Activity activity, string name)
            : base(activity, name)
        {
            RuleDefinitions rules = ConditionHelper.Load_Rules_DT(activity.Site, Helpers.GetRootActivity(activity));

            if (rules != null)
            {
                this.declarativeConditionCollection = rules.Conditions;
            }

            InitializeListView(this.declarativeConditionCollection, name);
        }
Example #10
0
        private void OnComponentChanged()
        {
            ISite site = ((IComponent)this.activity).Site;
            IComponentChangeService changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));

            if (changeService != null)
            {
                changeService.OnComponentChanged(this.activity, null, null, null);
            }

            ConditionHelper.Flush_Rules_DT(site, Helpers.GetRootActivity(this.activity));
        }
Example #11
0
    public static void OnLevelUp(Player player)
    {
        int jobId = (int)player.Job;
        int level = player.Levels.Level;
        IEnumerable <TrophyMetadata> jobSpecificLevelTrophies = GetRelevantTrophies(TrophyTypes.LevelUp)
                                                                .Where(t => ConditionHelper.IsMatching(t.ConditionCodes, jobId) &&
                                                                       ConditionHelper.IsMatching(t.Grades.First().ConditionTargets, level));

        IEnumerable <TrophyMetadata> levelTrophies = GetRelevantTrophies(TrophyTypes.Level);

        UpdateMatchingTrophies(player, jobSpecificLevelTrophies, 1);
        UpdateMatchingTrophies(player, levelTrophies, 1);
    }
        public void ReadConditionXmlInvalidXmlTest( )
        {
            var doc = new XmlDocument( );

            doc.LoadXml("<xml><condition></condition></xml>");
            Condition condition = ConditionHelper.ReadConditionXml(doc.DocumentElement, "condition");

            Assert.AreEqual(ConditionType.Unspecified, condition.Operator, "The value of Condition.Operator is invalid.");
            Assert.AreEqual(string.Empty, condition.ColumnName, "The value of Condition.ColumnName is invalid.");

            Assert.AreEqual(DatabaseType.UnknownType.GetType( ), condition.ColumnType.GetType( ), "The value of Condition.ColumnType is invalid.");
            Assert.AreEqual(0, condition.Arguments.Count, "The value of Arguments.Count is invalid.");
        }
        protected override string ToStringInternal()
        {
            var result = "MVN";

            if (S)
            {
                result += "S";
            }
            result += ConditionHelper.ToString(Condition);
            result += " R" + Rd + ", ";

            return(result);
        }
Example #14
0
        public override string ToString()
        {
            var result = "B";

            if (_l)
            {
                result += "L";
            }
            result += ConditionHelper.ToString(_condition);

            result += $" #{_offset + 8}";
            return(result);
        }
Example #15
0
        public void Execute(IExecutionEnvironment env)
        {
            if (!(env.CpuState is Aarch32CpuState armCpuState))
            {
                throw new InvalidOperationException("Unknown cpu state.");
            }

            if (!ConditionHelper.CanExecute(armCpuState, _condition))
            {
                return;
            }

            env.InterruptBroker.Execute(_svc, env);
        }
Example #16
0
    /// <summary>
    /// Updates all Conditions where the condition type, code and target match the given parameters.
    /// </summary>
    /// <param name="relevantQuests"><see cref="GetRelevantQuests"/></param>
    /// <param name="session">GameSession of request</param>
    /// <param name="conditionType">Condition type, see <see cref="ConditionTypes"/> for all types</param>
    /// <param name="code">Code as string</param>
    /// <param name="target">Target as string</param>
    private static void UpdateRelevantConditions(this IEnumerable <QuestStatus> relevantQuests, GameSession session, string conditionType, string code,
                                                 string target = "0")
    {
        foreach (QuestStatus quest in relevantQuests)
        {
            quest.Condition.Where(condition => ConditionHelper.IsMatching(condition.Type, conditionType) &&
                                  ConditionHelper.IsMatching(condition.Code, code) &&
                                  ConditionHelper.IsMatching(condition.Target, target) &&
                                  !condition.Completed)
            .UpdateConditions(session, quest);

            DatabaseManager.Quests.Update(quest);
        }
    }
Example #17
0
 /// <summary>
 /// Updates all Conditions where the condition type, code and target match the given parameters.
 /// </summary>
 /// <param name="relevantQuests"><see cref="GetRelevantQuests"/></param>
 /// <param name="session">GameSession of request</param>
 /// <param name="conditionType">Condition type, see <see cref="ConditionTypes"/> for all types</param>
 /// <param name="code">Code as long</param>
 /// <param name="target">Target as long</param>
 private static void UpdateRelevantConditions(this IEnumerable <QuestStatus> relevantQuests, GameSession session, string conditionType, long code,
                                              long target = 0)
 {
     foreach (QuestStatus quest in relevantQuests)
     {
         quest.Condition.Where(condition => ConditionHelper.IsMatching(condition.Type, conditionType) &&
                               ConditionHelper.IsMatching(condition.Code, code) &&
                               (ConditionHelper.IsMatching(condition.Target, target) ||
                                ConditionHelper.IsMatching(condition.Target, code.ToString()) ||
                                ConditionHelper.IsMatching(condition.Target, "0")) &&
                               !condition.Completed)
         .UpdateConditions(session, quest);
     }
 }
        public AirPurifier2sTrening(
            ILogger <AirPurifier2sTrening> logger,
            HomeAssistantConnector connector,
            AutomationHelpersFactory automationHelpersFactory)
        {
            this.logger           = logger;
            this.connector        = connector;
            this.turnOffCondition = automationHelpersFactory
                                    .GetConditionHelper()
                                    .For(TimeSpan.FromMinutes(forTurnOffTime));

            this.turnOnCondition = automationHelpersFactory
                                   .GetConditionHelper()
                                   .For(TimeSpan.FromMinutes(forTurnOnTime));
        }
Example #19
0
 private void ValidateConditions(ConditionXml condition)
 {
     foreach (var predicate in condition.Predicates)
     {
         var helper     = new ConditionHelper();
         var metadata   = helper.Execute(predicate);
         var impl       = new DecorationFactory().Instantiate(metadata);
         var isVerified = impl.Validate();
         if (!isVerified)
         {
             Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, $"Test ignored. At least one condition was not validated: '{impl.Message}'");
             Assert.Ignore($"This test has been ignored because following check wasn't successful: {impl.Message}");
         }
     }
 }
Example #20
0
 private void ValidateConditions(ConditionXml condition, IDictionary <string, ITestVariable> allVariables)
 {
     foreach (var predicate in condition.Predicates)
     {
         var helper     = new ConditionHelper(serviceLocator, allVariables);
         var args       = helper.Execute(predicate);
         var impl       = new DecorationFactory().Instantiate(args);
         var isVerified = impl.Validate();
         if (!isVerified)
         {
             Trace.WriteLineIf(NBiTraceSwitch.TraceInfo, $"Test ignored. At least one condition was not validated: '{impl.Message}'");
             Assert.Ignore($"This test has been ignored because following check wasn't successful: {impl.Message}");
         }
     }
 }
Example #21
0
 public AirHumidifierWaterLevelNotification(
     ILogger <AirHumidifierWaterLevelNotification> logger,
     HomeAssistantConnector connector,
     AutomationHelpersFactory automationHelpersFactory,
     NotificationPushService notificationPushService,
     IDateTimeHelper dateTimeHelper)
 {
     this.logger    = logger;
     this.connector = connector;
     this.notificationPushService = notificationPushService;
     this.dateTimeHelper          = dateTimeHelper;
     this.notifyCondition         = automationHelpersFactory
                                    .GetConditionHelper()
                                    .For(TimeSpan.Zero)
                                    .Name(logger, this.GetType().Name);
 }
        private void ValidateSupportedConditions(ConditionHelper helper)
        {
            if (typeof(TPropertyType) == typeof(object))
            {
                //TODO: Issue regarding the TPropertyType that comes from the UI always as 'Object'
                System.Diagnostics.Debug.WriteLine("WARN: Not able to check if the operation is supported or not.");
                return;
            }

            var supportedConditions = helper.SupportedConditions(typeof(TPropertyType));

            if (!supportedConditions.Contains(Condition))
            {
                throw new UnsupportedOperationException(Condition, typeof(TPropertyType).Name);
            }
        }
        /// <summary>
        /// Writes the color formatting rule to the specified XML writer.
        /// </summary>
        /// <param name="colorFormattingRule">The color formatting rule to serialize.</param>
        /// <param name="xmlWriter">The XML writer used to write the image to.</param>
        private static void WriteColorFormattingRuleXml(ColorFormattingRule colorFormattingRule, XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("colorFormattingRule");
            xmlWriter.WriteStartElement("rules");
            foreach (ColorRule rule in colorFormattingRule.Rules)
            {
                xmlWriter.WriteStartElement("rule");

                ColorInfoHelper.WriteColorInfoXml("backgroundColor", rule.BackgroundColor, xmlWriter);
                ColorInfoHelper.WriteColorInfoXml("foregroundColor", rule.ForegroundColor, xmlWriter);
                ConditionHelper.WriteConditionXml("condition", rule.Condition, xmlWriter);

                xmlWriter.WriteEndElement(); // rule
            }
            xmlWriter.WriteEndElement();     // rules
            xmlWriter.WriteEndElement();     // colorFormattingRule
        }
Example #24
0
        public async Task <IActionResult> Index(BankUniversityNameSearchViewModel search, int id)
        {
            var conditions = new ConditionHelper <TestSummeryDTO>();

            if (search.Term != null)
            {
                conditions.AddCondition(p => p.Title.Contains(search.Term));
            }


            var data = await _bankUniversityNameRepository.GetAll <TestSummeryDTO>(conditions.GetConditionList());

            var model = new SearchCriteriaPageModel <List <TestSummeryDTO>, BankUniversityNameSearchViewModel>(data, search);

            ViewBag.Id = id;
            return(View(model));
        }
        public void Execute(IExecutionEnvironment env)
        {
            switch (env.CpuState)
            {
            case Aarch32CpuState armCpuState:
                if (!ConditionHelper.CanExecute(armCpuState, _condition))
                {
                    return;
                }

                armCpuState.PC = armCpuState.Registers[_rn];
                break;

            default:
                throw new InvalidOperationException("Unknown cpu state.");
            }
        }
Example #26
0
        public AirPurifierProAutomations(
            ILogger <AirPurifierProAutomations> logger,
            HomeAssistantConnector connector,
            AutomationHelpersFactory automationHelpersFactory,
            IDateTimeHelper dateTimeHelper)
        {
            this.logger           = logger;
            this.connector        = connector;
            this.dateTimeHelper   = dateTimeHelper;
            this.turnOffCondition = automationHelpersFactory
                                    .GetConditionHelper()
                                    .For(TimeSpan.FromMinutes(forTime));

            this.turnOnCondition = automationHelpersFactory
                                   .GetConditionHelper()
                                   .For(TimeSpan.FromMinutes(forTime));
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object valueToConvert)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            string ruleSetName = valueToConvert as string;

            if ((ruleSetName == null) || (ruleSetName.TrimEnd().Length == 0))
            {
                ruleSetName = string.Empty;
            }

            ISite site = PropertyDescriptorUtils.GetSite(context, context.Instance);

            if (site == null)
            {
                string message = string.Format(CultureInfo.CurrentCulture, Messages.MissingService, typeof(ISite).FullName);
                throw new InvalidOperationException(message);
            }

            RuleSetCollection ruleSetCollection = null;
            RuleDefinitions   rules             = ConditionHelper.Load_Rules_DT(site, Helpers.GetRootActivity(site.Component as Activity));

            if (rules != null)
            {
                ruleSetCollection = rules.RuleSets;
            }

            if (ruleSetCollection != null && ruleSetName.Length != 0 && !ruleSetCollection.Contains(ruleSetName))
            {
                //in this case, RuleExpressionCondition is the only type allowed in the ruleConditionCollection
                RuleSet newRuleSet = new RuleSet();
                newRuleSet.Name = ruleSetName;
                ruleSetCollection.Add(newRuleSet);
                ConditionHelper.Flush_Rules_DT(site, Helpers.GetRootActivity(site.Component as Activity));
            }

            RuleSetReference ruleSetReference = new RuleSetReference();

            ruleSetReference.RuleSetName = ruleSetName;

            return(ruleSetReference);
        }
Example #28
0
        public override void SetValue(object component, object value)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }
            if (!(component is RuleConditionReference))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Messages.NotARuleConditionReference, new object[] { "component" }), "component");
            }
            string key = value as string;

            if ((key == null) || (key.TrimEnd(new char[0]).Length == 0))
            {
                key = string.Empty;
            }
            ISite serviceProvider = PropertyDescriptorUtils.GetSite(base.ServiceProvider, component);

            if (serviceProvider == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.MissingService, new object[] { typeof(ISite).FullName }));
            }
            RuleConditionCollection conditions  = null;
            RuleDefinitions         definitions = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(serviceProvider.Component as Activity));

            if (definitions != null)
            {
                conditions = definitions.Conditions;
            }
            if (((conditions != null) && (key.Length != 0)) && !conditions.Contains(key))
            {
                RuleExpressionCondition item = new RuleExpressionCondition {
                    Name = key
                };
                conditions.Add(item);
                ConditionHelper.Flush_Rules_DT(serviceProvider, Helpers.GetRootActivity(serviceProvider.Component as Activity));
            }
            PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(component)["ConditionName"];

            if (propertyDescriptor != null)
            {
                PropertyDescriptorUtils.SetPropertyValue(serviceProvider, propertyDescriptor, component, key);
            }
        }
        /// <summary>
        /// Reconstructs a color formatting rule from the specified XML image.
        /// </summary>
        /// <param name="node">The node containing the color formatting rule XML.</param>
        /// <returns>The color formatting rule.</returns>
        private static ColorFormattingRule ReadColorFormattingRuleXml(XmlNode node)
        {
            ColorFormattingRule formattingRule = new ColorFormattingRule();

            XmlNodeList ruleNodes = XmlHelper.SelectNodes(node, "colorFormattingRule/rules/rule");

            foreach (XmlNode ruleNode in ruleNodes)
            {
                ColorRule rule = new ColorRule();

                rule.BackgroundColor = ColorInfoHelper.ReadColorInfoXml(ruleNode, "backgroundColor");
                rule.ForegroundColor = ColorInfoHelper.ReadColorInfoXml(ruleNode, "foregroundColor");
                rule.Condition       = ConditionHelper.ReadConditionXml(ruleNode, "condition");

                formattingRule.Rules.Add(rule);
            }

            return(formattingRule);
        }
        public AirHumidifierAutomations(
            ILogger <AirHumidifierAutomations> logger,
            HomeAssistantConnector connector,
            AutomationHelpersFactory automationHelpersFactory,
            IDateTimeHelper dateTimeHelper)
        {
            this.logger           = logger;
            this.connector        = connector;
            this.dateTimeHelper   = dateTimeHelper;
            this.turnOffCondition = automationHelpersFactory
                                    .GetConditionHelper()
                                    .Name(logger, "Air humidifier turning off")
                                    .For(TimeSpan.FromMinutes(1));

            this.turnOnCondition = automationHelpersFactory
                                   .GetConditionHelper()
                                   .Name(logger, "Air humidifier turning on")
                                   .For(TimeSpan.FromMinutes(10));
        }