Beispiel #1
0
        private static void InitConfig()
        {
            ServiceCallHelper.LoadConfig(string.Empty); // Loads the global appsettings.json.

            //// Start by copying the local copy of <loggedOnUser>_appsettings.json to the server.
            //DirectoryHelper.FileCopy("[L]" + AppConfigHelper.executablePath + "\\" + AppConfigHelper.LoggedOnUser + "_appsettings.json",
            //                                                                      "[S]" + AppConfigHelper.PathToServerAppsettings, true);
            if (!IsServiceClass.IsService)
            {
                if (!File.Exists(DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToWSL()))))
                {
                    // Learned that wsl.exe cannot run from \Windows\System32 (file not found).
                    MessageBox.Show(DirectoryHelper.CleanPath(AppConfigHelper.PathToWSL()) + " (" +
                                    DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToWSL())) +
                                    ") does not exist. Correct PathToWSL in appsettings.json before continuing.", "ERROR", MessageBoxButtons.OK);
                }

                string path = DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToSeqDB()));
                if (!File.Exists(path))
                {
                    // Learned that although Ubuntu prefix is \\wsl on my machine, it is \\wsl$ on WIMMER.
                    MessageBox.Show(DirectoryHelper.CleanPath(AppConfigHelper.PathToSeqDB()) + " (" +
                                    DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToSeqDB())) +
                                    ") does not exist. " + Environment.NewLine + "Correct PathToSeqDB in appsettings.json before continuing, or" +
                                    Environment.NewLine + "issue 'wsl --shutdown' in PowerShell.", "ERROR", MessageBoxButtons.OK);
                }
            }
            else // IsService
            {
                try
                {
                    AppConfigHelper.seqdbConfigGlobal.ServerDriveList = ServiceCallHelper.DriveList();
                    ServiceCallHelper.SaveConfigGlobal();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to obtain the drive list from the server." + Environment.NewLine + ex.ToString(), "ERROR", MessageBoxButtons.OK);
                }
            }
        }