示例#1
0
 public void Modify(EMUser eMUser)
 {
     using (IRepository repository = SessionManager.CreateRepository(typeof(EMUser)))
     {
         repository.Update(eMUser);
     }
 }
示例#2
0
 public void Add(EMUser eMUser)
 {
     using (IRepository repository = SessionManager.CreateRepository(typeof(EMUser)))
     {
         repository.Save(eMUser);
     }
 }
示例#3
0
 private RUserInfo getReturnUserInfo(EMUser user)
 {
     RUserInfo info = new RUserInfo();
     info.UserCode = user.UserCode;
     info.UserName = user.UserName;
     info.TenantCode = user.TenantCode;
     //IEMTenantService service = new EMTenantService();
     //EMTenant tenantInfo = service.Select(user.TenantCode);
     if (user.Tenant != null)
     {
         info.TenantType = (int)user.Tenant.TenantType;
     }
     //TO DO 获取子运营商及子客户
     return info;
 }
示例#4
0
        /// <summary>
        /// 新增运营商(ado,采用事物)
        /// </summary>
        /// <param name="tenant">movo_tenant对应实体</param>
        /// <param name="userGroup">movo_usergroup对应实体</param>
        /// <param name="user">movo_user对应实体</param>
        public bool AddOperatingMerchant(EMTenant tenant, EMUserGroup userGroup, EMUser user)
        {
            EMTenant sameNameEntity = SelectByName(tenant.TenantName);
            if (sameNameEntity != null)
            {
                throw new Exception("已经有相同的名称的Tenant");
            }
            MySqlConnection con = new MySqlConnection(MySqlDB.ConnString);
            con.Open();
            MySqlTransaction trans = con.BeginTransaction();
            MySqlCommand cmd = con.CreateCommand();
            cmd.Transaction = trans;

            try
            {
                cmd.CommandText = string.Format(@"insert into movo_tenant(TenantCode,SuperTenantID,TenantName,CreateTime,ExpireTime,ContactName,PhoneNumber,TenantType,IsFreeze,QQ,Email,RegisterUserCode,RegisterUserName,LogoUrl,OperatorLevel) values(@TenantCode,@SuperTenantID,@TenantName,@CreateTime,@ExpireTime,@ContactName,@PhoneNumber,@TenantType,@IsFreeze,@QQ,@Email,@RegisterUserCode,@RegisterUserName,@LogoUrl,@OperatorLevel)");
                cmd.Parameters.AddRange(new MySqlParameter[]{
                    new MySqlParameter("TenantCode",tenant.TenantCode),
                    new MySqlParameter("SuperTenantID",tenant.SuperTenantID),
                    new MySqlParameter("TenantName",tenant.TenantName),
                    new MySqlParameter("CreateTime",tenant.CreateTime),
                    new MySqlParameter("ExpireTime",tenant.ExpireTime),
                    new MySqlParameter("ContactName",tenant.ContactName),
                    new MySqlParameter("PhoneNumber",tenant.PhoneNumber),
                    new MySqlParameter("TenantType",tenant.TenantType),
                    new MySqlParameter("IsFreeze",tenant.IsFreeze),
                    new MySqlParameter("QQ",tenant.QQ),
                    new MySqlParameter("Email",tenant.Email),
                    new MySqlParameter("RegisterUserCode",tenant.RegisterUserCode),
                    new MySqlParameter("RegisterUserName",tenant.RegisterUserName),
                    new MySqlParameter("LogoUrl",tenant.LogoUrl),
                    new MySqlParameter("OperatorLevel",tenant.OperatorLevel)
                });
                int addtenant = cmd.ExecuteNonQuery();


                cmd.CommandText = string.Format(@"insert into movo_usergroup(UserGroupID,UserGroupName,TenantCode,IsAdminGroup) values(@gUserGroupID,@gUserGroupName,@gTenantCode,@gIsAdminGroup)");
                cmd.Parameters.AddRange(new MySqlParameter[]{
                    new MySqlParameter("gUserGroupID",userGroup.UserGroupID),
                    new MySqlParameter("gUserGroupName",userGroup.UserGroupName),
                    new MySqlParameter("gTenantCode",userGroup.TenantCode),
                    new MySqlParameter("gIsAdminGroup",userGroup.IsAdminGroup)
                });
                int addusergroup = cmd.ExecuteNonQuery();

                cmd.CommandText = string.Format(@"insert into movo_user(UserCode,UserName,UserGroupID,TenantCode,Password,RealName,Mobile,IsRegisterUser,LastLoginTime,CreateTime) values(@uUserCode,@uUserName,@uUserGroupID,@uTenantCode,@uPassword,@uRealName,@uMobile,@uIsRegisterUser,@uLastLoginTime,@uCreateTime)");
                cmd.Parameters.AddRange(new MySqlParameter[]{
                    new MySqlParameter("uUserCode",user.UserCode),
                    new MySqlParameter("uUserName",user.UserName),
                    new MySqlParameter("uUserGroupID",user.UserGroupID),
                    new MySqlParameter("uTenantCode",user.TenantCode),
                    new MySqlParameter("uPassword",user.PassWord),
                    new MySqlParameter("uRealName",user.RealName),
                    new MySqlParameter("uMobile",user.Mobile),
                    new MySqlParameter("uIsRegisterUser",user.IsRegisterUser),
                    new MySqlParameter("uLastLoginTime",user.LastLoginTime),
                    new MySqlParameter("uCreateTime",user.CreateTime)
                });
                int adduser = cmd.ExecuteNonQuery();

                if (addtenant >= 1 && addusergroup >= 1 && adduser >= 1)
                {
                    trans.Commit();
                }
                
            }
            catch (Exception ex)
            {
                trans.Rollback();
                //加日志
                return false;
            }
            finally
            {
                con.Close();
            }
            return true;
        }
