private void A2Send()
 {
     try
     {
         ComParameter senddata = new ComParameter {
             DataString = this.CreateA2Data()
         };
         string str = this.JobCode();
         if (this.mNextStop)
         {
             ULogClass.LogWrite(string.Format("{0}_SEND", str + "(Next Stop)"), senddata.DataString.Substring(0, 400), true);
         }
         else
         {
             ULogClass.LogWrite(string.Format("{0}_SEND", str), senddata.DataString.Substring(0, 400), true);
         }
         int num = this.mGetClient.Send(this.mOwnerControl, str + this.mSendCount.ToString(), senddata);
         if (num > 0)
         {
             ULogClass.LogWrite(string.Format("{0}_SEND Error code({1})", str, num));
             this.OnNetworkError(num, null);
             this.mIsExcute = false;
             this.ButtonLock(false);
         }
     }
     catch (Exception exception)
     {
         ULogClass.LogWrite(string.Format("{0}_SEND Error code({1})", this.JobCode(), "Exception"));
         HttpExceptionEx ex = new HttpExceptionEx(HttpStatus.Idle, HttpCause.ProgramError, exception);
         this.OnNetworkError(9, ex);
         this.mIsExcute = false;
         this.ButtonLock(false);
     }
     this.mNextStop = false;
 }
Exemple #2
0
 public static RecvData CreateRecvData(ComParameter comParameter)
 {
     RecvData data = CreateRecvData(comParameter.DataString);
     if (comParameter.AttachCount > 0)
     {
         if (data.OtherData == null)
         {
             comParameter.DeleteAttachFolder();
         }
         else
         {
             PathInfo info = PathInfo.CreateInstance();
             string path = info.AttachPath + data.OtherData.Header.OutCode.Trim() + DateTime.Now.ToString("yyyyMMddHHmmssfff");
             comParameter.CopyAttachFiles(path);
             comParameter.DeleteAttachFolder();
             comParameter.AttachFolder = path;
         }
     }
     setAttachInfo(data.ResultData, comParameter);
     setAttachInfo(data.OtherData, comParameter);
     setAttachInfo(data.MData, comParameter);
     return data;
 }
Exemple #3
0
 public MemoryStream MakeSendData(HttpWebRequest request, ComParameter senddata)
 {
     MemoryStream message = null;
     string boundaryString = MimeFormat.BoundaryString;
     if (senddata.AttachCount > 0)
     {
         message = this.mBuilder.ToMemoryStream(senddata, boundaryString, this.mTrace);
         request.SendChunked = false;
         request.ContentType = MimeFormat.MultiContentType(boundaryString);
         request.ContentLength = message.ToArray().Length;
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "MakeSendData", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
     }
     else if (!string.IsNullOrEmpty(senddata.DataString))
     {
         message = this.mBuilder.ToMemoryStream(senddata, boundaryString, this.mTrace);
         request.SendChunked = false;
         request.ContentType = MimeFormat.TextContentType(this.mBuilder.BaseCharset);
         request.ContentLength = message.ToArray().Length;
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "MakeSendData", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
     }
     if (senddata.Sign == "1")
     {
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "ConvertSMIMEstr", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
         if (this.cSMime == null)
         {
             this.cSMime = new SMimeFormat();
         }
         string header = request.ContentType.ToString();
         message = this.cSMime.ConvertSMIME(message, header, senddata.SelectSign);
         request.ContentType = string.Format("multipart/signed; micalg=\"sha1\"; boundary=\"{0}\"; protocol=\"application/x-pkcs7-signature\"", this.cSMime.GetThisBoundary);
         request.ContentLength = message.ToArray().Length;
         this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "ConvertSMIMEend", string.Format("ContentType={0} Length={1}", request.ContentType, request.ContentLength)));
     }
     return message;
 }
