Esempio n. 1
0
        private void Manifest_SaveServiceExecutablePath(object owner, RoutedEventArgs args)
        {
            CoffeeTableManifest manifest = Extensions.GetCoffeeTableManifest();

            manifest.ServiceExecutablePath = ServicePathSelector.FileName;
            manifest.Set();
        }
Esempio n. 2
0
        // Set up the Coffee Table file manifest by saving the path to the launcher
        // and loading the path to the service if it exists
        private void Manifest_Refresh()
        {
            CoffeeTableManifest manifest = Extensions.GetCoffeeTableManifest();

            manifest.LauncherPath = Process.GetCurrentProcess().MainModule.FileName;
            manifest.Set();

            ServicePathSelector.FileName = manifest.ServiceExecutablePath ?? string.Empty;
        }
Esempio n. 3
0
        public static void Set(this CoffeeTableManifest manifest)
        {
            if (!Directory.Exists(ManifestPathRoot))
            {
                Directory.CreateDirectory(ManifestPathRoot);
            }
            string json = JsonConvert.SerializeObject(manifest, Formatting.Indented);

            File.WriteAllText(ManifestPath, json);
        }
Esempio n. 4
0
        private async void LaunchService(object sender, RoutedEventArgs e)
        {
            CoffeeTableManifest manifest = Extensions.GetCoffeeTableManifest();

            if (string.IsNullOrWhiteSpace(manifest.ServiceExecutablePath) ||
                !manifest.ServiceExecutablePath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ||
                !File.Exists(manifest.ServiceExecutablePath))
            {
                await this.ShowMessageAsync(HEADER_DEPLOY_FAILURE, "A valid path to the service executable could not be found. Did you provide one in the settings page?");

                return;
            }

            // Check that there is a sidebar and a homescreen application loaded
            if (!mAppBindings.Any(x => x.Type == ApplicationType.Homescreen) ||
                !mAppBindings.Any(x => x.Type == ApplicationType.Sidebar))
            {
                await this.ShowMessageAsync(HEADER_DEPLOY_FAILURE, "No sidebar application or homescreen application could be found. Have you added them?");

                return;
            }

            try
            {
                // Start the service and exit the current application
                Process.Start(manifest.ServiceExecutablePath);
                System.Windows.Application.Current.Shutdown();
            } catch (Exception ex) {
                if (ex is Win32Exception || ex is ObjectDisposedException)
                {
                    await this.ShowMessageAsync(HEADER_DEPLOY_FAILURE, "Failed to start the service process.");

                    return;
                }

                throw;
            }
        }