示例#5
0
 private EMUser ConvertTo(EMUserViewModel entity)
 {
     EMUser model = null;
     if (entity != null)
     {
         IUserService userService = new UserService();
         EMUser eMUser = userService.GetUser(entity.UserCode);
         model = new EMUser();
         model.UserCode = entity.UserCode;
         model.UserName = entity.UserName;
         model.IsRegisterUser = entity.IsRegisterUser;
         model.PassWord = entity.PassWord;
         model.RealName = entity.RealName;
         model.Mobile = entity.Mobile;
         model.Tenant = new EMTenant() { TenantCode = entity.TenantCode };
         model.LastLoginTime = entity.LastLoginTime;
         if (eMUser != null)
             model.CreateTime = eMUser.CreateTime;
         model.UserGroupID = entity.UserGroupID;
     }
     return model;
 }
 private OperateMyDataViewModel ConvertTo(EMUser user)
 {
     if (user != null)
     {
         OperateMyDataViewModel model = new OperateMyDataViewModel();
         model.UserCode = user.UserCode;
         model.UserName = user.UserName;
         model.Password = user.PassWord;
         model.TenantCode = user.TenantCode;
         //EMTenantService tenantService = new EMTenantService();
         //EMTenant tenant = tenantService.Select(user.TenantCode);
         if (user.Tenant != null)
         {
             model.TenantName = user.Tenant.TenantName;
             model.PhoneNumber = user.Tenant.PhoneNumber;
             model.ContactName = user.Tenant.ContactName;
             if (user.Tenant.CreateTime.Equals(DateTime.MinValue))
                 model.CreateTime = DateTime.MaxValue;
             else
                 model.CreateTime = user.Tenant.CreateTime;
             if (user.Tenant.ExpireTime.Equals(DateTime.MinValue))
                 model.ExpireTime = DateTime.MaxValue;
             else
                 model.ExpireTime = user.Tenant.ExpireTime;
             model.Email = user.Tenant.Email;
             model.QQ = user.Tenant.QQ;
             model.TenantLogoImgURl = user.Tenant.LogoUrl;
         }
         return model;
     }
     return null;
 }
 private EMUser GetEMUser(IdentityNoService identityNoServ, UserInfoViewModel vm, EMTenant tenant, EMUserGroup group)
 {
     EMUser user;
     user = new EMUser()
     {
         UserCode = identityNoServ.GetUserSerialNo(),
         UserName = vm.UserName,
         UserGroupID = group.UserGroupID,
         Tenant = tenant,
         PassWord = vm.EncryptPwd,
         IsRegisterUser = true,
         Mobile = tenant.PhoneNumber,
         CreateTime = DateTime.Now                 
     };
     return user;
 }
