public JsonResult GetStaffs(int page, int rows, string birthBegin, string birthEnd) { MongoDbRemoteRepository<Staff> repository = new MongoDbRemoteRepository<Staff>(); repository.Connect(); List<Staff> list = repository.List(i => i.GRADUATION_SCHOOL=="四川大学"); repository.CloseConnect(); var json2 = new { total = list.Count, rows = list.ToArray(), }; return Json(json2, JsonRequestBehavior.AllowGet); }
public JsonResult GetStaffs(int page, int rows, string birthBegin, string birthEnd) { MongoDbRemoteRepository <Staff> repository = new MongoDbRemoteRepository <Staff>(); repository.Connect(); List <Staff> list = repository.List(i => i.GRADUATION_SCHOOL == "四川大学"); repository.CloseConnect(); var json2 = new { total = list.Count, rows = list.ToArray(), }; return(Json(json2, JsonRequestBehavior.AllowGet)); }
public string D3Json() { if (mongoDbRemoteRepository != null) { mongoDbRemoteRepository.Connect(); var opcModels = mongoDbRemoteRepository.List(i => i.TagNo == "1TIC516JRQ-5A").OrderBy(i => i.Time).ToList(); if (opcModels.Count > 0) { string time = opcModels.ElementAt(0).Id.Created.ToString("yyyy-MM-dd hh:mm:ss"); string times = opcModels.ElementAt(0).Time; } string sd = "["; int k = 1; foreach (var modle in opcModels) { sd = sd + "{" + "\"Time\":" + k + "," + "\"Value\"" + ":" + modle.Value + "},"; k++; } sd = sd.Substring(0, sd.Length - 1) + "]"; string content = JsonConvert.SerializeObject(opcModels); mongoDbRemoteRepository.CloseConnect(); return(sd); } List <D3JsonC> list = new List <D3JsonC>(); for (int i = 0; i < 3; i++) { D3JsonC json = new D3JsonC(); json.date = i + 1; json.close = 20 + i; list.Add(json); } StringBuilder builder = new StringBuilder(); builder.Append(@"[{" + "\"date\"" + ":" + "\"1\"" + "," + "\"close\"" + ":" + "\"582.13\"" + "},"); builder.Append(@"{" + "\"date\"" + ":" + "\"2\"" + "," + "\"close\"" + ":" + "\"583.98\"" + "},"); builder.Append(@"{" + "\"date\"" + ":" + "\"3\"" + "," + "\"close\"" + ":" + "\"603\"" + "}]"); var s = Json(list, JsonRequestBehavior.AllowGet); //return Line(); return(Dc()); }
public string TagData(string tagNo) { this.mongoDbRemoteRepository = new MongoDbRemoteRepository<OpcModel>(); mongoDbRemoteRepository.Connect(); var opcModels = mongoDbRemoteRepository.List(i => i.TagNo == tagNo).OrderBy(i => i.Time).ToList(); string sd = "["; int k = 1; foreach (var modle in opcModels) { sd = sd + "{" + "\"Time\":\"" + modle.Id.Created.ToString("yyyy-MM-dd hh:mm:ss") + "\"," + "\"Value\"" + ":" + modle.Value + "},"; k++; if(k>=100) { break; } } sd = sd.Substring(0, sd.Length - 1) + "]"; string content = JsonConvert.SerializeObject(opcModels); mongoDbRemoteRepository.CloseConnect(); return sd; }
public string TagData(string tagNo) { this.mongoDbRemoteRepository = new MongoDbRemoteRepository <OpcModel>(); mongoDbRemoteRepository.Connect(); var opcModels = mongoDbRemoteRepository.List(i => i.TagNo == tagNo).OrderBy(i => i.Time).ToList(); string sd = "["; int k = 1; foreach (var modle in opcModels) { sd = sd + "{" + "\"Time\":\"" + modle.Id.Created.ToString("yyyy-MM-dd hh:mm:ss") + "\"," + "\"Value\"" + ":" + modle.Value + "},"; k++; if (k >= 100) { break; } } sd = sd.Substring(0, sd.Length - 1) + "]"; string content = JsonConvert.SerializeObject(opcModels); mongoDbRemoteRepository.CloseConnect(); return(sd); }