public void Repository_Get_PlayerAnalysis_Test() { try { // Arrange PlayerAnalysisRepository PlayerAnalysisRepository = new PlayerAnalysisRepository(); PlayerAnalysis playerAnalysis = new PlayerAnalysis(); playerAnalysis.sport = new Sport(); playerAnalysis.sport.id = 1; playerAnalysis.sport.name = "Sport 1"; playerAnalysis.sport.userId = 1; playerAnalysis.players = new List <Player>(); Player player = new Player(); player.id = 1; player.firstName = "FirstName"; player.lastName = "LastName"; playerAnalysis.players.Add(player); playerAnalysis.perfPara = new PerformanceParameter(); playerAnalysis.perfPara.id = 1; playerAnalysis.perfPara.perfParaName = new PerformanceParameterName(); playerAnalysis.perfPara.perfParaName.id = 1; playerAnalysis.perfPara.perfParaName.name = "Para Name 1"; playerAnalysis.perfPara.perfParaTypeGroup = new PerformanceParameterTypeGroup(); playerAnalysis.perfPara.perfParaTypeGroup.id = 1; playerAnalysis.perfPara.perfParaTypeGroup.name = "Para Type Group 1"; playerAnalysis.perfPara.sportId = 1; playerAnalysis.perfPara.customName = "custom name"; playerAnalysis.timeRange = "LAST1WEEK"; DateTime time = DateTime.Now; playerAnalysis.fromTime = time; playerAnalysis.toTime = time; // Act HighChart PlayerAnalysisResultFromDb = PlayerAnalysisRepository.GetPlayerAnalysis(playerAnalysis); // Assert Assert.IsNotNull(PlayerAnalysisResultFromDb); Assert.AreEqual(PlayerAnalysisResultFromDb.chart.type, "line"); Assert.IsTrue(PlayerAnalysisResultFromDb.xAxis.categories.Count == 8); Assert.AreEqual(PlayerAnalysisResultFromDb.yAxis.title.text, playerAnalysis.perfPara.perfParaName.name); Assert.AreEqual(PlayerAnalysisResultFromDb.tooltip.valueSuffix, " " + playerAnalysis.perfPara.perfParaTypeGroup.name); Assert.AreEqual(PlayerAnalysisResultFromDb.series[0].name, playerAnalysis.players[0].firstName + " " + playerAnalysis.players[0].lastName); Assert.IsTrue(PlayerAnalysisResultFromDb.series[0].data.Count == 8); } catch (Exception) { throw new AssertFailedException("Unable to fetch player Analysis."); } }
public void Post_Valid_Test() { // Arrange PlayerAnalysis PlayerAnalysisObjAsInput = new PlayerAnalysis(); PlayerAnalysisObjAsInput.sport = new Sport(); PlayerAnalysisObjAsInput.sport.id = 1; PlayerAnalysisObjAsInput.sport.name = "Sport 1"; PlayerAnalysisObjAsInput.sport.userId = 1; PlayerAnalysisObjAsInput.players = new List <Player>(); Player player = new Player(); player.id = 1; player.firstName = "FirstName"; player.lastName = "LastName"; PlayerAnalysisObjAsInput.players.Add(player); PlayerAnalysisObjAsInput.perfPara = new PerformanceParameter(); PlayerAnalysisObjAsInput.perfPara.id = 1; PlayerAnalysisObjAsInput.perfPara.perfParaName = new PerformanceParameterName(); PlayerAnalysisObjAsInput.perfPara.perfParaName.id = 1; PlayerAnalysisObjAsInput.perfPara.perfParaName.name = "Para Name 1"; PlayerAnalysisObjAsInput.perfPara.perfParaTypeGroup = new PerformanceParameterTypeGroup(); PlayerAnalysisObjAsInput.perfPara.perfParaTypeGroup.id = 1; PlayerAnalysisObjAsInput.perfPara.perfParaTypeGroup.name = "Para Type Group 1"; PlayerAnalysisObjAsInput.perfPara.sportId = 1; PlayerAnalysisObjAsInput.perfPara.customName = "custom name"; PlayerAnalysisObjAsInput.timeRange = "LAST1WEEK"; PlayerAnalysisObjAsInput.fromTime = DateTime.Now.AddDays(-1); PlayerAnalysisObjAsInput.toTime = DateTime.Now; HighChart highChart = new HighChart(); var mockRepository = new Mock <IPlayerAnalysisRepository>(); mockRepository.Setup(x => x.GetPlayerAnalysis(PlayerAnalysisObjAsInput)) .Returns(highChart); var controller = new PlayerAnalysisController(mockRepository.Object); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); // Act HttpResponseMessage response = controller.Post(PlayerAnalysisObjAsInput); // Assert string responseJSONStr = response.Content.ReadAsStringAsync().Result; Assert.IsNotNull(responseJSONStr); }
public void HighChart_Initialization_Test() { try { // Arrange and Act HighChart highChart = new HighChart(); // Assert Assert.IsNotNull(highChart); } catch (Exception) { throw new AssertFailedException("HighChart initialization failed."); } }
public void HighChart_Property_Set_Test() { try { // Arrange HighChart highChart = new HighChart(); // Act highChart.chart = new Chart(); highChart.chart.type = "line"; highChart.series = new List <SeriesElement>(); SeriesElement seriesElement = new SeriesElement(); seriesElement.name = "Player 1"; seriesElement.data = new List <string>(); seriesElement.data.Add("10"); seriesElement.data.Add("20"); highChart.series.Add(seriesElement); highChart.subtitle = new Title(); highChart.subtitle.text = "Subtitle"; highChart.title = new Title(); highChart.title.text = "Title"; highChart.tooltip = new ToolTip(); highChart.tooltip.valueSuffix = "Suffix"; highChart.xAxis = new XAxis(); highChart.xAxis.categories = new List <string>(); highChart.xAxis.categories.Add("Category 1"); highChart.yAxis = new YAxis(); highChart.yAxis.title = new Title(); highChart.yAxis.title.text = "Y Axis Title"; // Assert Assert.AreEqual <string>(highChart.chart.type, "line"); Assert.AreEqual <string>(highChart.series[0].name, "Player 1"); Assert.AreEqual <string>(highChart.series[0].data[0], "10"); Assert.AreEqual <string>(highChart.series[0].data[1], "20"); Assert.AreEqual <string>(highChart.subtitle.text, "Subtitle"); Assert.AreEqual <string>(highChart.title.text, "Title"); Assert.AreEqual <string>(highChart.tooltip.valueSuffix, "Suffix"); Assert.AreEqual <string>(highChart.xAxis.categories[0], "Category 1"); Assert.AreEqual <string>(highChart.yAxis.title.text, "Y Axis Title"); } catch (Exception) { throw new AssertFailedException("Setting HighChart properties failed."); } }
public IList <HighChart> GetChartData() { var vendors = _vendorRepository.GetAll(); var highCharts = new List <HighChart>(); foreach (var vendor in vendors) { var highChart = new HighChart { VendorName = vendor.Name, PercentVendor = CalculateVendorPercent(vendor.Name) }; highCharts.Add(highChart); } return(highCharts); }
public IList <HighChart> Get3DChartData() { var products = _productRepository.GetBrands(); var highCharts = new List <HighChart>(); foreach (var product in products) { var highChart = new HighChart { Brand = product.Brand, PercentBrand = CalculateBrandPercent(product.Brand) }; highCharts.Add(highChart); } return(highCharts); }
// POST: api/PlayerAnalysis public HttpResponseMessage Post([FromBody] PlayerAnalysis playerInfo) { HttpResponseMessage response; if (playerInfo == null) { response = Request.CreateResponse(HttpStatusCode.NoContent, "Invalid JSON Passed."); return(response); } HighChart highChart = _iPlayerAnalysisRepository.GetPlayerAnalysis(playerInfo); if (highChart != null) { response = Request.CreateResponse(HttpStatusCode.OK, "PlayerAnalysis added successfully."); response.Content = new StringContent(Helper.Serialize(highChart)); } else { response = Request.CreateResponse(HttpStatusCode.Conflict, "Error adding PlayerAnalysis."); } return(response); }
public HighChart GetPlayerAnalysis(PlayerAnalysis playerAnalysis) { HighChart highChart = new HighChart(); highChart.chart = new Chart(); highChart.chart.type = "line"; highChart.title = new Title(); highChart.title.text = "Performance Analysis Report of " + playerAnalysis.perfPara.perfParaName.name + " for " + playerAnalysis.sport.name; highChart.subtitle = new Title(); if (playerAnalysis.timeRange == "LAST1WEEK") { highChart.subtitle.text = "<strong>Duration</strong>: Last 1 Week"; playerAnalysis.fromTime = DateTime.Now.AddDays(-7); playerAnalysis.toTime = DateTime.Now; } else if (playerAnalysis.timeRange == "LAST1MONTH") { highChart.subtitle.text = "Duration: Last 1 Month"; playerAnalysis.fromTime = DateTime.Now.AddMonths(-1); playerAnalysis.toTime = DateTime.Now; } else if (playerAnalysis.timeRange == "LAST3MONTHS") { highChart.subtitle.text = "Duration: Last 3 Months"; playerAnalysis.fromTime = DateTime.Now.AddMonths(-3); playerAnalysis.toTime = DateTime.Now; } else if (playerAnalysis.timeRange == "LAST6MONTHS") { highChart.subtitle.text = "Duration: Last 6 Months"; playerAnalysis.fromTime = DateTime.Now.AddMonths(-6); playerAnalysis.toTime = DateTime.Now; } else { highChart.subtitle.text = "Duration: Custom"; playerAnalysis.fromTime = DateTime.Now.AddDays(-7); playerAnalysis.toTime = DateTime.Now; } highChart.xAxis = new XAxis(); highChart.xAxis.categories = new List <string>(); highChart.yAxis = new YAxis(); highChart.yAxis.title = new Title(); highChart.yAxis.title.text = playerAnalysis.perfPara.perfParaName.name; highChart.tooltip = new ToolTip(); highChart.series = new List <SeriesElement>(); SeriesElement seriesElement; String sqlStr = "select id, group_id, name from perf_para_type where group_id = @groupId"; MySqlCommand cmd = new MySqlCommand(sqlStr, conn); cmd.Parameters.AddWithValue("groupId", playerAnalysis.perfPara.perfParaTypeGroup.id); MySqlDataReader perfParaTypeSqlReader = cmd.ExecuteReader(); List <PerformanceParameterType> perfParaTypes = new List <PerformanceParameterType>(); PerformanceParameterType perfParaType = null; while (perfParaTypeSqlReader.Read()) { perfParaType = new PerformanceParameterType(); perfParaType.id = perfParaTypeSqlReader.GetInt32(0); perfParaType.groupId = perfParaTypeSqlReader.GetInt32(1); perfParaType.name = perfParaTypeSqlReader.GetString(2); perfParaTypes.Add(perfParaType); } perfParaTypeSqlReader.Close(); MySqlDataReader sqlReader; if (perfParaTypes.Count == 1) { highChart.tooltip.valueSuffix = " " + playerAnalysis.perfPara.perfParaTypeGroup.name; DateTime startTime = playerAnalysis.fromTime; while (startTime <= playerAnalysis.toTime) { highChart.xAxis.categories.Add(startTime.Day.ToString() + "-" + startTime.Month.ToString()); startTime = startTime.AddDays(1); } for (int i = 0; i < playerAnalysis.players.Count; i++) { seriesElement = new SeriesElement(); seriesElement.name = playerAnalysis.players[i].firstName + " " + playerAnalysis.players[i].lastName; seriesElement.data = new List <string>(); sqlStr = "select value from player_eval where sport_id = @sportId and player_id = @playerId and name_id = @nameId and type_id = @typeId and eval_date = @evalDate"; cmd = new MySqlCommand(sqlStr, conn); cmd.Parameters.AddWithValue("sportId", playerAnalysis.sport.id); cmd.Parameters.AddWithValue("playerId", playerAnalysis.players[i].id); cmd.Parameters.AddWithValue("nameId", playerAnalysis.perfPara.perfParaName.id); cmd.Parameters.AddWithValue("typeId", ((PerformanceParameterType)perfParaTypes[0]).id); MySqlParameter para; startTime = playerAnalysis.fromTime; while (startTime <= playerAnalysis.toTime) { if (cmd.Parameters.Contains("evalDate")) { cmd.Parameters.RemoveAt(4); } para = new MySqlParameter("evalDate", MySqlDbType.Date); para.Value = startTime; cmd.Parameters.Add(para); sqlReader = cmd.ExecuteReader(); if (sqlReader.Read()) { string[] timeformats = { @"m\:ss", @"mm\:ss", @"h\:mm\:ss" }; TimeSpan duration; if (playerAnalysis.perfPara.perfParaTypeGroup.name == "min:sec") { duration = TimeSpan.ParseExact(sqlReader.GetString(0), timeformats, CultureInfo.InvariantCulture); seriesElement.data.Add(duration.TotalSeconds.ToString()); highChart.tooltip.valueSuffix = " total sec"; } else if (playerAnalysis.perfPara.perfParaTypeGroup.name == "hr:min:sec") { duration = TimeSpan.ParseExact(sqlReader.GetString(0), timeformats, CultureInfo.InvariantCulture); seriesElement.data.Add(duration.TotalSeconds.ToString()); highChart.tooltip.valueSuffix = " total sec"; } else { seriesElement.data.Add(sqlReader.GetString(0)); } } else { seriesElement.data.Add(string.Empty); } sqlReader.Close(); startTime = startTime.AddDays(1); } highChart.series.Add(seriesElement); } } else { highChart.chart.type = "column"; for (int i = 0; i < perfParaTypes.Count; i++) { highChart.xAxis.categories.Add(((PerformanceParameterType)perfParaTypes[i]).name); } for (int i = 0; i < playerAnalysis.players.Count; i++) { seriesElement = new SeriesElement(); seriesElement.name = playerAnalysis.players[i].firstName + " " + playerAnalysis.players[i].lastName; seriesElement.data = new List <string>(); sqlStr = "select count(*) from player_eval where sport_id = @sportId and player_id = @playerId and name_id = @nameId and type_id = @typeId and eval_date >= @evalFromDate"; cmd = new MySqlCommand(sqlStr, conn); cmd.Parameters.AddWithValue("sportId", playerAnalysis.sport.id); cmd.Parameters.AddWithValue("playerId", playerAnalysis.players[i].id); cmd.Parameters.AddWithValue("nameId", playerAnalysis.perfPara.perfParaName.id); MySqlParameter para = new MySqlParameter("evalFromDate", MySqlDbType.Date); para.Value = playerAnalysis.fromTime; cmd.Parameters.Add(para); //para = new MySqlParameter("evalToDate", MySqlDbType.Date); //para.Value = playerAnalysis.toTime; //cmd.Parameters.Add(para); for (int j = 0; j < perfParaTypes.Count; j++) { if (cmd.Parameters.Contains("typeId")) { cmd.Parameters.RemoveAt(4); } cmd.Parameters.AddWithValue("typeId", ((PerformanceParameterType)perfParaTypes[j]).id); seriesElement.data.Add(cmd.ExecuteScalar().ToString()); } highChart.series.Add(seriesElement); } } return(highChart); }
public void ProcessRequest(HttpContext context) { string action = CommonHelper.QueryString("action"); switch (action) { case "operatingCost": //根据国家 获取省 try { List <HighChart> List = new List <HighChart>(); string ProjectID = CommonHelper.QueryString("ProjectID"); string DateType = CommonHelper.QueryString("DateType"); string PageType = CommonHelper.QueryString("PageType"); var list = GetDataTotal(DateType, PageType, ProjectID); if (list != null && list.Count > 0) { foreach (OperatingCostData info in list) { HighChart one = new HighChart(); HighChart two = new HighChart(); HighChart three = new HighChart(); HighChart four = new HighChart(); HighChart five = new HighChart(); HighChart six = new HighChart(); HighChart seven = new HighChart(); HighChart eight = new HighChart(); one.Name = info.Date; two.Name = info.Date; three.Name = info.Date; four.Name = info.Date; five.Name = info.Date; six.Name = info.Date; seven.Name = info.Date; eight.Name = info.Date; one.Group = "进货成本"; one.Value = info.CountMoneySum4; List.Add(one); two.Group = "赠品成本"; two.Value = info.CountMoneySum24; List.Add(two); three.Group = "刷拍成本"; three.Value = info.CountMoneySum7; List.Add(three); four.Group = "返现成本"; four.Value = info.CountMoneySum8; List.Add(four); five.Group = "广告费用"; five.Value = info.CountMoneySumFEE; List.Add(five); six.Group = "运费"; six.Value = info.CountMoneySum6; List.Add(six); seven.Group = "营业成本"; seven.Value = info.YYCBMonthMoney; List.Add(seven); eight.Group = "平台成本"; eight.Value = info.CountMoneySum5; List.Add(eight); } } if (List != null && List.Count > 0) { List = List.OrderBy(x => x.Group).ThenBy(x => x.Name).ToList(); } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(List, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; } }
public void ProcessRequest(HttpContext context) { string action = CommonHelper.QueryString("action"); switch (action) { case "Analysis": try { string Year = CommonHelper.QueryString("Year"); List <List <HighChart> > Data = new List <List <HighChart> >(); List <HighChart> MonthData = new List <HighChart>(); List <HighChart> YearData = new List <HighChart>(); List <HighChart> ReachData = new List <HighChart>(); List <HighChart> GrowthData = new List <HighChart>(); List <CWStaffSpendingMapping> MonthList = (List <CWStaffSpendingMapping>)context.Session["MonthListMark"]; if (MonthList.Count > 0) { HighChart A = new HighChart(); HighChart B = new HighChart(); HighChart C = new HighChart(); A.Group = "年目标"; B.Group = "年实际"; C.Group = "年同比"; A.Name = Year; B.Name = Year; C.Name = Year; foreach (CWStaffSpendingMapping info in MonthList) { HighChart a = new HighChart(); HighChart b = new HighChart(); HighChart c = new HighChart(); HighChart reach = new HighChart(); HighChart growth = new HighChart(); a.Name = info.YearStr + "-" + info.MonthStr.PadLeft(2, '0'); b.Name = a.Name; c.Name = a.Name; reach.Name = a.Name; growth.Name = a.Name; a.Group = "目标"; b.Group = "实际"; c.Group = "同比"; reach.Group = "达成率"; growth.Group = "增长率"; a.Value = info.MonthTarget; b.Value = (decimal)info.MonthTotal; c.Value = info.LastMonthTotal; reach.Value = info.MonthReachRate * 100; growth.Value = info.MonthGrowthRate * 100; MonthData.Add(a); MonthData.Add(b); MonthData.Add(c); ReachData.Add(reach); GrowthData.Add(growth); A.Value += a.Value; B.Value += b.Value; C.Value += c.Value; } YearData.Add(A); YearData.Add(B); YearData.Add(C); } Data.Add(MonthData); Data.Add(YearData); Data.Add(ReachData); Data.Add(GrowthData); JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(Data, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "BindDepartmentType": try { List <CodeList> List = new List <CodeList>(); var DepartmentTypeList = IoC.Resolve <ICodeService>().GetCodeListInfoByCodeTypeID(1); if (DepartmentTypeList.Count > 0) { foreach (CodeList info in DepartmentTypeList) { CodeList item = new CodeList(); item.CodeID = info.CodeID; item.CodeName = info.CodeName; List.Add(item); } } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(List, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "BindProjectId": try { int DepartmentTypeID = CommonHelper.QueryStringInt("DepartmentTypeID"); List <HighChart> ProjectList = new List <HighChart>(); var DepartmentTypeList = IoC.Resolve <IEnterpriseService>().GetDepartmentListByDepType(DepartmentTypeID); if (DepartmentTypeList.Count > 0) { foreach (Department Info in DepartmentTypeList) { var projectList = IoC.Resolve <IXMProjectService>().GetXMProjectListByDepID(Info.DepartmentID); if (projectList.Count > 0) { List <HighChart> list = new List <HighChart>(); foreach (XMProject info in projectList) { HighChart item = new HighChart(); item.Value = info.Id; item.Name = info.ProjectName; item.Group = info.ProjectTypeId.ToString(); list.Add(item); } ProjectList.AddRange(list); } } } //项目名称绑定--选取自运营项目 if (HozestERPContext.Current.User.CustomerID == 7 || HozestERPContext.Current.User.CustomerID == 84 || HozestERPContext.Current.User.CustomerID == 658) { ProjectList = ProjectList.Where(c => c.Group == "362").ToList(); } else { List <decimal> list = ProjectList.Select(p => p.Value).ToList(); var projectList = IoC.Resolve <IXMProjectService>().GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 362) .GroupBy(p => new { p.Id, p.ProjectName }) .Select(p => new { Id = p.Key.Id, ProjectName = p.Key.ProjectName }); for (int i = 0; i < projectList.Count(); i++) { if (list.IndexOf((projectList.ToList())[i].Id) == -1) { projectList.ToList().Remove((projectList.ToList())[i]); } } if (projectList.Count() > 0) { List <HighChart> List = new List <HighChart>(); foreach (var info in projectList) { HighChart item = new HighChart(); item.Value = info.Id; item.Name = info.ProjectName; List.Add(item); } ProjectList.AddRange(List); } } if (DepartmentTypeID != 505) { HighChart add = new HighChart(); add.Value = -1; add.Name = "---所有---"; ProjectList.Insert(0, add); } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(ProjectList, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; } }
public void ProcessRequest(HttpContext context) { string action = CommonHelper.QueryString("action"); switch (action) { case "productSales": try { List <ProductSalesData> list = new List <ProductSalesData>(); List <HighChart> List = new List <HighChart>(); if (System.Web.HttpContext.Current.Session["ProductSalesDataList"] != null) { list = (List <ProductSalesData>)System.Web.HttpContext.Current.Session["ProductSalesDataList"]; } foreach (ProductSalesData Info in list) { HighChart one = new HighChart(); one.Name = Info.ProductName.Trim(); one.Value = decimal.Parse(Info.ProductNum.ToString()); if (List.FirstOrDefault(x => x.Name == Info.ProductName.Trim()) != null) { HighChart search = List.FirstOrDefault(x => x.Name == Info.ProductName.Trim()); search.Value = search.Value + one.Value; } else { List.Add(one); } } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(List, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "ProjectIdBind": try { string Str = ""; //项目名称绑定--选取自运营项目 if (HozestERPContext.Current.User.CustomerID == 7 || HozestERPContext.Current.User.CustomerID == 84 || HozestERPContext.Current.User.CustomerID == 658) { var projectList = IoC.Resolve <IXMProjectService>().GetXMProjectList().Where(c => c.ProjectTypeId == 362); foreach (XMProject info in projectList) { Str = Str + info.ProjectName + "," + info.Id + ";"; } } else { var projectList = IoC.Resolve <IXMProjectService>().GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 362) .GroupBy(p => new { p.Id, p.ProjectName }) .Select(p => new { Id = p.Key.Id, ProjectName = p.Key.ProjectName }); foreach (var info in projectList) { Str = Str + info.ProjectName + "," + info.Id + ";"; } } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(Str, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "WarehouseBind": try { var WarehouseList = IoC.Resolve <ICodeService>().GetCodeListInfoByCodeTypeID(227); string Str = "---所有---,-1;"; foreach (var info in WarehouseList) { Str = Str + info.CodeName + "," + info.CodeID + ";"; } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(Str, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "NickList": try { string Str = ""; string ProjectId = CommonHelper.QueryString("ProjectId"); if (ProjectId != "") { //店铺数据源 if (HozestERPContext.Current.User.CustomerID == 7 || HozestERPContext.Current.User.CustomerID == 84 || HozestERPContext.Current.User.CustomerID == 658) { var nickList = IoC.Resolve <IXMOrderInfoAPIService>().GetXMNickList("", 1, Convert.ToInt32(ProjectId)); foreach (var info in nickList) { Str = Str + info.nick + "," + info.nick_id + ";"; } Str = Str + "---所有---,-1;"; } else { var nickList = IoC.Resolve <IXMOrderInfoAPIService>().GetXMNickListSS("", 1, Convert.ToInt32(ProjectId), HozestERPContext.Current.User.CustomerID, 0); if (nickList.Count() == 0) { Str = Str + "---无店铺权限---,0;"; } else { if (nickList.Count() > 0) { foreach (var info in nickList) { Str = Str + info.nick + "," + info.nick_id + ";"; } } Str = Str + "---所有---,99;"; } } } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(Str, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "Province": try { string Str = ""; int Warehouse = CommonHelper.QueryStringInt("Warehouse"); var ProvinceList = IoC.Resolve <IProvinceWarehouseService>().GetProvinceWarehouseListByWarehouseID(Warehouse); foreach (var info in ProvinceList) { Str = Str + info.ProvinceName + "," + info.ID + ";"; } Str += "---所有---,-1;"; JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(Str, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "JdReturn": try { string Begin = CommonHelper.QueryString("Begin"); string End = CommonHelper.QueryString("End"); string NickIDs = CommonHelper.QueryString("NickIDs"); var JdReturnList = IoC.Resolve <IXMJDSaleRejectedService>().GetXMJDSaleReportData(Begin, End, NickIDs); List <HighChart> HighChartList = new List <HighChart>(); foreach (var item in JdReturnList) { HighChart one = new HighChart(); one.Name = item.ReturnType; one.Value = decimal.Parse(item.Num.ToString()); HighChartList.Add(one); } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(HighChartList, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; } }
public void ProcessRequest(HttpContext context) { string action = CommonHelper.QueryString("action"); switch (action) { case "applicationSales": try { List <XMApplicationExchange> list = new List <XMApplicationExchange>(); List <HighChart> List = new List <HighChart>(); if (System.Web.HttpContext.Current.Session["ApplicationSalesDataList"] != null) { list = (List <XMApplicationExchange>)System.Web.HttpContext.Current.Session["ApplicationSalesDataList"]; } foreach (XMApplicationExchange Info in list) { HighChart one = new HighChart(); one.Name = Info.ProductName.Trim(); one.Value = decimal.Parse(Info.ProductNum.ToString()); if (List.FirstOrDefault(x => x.Name == Info.ProductName.Trim()) != null) { HighChart search = List.FirstOrDefault(x => x.Name == Info.ProductName.Trim()); search.Value = search.Value + one.Value; } else { List.Add(one); } } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(List, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "applicationSalesHuan": try { string ddlPlatform = CommonHelper.QueryString("ddlPlatform"); string nickid = CommonHelper.QueryString("nickid"); string timetype = CommonHelper.QueryString("timetype"); string ApplicaType = CommonHelper.QueryString("ApplicaType"); string BeginDate = CommonHelper.QueryString("BeginDate"); string EndDate = CommonHelper.QueryString("EndDate"); var list = IoC.Resolve <IXMApplicationService>().GetXMApplicationReportData(int.Parse(ddlPlatform), int.Parse(nickid), int.Parse(timetype), int.Parse(ApplicaType), Convert.ToDateTime(BeginDate), Convert.ToDateTime(EndDate), 1); List <HighChart> HighChartList = new List <HighChart>(); foreach (var item in list) { HighChart one = new HighChart(); one.Name = item.ProductName; one.Value = decimal.Parse(item.Num.ToString()); HighChartList.Add(one); } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(HighChartList, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "applicationSalesTui": try { string ddlPlatform = CommonHelper.QueryString("ddlPlatform"); string nickid = CommonHelper.QueryString("nickid"); string timetype = CommonHelper.QueryString("timetype"); string ApplicaType = CommonHelper.QueryString("ApplicaType"); string BeginDate = CommonHelper.QueryString("BeginDate"); string EndDate = CommonHelper.QueryString("EndDate"); var list = IoC.Resolve <IXMApplicationService>().GetXMApplicationReportData(int.Parse(ddlPlatform), int.Parse(nickid), int.Parse(timetype), int.Parse(ApplicaType), Convert.ToDateTime(BeginDate), Convert.ToDateTime(EndDate), 2); List <HighChart> HighChartList = new List <HighChart>(); foreach (var item in list) { HighChart one = new HighChart(); one.Name = item.ProductName; one.Value = decimal.Parse(item.Num.ToString()); HighChartList.Add(one); } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(HighChartList, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; } }
public void ProcessRequest(HttpContext context) { string action = CommonHelper.QueryString("action"); switch (action) { case "companyOperation": try { List <List <HighChart> > AllList = new List <List <HighChart> >(); for (int i = 0; i < 7; i++) { List <HighChart> empty = new List <HighChart>(); AllList.Add(empty); } List <HighChart> List = new List <HighChart>(); List <OperatingCostData> OperatingCostDataList = new List <OperatingCostData>(); List <List <HighChart> > list = new List <List <HighChart> >(); string DateType = CommonHelper.QueryString("DateType"); string PageType = CommonHelper.QueryString("PageType"); string Year = CommonHelper.QueryString("Year"); string Month = CommonHelper.QueryString("Month"); string ProjectId = CommonHelper.QueryString("ProjectId"); string NickId = CommonHelper.QueryString("NickId"); string mark = ""; //var list = GetDataTotal(DateType, PageType, Year, Month, ProjectId, NickId); if (System.Web.HttpContext.Current.Session["Mark"] != null) { mark = System.Web.HttpContext.Current.Session["Mark"].ToString();; } if ((DateType == "year" || DateType == "custom_year") && mark == (DateType + "," + ProjectId + "," + NickId)) { if (System.Web.HttpContext.Current.Session["HightChartsLineYear"] != null) { OperatingCostDataList = (List <OperatingCostData>)System.Web.HttpContext.Current.Session["HightChartsLineYear"]; } if (System.Web.HttpContext.Current.Session["HightChartsPieYear"] != null) { list = (List <List <HighChart> >)System.Web.HttpContext.Current.Session["HightChartsPieYear"]; } } else { GetDataTotal(DateType, PageType, Year, Month, ProjectId, NickId); if (System.Web.HttpContext.Current.Session["HightChartsLine"] != null) { OperatingCostDataList = (List <OperatingCostData>)System.Web.HttpContext.Current.Session["HightChartsLine"]; } if (System.Web.HttpContext.Current.Session["HightChartsPie"] != null) { list = (List <List <HighChart> >)System.Web.HttpContext.Current.Session["HightChartsPie"]; } } if (list != null && list.Count > 0) { foreach (OperatingCostData info in OperatingCostDataList) { HighChart one = new HighChart(); HighChart two = new HighChart(); HighChart three = new HighChart(); HighChart four = new HighChart(); HighChart five = new HighChart(); HighChart six = new HighChart(); HighChart seven = new HighChart(); one.Name = info.Date; two.Name = info.Date; three.Name = info.Date; four.Name = info.Date; five.Name = info.Date; six.Name = info.Date; seven.Name = info.Date; one.Group = "营业收入"; one.Value = info.CountMoneySum1; List.Add(one); two.Group = "营业成本"; two.Value = info.YYCBMonthMoney; List.Add(two); three.Group = "管理费用"; three.Value = info.ManagementFee; List.Add(three); four.Group = "人工成本"; four.Value = info.ZJRGMonthMoney; List.Add(four); five.Group = "增值税"; five.Value = info.ZZSMonthMoney; List.Add(five); six.Group = "毛利"; six.Value = info.MLMonthMoney; List.Add(six); seven.Group = "净利润"; seven.Value = info.SQLRMonthMoney; List.Add(seven); } AllList[0] = List; AllList[1] = ObjToHighChart(list[0]); AllList[2] = ObjToHighChart(list[1]); AllList[3] = ObjToHighChart(list[2]); AllList[4] = ObjToHighChart(list[3]); AllList[5] = ObjToHighChart(list[4]); AllList[6] = ObjToHighChart(list[5]); } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(AllList, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; } }
private List <HighChart> GetDataTotal(string DateType, string Year, string Month, string DepartmentType, string Project) { DateTime begin = new DateTime(); DateTime end = new DateTime(); List <string> list = new List <string>(); List <HighChart> HighChartList = new List <HighChart>(); string now = DateTime.Now.ToLongDateString(); string Format = ""; if ((DateType == "year") || DateType == "custom_year") { Format = "yyyy/MM"; } else { Format = "MM/dd"; } if (DateType == "week") { for (int i = 6; i >= 0; i--) { string Item = ""; if (DateTime.Now.Day < 7 && DateTime.Now.AddDays(-i).Day > 7) { Item = (DateTime.Now.Month - 1).ToString().PadLeft(2, '0') + "/" + (DateTime.Now.AddDays(-i).Day).ToString().PadLeft(2, '0'); } else { Item = DateTime.Now.Month.ToString().PadLeft(2, '0') + "/" + (DateTime.Now.AddDays(-i).Day).ToString().PadLeft(2, '0'); } list.Add(Item); } begin = DateTime.Parse(now).AddDays(-6); end = DateTime.Parse(now).AddDays(1).AddSeconds(-1); } else if (DateType == "month") { for (int i = DateTime.Now.Day - 1; i >= 0; i--) { string Item = ""; Item = DateTime.Now.Month.ToString().PadLeft(2, '0') + "/" + (DateTime.Now.AddDays(-i).Day).ToString().PadLeft(2, '0'); list.Add(Item); } begin = DateTime.Parse(now).AddDays(-DateTime.Now.Day + 1); end = DateTime.Parse(now).AddDays(1).AddSeconds(-1); } else if (DateType == "year") { for (int i = 1; i <= DateTime.Now.Month; i++) { string Item = ""; Item = DateTime.Now.Year + "/" + i.ToString().PadLeft(2, '0'); list.Add(Item); } begin = DateTime.Parse(DateTime.Now.Year + "/01/01"); end = DateTime.Parse(now).AddDays(1).AddSeconds(-1); } else if (DateType == "custom_year") { for (int i = 1; i <= 12; i++) { string Item = ""; Item = Year + "/" + i.ToString().PadLeft(2, '0'); list.Add(Item); } begin = DateTime.Parse(Year + "/01/01"); end = DateTime.Parse((int.Parse(Year) + 1) + "/01/01"); } else if (DateType == "custom_month") { int days = DateTime.DaysInMonth(int.Parse(Year), int.Parse(Month)); for (int i = days - 1; i >= 0; i--) { string Item = ""; Item = Month.PadLeft(2, '0') + "/" + (days - i).ToString().PadLeft(2, '0'); list.Add(Item); } begin = DateTime.Parse(Year + "/" + Month + "/01"); if (Month != "12") { end = DateTime.Parse(Year + "/" + (int.Parse(Month) + 1) + "/01"); } else { end = DateTime.Parse((int.Parse(Year) + 1) + "/01/01"); } } var List = IoC.Resolve <IXMFinancialCapitalFlowService>().GetListByDataToTable(begin.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd") , int.Parse(DepartmentType), int.Parse(Project), -1); if (List.Count > 0) { foreach (XMFinancialCapitalFlow Info in List) { HighChart one = new HighChart(); foreach (string date in list) { if (((DateTime)Info.Date).ToString(Format) == date) { one.Name = ((DateTime)Info.Date).ToString(Format); one.Group = Info.BudgetTypeName; one.Value = (decimal)Info.Amount; HighChartList.Add(one); break; } } } } return(HighChartList); }
public void ProcessRequest(HttpContext context) { string action = CommonHelper.QueryString("action"); switch (action) { case "autocomplete": try { string str = CommonHelper.QueryString("p").Trim(); JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); var list = IoC.Resolve <IXMBusinessDataService>().GetXMBusinessDataListByClientCompany(str).Take(10); if (list.Count() > 0) { foreach (XMBusinessDataBrief info in list) { info.PayPerson = info.PayPerson == null ? "空" : info.PayPerson; } } javaS.Serialize(list, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; case "ReceivablesBudget": try { string CodeTypeID = CommonHelper.QueryString("CodeTypeID").Trim(); JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); List <HighChart> list = new List <HighChart>(); if (CodeTypeID == "225") { //var BudgetList = IoC.Resolve<IBudgetSettingService>().GetBudgetSettingListByData(""); var BudgetList = IoC.Resolve <IXMFinancialFieldService>().GetBudgetSettingListByData(""); if (BudgetList.Count > 0) { foreach (XMFinancialField info in BudgetList) { HighChart item = new HighChart(); item.Name = info.FieldName; item.Value = info.Id; list.Add(item); } } } else { var ReceivablesTypeList = IoC.Resolve <ICodeService>().GetCodeListInfoByCodeTypeID(int.Parse(CodeTypeID)); if (ReceivablesTypeList.Count > 0) { foreach (CodeList info in ReceivablesTypeList) { HighChart item = new HighChart(); item.Name = info.CodeName; item.Value = info.CodeID; list.Add(item); } } } javaS.Serialize(list, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; } }
public void ProcessRequest(HttpContext context) { string action = CommonHelper.QueryString("action"); switch (action) { case "operatingResults": //根据国家 获取省 try { List <HighChart> HighChartList = new List <HighChart>(); List <OperatingCostData> List = new List <OperatingCostData>(); string DateType = CommonHelper.QueryString("DateType"); string PageType = CommonHelper.QueryString("PageType"); string Year = CommonHelper.QueryString("Year"); string Month = CommonHelper.QueryString("Month"); var ProjectList = IoC.Resolve <IXMProjectService>().GetXMProjectList(); if (ProjectList.Count > 0) { foreach (XMProject item in ProjectList) { string ProjectID = item.Id.ToString(); var list = GetDataTotal(DateType, PageType, ProjectID, Year, Month); if (list != null && list.Count > 0) { List.AddRange(list); } } } string[] Other = { "B2B", "B2C" }; foreach (string info in Other) { string ProjectID = info; var list = GetDataTotal(DateType, PageType, ProjectID, Year, Month); if (list != null && list.Count > 0) { List.AddRange(list); } } if (List != null && List.Count > 0) { foreach (OperatingCostData info in List) { string Group = ""; if (info.ProjectId == "B2B" || info.ProjectId == "B2C") { Group = info.ProjectId; } else { var project = IoC.Resolve <IXMProjectService>().GetXMProjectById(int.Parse(info.ProjectId)); if (project != null) { Group = project.ProjectName; } } HighChart one = new HighChart(); one.Name = info.Date; one.Group = Group; one.Value = info.CountMoneySum1; HighChartList.Add(one); } } if (HighChartList != null && HighChartList.Count > 0) { HighChartList = HighChartList.OrderBy(x => x.Group).ThenBy(x => x.Name).ToList(); } JavaScriptSerializer javaS = new JavaScriptSerializer(); StringBuilder josn = new StringBuilder(); javaS.Serialize(HighChartList, josn); context.Response.ContentType = "text/plain"; context.Response.Write(josn.ToString()); } catch { } break; } }