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); }
private bool RandomValueToVar(TriggerReader reader) { var var = reader.ReadVariable(true); var.Value = (double)new Random().Next(); return(true); }
private bool GetCurrentHourIntoVar(TriggerReader reader) { var var = reader.ReadVariable(true); var.Value = TimeZoneInfo.ConvertTime(DateTime.Now, timeZone).TimeOfDay.Hours.AsDouble(); return(true); }
private bool VariableGreaterThanOrEqual(TriggerReader reader) { var mainVar = reader.ReadVariable(); double num = reader.ReadNumber(); return(mainVar.Value.AsDouble() >= num); }
private bool GetUTCTimeZone(TriggerReader reader) { var var = reader.ReadVariable(true); var.Value = TimeZoneInfo.Utc.Id; return(true); }
private bool VariableLessThan(TriggerReader reader) { var mainVar = reader.ReadVariable(); double num = reader.ReadNumber(); return(mainVar.Value.AsDouble() < num); }
private bool IsVariableEqualToNumberOrVar(TriggerReader reader) { var var = reader.ReadVariable(); double num = 0; return(reader.ReadNumber() == var.Value.AsDouble()); }
private bool GetCurrentUpTimeIntoVar(TriggerReader reader) { var var = reader.ReadVariable(true); var.Value = System.Math.Round((TimeZoneInfo.ConvertTime(DateTime.Now, timeZone) - startTime).TotalSeconds); return(true); }
private bool DeleteVariable(TriggerReader reader) { var var = reader.ReadVariable(); var.Value = null; return(!var.IsConstant ? reader.Page.RemoveVariable(var.Name) : false); }
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); }
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); }
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); }
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); }
private bool SetVariableToString(TriggerReader reader) { var var = reader.ReadVariable(true); var str = reader.ReadString(); var.Value = str; return(true); }
private bool SubtractFromVariable(TriggerReader reader) { var toAssign = reader.ReadVariable(true); double num = reader.ReadNumber(); toAssign.Value = toAssign.Value.AsDouble() - num; return(true); }
private bool MultiplyByVariable(TriggerReader reader) { var toAssign = reader.ReadVariable(true); double num = reader.ReadNumber(); toAssign.Value = toAssign.Value.AsDouble() * num; return(true); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
private bool VariableIsNotConstant(TriggerReader reader) { return(!reader.ReadVariable().IsConstant); }