public static AjaxResult AddPassword(string id, string deviceId, string password, string startDate, string endDate, string locktype) { NewLockManager managerNew = new NewLockManager(); string start = managerNew.GetDateTime(startDate).ToString(); string end = managerNew.GetDateTime(endDate).ToString(); if (locktype == "1") //新锁 { string type = startDate == endDate ? "1" : "2"; string returnDate = managerNew.GetPostInterface(deviceId, "Admin", type, password, start, end); Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(returnDate); if (returnInfo["ret"].ToString() == "1") { return(AjaxResult.Error(returnInfo["msg"].ToString())); } } else { LockManager manager = new LockManager(); manager.AddPassword(deviceId, password, startDate, endDate); string ret = manager.UpdatePassengerInfoToDevice(deviceId, "", "", "", password, DateTime.Parse(start).ToString("yyyyMMddHHmm").Substring(2, 10), DateTime.Parse(end).ToString("yyyyMMddHHmm").Substring(2, 10), "3"); } return(AjaxResult.Success()); }
public static AjaxResult AddIDCard(string ID, string LockType) { DateTime startDate = DateTime.Now.AddDays(-1); DateTime endDate = DateTime.Now.AddDays(1); if (LockType == "1") //新锁 { NewLockManager managerNew = new NewLockManager(); string returnDate = managerNew.GetPostInterface(ID, "Admin", "4", "", startDate.ToString(), endDate.ToString()); Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(returnDate); if (returnInfo["ret"].ToString() == "1") { return(AjaxResult.Error(returnInfo["msg"].ToString())); } } else { LockManager manager = new LockManager(); string ret = manager.UpdatePassengerInfoToDevice(ID, "", "", "", "", startDate.ToString("yyyyMMddHHmm").Substring(2, 10), endDate.ToString("yyyyMMddHHmm").Substring(2, 10), "7"); } return(AjaxResult.Success()); }
public string NewAddPasswordICcard(string newLockId, string type, string pwdAndCard, string startTime, string endTime, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } NewLockManager managerNew = new NewLockManager(); Dictionary <string, string> ret = new Dictionary <string, string>(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("newLockId", newLockId); dic.Add("type", type); if (type == "1" || type == "2") { if (pwdAndCard == string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "永久录入字段pwdAndCard不允许为空!"); return(JSONHelper.ToJson(ret)); } else { dic.Add("pwdAndCard", pwdAndCard); } } dic.Add("startTime", startTime); dic.Add("endTime", endTime); string returnFiled = managerNew.checkIsNullFild(dic); if (returnFiled != string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "字段" + returnFiled + "不允许为空!"); return(JSONHelper.ToJson(ret)); } //是否给公司授权 if (managerNew.GetIsEnterprise(userId) == "2") { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //判断接口是否授权 if (!managerNew.GetIsInterfacePermissions("10", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } string[] strArr = { "1", "2", "3", "4" }; bool exists = ((IList)strArr).Contains(type); if (!exists) { ret.Add("ret", "1"); ret.Add("msg", "type参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } string deviceId = managerNew.getDeviceID(newLockId, "DeviceID"); string UserId = managerNew.getDeviceID(newLockId, "UserId"); if (deviceId == string.Empty || userId == string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "未获取该家庭锁信息!"); return(JSONHelper.ToJson(ret)); } return(managerNew.GetPostInterface(deviceId, UserId, type, pwdAndCard, startTime, endTime)); }