/// <summary> /// 留言 /// </summary> /// <param name="context"></param> /// <param name="ob"></param> /// <returns></returns> private ResponeDataEntity SetMsg(HttpContext context, JObject ob) { string snumber = ob["student"].ToString(); string message = ob["message"].ToString(); string phonenumber = ob["phonenumber"].ToString(); string unionid = ob["unionid"].ToString(); bool hasRelationShipe = false; ResponeDataEntity entity = new ResponeDataEntity(); entity.Status = 1; logHelper.logInfo(" SetMsg params:student:" + snumber + " message:" + message + " phonenumber:" + phonenumber + " unionid:" + unionid); //获取学生对象 Daiv_OA.Entity.StudentEntity stuEntity = stubll.GetEntityByNumber(snumber); if (stuEntity == null) { return new ResponeDataEntity() { Status = 0, Msg = snumber + "学生学号无效!" } } ; //验证学号和电话号码是否关联 List <Daiv_OA.Entity.ContactEntity> ctEntitys = ctbll.GetEntitysBySid(stuEntity.Sid); if (ctEntitys == null || ctEntitys.Count <= 0) { return new ResponeDataEntity() { Status = 0, Msg = snumber + "学生学号无情亲号!" } } ; foreach (var item in ctEntitys) { if (item.Cphone == phonenumber) { hasRelationShipe = true; } } if (!hasRelationShipe) { return new ResponeDataEntity() { Status = 0, Msg = snumber + "学生学号的情亲号不存在:" + phonenumber + "!" } } ; //保存用户留言 MessageEntity mentity = new MessageEntity(); mentity.ToUid = stuEntity.Sid; mentity.ToUname = stuEntity.Sname; mentity.FromUid = 0; mentity.Mtitle = phonenumber;//作为电话号码 mentity.Content = message; mentity.Addtime = DateTime.Now; new Daiv_OA.BLL.MessageBLL().Add(mentity); return(entity); }
/// <summary> /// 根据微信OpenID 获取用户信息 /// </summary> /// <param name="context"></param> /// <param name="ob"></param> /// <returns></returns> private ResponeDataEntity WXGetUser(HttpContext context, JObject ob) { string openId = ob["openId"].ToString(); string snumber = ob["snumber"].ToString(); WXUserEntity wxModel = new BLL.WXUserBLL().GetEntityByOpenId(openId); List <Daiv_OA.Entity.ContactEntity> ctEntitys = null; if (wxModel == null) { return new ResponeDataEntity() { Data = new { wxphone = "", stunumber = "", uid = 0, contacts = ctEntitys } } } ; //获取OA用户信息 //UserEntity umodel = new BLL.UserBLL().GetEntity(wxModel.OAUserID); ResponeDataEntity resultModel = new ResponeDataEntity(); //获取亲情号 Daiv_OA.Entity.StudentEntity stuEntity = stubll.GetEntityByNumber(snumber); ctEntitys = ctbll.GetEntitysBySid(stuEntity.Sid); resultModel.Status = 1; resultModel.Data = new { wxphone = wxModel.WXUserPhone, stunumber = "", uid = 0, contacts = ctEntitys }; return(resultModel); }
/// <summary> /// 根据学生序号获取联系电话 /// </summary> /// <param name="context"></param> /// <returns></returns> private ResponeDataEntity getContactBySnum(HttpContext context, JObject ob) { string snumber = ob["sNumber"].ToString(); logHelper.logInfo(" getContactBySnum params中文:sNumber:" + snumber); //获取学生对象 Daiv_OA.Entity.StudentEntity stuEntity = stubll.GetEntityByNumber(snumber); if (stuEntity == null) { return new ResponeDataEntity() { Status = 0, Msg = snumber + "学生学号无效!" } } ; List <Daiv_OA.Entity.ContactEntity> ctEntitys = ctbll.GetEntitysBySid(stuEntity.Sid); return(new ResponeDataEntity() { Status = 1, Data = ctEntitys }); }
/// <summary> /// 修改联系电话 /// </summary> /// <param name="context"></param> /// <returns></returns> private ResponeDataEntity SetContact(HttpContext context, JObject ob) { string snumber = ob["sNumber"].ToString(); string password = ob["password"].ToString(); string cPhone = ob["cPhone"].ToString(); string cPhoneName = ob["cPhoneName"].ToString(); string cPhone2 = ob["cPhone2"].ToString(); string cPhone3 = ob["cPhone3"].ToString(); string cPhone4 = ob["cPhone4"].ToString(); ResponeDataEntity resultEntity = new ResponeDataEntity(); logHelper.logInfo(" SetContact params:sNumber:" + snumber + " cPhone:" + cPhone + " cPhone2:" + cPhone2 + "cPhone3:" + cPhone3 + " cPhone4:" + cPhone4); //获取学生对象 Daiv_OA.Entity.StudentEntity stuEntity = stubll.GetEntityByNumber(snumber); if (stuEntity == null) { return new ResponeDataEntity() { Status = 0, Msg = snumber + "学生学号无效!" } } ; string uid = new Daiv_OA.BLL.UserBLL().Existslongin(snumber, Daiv_OA.Utils.MD5.Lower32(password)); if (string.IsNullOrEmpty(uid)) { return(new ResponeDataEntity() { Status = 0, Msg = snumber + "输入密码无效!" }); } //Daiv_OA.Entity.ContactEntity ctEntity = ctbll.GetEntityBySid(stuEntity.Sid); //电话号码验证 //if (!string.IsNullOrEmpty(cPhone) && !Validator.IsMobileNum(cPhone)) { resultEntity.Msg = cPhone+"电话号码无效!"; return resultEntity; }; //if (!string.IsNullOrEmpty(cPhone2) && !Validator.IsMobileNum(cPhone2)) { resultEntity.Msg = cPhone2 + "电话号码无效!"; return resultEntity; }; //if (!string.IsNullOrEmpty(cPhone3) && !Validator.IsMobileNum(cPhone3)) { resultEntity.Msg = cPhone3 + "电话号码无效!"; return resultEntity; }; //if (!string.IsNullOrEmpty(cPhone4) && !Validator.IsMobileNum(cPhone4)) { resultEntity.Msg = cPhone4 + "电话号码无效!"; return resultEntity; }; ////保存数据 //if (ctEntity == null) //{ // ctEntity = new ContactEntity() { Sid = stuEntity.Sid }; // ctEntity.Cphone = cPhone; // ctEntity.Cphone2 = cPhone2; // ctEntity.Cphone3 = cPhone3; // ctEntity.Cphone4 = cPhone4; // ctbll.Add(ctEntity); // return new ResponeDataEntity() { Status = 1, Msg = snumber + "修改成功!" }; //} //ctEntity.Cphone = cPhone; //ctEntity.Cphone2 = cPhone2; //ctEntity.Cphone3 = cPhone3; //ctEntity.Cphone4 = cPhone4; //ctbll.Update(ctEntity); string[] cPhoneArr = cPhone.Split(','); string[] cPhonenArr = cPhoneName.Split(','); List <Entity.ContactEntity> contactList = new List <Entity.ContactEntity>(); for (int i = 0; i < cPhoneArr.Length; i++) { if (string.IsNullOrEmpty(cPhoneArr[i]) || string.IsNullOrEmpty(cPhoneArr[i])) { continue; } //验证电话号码 if (!string.IsNullOrEmpty(cPhoneArr[i]) && !Validator.IsMobileNum(cPhoneArr[i])) { resultEntity.Msg = cPhoneArr[i] + "电话号码无效!"; return(resultEntity); } ; contactList.Add(new Entity.ContactEntity() { Cphone = cPhoneArr[i], CPhoneName = cPhonenArr[i] }); } //ctbll.DeleteBySid(stuEntity.Sid); ////联系电话实体添加 //foreach (var item in contactList) //{ // item.Sid = stuEntity.Sid; // ctbll.Add(item); //} ctbll.AddBatch(contactList, stuEntity.Sid); return(new ResponeDataEntity() { Status = 1, Msg = snumber + "修改成功!" }); }