示例#8
0
 private UserInfoViewModel ConvertToViewModel(EMUser user)
 {
     UserInfoViewModel viewModel = new UserInfoViewModel();
     viewModel.UserCode = user.UserCode;
     viewModel.UserName = user.UserName;
     viewModel.TenantCode = user.Tenant.TenantCode;//user.TenantCode;
     viewModel.TenantName = user.Tenant.TenantName;
     //viewModel.Password = user.PassWord;
     viewModel.IsRegisterUser = user.IsRegisterUser;
     return viewModel;
 }
示例#9
0
        /// <summary>
        /// 获取子用户列表
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="userGroupID">用户组</param>
        /// <param name="tenantCode">租户编码</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页条数</param>
        /// <param name="rowCount">总记录数</param>
        /// <returns></returns>
        public IList<EMUser> GetUserList(string userName, string userGroupID, string tenantCode, int pageIndex, int pageSize, ref int rowCount)
        {
            List<EMUser> uList = new List<EMUser>();
            string sCmdText = string.Format(@"SELECT movo_user.CreateTime,movo_user.IsRegisterUser,movo_user.LastLoginTime,movo_user.Mobile,movo_user.PassWord,movo_user.RealName,movo_user.TenantCode,movo_user.UserCode,movo_user.UserGroupID,movo_user.UserName,movo_tenant.TenantCode tTenantCode,movo_tenant.SuperTenantID tSuperTenantID,movo_tenant.TenantName tTenantName,movo_tenant.CreateTime tCreateTime,movo_tenant.ExpireTime tExpireTime,
movo_tenant.ContactName tContactName,movo_tenant.PhoneNumber tPhoneNumber,movo_tenant.TenantType tTenantType,movo_tenant.IsFreeze tIsFreeze,movo_tenant.QQ tQQ,movo_tenant.Email tEmail,
movo_tenant.RegisterUserCode tRegisterUserCode,movo_tenant.RegisterUserName tRegisterUserName,movo_tenant.LogoUrl tLogoUrl,movo_tenant.OperatorLevel tOperatorLevel  from movo_user  left join movo_tenant on movo_tenant.TenantCode=movo_user.TenantCode where movo_tenant.TenantCode='{0}'", tenantCode);
            string sql = string.Format(@"SELECT count(*) from movo_user  left join movo_tenant on movo_tenant.TenantCode=movo_user.TenantCode where movo_tenant.TenantCode='{0}'", tenantCode);
            if (!string.IsNullOrEmpty(userName))
            {
                sCmdText = sCmdText + string.Format(@" and movo_user.UserName like '%{0}%'", userName);
                sql = sql + string.Format(@" and movo_user.UserName like '%{0}%'", userName);
            }
            if (!string.IsNullOrEmpty(userGroupID))
            {
                sCmdText = sCmdText + string.Format(@" and movo_user.UserGroupID={0}", long.Parse(userGroupID));
                sql = sql + string.Format(@" and movo_user.UserGroupID={0}", long.Parse(userGroupID));
            }
            sCmdText = sCmdText + string.Format(@" order by movo_user.IsRegisterUser,movo_user.CreateTime desc limit {0},{1}", pageIndex, pageSize);
            using (DbDataReader sdrCount = MySqlDB.GetDataReader(CommandType.Text, sql))
            {
                if (sdrCount != null)
                {
                    while (sdrCount.Read())
                    {
                        rowCount = rowCount + Convert.ToInt32(sdrCount[0]);
                    }
                }
                sdrCount.Close();
            }

            using (DbDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, sCmdText))
            {
                if (sdr != null)
                {
                    while (sdr.Read())
                    {

                        EMUser eu = new EMUser();
                        eu.CreateTime = sdr["CreateTime"].ToDateTime();
                        eu.IsRegisterUser = sdr["IsRegisterUser"].ToBoolean();
                        eu.LastLoginTime = sdr["LastLoginTime"].ToDateTimeNull();
                        eu.Mobile = sdr["Mobile"].ToString();
                        eu.PassWord = sdr["PassWord"].ToString();
                        eu.RealName = sdr["RealName"].ToString();
                        eu.TenantCode = sdr["TenantCode"].ToString();
                        eu.UserCode = sdr["UserCode"].ToString();
                        eu.UserGroupID = sdr["UserGroupID"].ToULongNull();
                        eu.UserName = sdr["UserName"].ToString();

                        EMTenant et = new EMTenant();
                        et.ContactName = sdr["tContactName"].ToString();
                        et.CreateTime = sdr["tCreateTime"].ToDateTime();
                        et.Email = sdr["tEmail"].ToString();
                        et.ExpireTime = sdr["tExpireTime"].ToDateTimeNull();
                        et.IsFreeze = sdr["tIsFreeze"].ToString() == "1" ? true : false;
                        et.LogoUrl = sdr["tLogoUrl"].ToString();
                        et.OperatorLevel = sdr["tOperatorLevel"].ToIntNull();
                        et.PhoneNumber = sdr["tPhoneNumber"].ToString();
                        et.QQ = sdr["tQQ"].ToString();
                        et.RegisterUserCode = sdr["tRegisterUserCode"].ToString();
                        et.RegisterUserName = sdr["tRegisterUserName"].ToString();
                        et.SuperTenantID = sdr["tSuperTenantID"].ToString();
                        et.TenantCode = sdr["tTenantCode"].ToString();
                        et.TenantName = sdr["tTenantName"].ToString();
                        et.TenantType = (EnumTenantType)sdr["tTenantType"].ToInt();
                        eu.Tenant = et;
                        uList.Add(eu);
                    }
                }
                sdr.Close();
            }
            return uList;
        }
