public ScriptManageModel(ScriptLog log) : this() { Id = log.ScriptId; Name = log.Name; Content = log.Content; }
public bool ChangeGroup(object Player, object Group) { TShockAPI.TSPlayer p = null; TShockAPI.DB.User u = new TShockAPI.DB.User(); string g = ""; if ((p = GetPlayer(Player)) == null) { return(false); } if (Group is string) { g = Group as string; } else if (Group is TShockAPI.Group) { g = (Group as TShockAPI.Group).Name; } if (string.IsNullOrEmpty(g) == true) { return(false); } try { u.Name = p.User.Name; TShockAPI.TShock.Users.SetUserGroup(u, g); } catch (Exception ex) { ScriptLog.ErrorFormat("tshock_change_group", "Group change failed: {0}", ex.Message); return(false); } return(true); }
public ScriptLogItem(ScriptLog model) : this() { Id = model.Id; Name = model.Name; SessionId = model.SessionId; ChangeLog = model.ChangeLog; Created = model.Created; }
internal static PsDeploymentScriptLog ToPsDeploymentScriptLog(ScriptLog scriptLog) { return(new PsDeploymentScriptLog { Log = scriptLog.Log, Id = scriptLog.Id, Type = scriptLog.Type, Name = scriptLog.Name }); }
protected void oneSecondTimer_Elapsed(object sender, ElapsedEventArgs e) { for (int i = 0; i < recurList.Count; i++) { RecurringFunction func; lock (syncRoot) { func = recurList.ElementAtOrDefault(i); } if (func == null) { continue; } try { func.ExecuteAndRecur(); } catch (Exception ex) { ScriptLog.ErrorFormat("recurring", "Error on recurring rule: " + ex.Message); } } for (int i = 0; i < runAtList.Count; i++) { RunAt at; lock (syncRoot) { at = runAtList.ElementAtOrDefault(i); } if (at == null || engine == null || Terraria.Main.time <= at.AtTime || at.ExecutedInIteration == true) { continue; } try { engine.CallFunction(at.Func, at); } catch (Exception ex) { ScriptLog.ErrorFormat("recurring", "Error on recurring rule: " + ex.Message); } finally { at.ExecutedInIteration = true; } } }
/// <summary> /// Log the command in the recording. /// </summary> /// <param name="command">The text to log.</param> internal void LogCommand(string command) { // don't log if it is disabled if (_loggingDisabled == 0) { ScriptLog.AppendLine(command); ScriptLog.AppendLine("GO"); } if (CanExecute) { ExecutionLog.AppendLine(command); ExecutionLog.AppendLine("GO"); } }
/// <summary> /// Executes the function in this recurring rule if it's /// time to, and updates the next run time to the next /// recurance. /// </summary> public void ExecuteAndRecur() { if (DateTime.UtcNow < this.NextRunTime || Jist.JistPlugin.Instance == null) { return; } try { JistPlugin.Instance.CallFunction(Function, this); } catch (Exception ex) { ScriptLog.ErrorFormat("recurring", "Error occured on a recurring task function: " + ex.Message); } finally { Recur(); } }
static void Main(string[] args) { Console.WriteLine("Hello"); IScriptRepository repository = new ScriptRepository(); ScriptLog log = new ScriptLog(); log.AppName = "Test"; log.Author = "test"; repository.AddScriptLog(log); var logs = repository.Browse(); foreach (ScriptLog tmpLog in logs) { Console.WriteLine($"ID: {tmpLog.Id}\tApp Name: {tmpLog.AppName}\t{(tmpLog.Author != null ? $"Author: {tmpLog.Author}" : "")}"); } Console.ReadKey(); }
public bool ExecuteCommandSilent(object Player, object Command) { TShockAPI.TSPlayer p = null; string commandToExecute = ""; if ((p = GetPlayer(Player)) == null) { return(false); } try { if (Command is List <string> ) { List <string> cmdList = Command as List <string>; foreach (var param in cmdList.Skip(1)) { commandToExecute += " " + param; } } else if (Command is string) { commandToExecute = Command.ToString(); } if (string.IsNullOrEmpty((commandToExecute = commandToExecute.Trim())) == true) { return(false); } p.PermissionlessInvoke(commandToExecute, true); return(true); } catch (Exception) { ScriptLog.ErrorFormat("tshock_exec_silent", "The command \"{0}\" failed.", commandToExecute.Trim()); return(false); } }
private static void OpenScriptLog(object o) { ScriptLog s = o as ScriptLog; if (s == null) { return; } string u; AssetCollection ac = AssetCollection.GetCollection(".lua"); if (ac.GetFile(s.file, out u)) { ConsolerCommand.ReleaseLock(); OpenFileAtExternal(u, s.lineCode); } ac = AssetCollection.GetCollection(".lua", "Test/LuaDll"); if (ac.GetFile(s.file, out u)) { ConsolerCommand.ReleaseLock(); OpenFileAtExternal(u, s.lineCode); } }
internal Log CloseLog(Type type) { switch (type) { case Type.HEADER: HeaderLog = CurrentLog; break; case Type.SETUP: SetupLog = CurrentLog; break; case Type.TEARDOWN: TeardownLog = CurrentLog; break; case Type.SCRIPT: ScriptLog.Add(CurrentLog); break; } return(CloseLog()); }
/// <summary> /// Update data and create change log /// </summary> /// <param name="scriptLog"></param> /// <param name="scriptLogModel"></param> /// <returns></returns> private string ChangeLog(ScriptLog scriptLog, ScriptLogManageModel scriptLogModel) { var changeLog = new StringBuilder(); const string format = "- Update field: {0}\n"; if (!ConvertUtilities.Compare(scriptLog.Name, scriptLogModel.Name)) { changeLog.AppendFormat(format, "Name"); scriptLog.Name = scriptLogModel.Name; } if (!ConvertUtilities.Compare(scriptLog.Content, scriptLogModel.Content)) { changeLog.AppendFormat(format, "Content"); scriptLog.Content = scriptLogModel.Content; } if (!string.IsNullOrEmpty(changeLog.ToString())) { changeLog.Insert(0, "** Update Script **\n"); } return(changeLog.ToString()); }
public void AddScriptLog(ScriptLog log) { _context.ScriptLogs.Add(log); _context.SaveChanges(); }
internal ResponseModel Delete(ScriptLog scriptLog) { return(_scriptLogRepository.Delete(scriptLog)); }
internal ResponseModel Update(ScriptLog scriptLog) { return(_scriptLogRepository.Update(scriptLog)); }
internal ResponseModel Insert(ScriptLog scriptLog) { return(_scriptLogRepository.Insert(scriptLog)); }