Ejemplo n.º 1
0
        /// <summary>
        /// AddQueues
        /// </summary>
        /// <param name="token"></param>
        /// <param name="queuesType"></param>
        /// <returns>Returns void.</returns>
        public static void AddQueues(string token, InstallQueuesType queuesType)
        {
            if (token == null || token.Length == 0)
            {
                return;
            }

            m_InstallQueues.Enqueue(new Tuple <string, InstallQueuesType>(token, queuesType));
            m_QueuesSignal.Release();
        }
Ejemplo n.º 2
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));
        }