public ActionResult Index(GraphReportForm form) { GraphReport.Models.DataRequest dataRequest = new GraphReport.Models.DataRequest(); dataRequest.beginTime = Helpers.ConvertDT2pkTime(form.beginDateTime); dataRequest.endTime = Helpers.ConvertDT2pkTime(form.endDateTime); List <GraphReport.Models.Tag> selectedTags = new List <GraphReport.Models.Tag>(); foreach (string column in form.tags) { GraphReport.Models.Tag tag = new GraphReport.Models.Tag(); NameDef nameDef = GraphController.configSer.NameDef.Find(p => p.column == column); tag.column = column; if (nameDef.fullNames == null || nameDef.fullNames.Length == 0) { tag.label = tag.column; } else { tag.label = nameDef.fullNames[0]; } tag.table = GraphController.configSer.TableDef.Find(p => p.tabName.Contains(nameDef.table)).tabName; selectedTags.Add(tag); } dataRequest.definition = selectedTags; dataRequest.requestType = RequestType.absoulteScale; string json = JsonConvert.SerializeObject(dataRequest); ViewBag.json = json; return(View("data")); }
// GET: GraphReport public ActionResult Index() { object pathConfig = null; object pathNames = null; GraphReportForm form = new GraphReportForm(); foreach (string key in Session.Keys) { if (key.Contains("pathConfig") && key.Contains(Request.QueryString["plc"].ToString())) { pathConfig = Session[key]; } if (key.Contains("pathNames") && key.Contains(Request.QueryString["plc"].ToString())) { pathNames = Session[key]; } } Session.Add("pathConfig", pathConfig); Session.Add("pathNames", pathNames); GraphController GC = new GraphController(); GC.getConfig(Session["pathConfig"].ToString(), Session["pathNames"].ToString(), Session["ProjectName"].ToString()); List <NameDef> namedefinition = GraphController.config.NameDefList; List <SelectListItem> tags = new List <SelectListItem>(); foreach (NameDef namedef in namedefinition) { GraphReport.Models.Tag tag = new GraphReport.Models.Tag(); //this will change namedef table to full tablename from tabledef tag.table = GraphController.configSer.TableDef.Find(p => p.tabName.Contains(namedef.table)).tabName; tag.column = namedef.column; if (namedef.fullNames == null || namedef.fullNames.Length == 0) { tag.label = tag.column; } else { tag.label = namedef.fullNames[0]; } SelectListItem item = new SelectListItem() { Value = tag.column, Text = tag.label }; tags.Add(item); } form.beginDateTime = new DateTime(); form.endDateTime = new DateTime(); MultiSelectList multiSelect = new MultiSelectList(tags, "Value", "Text"); form.tagList = multiSelect; form.graphsCount = 1; return(View(form)); }