Beispiel #1
0
        public StartupManager(IWorkbook workbook, IPlatformService platformService, IMessageBoxService messageBoxService, INotificationService notificationService, ITrackingManager trackingManager)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (platformService == null)
            {
                throw new ArgumentNullException(nameof(platformService));
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.workbook            = workbook;
            this.platformService     = platformService;
            this.settings            = workbook.Settings;
            this.messageBoxService   = messageBoxService;
            this.notificationService = notificationService;
            this.trackingManager     = trackingManager;

            this.startTime = DateTime.UtcNow;
        }
        private bool TryHandleGarbageCollection(IExecutionContext executionContext, ITrackingManager trackingManager)
        {
            int staleBuildDirThreshold = executionContext.Variables.GetInt("maintenance.deleteworkingdirectory.daysthreshold") ?? 0;

            if (staleBuildDirThreshold > 0)
            {
                // scan unused build directories
                executionContext.Output(StringUtil.Loc("DiscoverBuildDir", staleBuildDirThreshold));
                trackingManager.MarkExpiredForGarbageCollection(executionContext, TimeSpan.FromDays(staleBuildDirThreshold));
            }
            else
            {
                executionContext.Output(StringUtil.Loc("GCBuildDirNotEnabled"));
                return(false);
            }

            executionContext.Output(StringUtil.Loc("GCBuildDir"));

            // delete unused build directories
            trackingManager.DisposeCollectedGarbage(executionContext);

            // give source provider a chance to run maintenance operation
            Trace.Info("Scan all SourceFolder tracking files.");
            string searchRoot = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), Constants.Build.Path.SourceRootMappingDirectory);

            if (!Directory.Exists(searchRoot))
            {
                executionContext.Output(StringUtil.Loc("GCDirNotExist", searchRoot));
                return(false);
            }

            return(true);
        }
 public TrackingInstance(ILogger <TrackingInstance> logger, ISentimentAnalysis sentiment, IArticlesPersistency persistency, ITrackingManager trackingManager)
 {
     this.sentiment       = sentiment ?? throw new ArgumentNullException(nameof(sentiment));
     this.persistency     = persistency ?? throw new ArgumentNullException(nameof(persistency));
     this.trackingManager = trackingManager;
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
 }
        public TrackingInstance(ILogger <TrackingInstance> logger, ITrackingConfigFactory trackingConfigFactory, ISentimentAnalysis sentiment, ITrackingManager manager, ITwitPersistency persistency)
        {
            if (trackingConfigFactory == null)
            {
                throw new ArgumentNullException(nameof(trackingConfigFactory));
            }

            this.sentiment   = sentiment ?? throw new ArgumentNullException(nameof(sentiment));
            this.manager     = manager ?? throw new ArgumentNullException(nameof(manager));
            this.persistency = persistency ?? throw new ArgumentNullException(nameof(persistency));
            this.logger      = logger ?? throw new ArgumentNullException(nameof(logger));
            Trackers         = trackingConfigFactory.GetTrackers();
            foreach (var tracker in Trackers.Where(item => !item.IsKeyword))
            {
                if (users.Contains(tracker.Keyword))
                {
                    logger.LogWarning("Keyword is already added {0}", tracker.Keyword);
                    continue;
                }

                users.Add(tracker.Keyword);
            }

            Languages = trackingConfigFactory.GetLanguages();
        }
Beispiel #5
0
        public BackgroundSynchronizationManager(IWorkbook workbook, ITrackingManager trackingManager, Action <string> toastMessage)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.workbook        = workbook;
            this.trackingManager = trackingManager;
            this.toastMessage    = toastMessage;

            this.toastBackgroundSync     = workbook.Settings.GetValue <bool>(CoreSettings.BackgroundToast);
            this.isBackgroundSyncEnabled = workbook.Settings.GetValue <bool>(CoreSettings.BackgroundSync);

            if (this.isBackgroundSyncEnabled)
            {
                // check the last time the app was run
                var lastRun = workbook.Settings.GetValue <DateTime>(CoreSettings.LastRunDateTime);
                if ((DateTime.UtcNow - lastRun).TotalDays > 14)
                {
                    this.isBackgroundSyncEnabled = false;
                    this.TrackEvent("Sync", "Skipping background sync, app wasn't ran in the last 14 days");
                }
            }
        }
        private async void OnBtnMail(object sender, RoutedEventArgs e)
        {
            ITrackingManager   trackingManager   = Ioc.Resolve <ITrackingManager>();
            IMessageBoxService messageBoxService = Ioc.Resolve <IMessageBoxService>();

            try
            {
                var email = new EmailMessage
                {
                    Subject = "2Day Logs",
                    Body    = "Logs are available as attachments"
                };

                await MailHelper.AddAttachment(email, "2day.db", "2day.db");

                await MailHelper.AddAttachment(email, LogService.Filename, "logs.txt");

                await EmailManager.ShowComposeNewEmailAsync(email);
            }
            catch (Exception ex)
            {
                string message = "Error while sending logs by email: " + ex;
                trackingManager.Exception(ex, message);
                messageBoxService.ShowAsync(StringResources.General_LabelError, message);
            }
        }
