コード例 #1
0
        private static void Main(string[] args)
        {
            var parser = new Parser();

            if (parser.ParseArguments(args, Dpo))
            {
                if (!string.IsNullOrEmpty(Dpo.SourcePlugin))
                {
                    var pluginPackageInfo = PluginPackageInfo.CreatePluginPackageInfo(Dpo.SourcePlugin);
                    PluginPackages.Add(pluginPackageInfo);
                }
                if (!string.IsNullOrEmpty(Dpo.FolderPath))
                {
                    var pluginsPath = Directory.GetFiles(Dpo.FolderPath, "*.sdlplugin", SearchOption.AllDirectories);
                    foreach (var plugin in pluginsPath)
                    {
                        var pluginInfo = PluginPackageInfo.CreatePluginPackageInfo(plugin);
                        PluginPackages.Add(pluginInfo);
                    }
                }
                _studioVersionService    = new StudioVersionService();
                _installedStudioVersions = _studioVersionService.GetInstalledStudioVersions();

                var backgroundWorker = new BackgroundWorker
                {
                    WorkerSupportsCancellation = true,
                    WorkerReportsProgress      = true
                };

                backgroundWorker.ProgressChanged    += BackgroundWorker_ProgressChanged;
                backgroundWorker.DoWork             += BackgroundWorker_DoWork;
                backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted;

                if (!backgroundWorker.IsBusy)
                {
                    backgroundWorker.RunWorkerAsync();

                    while (backgroundWorker.IsBusy)
                    {
                        Thread.Sleep(100);
                    }

                    if (Dpo.CloseConsole)
                    {
                        Console.WriteLine(@"Please press q to close the window.");
                        var key = Console.ReadKey();
                        if (key.KeyChar.Equals('q'))
                        {
                            Environment.Exit(0);
                        }
                    }
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            WindowDPIAwarness.SetPerMonitorDpiAwareness(ProcessDpiAwareness.Process_DPI_Unaware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            InitializeLoggingConfiguration();

            var logger = LogManager.GetLogger("log");


            if (args.Length == 0)
            {
                Application.Run(new PluginForm(logger));
            }
            else
            {
                var parser = new Parser();

                if (parser.ParseArguments(args, Dpo))
                {
                    var processStartInfo = new ProcessStartInfo("Sdl.Community.SdlPluginInstaller.Cmd.exe",
                                                                string.Join(" ", args))
                    {
                        UseShellExecute = false
                    };
                    var process = new Process
                    {
                        StartInfo = processStartInfo,
                    };
                    process.Start();
                }
                else
                {
                    var pluginPackageInfo = PluginPackageInfo.CreatePluginPackageInfo(args[0]);
                    if (string.IsNullOrEmpty(pluginPackageInfo.PluginName))
                    {
                        MessageBox.Show(
                            string.Format(
                                "There is no data in the package manifest. Please ask the plugin developer to add relevant information to the package manifest."),
                            Resources.Program_Main_Invalid_package, MessageBoxButtons.OK);
                        return;
                    }


                    Application.ThreadException += Application_ThreadException;
                    Application.Run(new InstallerForm(pluginPackageInfo, logger));
                }
            }
        }
コード例 #3
0
        public List <PluginPackageInfo> GetPluginPackages(string[] pluginPath)
        {
            var pluginList = new List <PluginPackageInfo>();

            foreach (var path in pluginPath)
            {
                try
                {
                    pluginList.Add(PluginPackageInfo.CreatePluginPackageInfo(path));
                }
                catch (UnauthorizedAccessException exception)
                {
                    _needsAdminRights = true;
                    _logger.Error(exception, "Admin rights are required");
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Error at getting plugins packages ");
                }
            }
            return(pluginList);
        }