public void DisplayTicketExplorerScreen() { SelectedView = 0; SelectedSubView = 2; TicketExplorerViewModel.StartDate = AppServices.MainDataContext.CurrentWorkPeriod.StartDate.Date; if (!AppServices.IsUserPermittedFor(PermissionNames.DisplayOldTickets)) { TicketExplorerViewModel.StartDate = AppServices.MainDataContext.CurrentWorkPeriod.StartDate; } TicketExplorerViewModel.EndDate = DateTime.Now; TicketExplorerViewModel.Refresh(); }
private void StartEngine() { LogViewModel.Write("Bot now running"); AppServices.InformUser("Program running."); var isStarted = GameEngine.Start(); if (!isStarted) { return; } StartPauseHeader = "P_ause"; }
// Internal application variables. //private bool m_IsShuttingDown = false; //private bool m_ServiceConnectionRequested = false; // guarentees we start services only once. #endregion// members #region Constructors // ***************************************************************** // **** Constructors **** // ***************************************************************** public Form1() { InitializeComponent(); // windows form stuff AppServices appServices = AppServices.GetInstance("AutoStackingTracker", true); // Set application information - do this before hubs are instantiated. appServices.Info.RequestShutdownAddHandler(new EventHandler(this.RequestShutdown)); appServices.LoadServicesFromFile("AutoStackingConfig.txt"); // Creates all services. CreateOrderHubControls(); // Create services we will need. appServices.Start(); appServices.Connect(); }//constructor
public override void Run() { // Stop program from running to next waypoint. EliteApi.Navigator.Reset(); if (Config.Instance.HomePointOnDeath) { HomePointOnDeath(); } // Stop the engine from running. AppServices.SendPauseEvent(); }
public override void Run(IGameContext context) { // Stop program from running to next waypoint. context.API.Navigator.Reset(); if (context.Config.HomePointOnDeath) { HomePointOnDeath(context); } // Stop the engine from running. AppServices.SendPauseEvent(); }
public void Setup() { Configuration = new ConfigurationBuilder().Build(); IHostingEnvironment environment = null; ISessionFactory sessionFactory = initSession(); IAppServices appServices = new AppServices(environment, Configuration, sessionFactory); IUnitOfWork unitOfWork = new UnitOfWork(sessionFactory, appServices); Reserve = new Reserve(unitOfWork); }
private void RestoreDefaults() { DetectionDistance = Constants.DetectionDistance; HeightThreshold = Constants.HeightThreshold; MeleeDistance = Constants.MeleeDistance; WanderDistance = Constants.DetectionDistance; GlobalCooldown = Constants.GlobalSpellCooldown; EnableTabTargeting = false; AvoidObjects = false; ShouldApproach = true; ShouldEngage = true; HomePointOnDeath = false; AppServices.InformUser("Defaults have been restored."); }
/// <summary> /// Saves the player's data to file. /// </summary> private void Save() { try { _settingsManager.TrySave(Config.Instance); AppServices.InformUser("Settings have been saved."); LogViewModel.Write("Settings saved"); } catch (InvalidOperationException ex) { AppServices.InformUser("Failed to save settings."); Logger.Log(new LogEntry(LoggingEventType.Error, $"{GetType()}.{nameof(Save)} : Failure on save settings", ex)); } }
protected override void AssertFinalState(AppServices services, ServerState finalServerState, DatabaseState finalDatabaseState) { finalDatabaseState.Workspaces.ContainsNoPlaceholders(); finalDatabaseState.Projects.ContainsNoPlaceholders(); finalDatabaseState.Tasks.ContainsNoPlaceholders(); finalDatabaseState.Tags.ContainsNoPlaceholders(); finalDatabaseState.TimeEntries .Should() .HaveCount(3) .And.Contain(te => te.Description == "A") .And.Contain(te => te.Description == "B") .And.Contain(te => te.Description == "C"); }
/// <summary> /// Saves the player's data to file. /// </summary> private void Save() { try { _settingsManager.TrySave(Config.Instance); AppServices.InformUser("Settings have been saved."); Log.Write("Settings saved"); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); AppServices.InformUser("Failed to save settings."); } }
/// <summary> /// 获取照片信息。 /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Photo(int id) { byte[] data = AppServices.GetService <DataService>().GetPhotoData(id); if (data == null) { return(new JsonResult(new ResultMessage { ResultCode = WebAPIStatus.STATE_NO_DATA, Message = "没有照片数据。" })); } System.IO.MemoryStream ms = new System.IO.MemoryStream(); ms.Write(data, 0, data.Length); ms.Position = 0x0; return(new FileStreamResult(ms, "image/png")); }
private List <Order> m_OrdersWorkspace = new List <Order>(); // work space for orders. #endregion // members #region Constructors // ***************************************************************** // **** Constructors **** // ***************************************************************** // // public SimExecutionListener(string name, IEngineHub engineHub) : base(name, engineHub) { m_AppServices = UV.Lib.Application.AppServices.GetInstance(); // find our AppServices IService service = null; if (m_AppServices.TryGetService("SimMarket", out service)) // find the simulated market { m_Market = (UV.Lib.MarketHubs.MarketHub)service; m_Market.FoundResource += new EventHandler(ListenerEventHandler); // subscribe to found resources. m_Market.MarketStatusChanged += new EventHandler(ListenerEventHandler); m_Market.InstrumentChanged += new EventHandler(ListenerEventHandler); } }
protected override void AssertFinalState(AppServices services, ServerState finalServerState, DatabaseState finalDatabaseState) { containsNoPlaceholdersFor(finalDatabaseState.Workspaces); containsNoPlaceholdersFor(finalDatabaseState.Projects); containsNoPlaceholdersFor(finalDatabaseState.Tasks); containsNoPlaceholdersFor(finalDatabaseState.Tags); finalDatabaseState.TimeEntries .Should() .HaveCount(3) .And.Contain(te => te.Description == "A" && te.ProjectId == finalDatabaseState.Projects.Single().Id) .And.Contain(te => te.Description == "B" && te.TaskId == finalDatabaseState.Tasks.Single().Id) .And.Contain(te => te.Description == "C" && te.TagIds.Single() == finalDatabaseState.Tags.Single().Id); }
public void SubmitPin() { if (PinSubmitted != null && AppServices.CanStartApplication()) { PinSubmitted(this, _pinValue); } else { if (!AppServices.CanStartApplication()) { MessageBox.Show(Localization.Properties.Resources.CheckDBVersion); } } PinValue = EmptyString; }
public Shell() { InitializeComponent(); LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); var selectedIndexChange = DependencyPropertyDescriptor.FromProperty(Selector.SelectedIndexProperty, typeof(TabControl)); selectedIndexChange.AddValueChanged(MainTabControl, MainTabControlSelectedIndexChanged); EventServiceFactory.EventService.GetEvent <GenericEvent <User> >().Subscribe(x => { if (x.Topic == EventTopicNames.UserLoggedIn) { UserLoggedIn(x.Value); } if (x.Topic == EventTopicNames.UserLoggedOut) { UserLoggedOut(x.Value); } }); EventServiceFactory.EventService.GetEvent <GenericEvent <UserControl> >().Subscribe( x => { if (x.Topic == EventTopicNames.DashboardClosed) { AppServices.ResetCache(); } }); UserRegion.Visibility = Visibility.Collapsed; RightUserRegion.Visibility = Visibility.Collapsed; Height = Properties.Settings.Default.ShellHeight; Width = Properties.Settings.Default.ShellWidth; _timer = new DispatcherTimer(); _timer.Tick += TimerTick; TimeLabel.Text = "..."; // DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString(); #if !DEBUG WindowStyle = WindowStyle.None; WindowState = WindowState.Maximized; #endif }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += this.OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { } // Place the frame in the current Window Window.Current.Content = rootFrame; } // load any cached dice frequency data. AppServices appServices = AppServices.Instance; string jsonText = await appServices.FileService.ReadFileAsync(Constants.DieFrequencyDataFilename); await appServices.DiceFrequencyTracker.LoadFromJsonAsync(jsonText); if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Register a global back event handler. This can be registered on a per-page-bases if you only have a subset of your pages // that needs to handle back or if you want to do page-specific logic before deciding to navigate back on those pages. SystemNavigationManager.GetForCurrentView().BackRequested += this.App_BackRequested; // enable the titlebar back button. SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; // Ensure the current window is active Window.Current.Activate(); } }
private void OnSaveDocument(string obj) { var fn = AskFileName("Report", ".xps"); if (!string.IsNullOrEmpty(fn)) { try { SaveAsXps(fn, Document); } catch (Exception e) { AppServices.LogError(e); } } }
/// <summary> /// Start the bot up /// </summary> public bool Start() { var route = Config.Instance.Route; var isPathReachable = !route.IsPathSet || route.IsPathUnreachable(_stateMachine._context); if (isPathReachable) { IsWorking = true; _stateMachine.Start(); _playerMonitor.Start(); return(true); } AppServices.InformUser("The route is not reachable"); return(false); }
/// <summary> /// Loads the route data. /// </summary> private void Load() { var route = _settings.TryLoad <Route>(); var isRouteLoaded = route != null; if (isRouteLoaded) { Config.Instance.Route = route; AppServices.InformUser("Path has been loaded."); } else { AppServices.InformUser("Failed to load the path."); } }
private static async Task Main() { // https://www.c-sharpcorner.com/UploadFile/f9f215/how-to-restrict-the-application-to-just-one-instance/ // Restrict the application to run in just one instance Mutex mutex = new Mutex(true, AppConstants.AppName, out bool createdNew); // If it is not the first instance, means that the App is already running! // We need to alert the user and then exiting the application. if (!createdNew) { MessageBox.Show( "An instance of the App is already running.", AppConstants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error ); // Exit return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // When in production, check if the DB folder exists. If not, create it. CreateDataFolderInProduction(); // Set the options builder for our database context DbContextOptionsBuilder <DatabaseContext> builder = new DbContextOptionsBuilder <DatabaseContext>(); builder.UseSqlite(IsDebug() ? AppConstants.connectionStringDev : AppConstants.connectionString); // Instantiate our database DatabaseContext DatabaseContext = new DatabaseContext(builder.Options); // Instantiate our repository IAppRepository AppRepository = new AppRepository(DatabaseContext); // Instantiate our services AppServices.ConfigureServices(AppRepository); // Set the application language AppTranslations.ConfigureLanguage(await AppServices.AppSettingsService.GetAppLanguageAsync()); Application.Run(new MainForm()); }
void IService.Start() { // Search for necessary services. AppServices app = AppServices.GetInstance(); foreach (IService iservice in app.GetServices()) { if (iservice is MarketHub) { m_MarketHub = (MarketHub)iservice; break; } } base.Start(); // Start this Hub. }
/// <summary> /// Sets up the MoonSharp Lua script engine. /// </summary> private void MoonSharpInit() { this.ScriptHost = AppServices.GetService <ScriptHost>(); this.ScriptHost.RegisterObject <ScriptCommands>(_scriptCommands.GetType(), _scriptCommands, "lua"); this.ScriptHost.RegisterObject <WindowScriptCommands>(_winScriptCommands.GetType(), _winScriptCommands, "win"); // Events for before and after execution of a script. this.ScriptHost.MoonSharp.PreScriptExecute += (sender, e) => { App.MainWindow.ViewModel.LuaScriptsActive = this.ScriptHost.Statistics.ScriptsActive; }; this.ScriptHost.MoonSharp.PostScriptExecute += (sender, e) => { App.MainWindow.ViewModel.LuaScriptsActive = this.ScriptHost.Statistics.ScriptsActive; }; this.ScriptHost.MoonSharp.ExceptionHandler = (exd) => { // InterpreterException's give us more info, like the line number and column the // error occurred on. if (exd.Exception is InterpreterException luaEx) { this.Conveyor.EchoError($"Lua Exception: {luaEx.DecoratedMessage}"); } else { this.Conveyor.EchoError($"Lua Exception: {exd?.Exception?.Message ?? "(null)"}"); } if (exd?.Exception?.InnerException is InterpreterException innerEx) { this.Conveyor.EchoError($"Lua Inner Exception: {innerEx?.DecoratedMessage}"); } if (!string.IsNullOrWhiteSpace(exd.FunctionName)) { this.Conveyor.EchoError($"Lua Function: {exd.FunctionName}"); } if (!string.IsNullOrWhiteSpace(exd.Description)) { this.Conveyor.EchoDebug($"Lua Internal Data: {exd.Description}"); } }; }
public void SubmitPin(int timeCardAction) { if (PinSubmitted != null && AppServices.CanStartApplication()) { PinSubmitted(this, new PinData { PinCode = _pinValue, TimeCardAction = timeCardAction }); } else { if (!AppServices.CanStartApplication()) { MessageBox.Show(Localization.Properties.Resources.CheckDBVersion); } } PinValue = EmptyString; }
public CsvExportercs(string folderPath, string what) { _folder = folderPath; _what = what; if (what == "Apps" || what == "All") { _total += AppServices.Gets().Count; } if (what == "Books" || what == "All") { _total += BookServices.Gets().Count; } if (what == "Games" || what == "All") { _total += GameServices.Gets().Count; } if (what == "Movies" || what == "All") { _total += MovieServices.Gets().Count; } if (what == "Music" || what == "All") { _total += MusicServices.Gets().Count; } if (what == "Nds" || what == "All") { _total += NdsServices.Gets().Count; } if (what == "Series" || what == "All") { _total += SerieServices.Gets().Count; } if (what == "XXX" || what == "All") { _total += XxxServices.Gets().Count; } }
public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(CookiePolicy.Configuration); services.AddDbContext <WebWalletDBContext>(dbContext => { dbContext.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection")); }, ServiceLifetime.Transient ); services .AddIdentity <User, IdentityRole>(IdentityConfiguration.Options) .AddDefaultTokenProviders() .AddEntityFrameworkStores <WebWalletDBContext>(); services .AddAuthentication() .AddCookie(); // Do not move this configuration in AddCookie method it does not work for paths different than // /Account/Login ; /Account/Logout; /Account/AccessDenied services.ConfigureApplicationCookie(CookieAuthentication.Options); AppRepositories.Add(services); AppServices.Add(services); services.Configure <AuthMessageSenderOptions>(Configuration); var mappingConfig = new MapperConfiguration(mc => mc.AddProfile(new MappingProfile()) ); IMapper mapper = mappingConfig.CreateMapper(); services.AddSingleton(mapper); services.AddMemoryCache(); services.AddResponseCaching(); services.AddHttpCacheHeaders(CacheHeader.ExpirationOptions, CacheHeader.ValidationOptions); services .AddMvc(Mvc.Options) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public PdfExporter(string folderPath, string what) { _what = what; _folder = Path.Combine(folderPath, "myCollections_" + _what + ".pdf"); if (what == "Apps" || what == "All") { _total += AppServices.Gets().Count; } if (what == "Books" || what == "All") { _total += BookServices.Gets().Count; } if (what == "Games" || what == "All") { _total += GameServices.Gets().Count; } if (what == "Movies" || what == "All") { _total += MovieServices.Gets().Count; } if (what == "Music" || what == "All") { _total += MusicServices.Gets().Count; } if (what == "Nds" || what == "All") { _total += NdsServices.Gets().Count; } if (what == "Series" || what == "All") { _total += SerieServices.Gets().Count; } if (what == "XXX" || what == "All") { _total += XxxServices.Gets().Count; } }
// // // ***************************************************** // **** SetupInitialize() **** // ***************************************************** protected override void SetupInitialize(IEngineHub engineHub, IEngineContainer engineContainer, int engineID, bool setupGui) { base.SetupInitialize(engineHub, engineContainer, engineID, false); //suppress gui creation. //EngineGui engineGui = base.SetupGuiTemplates(); //engineGui.HeaderControlFullName = string.Empty; // suppress popup gui. //engineGui.LowerHudFullName = typeof(Huds.TradeEngineHud).FullName; m_StrategyHub = (StrategyHub)engineHub; m_Strategy = (Strategy)engineContainer; // Get my associated execution hub. IService iservice; if (AppServices.GetInstance().TryGetService(this.m_ExecutionHubName, out iservice) && iservice is IEngineHub) { m_ExecutionHub = (IEngineHub)iservice; } }// SetupInitialize()
public void PinEntered(PinData pinData) { var u = AppServices.LoginUser(pinData.PinCode); if (u != User.Nobody) { if (pinData.TimeCardAction != 0) { MainDataContext.UpdateTimeCardEntry(u, pinData.TimeCardAction); if (pinData.TimeCardAction == 2) { AppServices.LogoutUser(); return; } } u.PublishEvent(EventTopicNames.UserLoggedIn); } }
/// <summary> /// 获取详细信息。 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public IActionResult GetDetails(int id) { Dictionary <string, object> data = AppServices.GetService <DataService>().GetDetails(id); if (data == null) { return(new JsonResult(new ResultMessage { ResultCode = WebAPIStatus.DATABASE_EXCEPTION, Message = "获取详细信息失败。" })); } ResultMessage ResultMsg = new ResultMessage(); ResultMsg.ResultCode = WebAPIStatus.STATE_OK; ResultMsg.DataFormat = "encode:base64;charset:utf-8;text/json"; ResultMsg.Data = Newtonsoft.Json.JsonConvert.SerializeObject(data); ResultMsg.Data = Convert.ToBase64String(Encoding.UTF8.GetBytes(ResultMsg.Data)); return(new JsonResult(ResultMsg)); }
/// <summary> /// Tells the program to start farming. /// </summary> public void Start() { // Return when the user has not selected a process. if (FFACE == null) { AppServices.InformUser("No process has been selected."); return; } if (GameEngine.IsWorking) { StopEngine(); } else { StartEngine(); } }
public UiCommandFactory(AppServices services) { Services = services; }