Beispiel #7
0
        public DragDropManager(MainPage mainPage, GridView gridviewTasks, ListView listviewNavigation, IWorkbook workbook, INavigationService navigationService, ITrackingManager trackingManager)
        {
            if (mainPage == null)
            {
                throw new ArgumentNullException(nameof(mainPage));
            }
            if (gridviewTasks == null)
            {
                throw new ArgumentNullException(nameof(gridviewTasks));
            }
            if (listviewNavigation == null)
            {
                throw new ArgumentNullException(nameof(listviewNavigation));
            }
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.mainPage = mainPage;

            this.gridviewTasks                    = gridviewTasks;
            this.gridviewTasks.ItemClick         += this.OnGridViewItemClick;
            this.gridviewTasks.Tapped            += this.OnGridViewTapped;
            this.gridviewTasks.RightTapped       += this.OnGridViewRightTapped;
            this.gridviewTasks.DragItemsStarting += this.OnGridViewDragItemsStarting;
            this.gridviewTasks.Loaded            += this.OnGridViewLoaded;
            this.gridviewTasks.SelectionChanged  += this.OnGridViewSelectionChanged;

            this.listviewNavigation            = listviewNavigation;
            this.listviewNavigation.DragOver  += this.OnListviewNavigationDragOver;
            this.listviewNavigation.Drop      += this.OnListviewNavigationDrop;
            this.listviewNavigation.DragLeave += this.OnListviewNavigationDragLeave;

            this.workbook          = workbook;
            this.navigationService = navigationService;
            this.trackingManager   = trackingManager;
            this.draggedItems      = new List <ITask>();

            this.highlightBrush         = this.mainPage.FindResource <SolidColorBrush>("ApplicationAccentBrush");
            this.ignoreSelectionChanges = -1;

            if (this.workbook.Settings.GetValue <bool>(CoreSettings.UseDarkTheme))
            {
                this.BackgroundIndicatorOpacity = 0.6;
            }
            else
            {
                this.BackgroundIndicatorOpacity = 0.4;
            }
        }
Beispiel #8
0
 public static void Exception(Exception exception, string message = null, bool isFatal = false)
 {
     if (Ioc.HasType <ITrackingManager>())
     {
         ITrackingManager trackingManager = Ioc.Resolve <ITrackingManager>();
         trackingManager.Exception(exception, message, isFatal);
     }
 }
Beispiel #9
0
 public static void Trace(string message)
 {
     if (Ioc.HasType <ITrackingManager>())
     {
         ITrackingManager trackingManager = Ioc.Resolve <ITrackingManager>();
         trackingManager.Trace(message);
     }
 }
        protected MiscSettingsPageViewModelBase(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, INotificationService notificationService, IPlatformService platformService, ITrackingManager trackingManager, IPersistenceLayer persistenceLayer) : base(workbook, navigationService)
        {
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }
            if (platformService == null)
            {
                throw new ArgumentNullException(nameof(platformService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }
            if (persistenceLayer == null)
            {
                throw new ArgumentNullException(nameof(persistenceLayer));
            }

            this.messageBoxService   = messageBoxService;
            this.notificationService = notificationService;
            this.platformService     = platformService;
            this.trackingManager     = trackingManager;
            this.persistenceLayer    = persistenceLayer;

            this.languages = new List <string> {
                " "
            };
            this.languages.AddRange(SupportedCultures.Languages);

            this.clearSearchHistoryCommand   = new RelayCommand(this.ClearSearchHistoryExecute);
            this.openWelcomeScreenCommand    = new RelayCommand(this.OpenWelcomeScreenExecute);
            this.deleteAllCommand            = new RelayCommand(this.DeleteAllExecute);
            this.deleteTasksCommand          = new RelayCommand(this.DeleteTasksExecute);
            this.deleteCompletedTasksCommand = new RelayCommand(this.DeleteCompletedTasksExecute);
            this.completeTasksCommand        = new RelayCommand(this.CompleteTasksExecute);
            this.createBackupCommand         = new RelayCommand(this.CreateBackupExecute);
            this.restoreBackupCommand        = new RelayCommand(this.RestoreBackupExecute);
            this.sortFoldersCommand          = new RelayCommand(() => this.SortElements(SortType.Folders));
            this.sortSmartViewsCommands      = new RelayCommand(() => this.SortElements(SortType.SmartViews));
            this.sortContextsCommand         = new RelayCommand(() => this.SortElements(SortType.Contexts));
            this.sortTagsCommand             = new RelayCommand(() => this.SortElements(SortType.Tags));

            string language = this.Workbook.Settings.GetValue <string>(CoreSettings.OverrideLanguage);

            if (!string.IsNullOrEmpty(language))
            {
                this.selectedLanguage = SupportedCultures.GetLanguageNameFromCode(language);
                this.previousLanguage = this.selectedLanguage;
            }

            this.sendAnalytics = this.Workbook.Settings.GetValue <bool>(CoreSettings.SendAnalytics);
        }
Beispiel #11
0
        public TileManager(IWorkbook workbook, ITrackingManager trackingManager, INotificationService notificationService, bool isBackground)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.workbook            = workbook;
            this.trackingManager     = trackingManager;
            this.notificationService = notificationService;
            this.isBackground        = isBackground;
            this.secondaryTiles      = new List <SecondaryTile>();

            if (!this.isBackground)
            {
                this.updateTileTimer = new DispatcherTimer {
                    Interval = TimeSpan.FromMilliseconds(UpdateBufferMs)
                };

                this.updateTileTimer.Tick += (s, e) =>
                {
                    this.updateTileTimer.Stop();
                    this.UpdateTiles();
                };

                this.workbook.TaskAdded += (s, e) =>
                {
                    this.updateTileTimer.Stop();
                    this.updateTileTimer.Start();
                };
                this.workbook.TaskRemoved += (s, e) =>
                {
                    this.updateTileTimer.Stop();
                    this.updateTileTimer.Start();
                };
                this.workbook.TaskChanged += (s, e) =>
                {
                    this.updateTileTimer.Stop();
                    this.updateTileTimer.Start();
                };
                this.workbook.FolderChanged += (s, e) =>
                {
                    this.updateTileTimer.Stop();
                    this.updateTileTimer.Start();
                };
            }
        }
