public bool ApplyTweak(Tweak tweak, bool?byUser = null) { if (byUser != null) { tweak.State = byUser == true ? TweakList.Tweak.States.Sellected : TweakList.Tweak.States.SelGroupe; } tweak.Status = true; if (!tweak.IsAvailable()) { return(false); } bool success; if (AdminFunc.IsAdministrator() || tweak.usrLevel) { success = TweakTools.ApplyTweak(tweak); } else { success = App.client.ApplyTweak(tweak); } TweakChanged?.Invoke(this, new TweakEventArgs() { tweak = tweak }); return(success); }
public bool UndoTweak(Tweak tweak) { tweak.State = TweakList.Tweak.States.Unsellected; tweak.Status = false; if (!tweak.IsAvailable()) { return(false); } bool success; if (AdminFunc.IsAdministrator() || tweak.usrLevel) { success = TweakTools.UndoTweak(tweak); } else { success = App.client.UndoTweak(tweak); } TweakChanged?.Invoke(this, new TweakEventArgs() { tweak = tweak }); return(success); }
public bool TestTweak(Tweak tweak, bool fixChanged = false) { if (!tweak.IsAvailable()) { return(false); } bool status; if (AdminFunc.IsAdministrator() || tweak.usrLevel || !App.client.IsConnected()) { status = TweakTools.TestTweak(tweak); } else { status = App.client.TestTweak(tweak); } if (tweak.Status != status) { tweak.Status = status; tweak.LastChangeTime = DateTime.Now; if (tweak.Status == false && tweak.State != Tweak.States.Unsellected) { Dictionary <string, string> Params = new Dictionary <string, string>(); Params.Add("Name", tweak.Name); Params.Add("Group", tweak.Group); Params.Add("Category", tweak.Category); TweakEventArgs.State state = TweakEventArgs.State.eChanged; if (fixChanged == true && tweak.FixFailed == false) { ApplyTweak(tweak); if (TestTweak(tweak, false) != true) { tweak.FixFailed = true; Priv10Logger.LogError(Priv10Logger.EventIDs.TweakError, Params, Priv10Logger.EventFlags.Notifications, Translate.fmt("msg_tweak_stuck", tweak.Name, tweak.Group)); } else { state = TweakEventArgs.State.eRestored; tweak.FixedCount++; Priv10Logger.LogInfo(Priv10Logger.EventIDs.TweakFixed, Params, Priv10Logger.EventFlags.Notifications, Translate.fmt("msg_tweak_fixed", tweak.Name, tweak.Group)); } } else { Priv10Logger.LogWarning(Priv10Logger.EventIDs.TweakChanged, Params, Priv10Logger.EventFlags.AppLogEntries, Translate.fmt("msg_tweak_un_done", tweak.Name, tweak.Group)); } if (state == TweakEventArgs.State.eChanged) { TweakChanged?.Invoke(this, new TweakEventArgs() { tweak = tweak, state = state }); } } } return(status); }