/***************************** 定时任务调用方法:推送人员信息至大华闸机 ********************************/ /// <summary> /// 人员信息 => 推送人员信息至大华 /// </summary> public static object PUSH_DH_ADD_PERSON(PersonMoudle personMoudle) { X_SUBJECT_TOKEN = RedisHelper.GetDatabase(REDIS_LINE_RECORD_DB_LEVEL).StringGet(REDIS_TOKEN_SET_KEY); if (personMoudle.photoUrl != null && personMoudle.photoUrl.Length != 0) { personMoudle.photoBase64 = GetImageBase64Str.ImageBase64Str(personMoudle.photoUrl); //通过头像地址,获取头像Base64位字符串 } return(HttpHelper.ExecutePostMachineInfo(Constants.CREATE_STUDENTS_INFO + "?sessionId=" + X_SUBJECT_TOKEN, JsonConvert.SerializeObject(personMoudle), X_SUBJECT_TOKEN)); }
// 推送访客至闸机 private string PushVisitor(string studentNum, int sex, string img, string name, string idCode, string buildingId, DateTime endTime) { // 闸机Id列表 var zjids = Read <Relevance>(p => p.SecondKey == buildingId && p.Name == Relation.GateBuilding).Select(p => p.FirstKey).ToList(); var channelIds = Read <Gate>(t => zjids.Contains(t.Id)).Select(p => p.DeviceNumber).ToArray(); var survey = new SurveyMoudle(); survey.channelId = channelIds.Select(p => p + "$7$0$0").ToArray(); survey.code = studentNum; survey.name = name; survey.sex = sex; survey.idCode = idCode; survey.photoBase64 = GetImageBase64Str.ImageBase64Str(img); survey.initialTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); survey.expireTime = endTime.ToString("yyyy-MM-dd HH:mm:ss"); return(DHAccount.TempSurvey(survey)); }
/// <summary> /// 人员信息 => 修改人员信息(大华) /// </summary> /// <param name="personMoudle"></param> public static object PUSH_DH_UPDATE_PERSON(PersonMoudle personMoudle) { X_SUBJECT_TOKEN = RedisHelper.GetDatabase(REDIS_LINE_RECORD_DB_LEVEL).StringGet(REDIS_TOKEN_SET_KEY); if (personMoudle.photoUrl != null && personMoudle.photoUrl.Length != 0) { personMoudle.photoBase64 = GetImageBase64Str.ImageBase64Str(personMoudle.photoUrl);//通过头像地址,获取头像Base64位字符串 } if (default(int) == personMoudle.id) { var PersonJson = HttpHelper.ExecuteGetPersons(Constants.SELECT_STUDENTS_INFO, new PersonMoudle() { code = personMoudle.code }, X_SUBJECT_TOKEN); if (null != PersonJson) { var code = PersonJson.Parse2JObject().Value <int>("code"); if (code == 200) { personMoudle.id = PersonJson.Parse2JObject()["data"]["list"][0].Value <int>("id"); } } } return(HttpHelper.ExecutePut(Constants.UPDATE_STUDENTS_INFO + "?sessionId=" + X_SUBJECT_TOKEN, JsonConvert.SerializeObject(personMoudle), X_SUBJECT_TOKEN)); }
// 下载用户头像,并返回用户 private DataTable DownImage(string[] userId, string imgPath = null) { var stuList = Read <User>(t => userId.Contains(t.Id)).ToList(); var dt = new DataTable(); var dc1 = new DataColumn("姓名", Type.GetType("System.String")); var dc2 = new DataColumn("性别", Type.GetType("System.String")); var dc3 = new DataColumn("学工号", Type.GetType("System.String")); var dc4 = new DataColumn("所属组织", Type.GetType("System.String")); var dc5 = new DataColumn("身份证号", Type.GetType("System.String")); var dc6 = new DataColumn("类别", Type.GetType("System.String")); var dc7 = new DataColumn("联系电话", Type.GetType("System.String")); var dc8 = new DataColumn("紧急联系人", Type.GetType("System.String")); var dc9 = new DataColumn("紧急联系人电话", Type.GetType("System.String")); var dc10 = new DataColumn("门禁卡号", Type.GetType("System.String")); var dc11 = new DataColumn("院区", Type.GetType("System.String")); var dc12 = new DataColumn("宿舍", Type.GetType("System.String")); var dc13 = new DataColumn("楼层", Type.GetType("System.String")); var dc14 = new DataColumn("寝室", Type.GetType("System.String")); var dc15 = new DataColumn("校区", Type.GetType("System.String")); var dc16 = new DataColumn("院系", Type.GetType("System.String")); var dc17 = new DataColumn("专业", Type.GetType("System.String")); var dc18 = new DataColumn("年级", Type.GetType("System.String")); var dc19 = new DataColumn("班级", Type.GetType("System.String")); dt.Columns.Add(dc1); dt.Columns.Add(dc2); dt.Columns.Add(dc3); dt.Columns.Add(dc4); dt.Columns.Add(dc5); dt.Columns.Add(dc6); dt.Columns.Add(dc7); dt.Columns.Add(dc8); dt.Columns.Add(dc9); dt.Columns.Add(dc10); dt.Columns.Add(dc11); dt.Columns.Add(dc12); dt.Columns.Add(dc13); dt.Columns.Add(dc14); dt.Columns.Add(dc15); dt.Columns.Add(dc16); dt.Columns.Add(dc17); dt.Columns.Add(dc18); dt.Columns.Add(dc19); foreach (var d in stuList) { var studentNo = d.Name; var imgUri = d.HeadIcon; var gender = "女"; var certificateNo = ""; var userType = "访客"; var ss = ""; var lc = ""; var ld = ""; if (d.DutyId.Contains("student")) { var stu = Read <Student>(p => p.UserId == d.Id).FirstOrDefault(); studentNo = stu?.StudentNumber; //imgUri = stu?.F_FacePic_File; gender = stu?.Gender == "0" ? "女" : "男"; certificateNo = stu?.CardNumber; userType = "学生"; var ssdata = Query <DormStudent>(p => p.StudentId == stu.Id).FirstOrDefault(); ss = ssdata?.DormInfo?.Title; lc = ssdata?.DormInfo?.FloorNumber; var ldid = ssdata?.DormInfo?.BuildingId; var lddata = Read <Building>(p => p.Id == ldid).FirstOrDefault(); ld = lddata?.BuildingNo; } if (d.DutyId.Contains("teacher")) { var tea = Read <Teacher>(p => p.UserId == d.Id).FirstOrDefault(); studentNo = tea?.JobNumber; imgUri = tea?.FacePhoto; gender = tea?.Gender == "0" ? "女" : "男"; certificateNo = tea?.CredNumber; userType = "教职工"; } var filepath = imgPath; if (string.IsNullOrEmpty(imgPath)) { filepath = System.AppDomain.CurrentDomain.BaseDirectory + "\\HeadIcoTemp\\"; } if (Directory.Exists(filepath)) { Directory.Delete(filepath, true); } Directory.CreateDirectory(filepath); var fileName = filepath + studentNo + ".png"; var t = GetImageBase64Str.DownLoadPic(imgUri, fileName); if (t) { var dr = dt.NewRow(); dr["姓名"] = d.Name; dr["性别"] = gender; dr["学工号"] = studentNo; dr["所属组织"] = "南昌航空大学"; dr["身份证号"] = certificateNo; dr["类别"] = userType; dr["联系电话"] = ""; dr["紧急联系人"] = ""; dr["紧急联系人电话"] = ""; dr["门禁卡号"] = ""; dr["院区"] = "宿舍管理"; dr["宿舍"] = ld; dr["楼层"] = lc; dr["寝室"] = ss; dr["校区"] = ""; dr["院系"] = ""; dr["专业"] = ""; dr["年级"] = ""; dr["班级"] = ""; dt.Rows.Add(dr); } } return(dt); }