/// <summary> /// 取大宗物料線圖所需資料包裝成Message形式 /// </summary> /// <param name="argu">QueryArgus</param> /// <param name="category">Category code</param> /// <returns>Message</returns> private string GetLineChartData(QueryArgus argu, int category) { if (argu == null || argu.startDate == null || argu.startDate == DateTime.MinValue || argu.startDate == DateTime.MaxValue) { return(JSonTool.SerializeJson(new Message("Start Date is required"))); } if (argu == null || argu.endDate == null || argu.endDate == DateTime.MinValue || argu.endDate == DateTime.MaxValue) { return(JSonTool.SerializeJson(new Message("End Date is required"))); } Message msg = new Message(); try { List <MaterialsLineChart> chartList = GetLineChartData(category, argu.startDate, argu.endDate); msg.result = chartList; msg.count = chartList.Count; } catch (Exception ex) { msg.count = 0; msg.message = ex.Message; } return(JSonTool.SerializeJson(msg)); }
public string GetMaterials() { VPriceMonthDetailDAL dal = new VPriceMonthDetailDAL(); List <VPriceMonthDetail> dalList = dal.Query(104, DateTime.Now.AddYears(-2), DateTime.Now); Mapper.Initialize(m => m.CreateMap <VPriceMonthDetail, Material>()); List <Material> materialList = Mapper.Map <List <VPriceMonthDetail>, List <Material> >(dalList); return(JSonTool.SerializeJson(materialList)); }