internal void SendInstallErrorEvent(ErrorInstallInfo errorInstallInfo) { JavaScriptSerializer js = new JavaScriptSerializer(); string data = js.Serialize(errorInstallInfo); try { var progRequest = js.Serialize(new ErrorInstallInfo() { ErrorMessage = errorInstallInfo.ErrorMessage, batteryStatus = errorInstallInfo.batteryStatus, batteryUsed = errorInstallInfo.batteryUsed, isAdmin = errorInstallInfo.isAdmin, osVersion = InstallUtils.GetOSVersion(), screenRes = null, machineId = _machineId, partnerId = _partnerId, campaignId = _campaignId, sdkVersion = FileHelper.GetCurrentVersion(Assembly.GetExecutingAssembly()), timeZone = InstallUtils.GetTimeZone() }); string body = String.Format(@"{{""Data"": {0}}}", progRequest); SendReport(ErrorInstallType, ProductId, progRequest, APIVersion); } catch (System.Exception ex) { } }
internal void SendUninstallErrorEvent(ErrorUninstallInfo errorUninstallInfo) { JavaScriptSerializer js = new JavaScriptSerializer(); string data = js.Serialize(errorUninstallInfo); try { var progRequest = js.Serialize(new ErrorUninstallInfo() { isAdmin = errorUninstallInfo.isAdmin, osVersion = InstallUtils.GetOSVersion(), partnerId = _partnerId, campaignId = _campaignId, installDate = _installDate, machineId = _machineId, token = _xToken, miners = null, HVVersion = FileHelper.GetCurrentVersion(Assembly.GetExecutingAssembly()), ErrorMessage = errorUninstallInfo.ErrorMessage }); string body = String.Format(@"{{""Data"": {0}}}", progRequest); SendReport(ErrorUninstallType, ProductId, progRequest, APIVersion); } catch (System.Exception ex) { } }
public async Task <ActionResult <BoolResult> > RedisConnect([FromBody] RedisConnectRequest request) { if (!await _configRepository.IsNeedInstallAsync()) { return(Unauthorized()); } var redisConnectionString = string.Empty; if (request.IsRedis) { redisConnectionString = InstallUtils.GetRedisConnectionString(request.RedisHost, request.IsRedisDefaultPort, request.RedisPort, request.IsSsl, request.RedisPassword); } var db = new Redis(redisConnectionString); var(isConnectionWorks, message) = await db.IsConnectionWorksAsync(); if (!isConnectionWorks) { return(this.Error(message)); } return(new BoolResult { Value = true }); }
internal static IEnumerable <IInstallationStep> GetUnInstallationProcedure(params string[] args) { InitializeEventService(args); yield return(new GenerateInstallMachineIds()); yield return(new StopProcess(InstallUtils.WcProcessName)); yield return(new UnInstallService(InstallService.ServiceName, InstallService.ExeName)); yield return(new RemoveUninstallInfoStep()); yield return(new RemoveAppdataFolder(InstallUtils.GetLocalAppDataFolder(), "Spario")); yield return(new RemoveFolder(InstallUtils.GetWCProgramDataFolder())); yield return(new RemoveFolder(InstallUtils.GetRoamingAppDataWCFolder())); yield return(new RemoveShortcut()); yield return(new RemoveLavasoftEmptyDirectories(InstallUtils.GetLavasoftProgramDataFolder(), InstallUtils.GetRoamingAppDataLavasoftFolder(), InstallUtils.GetLocalAppDataFolder())); yield return(new UpdateInstalledRegistry(false)); // remove Installed yield return(new ReportUninstallationResultStep(ReportUninstallationResultStep.InstallState.Ok, "CompleteUninstall")); yield return(new SelfDeleteFolder(InstallUtils.fullPathToBeDeleted(InstallUtils.GetInstallFolder()), CommunicationUtils.DataCollector.Version != "1.0.0.0")); }
internal static int StepExecuter(IEnumerable <IInstallationStep> procedure, IsCanceledHandler isCanceled, bool bInterruptOnReportError = true) { try { foreach (var step in procedure) { if (isCanceled()) { return(1); // canceled } InstallUtils.SafeCallInterruptable(bInterruptOnReportError, () => step.Init()); step.Perform(); InstallUtils.SafeCallInterruptable(bInterruptOnReportError, () => step.Report()); } } catch (GenericException ex) { // report installation failure InstallUtils.SafeCallInterruptable(false, () => ex.Report()); return(-1); } // report success return(0); }
internal void SendCompleteInstallEvent(CompleteInstallInfo completeInstallInfo) { JavaScriptSerializer js = new JavaScriptSerializer(); string data = js.Serialize(completeInstallInfo); try { var progRequest = js.Serialize(new CompleteInstallInfo() { cpuInfo = completeInstallInfo.cpuInfo, gpuInfo = completeInstallInfo.gpuInfo, powerProfile = completeInstallInfo.powerProfile, uptimeCurrent = completeInstallInfo.uptimeCurrent, uptimePct = completeInstallInfo.uptimePct, batteyStatus = completeInstallInfo.batteyStatus, batteryUsed = completeInstallInfo.batteryUsed, isAdmin = completeInstallInfo.isAdmin, osVersion = InstallUtils.GetOSVersion(), screenRes = null, machineId = _machineId, partnerId = _partnerId, campaignId = _campaignId, timeZone = InstallUtils.GetTimeZone() }); string body = String.Format(@"{{""Data"": {0}}}", progRequest); SendReport(CompleteInstallType, ProductId, progRequest, APIVersion); } catch (System.Exception ex) { } }
public async Task <ActionResult <DatabaseConnectResult> > DatabaseConnect([FromBody] DatabaseConnectRequest request) { if (!await _configRepository.IsNeedInstallAsync()) { return(Unauthorized()); } var connectionStringWithoutDatabaseName = _settingsManager.Containerized ? _settingsManager.DatabaseConnectionString : InstallUtils.GetDatabaseConnectionString(request.DatabaseType, request.DatabaseHost, request.IsDatabaseDefaultPort, TranslateUtils.ToInt(request.DatabasePort), request.DatabaseUserName, request.DatabasePassword, string.Empty); var db = new Database(request.DatabaseType, connectionStringWithoutDatabaseName); var(isConnectionWorks, message) = await db.IsConnectionWorksAsync(); if (!isConnectionWorks) { return(this.Error(message)); } var databaseNames = await db.GetDatabaseNamesAsync(); return(new DatabaseConnectResult { DatabaseNames = databaseNames }); }
internal static void Initialize(string partnerId, string campaignId, string xToken) { _partnerId = partnerId; _campaignId = campaignId; _xToken = xToken; _machineId = InstallUtils.ReadMachineGuid(); _installDate = InstallUtils.ReadValue("installDate"); }
public void Perform() { var iDate = InstallUtils.RemoveUnInstaller(); if (Installed != null) { Installed(iDate); } }
void Install(string source) { backButton.IsDisabled = () => true; retryButton.IsDisabled = () => true; insertDiskContainer.IsVisible = () => false; installingContainer.IsVisible = () => true; var dest = new string[] { Platform.SupportDir, "Content", "cnc" }.Aggregate(Path.Combine); var extractPackage = "INSTALL/SETUP.Z"; var installCounter = 0; var installTotal = filesToExtract.Count() + filesToExtract.Count(); var onProgress = (Action <string>)(s => Game.RunAfterTick(() => { progressBar.Percentage = installCounter * 100 / installTotal; installCounter++; statusLabel.GetText = () => s; })); var onError = (Action <string>)(s => Game.RunAfterTick(() => { statusLabel.GetText = () => "Error: " + s; backButton.IsDisabled = () => false; retryButton.IsDisabled = () => false; })); new Thread(_ => { try { if (!InstallUtils.CopyFiles(source, filesToCopy, dest, onProgress, onError)) { return; } if (!InstallUtils.ExtractFromPackage(source, extractPackage, filesToExtract, dest, onProgress, onError)) { return; } Game.RunAfterTick(() => { Ui.CloseWindow(); afterInstall(); }); } catch { onError("Installation failed"); } }) { IsBackground = true }.Start(); }
internal static IEnumerable <IInstallationStep> GetUpdateProcedure(params string[] args) { // create tmp folder string installedDate = null; var tmpFolder = Path.GetTempPath(); var owner = ProcessAsUser.GetProcessOwner(Process.GetCurrentProcess().Id).ToLower(); bool bAsUser = owner.Contains("system"); Trace.WriteLine("SpareioInstaller owner=" + owner); var cmdArgs = new Utils.CmdLineArgs(args); bool bPreProd = cmdArgs.CheckArg("preprod"); string _token = String.Empty; _token = cmdArgs.CheckArg("xToken") ? cmdArgs.GetArgValue("xToken") : InstallUtils.ReadValue("xToken"); InitializeEventService(args); yield return(new GenerateInstallMachineIds()); yield return(new StopProcess(InstallUtils.WcProcessName)); yield return(new DownloadStep(tmpFolder, TimeSpan.FromMinutes(DownloadStep.UpdateTimeout), DownloadStep.UpdateRetry, args) { Validator = x => ZipUtils.IsZipValid(x) }); yield return(new UnInstallService(InstallService.ServiceName, InstallService.ExeName, true)); yield return(new UnzipStep(Path.Combine(tmpFolder, "Spareio.zip"), InstallUtils.GetInstallFolder())); yield return(new RemoveUninstallInfoStep { Installed = iDate => { installedDate = iDate; } }); yield return(new UninstallInfoStep { InstalledDate = installedDate }); yield return(new InstallService(InstallUtils.GetWcRunFolder())); yield return(new ExecuteCommandStep("sc.exe", new[] { "start", InstallService.ServiceName, !String.IsNullOrEmpty(_token) ? _token : "" }) { HideWindow = true }); //yield return new RunSpareio(Path.Combine(InstallUtils.GetWcRunFolder(), "Spareio.exe")) { silent = true, preprod = bPreProd, update = true, InitMessage = "Applying update for distributed components..." }; yield return(new RunSpareio(Path.Combine(InstallUtils.GetWcRunFolder(), "Spareio.exe"), "") { preprod = bPreProd, AsUser = bAsUser, afterupdate = true, WaitForExit = false }); yield return(new ReportUpdateResultStep(ReportUpdateResultStep.InstallState.Ok, "CompleteUpdate")); }
public async Task <ActionResult <StringResult> > Prepare([FromBody] PrepareRequest request) { if (!await _configRepository.IsNeedInstallAsync()) { return(Unauthorized()); } var(success, errorMessage) = await _administratorRepository.InsertValidateAsync(request.UserName, request.AdminPassword, request.Email, request.Mobile); if (!success) { return(this.Error(errorMessage)); } if (_settingsManager.Containerized) { if (_settingsManager.DatabaseType == DatabaseType.SQLite) { var filePath = PathUtils.Combine(_settingsManager.ContentRootPath, Constants.LocalDbContainerVirtualPath.Substring(1)); if (!FileUtils.IsFileExists(filePath)) { await FileUtils.WriteTextAsync(filePath, string.Empty); } } } else { if (request.DatabaseType == DatabaseType.SQLite) { var filePath = PathUtils.Combine(_settingsManager.ContentRootPath, Constants.LocalDbHostVirtualPath.Substring(1)); if (!FileUtils.IsFileExists(filePath)) { await FileUtils.WriteTextAsync(filePath, string.Empty); } } var databaseConnectionString = InstallUtils.GetDatabaseConnectionString(request.DatabaseType, request.DatabaseHost, request.IsDatabaseDefaultPort, TranslateUtils.ToInt(request.DatabasePort), request.DatabaseUserName, request.DatabasePassword, request.DatabaseName); var redisConnectionString = string.Empty; if (request.IsRedis) { redisConnectionString = InstallUtils.GetRedisConnectionString(request.RedisHost, request.IsRedisDefaultPort, request.RedisPort, request.IsSsl, request.RedisPassword); } _settingsManager.SaveSettings(request.IsProtectData, false, false, request.DatabaseType, databaseConnectionString, redisConnectionString, string.Empty, null, null); } return(new StringResult { Value = _settingsManager.SecurityKey }); }
static void Copy(string src, string path) { foreach (FileInfo file in new DirectoryInfo(src).GetFiles()) { ClearLine(); Console.Write($"Copying: {file.Name}"); file.CopyTo($"{path}\\{file.Name}", true); Thread.Sleep(20); } InstallUtils.SelfCopy(path); }
public static void StartInstallManager() { if (InstallUtils.IsInstalled()) { Uninstall(); } else { Install(); } }
void Install(string source) { backButton.IsDisabled = () => true; retryButton.IsDisabled = () => true; insertDiskContainer.IsVisible = () => false; installingContainer.IsVisible = () => true; var dest = new string[] { Platform.SupportDir, "Content", "ts" }.Aggregate(Path.Combine); var copyFiles = new string[] { "install/tibsun.mix", "scores.mix", "multi.mix" }; var installCounter = 0; var installTotal = copyFiles.Count(); var onProgress = (Action <string>)(s => Game.RunAfterTick(() => { progressBar.Percentage = installCounter * 100 / installTotal; installCounter++; statusLabel.GetText = () => s; })); var onError = (Action <string>)(s => Game.RunAfterTick(() => { statusLabel.GetText = () => "Error: " + s; backButton.IsDisabled = () => false; retryButton.IsDisabled = () => false; })); var t = new Thread(_ => { try { if (!InstallUtils.CopyFiles(source, copyFiles, dest, onProgress, onError)) { return; } Game.RunAfterTick(() => { Ui.CloseWindow(); continueLoading(); }); } catch { onError("Installation failed"); } }) { IsBackground = true }; t.Start(); }
private void RemoveAgentAutoStartTask() { try { if (InstallUtils.TaskExists(Const.AppName)) { InstallUtils.DeleteStartupTask(Const.AppName); } } catch (Exception ex) { } }
public void Perform() { if (_bSetValue) { InstallUtils.GenerateSuccessfullInstallMark(); } else { InstallUtils.RemoveInstalledMark(); // https://lavasoft.atlassian.net/browse/WC-2019 It is decided to leave machine id always //string GUID = InstallUtils.RemoveMachineIdGuid(); } }
public void Reload() { var envSecurityKey = GetEnvironmentVariable(EnvSecurityKey); var envDatabaseType = GetEnvironmentVariable(EnvDatabaseType); var envDatabaseHost = GetEnvironmentVariable(EnvDatabaseHost); var envDatabasePort = GetEnvironmentVariable(EnvDatabasePort); var envDatabaseUser = GetEnvironmentVariable(EnvDatabaseUser); var envDatabasePassword = GetEnvironmentVariable(EnvDatabasePassword); var envDatabaseName = GetEnvironmentVariable(EnvDatabaseName); var envDatabaseConnectionString = GetEnvironmentVariable(EnvDatabaseConnectionString); var envRedisConnectionString = GetEnvironmentVariable(EnvRedisConnectionString); var isEnvironment = IsEnvironment(envSecurityKey, envDatabaseType, envDatabaseConnectionString, envDatabaseHost, envDatabaseUser, envDatabasePassword, envDatabaseName); if (isEnvironment) { IsProtectData = false; SecurityKey = envSecurityKey; DatabaseType = TranslateUtils.ToEnum(envDatabaseType, DatabaseType.MySql); DatabaseConnectionString = DatabaseType == DatabaseType.SQLite ? $"Data Source={Constants.LocalDbContainerVirtualPath};Version=3;" : envDatabaseConnectionString; RedisConnectionString = envRedisConnectionString; if (string.IsNullOrEmpty(DatabaseConnectionString)) { var port = TranslateUtils.ToInt(envDatabasePort); DatabaseConnectionString = InstallUtils.GetDatabaseConnectionString(DatabaseType, envDatabaseHost, port == 0, port, envDatabaseUser, envDatabasePassword, envDatabaseName); } } else { IsProtectData = _config.GetValue(nameof(IsProtectData), false); SecurityKey = _config.GetValue <string>(nameof(SecurityKey)); DatabaseType = TranslateUtils.ToEnum( IsProtectData ? Decrypt(_config.GetValue <string>("Database:Type")) : _config.GetValue <string>("Database:Type"), DatabaseType.MySql); DatabaseConnectionString = DatabaseType == DatabaseType.SQLite ? $"Data Source={Constants.LocalDbHostVirtualPath};Version=3;" : IsProtectData ? Decrypt(_config.GetValue <string>("Database:ConnectionString")) : _config.GetValue <string>("Database:ConnectionString"); RedisConnectionString = IsProtectData ? Decrypt(_config.GetValue <string>("Redis:ConnectionString")) : _config.GetValue <string>("Redis:ConnectionString"); } }
void CheckForDisk() { var path = InstallUtils.GetMountedDisk(IsValidDisk); if (path != null) { Install(path); } else { insertDiskContainer.IsVisible = () => true; installingContainer.IsVisible = () => false; } }
public void Perform() { try { InstallUtils.UpdatePartnerInfo(_partnerId, _campaignId, _xToken); } catch (System.Exception ex) { throw new CreatePartnerException(ex) { Step = this }; } }
static void OpenVoiceModder() { if (!InstallUtils.IsInstalled()) { Installer.Start(temp); } else { Uninstaller.Start(); } ClearFolder(log: true); Thread.Sleep(1500); Reset(); }
public void SaveSettings(bool isProtectData, bool isDisablePlugins, DatabaseType databaseType, string databaseConnectionString, string redisConnectionString, string adminRestrictionHost, string[] adminRestrictionAllowList, string[] adminRestrictionBlockList) { var type = databaseType.GetValue(); var databaseConnectionStringValue = databaseConnectionString; var redisConnectionStringValue = redisConnectionString; if (isProtectData) { type = Encrypt(type, SecurityKey); databaseConnectionStringValue = Encrypt(databaseConnectionStringValue, SecurityKey); redisConnectionStringValue = Encrypt(redisConnectionString, SecurityKey); } InstallUtils.SaveSettings(ContentRootPath, isProtectData, isDisablePlugins, SecurityKey, type, databaseConnectionStringValue, redisConnectionStringValue, adminRestrictionHost, adminRestrictionAllowList, adminRestrictionBlockList); }
public override void Uninstall(IDictionary savedState) { try { InstallUtils.InstallModeEnum installMode = (InstallUtils.InstallModeEnum)savedState["InstallMode"]; string pathToAddinFile = (string)savedState["PathToAddinFile"]; InstallUtils.UninstallRegistryFree(savedState, pathToAddinFile); } catch { } base.Uninstall(savedState); }
private void runAtStartupItem_Click(object sender, EventArgs e) { bool autoRun = InstallUtils.TaskExists(Const.AppName); if (autoRun == false) { InstallUtils.CreateStartupTask(Const.AppName, Application.ExecutablePath); } else { InstallUtils.DeleteStartupTask(Const.AppName); } RunAtStartupMenuItem.Checked = !autoRun; }
void CheckForDisk() { Func <string, bool> ValidDiskFilter = diskRoot => File.Exists(diskRoot + Path.DirectorySeparatorChar + "MAIN.MIX") && File.Exists(new string[] { diskRoot, "INSTALL", "REDALERT.MIX" }.Aggregate(Path.Combine)); var path = InstallUtils.GetMountedDisk(ValidDiskFilter); if (path != null) { Install(path); } else { insertDiskContainer.IsVisible = () => true; installingContainer.IsVisible = () => false; } }
public void Perform() { try { if (Directory.Exists(InstallUtils.GetStartMenuPath())) { Directory.Delete(InstallUtils.GetStartMenuPath(), true); } //InstallUtils.RestartWindowsExplorer(); } catch (System.Exception ex) { throw new RemoveFolderException(ex) { Step = this }; } }
internal static IEnumerable <IInstallationStep> GetInstallationProcedure(params string[] args) { // create tmp folder var tmpFolder = Path.GetTempPath(); var cmdArgs = new Utils.CmdLineArgs(args); bool bSilent = cmdArgs.CheckArg("silent"); string xToken = cmdArgs.GetArgValue("xToken"); InitializeEventService(args); yield return(new GenerateInstallMachineIds()); yield return(new CreatePartnerInfoStep(args)); yield return(new DownloadStep(tmpFolder, TimeSpan.FromMinutes(DownloadStep.InstallTimeout), DownloadStep.InstallRetry, args) { Validator = x => ZipUtils.IsZipValid(x) }); yield return(new UnzipStep(Path.Combine(tmpFolder, "Spareio.zip"), InstallUtils.GetInstallFolder())); yield return(new InstallService(InstallUtils.GetWcRunFolder())); yield return(new ExecuteCommandStep("sc.exe", new[] { "start", InstallService.ServiceName, xToken }) { HideWindow = true }); yield return(new UninstallInfoStep()); yield return(new UpdateInstalledRegistry(true)); yield return(new RunSpareio(Path.Combine(InstallUtils.GetWcRunFolder(), "Spareio.exe")) { silent = bSilent, install = true, InitMessage = "Applying Selected Configuration ..." }); yield return(new RunSpareio(Path.Combine(InstallUtils.GetWcRunFolder(), "Spareio.exe")) { silent = bSilent, afterinstall = true, WaitForExit = false }); yield return(new ReportInstallationResultStep(ReportInstallationResultStep.InstallState.Ok, "CompleteInstall")); }
void CheckForDisk() { var path = InstallUtils.GetMountedDisk(IsValidDisk); if (path != null) { Install(path); } else if ((installData.InstallShieldCABFileIds.Length != 0 || installData.InstallShieldCABFilePackageIds.Length != 0) && (path = InstallUtils.GetMountedDisk(IsTFD)) != null) { InstallTFD(Platform.ResolvePath(path, "data1.hdr")); } else { insertDiskContainer.IsVisible = () => true; installingContainer.IsVisible = () => false; } }
public void Perform() { try { foreach (string directory in _LavasoftDirectoryPaths) { if (Directory.Exists(directory) && InstallUtils.IsDirectoryEmpty(directory)) { Directory.Delete(directory, true); } } } catch (System.Exception ex) { throw new RemoveFolderException(ex) { Step = this }; } }
public void Perform() { try { if (String.IsNullOrEmpty(_machineId)) { _machineId = InstallUtils.GenerateMachineIdGuid(); } if (String.IsNullOrEmpty(_installId)) { _installId = InstallUtils.GenerateInstallIdGuid(); } } catch (System.Exception ex) { throw new MachineInstallIdException(ex) { Step = this }; } }