예제 #1
0
        public HomePage()
        {
            InitializeComponent();
            InitializeTitleBar();
            InitializeVariables();
            InitialzeEvents();

            ApplyCommandBarBarFrostedGlass();
            ShowUpdateChangelogIfUpdated();

            BackgroundTasks.CheckAllTasks();
            InAppPurchases.CheckAndUpdatePremiumUser();
        }
예제 #2
0
        private void LockTaskSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            var toggle = (ToggleSwitch)sender;

            if (toggle.IsOn)
            {
                BackgroundTasks.RegisterLockscreenTask();
            }
            else
            {
                BackgroundTasks.UnregisterLockscreenTask();
            }
        }
        public void Start(IBackgroundTaskInstance taskInstance)
        {
            var task = BackgroundTasks.FirstOrDefault(b => b.Match(taskInstance?.Task?.Name));

            if (task == null)
            {
                // This condition should not be met. It is it it means the background task to start was not found in the background tasks managed by this service.
                // Please check CreateInstances to see if the background task was properly added to the BackgroundTasks property.
                return;
            }

            task.RunAsync(taskInstance).FireAndForget();
        }
 public ProductsController(IRepository <Product> _ProductRepo, IRepository <FoodWastePreventionSystem.Models.Batch> _ProductInStoreRepo,
                           IRepository <Transaction> _TransactiontRepo, IRepository <Auction> _AuctionRepo,
                           IRepository <ProductToBeAuctioned> _ProductToBeAuctionedRepo, IRepository <Loss> _LossRepo,
                           IRepository <AuctionTransactionStatus> _AuctionTransactionStausRepo,
                           AuctionLogic _AuctionL, ProductsLogic _ProductL, SalesLogic _SalesL, BackgroundTasks _cron)
 {
     Cron              = _cron;
     ProductRepo       = _ProductRepo;
     Auctionrepo       = _AuctionRepo;
     ToBeAuctionedRepo = _ProductToBeAuctionedRepo;
     ProductLogic      = _ProductL;
     AuctionLogic      = _AuctionL;
     SalesLogic        = _SalesL;
 }
 public TestComponentViewModelFactory(
     ComponentInstancesViewModel componentInstancesViewModel,
     OutputFactory outputFactory,
     OperationViewModelFactory operationViewModelFactory,
     BackgroundTasks backgroundTasks,
     OperationMachinesByControlObject operationMachinesByControlObject,
     ApplicationEvents applicationEvents)
 {
     _componentInstancesViewModel = componentInstancesViewModel;
     _outputFactory                    = outputFactory;
     _operationViewModelFactory        = operationViewModelFactory;
     _backgroundTasks                  = backgroundTasks;
     _operationMachinesByControlObject = operationMachinesByControlObject;
     _applicationEvents                = applicationEvents;
 }
예제 #6
0
        private async void DeleteSecondaryTask(IBackgroundTaskRegistration task)
        {
            var taskName = task.Name;

            await Settings.DeleteSecondaryTaskLocation(taskName);

            BackgroundTasks.UnregisterSecondaryTileTask(taskName);

            _ActiveTasks.Remove(task);

            if (_ActiveTasks.Count == 0)
            {
                EmptyViewSecondaryTasks.Visibility = Visibility.Visible;
            }
        }
예제 #7
0
        private void TileIntervalUpdate_Loaded(object sender, RoutedEventArgs e)
        {
            var savedInterval = BackgroundTasks.GetTileTaskInterval();

            for (int i = 0; i < TileIntervalUpdate.Items.Count; i++)
            {
                var item         = (ComboBoxItem)TileIntervalUpdate.Items[i];
                var itemInterval = uint.Parse((string)item.Tag);

                if (itemInterval == savedInterval)
                {
                    TileIntervalUpdate.SelectedIndex = i;
                    break;
                }
            }
        }
 public ComponentInstanceViewModel(
     string instanceName,
     OutputFactory outputFactory,
     OperationEntries operationEntries,
     CoreTestComponent testComponentInstance,
     BackgroundTasks backgroundTasks,
     OperationMachinesByControlObject operationMachinesByControlObject,
     Capabilities.CustomGui customUi)
 {
     _instanceName          = instanceName;
     _outputFactory         = outputFactory;
     _operationEntries      = operationEntries;
     _testComponentInstance = testComponentInstance;
     _customUi        = customUi;
     _backgroundTasks = backgroundTasks;
     _operationMachinesByControlObject = operationMachinesByControlObject;
 }
