Beispiel #1
0
        static void Main(string[] args)
        {
            DataModel      model  = new DataModel();
            FunctionMapper mapper = new FunctionMapper();
            var            ip     = new byte[] { 127, 0, 0, 1 };
            TcpListener    server = new TcpListener(new IPAddress(ip), 8888);

            server.Start();
            Byte[] send       = new byte[50000];
            Byte[] receive    = new byte[5000];
            string jsonString = "";

            Console.WriteLine("Waiting for connection...");
            while (true)
            {
                TcpClient client = server.AcceptTcpClient();
                Console.WriteLine("Connection!...");

                NetworkStream stream = client.GetStream();
                stream.Read(receive, 0, receive.Length);
                string received = Encoding.ASCII.GetString(receive);
                Console.WriteLine(received);
                jsonObject jsono = JsonConvert.DeserializeObject <jsonObject>(received);
                jsonString = mapper.Map(jsono);

                receive  = new byte[5000];
                received = "";

                send = Encoding.UTF8.GetBytes(jsonString);
                stream.Write(send, 0, send.Length);
            }
        }
        /// <summary>
        /// 查询功能
        /// </summary>
        /// <param name="functionQuery"></param>
        /// <returns></returns>
        public PagedResult <FunctionDTO> Find(FunctionQuery functionQuery)
        {
            Check.Argument.IsNotNull(functionQuery, "functionQuery");

            //Apply filtering
            var query = _databaseContext.Functions.Where(functionQuery);

            var total = query.Count();

            query = SortMemeberHelper.SortingAndPaging <Function>(query, functionQuery.sort, functionQuery.dir
                                                                  , functionQuery.page, functionQuery.limit);


            var resultSet = query.AsNoTracking().ToList().Select(r => _functionMapper.Map(r)).ToList();

            return(new PagedResult <FunctionDTO>(resultSet, total));
        }