internal async Task InitiateAsync(RemotingAgent agent) { if (agent == null) { throw new ArgumentNullException(nameof(agent)); } Settings.Load(); NotifyIconContainer.ShowIcon("pack://application:,,,/Resources/Icons/TrayIcon.ico", ProductInfo.Title); _current.MainWindow = new MainWindow(this); _current.MainWindow.Deactivated += OnMainWindowDeactivated; if (!StartupService.IsStartedOnSignIn(Settings.LastSaveTime)) { _current.MainWindow.Show(); } agent.ShowRequested += OnMainWindowShowRequested; await ScanAsync(); _settingsWatcher.Subscribe(() => ScanAsync()); _powerWatcher.Subscribe(() => ScanAsync()); _brightnessWatcher.Subscribe((instanceName, brightness) => Update(instanceName, brightness)); }
public ActionResult Empresa(string id) { var context = new ContextService(); context.BaseDatos = id; using (var service = new StartupService(context, id)) { var serviceConfiguracion = new ConfiguracionService(context, service.Db); var estadoImportacion = serviceConfiguracion.GetCargaDatos(); EmpresaModel model; if (estadoImportacion == 2) { ViewBag.database = id; model = Helper.fModel.GetModel <EmpresaModel>(context, service.Db); model.EstadoImportacion = estadoImportacion; } else { model = new EmpresaModel(); model.EstadoImportacion = estadoImportacion; } return(View(model)); } }
private void mainForm_Load(object sender, EventArgs e) { TCPServer = new TCPServer(); TCPServer.NewMessage += TCPServer_NewMessage; TCPServer.MessageSent += TCPServer_MessageSent; Data = new Data(); HostList = new List <string>(); TCPServer.mainForm = this; Data.mainForm = this; if (Settings.Default.keypass != string.Empty) { textBoxLocalKeypass.Text = crypto.StringCipher.Decrypt(Settings.Default.keypass); } textBoxAlias.Text = Settings.Default.alias; checkBoxStartup.Checked = Settings.Default.runstartup; checkBoxHideStartup.Checked = Settings.Default.hidestartup; StartupService = new StartupService("Remsys 3.0"); LoadData(); LoadContextMenus(); timer1.Start(); comboBox1.Items.Clear(); metroComboBox1.Items.Clear(); foreach (TCPServer.NetworkComputer networkComputer in TCPServer.NetworkComputer.GetLocalNetwork()) { comboBox1.Items.Add(networkComputer.Name); metroComboBox1.Items.Add(networkComputer.Name); } TCPServer.NetworkComputer.GetLocalNetwork(); }
private async Task GetAsync(string id, IEnumerable <DatosDefectoItemModel> entidades, CancellationToken cancellationToken, ContextService _context) { var context = _context; context.BaseDatos = id; var serviceConfiguracion = new ConfiguracionService(context); //serviceConfiguracion.SetCargaDatos(1); try { cancellationToken.ThrowIfCancellationRequested(); using (var service = new StartupService(context, id)) { await Task.Run(() => service.CreateDatosDefecto(entidades)); serviceConfiguracion.SetCargaDatos(2); return; } } catch (TaskCanceledException tce) { serviceConfiguracion.SetCargaDatos(-1); } catch (Exception ex) { serviceConfiguracion.SetCargaDatos(-1); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { StartupService.ConfigureServices(services, Configuration); // Add framework services. services.AddMvc(); }
// Use this for initialization void Start() { Screen.SetResolution(640, 1136, false); startup = new StartupService(this); startup.Init(); }
public ActionResult DatosDefecto(string id) { var context = new ContextService(); context.BaseDatos = id; using (var service = new StartupService(context, id)) { return(View(service.GetDatosDefecto())); } }
public MainWindowViewModel() { this.audioService = new AudioService(); this.startupService = new StartupService(); this.Background = Task.Run(this.RefreshState); this.SwitchCommand = new RelayCommand(this.SwitchState); this.SairCommand = new RelayCommand(this.Sair); this.AddAppStartupCommand = new RelayCommand(this.AddAppStartup); this.RemoverAppStartupCommand = new RelayCommand(this.RemoverAppStartup); }
public static bool Check() { try { var service = new StartupService(Key); return(service.Check()); } catch (Exception e) { Logging.LogUsefulException(e); return(false); } }
protected override async Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args) { if (args.PreviousExecutionState != ApplicationExecutionState.Running) { // Here we would load the application's resources. } await FillNavigationQueueAsync(); await LoadAppResources(); //NavigationService.Navigate(PageTokens.SetupPage, null); NavigationService.Navigate(StartupService.GetFromBootSequence(), null); }
public void CreateRequest() { var startupService = new StartupService(); var requestManagerMock = new Mock <IRequestIdManager>(); requestManagerMock.SetupGet(x => x.GetNextId).Returns(1); startupService.GetData(requestManagerMock.Object); var request = startupService.JsonString; string original = "[{\"__class__\":\"ServerRequest\",\"requestData\":[],\"requestClass\":\"StartupService\",\"requestMethod\":\"getData\",\"requestId\":1}]"; Assert.AreEqual(original, request); }
public static bool Check() { try { var path = $@"""{Utils.GetExecutablePath()}"""; var service = new StartupService(Key); return(service.Check(path)); } catch (Exception e) { Logging.LogUsefulException(e); return(false); } }
public ActionResult Empresa(string database, EmpresaModel model) { ViewBag.database = database; if (ModelState.IsValid) { var context = new ContextService(); context.BaseDatos = database; using (var service = new StartupService(context, database)) { try { if (model != null) { var nModel = Helper.fModel.GetModel <EmpresaModel>(context, service.Db); model.Paises = nModel.Paises; model.PlanesGenerales = nModel.PlanesGenerales; var aux = Helper.fModel.GetModel <EmpresaModel>(context, service.Db); model.PlanesGenerales = aux.PlanesGenerales; model.Paises = aux.Paises; model.LstTarifasVentas = aux.LstTarifasVentas; model.LstTarifasCompras = aux.LstTarifasCompras; service.CreateEmpresa(model); using (var loginService = new LoginService()) { HttpCookie securityCookie; FormsAuthentication.SignOut(); loginService.Forzardesconexion(database, ApplicationHelper.UsuariosAdministrador); loginService.SetEmpresaUserAdmin(_dominio, database, model.Id, string.Empty, string.Empty, Guid.NewGuid(), out securityCookie); Response.Cookies.Add(securityCookie); } } return(RedirectToAction("Index", "Home")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } } return(View(model)); }
public async Task GetByIdAsyncWhenNoStartupFoundReturnsStartupNotFoundResponse() { // Arrange var mockStartupRepository = GetDefaultIStartupRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); var startupId = 1; mockStartupRepository.Setup(r => r.FindById(startupId)) .Returns(Task.FromResult <Domain.Models.Startup>(null)); var service = new StartupService(mockStartupRepository.Object, mockUnitOfWork.Object); // Act StartupResponse result = await service.GetByIdAsync(startupId); var message = result.Message; // Assert message.Should().Be("Startup not found"); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { string[] initialScopes = Configuration.GetValue <string>("DownstreamApi:Scopes")?.Split(' ') ?? Array.Empty <string>(); services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) .AddMicrosoftGraph(Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); services.AddControllersWithViews(options => { var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); options.Filters.Add(new AuthorizeFilter(policy)); }); services.AddRazorPages().AddMicrosoftIdentityUI(); StartupService.ConfigureServices(services); }
public SettingViewModel( IScreen hostScreen, ILogger <SettingViewModel> logger, IConfigService configService, Config config, SourceList <RoomStatus> roomList, StartupService startup) { HostScreen = hostScreen; _logger = logger; _configService = configService; Config = config; _roomList = roomList; _startup = startup; SelectMainDirCommand = ReactiveCommand.Create(SelectDirectory); OpenMainDirCommand = ReactiveCommand.CreateFromObservable(OpenDirectory); CheckUpdateCommand = ReactiveCommand.CreateFromTask(CheckUpdateAsync); InitAsync().NoWarning(); }
public ActionResult DatosDefecto(string id, IEnumerable <DatosDefectoItemModel> model) { var context = new ContextService(); context.BaseDatos = id; using (var service = new StartupService(context, id)) { var serviceConfiguracion = new ConfiguracionService(context); serviceConfiguracion.SetCargaDatos(1); if (model != null) { //service.CreateDatosDefecto(model); HostingEnvironment.QueueBackgroundWorkItem(async token => await GetAsync(id, model, token, context)); } return(RedirectToAction("Empresa", new { id })); } }
static Task Main(string[] args) { var host = new HostBuilder() .ConfigureAppConfiguration(configurationBuilder => configurationBuilder.AddCommandLine(args)) .ConfigureFunctionsWorkerDefaults() .ConfigureServices(services => { // Add Logging services.AddLogging(); // Add HttpClient services.AddHttpClient(); // Add Custom Services services.AddSingleton <QueueClient>(new QueueClient(_storageConnectionString, QueueConstants.RemainingRepositoriesQueue)); StartupService.ConfigureServices(services, _token, options => options.UseSqlServer(_connectionString)); }) .Build(); return(host.RunAsync()); }
private async Task FillNavigationQueueAsync() { // do some async tasks to check the startup logic var applicationSettingsService = ServiceLocator.Current.GetInstance <IApplicationSettingsService>(); // step 1: check initial setup if (!applicationSettingsService.IsConfigured()) { StartupService.AddToBootSequence(PageTokens.SetupPage); } // step 2: check user logged in if (string.IsNullOrEmpty(applicationSettingsService.GetUser())) { StartupService.AddToBootSequence(PageTokens.LoginPage); } // step 3: actual main page StartupService.AddToBootSequence(PageTokens.MainPage); }
public static bool Set(bool enabled) { try { var path = $@"""{Utils.GetExecutablePath()}"""; var service = new StartupService(Key); if (enabled) { service.Set(path); } else { service.Delete(); } return(true); } catch (Exception e) { Logging.LogUsefulException(e); return(false); } }
public ActionResult Admin(RootModel model) { if (ModelState.IsValid) { var context = new ContextService(); context.BaseDatos = model.DataBase; using (var service = new StartupService(context, model.DataBase)) { //Create user password service.CreateAdmin(model.Password); using (var lservice = new LoginService()) { HttpCookie cookie; lservice.Login(_dominio, ApplicationHelper.UsuariosAdministrador, model.Password, out cookie, ApplicationHelper.EmpresaMock, string.Empty, string.Empty); Response.Cookies.Add(cookie); } return(RedirectToAction("DatosDefecto", new { id = model.DataBase })); } } return(View(model)); }
public void Run() { Status = FoeTaskStatus.Running; var httpManager = _diContainer.Resolve <IHttpRequestManager>(); var httpManagerInit = _diContainer.Resolve <IRequestManagerInitializer>(); var settings = _diContainer.Resolve <ISettings>(); var hashCreator = _diContainer.Resolve <IHashCreator>(); var uri = settings.Gateway; var requestIdManager = _diContainer.Resolve <IRequestIdManager>(); var startupService = new StartupService(); startupService.GetData(requestIdManager); var request = startupService.JsonString; var signature = hashCreator.GetSignature(request); httpManagerInit.InitializeHeader(signature); httpManager.SendPostRequest(uri, request, null, null, false); Status = FoeTaskStatus.Success; }
public override async void OnShow() { var user = ReadUserSecurityService.ReadUser(); if (user != null) { if (string.IsNullOrEmpty(user.Username)) { await Navigation.PushAsync(new EnterUsernamePage(user)); return; } try { DialogService.ShowLoading("Authenticating..."); StartupService.SetUser(user); // need to validate that the token is still valid var loginValid = await LoginUserService.CheckUserTokenAsync(); if (loginValid) { DialogService.HideLoading(); await Navigation.PushModalAsync(new ScorePredictNavigationPage(new MainPage())); } else { ClearUserSecurityService.ClearUserSecurity(); DialogService.Alert("You session has expired. Please log in again"); } } finally { DialogService.HideLoading(); } } }
protected override void OnStartup(StartupEventArgs e) { var startupService = new StartupService(); var services = startupService.Configure(); var configuration = startupService.ConfigureSettings(); services.AddDbContext <FindMusicContext>((serviceProvider, options) => { var connectionString = configuration.GetConnectionString("Storage"); options.UseSqlite(connectionString); }); var provider = startupService.BuildProvider(services); var findMusic = provider.Resolve <FindMusicViewModel>(); var window = new MainWindow { DataContext = findMusic }; Current.MainWindow = window; window.Show(); base.OnStartup(e); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, StartupService startupService) { loggerFactory.AddSerilog(); if (env.IsDevelopment()) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseDeveloperExceptionPage(); } if (!string.IsNullOrEmpty(SiteConfig.BaseUrlPrefix)) { app.UsePathBase(); } app.UseSession(); app.UseSecretValidator(); app.UseRequestSizeLimit(); if (!string.IsNullOrEmpty(Configuration.GetValue("SlambyApi:Elm:Key", string.Empty))) { app.UseElmSecurity(); app.UseElmStyleUrlFix(); app.UseElmPage(); // Shows the logs at the specified path app.UseElmCapture(); // Adds the ElmLoggerProvider } app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); var logger = loggerFactory.CreateLogger <Startup>(); try { startupService.Startup(); if (env.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUi("swagger/ui", $"/swagger/{ApiVersion}/swagger.json"); } app.UseGzip(); app.UseRequestLogger(); // Set up custom content types - associating file extension to MIME type var provider = new FileExtensionContentTypeProvider(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(SiteConfig.Directory.User), RequestPath = new PathString(Common.Constants.FilesPath), ContentTypeProvider = provider }); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, "assets")), RequestPath = new PathString("/assets"), ContentTypeProvider = provider }); //LimitsMiddleware.AspNetCore int maxConcurrentRequests = int.TryParse( Configuration.GetValue("SlambyApi:RequestsLimiting:MaxConcurrentRequests", string.Empty), out maxConcurrentRequests) ? maxConcurrentRequests : 0; if (maxConcurrentRequests > 0) { app.UseConcurrentRequestsLimit(maxConcurrentRequests); } app.UseApiHeaderVersion(); app.UseApiHeaderAuthentication(); app.UseElapsedTime(); app.UseMvc(); app.UseNotFound(); app.UseTerminal(); } catch (Exception ex) { app.WriteExceptionResponse(logger, ex, "Startup Runtime Error"); } }
public Startup(IConfiguration configuration, StartupService startupService) { Configuration = configuration; this._startupService = startupService; }
private void OnLoginClicked() { _applicationSettingsService.Login(Username); _navigationService.Navigate(StartupService.GetFromBootSequence(), null); _navigationService.RemoveAllPages(); }
public override void Configure(IFunctionsHostBuilder builder) { builder.Services.AddSingleton <CloudQueueClient>(CloudStorageAccount.Parse(_storageConnectionString).CreateCloudQueueClient()); StartupService.ConfigureServices(builder.Services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { StartupService.AddDbContext(services, Configuration.GetConnectionString("AppTemplate")); services.AddControllers(); }
public RegisterInviteRoleLink(StartupService service, CommandService commandService) { this.startupService = service; this.commandService = commandService; }
public static ServiceProvider Initialize(ThreadExecuter threadExecuter, SqlDialect dialect) { Logger.Debug("Creating services"); var factory = new SessionFactory(dialect); // Settings should be upgraded early, it contains the language pack etc and some services depends on settings. var settingsService = StartupService.LoadSettingsService(); var grimDawnDetector = new GrimDawnDetector(settingsService); IPlayerItemDao playerItemDao; IDatabaseItemDao databaseItemDao; IDatabaseSettingDao databaseSettingDao; IDatabaseItemStatDao databaseItemStatDao; IItemTagDao itemTagDao; IBuddyItemDao buddyItemDao; IBuddySubscriptionDao buddySubscriptionDao; IRecipeItemDao recipeItemDao; IItemSkillDao itemSkillDao; IAugmentationItemDao augmentationItemRepo; IItemCollectionDao itemCollectionRepo; if (dialect == SqlDialect.Sqlite) { playerItemDao = new PlayerItemRepo(threadExecuter, factory, dialect); databaseItemDao = new DatabaseItemRepo(threadExecuter, factory, dialect); databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory, dialect); databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory, dialect); itemTagDao = new ItemTagRepo(threadExecuter, factory, dialect); buddyItemDao = new BuddyItemRepo(threadExecuter, factory, dialect); buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory, dialect); recipeItemDao = new RecipeItemRepo(threadExecuter, factory, dialect); itemSkillDao = new ItemSkillRepo(threadExecuter, factory); augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory, dialect), dialect); itemCollectionRepo = new ItemCollectionRepo(threadExecuter, factory, dialect); } else { databaseItemStatDao = new DatabaseItemStatDaoImpl(factory, dialect); playerItemDao = new PlayerItemDaoImpl(factory, databaseItemStatDao, dialect); databaseItemDao = new DatabaseItemDaoImpl(factory, dialect); databaseSettingDao = new DatabaseSettingDaoImpl(factory, dialect); itemTagDao = new ItemTagDaoImpl(factory, dialect); buddyItemDao = new BuddyItemDaoImpl(factory, databaseItemStatDao, dialect); buddySubscriptionDao = new BuddySubscriptionDaoImpl(factory, dialect); recipeItemDao = new RecipeItemDaoImpl(factory, dialect); itemSkillDao = new ItemSkillDaoImpl(factory); augmentationItemRepo = new AugmentationItemDaoImpl(factory, databaseItemStatDao, dialect); itemCollectionRepo = new ItemCollectionDaoImpl(factory, dialect); } // Chicken and the egg.. var itemStatService = new ItemStatService(databaseItemStatDao, itemSkillDao, settingsService); SearchController searchController = new SearchController( databaseItemDao, playerItemDao, itemStatService, buddyItemDao, augmentationItemRepo, settingsService, itemCollectionRepo ); List <object> services = new List <object>(); services.Add(itemTagDao); services.Add(databaseItemDao); services.Add(databaseItemStatDao); services.Add(playerItemDao); services.Add(databaseSettingDao); services.Add(buddyItemDao); services.Add(buddySubscriptionDao); services.Add(itemSkillDao); services.Add(augmentationItemRepo); //services.Add(userFeedbackService); services.Add(settingsService); services.Add(grimDawnDetector); services.Add(recipeItemDao); services.Add(itemCollectionRepo); services.Add(searchController); services.Add(itemStatService); var cacher = new TransferStashServiceCache(databaseItemDao); services.Add(cacher); Logger.Debug("All services created"); return(new ServiceProvider(services)); }