Beispiel #12
0
 public BeaconController(IRepository <BeaconEntity> repository, ILog logger, ICorePipeline pipeline, ITrackerProvider trackerProvider, ISitecoreContext sitecoreContext, ISettings settings, IRequestHelper request, HttpContextBase httpContext, IWebClient client, ITrackingManager trackingManager) : base(repository)
 {
     Assert.ArgumentNotNull(logger, "logger");
     Assert.ArgumentNotNull(pipeline, "pipeline");
     Assert.ArgumentNotNull(settings, "settings");
     Assert.ArgumentNotNull(trackerProvider, "TrackerProvider");
     Assert.ArgumentNotNull(client, "client");
     Assert.ArgumentNotNull(trackingManager, "trackingManager");
     this.logger           = logger;
     this.pipeline         = pipeline;
     this.trackerProvider  = trackerProvider;
     this.sitecoreSettings = settings;
     this.requestHelper    = request;
     this.sitecoreContext  = sitecoreContext;
     this.trackingManager  = trackingManager;
     this.httpContextBase  = httpContext;
     this.webClient        = client;
 }
Beispiel #13
0
        public BackupHelper(IPersistenceLayer persistenceLayer, IMessageBoxService messageBoxService, ITrackingManager trackingManager)
        {
            if (persistenceLayer == null)
            {
                throw new ArgumentNullException(nameof(persistenceLayer));
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.persistenceLayer  = persistenceLayer;
            this.messageBoxService = messageBoxService;
            this.trackingManager   = trackingManager;
        }
        public SynchronizationManager(IPlatformService platformService, ITrackingManager trackingManager, string platform, bool isBackground)
        {
            if (platformService == null)
            {
                throw new ArgumentNullException(nameof(platformService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.platformService = platformService;
            this.platform        = platform;
            this.isBackground    = isBackground;

            this.providerFactory = new Dictionary <SynchronizationService, Func <ISynchronizationProvider> >();
            this.providerCache   = new Dictionary <SynchronizationService, ISynchronizationProvider>();
            this.trackingManager = trackingManager;
        }
        public KeyboardShortcutManager(IWorkbook workbook, Frame rootFrame, INavigationService navigationService, ITrackingManager trackingManager)
        {
            this.trackingManager = trackingManager;
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (rootFrame == null)
            {
                throw new ArgumentNullException(nameof(rootFrame));
            }
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.shortcuts = new List <KeyboardShortcutBase>
            {
                new NavigateBackwardShortcut(rootFrame, navigationService),
                new SaveChangesShortcut(rootFrame, navigationService),
                new CreateTaskShortcut(rootFrame, navigationService, workbook),
                new SelectAllTasksShortcut(rootFrame, navigationService),
                new SaveAndContinueShortcut(rootFrame, navigationService),
                new EscapeMainPageShortcut(rootFrame, navigationService),
                new MenuNavigateShorcut(rootFrame, navigationService),
                new EscapeMainPageShortcut(rootFrame, navigationService),
                new DeleteSelectionShorcut(rootFrame, navigationService),
                new StartSpeechRecognitionShortcut(rootFrame, navigationService),
                new StartSyncShortcut(rootFrame, navigationService),
                new SearchShortcut(rootFrame, navigationService),
                new ToggleNavMenuShortcut(rootFrame, navigationService),
                new CopyPasteShortcut(rootFrame, navigationService, workbook),
                new PrintShortcut(rootFrame, navigationService),
                new DebugShorcut(rootFrame, navigationService),
                new AddSubTaskShortcut(rootFrame, navigationService)
            };

            rootFrame.KeyUp += this.OnRootFrameKeyUp;
        }
        protected AdvancedSyncronizationManagerBase(IWorkbook workbook, ISynchronizationManager synchronizationManager, ITrackingManager trackingManager)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (synchronizationManager == null)
            {
                throw new ArgumentNullException(nameof(synchronizationManager));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.workbook = workbook;
            this.synchronizationManager = synchronizationManager;
            this.trackingManager        = trackingManager;
        }
        protected SmartViewViewModelBase(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, ITrackingManager trackingManager)
            : base(workbook, navigationService)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException(nameof(workbook));
            }
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.workbook          = workbook;
            this.navigationService = navigationService;
            this.messageBoxService = messageBoxService;
            this.trackingManager   = trackingManager;

            this.blocks = new ObservableCollection <SmartViewBlockViewModel>();

            this.addBlockCommand = new RelayCommand(this.AddBlockExecute);

            var smartview = new SmartView(this.workbook, new Core.Shared.Model.Impl.SmartView()
            {
                Rules = "(Title Contains azerty)"
            });

            this.liveCountFolderViewModel = new FolderItemViewModel(this.workbook, smartview);

            this.tracker          = new SmartViewViewModelTracker(this);
            this.tracker.Changed += this.OnContentChanged;
        }
Beispiel #18
0
        public DatabaseContext(string path, bool automaticSave, ISQLitePlatform sqLitePlatform, ITrackingManager trackingManager)
        {
            if (sqLitePlatform == null)
            {
                throw new ArgumentNullException(nameof(sqLitePlatform));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            this.dbFileName      = Path.GetFileName(path);
            this.fullPathFile    = path;
            this.sqLitePlatform  = sqLitePlatform;
            this.connection      = this.CreateSQLiteConnection(this.fullPathFile);
            this.trackingManager = trackingManager;

            this.objectTracker = new ObjectTracker(this.connection, automaticSave);
        }
        protected SyncSettingsViewModelBase(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, ISynchronizationManager synchronizationManager, ITrackingManager trackingManager) : base(workbook, navigationService)
        {
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (synchronizationManager == null)
            {
                throw new ArgumentNullException(nameof(synchronizationManager));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }

            this.messageBoxService      = messageBoxService;
            this.synchronizationManager = synchronizationManager;
            this.trackingManager        = trackingManager;
            this.checkSettingsCommand   = new RelayCommand(this.CheckSettingsExecute);

            this.trackingManager.TagEvent("Sync settings open", new Dictionary <string, string> {
                { "service", this.SynchronizationService.ToString() }
            });
        }
Beispiel #20
0
        public EditTaskViewModel(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, INotificationService notificationService, ITileManager tileManager, ISynchronizationManager synchronizationManager, ISpeechService speechService, ITrackingManager trackingManager, IPlatformService platformService)
            : base(workbook, navigationService, messageBoxService, notificationService, synchronizationManager, speechService, trackingManager, platformService)
        {
            if (tileManager == null)
            {
                throw new ArgumentNullException(nameof(tileManager));
            }

            this.tileManager = tileManager;
        }
 public VercorsSettingsViewModel(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, ISynchronizationManager synchronizationManager, ITrackingManager trackingManager)
     : base(workbook, navigationService, messageBoxService, synchronizationManager, trackingManager)
 {
 }
Beispiel #22
0
 public LocationService()
 {
     _manager = IOCContainerFactory.Instance.CurrentContainer.Resolve<ITrackingManager>();
     LoadTracksByDevice1();
     LoadTracksByDevice2();
 }
Beispiel #23
0
        protected MainPageViewModelBase(IWorkbook workbook, ISynchronizationManager synchronizationManager, IStartupManager startupManager, IMessageBoxService messageBoxService, INotificationService notificationService, INavigationService navigationService, IPlatformService platformService, ITileManager tileManager, ITrackingManager trackingManager, ISpeechService speechService)
            : base(workbook, navigationService)
        {
            if (startupManager == null)
            {
                throw new ArgumentNullException(nameof(startupManager));
            }
            if (synchronizationManager == null)
            {
                throw new ArgumentNullException(nameof(synchronizationManager));
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (platformService == null)
            {
                throw new ArgumentNullException(nameof(platformService));
            }
            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }
            if (tileManager == null)
            {
                throw new ArgumentNullException(nameof(tileManager));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }
            if (speechService == null)
            {
                throw new ArgumentNullException(nameof(speechService));
            }

            this.synchronizationManager = synchronizationManager;
            this.messageBoxService      = messageBoxService;
            this.notificationService    = notificationService;
            this.platformService        = platformService;
            this.tileManager            = tileManager;
            this.trackingManager        = trackingManager;
            this.speechService          = speechService;

            this.synchronizationManager.OperationStarted         += this.OnSyncStarted;
            this.synchronizationManager.OperationProgressChanged += this.OnSyncProgressChanged;
            this.synchronizationManager.OperationCompleted       += this.OnSyncOperationCompleted;
            this.synchronizationManager.OperationFailed          += this.OnSyncOperationFailed;
            this.synchronizationManager.PropertyChanged          += (s, e) =>
            {
                if (e.PropertyName == "ActiveService")
                {
                    this.RaisePropertyChanged("SyncPrioritySupport");
                }
            };

            this.Workbook.Settings.KeyChanged += this.OnSettingsChanged;
            this.Workbook.TaskAdded           += this.OnTaskAddded;

            this.Workbook.FoldersReordered  += this.OnFolderReordered;
            this.Workbook.ContextsReordered += this.OnContextReordered;

            this.addViewCommand      = new RelayCommand(this.AddViewExecute);
            this.addSmartViewCommand = new RelayCommand(this.AddSmartViewExecute);
            this.addFolderCommand    = new RelayCommand(this.AddFolderExecute);
            this.addContextCommand   = new RelayCommand(this.AddContextExecute);
            this.addTaskCommand      = new RelayCommand(this.AddTaskExecute);
            this.syncCommand         = new RelayCommand(this.SyncExecute);
            this.openSettingsCommand = new RelayCommand(this.OpenSettingsExecute);
            this.openDebugCommand    = new RelayCommand(this.OpenDebugExecute);
            this.clearSearchCommand  = new RelayCommand(this.ClearSearchExecute);
            this.speechCommand       = new RelayCommand(this.SpeechExecute);
            this.quickSpeechCommand  = new RelayCommand(this.QuickSpeechExecute);
            this.printCommand        = new RelayCommand(this.PrintExecute);
            this.shareCommand        = new RelayCommand(this.ShareExecute);
            this.editCommand         = new RelayCommand(this.EditExecute);

            this.deleteSelectionCommand      = new RelayCommand(this.DeleteSelectionExecute);
            this.completeSelectionCommand    = new RelayCommand(this.CompleteSelectionExecute);
            this.toggleTaskCompletionCommand = new RelayCommand <ITask>(this.ToggleTaskCompletionExecute);
            this.setPrioritySelectionCommand = new RelayCommand <string>(this.SetPrioritySelectionExecute);

            this.menuItems = new SortableObservableCollection <MenuItemViewModel>();

            bool hasViews      = this.Workbook.Views.Any(v => v.IsEnabled);
            bool hasSmartViews = this.Workbook.SmartViews.Any();
            bool hasFolders    = this.Workbook.Folders.Any();
            bool hasContexts   = this.Workbook.Contexts.Any();

            // create search view
            this.viewSearch       = new ViewSearch(this.Workbook);
            this.searchFolderItem = new FolderItemViewModel(this.Workbook, this.viewSearch);

            // load views
            foreach (var view in this.Workbook.Views.Where(f => f.IsEnabled))
            {
                this.menuItems.Add(new FolderItemViewModel(workbook, view));
            }

            // load smart views
            if (this.Workbook.SmartViews.Any())
            {
                if (hasViews)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorSmartViewId));
                }

                foreach (var smartview in this.Workbook.SmartViews)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, smartview));
                }
            }

            // load folders
            if (this.Workbook.Folders.Count > 0)
            {
                if (hasViews || hasSmartViews)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorFolderId));
                }

                foreach (var folder in this.Workbook.Folders)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, folder));
                }
            }

            // load contexts
            if (this.Workbook.Contexts.Count > 0)
            {
                if (hasViews || hasSmartViews || hasFolders)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorContextId));
                }

                foreach (var context in this.Workbook.Contexts)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, context));
                }
            }

            // load tags
            if (this.Workbook.Tags.Any())
            {
                if (hasViews || hasSmartViews || hasFolders || hasContexts)
                {
                    this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorTagId));
                }

                foreach (var tag in this.Workbook.Tags)
                {
                    this.menuItems.Add(new FolderItemViewModel(workbook, tag));
                }
            }
        }