示例#10
0
 public EMUser GetLoginUser(string userName, string pwd)
 {
     string cmdText = "SELECT * FROM movo_user where UserName = @UserName and PassWord=@Pwd";
     MySqlParameter[] cmdParams = new MySqlParameter[] {
         new MySqlParameter("UserName", userName),
         new MySqlParameter("Pwd", pwd)
     };
     EMUser res = null;
     using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, cmdText, cmdParams))
     {
         if (sdr != null)
         {
             if (sdr.Read())
             {
                 res = new EMUser();
                 res.UserCode = sdr["UserCode"].ToString();
                 res.UserName = userName;
                 res.UserGroupID = sdr["UserGroupID"].ToULongNull();
                 res.TenantCode = sdr["TenantCode"].ToString();
                 res.PassWord = pwd;
                 res.RealName = sdr["RealName"].ToString();
                 res.Mobile = sdr["Mobile"].ToString();
                 res.IsRegisterUser = sdr["IsRegisterUser"].ToBoolean();
                 res.LastLoginTime = sdr["LastLoginTime"].ToDateTimeNull();
                 res.CreateTime = sdr["CreateTime"].ToDateTime();
             }
             sdr.Close();
             if (res != null)
             {
                 res.Tenant = GetTenantInfoByTenantCode(res.TenantCode);
             }
         }
     }
     return res;
 }
示例#11
0
        public EMUser GetUserFullInfo(string userCode)
        {
            EMUser res = new EMUser();
            string scmdText = string.Format("SELECT * FROM movo_user u LEFT JOIN movo_tenant t ON u.TenantCode = t.TenantCode WHERE u.UserCode = '{0}'", userCode);
            using (DbDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, scmdText))
            {
                if (sdr != null)
                {
                    if (sdr.Read())
                    {
                        res.UserCode = userCode;
                        res.UserName = sdr["UserName"].ToString();
                        res.UserGroupID = sdr["UserGroupID"].ToULongNull();
                        res.TenantCode = sdr["TenantCode"].ToString();
                        res.PassWord = sdr["PassWord"].ToString();
                        res.RealName = sdr["RealName"].ToString();
                        res.Mobile = sdr["Mobile"].ToString();
                        res.IsRegisterUser = sdr["IsRegisterUser"].ToBoolean();
                        res.LastLoginTime = sdr["LastLoginTime"].ToDateTimeNull();
                        res.CreateTime = sdr["CreateTime"].ToDateTime();

                        res.Tenant = new EMTenant(); //租户信息
                        res.Tenant.TenantCode = sdr["TenantCode"].ToString();
                        res.Tenant.SuperTenantID = sdr["SuperTenantID"].ToString();
                        res.Tenant.TenantName = sdr["TenantName"].ToString();
                        res.Tenant.CreateTime = sdr["CreateTime"].ToDateTime();
                        res.Tenant.ExpireTime = sdr["ExpireTime"].ToDateTimeNull();
                        res.Tenant.ContactName = sdr["ContactName"].ToString();
                        res.Tenant.PhoneNumber = sdr["PhoneNumber"].ToString();
                        res.Tenant.TenantType = (EnumTenantType)sdr["TenantType"].ToInt();
                        res.Tenant.IsFreeze = sdr["IsFreeze"].ToString() == "1" ? true : false;
                        res.Tenant.QQ = sdr["QQ"].ToString();
                        res.Tenant.Email = sdr["Email"].ToString();
                        res.Tenant.RegisterUserCode = sdr["RegisterUserCode"].ToString();
                        res.Tenant.RegisterUserName = sdr["RegisterUserName"].ToString();
                        res.Tenant.LogoUrl = sdr["LogoUrl"].ToString();
                        res.Tenant.OperatorLevel = sdr["OperatorLevel"].ToIntNull();
                    }
                }
            }
            return res;
        }
