Exemple #1
0
        public override int Handle(StartOptions command)
        {
            var virgilHub = ServiceHub.Create(ServiceHubConfig.UseAccessToken(ApiConfig.VirgilToken));

            ServiceLocator.Setup(virgilHub);

            var eventAggregator = this.bootstrapper.Container.Resolve <IEventAggregator>();

            eventAggregator.Subscribe(new Listener());

            var appState = this.bootstrapper.Container.Resolve <ApplicationState>();

            appState.Restore();

            if (!appState.HasAccount)
            {
                Console.WriteLine("    There is no Virgil Card stored");
                return(1);
            }

            var folderSettings = this.bootstrapper.Container.Resolve <FolderSettingsStorage>();

            if (folderSettings.FolderSettings.IsEmpty())
            {
                Console.WriteLine("    There is no folder to bropbox link configured");
                return(1);
            }

            var validationErrors = folderSettings.FolderSettings.Validate();

            if (validationErrors.Any())
            {
                foreach (var validationError in validationErrors)
                {
                    Console.WriteLine("    " + validationError);
                }
                return(1);
            }

            ExceptionNotifier.Current.OnDropboxSessionExpired(() =>
            {
                eventAggregator.Publish(new DropboxSessionExpired());
                Console.WriteLine("    Dropbox session has expired");
                Environment.Exit(1);
            });

            var folderLinkFacade = this.bootstrapper.Container.Resolve <FolderLinkFacade>();

            Task.Factory.StartNew(() => folderLinkFacade.Rebuild());

            Console.WriteLine("    Virgil sync is running");

            while (true)
            {
                Console.ReadLine();
            }
        }
Exemple #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += this.OnDispatcherUnhandledException;

            var virgilHub = ServiceHub.Create(ServiceHubConfig.UseAccessToken(ApiConfig.VirgilToken));

            Virgil.SDK.Domain.ServiceLocator.Setup(virgilHub);

            var updater = new Updater();

            updater.Start();

            this.Bootstrapper = new Bootstrapper();
            this.Bootstrapper.Initialize();

            this.AppState = this.Bootstrapper.IoC.Get <ApplicationState>();
            this.AppState.Restore();

            this.FolderSettings = this.Bootstrapper.IoC.Get <FolderSettingsStorage>();
            this.MainWindow     = new TrayWindow
            {
                DataContext = this.Bootstrapper.IoC.Get <OperationStatusViewModel>()
            };

            ExceptionNotifier.Current.OnDropboxSessionExpired(() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    this.Bootstrapper.IoC.Get <IEventAggregator>().Publish(new DropboxSessionExpired());
                });
            });

            this.ShowUI();
        }
Exemple #3
0
 /// <summary>
 /// Setups service locator to use virgil api configuration to access services.
 /// </summary>
 /// <param name="config">The configuration.</param>
 public static void Setup(ServiceHubConfig config)
 {
     services = ServiceHub.Create(config);
 }