예제 #9
0
        private void UpdateTileTaskActivityText()
        {
            var activity = BackgroundTasks.GetTileTaskActivity();

            if (activity == null)
            {
                return;
            }

            var message = _ResourcesLoader.GetString("TileLastRun");

            LastUpdatedTask.Text = message + activity["LastRun"];

            if (activity["Exception"] != null)
            {
                var reason = (string)activity["Exception"];
                LastTileTaskError.Text = reason;
            }
        }
예제 #10
0
        private async Task <bool> UnpinLocationOnStart(LocationItem location)
        {
            // 1.Unpin
            var locationId = TileDesigner.ConvertLocationNameToTileId(location.Name);
            var isUnpinned = await TileDesigner.UnpinSecondaryTile(locationId);

            if (!isUnpinned)
            {
                return(false);
            }

            // 2.Delete task config
            await Settings.DeleteSecondaryTaskLocation(locationId);

            // 3.Unregister task
            BackgroundTasks.UnregisterSecondaryTileTask(locationId);

            return(true);
        }
        private static void Configure(
            ComponentLocation componentLocation,
            ApplicationBootstrap bootstrap,
            ApplicationContext applicationContext,
            BackgroundTasks backgroundTasks)
        {
            var operationsOutputViewModel        = new OperationsOutputViewModel();
            var operationPropertiesViewModel     = new OperationPropertiesViewModel();
            var scriptOperationsViewModel        = new ScriptOperationsViewModel(operationPropertiesViewModel);
            var operationsViewModel              = new OperationsViewModel(operationPropertiesViewModel);
            var operationViewsViewModel          = new OperationViewsViewModel(new OperationsViewInitialization[] { operationsViewModel, scriptOperationsViewModel });
            var componentInstancesViewModel      = new ComponentInstancesViewModel(operationsViewModel, operationViewsViewModel);
            var operationMachinesByControlObject = new OperationMachinesByControlObject();
            var outputFactory = new OutputFactory(operationsOutputViewModel);
            var testComponentViewModelFactory =
                new TestComponentViewModelFactory(
                    componentInstancesViewModel,
                    outputFactory,
                    new WpfOperationViewModelFactory(applicationContext, scriptOperationsViewModel, new PropertySetBuilderFactory()),
                    backgroundTasks,
                    operationMachinesByControlObject,
                    bootstrap);
            var componentsViewModel = new ComponentsViewModel(testComponentViewModelFactory);

            var topMenuBarViewModel = new TopMenuBarViewModel(
                componentInstancesViewModel,
                operationsOutputViewModel, new PersistentModelContentBuilderFactory(operationsOutputViewModel, operationMachinesByControlObject));

            var factoryRepositories = componentLocation.LoadComponentRoots();

            AddAllInstanceFactories(factoryRepositories, componentsViewModel);

            bootstrap.SetOperationPropertiesViewDataContext(operationPropertiesViewModel);
            bootstrap.SetTopMenuBarContext(topMenuBarViewModel);
            bootstrap.SetOperationsViewDataContext(operationsViewModel);
            bootstrap.SetScriptOperationsViewDataContext(scriptOperationsViewModel);
            bootstrap.SetOperationsOutputViewDataContext(operationsOutputViewModel);
            bootstrap.SetComponentsViewDataContext(componentsViewModel);
            bootstrap.SetComponentInstancesViewDataContext(componentInstancesViewModel);
            bootstrap.SetOperationsViewsViewDataContext(operationViewsViewModel);
            return;
        }
예제 #12
0
 public string Do()
 {
     if (Parameters.BackgroundTask.Enabled)
     {
         if (QueryStrings.Bool("NoLog"))
         {
             return(BackgroundTasks.Do());
         }
         else
         {
             var log  = new SysLogModel();
             var html = BackgroundTasks.Do();
             log.Finish(html.Length);
             return(html);
         }
     }
     else
     {
         return(null);
     }
 }
        //string cStr = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            BackgroundTasks.StartKPI();

            //SqlDependency.Start(cStr);

            //SqlConnection con = new SqlConnection(cStr);
            //SqlCommand sqlCommand = new SqlCommand();
            //sqlCommand.Connection = con;
            //con.Open(); //await sqlCommand.Connection.OpenAsync();
            //sqlCommand.CommandType = CommandType.Text;
            //sqlCommand.CommandText = "SELECT TOP 1 * FROM KPI ORDER BY measure_time DESC";
            //sqlCommand.Notification = null;

            //SqlDependency sqlDep = new SqlDependency(sqlCommand);
            ////sqlDep.OnChange += ;
            //sqlCommand.ExecuteReader(); //await this.sampleSqlCommand.ExecuteReaderAsync();
        }
