Example #1
0
        public ApiMessage GetExcelBuyReport()
        {
            ApiMessage message = new ApiMessage() { Status = "ok" };
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            ReportFactory reportManager = new ReportFactory(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            long stime = 0;
            long etime = 0;

            int totalProducts = 0;
            int[] product_id = null;

            long.TryParse(request["stime"], out stime);
            long.TryParse(request["etime"], out etime);

            if (!string.IsNullOrEmpty(request["products"]))
            {
                product_id = base.ConvertToIntArrar(request["products"]);
            }

            try
            {
                JToken[] json = reportManager.GetBuyReport(stime, etime, product_id, 0, 0, out totalProducts, false);
                if (json!=null)
                {
                    BuyExcelReport excel = new BuyExcelReport();
                    excel.Export(json);
                    message.Item = "http://" + request.Url.Authority + "/Content/reports/tmp/" + excel.ReportFileName;
                }
                else
                {
                    message.Status = "failed";
                    message.Message = "没有搜索到符合要求的采购数据";
                }
            }
            catch (KMJXCException kex)
            {
                message.Status = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status = "failed";
                message.Message = "没有搜索到符合要求的采购数据";
            }
            finally
            {

            }
            return message;
        }
Example #2
0
        public PQGridData GetStockReport()
        {
            PQGridData data = new PQGridData();
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            ReportFactory reportManager = new ReportFactory(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);

            int page = 1;
            int pageSize = 50;
            int totalProducts = 0;
            int[] product_id = null;
            bool paging = false;

            int.TryParse(request["page"], out page);
            int.TryParse(request["pageSize"], out pageSize);

            if (!string.IsNullOrEmpty(request["products"]))
            {
                product_id = base.ConvertToIntArrar(request["products"]);
            }

            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 50;
            }
            if (!string.IsNullOrEmpty(request["paging"]) && request["paging"] == "1")
            {
                paging = true;
            }
            else
            {
                paging = false;
            }
            try
            {
                string json = reportManager.GetStockReport(product_id, page, pageSize, out totalProducts, paging);
                data.totalRecords = totalProducts;
                if (!string.IsNullOrEmpty(json))
                {
                    data.data = JArray.Parse(json);
                }
                data.curPage = page;
            }
            catch (Exception ex)
            {
                data.data = JArray.Parse("[]");
                data.totalRecords = 0;
                data.curPage = 1;
            }
            finally
            {

            }
            return data;
        }