private void CheckVersionUpdateEvent(CheckVersionResponse response) { if (response != null) { VersionType type = (VersionType)System.Enum.Parse(typeof(VersionType), response.type.ToString()); UpdateItem item = new UpdateItem(response.url, response.name, response.updateInfo, type); if (WindowModel.Instance.IsOpenUpdateWindow()) { UpdateWindow updateWindow = WindowModel.Instance.UpdateWindow; updateWindow.UpdateInfo(item); } else { if (type == VersionType.VERSION_UPDATE) { item.EndEvent = new EndEvent(this.UpdateVersionEnd); this.fileService.DownloadIDKinUpdatePackage(item); } } } }
public async Task DownloadUpdate(CheckVersionResponse versionResponse, string destination, IProgress <(long, long?)>?progress = null)
void _worker_DoWork(object sender, DoWorkEventArgs e) { WorkerResult result = new WorkerResult(); InstallerInterface installer = null; try { WorkerArg arg = e.Argument as WorkerArg; result.TestConnectionOnly = arg.TestConnectionOnly; result.TestStatus = StackHashErrorIndexDatabaseStatus.Unknown; // configure for local access to the service if (!_localServiceConfigComplete) { _localServiceGuid = ClientLogic.GetLocalServiceGuid(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location); CheckVersionRequest checkVersionRequest = new CheckVersionRequest(); checkVersionRequest.ServiceGuid = _localServiceGuid == Guid.Empty ? null : _localServiceGuid.ToString(); checkVersionRequest.ClientData = GenerateClientData(); checkVersionRequest.MajorVersion = fvi.ProductMajorPart; checkVersionRequest.MinorVersion = fvi.ProductMinorPart; CheckVersionResponse checkVersionResponse = ServiceProxy.Services.Admin.CheckVersion(checkVersionRequest); _localServiceConfigComplete = true; } // always test that the service can access the database StackHashSqlConfiguration sqlConfig = new StackHashSqlConfiguration(); sqlConfig.ConnectionString = arg.MasterConnectionString; sqlConfig.ConnectionTimeout = DefaultSqlConnectionTimeout; sqlConfig.EventsPerBlock = DefaultSqlEventsPerBlock; sqlConfig.InitialCatalog = arg.ProfileName; sqlConfig.MaxPoolSize = DefaultSqlMaxPoolSize; sqlConfig.MinPoolSize = DefaultSqlMinPoolSize; TestDatabaseConnectionRequest request = new TestDatabaseConnectionRequest(); request.ClientData = GenerateClientData(); request.ContextId = -1; request.SqlSettings = sqlConfig; request.TestDatabaseExistence = false; request.CabFolder = arg.CabFolder; TestDatabaseConnectionResponse response = ServiceProxy.Services.Admin.TestDatabaseConnection(request); result.TestStatus = response.TestResult; result.TestLastExceptionText = response.LastException; result.CanAccessCabFolder = response.IsCabFolderAccessible; result.CabFolderExceptionText = response.CabFolderAccessLastException; // contine if the test succeeded and we're not just testing if ((result.TestStatus == StackHashErrorIndexDatabaseStatus.Success) && (result.CanAccessCabFolder) && (!arg.TestConnectionOnly)) { // make sure NETWORK SERVICE can access the cab folder FolderPermissionHelper.NSAddAccess(arg.CabFolder); if (arg.CreateDatabase) { installer = new InstallerInterface(arg.MasterConnectionString, arg.ProfileName, arg.CabFolder); installer.Connect(); if (!installer.DatabaseExists()) { installer.CreateDatabase(arg.UseDefaultLocation); } } DBConfigSettings.Settings.ProfileName = arg.ProfileName; DBConfigSettings.Settings.ConnectionString = arg.ConnectionString; DBConfigSettings.Settings.ProfileFolder = arg.CabFolder; DBConfigSettings.Settings.Save(); _configurationSucceeded = true; } } catch (Exception ex) { result.WorkerException = ex; } finally { if (installer != null) { installer.Disconnect(); } } // if a test exception was reported include it in the WorkerException if (!string.IsNullOrEmpty(result.TestLastExceptionText)) { if (result.WorkerException == null) { result.WorkerException = new AdminReportException(result.TestLastExceptionText); } else { result.WorkerException = new AdminReportException(result.TestLastExceptionText, result.WorkerException); } } else if (!string.IsNullOrEmpty(result.CabFolderExceptionText)) { if (result.WorkerException == null) { result.WorkerException = new AdminReportException(result.CabFolderExceptionText); } else { result.WorkerException = new AdminReportException(result.CabFolderExceptionText, result.WorkerException); } } e.Result = result; }