Exemple #1
0
        /// <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 kliteX64 = m_KliteX64;
            string kliteX86 = m_KliteX86;
            string kliteUrl = kliteX86;

            if (DeployServer.Is64BitEnv)
            {
                kliteUrl = kliteX64;
            }

            string kliteFileName     = Path.GetFileName(kliteUrl);
            string kliteFileSavePath = Path.Combine(Path.GetTempPath(), kliteFileName);

            try
            {
                using (WebClient webClient = new WebClient())
                {
                    webClient.DownloadFileCompleted += (s, e) =>
                    {
                        string installToken = Md5.GenerateBase64(kliteFileSavePath);

                        InstallQueuesType queuesType = new InstallQueuesType
                        {
                            FilePath  = kliteFileSavePath,
                            FileName  = kliteFileName,
                            Arguments = "/verysilent"
                        };

                        InstallServer.AddQueues(installToken, queuesType);
                    };

                    webClient.DownloadFileAsync(new Uri(kliteUrl), kliteFileSavePath);

                    response.success = true;
                }
            }
            catch (Exception e)
            {
                ZNLogger.Common.Error(string.Format(CultureInfo.InvariantCulture, "InstallKLite Async Error:{0}\n{1}", e.Message, e.StackTrace));
            }

            return(JsonConvert.SerializeObject(response));
        }
Exemple #2
0
        /// <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));
        }