Beispiel #24
0
        public MainPage()
        {
            this.InitializeComponent();

            this.workbook          = Ioc.Resolve <IWorkbook>();
            this.navigationService = Ioc.Resolve <INavigationService>();
            this.messageBoxService = Ioc.Resolve <IMessageBoxService>();
            this.trackingManager   = Ioc.Resolve <ITrackingManager>();
            this.tileManager       = Ioc.Resolve <ITileManager>();
            this.platformService   = Ioc.Resolve <IPlatformService>();

            // setup cache mode so that this page is cached accross navigation
            this.NavigationCacheMode = NavigationCacheMode.Required;

            this.viewModel = Ioc.Build <MainPageViewModel>();
            this.viewModel.PropertyChanged += this.OnViewModelPropertyChanged;
            Ioc.RegisterInstance <IMainPageViewModel, MainPageViewModel>(this.viewModel);

            this.navigationMenuManager    = Ioc.Build <NavigationMenuManager>();
            this.taskListSelectionManager = new GridViewSelectionManager(this.workbook, this.viewModel, this.GridViewTasks);
            this.dragDropManager          = new DragDropManager(this, this.GridViewTasks, this.ListViewNavigation, this.workbook, this.navigationService, this.trackingManager);

            this.lastSplitViewOpen = !this.workbook.Settings.GetValue <bool>(CoreSettings.NavigationMenuMinimized);

            this.Loaded      += this.OnLoaded;
            this.SizeChanged += this.OnSizeChanged;

            this.DataContext = this.viewModel;

            this.HeaderBarAutoSuggestBox.QuerySubmitted += (s, e) =>
            {
                this.HeaderBarAutoSuggestBox.Focus(FocusState.Programmatic);
            };
            this.HeaderBarAutoSuggestBox.GotFocus += (s, e) =>
            {
                this.PanelHeaderContent.Visibility = Visibility.Collapsed;
                this.HeaderBarAutoSuggestBoxBorderMask.Visibility = Visibility.Collapsed;
            };
            this.HeaderBarAutoSuggestBox.LostFocus += (s, e) =>
            {
                if (string.IsNullOrWhiteSpace(this.ViewModel.SearchText))
                {
                    this.PanelHeaderContent.Visibility = Visibility.Visible;
                    this.HeaderBarAutoSuggestBoxBorderMask.Visibility = Visibility.Visible;
                }
            };

            // when user types text in the search box, update the view model
            var synchronizationContext = SynchronizationContext.Current;

            Observable
            .FromEventPattern <AutoSuggestBoxTextChangedEventArgs>(this.NavBarAutoSuggestBox, "TextChanged")
            .Throttle(TimeSpan.FromMilliseconds(250))
            .ObserveOn(synchronizationContext)
            .Subscribe(e => this.viewModel.SearchText = this.NavBarAutoSuggestBox.Text);
            Observable
            .FromEventPattern <AutoSuggestBoxTextChangedEventArgs>(this.HeaderBarAutoSuggestBox, "TextChanged")
            .Throttle(TimeSpan.FromMilliseconds(250))
            .ObserveOn(synchronizationContext)
            .Subscribe(e => this.viewModel.SearchText = this.HeaderBarAutoSuggestBox.Text);

            DataTransferManager.GetForCurrentView().DataRequested += this.OnDataRequested;

            this.SplitView.RegisterPropertyChangedCallback(SwipeableSplitView.IsSwipeablePaneOpenProperty, this.OnSplitViewIsOpenChanged);

            this.ContextualActionBar.Visibility = Visibility.Collapsed;
            this.ContextualActionBar.Initialize(this.SelectionManager);

            this.ListViewTasks.Tapped += (s, e) =>
            {
                this.navigationService.CloseFlyouts();
            };
        }
