コード例 #1
0
        public virtual async Task <ResponseData> GetAll(string id)
        {
            Stopwatch stop = Stopwatch.StartNew();

            try
            {
                var service = GetService(id);//_service.FirstOrDefault(m => m.Key == id).Value;
                if (service == null)
                {
                    return(this.GetResponse());
                }
                var type   = service.GetType();
                var result = type.InvokeMember("FindAll", bindings, null, service, null);
                RState.ListDataParse(result, type);
                stop.Stop();
                return(this.GetResponse(result));
            }
            catch (Exception ext)
            {
                return(this.ExceptionResult(ext, stop));
            }
        }
コード例 #2
0
        public virtual async Task <ResponseData> DataWithCount([FromBody] Query model)
        {
            Stopwatch stop = Stopwatch.StartNew();

            try
            {
                if (model == null)
                {
                    return(this.GetResponse(Responses.ComeNullModal));
                }
                var type = _types.FirstOrDefault(m => m.Key == model.name).Value;
                if (type == null)
                {
                    return(this.GetResponse(Responses.ServiceNotFound));
                }
                var service = _service[model.name];
                var result  = new PostResponse();
                if (model.WithOffset)
                {
                    result.Items = (IEnumerable)service.GetType().InvokeMember("FindReverse", bindings, null, service, new object[] { model.key, model.value, model.offset, model.limit });
                    RState.ListDataParse(result.Items, type);
                    result.Count = (long)service.GetType().InvokeMember("Count", bindings, null, service, new object[] { model.key, model.value, 0, "DatawitCount" });
                }
                else
                {
                    result.Items = (IEnumerable)service.GetType().InvokeMember("FindReverse", bindings, null, service, new object[] { model.offset, model.limit, });
                    RState.ListDataParse(result.Items, type);
                    result.Count = (long)service.GetType().InvokeMember("Count", bindings, null, service, new object[] { 0, "PostsData" });
                }
                stop.Stop();
                return(this.GetResponse(result));
            }
            catch (Exception ext)
            {
                return(this.ExceptionResult(ext, stop));
            }
        }