コード例 #1
0
        public static async void DatabaseAsync(string servicePath, string installationPath, string file)
        {
            var computerName   = Environment.GetEnvironmentVariable("COMPUTERNAME");
            var databaseFolder = Path.Combine(installationPath, "Database");

            Directory.CreateDirectory(databaseFolder);

            var database = await Task.Run(() => ZipExtract.ExtractAndGetFile(servicePath, file));

            var databaseName       = Path.GetFileName(database);
            var databaseWithoutExt = Path.GetFileNameWithoutExtension(databaseName);

            var installArgs0 = $"-E -S {computerName}\\SQLEXPRESS -Q \"USE master\"";

            var installArgs1 = $"-E -S {computerName}\\SQLEXPRESS -Q \"EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\\Microsoft\\MSSQLServer\\MSSQLServer', N'LoginMode', REG_DWORD, 2\"";

            var installArgs2 = $"-E -S {computerName}\\SQLEXPRESS -Q \"CREATE LOGIN prolexnet WITH PASSWORD = '******'\"";

            var installArgs3 = $"-E -S {computerName}\\SQLEXPRESS -Q \"ALTER SERVER ROLE [sysadmin] ADD MEMBER [prolexnet]\"";

            var installArgs4 = $"-E -S {computerName}\\SQLEXPRESS -Q \"RESTORE DATABASE[ProlexNet] FROM DISK = '{database}' WITH RECOVERY, MOVE '{databaseWithoutExt}_DATA' TO '{databaseFolder}\\{databaseWithoutExt}_DATA.mdf', MOVE '{databaseWithoutExt}_Log' TO '{databaseFolder}\\{databaseWithoutExt}_Log.ldf'\"";

            InstallFactory("SqlCmd", installArgs0);
            InstallFactory("SqlCmd", installArgs1);
            InstallFactory("SqlCmd", installArgs2);
            InstallFactory("SqlCmd", installArgs3);
            InstallFactory("SqlCmd", installArgs4);

            InstallFactory("NET", "STOP MSSQL$SQLEXPRESS");
            InstallFactory("NET", "START MSSQL$SQLEXPRESS");
        }
コード例 #2
0
        // ProlexNet
        public static async Task ProlexNetAsync(Action <DownloadProgressChangedEventArgs, double> callback, string port)
        {
            var installationPath = MainWindowViewModel.InstallationPath;
            var servicePath      = CreateServicePath.ServicePath;

            var url              = DownloadParameters.AppList.ProlexNet.Url;
            var hash             = DownloadParameters.AppList.ProlexNet.Hash;
            var downloadFileName = Path.GetFileName(url);
            var file             = Path.Combine(servicePath, downloadFileName);

            var installationSubFolder = Path.Combine(installationPath, "ProlexNet");

            await DownloadFileInBackgroundAsync(url, file, hash, callback);

            await Task.Run(() => ZipExtract.Run(file, installationSubFolder));

            await Task.Run(() => CreateRegistryKey.ProlexNet(servicePath, installationPath));
        }