Exemple #4
0
 private void ReceivedResponse(ComParameter data)
 {
     if (((Control) this.mRequestSender).InvokeRequired)
     {
         ReceivedDelegate method = new ReceivedDelegate(this.ReceivedResponse);
         ((Control) this.mRequestSender).Invoke(method, new object[] { data });
     }
     else
     {
         this.mTrace.WriteString(this.mTracekind, string.Format("# {0,-16} : status[{1}]", "ReceivedResponse", this.mStatus));
         if (this.mRequestAfterAbort)
         {
             WebException wex = new WebException(Resources.ResourceManager.GetString("HTTP01"), WebExceptionStatus.RequestCanceled);
             this.mIsTimeout = false;
             this.ErrorResponse(wex, true);
         }
         else
         {
             this.OnReceived(this, this.mSendkey, data);
         }
     }
 }
 public bool Accumulate_OnReceived(ComParameter recvdata)
 {
     if (base.DisposingFlag)
     {
         base.stbReqStatus.Text = "";
         ULogClass.LogWrite("Logoff Staus = Abolished the messages and ended extraction due to logoff status.");
         return false;
     }
     if (this.acm.IsREQ)
     {
         base.stbReqStatus.Text = "RECEIVING";
     }
     else
     {
         base.stbReqStatus.Text = "RECEIVING";
     }
     if (recvdata.DataString.Length < 400)
     {
         base.stbReqStatus.Text = "";
         return true;
     }
     string str = "";
     RecvData data = new RecvData();
     try
     {
         data = DataFactory.CreateRecvData(recvdata);
     }
     catch
     {
         str = "-1";
     }
     IData mData = null;
     if (data.MData != null)
     {
         mData = data.MData;
         str = base.idv.AppendJobData(mData, 2, true, true, false);
     }
     else
     {
         if (data.ResultData != null)
         {
             base.stbReqStatus.Text = "";
             mData = data.ResultData;
             if (!mData.Header.Control.EndsWith("P"))
             {
                 ULogClass.LogWrite("INET_RECV_OTHER ", mData.GetDataString().Substring(0, 400), true);
                 return true;
             }
             str = base.idv.AppendJobData(mData, 2, true, true, false);
         }
         if (data.OtherData != null)
         {
             mData = data.OtherData;
             str = base.idv.AppendJobData(mData, 2, true, true, false);
         }
     }
     if (str == "-1")
     {
         MessageDialog dialog = new MessageDialog();
         dialog.ShowMessage("E404", "", "");
         dialog.Dispose();
         return false;
     }
     base.ReceiveNoticeMessage(mData);
     if (mData != null)
     {
         ULogClass.LogWrite("INET_RECV_OTHER ", mData.GetDataString().Substring(0, 400), true);
         try
         {
             string path = base.SaveFileCheck(mData);
             if (path != "")
             {
                 if (mData.Header.DataType == "A")
                 {
                     base.idv.AppendRecord(mData, Path.GetDirectoryName(path));
                 }
                 else
                 {
                     DataFactory.SaveToEdiFile(mData, path);
                     base.idv.SaveStatusChange(mData.ID, true);
                 }
             }
         }
         catch
         {
         }
         mData = base.ContainedSet(mData);
         base.pr.Print(this, mData.ID, mData, 2);
     }
     if (mData != null)
     {
         base.idv.Distribute(mData);
     }
     return true;
 }
 public ComParameter ToComParameter(MemoryStream mem, string boundary, NetTrace trace)
 {
     MimePart part;
     ComParameter parameter = new ComParameter();
     byte[] buffer = mem.ToArray();
     for (long i = 0L; this.GetPart(boundary, buffer, i, out part); i = part.NextOffset)
     {
         if (Encoding.ASCII.GetString(buffer, (((int) part.BodyOffset) + part.BodyLength) - 4, 4).EndsWith("\r\n\r\n"))
         {
             part.BodyLength -= 2;
         }
         ContentType ct = null;
         string str2 = null;
         ContentDisposition cd = null;
         string str3 = this.GetValue(part.HdList, "Content-type");
         if (!string.IsNullOrEmpty(str3))
         {
             ct = new ContentType(str3);
         }
         str2 = this.GetValue(part.HdList, "Content-Transfer-Encoding");
         str3 = this.GetValue(part.HdList, "Content-Disposition");
         if (!string.IsNullOrEmpty(str3))
         {
             cd = new ContentDisposition(str3);
         }
         if (MimeFormat.IsAttachment(cd))
         {
             if (string.IsNullOrEmpty(parameter.AttachFolder))
             {
                 parameter.AttachFolder = this.AttachFolder;
                 this.CreateAttachFolder(parameter.AttachFolder);
             }
             string str4 = MimeFormat.DecodeAttachFile(cd.FileName);
             if (trace != null)
             {
                 trace.WriteString(NetTrace.Tracekind.MIME, string.Format("+ {0,-16} : {1}", "ToComParameter", string.Format("AttachFilename={0} DataLength={1}{2}{3}", new object[] { str4, part.BodyLength, "\r\n", part.Header })));
             }
             if ((str2 != null) && str2.StartsWith("base64", StringComparison.CurrentCultureIgnoreCase))
             {
                 string str5 = Encoding.ASCII.GetString(buffer, (int) part.BodyOffset, part.BodyLength);
                 this.WriteAttachFile(Path.Combine(parameter.AttachFolder, str4), str5);
             }
             else
             {
                 FileStream stream = new FileStream(Path.Combine(parameter.AttachFolder, str4), FileMode.OpenOrCreate, FileAccess.Write);
                 stream.Write(buffer, (int) part.BodyOffset, part.BodyLength);
                 stream.Close();
             }
         }
         else if (MimeFormat.IsText(ct))
         {
             if (trace != null)
             {
                 trace.WriteString(NetTrace.Tracekind.MIME, string.Format("+ {0,-16} : {1}", "ToComParameter", string.Format("TextDataLength={0}{1}{2}", part.BodyLength, "\r\n", part.Header)));
             }
             if (string.IsNullOrEmpty(parameter.DataString))
             {
                 parameter.DataString = this.TextDecoding(buffer, (int) part.BodyOffset, part.BodyLength, ct.CharSet);
             }
         }
         if (part.LastPart)
         {
             return parameter;
         }
     }
     return parameter;
 }
 private void RequestSend(RequestCommand command, string outcode)
 {
     try
     {
         int num;
         if (command == RequestCommand.GET)
         {
             this.mIsExcute = true;
         }
         ComParameter senddata = new ComParameter {
             DataString = this.CreateRequestData(command, outcode)
         };
         ULogClass.LogWrite(string.Format("{0}_SEND Command({1})", this.JobCode(), command.ToString()), senddata.DataString.Substring(0, 400), true);
         if (command == RequestCommand.GET)
         {
             num = this.mGetClient.Send(this.mOwnerControl, command.ToString() + this.mSendCount.ToString(), senddata);
         }
         else
         {
             num = this.mCmdClient.Send(this.mOwnerControl, command.ToString() + this.mSendCount.ToString(), senddata);
         }
         if (num > 0)
         {
             ULogClass.LogWrite(string.Format("{0}_SEND Error code({1})", this.JobCode(), num));
             this.OnNetworkError(num, null);
             this.mIsExcute = false;
             this.ButtonLock(false);
         }
     }
     catch (Exception exception)
     {
         ULogClass.LogWrite(string.Format("{0}_SEND Error code({1})", this.JobCode(), "Exception"));
         HttpExceptionEx ex = new HttpExceptionEx(HttpStatus.Idle, HttpCause.ProgramError, exception);
         this.OnNetworkError(9, ex);
         this.mIsExcute = false;
         this.ButtonLock(false);
     }
 }
Exemple #8
0
        public ComParameter SendData(string strSendMSG)
        {
            try
            {
                this.SendMSG = strSendMSG;
                sendData = new ComParameter();
                sendData.DataString = SendMSG;
                sendData.Sign = (this.KySo == true) ? "1" : "";
                if (this.KySo == true)//set cert để ký
                {
                    X509Certificate2 storedCert =
                    CryptographyHelper.GetStoreX509Certificate2BySerial("5404287E6CC0BC4DA008B43C710C0D5A");
                    sendData.SelectSign = storedCert;

                    //test
                    RSACryptography rsaC = new RSACryptography(storedCert);

                    string strKetQuaKy = rsaC.SignHash("sdfdf");
                }

                returnParameter = null;
                allDone.Reset();

                //chống lỗi ssl
                System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

                // Create a new HttpWebRequest object.
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(st.fIPHQ);

                // Set the Method property to 'POST' to post data to the URI.
                request.Method = "POST";

                request.Credentials = CredentialCache.DefaultCredentials;
                request.KeepAlive = false;
                request.ProtocolVersion = HttpVersion.Version11;
                request.UserAgent = "NACCS Terminal Software";
                request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                request.Method = "POST";

                request.SendChunked = false;
                request.ContentType = "text/plain; charset=UTF-8";

                //Tao send data
                HttpClient h = new HttpClient();
                byteArray = h.MakeSendData(request, sendData).ToArray();

                // start the asynchronous operation
                request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);

                // Keep the main thread from continuing while the asynchronous 
                // operation completes. A real world application 
                // could do something useful such as updating its user interface. 
                allDone.WaitOne();

                string checkPoint = "";

                return returnParameter;
            }
            catch (Exception ex)
            {
                this.Show1(ex.Message, "Vui lòng liên hệ nhà cung cấp phần mềm. Hotline: 0917 863 688  (Mr. Tuyển)");
                return null;
            }
        }
Exemple #9
0
 private void ListRequest()
 {
     this.sortColumnIndex = -1;
     this.reportSortOrder = SortOrder.None;
     ComParameter data = new ComParameter();
     string mSelectOutcode = "";
     if (this.mPost)
     {
         mSelectOutcode = this.mSelectOutcode;
     }
     string body = string.Format("{0}{1}", mSelectOutcode.PadRight(7, ' '), "\r\n");
     data.DataString = this.CreateRequestData(RequestCommand.LST, body);
     string sendkey = RequestCommand.LST.ToString();
     this.RequestSend(data, sendkey, "LIST");
 }
