/// <summary> /// 서버 Response가 file이 아닌 경우 그에 대한 데이터 검토 /// [0] : 메세지 코드 /// [1] : 메세지박스 문자열 /// [2] : 작업진행창 문자열 /// </summary> /// <returns></returns> private void measureResponseData() { MessageReceiveEventArgs mRe = new MessageReceiveEventArgs(PatchManager.JSON_COMPLETE, ""); OnMessageReceive(mRe); string[] msg = new string[3] { "", "", "" }; Debug.WriteLine("received json = " + st.getJson()); JObject response = JObject.Parse(st.getJson()); try { if (st.result().Equals(StreamModule.JSON)) /// JSON 수신 단계 (완료, 오류) { if (response.GetValue("_is_error").ToString().ToLower().Equals("true")) { string errorMsg = response.GetValue("_error_msg").ToString().Trim(); if (errorMsg.Equals("")) { msg[1] = MsgERR.ERR_ERROR + " \n" + MsgERR.ERR_RETRY; msg[2] = MsgERR.ERR_SVRERROR; } else { msg[1] = MsgERR.ERR_ERROR + " \n" + MsgERR.ERR_ASK;//"오류가 발생하였습니다. \n관리자에게 문의 바랍니다."; msg[2] = MsgERR.ERR_ERROR + " : " + HttpUtility.UrlDecode(errorMsg); } WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(true, msg[1]);//(PatchManager.JSON_COMPLETE, ""); OnWorkCompleted(wCe); } else if (response.GetValue("_is_update").ToString().ToLower().Equals("true")) { JObject xmlJson = JObject.Parse(response.GetValue("_xml_list").ToString()); PatchXMLData(xmlJson); } else if (response.GetValue("_is_maxreach").ToString().ToLower().Equals("true")) { msg[1] = MsgERR.ERR_REACHMAXCONN + "\n" + MsgERR.ERR_RETRY; //"허용된 접속자 수를 초과하였습니다.\n잠시 후 다시 시도해 주십시오."; msg[2] = MsgERR.ERR_REACHMAXCONN; WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(true, msg[1]); //(PatchManager.JSON_COMPLETE, ""); OnWorkCompleted(wCe); } else if (isFileError) { msg[1] = MsgERR.ERR_COMMIT + "\n" + MsgERR.ERR_RETASK; msg[2] = MsgERR.ERR_COMMIT; WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(true, msg[1]);//(PatchManager.JSON_COMPLETE, ""); OnWorkCompleted(wCe); } else { msg[1] = Msg.DEF_NOCHANGE; msg[2] = Msg.DEF_NOCHANGE; WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(false, msg[1]);//(PatchManager.JSON_COMPLETE, ""); OnWorkCompleted(wCe); } } else /// 파일 적용 단계 { if (isFileError) { msg[1] = MsgERR.ERR_COMMIT + "\n" + MsgERR.ERR_RETASK; msg[2] = MsgERR.ERR_COMMIT; WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(true, msg[1]);//(PatchManager.JSON_COMPLETE, ""); OnWorkCompleted(wCe); } else { WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(false, msg[1]);//(PatchManager.JSON_COMPLETE, ""); OnWorkCompleted(wCe); } } } catch (Exception e) { WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(true, e.ToString());//(PatchManager.JSON_COMPLETE, ""); OnWorkCompleted(wCe); } }
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(); } }