private async Task _watcherService_OnGameActionHandler(WatcherService sender, The100Watcher.EventArgs.GameEventArgs args) { var filterBuilder = Builders <Guild> .Filter; var filter = filterBuilder.AnyEq(x => x.The100Groups, args.Game.GroupId) & filterBuilder.Eq(x => x.PostGameNotifications, true); var results = (await _guildCollection.FindAsync(filter)).ToList(); // Send the notifications to the guilds requesting updates for this groups games for (int i = 0; i < results.Count; i++) { try { var guild = await _discordClient.GetGuildAsync(ulong.Parse(results[i].Id)); if (guild.Channels.TryGetValue(ulong.Parse(results[i].NotificationsChannel), out var channel)) { await channel.SendMessageAsync(args.Message, args.Game.ToEmbed()); } else { await guild.GetDefaultChannel().SendMessageAsync(args.Message, args.Game.ToEmbed()); } } catch (Exception ex) { /* shush */ } } }
private void AddProcessWatchers( ) { foreach (var server in ServersConfig.Servers) { WatcherService.Add(new ProcessWatcher(server.Port, server.Name, server.Path, server.ProcessName)); } }
/// <summary> /// You must pass the smallest timeframe the software will watch for. /// Eg.: If set to TEN_MINUTES, then one mouse movement or keypress in that timeframe /// will be considered an active time. /// DataPrecision is not implemented fully, only High precision works /// </summary> /// <param name="appName">If saving is enabled the resulting file will have this as prefix</param> /// <param name="resolution">The smallest timeframe the software will watch for</param> /// <param name="SavePreference">Dictates how usage data will be saved/stored</param> /// <param name="dataPrecision">Sets how fine grained the data will be</param> public Watcher(string appName, Resolution chosenResolution, SavePreference preference, DataPrecision dataPrecision) { ISaveService saveService = new SaveService(appName, preference, dataPrecision); IUsageKeeper keeper = CreateKeeper(ref saveService, dataPrecision, chosenResolution); IStorage store = new UsageStore(keeper); wService = new WatcherService(ref store, ref saveService); }
public DiscordBotService(AppSettings settings, MongoDbClient dbClient, IServiceProvider sp, ILoggerFactory factory) { _settings = settings; _dbClient = dbClient; _sp = sp; _factory = factory; _watcherService = _sp.GetRequiredService <WatcherService>(); _guildCollection = _dbClient.GetCollection <Guild>(_settings.Mongo.Collections.Guilds); }
/// <summary> /// You must pass the smallest timeframe the software will watch for. /// Eg.: If set to TEN_MINUTES, then one mouse movement or keypress in that timeframe /// will be considered an active time. /// DataPrecision is not implemented fully, only High precision works /// </summary> /// <param name="appName">If saving is enabled the resulting file will have this as prefix</param> /// <param name="resolution">The smallest timeframe the software will watch for</param> /// <param name="savePreference">Dictates how usage data will be saved/stored</param> /// <param name="dataPrecision">Sets how fine grained the data will be</param> public Watcher(string appName, Resolution chosenResolution, SavePreference preference, DataPrecision dataPrecision) { ISaveService saveService = new SaveService(appName, preference, dataPrecision); IUsageToday today = (IUsageToday)CreateOrLoadKeeper(ref saveService, dataPrecision, chosenResolution, SaveType.Today); IUsageArchive archive = (IUsageArchive)CreateOrLoadKeeper(ref saveService, dataPrecision, chosenResolution, SaveType.Archive); IStorage store = new UsageStorage(ref today, ref archive, ref saveService); wService = new WatcherService(ref store); }
public void CloseFile(CodeFileDocumentControl tp, bool ask_for_save = true) { string FileName = tp.FileName.ToLower(); string exeName = tp.EXEFileName; if (WorkbenchServiceFactory.RunService.IsRun(exeName)) { WorkbenchServiceFactory.RunService.Stop(exeName); } if (ask_for_save) { if (tp.DocumentChanged && !tp.FromMetadata) { if (!QuestionAndSaveFile(tp)) { SaveCanceled = true; return; } } } if (tp.DocumentSavedToDisk) { AddLastFile(CurrentSourceFileName); } if (LastSelectedTab != null && !LastSelectedTab.IsDisposed) { CurrentCodeFileDocument = LastSelectedTab; } if (tp == ActiveCodeFileDocument) { ActiveCodeFileDocument = null; } OutputTextBoxs.Remove(tp); OpenDocuments.Remove(Tools.FileNameToLower(tp.FileName)); //RunArgumentsTable.Remove(tp); tp.Dispose(); CheckErrorListAndClear(FileName); WatcherService.RemoveWatcher(FileName); if (OpenDocuments.Count == 1) { CloseButtonsEnabled = false; } SaveAllButtonsEnabled = !AllSaved(); WorkbenchServiceFactory.CodeCompletionParserController.CloseFile(FileName); WorkbenchServiceFactory.CodeCompletionParserController.ParseInformationUpdated -= tp.TextEditor.UpdateFolding; CodeCompletionKeyHandler.Detach(tp.TextEditor); tp.TextEditor.Document.DocumentChanged -= tp.Document_DocumentChanged; tp.TextEditor.Document.TextContent = ""; tp.TextEditor.Document.DocumentChanged += tp.Document_DocumentChanged; GC.Collect(); }
public MainJob( CurrencyService currencyService, IndicatorService indicatorService, LineService lineService, WatcherService watcherService, OrderService orderService, NotificationService notificationService, ILogger <MainJob> logger) { _currencyService = currencyService; _indicatorService = indicatorService; _lineService = lineService; _watcherService = watcherService; _orderService = orderService; _notificationService = notificationService; _logger = logger; }
internal void SaveFileAs(CodeFileDocumentControl TbPage, string FileName) { try { if (TbPage.DesignerAndCodeTabs != null) { TbPage.GenerateDesignerCode(null); } CodeFileDocumentControl dt = TbPage; WatcherService.DisableWatcher(FileName); //dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding; if (!dt.TextEditor.CanSaveWithCurrentEncoding()) { dt.TextEditor.Encoding = Encoding.UTF8; dt.TextEditor.SaveFile(FileName); dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding; } else { dt.TextEditor.SaveFile(FileName); } WatcherService.EnableWatcher(FileName); OpenDocuments.Remove(Tools.FileNameToLower(dt.FileName)); OpenDocuments.Add(Tools.FileNameToLower(FileName), TbPage); WorkbenchServiceFactory.CodeCompletionParserController.RenameFile(dt.FileName, FileName); TbPage.SaveFormFile(FileName); dt.DocumentChanged = false; dt.FileName = FileName; dt.DocumentSavedToDisk = true; dt.SetHighlightingStrategyForFile(FileName); SetTabPageText(TbPage); if (!WorkbenchServiceFactory.RunService.HasRunArgument(FileName.ToLower())) { WorkbenchServiceFactory.RunService.AddRunArgument(FileName.ToLower(), ""); } if (TbPage == CurrentCodeFileDocument) { UpdateSaveButtonsEnabled(); } } catch (Exception ex) { MessageBox.Show(String.Format(Form1StringResources.Get("SAVE_FILE_ERROR_TEXT{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Start() { LogService.Clear(); LogService.Log("starting up the service."); api = new XillioApi("http://tenant.localhost:8080/", true); RunAuthentication(); //Setup other services watcher = new WatcherService(api); try { ping = new PingService(api); } catch (Exception e) { LogService.Log(e); throw; } LogService.Log("service started."); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, WatcherService watcher, IRateCache rateCache, IEmailSender emailService, IExchangeBroker broker) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "GRAFT Payment Terminal Gateway API V1"); }); app.UseMiddleware(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); watcher.Add(rateCache); watcher.Add(emailService); watcher.Add(broker); // comment this line if you want to apply the migrations as a separate process context.Database.Migrate(); }
public SettingsModal(WatcherService appSvc) { this.app = appSvc; InitializeComponent(); // Poplate fields with values set in app enableLiveLogging.Checked = app.LiveLogging; monitoringDir.Text = this.app.MonitorPath; logPath.Text = this.app.LogPath; logFileName.Text = this.app.LogFileName; includeSubdirs.Checked = this.app.MonitorSubDirectories; enableSQLite.Checked = this.app.LogToSqlite; enableFileLog.Checked = this.app.LogToFile; DBPath.Text = this.app.SqliteFileName; DBTableName.Text = this.app.SqliteTableName; foreach (string item in this.app.ExtensionsToWatch) { filterExtensions.Items.Add(item); } updateEnabledFields(); }
public D_WatcherController(WatcherService watcherService) { _watcherService = watcherService; }
public bool OpenFile(string FileName, string PreferedFileName, bool not_open_designer = false) { CodeFileDocumentControl tp = FindTab(FileName); bool IsNewFile = FileName == null; if (tp == null) { if (!IsNewFile && !File.Exists(FileName)) { MessageBox.Show(string.Format(PascalABCCompiler.StringResources.Get("!FILE_NOT_FOUND{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } visualStates.FileOpened = true;//????? if (!IsNewFile) { openFileDialog1.InitialDirectory = Path.GetDirectoryName(FileName); } if (!IsBlankNewProgram(CurrentCodeFileDocument)) { if (IsNewFile) { if (PreferedFileName == null) { FileName = InstNameNewProgramm(MainDockPanel); } else { FileName = PreferedFileName; } } tp = AddNewProgramToTab(MainDockPanel, FileName); } else if (!IsNewFile) { CheckErrorListAndClear(CurrentCodeFileDocument.FileName); WorkbenchServiceFactory.CodeCompletionParserController.CloseFile(CurrentCodeFileDocument.FileName); OpenDocuments.Remove(Tools.FileNameToLower(CurrentCodeFileDocument.FileName)); CurrentCodeFileDocument.FileName = FileName; SetTabPageText(CurrentCodeFileDocument); if (!WorkbenchServiceFactory.RunService.HasRunArgument(FileName.ToLower())) { WorkbenchServiceFactory.RunService.AddRunArgument(FileName.ToLower(), ""); } tp = CurrentCodeFileDocument; } if (!IsNewFile) { AddLastFile(FileName); WatcherService.AddWatcher(FileName); int ticks = Environment.TickCount; tp.LoadFromFile(FileName); //MessageBox.Show((Environment.TickCount-ticks).ToString()); tp.DocumentSavedToDisk = true; //ivan added ShowAddedBreakpoints(tp); //ShowAddedBreakpoints(tabControl1.TabPages[TabIndex]); } //CloseButtonsEnabled = OpenDocuments.Count > 1; ChangedSelectedTab(); if (FileName != null) // SS 09.08.08 { WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(FileName); } } if (tp != null) { if (MainDockPanel.ActiveDocument != tp) { CurrentCodeFileDocument = tp; } } if (FileName != null) { string filename = Tools.FileNameToLower(FileName); if (OpenDocuments.ContainsKey(filename)) { OpenDocuments[filename] = tp; } else { OpenDocuments.Add(filename, tp); } CloseButtonsEnabled = OpenDocuments.Count > 1;//Ivan 09.08.08 err 195 } visualStates.FileOpened = false; //ssyy if (!IsNewFile) { if (Path.GetExtension(FileName) == ".pas") { string XMLFile = Path.ChangeExtension(FileName, string_consts.xml_form_extention); if (File.Exists(XMLFile)) { if (not_open_designer) { if (VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument.DesignerAndCodeTabs != null) { //VisualPascalABC.Form1.Form1_object.CahngedSelectedTab(); VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument.DesignerAndCodeTabs.SelectedTab = VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument.TextPage; } } else { _currentCodeFileDocument.AddDesigner(XMLFile); } } } } return(true); }
public CodeFileDocumentControl OpenFileForDebug(string FileName) { CodeFileDocumentControl tp = FindTab(FileName); bool IsNewFile = FileName == null; if (tp == null) { visualStates.FileOpened = true;//????? if (!IsNewFile && !File.Exists(FileName)) { //MessageBox.Show(string.Format(PascalABCCompiler.StringResources.Get("!FILE_NOT_FOUND{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Warning); bool exists = false; foreach (string s in search_debug_paths) { FileName = String.Concat(s, Path.DirectorySeparatorChar, Path.GetFileName(FileName)); if (File.Exists(FileName)) { tp = FindTab(FileName); if (tp != null) { CurrentCodeFileDocument = tp; //(CurrentTabPage.ag as CodeFileDocumentControl).DocumentSavedToDisk = !IsNewFile; visualStates.FileOpened = false; AddDebugPage(CurrentCodeFileDocument); return(CurrentCodeFileDocument); } else { exists = true; break; } } } if (!exists) { visualStates.FileOpened = false; return(null); } } openFileDialog1.InitialDirectory = Path.GetDirectoryName(FileName); if (!IsBlankNewProgram(CurrentCodeFileDocument)) { if (IsNewFile) { FileName = InstNameNewProgramm(MainDockPanel); } tp = AddNewProgramToTab(MainDockPanel, FileName); } else if (!IsNewFile) { //CheckErrorListAndClear((tabControl1.TabPages[TabIndex].ag as CodeFileDocumentControl).FileName); CurrentCodeFileDocument.FileName = FileName; if (!ProjectFactory.Instance.ProjectLoaded) { SetTabPageText(CurrentCodeFileDocument); } tp = CurrentCodeFileDocument; } if (!IsNewFile) { AddLastFile(FileName); WatcherService.AddWatcher(FileName); tp.LoadFromFile(FileName); tp.DocumentSavedToDisk = true; //ivan added ShowAddedBreakpoints(tp); //ShowAddedBreakpoints(tabControl1.TabPages[TabIndex]); } CloseButtonsEnabled = OpenDocuments.Count > 1; } if (tp != null) { CurrentCodeFileDocument = tp; if (tp.DesignerAndCodeTabs != null) { tp.DesignerAndCodeTabs.SelectedTab = tp.TextPage; } //(CurrentTabPage.ag as CodeFileDocumentControl).DocumentSavedToDisk = !IsNewFile; } visualStates.FileOpened = false; AddDebugPage(CurrentCodeFileDocument); //CahngedSelectedTab(); return(CurrentCodeFileDocument); }
public MainAppWindow() { InitializeComponent(); app = new WatcherService(); app.AddChangedEventHandler(WatcherService_OnFilesystemChange); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, ILoggerFactory loggerFactory, WatcherService watcher, IEmailSender emailSender, IRateCache rateCache, IBitcoinService bitcoinService, IGraftWalletService graftWalletService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "GRAFT Exchange Broker API V1"); }); app.UseMiddleware(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); watcher.Add(rateCache); watcher.Add(emailSender); watcher.Add(bitcoinService); watcher.Add(graftWalletService); // comment this line if you want to apply the migrations as a separate process context.Database.Migrate(); BitcoinService.Init(options => { options.IsTestNetwork = Configuration["BitcoinService:NetworkType"] != "MainNet"; options.TryCount = 2; options.DelayMs = 2000; options.LoggerFactory = loggerFactory; options.DbContext = context; options.BitcoinExtPubKeyString = Configuration["BitcoinService:BitcoinExtPubKeyString"]; }); EthereumService.Init( ConnectionString, loggerFactory, Configuration["EthereumService:NetworkType"] != "MainNet", Configuration["EthereumService:EthereumPoolWalletPassword"], Configuration["EthereumService:EthereumGethNodeUrl"], Configuration["EthereumService:EthereumBrokerWallet"], Convert.ToDecimal(Configuration["EthereumService:EthereumPoolDrainLimit"])); bitcoinService.Ping(); GraftWalletService.Init(context, Configuration["GraftWalletService:RpcUrl"], ConnectionString, loggerFactory); }
private void OnOffline(ServerStatusChangedEventArgs args) { Logger.Warn(args); WatcherService.Restart(args.Port); }
public AdminDashboardController(WatcherService watcher) { this.watcher = watcher; }