Exemple #10
0
 private void CallbackOnGetReceived(object sender, string sendkey, ComParameter recvdata)
 {
     bool flag = false;
     bool flag2 = false;
     if (recvdata.DataString.Length < 400)
     {
         ULogClass.LogWrite(string.Format("{0}_RECV", this.JobCode()), recvdata.DataString, false);
         this.mTurnRtpinfo = "";
         this.mNextStop = false;
     }
     else
     {
         IData data = new NaccsData {
             Header = { DataString = recvdata.DataString.Substring(0, 400) }
         };
         this.mTurnRtpinfo = data.Header.RtpInfo;
         flag2 = data.Header.Control.EndsWith("P");
         flag = !flag2 && (data.Header.DataType == "R");
     }
     Stopwatch stopwatch = new Stopwatch();
     try
     {
         stopwatch.Start();
         this.mRecvOK = this.OnReceived(recvdata);
         stopwatch.Stop();
         if (flag2)
         {
             if (this.mRecvOK)
             {
                 if ((this.mA2Timeout == 0) || (stopwatch.ElapsedMilliseconds < ((this.mA2Timeout - this.mA2Delay) * 0x3e8)))
                 {
                     this.mA2tm = new System.Windows.Forms.Timer();
                     this.mA2tm.Tick += new EventHandler(this.A2Send_Tick);
                     this.mA2tm.Interval = 1;
                     if (this.mA2Delay > 0)
                     {
                         this.mA2tm.Interval = this.mA2Delay * 0x3e8;
                     }
                     this.mA2tm.Enabled = true;
                 }
                 else
                 {
                     flag2 = false;
                     ComParameter parameter = new ComParameter {
                         DataString = "A2Timeout"
                     };
                     this.OnReceived(parameter);
                     new MessageDialog().ShowMessage("E121", null);
                 }
             }
             else
             {
                 flag2 = false;
                 this.mNextStop = false;
             }
         }
         else if (flag)
         {
             flag2 = false;
             this.mNextStop = false;
             RecvData data2 = DataFactory.CreateRecvData(recvdata.DataString);
             HttpErrorDlg dlg = new HttpErrorDlg();
             dlg.ShowJobError(this.JobCode(), data2.ResultData);
             dlg.Dispose();
         }
     }
     finally
     {
         stopwatch.Reset();
         this.mIsExcute = flag2;
         this.ButtonLock(false);
     }
 }
Exemple #11
0
 private void DataSave(ComParameter recvdata, string fname, string outcode)
 {
     string dir = FileSave.CreateInstance().TypeList.getType("F").Dir;
     try
     {
         if (fname.EndsWith(".GZ", StringComparison.CurrentCultureIgnoreCase))
         {
             string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fname);
             MemoryStream stream = this.Decompress(Path.Combine(recvdata.AttachFolder, fname));
             try
             {
                 Encoding encoding = Encoding.GetEncoding("UTF-8");
                 if (fileNameWithoutExtension.EndsWith(".EDI", StringComparison.CurrentCultureIgnoreCase))
                 {
                     ComParameter parameter = new ComParameter {
                         DataString = encoding.GetString(stream.ToArray(), 0, stream.ToArray().Length)
                     };
                     this.OnReceived(parameter);
                 }
                 else
                 {
                     fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fname);
                     string str3 = this.mOutcodeTbl.Find(outcode);
                     if (!string.IsNullOrEmpty(str3))
                     {
                         fileNameWithoutExtension = string.Format("{0}{1}", str3, fileNameWithoutExtension.Substring(outcode.Length));
                     }
                     this.CreateBatchFolder(dir);
                     StreamWriter writer = new StreamWriter(Path.Combine(dir, fileNameWithoutExtension), false, Encoding.GetEncoding("UTF-8"));
                     try
                     {
                         writer.Write(encoding.GetString(stream.ToArray(), 0, stream.ToArray().Length));
                     }
                     finally
                     {
                         writer.Close();
                     }
                 }
                 return;
             }
             finally
             {
                 stream.Close();
             }
         }
         this.CreateBatchFolder(dir);
         File.Copy(Path.Combine(recvdata.AttachFolder, fname), Path.Combine(dir, fname), true);
     }
     finally
     {
         recvdata.DeleteAttachFolder();
     }
 }
Exemple #12
0
 private void GetRequest(int index)
 {
     bool flag = false;
     List<ListViewItem> list = this.ReportCheckedItems();
     for (int i = index; i < list.Count; i++)
     {
         this.mSendIndex = i;
         this.stGuide.Text = string.Format("{0:D}/{1:D}の管理資料を取り出しています。", i + 1, list.Count);
         if (string.IsNullOrEmpty(list[i].SubItems[this.clmStatus.Index].Text))
         {
             RequestCommand gTP;
             flag = true;
             string text = list[i].SubItems[this.clmFileName.Index].Text;
             string body = string.Format("{0}{1}", text.PadRight(0x80, ' '), "\r\n");
             if (this.mPost)
             {
                 gTP = RequestCommand.GTP;
             }
             else
             {
                 gTP = RequestCommand.GTN;
             }
             ComParameter data = new ComParameter {
                 DataString = this.CreateRequestData(gTP, body)
             };
             string sendkey = string.Format("{0}{1}", gTP.ToString(), i);
             this.RequestSend(data, sendkey, string.Format("GET:{0}", list[i].SubItems[this.clmOutcode.Index].Text));
             break;
         }
     }
     if (!flag)
     {
         this.mGetting = false;
         this.MenuStatusChange();
     }
 }
