private ServiceProvider BuildContainer(AppOption appOption) { var service = new ServiceCollection(); service.AddLogging(x => { x.AddConsole(); x.AddDebug(); }); service.AddSingleton(appOption); service.AddSingleton <ParseCommand>(); service.AddSingleton <ParseActivity>(); service.AddSingleton <FileReader>(); service.AddSingleton <NmeaParser>(); service.AddSingleton <FileWriter>(); service.AddSingleton <AisStore>(); service.AddSingleton <Counters>(); service.AddSingleton <Tracking>(); service.AddSingleton <ParserErrorLog>(); return(service.BuildServiceProvider()); }
public BindMachControl() { InitializeComponent(); this.Option = Current.Option; this.DataContext = this.Option; this.Timer = new System.Threading.Timer(new TimerCallback(this.SetBackground), null, 2000, 1000); }
public App(ILogger <App> logger, IOptions <AppOption> appOption, IConfiguration configuration, IFreeSql fsql, IHttpClientFactory httpClientFactory) { _logger = logger; _appOption = appOption.Value; this.configuration = configuration; this.fsql = fsql; this.httpClientFactory = httpClientFactory; }
public NmeaParser(AppOption appOption, Counters counters, ParserErrorLog parserErrorLog, ILogger <NmeaParser> logger) { _logger = logger.VerifyNotNull(nameof(logger)); _appOption = appOption.VerifyNotNull(nameof(appOption)); _counters = counters.VerifyNotNull(nameof(counters)); _parserErrorLog = parserErrorLog.VerifyNotNull(nameof(parserErrorLog)); _skipMessageTypes = new HashSet <string>(_appOption.IgnoreTypes, StringComparer.OrdinalIgnoreCase); }
/// <summary> /// 初始化並建立Logger /// </summary> public static void Init ( AppOption app, MailNotifyOption mail, MongoOptionV2 mo ) { Log.Logger = DefaultWriteTo(app, mail, mo).CreateLogger(); }
/// <summary> /// The handler should initialize anything it needs from the request and scheme here. /// </summary> /// <param name="scheme">The <see cref="T:Microsoft.AspNetCore.Authentication.AuthenticationScheme" /> scheme.</param> /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Http.HttpContext" /> context.</param> /// <returns></returns> public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) { this.scheme = scheme; this.context = context; this.loginService = this.context.RequestServices.GetService <ILoginService>(); var appConfig = this.context.RequestServices.GetService <IOptions <AppOption> >(); if (appConfig.Value == null) { throw new ApplicationException("need app config"); } this.appOption = appConfig.Value; return(Task.CompletedTask); }
/// <summary> /// 取得預設的初始化設定WriteTo /// </summary> public static LoggerConfiguration DefaultWriteTo ( AppOption app, MailNotifyOption mail, MongoOptionV2 mo ) { string author = app.AuthorName; var writeto = new LoggerConfiguration().MinimumLevel.Verbose(); //ColoredConsole writeto = writeto.WriteTo.LiterateConsole(restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Verbose); //SlowNotify if (mail != null) { writeto = writeto.WriteTo.Email( fromEmail: mail.MailList[0], toEmails: mail.MailList, mailServer: mail.MailServer, // "smtp.mailgun.org", networkCredential: mail.NetworkCredential, //new System.Net.NetworkCredential("*****@*****.**", "test123456"), mailSubject: string.Format(mail.MailSubjectTemplate /*"【{0}】出問題了,請檢查"*/, app.ProjectName), restrictedToMinimumLevel: mail.LogLevel, batchPostingLimit: mail.BatchPostingLimit ); } //MongoDBCapped if (mo != null) { writeto = writeto.WriteTo.MongoDBCapped( databaseUrl: mo.DatabaseUrl, restrictedToMinimumLevel: mo.LogLevel, cappedMaxSizeMb: mo.CollectionMB, cappedMaxDocuments: null, collectionName: mo.CollectionName, batchPostingLimit: mo.BatchPostingLimit, period: mo.BatchTimePostingLimit, formatProvider: null); } writeto = writeto.Enrich.WithProperty("dApp", app.ProjectName).Enrich.WithProperty("dAuthor", app.AuthorName); //因為可能公用,所以自動加上dApp維度 return(writeto); }
public void TestEchoAbc() { AppInfo appInfo = new AppInfo() { Command = IsWindows ? "cmd /c echo ${text}" : "sh -c \"echo ${text}\"" }; AppOption appOption = new AppOption(); AppAction appAction = new AppAction(appInfo, appOption); var inputs = new Dictionary <string, object>() { { "text", "abc" } }; var context = this.CreateActionContext(inputs); AppResult res = appAction.Run(context) as AppResult; Assert.IsNotNull(res); Assert.AreEqual(0, res.ExitCode); Assert.AreEqual("abc", res.Output.Trim()); }
public static LoggerConfiguration DefaultWriteTo ( AppOption app, MailNotifyOption mail, MongoOption mo ) { var mov2 = new MongoOptionV2() { BatchPostingLimit = mo.BatchPostingLimit, BatchTimePostingLimit = mo.BatchTimePostingLimit, CollectionMB = mo.CollectionMB, CollectionName = mo.CollectionName, LogLevel = mo.LogLevel, DatabaseUrl = string.Format("mongodb://{0}:{1}/{2}", mo.MongoDBIp, "27017", app.AuthorName + "_" + app.ProjectName) }; return(DefaultWriteTo(app, mail, mov2)); }
public void TestPingWithCount() { AppInfo appInfo = new AppInfo() { Command = IsWindows ? "ping ${host} -n ${count}" : "ping ${host} -c ${count}" }; AppOption appOption = new AppOption(); AppAction appAction = new AppAction(appInfo, appOption); var inputs = new Dictionary <string, object>() { { "host", "127.0.0.1" }, { "count", 1 } }; var context = this.CreateActionContext(inputs); AppResult res = appAction.Run(context) as AppResult; Assert.IsNotNull(res); Assert.AreEqual(0, res.ExitCode); Assert.IsNotNull(res.Output); }
public AppScoped(IOptions <AppOption> appOption, IOptions <TenantOption> tenantOption) { _appOption = appOption.Value; _tenantOption = tenantOption.Value; }
public async Task <IActionResult> GetOptions([FromBody] GetOptions.Request req) { // TODO 190611 DedicatedServerが本プロトコルを投げてくるので暫定処理 if (SelfHost.hostType != evolib.HostType.Player) { return(Ok(new GetOptions.Response() { appOptions = new List <GetOptions.Response.AppOption>(), mobileSuitOptions = new List <GetOptions.Response.MobileSuitOption>(), })); } var db = PDBSM.PersonalDBContext(SelfHost.playerInfo.playerId); var res = new GetOptions.Response(); res.appOptions = new List <GetOptions.Response.AppOption>(); for (int i = 0; i <= (int)AppOption.Const.MaxCategory; i++) { var reco = await db.AppOptions.FindAsync(SelfHost.playerInfo.playerId, i); if (reco == null) { reco = new AppOption() { playerId = SelfHost.playerInfo.playerId, category = i, //TODO set from master data. }; await db.AppOptions.AddAsync(reco); } res.appOptions.Add(new GetOptions.Response.AppOption() { category = reco.category, values = reco.Values(), }); } res.mobileSuitOptions = new List <GetOptions.Response.MobileSuitOption>(); var allMsIds = MasterData.AllMobileSuitIds; allMsIds.Add(CommonMobileSuitId); foreach (var msId in allMsIds) { var reco = await db.MobileSuitOptions.FindAsync(SelfHost.playerInfo.playerId, msId); if (reco == null) { reco = new MobileSuitOption() { playerId = SelfHost.playerInfo.playerId, mobileSuitId = msId, //TODO set from master data. }; await db.MobileSuitOptions.AddAsync(reco); } res.mobileSuitOptions.Add(new GetOptions.Response.MobileSuitOption() { mobileSuitId = reco.mobileSuitId, values = reco.Values(), }); } await db.SaveChangesAsync(); return(Ok(res)); }
public async Task SaveSettingAsync(AppOption data) { await AppData.SaveAsync(data); }
public JawControl() { InitializeComponent(); this.Option = Current.Option; this.DataContext = this.Option; }