Ejemplo n.º 1
0
 protected virtual void OnWorkCompleted(WorkCompletedEventArgs e)
 {
     if (WorkCompletedEvent != null)
     {
         WorkCompletedEvent(this, e);
     }
 }
Ejemplo n.º 2
0
        private void PatchXMLData(JObject xmlJson)
        {
            //WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(false, "");
            //OnWorkCompleted(wCe);


            Boolean isUpdateProcessed          = false;
            Dictionary <string, string> dicXml = JsonConvert.DeserializeObject <Dictionary <string, string> >(xmlJson.ToString());

            foreach (KeyValuePair <string, string> value in dicXml)
            {
                XmlDocument xdClient = new XmlDocument();
                XmlDocument xdServer = new XmlDocument();
                try
                {
                    Boolean isUpdate = false;
                    Debug.WriteLine("Load : " + strDestPath + value.Key);
                    xdClient.Load(strDestPath + value.Key);
                    Debug.WriteLine("Load Complete");
                    Debug.WriteLine("Server XML : " + value.Value);
                    String xml = value.Value;
                    //String xml = HttpUtility.UrlDecode(value.Value, Encoding.UTF8);
                    xdServer.LoadXml(xml.TrimStart());

                    isUpdate = syncDiffData(xdClient.DocumentElement, xdServer.DocumentElement, ref xdClient, ref xdServer);
                    if (isUpdate)
                    {
                        ConfApplyEventArgs cAe = new ConfApplyEventArgs(false, strDestPath + value.Key);
                        OnConfApply(cAe);
                        isUpdateProcessed = true;
                    }
                    Debug.WriteLine("Save : " + strDestPath + value.Key);
                    xdClient.Save(strDestPath + value.Key);
                    Debug.WriteLine("Save Complete");
                }
                catch (Exception e)
                {
                    Debug.WriteLine("An error has occured : " + e.ToString());
                    continue;
                }
            }
            if (isUpdateProcessed)
            {
                ConfApplyCompletedEventArgs cCe = new ConfApplyCompletedEventArgs(false, "");
                OnConfApplyCompleted(cCe);
            }
            else
            {
                WorkCompletedEventArgs wCe = new WorkCompletedEventArgs(false, "");
                OnWorkCompleted(wCe);
            }
        }
Ejemplo n.º 3
0
        void workComplete(object sender, WorkCompletedEventArgs e)
        {
            Debug.WriteLine("WorkCompletedEvent");
            string result = "";

            if (!e.isError)
            {
                SetLbStatusText(MsgForm.COMPLETEUP);
                result = Msg.DEF_SETCOMPLETE + ".\n" + Msg.DEF_RESTART;
            }
            else
            {
                SetLbStatusText(MsgForm.PROBLEM);
                picStatus.Image = Properties.Resources.ERROR;
                if (e.errorMsg.Trim().Equals(""))
                {
                    result = MsgERR.ERR_RUN + "\n" + Msg.DEF_RESTART;
                }
                else
                {
                    result = e.errorMsg;
                }
            }
            MessageBox.Show(result);//.Temp.ToString());
            if (e.isError)
            {
                sbLog.AppendLine(System.DateTime.Today.ToString() + " - " + e.errorMsg);
            }
            sbLog.AppendLine(System.DateTime.Today.ToString() + " - " + Msg.DEF_PROCCOMPLETE);
            SetbtnFuncClickEvent(btnFunc_Click, false);
            SetbtnFuncClickEvent(btnFunc_Click_Cancel, false);
            SetbtnFuncEnabled(true);
            SetbtnFuncText(MsgForm.CLOSE);
            SetbtnFuncClickEvent(btnFunc_Click_Exit, true);
            setLbLogText(MsgForm.LOG);
        }
Ejemplo n.º 4
0
        /// <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);
            }
        }
Ejemplo n.º 5
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();
            }
        }