/// <summary> /// OnRequestAsync /// </summary> /// <param name="aJson"></param> /// <returns>Returns string.</returns> public string OnRequestAsync(dynamic aJson) { dynamic response = new ExpandoObject(); response.success = false; response.result = null; string gitX64 = m_Gitx64; string gitX86 = m_Gitx86; string gitUrl = gitX86; if (DeployServer.Is64BitEnv) { gitUrl = gitX64; } string gitFileName = Path.GetFileName(gitUrl); string gitFileSavePath = Path.Combine(Path.GetTempPath(), gitFileName); try { using (WebClient webClient = new WebClient()) { webClient.DownloadFileCompleted += (s, e) => { string installToken = Md5.GenerateBase64(gitFileSavePath); InstallQueuesType queuesType = new InstallQueuesType { FilePath = gitFileSavePath, FileName = gitFileName, Arguments = "/SILENT" }; InstallServer.AddQueues(installToken, queuesType); }; webClient.DownloadFileAsync(new Uri(gitUrl), gitFileSavePath); response.success = true; } } catch (Exception e) { ZNLogger.Common.Error(string.Format(CultureInfo.InvariantCulture, "InstallGit Async Error:{0}\n{1}", e.Message, e.StackTrace)); } return(JsonConvert.SerializeObject(response)); }
/// <summary> /// OnRequest /// </summary> /// <param name="aJson"></param> /// <returns>Returns string.</returns> public string OnRequest(dynamic aJson) { dynamic response = new ExpandoObject(); response.success = false; response.result = null; try { string?command = Convert.ToString(aJson["Command"]); if (command == null || string.IsNullOrEmpty(command)) { return(JsonConvert.SerializeObject(response)); } ServicesSubCommandType?commands = Helper.BuildCommands(command); ManagedPackageRepoType?repo = ManagedPackageServer.GetRepoByName(commands); string?repoTempPath = ManagedPackageServer.RepoTempPath; if (repo != null && repo.Name != null && !string.IsNullOrEmpty(repo.Name)) { string?repoUrl = repo.Urlx86; string?repoArgs = repo.CmdInstallx86; if (DeployServer.Is64BitEnv) { repoUrl = !string.IsNullOrEmpty(repo.Urlx64) ? repo.Urlx64 : repoUrl; repoArgs = !string.IsNullOrEmpty(repo.CmdInstallx64) ? repo.CmdInstallx64 : repoArgs; } string?repoBinaryFileName = Path.GetFileName(repoUrl); string?repoBinaryTempFilePath = !string.IsNullOrEmpty(repoTempPath) ? repoTempPath : Path.GetTempPath(); string?repoBinaryFileLocalPath = Path.Combine(repoBinaryTempFilePath, repoBinaryFileName ?? ""); InstallQueuesType installQueuesTypeRepo = new() { RepoUrl = repoUrl, FileName = repoBinaryFileName, FilePath = repoBinaryFileLocalPath, Arguments = repoArgs }; if (InstallServer.AddQueues(commands.Option, installQueuesTypeRepo) > 0) { response.success = true; } } } catch (Exception e) { if (DeployServer.AppDebug) { ZNLogger.Common.Error(string.Format(CultureInfo.InvariantCulture, "ManagedPackage Error:{0}\n{1}", e.Message, e.StackTrace)); } } return(JsonConvert.SerializeObject(response)); }