Creating Condition in C# set does not add it to VC - VisualCron - Forum

Community forum

Adrian Basheer
2016-02-08T16:36:38Z
Hello,

With the following code snippet, I am trying to create a condition, then add it to a condition set, then add the condition set to the server object.
The result is that the condition set can be see in Visual Cron, but it is an empty set. It is as if cs.Conditions.Add(cc1); is not having an effect.

Any help would be greatly appreciated.

            ConditionClass cc1 = new ConditionClass();
            cc1.ConditionType = ConditionClass.ConditionT.VisualCron;
            cc1.CVisualCron = new ConditionVisualCronClass();
            cc1.CVisualCron.MatchType = ConditionClass.MatchT.MatchIsNot;
            cc1.CVisualCron.CheckType = ConditionVisualCronClass.CheckT.TaskOutputIs;
            cc1.CVisualCron.Contains = "";
            cc1.CVisualCron.LocatorType = ConditionVisualCronClass.LocatorT.Auto;

            ConditionSetClass cs = new ConditionSetClass();
            cs.Description = "API Prev Task has StdOut";
            cs.Conditions.Add(cc1);

            server.Conditions.Add(cs);
Adrian Basheer
2016-02-09T21:39:15Z
Hello,
After some guessing, I called UpdateIds() just before saving, and it worked.
This however looks a bit like a bug, as you would expect an Id to be assigned automatically to objects with Null Id:


            ConditionClass cc1 = new ConditionClass();
            cc1.ConditionType = ConditionClass.ConditionT.VisualCron;
            cc1.CVisualCron = new ConditionVisualCronClass();
            cc1.Description = "Determines if the previous task has output";
            cc1.CVisualCron.MatchType = ConditionClass.MatchT.MatchIsNot;
            cc1.CVisualCron.CheckType = ConditionVisualCronClass.CheckT.TaskOutputIs;
            cc1.CVisualCron.Contains = "";
            cc1.CVisualCron.LocatorType = ConditionVisualCronClass.LocatorT.Auto;

            ConditionClass cc2 = new ConditionClass();
            cc2.ConditionType = ConditionClass.ConditionT.VisualCron;
            cc2.CVisualCron = new ConditionVisualCronClass();
            cc2.Description = "Determines if the previous task has errors";
            cc2.CVisualCron.MatchType = ConditionClass.MatchT.MatchIsNot;
            cc2.CVisualCron.CheckType = ConditionVisualCronClass.CheckT.TaskOutputErrorIs;
            cc2.CVisualCron.Contains = "";
            cc2.CVisualCron.LocatorType = ConditionVisualCronClass.LocatorT.Auto;

            ConditionSetClass cs = new ConditionSetClass();
            cs.Description = "API Prev Task has StdOut";
            cs.Conditions.Add(cc1);
            cs.Conditions.Add(cc2);
            cs.UpdateIds();  // <--------------

            server.Conditions.Add(cs);
Scroll to Top