Ejemplo n.º 1
0
        private bool SetVariableToNumberOrVariable(TriggerReader reader)
        {
            var var = reader.ReadVariable(true);

            if (reader.PeekVariable <double>())
            {
                var.Value = reader.ReadVariable().Value.AsDouble(0d);
            }
            else if (reader.PeekNumber())
            {
                var.Value = reader.ReadNumber();
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool RandomValueToVar(TriggerReader reader)
        {
            var var = reader.ReadVariable(true);

            var.Value = (double)new Random().Next();
            return(true);
        }
Ejemplo n.º 3
0
        private bool GetCurrentHourIntoVar(TriggerReader reader)
        {
            var var = reader.ReadVariable(true);

            var.Value = TimeZoneInfo.ConvertTime(DateTime.Now, timeZone).TimeOfDay.Hours.AsDouble();
            return(true);
        }
Ejemplo n.º 4
0
        private bool VariableGreaterThanOrEqual(TriggerReader reader)
        {
            var    mainVar = reader.ReadVariable();
            double num     = reader.ReadNumber();

            return(mainVar.Value.AsDouble() >= num);
        }
Ejemplo n.º 5
0
        private bool GetUTCTimeZone(TriggerReader reader)
        {
            var var = reader.ReadVariable(true);

            var.Value = TimeZoneInfo.Utc.Id;
            return(true);
        }
Ejemplo n.º 6
0
        private bool VariableLessThan(TriggerReader reader)
        {
            var    mainVar = reader.ReadVariable();
            double num     = reader.ReadNumber();

            return(mainVar.Value.AsDouble() < num);
        }
Ejemplo n.º 7
0
        private bool IsVariableEqualToNumberOrVar(TriggerReader reader)
        {
            var    var = reader.ReadVariable();
            double num = 0;

            return(reader.ReadNumber() == var.Value.AsDouble());
        }
Ejemplo n.º 8
0
        private bool GetCurrentUpTimeIntoVar(TriggerReader reader)
        {
            var var = reader.ReadVariable(true);

            var.Value = System.Math.Round((TimeZoneInfo.ConvertTime(DateTime.Now, timeZone) - startTime).TotalSeconds);
            return(true);
        }
Ejemplo n.º 9
0
        private bool DeleteVariable(TriggerReader reader)
        {
            var var = reader.ReadVariable();

            var.Value = null;
            return(!var.IsConstant ? reader.Page.RemoveVariable(var.Name) : false);
        }
Ejemplo n.º 10
0
        private bool JobCalled(TriggerReader reader)
        {
            double jobNumber = 0;

            if (reader.PeekVariable())
            {
                jobNumber = reader.ReadVariable().Value.AsDouble();
            }
            else if (reader.PeekNumber())
            {
                jobNumber = reader.ReadNumber();
            }

            double requiredJobNumber = reader.GetParameter <double>(0);

            if (reader.TryReadVariableTable(out VariableTable table, true))
            {
                object[] args = reader.Parameters.Skip(1).ToArray();
                for (int i = 0; i <= args.Length - 1; i++)
                {
                    table.Add(i.ToString(), args[i]);
                }
            }

            bool result = false;

            if (jobNumber > 0 && jobNumber == requiredJobNumber)
            {
                result = reader.CurrentBlock.IndexOfTrigger(TriggerCategory.Effect, 115, reader.CurrentBlockIndex) == -1;
            }
            return(result);
        }
Ejemplo n.º 11
0
        private bool CallJob(TriggerReader reader)
        {
            double jobNumber = 0;

            if (reader.PeekVariable())
            {
                jobNumber = reader.ReadVariable().Value.AsDouble();
            }
            else if (reader.PeekNumber())
            {
                jobNumber = reader.ReadNumber();
            }

            var args = reader.ReadValues().ToArray();

            if (jobNumber > 0)
            {
                if (args == null || args.Length == 0)
                {
                    reader.Page.Execute(100, jobNumber);
                }
                else
                {
                    reader.Page.Execute(100, Enumerable.Concat(new object[] { jobNumber }, args).ToArray());
                }
            }
            return(true);
        }
Ejemplo n.º 12
0
        private bool ForKeyValueInTable(TriggerReader reader)
        {
            var table = reader.ReadVariableTable();
            var key   = reader.ReadVariable(true);
            var val   = reader.ReadVariable(true);

            if (!table.Next(out object keyVal))
            {
                reader.Page.RemoveVariable(key);
                reader.Page.RemoveVariable(val);
                return(false);
            }
            key.Value = table.ActiveIndexer;
            val.Value = keyVal;
            return(true);
        }
Ejemplo n.º 13
0
        private bool GetEnvVariable(TriggerReader reader)
        {
            string envVar = Environment.GetEnvironmentVariable(reader.ReadString());
            var    var    = reader.ReadVariable(true);

            var.Value = envVar;
            return(true);
        }
        private bool PutWordCountIntoVariable(TriggerReader reader)
        {
            string[] words = reader.ReadString().Split(' ');
            var      var   = reader.ReadVariable(true);

            var.Value = words.Length;
            return(true);
        }
        private bool AddStringToVar(TriggerReader reader)
        {
            string str = reader.ReadString();
            var    var = reader.ReadVariable();

            var.Value = var.Value + str;
            return(true);
        }
Ejemplo n.º 16
0
        private bool SetVariableToString(TriggerReader reader)
        {
            var var = reader.ReadVariable(true);
            var str = reader.ReadString();

            var.Value = str;
            return(true);
        }
Ejemplo n.º 17
0
        private bool SubtractFromVariable(TriggerReader reader)
        {
            var    toAssign = reader.ReadVariable(true);
            double num      = reader.ReadNumber();

            toAssign.Value = toAssign.Value.AsDouble() - num;
            return(true);
        }
Ejemplo n.º 18
0
        private bool MultiplyByVariable(TriggerReader reader)
        {
            var    toAssign = reader.ReadVariable(true);
            double num      = reader.ReadNumber();

            toAssign.Value = toAssign.Value.AsDouble() * num;
            return(true);
        }
Ejemplo n.º 19
0
        private bool GetTableKeyIntoVar(TriggerReader reader)
        {
            var var  = reader.ReadVariableTable();
            var key  = reader.ReadString();
            var into = reader.ReadVariable(true);

            into.Value = var[key];
            return(true);
        }
        private bool IndexOfStringToVar(TriggerReader reader)
        {
            var str    = reader.ReadString();
            var search = reader.ReadString();
            var var    = reader.ReadVariable(true);
            var index  = str.IndexOf(search);

            var.Value = index;
            return(true);
        }
Ejemplo n.º 21
0
 private bool GetCurrentTimerIntoVar(TriggerReader reader)
 {
     if (reader.Parameters.Length > 0)
     {
         var var = reader.ReadVariable(true);
         var.Value = reader.GetParameter <double>(0);
         return(true);
     }
     return(false);
 }
        private bool SubStringToVar(TriggerReader reader)
        {
            var str    = reader.ReadString();
            var start  = reader.ReadNumber();
            var end    = reader.ReadNumber();
            var var    = reader.ReadVariable(true);
            var subStr = str.Substring((int)start, (int)end);

            var.Value = subStr;
            return(true);
        }
Ejemplo n.º 23
0
        private bool ForEntryInTable(TriggerReader reader)
        {
            var table = reader.ReadVariableTable();
            var var   = reader.ReadVariable(true);

            if (!table.Next(out object keyVal))
            {
                reader.Page.RemoveVariable(var);
                return(false);
            }
            var.Value = keyVal;
            return(true);
        }
Ejemplo n.º 24
0
        private bool IsVariableEqualToString(TriggerReader reader)
        {
            var var = reader.ReadVariable();

            if (var == null)
            {
                return(false);
            }
            if (reader.PeekString())
            {
                var str = reader.ReadString();
                return(var.Value.AsString(string.Empty).Equals(str, StringComparison.InvariantCulture));
            }
            return(false);
        }
Ejemplo n.º 25
0
        public double ReadVariableOrNumber(TriggerReader reader, bool addIfNotExist = false)
        {
            double num = 0;

            if (reader.PeekVariable())
            {
                string str = reader.ReadVariable(addIfNotExist).Value.ToString();
                double.TryParse(str, out num);
            }
            else if (reader.PeekNumber())
            {
                num = reader.ReadNumber();
            }
            return(num);
        }
Ejemplo n.º 26
0
        private bool ReadFileIntoVariable(TriggerReader reader)
        {
            string        file = reader.ReadString();
            var           var  = reader.ReadVariable(true);
            StringBuilder sb   = new StringBuilder();

            using (var stream = File.Open(Path.Combine(DefaultAuthorizedPath, file), FileMode.Open, FileAccess.Read))
            {
                using (var streamReader = new StreamReader(stream))
                {
                    sb.Append(streamReader.ReadToEnd());
                }
            }
            var.Value = sb.ToString();
            return(true);
        }
Ejemplo n.º 27
0
        private bool WhileVarIsNotValue(TriggerReader reader)
        {
            var  var         = reader.ReadVariable();
            var  value       = reader.ReadNumber();
            bool canContinue = var.Value.AsDouble() != value;

            if (!reader.Page.HasVariable("___while_counter", out ConstantVariable whileCounter))
            {
                whileCounter = reader.Page.SetVariable(new ConstantVariable("___while_counter", 0d));
            }
            whileCounter.SetValue(whileCounter.Value.AsDouble() + 1);
            if (whileCounter.Value.AsDouble() >= reader.Engine.Options.LoopLimit)
            {
                canContinue = false;
            }
            if (!canContinue)
            {
                reader.Page.RemoveVariable(whileCounter);
            }
            return(canContinue);
        }
        public static bool CreateForm(TriggerReader reader)
        {
            string formName = (reader.PeekString()) ? reader.ReadString() : "Form";

            if (reader.PeekVariable() == false)
            {
                return(false);
            }
            Variable var  = reader.ReadVariable(true);
            Form     form = new Form();

            form.Text = formName;
            double id = ControlLib.CreateRandomID();

            reader.Page.SetVariable(var.Name, id, var.IsConstant);
            form.Name = id.ToString();
            ControlLib.controls.Add(id, form);
            form.ShowDialog();
            form.Visible = true;
            return(true);
        }
Ejemplo n.º 29
0
        private bool WhileVarIsNotString(TriggerReader reader)
        {
            var  var         = reader.ReadVariable();
            var  value       = reader.ReadString();
            bool canContinue = !var.Value.AsString().Equals(value, StringComparison.InvariantCulture);

            if (!reader.Page.HasVariable("___while_counter", out ConstantVariable whileCounter))
            {
                whileCounter = reader.Page.SetVariable(new ConstantVariable("___while_counter", 0d));
            }
            whileCounter.SetValue(whileCounter.Value.AsDouble() + 1);
            if (whileCounter.Value.AsDouble() >= reader.Engine.Options.LoopLimit)
            {
                canContinue = false;
            }

            if (!canContinue)
            {
                reader.Page.RemoveVariable(whileCounter);
            }
            return(canContinue);
        }
Ejemplo n.º 30
0
 private bool VariableIsNotConstant(TriggerReader reader)
 {
     return(!reader.ReadVariable().IsConstant);
 }