/// <summary> /// 获取门禁卡操作历史 /// </summary> /// <param name="id"></param> /// <param name="begin_date"></param> /// <param name="end_date"></param> /// <returns></returns> public List <cards_actions> GetCardActions(int id, string begin_date, string end_date) { BaseTran <cards_actions> recv = new BaseTran <cards_actions>(); string path = "cards/" + Convert.ToString(id) + "/actions"; string url = BaseUri + path; if (begin_date != null) { url += "?begin_date=" + begin_date; } else { url += "?begin_date"; } if (end_date != null) { url += "&end_date=" + end_date; } else { url += "&end_date"; } recv = GetEntityList <cards_actions>(url); if (recv.data == null) { recv.data = new List <cards_actions>(); } return(recv.data); }
/// <summary> /// 获取单台设备操作历史 /// </summary> /// <param name="id"></param> /// <param name="begin_date"></param> /// <param name="end_date"></param> /// <returns></returns> public List <devices_actions> GetDeviceActions(int id, string begin_date, string end_date) { string path = "api/devices/" + id + "/actions"; string url = BaseUri + path; if (begin_date != null) { url += "?begin_date=" + begin_date; } else { url += "?begin_date"; } if (end_date != null) { url += "&end_date=" + end_date; } else { url += "&end_date"; } BaseTran <devices_actions> recv = new BaseTran <devices_actions>(); recv = GetEntityList <devices_actions>(url); if (recv.data == null) { recv.data = new List <devices_actions>(); } return(recv.data); }
public BaseTran <T> GetEntityList <T>(string url, bool nullable = false) where T : new() { var recv = new BaseTran <T>(); try { recv = WebApiHelper.GetEntity <BaseTran <T> >(url); if (recv == null) { Log.Info(LogTags.BaseData, "BaseDataInnerClient.GetEntityList recv==null:" + url); //return null; recv = new BaseTran <T>(); } } catch (Exception ex) { Message = ex.Message; Log.Error(LogTags.BaseData, "BaseDataInnerClient.GetEntityList:" + url + "\n" + Message); recv = new BaseTran <T>(); } if (nullable == false)//列表不能为null,因为返回后有要放到foreach里面 { if (recv.data == null) { recv.data = new List <T>(); } } return(recv); }
public BaseTran <sis> GetSis(string tags) { //BaseDataDb db = new BaseDataDb(); var list = new List <sis>(); string[] tagList = tags.Split(','); Bll bll = new Bll(); foreach (var tag in tagList) { var monitor = bll.DevMonitorNodes.Find(p => p.TagName == tag); sis sis = new sis(); sis.kks = tag; sis.t = DateTime.Now.ToStamp(); if (monitor != null) { sis.value = monitor.Value; sis.unit = monitor.Unit; } if (string.IsNullOrEmpty(sis.value)) { sis.value = "-1";//代表模拟数据 } list.Add(sis); } var data = new BaseTran <sis>(list); return(data); }
/// <summary> /// 获取SIS传感数据 /// </summary> /// <param name="strTags"></param> /// <returns></returns> public List <sis> GetSisList(string strTags) { //string path = "api/rt/sis?kks=" + kks; //string url = BaseUri + path; //string[] sArray = BaseUri.Split(new string[] { "api" }, StringSplitOptions.RemoveEmptyEntries); //string BaseUri2 = sArray[0]; // BaseUri2 += "api-viz/"; ParkName = AppContext.ParkName; if (ParkName == "中山嘉明电厂") { string url = BaseUri + "Sis/list/kks/" + strTags; int length = url.Length;//max:2083 List <sis> list = GetEntityList2 <sis>(url); return(list); } else { BaseTran <sis> recv = new BaseTran <sis>(); // string url = BaseUri + "rt/sis/" + strTags; string url = BaseUri + "Sis/list"; int length = url.Length;//max:2083 recv = GetEntityList <sis>(url, true); //if (recv.data == null) //{ // recv.data = new List<sis>(); //} return(recv.data); } }
public BaseTran <users> GetUserList() { BaseTran <users> send = new BaseTran <users>(); List <users> lst = new List <users>(); lst.Add(new users() { id = 1, name = "蔡万伟", gender = 1, email = "*****@*****.**", phone = "111111111", mobile = "aaaaaaaaa", enabled = true, dept_name = "研发" }); lst.Add(new users() { id = 2, name = "叶宗雷", gender = 1, email = "*****@*****.**", phone = "222222222", mobile = "bbbbbbbbb", enabled = true, dept_name = "研发" }); lst.Add(new users() { id = 3, name = "郑国涛", gender = 1, email = "*****@*****.**", phone = "333333333", mobile = "ccccccccc", enabled = true, dept_name = "研发" }); lst.Add(new users() { id = 4, name = "王朝武", gender = 1, email = "*****@*****.**", phone = "444444444", mobile = "ddddddddd", enabled = true, dept_name = "研发" }); lst.Add(new users() { id = 5, name = "王锴", gender = 1, email = "*****@*****.**", phone = "555555555", mobile = "eeeeeeeee", enabled = true, dept_name = "研发" }); send.total = 5; send.msg = "ok"; send.data = lst; return(send); }
public BaseTran <tickets> GetList(int type, string begin_date, string end_date) { var lst = items.FindAll(i => i.type == type); var send = new BaseTran <tickets>(lst); return(send); }
public BaseTran <tickets> GetList() { var lst = items; var send = new BaseTran <tickets>(lst); return(send); }
public BaseTran <events> GeteventsList(int?src, int?level, long?begin_t, long?end_t) { BaseTran <events> send = new BaseTran <events>(); List <events> lst = new List <events>(); foreach (var item in dict) { events Val = item.Value.Clone(); events data = null; if (src != null) { if (Val.src == src) { data = Val.Clone(); } else { data = null; } } if (level != null) { if (Val.level == level) { data = Val.Clone(); } else { data = null; } } if (begin_t != null && end_t != null) { if (Val.t >= begin_t && Val.t <= end_t) { data = Val.Clone(); } else { data = null; } } if (data != null) { lst.Add(data); } } send.total = lst.Count; send.msg = "ok"; send.data = lst; return(send); }
public List <device> GetDevices() { string path = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\BaseData\\devices.json"; string json = File.ReadAllText(path); BaseTran <device> obj = JsonConvert.DeserializeObject <BaseTran <device> >(json); return(obj.data); }
/// <summary> /// 获取门禁卡列表 /// </summary> /// <returns></returns> public List <cards> GetCardList() { string path = "cards"; string url = BaseUri + path; BaseTran <cards> recv = new BaseTran <cards>(); recv = GetEntityList <cards>(url); return(recv.data); }
public List <user> GetUserList() { BaseTran <user> recv = new BaseTran <user>(); string path = "users"; string url = BaseUri + path; recv = GetEntityList <user>(url); return(recv.data); }
public List <device> GetDeviceList(string types, string code, string name) { BaseTran <device> recv = new BaseTran <device>(); string path = "devices"; string url = BaseUri + path; if (types == null && code == null && name == null) { } else { if (types != null) { url += "?types=" + types; } else { url += "?types"; } if (code == null && name == null) { } else { if (code != null) { url += "&code=" + code; } else { url += "&code"; } if (name != null) { url += "&name=" + name; } else { url += "&name"; } } } recv = GetEntityList <device>(url); if (recv.data == null) { recv.data = new List <device>(); } return(recv.data); }
public BaseTran <sis> GetSomesisList(string kks) { BaseTran <sis> recv = new BaseTran <sis>(); try { string path = "api/rt/sis?kks=" + kks; string url = BaseUri + path; recv = GetEntityList <sis>(url); if (recv.data == null) { recv.data = new List <sis>(); } foreach (sis item in recv.data) { DevInfo DevInfo = bll.DevInfos.DbSet.Where(p => p.KKS == item.kks).FirstOrDefault(); if (DevInfo == null) { continue; } DevInstantData did = bll.DevInstantDatas.DbSet.Where(p => p.Id == item.kks).FirstOrDefault(); if (did == null) { did = new DevInstantData(); did.Id = item.kks; did.Value = item.value; did.DateTime = DateTime.Now; did.DateTimeStamp = TimeConvert.DateTimeToTimeStamp(did.DateTime); bll.DevInstantDatas.Add(did); } else { DevInstantDataHistory didh = did.RemoveToHistory(); did.Value = item.value; did.DateTime = DateTime.Now; did.DateTimeStamp = TimeConvert.DateTimeToTimeStamp(did.DateTime); bll.DevInstantDatas.Edit(did); bll.DevInstantDataHistorys.Add(didh); } } } catch (Exception ex) { string messgae = ex.Message; } return(recv); }
private BaseTran <T> LoadFromFile <T>(string fileName) { string path = AppDomain.CurrentDomain.BaseDirectory + "Data\\BaseData\\" + fileName + ".json"; if (File.Exists(path)) { string json = File.ReadAllText(path); BaseTran <T> data = JsonConvert.DeserializeObject <BaseTran <T> >(json); return(data); } return(null); }
public List <org> GetOrgList() { BaseTran <org> recv = new BaseTran <org>(); string path = "orgs"; string url = BaseUri + path; recv = GetEntityList <org>(url); if (recv.data == null) { recv.data = new List <org>(); } return(recv.data); }
public List <zone> GetZoneList() { string path = "zones?struct=LIST"; string url = BaseUri + path; BaseTran <zone> recv = new BaseTran <zone>(); recv = GetEntityList <zone>(url); if (recv.data == null) { recv.data = new List <zone>(); } return(recv.data); }
/// <summary> /// 获取指定区域下设备列表 /// </summary> /// <param name="zoneId"></param> /// <returns></returns> public List <device> GetZoneDeviceList(int zoneId) { BaseTran <device> recv = new BaseTran <device>(); string path = "api/zones/" + zoneId + "/devices"; string url = BaseUri + path; recv = GetEntityList <device>(url); if (recv.data == null) { recv.data = new List <device>(); } return(recv.data); }
/// <summary> /// 获取两票列表 /// </summary> /// <param name="type">1:操作票;2:工作票</param> /// <param name="begin_date">格式:yyyyMMdd 默认为当天</param> /// <param name="end_date">跨度最大一个月</param> /// <returns></returns> public BaseTran <tickets> GetTicketsList(string type, string begin_date, string end_date) { BaseTran <tickets> recv = new BaseTran <tickets>(); string path = "api/tickets"; string url = BaseUri + path; QueryArg query = new QueryArg(); query.Add("type", type); query.Add("begin_date", begin_date); query.Add("end_date", end_date); url += query.GetQueryString(); recv = GetEntityList <tickets>(url); if (recv.data == null) { recv.data = new List <tickets>(); } return(recv); }
public BaseTran <cards> GetDeviceList() { BaseTran <cards> send = new BaseTran <cards>(); List <cards> lst = new List <cards>(); foreach (var item in dict) { cards data = new cards(); data = item.Value.Clone(); lst.Add(data); } send.total = lst.Count; send.msg = "ok"; send.data = lst; return(send); }
public BaseTran <org> GetorgList() { BaseTran <org> send = new BaseTran <org>(); List <org> lst = new List <org>(); foreach (var item in dict) { org data = new org(); data = item.Value.Clone(); lst.Add(data); } send.total = lst.Count; send.msg = "ok"; send.data = lst; return(send); }
public BaseTran <T> GetEntityList <T>(string url) { var recv = new BaseTran <T>(); try { recv = WebApiHelper.GetEntity <BaseTran <T> >(url); if (recv.data == null) { recv.data = new List <T>(); } } catch (Exception ex) { Message = ex.Message; return(null); } return(recv); }
/// <summary> /// 获取告警事件列表 /// </summary> /// <param name="src"></param> /// <param name="level"></param> /// <param name="begin_t"></param> /// <param name="end_t"></param> /// <returns></returns> public List <events> GetEventList(int?src, int?level, long?begin_t, long?end_t) { BaseTran <events> recv = new BaseTran <events>(); string path = "events"; string url = BaseUri + path; if (src != null) { url += "?src=" + Convert.ToString(src); } else { url += "?src"; } if (level != null) { url += "&level=" + Convert.ToString(level); } else { url += "&level"; } if (begin_t != null && end_t != null) { url += "&begin_t=" + Convert.ToString(begin_t) + "&end_t=" + Convert.ToString(end_t); } else { url += "&begin_t" + "&end_t"; } recv = GetEntityList <events>(url); if (recv.data == null) { recv.data = new List <events>(); } return(recv.data); }
public BaseTran <zones> GetzonesList(string struc) { BaseTran <zones> send = new BaseTran <zones>(); List <zones> lst = new List <zones>(); foreach (var item in dict) { zones data = new zones(); data = item.Value.Clone(); data.lstdev = null; data.lstzon = null; lst.Add(data); } send.total = lst.Count; send.msg = "ok"; send.data = lst; return(send); }
public BaseTran <devices> GetZoneDevList(string id) { BaseTran <devices> send = new BaseTran <devices>(); List <devices> lst = new List <devices>(); zones data = new zones(); int nId = Convert.ToInt32(id); if (dict.ContainsKey(nId)) { data = dict[nId].Clone(); } lst = data.lstdev; send.total = lst.Count; send.msg = "ok"; send.data = lst; return(send); }
public BaseTran <cards_actions> GetSingleCardActionHistory(string id, string begin_date, string end_date) { BaseTran <cards_actions> send = new BaseTran <cards_actions>(); List <cards_actions> lst = new List <cards_actions>(); List <cards_actions> lst2 = new List <cards_actions>(); int nId = Convert.ToInt32(id); foreach (var item in dict2) { cards_actions copy = item.Value.Clone(); if (copy.device_id == nId) { lst2.Add(copy); } } if (begin_date != null && end_date != null) { DateTime dtBegin = DateTime.ParseExact(begin_date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); DateTime dtEnd = DateTime.ParseExact(end_date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0)); long begin = (dtBegin.Ticks - startTime.Ticks) / 10000000; long end = (dtEnd.Ticks - startTime.Ticks) / 10000000; lst = lst2.Where(p => (p.t >= begin && p.t <= end)).ToList(); } else { lst = lst2; } send.total = lst.Count; send.msg = "ok"; send.data = lst; return(send); }
public BaseTran <sis> GetSomesisList(string kks) { BaseTran <sis> send = new BaseTran <sis>(); List <sis> lst = new List <sis>(); Dictionary <string, string> dictCom = new Dictionary <string, string>(); string[] kkss = null; if (kks != null) { kkss = kks.Split(','); for (int i = 0; i < kkss.Length; i++) { string val = kkss[i]; if (!dictCom.ContainsKey(val)) { dictCom.Add(val, val); } } } foreach (var item in dict) { sis val = item.Value.Clone(); if (dictCom.ContainsKey(val.kks)) { lst.Add(val); } } send.total = lst.Count; send.msg = "ok"; send.data = lst; return(send); }
/// <summary> /// 获取人员列表 /// </summary> /// <returns></returns> public BaseTran <user> GetUserList() { //users recv = new users(); //BaseTran<user> recv2 = new BaseTran<user>(); BaseTran <user> recv = new BaseTran <user>(); try { string path = "api/users"; string url = BaseUri + path; recv = GetEntityList <user>(url); foreach (user item in recv.data) { List <Personnel> PeList = bll.Personnels.DbSet.Where(p => p.Name == item.name).ToList(); Personnel Personnel = null; int nFlag = 0; int nCount = 0; if (PeList.Count == 0) { Personnel = new Personnel(); Personnel.ParentId = null; nFlag = 0; } else { foreach (Personnel item2 in PeList) { if (item2.Abutment_Id == item.id) { nFlag = 1; Personnel = item2; break; } else { nFlag = 2; Personnel = item2; nCount++; } } } if (nFlag == 2 && nCount > 1) { FileStream fs = System.IO.File.Create(@"a.txt"); StreamWriter sw = new StreamWriter(fs); sw.WriteLine("id=" + item.id + " Name=" + item.name + " Depart=" + item.dept_name); sw.Close(); fs.Close(); continue; } Personnel.Abutment_Id = item.id; Personnel.Name = item.name; Personnel.Sex = (Sexs)item.gender; Personnel.Email = item.email; Personnel.Phone = item.phone; Personnel.Mobile = item.mobile; Personnel.Enabled = item.enabled; if (item.dept_name != null) { Department Department = bll.Departments.DbSet.Where(p => p.Name == item.dept_name).FirstOrDefault(); if (Department != null) { Personnel.ParentId = Department.Id; } } if (nFlag == 0) { bll.Personnels.Add(Personnel); } else { bll.Personnels.Edit(Personnel); } } } catch (Exception ex) { string messgae = ex.Message; } return(recv); }
/// <summary> /// 获取两票列表 /// </summary> /// <param name="type">1:操作票;2:工作票</param> /// <param name="begin_date">格式:yyyyMMdd 默认为当天</param> /// <param name="end_date">跨度最大一个月</param> /// <returns></returns> public BaseTran <tickets> GetTicketsList(string type, string begin_date, string end_date) { BaseTran <tickets> recv = new BaseTran <tickets>(); try { string path = "api/tickets"; string url = BaseUri + path; QueryArg query = new QueryArg(); query.Add("type", type); query.Add("begin_date", begin_date); query.Add("end_date", end_date); url += query.GetQueryString(); recv = GetEntityList <tickets>(url); if (recv.data == null) { recv.data = new List <tickets>(); } foreach (tickets item in recv.data) { int nFlag = 0; if (item.type == 1) { OperationTicket ot = bll.OperationTickets.DbSet.Where(p => p.Abutment_Id == item.id).FirstOrDefault(); if (ot == null) { ot = new OperationTicket(); ot.OperationStartTime = DateTime.Now; ot.OperationEndTime = DateTime.Now.AddDays(1); nFlag = 1; } ot.Abutment_Id = item.id; ot.No = item.code; if (nFlag == 1) { bll.OperationTickets.Add(ot); } else { bll.OperationTickets.Edit(ot); } } else { WorkTicket wt = bll.WorkTickets.DbSet.Where(p => p.Abutment_Id == item.id).FirstOrDefault(); if (wt == null) { wt = new WorkTicket(); wt.StartTimeOfPlannedWork = DateTime.Now; wt.EndTimeOfPlannedWork = DateTime.Now.AddDays(1); nFlag = 1; } wt.Abutment_Id = item.id; wt.No = item.code; if (nFlag == 1) { bll.WorkTickets.Add(wt); } else { bll.WorkTickets.Edit(wt); } } } } catch (Exception ex) { string messgae = ex.Message; } return(recv); }
// GET: users public ActionResult GetUserList() { BaseTran <user> recv = client.GetUserList(); return(View(recv)); }