public JsonResult MeetingDataToJson(RoomObject Obj) //處理給Google的Json數據 { IQueryable <MeetingData> MData = _db.MeetingData.Where(x => x.STime.Contains(Obj.SearchDate)).AsQueryable().OrderBy(x => x.Room); if (MData.Count() == 0) { return(this.Json("")); } Graph graph = new Graph { cols = new List <Col> { // id 可直接填空字串,預設會自動建立 // label 為提示訊息前置值,假如 沒有設定 f 資料,預設會讀取 label 加上此資料格的值 例如:小計:654.0600 // type 此欄資料格式,只有 boolean、number、string、date、datetime、timeofday 六種格式 new Col { id = "Room", label = "會議室", type = "string" }, new Col { id = "Event", label = "申請事由", type = "string" }, new Col { id = "STime", label = "起始時間", type = "date" }, new Col { id = "ETime", label = "結束時間", type = "date" } }, rows = new List <DataPointSet>() }; List <DataPointSet> rows = new List <DataPointSet>(); foreach (MeetingData mt in MData) { DataPointSet cSetRow = new DataPointSet(); List <DataPoint> cSetList = new List <DataPoint>(); DataPoint[] cSetProp = new DataPoint[5]; //將會議室數據轉為LIST cSetProp[0] = new DataPoint(); cSetProp[0].v = mt.Room.Trim(' '); cSetList.Add(cSetProp[0]); cSetProp[1] = new DataPoint(); cSetProp[1].v = "申請事由:" + mt.Event.Trim(' ') + " 申請人:" + mt.Applicant.Trim(' ');; cSetList.Add(cSetProp[1]); cSetProp[2] = new DataPoint(); cSetProp[2].v = Timehandle(mt.STime); cSetList.Add(cSetProp[2]); cSetProp[3] = new DataPoint(); cSetProp[3].v = Timehandle(mt.ETime); cSetList.Add(cSetProp[3]); cSetRow.c = cSetList; rows.Add(cSetRow); } graph.rows = rows; return(this.Json(graph, JsonRequestBehavior.AllowGet)); }
private bool LoadLocationDataFile(string filePath) { bool loaded = false; _locationDataSet = new DataPointSet(); try { if (File.Exists(filePath)) { using (FileStream fs = new FileStream(filePath, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs)) { sr.ReadLine(); //just the header. There's no need to do anything with it GISDataPoint gsPoint = null; while (!sr.EndOfStream) { string currentLine = sr.ReadLine(); string[] arrayValues = currentLine.Split('\t'); foreach (double rangeKey in rangeOfTimeDictionary.Keys) { switch (DataSetTimeDomain) { case Common.TimeDomain.Year: gsPoint = new GISDataPoint(Int64.Parse(arrayValues[COLUMN_ID]), rangeKey, Double.Parse(arrayValues[COLUMN_X]), Double.Parse(arrayValues[COLUMN_Y]), 0, rangeOfTimeDictionary[rangeKey]); break; case Common.TimeDomain.YearMonth: gsPoint = new GISDataPoint(Int64.Parse(arrayValues[COLUMN_ID]), rangeKey, Double.Parse(arrayValues[COLUMN_X]), Double.Parse(arrayValues[COLUMN_Y]), 0, rangeOfTimeDictionary[rangeKey]); break; case Common.TimeDomain.YearMonthDay: gsPoint = new GISDataPoint(Int64.Parse(arrayValues[COLUMN_ID]), rangeKey, Double.Parse(arrayValues[COLUMN_X]), Double.Parse(arrayValues[COLUMN_Y]), 0, rangeOfTimeDictionary[rangeKey]); break; case Common.TimeDomain.YearQuarter: gsPoint = new GISDataPoint(Int64.Parse(arrayValues[COLUMN_ID]), rangeKey, Double.Parse(arrayValues[COLUMN_X]), Double.Parse(arrayValues[COLUMN_Y]), 0, rangeOfTimeDictionary[rangeKey]); break; } _listLocationDataPoints.Add(gsPoint); } } } } } else { //should throw? //probably just log and return false; } if (_listLocationDataPoints.Count > 0) { loaded = true; } } catch (Exception ex) { throw ex; } return(loaded); }