예제 #14
0
        public App()
        {
            BackgroundTasks.Add(Settings);

            // Basic unhandled exception catchment
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            // Get command line arguments and initialize ViewModel
            var arguments = Environment.GetCommandLineArgs().Skip(1).ToList();

            try
            {
                ViewModel = new ApplicationViewModel(arguments, Settings);
                if (ViewModel.Url != null)
                {
                    BackgroundTasks.Add(ViewModel.Url);
                }
            }
            catch (Exception exception)
            {
                ShowExceptionReport(exception);
            }
        }
예제 #15
0
        /// <summary>
        /// Add or remove background task when the toggle changes state
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TileTaskSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            var toggle = (ToggleSwitch)sender;

            if (toggle.IsOn)
            {
                ShowTileTaskActivity();
                UpdateTileTaskActivityText();

                if (BackgroundTasks.IsPrimaryTaskActivated())
                {
                    return;
                }

                BackgroundTasks.RegisterPrimaryTileTask(GetTileIntervalUpdate());
                UpdatePrimaryTaskType();
            }
            else
            {
                BackgroundTasks.UnregisterPrimaryTileTask();
                HideTileTaskAcitvity();
            }
        }
        public string Do()
        {
            var context = new Context();

            if (Parameters.BackgroundTask.Enabled)
            {
                if (context.QueryStrings.Bool("NoLog"))
                {
                    return(BackgroundTasks.Do(context));
                }
                else
                {
                    var log  = new SysLogModel(context: context);
                    var html = BackgroundTasks.Do(context: context);
                    log.Finish(context: context, responseSize: html.Length);
                    return(html);
                }
            }
            else
            {
                return(null);
            }
        }
예제 #17
0
        private async Task <bool> PinLocationOnStart(LocationItem location)
        {
            // 1.Ask for pin
            var locationId = TileDesigner.ConvertLocationNameToTileId(location.Name);
            var isPined    = await TileDesigner.PinSecondaryTile(location);

            if (!isPined)
            {
                return(false);
            }

            // 2.Register task config
            await Settings.SaveSecondaryTaskLocation(locationId, location);

            // 3.Register task
            BackgroundTasks.RegisterSecondaryTileTask(locationId);

            // 4.Update the tile
            var forecast = await App.DataSource.GetCurrentForecast(location.Latitude, location.Longitude);

            TileDesigner.UpdateSecondary(locationId, forecast, location);

            return(true);
        }
 //bug move to factory
 private static DefaultOperationStateMachine StateMachineFor(ComponentOperation componentOperation, BackgroundTasks backgroundTasks)
 {
     return(new DefaultOperationStateMachine(
                componentOperation,
                new UnavailableOperationState(),
                new OperationStatesFactory(backgroundTasks)));
 }
 public OperationStatesFactory(BackgroundTasks backgroundTasks)
 {
     _backgroundTasks = backgroundTasks;
 }
예제 #20
0
 public OperationEntries(BackgroundTasks backgroundTasks)
 {
     _backgroundTasks = backgroundTasks;
     _operations      = new List <OperationEntry>();
 }
 public RunnableOperationState(BackgroundTasks backgroundTasks)
 {
     _inBackground = backgroundTasks;
 }
예제 #22
0
 private async void UpdateTileTaskSwitcher()
 {
     TileTaskSwitch.IsOn = BackgroundTasks.IsPrimaryTaskActivated();
 }
        public void TriggerBackTask(string taskName)
        {
            var task = BackgroundTasks.FirstOrDefault(b => b.Match(taskName));

            task?.Trigger();
        }
        public void StopBackTask(string taskName)
        {
            var task = BackgroundTasks.FirstOrDefault(b => b.Match(taskName));

            task?.Kill();
        }
예제 #25
0
 private void RestartTileTask_Tapped(object sender, TappedRoutedEventArgs e)
 {
     BackgroundTasks.UnregisterPrimaryTileTask();
     BackgroundTasks.RegisterPrimaryTileTask(GetTileIntervalUpdate());
 }
예제 #26
0
        private void SecondaryTasksListView_Loaded(object sender, RoutedEventArgs e)
        {
            var listView = (ListView)sender;

            _ActiveTasks         = new ObservableCollection <IBackgroundTaskRegistration>(BackgroundTasks.GetAllTasks());
            listView.ItemsSource = _ActiveTasks;

            if (listView.Items.Count > 0)
            {
                EmptyViewSecondaryTasks.Visibility = Visibility.Collapsed;
            }
        }