public App() { CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fr"); CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("fr"); var logger = new Logger.Logger(); logger.Info(this, new string('-', 100)); logger.Info(this, "Application starting up"); logger.Info(this, $"Language: {ResourceDictionaryLoader.GetLanguage}"); }
/// <summary> /// Initializes device /// </summary> public void Init() { // Send initialize command & check if failed if (Command("ZR") == false) { return; } // Wait for device to finish if (communicator.WaitForDevice() == Communicator.Status.READY) { logger.Info("Initialized"); } }
/// <summary> /// Simplified function, which also gives out a consoletext /// uses the webfunction internal /// </summary> /// <param name="_tradeOfferID"></param> /// <param name="_partnerID"></param> /// <returns></returns> public async Task <bool> AcceptTradeoffer(string _tradeOfferID, SteamID _partnerID) { bool acceptedOffer = await AcceptTradeOffer(_tradeOfferID).ConfigureAwait(false); if (acceptedOffer) { m_logger.Info($"Accepted the offer with the id {_tradeOfferID} from the user {_partnerID.ConvertToUInt64()}"); return(true); } else { return(false); } }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { MethodInfo invokedMethod = loggedObject.GetType().GetMethod(binder.Name); if (invokedMethod != null) { result = invokedMethod.Invoke(loggedObject, args); _logger.Info(binder.Name); return(true); } _logger.Error(binder.Name); result = null; return(false); }
/// <summary> /// requestに従って数え上げる /// </summary> /// <returns>Expression,結果のペアリスト</returns> public Tuple <string, long>[] Run(LibraRequest request) { try { var delegates = request.BuildFilter(); var signals = request.SignalList; if (!signals.Any()) { throw new LibraException("Conditions have no signals"); } var db = new ReadOnlyRepository(request.SqliteFile); log.Info("----Parameter Info----"); Console.WriteLine(db.GetParameter()); log.Info("----------------------"); using var bar = new ProgressBar( (int)(request.IsSplitWithSeed ? (request.SeedEnd - request.SeedStart + 1) : request.Sweeps.Times), "Ptolemy.Libra", new ProgressBarOptions { ForegroundColor = ConsoleColor.DarkYellow, BackgroundCharacter = '-', ProgressCharacter = '>', CollapseWhenFinished = true, BackgroundColor = ConsoleColor.Gray, ForegroundColorDone = ConsoleColor.Green }); db.IntervalEvent += () => bar.Tick(); var result = request.IsSplitWithSeed switch { true => db.Aggregate(token, signals, delegates, Range(request.SeedStart, request.SeedEnd).ToList(), request.Sweeps.Size, request.Sweeps.Start, LibraRequest.GetKey), false => db.Aggregate(token, signals, delegates, request.SeedStart, request.Sweeps.Section().ToList(), LibraRequest.GetKey) }; return(request.ExpressionNameList.Zip(result, Tuple.Create).ToArray()); } catch (LibraException) { throw; } catch (Exception e) { throw new LibraException($"Unknown error has occured\n\t-->{e}"); } }
public MainMenuViewModel(IEnumerable <IMenuCommand> coreCommands, IEnumerable <Lazy <IModuleContract> > modules) { var logger = new Logger.Logger(); logger.Info(this, "Load menus"); Menu = MenuBuilder.CreateMenu(coreCommands, modules); }
private void InitializeLogging() { var logger = new Logger.Logger(); logger.ExposeToApi(HttpApiController); logger.Info("Starting..."); Logger = logger; }
static void Main(string[] args) { Logger.Logger logger = Logger.Loggers.LogFactory.GetLogger(); logger.Error("I'm a small bug"); logger.Info("I can be useful"); logger.Warning("Nobody looks at warnings("); logger.Error(new StackOverflowException()); }
static void Main(string[] args) { _log.Debug("Debug message"); _log.Info("Info message"); _log.Warn("Warn message"); _log.Error("Error message"); _log.Flush(); Console.WriteLine("Done"); }
/// <summary> /// If we didn't link our mobile via the bot, just return a message /// If we did link our mobile via the bot, we have to get the SteamLogin and SteamLoginSecure, which we get from logging in to the web /// Pass the sessionID because we need it aswell, generate a uint64 SteamID from the SessionID, without this we can't fetch the confirmations /// With these values we can get all confirmations and accept or deny them, without it will throw errors /// </summary> public async Task ConfirmAllTrades(string _steamLogin, string _steamLoginSecure, string _sessionID) { if (m_steamGuardAccount == null) { m_logger.Warning("Bot account does not have 2FA enabled."); } else { m_steamGuardAccount.Session = new SessionData { SteamLogin = _steamLogin, SteamLoginSecure = _steamLoginSecure, SessionID = _sessionID, SteamID = new SteamID(Encoding.UTF8.GetString(Convert.FromBase64String(_sessionID))).ConvertToUInt64() }; bool hasToRelog = false; Confirmation[] confirmations = null; try { confirmations = await m_steamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false); } catch (SteamGuardAccount.WGTokenInvalidException exception) { hasToRelog = true; } if (confirmations != null) { foreach (Confirmation confirmation in confirmations) { bool confirmedTrade = m_steamGuardAccount.AcceptConfirmation(confirmation); if (confirmedTrade) { m_logger.Info($"Confirmed {confirmation.Key}, {confirmation.IntType}/{confirmation.Creator}(Confirmation ID #{confirmation.ID})"); } else { m_logger.Warning($"Could not confirm {confirmation.Key}, (Confirmation ID #{confirmation.ID})"); } } } else { if (hasToRelog) { await m_steamGuardAccount.RefreshSessionAsync().ConfigureAwait(false); } } } }
private static void Main(string[] args) { var logger = new Logger.Logger(); try { // parse cli options var request = Parser.Default.ParseArguments <DracoOption>(args) .MapResult( o => o.Build(), e => throw new DracoParseFailedException()); using var cts = new CancellationTokenSource(); var token = cts.Token; Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; cts.Cancel(); }; logger.Warn("Press Ctrl+C to cancel"); // start process Spinner.Start("Ptolemy.Draco ", spin => { using var draco = new Draco(token, request); // print logs to stdout var d = draco.Log.Subscribe(s => logger.Info(s)); try { draco.Run(); spin.Info("Completed"); } catch (Exception) { spin.Fail("Failed"); } finally { d.Dispose(); } }); } catch (DracoException e) { logger.Error($"{e}"); } catch (DracoParseFailedException) { } catch (Exception e) { logger.Fatal($"{e}"); } }
private static void Main(string[] args) { var log = new Logger.Logger(); try { Config.Config.Load(); log.Info($"use config file: {Config.Config.ConfigFile}"); } catch (Exception e) { log.Error($"Failed load config file: {Config.Config.ConfigFile}\n\t-->{e}"); Environment.Exit(1); } Console.Clear(); using var cts = new CancellationTokenSource(); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; cts.Cancel(); }; log.Warn("Press Ctrl+C to cancel"); var token = cts.Token; try { var itf = Parser.Default.ParseArguments <AriesMake, AriesRun, AriesLsDb>(args) .MapResult( (AriesMake a) => a, (AriesRun a) => a, (AriesLsDb a) => (IAriesVerb)a, e => throw new ParseFailedException()); itf.Run(token); } catch (ParseFailedException) { } catch (AriesException e) { log.Error(e); } catch (Exception e) { log.Error($"Unknown error has occured\n\t-->{e}"); } Console.ResetColor(); }
/// <summary> /// If we didn't link our mobile via the bot, just return a message /// If we did link our mobile via the bot, we have to get the SteamLogin and SteamLoginSecure, which we get from logging in to the web /// Pass the sessionID because we need it aswell, generate a uint64 SteamID from the SessionID, without this we can't fetch the confirmations /// With these values we can get all confirmations and accept or deny them, without it will throw errors /// </summary> public void ConfirmAllTrades(string _steamLogin, string _steamLoginSecure, string _sessionID) { if (m_steamGuardAccount == null) { m_logger.Warning("Bot account does not have 2FA enabled."); } else { m_steamGuardAccount.Session = new SessionData { SteamLogin = _steamLogin, SteamLoginSecure = _steamLoginSecure, SessionID = _sessionID, SteamID = new SteamID(Encoding.UTF8.GetString(Convert.FromBase64String(_sessionID))).ConvertToUInt64() }; Confirmation[] confirmations = m_steamGuardAccount.FetchConfirmations(); if (confirmations != null) { foreach (Confirmation confirmation in confirmations) { bool confirmedTrade = m_steamGuardAccount.AcceptConfirmation(confirmation); if (confirmedTrade) { m_logger.Info($"Confirmed {confirmation.Description}, (Confirmation ID #{confirmation.ID})"); } else { m_logger.Warning($"Could not confirm {confirmation.Description}, (Confirmation ID #{confirmation.ID})"); } } } else { m_logger.Error("Mobilehelper: Must Login"); } } }
private static void Main(string[] args) { Console.Clear(); var log = new Logger.Logger(); using var cts = new CancellationTokenSource(); var token = cts.Token; Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; cts.Cancel(); }; log.Warn("Press Ctrl+C to cancel"); try { Tuple <string, long>[] result = null; var sw = new Stopwatch(); sw.Start(); log.Info("Start Ptolemy.Libra"); var request = Parser .Default .ParseArguments <LibraOption>(args) .MapResult(o => o.BuildRequest(), e => throw new ParseFailedException()); log.Info("Built request"); log.Info($"{request.Expressions.Count} expression(s) detected"); log.Info($"Sweep"); if (request.IsSplitWithSeed) { log.Info($"\tSeed: Start: {request.SeedStart}, End: {request.SeedEnd}"); log.Info($"\tSweep per query: {request.Sweeps.Size}"); log.Info($"\tTotal Sweeps: {(request.SeedEnd - request.SeedStart + 1) * request.Sweeps.Size}"); } else { log.Info($"\tSeed: {request.SeedStart}"); log.Info($"\tSweep: Start: {request.Sweeps.Start}, End: {request.Sweeps.Total+request.Sweeps.Start-1}"); } var libra = new Libra(token, log); result = libra.Run(request); sw.Stop(); log.Info($"Elapsed time: {sw.Elapsed}"); log.Info("Result: "); Console.WriteLine(); foreach (var(key, value) in result) { Console.WriteLine($"Expression: {key}, Value: {value}"); } } catch (ParseFailedException) { } catch (LibraException e) { log.Error(e); } catch (Exception e) { log.Error($"Unknown has occured\n\t-->{e}"); } }
/// <summary> /// First get the summary of our tradeoffers, so we know how much tradeoffers we do have to handle /// Initialize a counter, which will be increased after every handled tradeoffer /// Receive all active tradeoffers /// /// Check if the result is not null so we do not run into an error /// Go trough every tradeoffer and check if it is active and we did not reach the amount of offers to handle /// If it is active get the tradepartners ID so we can print a message with his ID in the accept or decline function /// If we have to give Items and do not receive any items decline the trade /// Check if the tradeoffer is a donation /// If it is not a donation go on and check if the tradeoffer is sent by an admin /// If it is sent by an admin accept it and continue with the next trade /// If it is not a donation, not sent by an admin and it seems like a fair trade, check for escrow and finally check the tradeitems itself if it is a fair trade /// </summary> /// <param name="_steamFriendsHelper"></param> /// <param name="_steamID"></param> public async Task CheckForTradeOffers(SteamFriendsHelper _steamFriendsHelper, SteamID _steamID) { TradeOffersSummaryResponse tradeOfferCountToHandle = await m_tradeOfferWebAPI.GetTradeOffersSummary().ConfigureAwait(false); int tradeOfferHandledCounter = 0; GetOffersResponse receivedOffers = await m_tradeOfferWebAPI.GetReceivedActiveTradeOffers(true).ConfigureAwait(false); if (receivedOffers.TradeOffersReceived != null) { foreach (TradeOffer tradeOffer in receivedOffers.TradeOffersReceived) { if (tradeOfferHandledCounter >= tradeOfferCountToHandle.PendingReceivedCount) { break; } if (tradeOffer.TradeOfferState != ETradeOfferState.ETradeOfferStateActive) { continue; } if (tradeOffer.ConfirmationMethod == ETradeOfferConfirmationMethod.ETradeOfferConfirmationMethod_Email) { m_logger.Info($"Accept the trade offer {tradeOffer.TradeOfferID} via your email"); tradeOfferHandledCounter++; continue; } // If we were not logged on to the web or the authentication failed, go to the next tradeoffer and check it again if (!await m_steamWeb.RefreshSessionIfNeeded().ConfigureAwait(false)) { continue; } if (tradeOffer.ConfirmationMethod == ETradeOfferConfirmationMethod.ETradeOfferConfirmationMethod_MobileApp) { m_mobileHelper.ConfirmAllTrades(m_steamWeb.SteamLogin, m_steamWeb.SteamLoginSecure, m_steamWeb.SessionID); tradeOfferHandledCounter++; continue; } SteamID tradePartnerID = _steamFriendsHelper.GetSteamID(tradeOffer.AccountIDOther); // Check for a donation if (m_botInfo.AcceptDonations && await TradeOfferIsDonation(tradeOffer, tradePartnerID).ConfigureAwait(false)) { tradeOfferHandledCounter++; continue; } // Check for a tradeoffer from an admin if (await AdminTradeOffer(_steamFriendsHelper, tradeOffer, tradePartnerID).ConfigureAwait(false)) { m_mobileHelper.ConfirmAllTrades(m_steamWeb.SteamLogin, m_steamWeb.SteamLoginSecure, m_steamWeb.SessionID); tradeOfferHandledCounter++; continue; } // Check if we have to give items but do not receive any items if (tradeOffer.ItemsToGive != null && tradeOffer.ItemsToReceive == null) { await m_tradeOfferWebAPI.DeclineTradeofferShortMessage(tradeOffer.TradeOfferID).ConfigureAwait(false); tradeOfferHandledCounter++; continue; } // If we do not want to accept escrow tradeoffers, check them here before going on if (!m_botInfo.AcceptEscrow) { if (await CheckTradeOfferForEscrow(tradeOffer, tradePartnerID).ConfigureAwait(false)) { tradeOfferHandledCounter++; continue; } } await CheckTradeOffer(receivedOffers, tradeOffer, tradePartnerID).ConfigureAwait(false); tradeOfferHandledCounter++; } } }
public Assembler() { Logger.Info("Initializing Assembly process"); }
private static void Main(string[] args) { var log = new Logger.Logger(); log.Info("Welcome to Ptolemy.Argo"); try { var req = Parser.Default.ParseArguments <ArgoOption>(args) .MapResult(o => { if (!o.Clean) { return(o.BuildRequest()); } // --clean var path = Path.Combine(Path.GetTempPath(), "Ptolemy.Argo"); Spinner.Start("Cleanup...", spin => { if (Directory.Exists(path)) { Directory.Delete(path, true); } spin.Info("Finished"); }); throw new ArgoClean(); }, e => throw new ParseFailedException()); Console.Clear(); log.Info($"TargetNetList Netlist: {req.NetList}"); log.Info("Parameters"); log.Info("\tVtn:"); log.Info($"\t\tThreshold: {req.Transistors.Vtn.Threshold}"); log.Info($"\t\tSigma: {req.Transistors.Vtn.Sigma}"); log.Info($"\t\tNumberOfSigma: {req.Transistors.Vtn.NumberOfSigma}"); log.Info("\tVtp:"); log.Info($"\t\tThreshold: {req.Transistors.Vtp.Threshold}"); log.Info($"\t\tSigma: {req.Transistors.Vtp.Sigma}"); log.Info($"\t\tNumberOfSigma: {req.Transistors.Vtp.NumberOfSigma}"); log.Info($"\tSweeps: {req.SweepStart:E} to {req.Sweep + req.SweepStart - 1:E}"); log.Info($"\tSeed: {req.Seed:E}"); log.Info($"\tTemperature: {req.Temperature}"); log.Info($"\tSimulationTime: {req.Time.Start:E} to {req.Time.Stop:E} (step={req.Time.Step:E})"); log.Info($"ExtractTargets: {string.Join(",", req.Signals)}"); log.Info($"Include {req.Includes.Count} files"); foreach (var inc in req.Includes) { log.Info($"\t--> {inc}"); } log.Warn($"Press Ctrl+C to cancel"); using var cts = new CancellationTokenSource(); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; cts.Cancel(); }; var sw = new Stopwatch(); sw.Start(); var res = Argo.Run(cts.Token, req); sw.Stop(); log.Info("Finished simulation"); log.Info($"Elapsed: {sw.Elapsed}"); log.Info($"{res.Count} result records"); // 結果をSTDOUTに出す if (string.IsNullOrEmpty(req.ResultFile)) { log.Warn("result file not set. print to stdout"); Console.WriteLine("["); foreach (var r in res) { Console.WriteLine($"{r},"); } Console.WriteLine("]"); } // 結果をファイルに書く else { log.Info($"Write to {req.ResultFile}"); using var writer = new StreamWriter(req.ResultFile); writer.WriteLine("["); foreach (var r in res) { writer.WriteLine($"{r},"); writer.Flush(); } writer.WriteLine("]"); writer.Flush(); } } catch (ArgoClean) { log.Info("Ptolemy.Argo clean temp directory /tmp/Ptolemy.Argo"); } catch (ParseFailedException) { log.Warn("Failed parse options"); } catch (ArgoException e) { log.Error(e); Environment.ExitCode = 1; } catch (Exception e) { log.Error($"Unexpected exception was thrown\n-->{e}"); Environment.ExitCode = 1; } }
public override void OnEnabled() { base.OnEnabled(); foreach (KeyValuePair <string, Language> defaultLanguage in Translation.Translation.DefaultLanguages) { this.RegisterTranslation(defaultLanguage.Value, defaultLanguage.Key); } Language t = this.LoadTranslation <Language>(); Exiled.API.Features.Log.Debug(t.ContainDenied); Exiled.API.Features.Log.Debug(t.NotImplementedYet); Exiled.API.Features.Log.Debug(t.IntercomDenied); //Exiled.Events.Events.DisabledPatches.Add(new Tuple<Type, string>(typeof(RespawnManager), nameof(RespawnManager.Spawn))); //Exiled.Events.Events.Instance.ReloadDisabledPatches(); try { Log = new Logger.Logger("GhostSpectator", Loader.ShouldDebugBeShown); Log.Info($"Attempting to set language to {Config.Lang}."); Translation.Translation.LoadTranslations(); CultureInfo ci; try { ci = CultureInfo.GetCultureInfo(Config.Lang); } catch (Exception e) { ci = CultureInfo.GetCultureInfo("en"); Log.Error($"{Config.Lang} is not a valid language. Defaulting to English."); Log.Error($"{e.Message}"); } CultureInfo.DefaultThreadCurrentCulture = ci; CultureInfo.DefaultThreadCurrentUICulture = ci; Log.Info($"Language set to {ci.DisplayName}."); Log.Debug($"Language test {Translation.Translation.GetText().DoorDenied}."); RegisterEvents(); Log.Debug("Patching..."); try { //You must use an incrementer for the harmony instance name, otherwise the new instance will fail to be created if the plugin is reloaded. _patchFixer++; _instance = new Harmony($"ghostspectator.patches{_patchFixer}"); _instance.PatchAll(); } catch (Exception exception) { Log.Error($"Patching failed! {exception}"); } //Timing.RunCoroutine(EventHandlers.SlowUpdate()); Log.Info($"{Name} loaded. c:"); } catch (Exception e) { Log.Error($"There was an error loading the plugin: {e}"); } }
public void RunAsConsole(string[] args) { if (args.Length > 1) { if (args[1].Contains("simulate")) { _simulate = true; _log.Info("Running in simulated mode. No files will be deleted"); } } OnStart(args); Console.WriteLine("Running service as a Console. Press Enter to stop program"); Console.ReadLine(); OnStop(); }