public bool CheckCimResult(PostInfo info)
 {
     try
     {
         if (ReceiveHelper.CheckResult(info.correlationID, out bool value))
         {
             if (value)
             {
                 //CIM返回结果是有效
                 //TODO
                 //通知plc可继续运行
                 SetCimResult[(int)info.type]("获取" + info.type.ToString() + "返回结果OK", false);
                 SendCIMResult(info.type, OK);
             }
             else
             {
                 //返回结果无效
                 //TODO
                 //通知plc抛料
                 ShowAlarm(xmlParser.GetErrorMsg());
                 SetCimResult[(int)info.type]("获取" + info.type.ToString() + "返回结果NG", true);
                 SendCIMResult(info.type, NG);
             }
             return(true);
         }
         //TODO返回结果超时
         return(false);
     }
     catch (Exception ex)
     {
         Log.L_I.WriteError("CIM", ex);
         return(false);
     }
 }
Exemplo n.º 2
0
        public override MailModel GetMail(Int32 index)
        {
            String uid = Instruction.UIDLResponse(index).Split(' ')[2];

            response = Instruction.RETRResponse(index);

            System.Text.StringBuilder headSb = new System.Text.StringBuilder();
            while (true)
            {
                response = Instruction.ReadResponse();
                if (response == emptyBoundary)
                {
                    break;
                }
                else
                {
                    headSb.AppendLine(response);
                }
            }
            System.Text.StringBuilder bodySb = new System.Text.StringBuilder();
            while (true)
            {
                response = Instruction.ReadResponse();
                if (response == pointBoundary)
                {
                    break;
                }
                else
                {
                    bodySb.AppendLine(response);
                }
            }
            return(ReceiveHelper.GetMail(uid, headSb.ToString(), bodySb.ToString()));
        }
        public HttpResponseMessageBuilder(int bufferSize, CookieContainer cookies = null, Uri uri = null)
        {
            this.bufferSize = bufferSize;
            this.cookies    = cookies;
            this.uri        = uri;

            receiveHelper = new ReceiveHelper(bufferSize);
        }
Exemplo n.º 4
0
        public void sendMessage(string msg)
        {
            var data = ReceiveHelper.EncodeMsg(msg);

            foreach (var c in m_clients)
            {
                c.Send(data);
            }
        }
Exemplo n.º 5
0
        public ResponseBuilder(int bufferSize, CookieContainer cookies = null, Uri uri = null)
        {
            this.bufferSize = bufferSize;

            this.cookies = cookies;
            this.uri     = uri;

            contentLength = -1;
            receiveHelper = new ReceiveHelper(bufferSize);
        }
Exemplo n.º 6
0
        private MailHeadModel getMailHeader(Int32 index)
        {
            response = Instruction.FETCHResponse(index, FetchType.UID);
            String uid = Regex.Match(response, IMAPHelper.UIDPattern).Groups["uid"].ToString();

            response = Instruction.FETCHResponse(index, FetchType.Expression("BODY[HEADER.FIELDS (Date From Subject Content-Type Content-Transfer-Encoding)]"));
            String body = Regex.Match(response, IMAPHelper.FetchMailPattern).Groups["body"].ToString();

            response = Instruction.STOREReduceFlagResponse(index, StoreFlags.Seen);
            return(ReceiveHelper.GetMailHead(uid, body));
        }
Exemplo n.º 7
0
        public override MailModel GetMail(int index)
        {
            response = Instruction.FETCHResponse(index, FetchType.UID);
            String uid = Regex.Match(response, IMAPHelper.UIDPattern).Groups["uid"].ToString();

            response = Instruction.FETCHResponse(index, FetchType.RFC822_HEADER);
            String head = Regex.Match(response, IMAPHelper.FetchMailPattern).Groups["body"].ToString();

            response = Instruction.FETCHResponse(index, FetchType.RFC822_TEXT);
            String body = Regex.Match(response, IMAPHelper.FetchMailPattern).Groups["body"].ToString();

            return(ReceiveHelper.GetMail(uid, head, body));
        }
Exemplo n.º 8
0
        /// <summary>
        ///  根据编号获得邮件头部内容
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private MailHeadModel getMailHeader(Int32 index)
        {
            String uid = Instruction.UIDLResponse(index).Split(' ')[2];

            response = Instruction.TOPResponse(index);
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            while (true)
            {
                response = Instruction.ReadResponse();
                if (response == pointBoundary)
                {
                    break;
                }
                stringBuilder.AppendLine(response);
            }
            return(ReceiveHelper.GetMailHead(uid, stringBuilder.ToString()));
        }
Exemplo n.º 9
0
        public void AcceptClient(IAsyncResult ar)
        {
            Debug.Log(ar.AsyncState);

            var socketserver = ar.AsyncState as WebSocketServer;
            var m_listener   = socketserver.m_listener;

            Socket client = m_listener.EndAcceptSocket(ar);

            Debug.Log("accept " + client.RemoteEndPoint.ToString());

            ReceiveHelper receivehelper = new ReceiveHelper(m_callback);

            client.BeginReceive(receivehelper.m_buffer, 0, 1024, 0, new AsyncCallback(receivehelper.ReceiveTarget), client);
            socketserver.m_clientManager.AddClient(client);
            m_listener.BeginAcceptSocket(new AsyncCallback(AcceptClient), socketserver);
        }
Exemplo n.º 10
0
 internal HttpResponseBuilder()
 {
     receiveHelper = new ReceiveHelper(bufferSize);
 }
Exemplo n.º 11
0
 public ZipWraperStream(Stream baseStream, ReceiveHelper receiverHelper)
 {
     _baseStream     = baseStream;
     _receiverHelper = receiverHelper;
 }