Exemple #13
0
 private void CallbackOnReceived(object sender, string sendkey, ComParameter recvdata)
 {
     if (sendkey.StartsWith(RequestCommand.LST.ToString()))
     {
         ULogClass.LogWrite("BATCH_RECV", recvdata.DataString.Substring(0, 400), true);
         this.SendDlgClose();
         this.View(recvdata);
         this.mGetting = false;
         this.MenuStatusChange();
     }
     else if (recvdata.AttachCount == 0)
     {
         ULogClass.LogWrite("BATCH_RECV", recvdata.DataString.Substring(0, 400), true);
         this.SendDlgClose();
         RecvData data = DataFactory.CreateRecvData(recvdata.DataString);
         if ((data.OtherData == null) && (data.ResultData.Items.Count > 0))
         {
             HttpErrorDlg dlg = new HttpErrorDlg();
             dlg.ShowJobError(data.ResultData.Header.JobCode, data.ResultData);
             dlg.Dispose();
         }
         this.mGetting = false;
         this.MenuStatusChange();
     }
     else
     {
         List<ListViewItem> list = this.ReportCheckedItems();
         list[this.mSendIndex].SubItems[this.clmStatus.Index].Text = "取得済み";
         this.lvReport.Refresh();
         string text = list[this.mSendIndex].SubItems[this.clmFileName.Index].Text;
         string outcode = list[this.mSendIndex].SubItems[this.clmOutcode.Index].Text;
         ULogClass.LogWrite(string.Format("BATCH_RECV File({0})", text));
         try
         {
             try
             {
                 this.DataSave(recvdata, text, outcode);
                 if (!this.mIsCancel)
                 {
                     System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer {
                         Interval = 10
                     };
                     timer.Tick += new EventHandler(this.GetNextFile);
                     timer.Enabled = true;
                 }
             }
             finally
             {
                 this.SendDlgClose();
             }
         }
         catch (Exception exception)
         {
             MessageDialog dialog = new MessageDialog();
             string internalCode = string.Format("{0}{1}", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo), "\r\n") + string.Format("<Exception>{0}", "\r\n");
             if (exception.Message != null)
             {
                 internalCode = internalCode + string.Format("-ExceptionMessage{1} {0}{1}{1}", exception.Message, "\r\n");
             }
             dialog.ShowMessage("E303", text, internalCode);
             this.mGetting = false;
             this.MenuStatusChange();
         }
     }
 }
