1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using EMIS.DataLogic.SystemDAL;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.ViewModel.SystemView;
- using EMIS.DataLogic.Common.Students;
- namespace EMIS.CommonLogic.SystemServices
- {
- public class WechatMPServices : BaseServices, IWechatMPServices
- {
- public WechatMPDAL WechatMPDAL { get; set; }
- public UserDAL UserDAL { get; set; }
- public StudentsDAL StudentsDAL { get; set; }
- public List<string> GetOpenIDList(IList<Guid?> roleIDList, IList<Guid?> userIDList)
- {
- Expression<Func<Sys_Role, bool>> roleExp = (x => true);
- Expression<Func<Sys_User, bool>> userExp = (x => true);
- if (roleIDList != null && roleIDList.Count() > 0)
- {
- roleExp = roleExp.And(x => roleIDList.Contains(x.RoleID));
- }
- else
- {
- roleExp = (x => false);
- }
- if (userIDList != null && userIDList.Count() > 0)
- {
- userExp = userExp.And(x => userIDList.Contains(x.UserID));
- }
- else
- {
- userExp = (x => false);
- }
- var query = WechatMPDAL.GetOpenIDList(roleExp, userExp);
- return query.ToList();
- }
- public StudentUserView GetUserViewByOpenID(string openID)
- {
- var wechatSubscribe = WechatMPDAL.WechatSubscripbeRepository.GetSingle(x => x.OpenID == openID);
- if (wechatSubscribe == null)
- {
- return null;
- }
- return UserDAL.GetStudentUserView(x => x.UserID == wechatSubscribe.UserID, (x => true)).FirstOrDefault();
- }
- public void BindOpenID(string loginID, string openID)
- {
- var user = StudentsDAL.StudentRepository.GetSingle(x => x.Sys_User.LoginID == loginID);
- if (user == null)
- {
- return;
- }
- var subscribe = WechatMPDAL.WechatSubscripbeRepository.GetSingle(x => x.UserID == user.UserID);
- if (subscribe == null)
- {
- subscribe = new CF_WechatSubscribe();
- subscribe.WechatSubscribeID = Guid.NewGuid();
- subscribe.UserID = user.UserID;
- UnitOfWork.Add(subscribe);
- }
- subscribe.OpenID = openID;
- UnitOfWork.Commit();
- }
- public void UnBindOpenID(string openID)
- {
- UnitOfWork.Delete<CF_WechatSubscribe>(x => x.OpenID == openID);
- }
- }
- }
|