コード例 #1
0
ファイル: Program.cs プロジェクト: ghockx1p/southwind
        private static bool RunLocally()
        {
            if (!File.Exists(DisconnectedClient.DatabaseFile) && !File.Exists(DisconnectedClient.DownloadBackupFile))
            {
                return(false);
            }

            StartOption result;

            if (!SelectorWindow.ShowDialog(
                    EnumExtensions.GetValues <StartOption>(), out result,
                    elementIcon: so => SouthwindImageLoader.GetImageSortName(so == StartOption.RunLocally ? "local.png" : "server.png"),
                    elementText: so => so.NiceToString(),
                    title: "Startup mode",
                    message: "A local database has been found on your system.\r\nWhat you want to do?"))
            {
                Environment.Exit(0);
            }

            if (result == StartOption.RunLocally)
            {
                if (File.Exists(DisconnectedClient.DownloadBackupFile))
                {
                    ProgressWindow.Wait("Waiting", "Restoring database...", () =>
                    {
                        LocalServer.RestoreDatabase(
                            Settings.Default.LocalDatabaseConnectionString,
                            DisconnectedClient.DownloadBackupFile,
                            DisconnectedClient.DatabaseFile,
                            DisconnectedClient.DatabaseLogFile);

                        File.Delete(DisconnectedClient.DownloadBackupFile);
                    });
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }//RunLocally