/// <summary> /// 单个电站的工作年份 /// </summary> /// <param name="plantId"></param> protected void FillPlantYears(int plantId) { Plant plant = PlantService.GetInstance().GetPlantInfoById(plantId); IList <int> yearList = collectorYearDataService.GetWorkYears(plant); IList <SelectListItem> plantYearsList = Currencies.FillYearItems(yearList); ViewData[ComConst.WorkYears] = plantYearsList; }
/// <summary> /// 获取电站年份 /// </summary> private void FillYearsList() { User user = UserUtil.getCurUser(); IList <int> yearList = collectorYearDataService.GetWorkYears(user.plants); IList <SelectListItem> plantYearsList = Currencies.FillYearItems(yearList); ViewData["plantYear"] = plantYearsList; }
public void FillPlantYears(string plantId) { Plant plant = FindPlant(int.Parse(plantId)); IList <int> yearList = collectorYearDataService.GetWorkYears(plant); IList <SelectListItem> plantYearsList = Currencies.FillYearItems(yearList); ViewData["plantYear"] = plantYearsList; }
/// <summary> /// 根据电站Id填充电站年份 /// </summary> /// <param name="plantId"></param> public void FillPlantYears(string plantId) { if (!(string.IsNullOrEmpty(plantId)) && plantId != "null") { Plant plant = FindPlant(int.Parse(plantId)); IList <int> yearList = collectorYearDataService.GetWorkYears(plant); IList <SelectListItem> plantYearsList = Currencies.FillYearItems(yearList); ViewData["plantYear"] = plantYearsList; } else { User users = UserUtil.getCurUser(); IList <int> yearList = collectorYearDataService.GetWorkYears(users.plants); IList <SelectListItem> plantYearsList = Currencies.FillYearItems(yearList); ViewData["plantYear"] = plantYearsList; } }
/// <summary> /// 真正处理报表数据和返回视图的地方,预览和查看公用 /// </summary> /// <param name="report"></param> /// <param name="cTime"></param> /// <param name="pId"></param> /// <returns></returns> private ActionResult HandleViewReport(DefineReport report, int tId, string cTime, string pId, string type) { ViewData["Culture"] = Session["Culture"]; ViewData["rId"] = report.Id; ViewData["tId"] = tId.ToString(); ViewData["cTime"] = cTime; ViewData["pId"] = pId; if (!(string.IsNullOrEmpty(pId))) { if (string.IsNullOrEmpty(cTime)) { cTime = CalenderUtil.curDateWithTimeZone(report.plant.timezone, "yyyyMMdd"); } } else { if (string.IsNullOrEmpty(cTime)) { cTime = CalenderUtil.curDateWithTimeZone(report.user.timezone, "yyyyMMdd"); } } ViewData["time"] = cTime; if (tId == DataReportType.TOTAL_REPORT_CODE) { IList <int> workYears = null; if (!(string.IsNullOrEmpty(pId))) { workYears = collectorYearDataService.GetWorkYears(report.plant); cTime = CalenderUtil.curDateWithTimeZone(report.plant.timezone, "yyyy"); } else { workYears = collectorYearDataService.GetWorkYears(report.user.displayPlants); cTime = CalenderUtil.curDateWithTimeZone(report.user.timezone, "yyyy"); } if (workYears.Count > 0) { cTime = workYears[0] + "-" + workYears[workYears.Count - 1]; ViewData["time"] = cTime; } else { cTime += "-" + cTime; ViewData["time"] = Resources.SunResource.NO_WORK_YEARS; } } else if (tId == DataReportType.WEEK_REPORT_CODE) { string[] wTime = reportService.convertToDateArr(tId, cTime); int year1 = int.Parse(wTime[0].Substring(0, 4)); int mm1 = int.Parse(wTime[0].Substring(4, 2)); int dd1 = int.Parse(wTime[0].Substring(6, 2)); int year2 = int.Parse(wTime[1].Substring(0, 4)); int mm2 = int.Parse(wTime[1].Substring(4, 2)); int dd2 = int.Parse(wTime[1].Substring(6, 2)); string weekTime = year1 + "/" + mm1 + "/" + dd1 + "-" + year2 + "/" + mm2 + "/" + dd2; ViewData["time"] = weekTime; } else if (tId == DataReportType.MONTH_REPORT_CODE) { cTime = cTime.Split('-').Length > 2 ? cTime.Substring(0, cTime.LastIndexOf("-")) : cTime; ViewData["time"] = cTime; } else if (tId == DataReportType.YEAR_REPORT_CODE) { cTime = cTime.Split('-').Length > 2 ? cTime.Substring(0, cTime.IndexOf("-")) : cTime; ViewData["time"] = cTime; } if (report != null) { IList <Object> datalist = reportService.getDatabyItemCodes(report, cTime); if (datalist.Count != 0) { ViewData["deviceHash"] = (Hashtable)datalist[2]; ViewData["plantItemCodes"] = addIntNumtoList((IList <int>)datalist[0]); ViewData["plantHash"] = (Hashtable)datalist[1]; ViewData["deviceItemCodes"] = (IList <int>)datalist[3]; } else { ViewData["NoData"] = LanguageUtil.getDesc("NODATA"); } } else { ViewData["NoData"] = LanguageUtil.getDesc("NODATA"); } if (!(string.IsNullOrEmpty(pId))) { base.FillPlantYears(int.Parse(pId)); string yyyy = ViewData["cTime"] != null ? ViewData["cTime"] as string : DateTime.Now.Year.ToString(); yyyy = yyyy.Length >= 4 ? yyyy.Substring(0, 4) : yyyy; if (ViewData[ComConst.WorkYears] != null && (ViewData[ComConst.WorkYears] as IList <SelectListItem>).Count > 0) { foreach (SelectListItem item in ViewData[ComConst.WorkYears] as IList <SelectListItem> ) { item.Selected = false; item.Selected = item.Text.Equals(yyyy); } } if (tId == DataReportType.TODAY_REPORT_CODE) { if (string.IsNullOrEmpty(type)) { return(View("ViewDayReport", report)); } else { return(View("EmailViewDayReport", report)); } } else { if (string.IsNullOrEmpty(type)) { return(View("ViewNotDayReport", report)); } else { return(View("EmailViewNotDayReport", report)); } } } else { base.FillAllPlantYears(report.user); string yyyy = ViewData["cTime"] != null ? ViewData["cTime"] as string : DateTime.Now.Year.ToString(); yyyy = yyyy.Length >= 4 ? yyyy.Substring(0, 4) : yyyy; if (ViewData[ComConst.WorkYears] != null && (ViewData[ComConst.WorkYears] as IList <SelectListItem>).Count > 0) { foreach (SelectListItem item in ViewData[ComConst.WorkYears] as IList <SelectListItem> ) { item.Selected = false; item.Selected = item.Text.Equals(yyyy); } } if (string.IsNullOrEmpty(type)) { return(View("ViewUserReport", report)); } else { return(View("EmailViewUserReport", report)); } } }