Beispiel #25
0
        protected TaskViewModelBase(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, INotificationService notificationService, ISynchronizationManager synchronizationManager, ISpeechService speechService, ITrackingManager trackingManager, IPlatformService platformService)
            : base(workbook, navigationService)
        {
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }
            if (synchronizationManager == null)
            {
                throw new ArgumentNullException(nameof(synchronizationManager));
            }
            if (speechService == null)
            {
                throw new ArgumentNullException(nameof(speechService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }
            if (platformService == null)
            {
                throw new ArgumentNullException(nameof(platformService));
            }

            this.messageBoxService      = messageBoxService;
            this.notificationService    = notificationService;
            this.synchronizationManager = synchronizationManager;
            this.speechService          = speechService;
            this.trackingManager        = trackingManager;
            this.platformService        = platformService;

            this.syncPrioritySupport = this.synchronizationManager.SyncPrioritySupport;

            this.priority = this.Workbook.Settings.GetValue <TaskPriority>(CoreSettings.DefaultPriority);
            if (this.syncPrioritySupport == SyncPrioritySupport.LowMediumHigh && (this.priority == TaskPriority.None || this.priority == TaskPriority.Star))
            {
                this.priority = TaskPriority.Low;
            }

            var context = ModelHelper.GetDefaultContext(this.Workbook);

            if (context != null)
            {
                this.TargetContext = context;
            }

            this.dueDate = null;
            this.title   = string.Empty;
            this.note    = string.Empty;
            this.tags    = new ObservableCollection <string>();

            this.subtasks = new ObservableCollection <ITask>();

            this.targetFolder = workbook.Folders.FirstOrDefault();

            this.frequencies = new ObservableCollection <Frequency>
            {
                new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.Once)),
                new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.Daily)),
                new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.Weekly)),
                new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.Monthly)),
                new Frequency(FrequencyFactory.GetCustomFrequency(FrequencyType.Yearly))
            };
            this.defaultFrequenciesCount = this.frequencies.Count;

            // by default, select "once"
            this.selectedFrequency = this.frequencies.First();

            this.addFolderCommand        = new RelayCommand(this.AddFolderExecute);
            this.addContextCommand       = new RelayCommand(this.AddContextExecute);
            this.clearDueDateCommand     = new RelayCommand(this.ClearDueDateExecute);
            this.clearStartDateCommand   = new RelayCommand(this.ClearStartDateExecute);
            this.clearReminderCommand    = new RelayCommand(this.ClearReminderExecute);
            this.clearProgressCommand    = new RelayCommand(() => this.Progress = null);
            this.clearContextCommand     = new RelayCommand(() => this.TargetContext = null);
            this.clearFrequencyCommand   = new RelayCommand(() => this.SelectedFrequency = null);
            this.addTagCommand           = new RelayCommand <string>(this.AddTagExecute);
            this.deleteTagCommand        = new RelayCommand <string>(this.DeleteTagExecute);
            this.openLinkCommand         = new RelayCommand(this.OpenLinkExecute);
            this.startSpeechTitleCommand = new RelayCommand(this.SpeechTitleExecute);
            this.startSpeechNoteCommand  = new RelayCommand(this.SpeechNoteExecute);
            this.quickAddCommand         = new RelayCommand(this.SaveContinueExecute);
            this.editPreviousCommand     = new RelayCommand(this.EditPreviousExecute);
            this.editNextCommand         = new RelayCommand(this.EditNextExecute);
            this.callPhoneNumberCommand  = new RelayCommand(this.CallPhoneNumberExecute);
            this.addSubtaskCommand       = new RelayCommand(this.AddSubtaskExecute);
            this.deleteSubtaskCommand    = new RelayCommand <ITask>(this.DeleteSubtaskExecute);
            this.openNotesCommand        = new RelayCommand(this.OpenNotesExecute);

            this.possibleTags  = new ObservableCollection <string>();
            this.availableTags = new ObservableCollection <ItemCountViewModel>();
        }
        private async Task RunSourceProviderMaintenance(IExecutionContext executionContext, ITrackingManager trackingManager, TrackingConfig trackingConfig)
        {
            var             extensionManager = HostContext.GetService <IExtensionManager>();
            ISourceProvider sourceProvider   = extensionManager.GetExtensions <ISourceProvider>().FirstOrDefault(x => string.Equals(x.RepositoryType, trackingConfig.RepositoryType, StringComparison.OrdinalIgnoreCase));

            if (sourceProvider != null)
            {
                try
                {
                    trackingManager.MaintenanceStarted(trackingConfig);
                    string repositoryPath = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), trackingConfig.SourcesDirectory);
                    await sourceProvider.RunMaintenanceOperations(executionContext, repositoryPath);

                    trackingManager.MaintenanceCompleted(trackingConfig);
                }
                catch (Exception ex)
                {
                    executionContext.Error(StringUtil.Loc("ErrorDuringBuildGC", trackingConfig.FileLocation));
                    executionContext.Error(ex);
                }
            }
        }
        private static List <TrackingConfig> GetTrackingConfigsForMaintenance(IExecutionContext executionContext, ITrackingManager trackingManager)
        {
            var trackingConfigs = new List <TrackingConfig>();

            foreach (var config in trackingManager.EnumerateAllTrackingConfigs(executionContext))
            {
                executionContext.Output(StringUtil.Loc("EvaluateTrackingFile", config.FileLocation));
                if (string.IsNullOrEmpty(config.RepositoryType))
                {
                    // repository not been set.
                    executionContext.Output(StringUtil.Loc("SkipTrackingFileWithoutRepoType", config.FileLocation));
                }
                else
                {
                    trackingConfigs.Add(config);
                }
            }

            return(trackingConfigs);
        }