Exemple #14
0
 private void View(ComParameter recvdata)
 {
     RecvData data = DataFactory.CreateRecvData(recvdata.DataString);
     if (data.OtherData == null)
     {
         if (data.ResultData.Items.Count > 0)
         {
             HttpErrorDlg dlg = new HttpErrorDlg();
             dlg.ShowJobError(data.ResultData.Header.JobCode, data.ResultData);
             dlg.Dispose();
         }
     }
     else
     {
         if (this.mReportItems == null)
         {
             this.mReportItems = new List<ListViewItem>();
         }
         else
         {
             this.mReportItems.Clear();
         }
         this.lvReport.VirtualListSize = 0;
         this.lvReport.Items.Clear();
         for (int i = 0; i < data.OtherData.Items.Count; i += 2)
         {
             string str2;
             string str3;
             string str4;
             int index = data.OtherData.Items[i].IndexOf('.');
             string path = data.OtherData.Items[i].Substring(0, index);
             if (path.Length > 7)
             {
                 str2 = path.Substring(0, 7);
             }
             else
             {
                 str2 = path;
             }
             string[] strArray = path.Split(new char[] { '_' });
             if (strArray.Length > 1)
             {
                 try
                 {
                     DateTime time;
                     string str = strArray[strArray.Length - 1].ToString();
                     if (DateTime.TryParseExact(this.getDivFormConv(str, "____/__/__ __:__:__", ' '), "yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out time))
                     {
                         str3 = time.ToString();
                     }
                     else
                     {
                         str3 = "__/__/____ __:__:__";
                     }
                 }
                 catch
                 {
                     str3 = strArray[1];
                 }
             }
             else
             {
                 str3 = "";
             }
             if ((i + 1) < data.OtherData.Items.Count)
             {
                 try
                 {
                     long num3 = 0L;
                     num3 = long.Parse(data.OtherData.Items[i + 1].Trim());
                     str4 = string.Format("{0:n0}", Math.Ceiling((double) (((double) num3) / 1024.0)));
                 }
                 catch
                 {
                     str4 = data.OtherData.Items[i + 1].Trim();
                 }
             }
             else
             {
                 str4 = "";
             }
             string fileName = this.mOutcodeTbl.Find(str2);
             if (string.IsNullOrEmpty(fileName))
             {
                 fileName = Path.GetFileName(path);
             }
             ListViewItem item = new ListViewItem(fileName);
             item.SubItems.Add(str2);
             item.SubItems.Add(str3);
             item.SubItems.Add(str4);
             item.SubItems.Add("");
             item.SubItems.Add(data.OtherData.Items[i].Trim());
             this.mReportItems.Add(item);
         }
         if (this.mReportItems.Count > 0)
         {
             this.mReportItems.Sort(new Comparison<ListViewItem>(this.DefaultCompareItem));
             this.lvReport.VirtualListSize = this.mReportItems.Count;
             this.AllCheck();
         }
         else
         {
             this.MenuStatusChange();
         }
     }
 }
Exemple #15
0
        private void GetResponseCallback(IAsyncResult asynchronousResult)
        {
            //chống lỗi ssl
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;

            // End the operation
            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
            Stream streamResponse = response.GetResponseStream();

            StreamReader streamRead = new StreamReader(streamResponse);

            ComParamBuilder mBuilder = new ComParamBuilder();
            mBuilder.BaseCharset = "UTF-8";

            MemoryStream sMIMEmessage = mBuilder.ReadToMemory(streamResponse);
            returnParameter = mBuilder.ToTextComParameter(sMIMEmessage, "UTF-8");

            string responseString = streamRead.ReadToEnd();
            Console.WriteLine(responseString);
            //lblMSG.Text = responseString;
            //Literal1.Text = responseString;

            // Close the stream object
            streamResponse.Close();
            streamRead.Close();

            // Release the HttpWebResponse
            response.Close();
            allDone.Set();
        }
Exemple #16
0
 public int Send(object sender, string key, ComParameter senddata)
 {
     this.TraceSet();
     this.mTrace.WriteString(NetTrace.Tracekind.START, null);
     this.mTrace.WriteString(this.mTracekind, string.Format("{0} key[{1}]", string.Format("# {0,-16} : status[{1}]", "Send Request", this.mStatus), key));
     if (this.mRequestBeforAbort)
     {
         this.Status = HttpStatus.Idle;
         return -1;
     }
     if (this.mStatus != HttpStatus.Idle)
     {
         for (int i = 0; i < this.RetryCount; i++)
         {
             this.mTrace.WriteString(this.mTracekind, string.Format("{0} key[{1}]", string.Format("# {0,-16} : status[{1}]", "Send Wait", this.mStatus), key));
             Thread.Sleep(this.RetryWaitTimer);
             if (this.mStatus == HttpStatus.Idle)
             {
                 this.mTrace.WriteString(this.mTracekind, string.Format("{0} key[{1}]", string.Format("# {0,-16} : status[{1}]", "Send Retry", this.mStatus), key));
                 break;
             }
         }
     }
     HttpResult result = this.HttpRequest(sender, key, this.mSettings.UriString, senddata);
     if (result != HttpResult.None)
     {
         this.Status = HttpStatus.Idle;
         this.mTrace.WriteString(this.mTracekind, string.Format("{0} key[{1}]", string.Format("- {0,-16} : error[{1}]", "Send Request", result), key));
     }
     return (int) result;
 }
Exemple #17
0
 private void RequestSend(ComParameter data, string sendkey, string msg)
 {
     try
     {
         this.SendDlgShow(msg);
         ULogClass.LogWrite(string.Format("BATCH_SEND Command({0})", msg), data.DataString.Substring(0, 400), true);
         int num = this.mHttpClient.Send(this.mOwnerControl, sendkey, data);
         if (num > 0)
         {
             ULogClass.LogWrite(string.Format("BATCH_SEND Error code({0})", num));
             this.SendDlgClose();
             HttpErrorDlg dlg = new HttpErrorDlg();
             dlg.ShowSendError(num);
             dlg.Dispose();
             this.mGetting = false;
             this.MenuStatusChange();
         }
     }
     catch
     {
         this.SendDlgClose();
         HttpErrorDlg dlg2 = new HttpErrorDlg();
         dlg2.ShowSendError(9);
         dlg2.Dispose();
         this.mGetting = false;
         this.MenuStatusChange();
     }
 }
Exemple #18
0
 private void CallbackOnCmdReceived(object sender, string sendkey, ComParameter recvdata)
 {
     if (recvdata.DataString.Length < 400)
     {
         ULogClass.LogWrite(string.Format("{0}_RECV", this.JobCode()), recvdata.DataString, false);
         this.mIsExcute = false;
     }
     else
     {
         ULogClass.LogWrite(string.Format("{0}_RECV", this.JobCode()), recvdata.DataString.Substring(0, 400), true);
         if (sendkey.StartsWith(RequestCommand.REF.ToString()))
         {
             this.RefResponce(recvdata);
         }
     }
     this.ButtonLock(false);
 }
 public bool Logon_AtOnce_OnReceived(ComParameter recvdata)
 {
     bool flag;
     try
     {
         if (recvdata.DataString.Length < 400)
         {
             base.stbRepStatus.Text = "";
             this.LogonEnd();
             if (this.LogonSendFlag)
             {
                 System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer {
                     Interval = 10
                 };
                 timer.Tick += new EventHandler(this.tm_TickSend);
                 timer.Enabled = true;
             }
             return true;
         }
         base.UserCode = "";
         base.UserPassword = "";
         base.StatusChange(0);
         base.UserCodeJobSet("");
         flag = false;
     }
     finally
     {
         base.Enabled = true;
         if (this.Logonsender != null)
         {
             ((CommonJobForm) this.Logonsender).Enabled = true;
         }
         this.SendRecvDlgHide();
         this.LogonSendFlag = false;
     }
     return flag;
 }
Exemple #20
0
 private void RefResponce(ComParameter recvdata)
 {
     RecvData data = DataFactory.CreateRecvData(recvdata.DataString);
     if (data.OtherData == null)
     {
         HttpErrorDlg dlg = new HttpErrorDlg();
         dlg.ShowJobError(this.JobCode(), data.ResultData);
         dlg.Dispose();
     }
     else
     {
         string text = null;
         if (this.lvList.SelectedItems.Count > 0)
         {
             text = this.lvList.SelectedItems[0].Text;
         }
         this.lvList.Items.Clear();
         int num = 0;
         for (int i = 1; i < data.OtherData.ItemCount; i += 2)
         {
             int num2;
             ListViewItem item = new ListViewItem {
                 Text = data.OtherData.Items[i]
             };
             if (!string.IsNullOrEmpty(text) && (text == item.Text))
             {
                 item.Selected = true;
             }
             try
             {
                 num2 = int.Parse(data.OtherData.Items[i + 1].Trim());
             }
             catch
             {
                 num2 = 0;
             }
             num += num2;
             item.SubItems.Add(string.Format("{0:n0}", num2));
             this.lvList.Items.Add(item);
         }
         this.lblTotal.Text = string.Format("Tổng hạng mục: {0:n0}", num);
     }
 }
 private bool BatchDoc_OnReceived(ComParameter recvdata)
 {
     if (recvdata.DataString.Length >= 400)
     {
         string str = "";
         RecvData data = new RecvData();
         try
         {
             data = DataFactory.CreateRecvData(recvdata);
         }
         catch
         {
             str = "-1";
         }
         IData mData = null;
         if (data.MData != null)
         {
             mData = data.MData;
             str = base.idv.AppendJobData(mData, 2, true, true, false);
         }
         else
         {
             if (data.ResultData != null)
             {
                 mData = data.ResultData;
                 str = base.idv.AppendJobData(mData, 2, true, true, false);
             }
             if (data.OtherData != null)
             {
                 mData = data.OtherData;
                 str = base.idv.AppendJobData(mData, 2, true, true, false);
             }
         }
         if (mData != null)
         {
             ULogClass.LogWrite("INET_RECV_OTHER ", mData.GetDataString().Substring(0, 400), true);
             try
             {
                 string fileName = base.SaveFileCheck(mData);
                 if (fileName != "")
                 {
                     DataFactory.SaveToEdiFile(mData, fileName);
                     base.idv.SaveStatusChange(mData.ID, true);
                 }
             }
             catch
             {
             }
             mData = base.ContainedSet(mData);
             base.pr.Print(this, mData.ID, mData, 2);
         }
         if (mData != null)
         {
             base.idv.Distribute(mData);
         }
         if (str == "-1")
         {
             MessageDialog dialog = new MessageDialog();
             dialog.ShowMessage("E404", "", "");
             dialog.Dispose();
         }
     }
     return true;
 }
Exemple #22
0
 private void NoticeDlgCancel()
 {
     this.mIsExcute = false;
     ComParameter recvdata = new ComParameter {
         DataString = "DialogCancel"
     };
     this.OnReceived(recvdata);
 }
 public MemoryStream ToMemoryStream(ComParameter data, string boundary, NetTrace trace)
 {
     byte[] bytes = Encoding.ASCII.GetBytes("\r\n");
     MemoryStream stream = new MemoryStream();
     bool flag = data.AttachCount > 0;
     if (!string.IsNullOrEmpty(data.DataString))
     {
         string str = MimeFormat.TextPart(boundary, this.BaseCharset);
         MemoryStream stream2 = this.TextEncoding(data.DataString);
         try
         {
             if (flag)
             {
                 if (trace != null)
                 {
                     trace.WriteString(NetTrace.Tracekind.MIME, string.Format("+ {0,-16} : {1}", "ToMemoryStream", string.Format("TextDataLength={0}{1}{2}", stream2.ToArray().Length, "\r\n", str)));
                 }
                 byte[] buffer = Encoding.ASCII.GetBytes(str);
                 stream.Write(buffer, 0, buffer.Length);
             }
             stream.Write(stream2.ToArray(), 0, stream2.ToArray().Length);
         }
         finally
         {
             stream2.Close();
         }
     }
     foreach (string str2 in data.AttachFiles)
     {
         if (stream.ToArray().Length > 0)
         {
             stream.Write(bytes, 0, bytes.Length);
         }
         string path = Path.Combine(data.AttachFolder, str2);
         string s = MimeFormat.AttachtPart(path, boundary);
         string str5 = this.ReadAttachFile(path) + "\r\n";
         byte[] buffer3 = this.BaseEncoding.GetBytes(str5);
         if (trace != null)
         {
             trace.WriteString(NetTrace.Tracekind.MIME, string.Format("+ {0,-16} : {1}", "ToMemoryStream", string.Format("AttachFilename={0} DataLength={1}{2}{3}", new object[] { str2, buffer3.Length, "\r\n", s })));
         }
         byte[] buffer4 = Encoding.ASCII.GetBytes(s);
         stream.Write(buffer4, 0, buffer4.Length);
         stream.Write(buffer3, 0, buffer3.Length);
     }
     if (flag)
     {
         stream.Write(bytes, 0, bytes.Length);
         byte[] buffer5 = Encoding.ASCII.GetBytes(MimeFormat.LastPart(boundary));
         stream.Write(buffer5, 0, buffer5.Length);
     }
     return stream;
 }
 private void OnSend(object sender, IData Data)
 {
     if (base.ComStatus == 1)
     {
         this.sendjobsender = sender;
         if (Data.Signflg == 1)
         {
             if (this.CA == null)
             {
                 this.CA = new SignaturesCert();
             }
             try
             {
                 IntPtr handle;
                 if (sender == null)
                 {
                     handle = base.Handle;
                 }
                 else
                 {
                     handle = ((Form) sender).Handle;
                 }
                 this.CA.GetSigneture(handle);
             }
             catch (Exception exception)
             {
                 new MessageDialog().ShowMessage("E124", MessageDialog.CreateExceptionMessage(exception));
                 base.StatusChange(1);
                 base.Enabled = true;
                 this.SendRecvDlgHide();
                 return;
             }
         }
         this.SendRecvDlgShow(1);
         if (this.bSendFlag)
         {
             base.frmSendRecv.lblSendJobCode.Text = Data.JobCode + " " + this.SendCount.ToString() + "/" + this.SendAllCount.ToString();
         }
         else
         {
             base.frmSendRecv.lblSendJobCode.Text = Data.JobCode;
         }
         base.Enabled = false;
         ComParameter senddata = new ComParameter();
         Data = base.SendDataCreate(Data, 0);
         senddata.DataString = Data.GetDataString();
         senddata.AttachFolder = Data.AttachFolder;
         if (Data.Signflg == 1)
         {
             senddata.SelectSign = this.CA.Cert;
             senddata.Sign = Data.Signflg.ToString();
         }
         base.StatusChange(2);
         string iD = Data.ID;
         if (!this.bSendFlag)
         {
             if (Data.ID == null)
             {
                 iD = base.idv.AppendJobData(Data, 0, false, false, false);
             }
             else
             {
                 iD = base.idv.UpdateJobData(Data);
             }
         }
         else
         {
             iD = base.idv.UpdateJobData(Data);
         }
         if (base.sysenv.TerminalInfo.Debug)
         {
             ULogClass.LogWrite("INET_SEND ", Data.GetDataString(), false);
         }
         else
         {
             ULogClass.LogWrite("INET_SEND ", Data.GetDataString().Substring(0, 400), true);
         }
         this.ConnectFlag = true;
         int errcode = this.ihc.Send(this, iD, senddata);
         if (errcode > 0)
         {
             HttpErrorDlg dlg = new HttpErrorDlg();
             base.StatusChange(1);
             base.Enabled = true;
             this.SendRecvDlgHide();
             dlg.ShowSendError(errcode);
             ULogClass.LogWrite("SendError Status=" + System.Enum.GetNames(typeof(HttpResult))[errcode].ToString());
             dlg.Dispose();
         }
         else if (errcode < 0)
         {
             base.StatusChange(1);
             base.Enabled = true;
             this.SendRecvDlgHide();
             ULogClass.LogWrite("User Cancel StatusCode = " + errcode.ToString());
             if (this.bSendFlag)
             {
                 if (base.BatchSendFlag)
                 {
                     base.BatchSendFlag = false;
                     MessageDialog dialog2 = new MessageDialog();
                     if (dialog2.ShowMessage("I104", base.SendReportDlg.StatusCount(USendReportDlg.ReportStatus.Sent).ToString(), "") == DialogResult.Yes)
                     {
                         base.SendReportDlg.Show();
                     }
                     dialog2.Dispose();
                 }
                 this.bSendFlag = false;
             }
         }
     }
 }
Exemple #25
0
 private static void setAttachInfo(IData data, ComParameter comParameter)
 {
     if ((data != null) && (comParameter.AttachCount > 0))
     {
         data.AttachFolder = "";
         if ((data.Header.DataType == "C") || (data.Header.DataType == "M"))
         {
             data.AttachFolder = comParameter.AttachFolder;
             data.AttachCount = comParameter.AttachCount;
         }
         data.Status = DataStatus.Recept;
         data.Contained = ContainedType.ReceiveOnly;
     }
     if ((data != null) && (comParameter.Sign == "1"))
     {
         data.Signflg = int.Parse(comParameter.Sign);
         data.SignFileFolder = "";
         PathInfo info = PathInfo.CreateInstance();
         DirectoryInfo info2 = new DirectoryInfo(info.SignFilePath);
         if (!info2.Exists)
         {
             info2.Create();
         }
         string path = info.SignFilePath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "chk.txt";
         StreamWriter writer = null;
         try
         {
             writer = new StreamWriter(path);
             writer.Write(comParameter.SignFile);
         }
         finally
         {
             writer.Close();
         }
         data.SignFileFolder = path;
     }
 }
 private void Http_OnReceived(object sender, string sendkey, ComParameter dt)
 {
     string[,] strArray = new string[,] { { "High security alert", "E123" }, { "Verification GW Error", "E134" }, { "Message Format GW Error", "E135" } };
     ULogClass.LogWrite(string.Format("INET_RECV_START Length={0} AttachCount={1}", dt.DataString.Length, dt.AttachCount), null, false);
     this.ConnectFlag = false;
     base.idv.SendStatusChange(sendkey);
     for (int i = 0; i < strArray.GetLength(0); i++)
     {
         if ((dt.DataString.IndexOf(Environment.NewLine) != 0x18e) && dt.DataString.Contains(strArray[i, 0]))
         {
             base.StatusChange(1);
             if (!this.bSendFlag)
             {
                 base.Enabled = true;
                 this.SendRecvDlgHide();
             }
             MessageDialog dialog = new MessageDialog();
             dialog.ShowMessage(strArray[i, 1].ToString(), "", dt.DataString);
             dialog.Dispose();
             if (strArray[i, 0] == "Verification GW Error")
             {
                 this.CA = null;
             }
             return;
         }
     }
     if (dt.DataString.Length < 400)
     {
         dt.DataString = base.ErrCreate(dt.DataString);
     }
     RecvData recvdata = DataFactory.CreateRecvData(dt);
     IData data = null;
     IData data3 = null;
     IData data4 = null;
     string str = "-1";
     if (recvdata.MData != null)
     {
         data = recvdata.ResultData;
         if (base.usrenv.InteractiveInfo.JobConnect && (data.JobData.Substring(0, 15) == "00000-0000-0000"))
         {
             this.RepSend(1);
         }
         data = recvdata.MData;
         str = base.idv.AppendJobData(data, 2, false, true, false);
     }
     else
     {
         if (recvdata.ResultData != null)
         {
             data = recvdata.ResultData;
             if (base.usrenv.InteractiveInfo.JobConnect && (data.JobData.Substring(0, 15) == "00000-0000-0000"))
             {
                 this.RepSend(1);
             }
             str = base.idv.AppendJobData(data, 2, false, true, false);
             data3 = data;
         }
         if (recvdata.OtherData != null)
         {
             data = recvdata.OtherData;
             str = base.idv.AppendJobData(data, 2, false, true, false);
             data4 = data;
         }
     }
     ULogClass.LogWrite(string.Format("INET_RECV_DB_APPEND Key={0}", str), null, false);
     base.StatusChange(1);
     if (!this.bSendFlag)
     {
         base.Enabled = true;
         this.SendRecvDlgHide();
     }
     if (this.DateCheckFlag)
     {
         try
         {
             string s = data.Header.ServerRecvTime.ToString().Trim().PadRight(14, '0');
             string format = "yyyyMMddHHmmss";
             DateTime time = DateTime.ParseExact(s, format, null);
             DateTime now = DateTime.Now;
             TimeSpan span = (TimeSpan) (now - time);
             if ((-5.0 > span.TotalMinutes) || (5.0 < span.TotalMinutes))
             {
                 MessageDialog dialog2 = new MessageDialog();
                 dialog2.ShowMessage("W001", "Server's Time : " + time.ToString("dd/MM/yyyy HH:mm:ss", DateTimeFormatInfo.InvariantInfo) + Environment.NewLine + "PC's time : " + now.ToString("dd/MM/yyyy HH:mm:ss", DateTimeFormatInfo.InvariantInfo) + Environment.NewLine + Environment.NewLine, "");
                 dialog2.Dispose();
             }
         }
         catch
         {
         }
         this.DateCheckFlag = false;
     }
     if (!this.bSendFlag)
     {
         bool flag = false;
         if (base.sysenv.TerminalInfo.UserKind == 4)
         {
             KioskLink link = new KioskLink(recvdata);
             IData data5 = link.CreateLinkData();
             if (data5 != null)
             {
                 flag = true;
                 if (this.sendjobsender != null)
                 {
                     ((JobForm) this.sendjobsender).Close();
                 }
                 this.KioskLinkData = new _KioskLinkData();
                 this.KioskLinkData.Data = data5;
                 this.KioskLinkData.Data.Header.System = this.KioskLinkSystem;
                 this.KioskLinkData.File = link.LinkFile;
                 this.KioskLinkData.No = 1;
                 System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer {
                     Interval = 10
                 };
                 timer.Tick += new EventHandler(this.KioskLink_Tick);
                 timer.Enabled = true;
             }
         }
         if (!flag)
         {
             base.JobFormOpen(int.Parse(str), data, this.sendjobsender);
         }
     }
     if (data4 != null)
     {
         ULogClass.LogWrite("INET_RECV_OTHER ", data4.GetDataString().Substring(0, 400), true);
         try
         {
             string path = base.SaveFileCheck(data4);
             if (path != "")
             {
                 if (data4.Header.DataType == "A")
                 {
                     base.idv.AppendRecord(data4, Path.GetDirectoryName(path));
                 }
                 else
                 {
                     DataFactory.SaveToEdiFile(data4, path);
                     base.idv.SaveStatusChange(data4.ID, false);
                 }
             }
         }
         catch
         {
         }
         data4 = base.ContainedSet(data4);
         base.pr.Print(this, data4.ID, data4, 2);
     }
     if (data3 != null)
     {
         ULogClass.LogWrite("INET_RECV_RESULT ", data3.GetDataString().Substring(0, 400), true);
         try
         {
             string fileName = base.SaveFileCheck(data3);
             if (fileName != "")
             {
                 DataFactory.SaveToEdiFile(data3, fileName);
                 base.idv.SaveStatusChange(data3.ID, false);
             }
         }
         catch
         {
         }
     }
     if (((data3 == null) && (data4 == null)) && (data != null))
     {
         ULogClass.LogWrite("INET_RECV_MDATA ", data.GetDataString().Substring(0, 400), true);
         try
         {
             string str6 = base.SaveFileCheck(data);
             if (str6 != "")
             {
                 DataFactory.SaveToEdiFile(data, str6);
                 base.idv.SaveStatusChange(data.ID, false);
             }
         }
         catch
         {
         }
         RecvData data6 = DataFactory.CreateRecvData(data);
         data6.OtherData = base.ContainedSet(data6.OtherData);
         base.pr.Print(this, data.ID, data6.OtherData, 2);
     }
     if (data4 != null)
     {
         base.idv.Distribute(data4);
     }
     if (data3 != null)
     {
         base.idv.Distribute(data3);
     }
     if (((data3 == null) && (data4 == null)) && (data != null))
     {
         base.idv.Distribute(data);
     }
     base.idv.DataViewSaveRepaint();
     if (this.bSendFlag && !this.cancelflag)
     {
         ULogClass.LogWrite("INET_RECV_END NextSend", null, false);
         base.SendReportDlg.SetStatus(sendkey, USendReportDlg.ReportStatus.Sent, "");
         System.Windows.Forms.Timer timer2 = new System.Windows.Forms.Timer {
             Interval = 10
         };
         timer2.Tick += new EventHandler(this.tm_Tick);
         timer2.Enabled = true;
     }
     else
     {
         ULogClass.LogWrite("INET_RECV_END", null, false);
     }
 }
Exemple #27
0
 protected HttpResult HttpRequest(object sender, string key, string uri, ComParameter senddata)
 {
     this.mTrace.WriteString(this.mTracekind, string.Format("# {0,-16} : status[{1}]", "HttpRequest", this.mStatus));
     if (this.mStatus != HttpStatus.Idle)
     {
         return HttpResult.StatusError;
     }
     this.mRequestAfterAbort = false;
     this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "HttpRequest", string.Format("key={0} uri={1}", key, uri)));
     this.mRequestSender = sender;
     this.mSendkey = key;
     this.mSenddata = senddata;
     try
     {
         if (string.IsNullOrEmpty(uri))
         {
             this.mTrace.WriteString(this.mTracekind, string.Format("- {0,-16} : error[{1}]", "HttpRequest", HttpResult.UriError));
             return HttpResult.UriError;
         }
         this.mRequest = (HttpWebRequest) WebRequest.Create(uri);
         try
         {
             this.mRequest.Credentials = CredentialCache.DefaultCredentials;
         }
         catch (Exception exception)
         {
             this.mTrace.WriteString(this.mTracekind, string.Format("+ {0,-16} : {1}", "HttpRequest", "Credentials Set Warning"));
             this.mTrace.WriteString(this.mTracekind, string.Format("! {0,-16} : {1} \r\n{2}", "HttpRequest", exception.GetType(), exception.Message));
         }
         this.mRequest.KeepAlive = this.mSettings.KeepAlive;
         this.mRequest.ProtocolVersion = this.mSettings.ProtocolVersion;
         this.mRequest.UserAgent = this.DefUserAgent;
         this.mRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
         HttpResult result = this.SetProxy();
         if (result != HttpResult.None)
         {
             return result;
         }
         result = this.SetClientCert();
         if (result != HttpResult.None)
         {
             return result;
         }
         this.Status = HttpStatus.RequestWait;
         new Thread(new ThreadStart(this.DoRequest)) { Name = "通信スレッド(" + this.mSendkey + ")", IsBackground = true }.Start();
     }
     catch (Exception exception2)
     {
         this.mTrace.WriteString(this.mTracekind, string.Format("! {0,-16} : {1} \r\n{2}", "HttpRequest", exception2.GetType(), exception2.Message));
         return HttpResult.ProgramError;
     }
     return HttpResult.None;
 }
