public JsonResult UploadPictures() { JsonResult result = new JsonResult(); var dashboardservice = new DashboardServices(); var picList = new List <Picture>(); var files = Request.Files; for (int i = 0; i < files.Count; i++) { var picture = files[i]; //var pathToImagesFolder = Server.MapPath("images/site/"); var fileName = Guid.NewGuid() + Path.GetExtension(picture.FileName); var filePath = Server.MapPath("~/images/site/") + fileName; picture.SaveAs(filePath); var dbPicture = new Picture(); dbPicture.URL = fileName; if (dashboardservice.SavePicture(dbPicture)) { picList.Add(dbPicture); } } result.Data = picList; return(result); }
/// <summary> /// Get PO Orders for Dashboard displaying (HightCharts) /// </summary> /// <returns></returns> public ActionResult GetPoOrders(List <Int32> channelList, String sTime, String eTime) { try { var sPage = Request["page"]; var sRows = Request["rows"]; var page = 1; var rows = 10; if (!string.IsNullOrEmpty(sPage)) { page = Convert.ToInt32(sPage); } if (!string.IsNullOrEmpty(sRows)) { rows = Convert.ToInt32(sRows); } var useInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]); var dSvs = new DashboardServices(); int totalRecord; var lowInventoryList = dSvs.GetLowInventory(page, rows, out totalRecord, useInfo); var serializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }; /*当订单数据量超过13000行记录的时候会报错,需要特殊配置*/ //var serializer = new JavaScriptSerializer(); // For simplicity just use Int32's max value. // You could always read the value from the config section mentioned above. var resultData = new { Status = StatusType.OK, Data = dSvs.GetEcomOrder(channelList.ToArray(), sTime, eTime).ToArray(), Metrics = new { AvgOrders = dSvs.GetAvgDailyOrders(sTime, eTime), AvgAmt = dSvs.GetAvgOrderAmount(sTime, eTime).ToString("C", new CultureInfo("en-US")), ProductDev = dSvs.GetProductsDevCount(), ItemAtt = dSvs.GetAttentionItemsCount() }, LowInventory = lowInventoryList, ProductDevList = dSvs.GetProductsDevList(), TotalRecord = totalRecord }; var result = new ContentResult { Content = serializer.Serialize(resultData), ContentType = "application/json" }; return(result); } catch (EntityCommandExecutionException ex) { if (ex.InnerException != null) { NBCMSLoggerManager.Error(ex.InnerException.Message); NBCMSLoggerManager.Error(ex.InnerException.Source); NBCMSLoggerManager.Error(ex.InnerException.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.InnerException.Message })); } NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); NBCMSLoggerManager.Error(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); NBCMSLoggerManager.Error(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// 这个方法是用于Dashboard页面重新查询订单信息(点击页面Query按钮)的时候用的 /// CreateDate:2013年12月23日16:49:48 /// </summary> /// <param name="channelList"></param> /// <param name="sTime"></param> /// <param name="eTime"></param> /// <returns></returns> public ActionResult QueryPoOrder(List <Int32> channelList, String sTime, String eTime) { try { var dSvs = new DashboardServices(); /*当订单数据量超过13000行记录的时候会报错,需要特殊配置*/ var serializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }; var resultData = new { Status = StatusType.OK, Data = dSvs.GetEcomOrder(channelList.ToArray(), sTime, eTime).ToArray(), Metrics = new { AvgOrders = dSvs.GetAvgDailyOrders(sTime, eTime), AvgAmt = dSvs.GetAvgOrderAmount(sTime, eTime).ToString("C", new CultureInfo("en-US")) }, }; var result = new ContentResult { Content = serializer.Serialize(resultData), ContentType = "application/json" }; return(result); } catch (EntityCommandExecutionException ex) { if (ex.InnerException != null) { NBCMSLoggerManager.Error(ex.InnerException.Message); NBCMSLoggerManager.Error(ex.InnerException.Source); NBCMSLoggerManager.Error(ex.InnerException.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.InnerException.Message })); } NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); NBCMSLoggerManager.Error(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); NBCMSLoggerManager.Error(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public DashboardController(AppDbContext appdbContext) { dashboardService = new DashboardServices(appdbContext); _appDbContext = appdbContext; }
public IActionResult Index() { DashboardDTO dto = DashboardServices.Get(); return(View(dto)); }
public ActionResult Index(int?ClientId, int?ProductId, int?ProductItemId) { try { #region Curent user session check var userData = MvcApplication.GetUserData(User.Identity.Name); if (userData == null || userData.UserId < 1) { return(RedirectToActionPermanent("Login", "Portal")); } #endregion #region check if productitemid is 0, initialize productItemId from ProductItemService based on client and product if (ProductItemId == 0) { var searchObjForItem = new ProductItemSearchObj { AdminUserId = userData.UserId, ClientId = ClientId ?? 0, ProductId = ProductId ?? 0, Status = -2, }; var retValForItem = ProductItemService.LoadProductItems(searchObjForItem, userData.Username); var items = retValForItem.ProductItems.Where(m => m.ProductId == ProductId && m.ClientId == ClientId).ToList(); var itemCount = items.Count(m => m.ClientId == ClientId && m.ProductId == ProductId); ViewBag.productItemCount = itemCount; if (itemCount == 1) { var itemId = Convert.ToInt32(items.FirstOrDefault(m => m.ProductId == ProductId && m.ClientId == ClientId).ProductItemId); ViewBag.productItemId = itemId; ProductItemId = itemId; } } #endregion #region client, product and item session initialization AppSession newSession = null; var userClientSession = (AppSession)Session["_UserClientSession_"]; newSession = new AppSession { ClientId = ClientId ?? 0, ProductId = ProductId ?? 0, ProductItemId = ProductItemId ?? 0, }; Session["_UserClientSession_"] = newSession; var clientId = ClientId ?? newSession.ClientId; var productId = ProductId ?? newSession.ProductId; var productItemId = ProductItemId ?? newSession.ProductItemId; #endregion var obj = new ClientProductInfoObj { CurrentClientId = clientId, CurrentProductId = productId, CurrentProductItemId = productItemId, ProductInfo = new ProductItemObj() }; if (clientId > 0 && productId > 0) { var prodInfo = getProductItemObj(clientId, productId, productItemId); if (prodInfo.ProductItemId > 0) { obj.ProductInfo = prodInfo; } } var searchObj = new AppStatSearchObj { AdminUserId = userData.UserId, StartDate = "", StopDate = "", ProductItemId = productItemId, ProductId = productId, ClientId = clientId, UserId = userData.UserId, }; var retVal = DashboardServices.LoadDashboard(searchObj, userData.Username); if (retVal?.Status == null) { ViewBag.Error = "No record found!"; return(View(new ClientProductInfoObj())); } if (!retVal.Status.IsSuccessful) { ViewBag.Error = "No record found!"; return(View(new ClientProductInfoObj())); } obj.Appstats = retVal; if (obj == null) { return(View(new ClientProductInfoObj())); } return(View(obj)); } catch (Exception ex) { ViewBag.Error = ex.Message; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new ClientProductInfoObj())); } }