示例#12
0
 /// <summary>
 ///  新增子用户
 /// </summary>
 /// <param name="user">movo_user对应的实体</param>
 /// <returns></returns>
 public bool AddUser(EMUser user)
 {
     string sCmdText = string.Format(@"insert into movo_user(UserCode,UserName,UserGroupID,TenantCode,Password,RealName,Mobile,IsRegisterUser,LastLoginTime,CreateTime) values(@UserCode,@UserName,@UserGroupID,@TenantCode,@Password,@RealName,@Mobile,@IsRegisterUser,@LastLoginTime,@CreateTime)");
     MySqlParameter[] parm = new MySqlParameter[] {
         new MySqlParameter("UserCode", user.UserCode),
         new MySqlParameter("UserName", user.UserName),
         new MySqlParameter("UserGroupID", user.UserGroupID),
         new MySqlParameter("TenantCode", user.TenantCode),
         new MySqlParameter("Password", user.PassWord),
         new MySqlParameter("RealName", user.RealName),
         new MySqlParameter("Mobile", user.Mobile),
         new MySqlParameter("IsRegisterUser", user.IsRegisterUser),
         new MySqlParameter("LastLoginTime", user.LastLoginTime),
         new MySqlParameter("CreateTime", user.CreateTime)
     };
     int iCount = MySqlDB.ExecuteNonQuery(CommandType.Text, sCmdText, parm);
     //if (iCount > 0)
     //{
     //    return true;
     //}
     return iCount > 0;
 }
示例#13
0
        public void Update(EMUser aEMUser)
        {
            string cmdText = string.Format(@"UPDATE movo_user SET UserName=@UserName, UserGroupID=@UserGroupID, TenantCode=@TenantCode, 
Password=@Password, RealName=@RealName, Mobile=@Mobile, IsRegisterUser=@IsRegisterUser, LastLoginTime=@LastLoginTime WHERE UserCode={0}", aEMUser.UserCode);
            MySqlParameter[] sp = new MySqlParameter[] {
                new MySqlParameter("UserName", aEMUser.UserName),
                new MySqlParameter("UserGroupID", aEMUser.UserGroupID),
                new MySqlParameter("TenantCode", aEMUser.TenantCode),
                new MySqlParameter("Password", aEMUser.PassWord),
                new MySqlParameter("RealName", aEMUser.RealName),
                new MySqlParameter("Mobile", aEMUser.Mobile),
                new MySqlParameter("IsRegisterUser", aEMUser.IsRegisterUser),
                new MySqlParameter("LastLoginTime", aEMUser.LastLoginTime),
                new MySqlParameter("CreateTime", aEMUser.CreateTime)
            };
            MySqlDB.ExecuteNonQuery(CommandType.Text, cmdText, sp);
            /*
            using (IRepository repository = SessionManager.CreateRepository(typeof(EMUser)))
            {
                repository.Update(eMUser);
            }*/
        }
示例#14
0
 public void UpdLastLoginTime(EMUser aEMUser)
 {
     string cmdText = string.Format(@"UPDATE movo_user SET LastLoginTime=@LastLoginTime WHERE UserCode={0}", aEMUser.UserCode);
     MySqlParameter[] sp = new MySqlParameter[] {
         new MySqlParameter("LastLoginTime", aEMUser.LastLoginTime)
     };
     MySqlDB.ExecuteNonQuery(CommandType.Text, cmdText, sp);
 }
示例#15
0
 private EMUser GetEMUser(IdentityNoService identityNoServ,string userName, string pwd,
     string email, string QQ, EMTenant tenant, EMUserGroup group)
 {
     EMUser user;
     user = new EMUser()
     {
         UserCode = identityNoServ.GetUserSerialNo(),
         UserName = userName,
         UserGroupID = group.UserGroupID,
         Tenant= tenant,
         PassWord = pwd,
         IsRegisterUser = true, 
         CreateTime = DateTime.Now                 
     };
     return user;
 }