Exemplo n.º 1
0
 public void Add(EMUserGroup entity)
 {
     using (IRepository session = SessionManager.CreateRepository(typeof(EMUserGroup)))
     {
         session.Save(entity);
     }
 }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
 private EMUserGroup GetEMUserGroup(IdentityNoService identityNoServ, string tenantCode, UserInfoViewModel userInfoViewModel)
 {
     EMUserGroup group;
     group = new EMUserGroup()
     {
         IsAdminGroup = true,
         UserGroupID = identityNoServ.GetUserGroupID(),
         UserGroupName = "管理员",
         TenantCode = tenantCode,
     };
     return group;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 private static EMUserGroup GetEMUserGroup(IdentityNoService identityNoServ, string tenantCode)
 {
     EMUserGroup group;
     group = new EMUserGroup()
     {
         IsAdminGroup = true,
         UserGroupID = identityNoServ.GetUserGroupID(),
         UserGroupName = "管理员",
         TenantCode = tenantCode
     };
     return group;
 }
Exemplo n.º 6
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;
 }