Exemple #28
0
        private void XuLyTraVe(ComParameter recvdata)
        {
            bool flag = false;
            bool flag2 = false;
            if (recvdata.DataString.Length < 400)
            {
                if (recvdata.DataString.Equals("LOGON OK"))
                {
                    ////LOGON OK
                    //lblMSG.Text = string.Format("Đăng nhập thành công. Hệ thống thông báo: {0}", recvdata.DataString);
                    
                }
                else//case này Chưa xác định được nội dung là gì
                {
                    //lblMSG.Text = string.Format("Hệ thống thông báo: {0}", recvdata.DataString);
                    //ModalPopupExtender.Show();
                }
            }
            else
            {
                IData data = new NaccsData
                {
                    Header = { DataString = recvdata.DataString.Substring(0, 400) }
                };

                flag = data.Header.Control.EndsWith("P");
                flag2 = (!flag) && (data.Header.DataType == "R");
            }

            try
            {
                if (flag)
                {

                }
                else if (flag2)
                {
                    flag = false;

                    RecvData data2 = DataFactory.CreateRecvData(recvdata.DataString);
                    //HttpErrorDlg dlg = new HttpErrorDlg();
                    //dlg.ShowJobError(this.JobCode(), data2.ResultData);
                    IData resultData = data2.ResultData;
                    int length = 15;
                    if (resultData.Items[0].Length < 15)
                    {
                        length = resultData.Items[0].Length;
                    }
                    string resultCode = resultData.Items[0].Substring(0, length).ToUpper();
                    string jobCodeForReturn = this.jobCode;
                    string messageCode = resultCode.Substring(0, 5);

                    XmlDocument document = new XmlDocument();

                    if (messageCode.IndexOf('A') == 0)//Kiểu lỗi hệ thống thì sử dụng file help kiểu hệ thống
                    {
                        jobCodeForReturn = "SYS";
                        string strSysHelpFile = Path.Combine(Application.StartupPath, string.Format(@"App_LocalResources\Help\gym_err\{0}_err.xml", jobCodeForReturn));
                        document.Load(strSysHelpFile);
                    }
                    else
                    {
                        document.Load(strHelpFile);
                    }                   
                    
                    XmlNode node = document.SelectSingleNode("//response[@code='" + messageCode + "']");

                    string strName = node.Attributes["name"].Value;
                    string strID = node.Attributes["id"].Value;
                    //this.txbMessageCode.Text = messageCode;
                    string strDesc = node.SelectSingleNode("description").InnerText;
                    
                    string strDisposition = node.SelectSingleNode("disposition").InnerText;//cách khắc phục


                    #region Lưu thông điệp trả về
                    THONGDIEP receiveTD = new THONGDIEP();
                    receiveTD.TD_CACHKHACPHUC = strDisposition;
                    receiveTD.TD_COKETTHUC = resultData.Header.EndFlag.Trim();
                    receiveTD.TD_DINHDANG = resultData.Header.Pattern.Trim();
                    receiveTD.TD_LOAITD = resultData.Header.DataType.Trim();
                    receiveTD.TD_MANV = resultData.JobCode.Trim();
                    receiveTD.TD_MATD = resultData.OutCode.Trim();
                    receiveTD.TD_MESSSAGECODE = messageCode;
                    receiveTD.TD_MOTALOI = strDesc;
                    receiveTD.TD_RETURNCODE = resultCode;
                    receiveTD.TD_TENCHITIEU = strName;
                    receiveTD.TD_TENNV = this.jobTitle;
                    receiveTD.TD_THOIGIAN = DateTime.Now;
                    if (((resultData.Header.DataType == "R") || (resultData.Header.DataType == "M")) || (resultData.Header.DataType == "U"))
                    {
                        receiveTD.TD_TIEUDE = resultData.Header.Subject.Remove(0, 0x10).Trim();
                    }
                    else
                    {
                        receiveTD.TD_TIEUDE = resultData.Header.Subject.Trim();
                    }                   
                    receiveTD.TD_TRANGTHAI = (int)TrangThaiThongDiep.Nhan;
                    receiveTD.TD_CONTENT = recvdata.DataString;
                    using (tDBContext mainDB = new tDBContext())
                    {
                        string strMaxID = mainDB.THONGDIEPs.Max("TD_ID");
                        if(string.IsNullOrEmpty(strMaxID))strMaxID="0";
                        receiveTD.TD_ID = Convert.ToInt32(strMaxID) + 1;
                        mainDB.THONGDIEPs.InsertOnSubmit(receiveTD);
                        mainDB.SubmitAllChange();
                    }
                    #endregion
                    
                    this.Show1(strDesc, strDisposition);
                }
            }
            finally
            {

            }
        }
 public ComParameter ToAttachComParameter(MemoryStream mem, string name, string trans)
 {
     ComParameter parameter = new ComParameter {
         AttachFolder = this.AttachFolder
     };
     this.CreateAttachFolder(parameter.AttachFolder);
     if ((trans != null) && trans.StartsWith("base64", StringComparison.CurrentCultureIgnoreCase))
     {
         string str = Encoding.ASCII.GetString(mem.ToArray());
         this.WriteAttachFile(Path.Combine(parameter.AttachFolder, name), str);
         return parameter;
     }
     FileStream stream = new FileStream(Path.Combine(parameter.AttachFolder, name), FileMode.OpenOrCreate, FileAccess.Write);
     stream.Write(mem.ToArray(), 0, mem.ToArray().Length);
     stream.Close();
     return parameter;
 }