Ejemplo n.º 1
0
        private void startValidation(Boolean isGetJson)
        {
            Uri destURI = new Uri(strDestURL);

            Debug.WriteLine("enter patch method");

            JObject sendJson = FileHashFilter.getJson(strDestPath);

            sendJson.Add(new JProperty("_patch_ver", strDestVer));
            sendJson.Add(new JProperty("_patch_method", "PATCH"));
            sendJson.Add(new JProperty("_patch_error", isFileError));

            string jsonData = new JObject(sendJson).ToString();

            Debug.WriteLine("sending json : " + jsonData);

            byte[] jsonByte = Encoding.Default.GetBytes(jsonData);
            Dictionary <string, string> postData = new Dictionary <string, string>();

            if (isGetJson)
            {
                postData.Add("Method", "JSON");
            }
            else
            {
                postData.Add("Method", "UPDATE");
            }
            st = new StreamModule();
            st.setEncoding(Encoding.UTF8);
            webRequest = HttpWebRequest.Create(destURI) as HttpWebRequest;

            webRequest.CookieContainer = cookieContainer;
            webResponse = st.sendData(webRequest, jsonData, postData, Encoding.UTF8);

            ValidateEndEventArgs vEe = new ValidateEndEventArgs(false, "");

            OnValidateEnd(vEe);

            if (st.result().Equals(StreamModule.FILE))
            {
                if (!isFilePatched)
                {
                    isFilePatched = true;
                    patchDownload();
                }
                else
                {
                    if (webResponse != null)
                    {
                        webResponse.Close();
                    }
                    StringBuilder sbError = new StringBuilder();
                    sbError.AppendLine(MsgERR.ERR_COMPLETE);
                    sbError.AppendLine(MsgERR.ERR_RETASK);
                    WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(false, sbError.ToString());//(PatchManager.JSON_COMPLETE, "");
                    OnWorkCompleted(wCe);
                }
            }
            else if (st.result().Equals(StreamModule.JSON))
            {
                st.receiveData(webResponse);
                measureResponseData();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 업데이트가 필요한지의 여부를 판단함.
        /// </summary>
        /// <returns>
        /// <para>STS_READY - 모든 파일이 최신. 패치가 필요하지 않습니다.</para>
        /// <para>STS_PATCH - 패치가 필요합니다.</para>
        /// <para>STS_REACHMAXCONN - 허용된 접속자 수를 초과하였습니다.</para>
        /// <para>STS_NETWORKERROR - 네트워크 문제로 패치를 실행할 수 없습니다.</para>
        /// <para>STS_SERVERERROR - 패치 서버에 접속할 수 없습니다.</para>
        /// <para>STS_CONFIGERROR - 설정 파일에 문제가 발생하였습니다.</para>
        /// <para>STS_ERROR - 처리되지 않은 에러가 발생하였습니다.</para>
        /// </returns>
        public string getUpdateStatus()
        {
            string update = MsgSYS.STS_READY;//"STS_READY";

            if (isConfigError)
            {
                return(MsgSYS.STS_CONFIGERROR);//"STS_CONFIGERROR";
            }
            try
            {
                if (!isServerAvailable())
                {
                    return(MsgSYS.STS_SERVERERROR);//"STS_SERVERERROR";
                }
                Uri destURI = new Uri(strDestURL);
                Debug.WriteLine("enter validating method");

                JObject sendJson = FileHashFilter.getJson(strDestPath, true);
                sendJson.Add(new JProperty("_patch_ver", strDestVer));
                sendJson.Add(new JProperty("_patch_method", "VALIDATE"));

                string jsonData = new JObject(sendJson).ToString();
                byte[] jsonByte = Encoding.Default.GetBytes(jsonData);
                Dictionary <string, string> postData = new Dictionary <string, string>();
                postData.Add("Method", "VALIDATE");
                st = new StreamModule();
                st.setEncoding(Encoding.UTF8);
                try
                {
                    webRequest  = HttpWebRequest.Create(destURI) as HttpWebRequest;
                    webResponse = st.sendData(webRequest, jsonData, postData, Encoding.UTF8);
                }
                catch
                {
                    return(MsgSYS.STS_FRAMEWORKERROR);//reqE.ToString();
                }
                st.receiveData(webResponse);


                try
                {
                    JObject response = JObject.Parse(st.getJson());
                    if (response.GetValue("_is_error").ToString().ToLower().Equals("true"))
                    {
                        update = MsgSYS.STS_ERROR;//"STS_ERROR";
                    }
                    else if (response.GetValue("_is_update").ToString().ToLower().Equals("true"))
                    {
                        update = MsgSYS.STS_PATCH;//"STS_PATCH";
                    }
                    else if (response.GetValue("_is_maxreach").ToString().ToLower().Equals("true"))
                    {
                        update = MsgSYS.STS_REACHMAXCONN;// "STS_REACHMAXCONN";
                    }
                }
                catch//  (Exception parseE)
                {
                    //return parseE.ToString();
                    return(MsgSYS.STS_PARSEERROR);//"STS_PARSEERROR";
                }
            }
            catch// (Exception eE)
            {
                //return eE.ToString();
                return(MsgSYS.STS_ERROR);//"STS_ERROR";
            }
            return(update);
        }