示例#1
0
        /****************************************************************
         *                          Read Node
         ***************************************************************/

        public Node Read()
        {
            var rdResult = new Read()
            {
                AnchorToken = Expect(TokenCategory.READ)
            };

            if (this.labelCache != null)
            {
                rdResult.Add(this.labelCache);
                this.labelCache = null;
            }

            Expect(TokenCategory.PARENTHESIS_OPEN);
            Expect(TokenCategory.MUL);
            Expect(TokenCategory.COMMA);
            Expect(TokenCategory.MUL);
            Expect(TokenCategory.PARENTHESIS_CLOSE);

            var readTo = new Identifier()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            if (CurrentToken == TokenCategory.PARENTHESIS_OPEN)
            {
                readTo.Add(ArrayDeclaration());
            }
            rdResult.Add(readTo);

            while (firstOfMultipleDeclarations.Contains(CurrentToken))
            {
                if (CurrentToken == TokenCategory.PARENTHESIS_OPEN)
                {
                    readTo.Add(ArrayDeclaration());
                    rdResult.Add(readTo);
                }

                else if (CurrentToken == TokenCategory.COMMA)
                {
                    Expect(TokenCategory.COMMA);
                    readTo = new Identifier()
                    {
                        AnchorToken = Expect(TokenCategory.IDENTIFIER)
                    };

                    if (CurrentToken != TokenCategory.PARENTHESIS_OPEN)
                    {
                        rdResult.Add(readTo);
                    }
                }
            }
            return(rdResult);
        }
 /// <summary>
 /// Ctor of the action configuration model.
 /// </summary>
 public OpcActionConfigurationModel(ReadActionModel action, string endpointUrl = null, bool useSecurity = true)
 {
     Init();
     EndpointUrl = new Uri(endpointUrl ?? DefaultEndpointUrl);
     UseSecurity = useSecurity;
     Read.Add(new ReadActionModel(action));
 }
示例#3
0
        private void ReceivedData(IAsyncResult ar)
        {
            RequestState   rs        = ar.AsyncState as RequestState;
            HttpWebRequest req       = rs.Req;
            Stream         resStream = rs.ResStream;
            string         url       = rs.Url;
            int            depth     = rs.Depth;
            string         html      = string.Empty;
            int            read      = 0;

            try
            {
                read = resStream.EndRead(ar);
                if (Stop)
                {
                    rs.ResStream.Close();
                    req.Abort();
                    return;
                }
                if (read > 0)
                {
                    MemoryStream ms     = new MemoryStream(rs.Data, 0, read);                                         //创建内存流
                    StreamReader reader = new StreamReader(ms, mEncoding);
                    string       str    = reader.ReadToEnd();                                                         //读取全部字符串
                    rs.Html.Append(str);
                    var result = resStream.BeginRead(rs.Data, 0, rs.BufferSize, new AsyncCallback(ReceivedData), rs); //再次请求数据
                    return;
                }
                html = rs.Html.ToString();
                bool isRedis = Convert.ToBoolean(RedisCommon.GetConfig("IsRedis"));
                if (!isRedis)
                {
                    SaveContents(html, url);//保存到本地
                }
                else
                {
                    mRedisCommon.SetValue(url, html);
                }
                string[] links = GetLinks(html); //获取页面中的链接
                Read.Add(url, depth);            //添加到已经下载集合
                AddUrl(links, depth + 1);
                Unread.Remove(url);              //移除未下载
                mRedisCommon.SetValue(url, url);
                DispatchWork();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }
示例#4
0
 private IStatement CallRead()
 {
     if (Accept(Symbol.ReadProcedure))
     {
         Require(Symbol.ClosureOpen);
         Read read = new Read();
         do
         {
             Identifier ident = Identifier();
             if (ident == null)
             {
                 throw new SyntaxException(expIdentifier, current);
             }
             VariableReference  varRef    = ReadVariableReference(ident);
             AssigmentStatement assigment = new AssigmentStatement(varRef, new Reading(ident));
             read.Add(assigment);
         } while (Accept(Symbol.Comma));
         Require(Symbol.ClosureClose);
         return(read);
     }
     return(null);
 }