public static bool ExtractFileFromZip(TriggerReader reader) { string fileToSnatch = reader.ReadString(); string zipFile = reader.ReadString(); try { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(zipFile)) { foreach (ZipEntry entry in zip.Entries) { if (entry.FileName.Equals(fileToSnatch)) { entry.Extract(); return(true); } } } } catch (Exception ex) { return(false); } return(true); }
private bool PutStringIntoTable(TriggerReader reader) { var var = reader.ReadVariableTable(true); var value = reader.ReadString(); var key = reader.ReadString(); var.Add(key, value); 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 AppendToFile(TriggerReader reader) { string data = reader.ReadString(); string file = reader.ReadString(); using (var streamWriter = new StreamWriter(Path.Combine(DefaultAuthorizedPath, file), true)) { streamWriter.WriteLine(data); } return(true); }
public static bool CreateMessageBox(TriggerReader reader) { string msg = (reader.PeekString()) ? reader.ReadString() : ""; MessageBox.Show(msg); 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 UnloadLibrary(TriggerReader reader) { var libName = reader.ReadString(); var lib = reader.Page.Libraries.FirstOrDefault(l => l.GetType().Name == libName); reader.Page.RemoveLibrary(lib); return(true); }
public virtual bool PrintToLog(TriggerReader reader) { string output = reader.ReadString(); Logger.Info <Sys>(output); //Console.WriteLine(output); return(true); }
private bool SetVariableToString(TriggerReader reader) { var var = reader.ReadVariable(true); var str = reader.ReadString(); var.Value = str; 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 LoadLibraryFromFile(TriggerReader reader) { if (!reader.PeekString()) { return(false); } reader.Page.LoadLibraryFromAssembly(reader.ReadString()); 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); }
public static bool WriteFileToZip(TriggerReader reader) { string fileToZip = reader.ReadString(); string zipFile = reader.ReadString(); try { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(zipFile)) { zip.AddFile(fileToZip); zip.Save(); } } catch (Exception ex) { return(false); } return(true); }
private bool DeleteFile(TriggerReader reader) { if (!reader.PeekString()) { return(false); } string file = reader.ReadString(); File.Delete(Path.Combine(DefaultAuthorizedPath, file)); return(true); }
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); }
public bool TestTriggerHandlerEffectMethod(TriggerReader reader) { if (reader.PeekString()) { Console.WriteLine(reader.ReadString()); } else { Console.WriteLine("Error!!!... no value."); } return(true); }
private bool SetTheTimeZone(TriggerReader reader) { try { timeZone = TimeZoneInfo.FindSystemTimeZoneById(reader.ReadString()); } catch (Exception ex) { Logger.Debug <Timers>(ex); timeZone = TimeZoneInfo.Local; return(false); } 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 static bool ExtractAllFromZip(TriggerReader reader) { string zipFile = reader.ReadString(); try { Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(zipFile); zip.ExtractAll(""); } catch (Exception ex) { return(false); } return(true); }
private bool CanWriteFile(TriggerReader reader) { string file = reader.ReadString(); try { using (var stream = File.Open(Path.Combine(DefaultAuthorizedPath, file), FileMode.Open, FileAccess.Write)) { return(true); } } catch // (UnauthorizedAccessException ex) { return(false); } }
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); }
public static bool SetText(TriggerReader reader) { if (reader.PeekNumber() == false) { return(false); } Control control; bool containsControl = controls.TryGetValue(reader.ReadNumber(), out control); if (containsControl == false) { return(false); } control.Text = (reader.PeekString()) ? reader.ReadString() : ""; return(true); }
public static bool CreateZipFile(TriggerReader reader) { string zipFile = reader.ReadString(); try { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(zipFile)) { zip.Save(); } } catch (Exception ex) { return(false); } return(true); }
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 FileExists(TriggerReader reader) { string file = (reader.PeekString()) ? reader.ReadString() : ""; return(File.Exists(file)); }