Beispiel #28
0
 public static void InjectTrackingManager(ITrackingManager manager)
 {
     _trackingManager = manager;
 }
        public async void SafeRun(IBackgroundTaskInstance taskInstance)
        {
            bool hadException = false;

            // Register to receive an event if Cortana dismisses the background task. This will
            // occur if the task takes too long to respond, or if Cortana's UI is dismissed.
            // Any pending operations should be cancelled or waited on to clean up where possible.
            taskInstance.Canceled += this.OnTaskCanceled;

            WinSettings.Instance.SetValue(CoreSettings.BackgroundLastStartExecution, DateTime.Now);
            ReportStatus(BackgroundExecutionStatus.Started);

            LogService.Initialize(new WinLogHandler());
            LogService.Level = WinSettings.Instance.GetValue <LogLevel>(CoreSettings.LogLevel);

            ResourcesLocator.Initialize("ms-appx://", UriKind.Absolute);

            var mutex = new Mutex(false, Constants.SyncPrimitiveAppRunningForeground);

            if (!mutex.WaitOne(1))
            {
                LogService.Log("Agent", "Skipping background agent because app is foreground");
                await LogService.SaveAsync();

                this.deferral.Complete();

                ReportStatus(BackgroundExecutionStatus.Skipped);

                return;
            }

            ITrackingManager trackingManager = null;

            try
            {
                this.persistenceLayer = new WinPersistenceLayer(automaticSave: false);

                var deviceFamily = DeviceFamily.Unkown;

                if (AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Desktop", StringComparison.OrdinalIgnoreCase))
                {
                    deviceFamily = DeviceFamily.WindowsDesktop;
                }
                else if (AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Mobile", StringComparison.OrdinalIgnoreCase))
                {
                    deviceFamily = DeviceFamily.WindowsMobile;
                }

                trackingManager = new TrackingManager(false, deviceFamily);

                var workbook = this.persistenceLayer.Open(tryUpgrade: true) as Workbook;

                if (workbook != null)
                {
                    ReportStatus(BackgroundExecutionStatus.WorkbookLoaded);

                    Ioc.RegisterInstance <IWorkbook, Workbook>(workbook);
                    workbook.Initialize();

                    // important: load alarm manager so that we update reminders properly is a recurring task is created
                    var alarmManager = new AlarmManager(workbook);

                    var backgroundSyncManager = new BackgroundSynchronizationManager(workbook, trackingManager, ToastHelper.ToastMessage);
                    await backgroundSyncManager.SetupAsync();

                    if (backgroundSyncManager.CanSync())
                    {
                        ReportStatus(BackgroundExecutionStatus.SyncStarted);

                        this.synchronizationManager = backgroundSyncManager.SynchronizationManager;

                        if (workbook.Settings.GetValue <bool>(CoreSettings.BackgroundToast))
                        {
                            this.synchronizationManager.OperationCompleted += (s, e) => ToastHelper.ToastMessage(e.Item);
                            this.synchronizationManager.OperationFailed    += (s, e) => ToastHelper.ToastMessage(e.Message);
                        }

                        bool result = await backgroundSyncManager.TrySyncAsync(this.persistenceLayer);

                        if (result)
                        {
                            ReportStatus(BackgroundExecutionStatus.SyncCompleted);
                        }
                        else
                        {
                            ReportStatus(BackgroundExecutionStatus.SyncError);
                        }
                    }

                    // update tiles
                    ReportStatus(BackgroundExecutionStatus.TileStarted);

                    TileManager timeManager = new TileManager(workbook, trackingManager, null, true);
                    await timeManager.LoadSecondaryTilesAsync();

                    timeManager.UpdateTiles();

                    ReportStatus(BackgroundExecutionStatus.TileCompleted);

                    // save log
                    await LogService.SaveAsync();
                }
                else
                {
                    ReportStatus(BackgroundExecutionStatus.WorkbookNotLoaded);
                }
            }
            catch (Exception ex)
            {
                hadException = true;

                LogService.Level |= LogLevel.Debug;
                LogService.Log("WinBackgroundTaskHelper", "Exception during background execution: " + ex.GetAllMessages());

                if (trackingManager != null)
                {
                    trackingManager.Exception(ex, "Exception Background task helper");
                }

                ReportStatus(BackgroundExecutionStatus.CompletedException);
            }

            if (!hadException)
            {
                ReportStatus(BackgroundExecutionStatus.CompletedSuccess);
            }

            await LogService.SaveAsync();

            WinSettings.Instance.SetValue(CoreSettings.BackgroundLastEndExecution, DateTime.Now);

            this.deferral.Complete();
        }
Beispiel #30
0
        private static async Task <SynchronizationManager> InitializeSyncAsync(IWorkbook workbook, IPlatformService platformService, ITrackingManager trackingManager)
        {
            var cryptoService = Ioc.RegisterInstance <ICryptoService, WinCryptoService>(new WinCryptoService());

            var synchronizationManager = new SynchronizationManager(platformService, trackingManager, "win", false);

            await SynchronizationManagerBootstraper.InitializeAsync(workbook, synchronizationManager, cryptoService, new VercorsService(), false);

            Ioc.RegisterInstance <ISynchronizationManager, SynchronizationManager>(synchronizationManager);

            return(synchronizationManager);
        }
Beispiel #31
0
        public static void Run(ITrackingManager trackingManager, SQLiteConnection connection)
        {
            foreach (var table in new List <string> {
                "folder", "tasks"
            })
            {
                try
                {
                    var databaseEntries = connection.Query <DatabaseEntry>("SELECT * FROM " + table);
                    foreach (var databaseEntry in databaseEntries)
                    {
                        string update = string.Empty;

                        if (!string.IsNullOrWhiteSpace(databaseEntry.Added))
                        {
                            update += string.Format(" Added = '{0}',", NormalizeDatetime(databaseEntry.Added));
                        }

                        if (!string.IsNullOrWhiteSpace(databaseEntry.Alarm))
                        {
                            update += string.Format(" Alarm = '{0}',", NormalizeDatetime(databaseEntry.Alarm));
                        }

                        if (!string.IsNullOrWhiteSpace(databaseEntry.Modified))
                        {
                            update += string.Format(" Modified = '{0}',", NormalizeDatetime(databaseEntry.Modified));
                        }

                        if (!string.IsNullOrWhiteSpace(databaseEntry.Due))
                        {
                            update += string.Format(" Due = '{0}',", NormalizeDatetime(databaseEntry.Due));
                        }

                        if (!string.IsNullOrWhiteSpace(databaseEntry.Start))
                        {
                            update += string.Format(" Start = '{0}',", NormalizeDatetime(databaseEntry.Start));
                        }

                        if (!string.IsNullOrWhiteSpace(databaseEntry.Completed))
                        {
                            update += string.Format(" Completed = '{0}',", NormalizeDatetime(databaseEntry.Completed));
                        }

                        update = update.TrimEnd(',');

                        try
                        {
                            connection.Execute(string.Format("UPDATE {0} SET {1} WHERE Id = {2}", table, update, databaseEntry.Id));
                        }
                        catch (Exception e1)
                        {
                            trackingManager.Exception(e1, "DatebaseDateTimeFixer update query");
                        }
                    }
                }
                catch (Exception e2)
                {
                    trackingManager.Exception(e2, "DatebaseDateTimeFixer select query");
                }
            }
        }