private PagedDataList<DeviceManageViewModel> GetDeviceManageViewModel(string tenantCode, EMTenant tenant, int rowIndex, int pageSize) { //获取车辆信息 EMVehicleService vehicleService = new EMVehicleService(); int rowCount = 0; IList<EMVehicle> vehicleList = vehicleService.SelectAll(new string[] { tenantCode }.ToList(), rowIndex, pageSize, ref rowCount, "InstallTime", false); if (rowCount == 0) { return null; } //获取当前服务器时间 DateTime nowTime = DateTime.Now; //拼装ViewModel List<DeviceManageViewModel> modelList = new List<DeviceManageViewModel>(); foreach (EMVehicle vehicle in vehicleList) { DeviceManageViewModel model = GetDeviceManageVM(nowTime, vehicle, tenant); modelList.Add(model); } return new PagedDataList<DeviceManageViewModel>() { Datas = modelList, RowCount = rowCount }; }
/// <summary> /// 更新数据 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Update(EMTenant entity) { string cmdText = "UPDATE movo_tenant SET TenantName=@TenantName, QQ=@QQ, Email=@Email, ContactName=@ContactName, PhoneNumber=@PhoneNumber, LogoUrl=@LogoUrl, ExpireTime=@ExpireTime WHERE TenantCode=@TenantCode"; MySqlParameter[] cmdParms = new MySqlParameter[] { new MySqlParameter("TenantCode", entity.TenantCode), new MySqlParameter("TenantName", entity.TenantName), new MySqlParameter("QQ", entity.QQ), new MySqlParameter("Email", entity.Email), new MySqlParameter("ContactName", entity.ContactName), new MySqlParameter("PhoneNumber", entity.PhoneNumber), new MySqlParameter("LogoUrl", entity.LogoUrl), new MySqlParameter("ExpireTime", entity.ExpireTime) }; return MySqlDB.ExecuteNonQuery(CommandType.Text, cmdText, cmdParms); }
public EMTenant SelectByName(string tenantName) { EMTenant em = null; if (!string.IsNullOrEmpty(tenantName)) { MySqlParameter cmdParms = new MySqlParameter("TenantName", tenantName); string sCmdText = "SELECT * FROM movo_tenant WHERE TenantName=@TenantName"; using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, sCmdText, cmdParms)) { if (sdr != null) { if (sdr.Read()) { em = new EMTenant(); em.ContactName = sdr["ContactName"].ToString(); em.CreateTime = sdr["CreateTime"].ToDateTime(); em.Email = sdr["Email"].ToString(); em.ExpireTime = sdr["ExpireTime"].ToDateTimeNull(); em.IsFreeze = sdr["IsFreeze"].ToString() == "1" ? true : false; em.LogoUrl = sdr["LogoUrl"].ToString(); em.OperatorLevel = sdr["OperatorLevel"].ToIntNull(); em.PhoneNumber = sdr["PhoneNumber"].ToString(); em.QQ = sdr["QQ"].ToString(); em.RegisterUserCode = sdr["RegisterUserCode"].ToString(); em.RegisterUserName = sdr["RegisterUserName"].ToString(); em.SuperTenantID = sdr["SuperTenantID"].ToString(); em.TenantCode = sdr["TenantCode"].ToString(); em.TenantName = sdr["TenantName"].ToString(); em.TenantType = (EnumTenantType)sdr["TenantType"].ToInt(); } sdr.Close(); } } } return em; }
public EMTenant SelectByCode(string tenantCode) { if (string.IsNullOrEmpty(tenantCode)) return null; EMTenant res = null; string cmdText = string.Format("SELECT * FROM movo_tenant WHERE TenantCode={0}", tenantCode); using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, cmdText)) { if (sdr != null) { if (sdr.Read()) { res = new EMTenant(); res.TenantCode = tenantCode; res.SuperTenantID = sdr["SuperTenantID"].ToString(); res.TenantName = sdr["TenantName"].ToString(); res.CreateTime = sdr["CreateTime"].ToDateTime(); res.ExpireTime = sdr["ExpireTime"].ToDateTimeNull(); res.ContactName = sdr["ContactName"].ToString(); res.PhoneNumber = sdr["PhoneNumber"].ToString(); res.TenantType = (EnumTenantType)sdr["TenantType"].ToInt(); res.IsFreeze = sdr["IsFreeze"].ToBoolean(); res.QQ = sdr["QQ"].ToString(); res.Email = sdr["Email"].ToString(); res.RegisterUserCode = sdr["RegisterUserCode"].ToString(); res.RegisterUserName = sdr["RegisterUserName"].ToString(); res.LogoUrl = sdr["LogoUrl"].ToString(); res.OperatorLevel = sdr["OperatorLevel"].ToIntNull(); } sdr.Close(); } } return res; }
/// <summary> /// 根据租户编码获取租户信息 /// </summary> /// <param name="TenantCode"></param> /// <returns></returns> public EMTenant GetTenantBySuperTenantID(string SuperTenantID) { EMTenant em = new EMTenant(); if (!string.IsNullOrEmpty(SuperTenantID)) { string sCmdText = string.Format(@"select * from movo_tenant where TenantCode='{0}'", SuperTenantID); using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, sCmdText)) { if (sdr != null) { if (sdr.Read()) { em.ContactName = sdr["ContactName"].ToString(); em.CreateTime = sdr["CreateTime"].ToDateTime(); em.Email = sdr["Email"].ToString(); em.ExpireTime = sdr["ExpireTime"].ToDateTimeNull(); em.IsFreeze = sdr["IsFreeze"].ToString() == "1" ? true : false; em.LogoUrl = sdr["LogoUrl"].ToString(); em.OperatorLevel = sdr["OperatorLevel"].ToIntNull(); em.PhoneNumber = sdr["PhoneNumber"].ToString(); em.QQ = sdr["QQ"].ToString(); em.RegisterUserCode = sdr["RegisterUserCode"].ToString(); em.RegisterUserName = sdr["RegisterUserName"].ToString(); em.SuperTenantID = sdr["SuperTenantID"].ToString(); em.TenantCode = sdr["TenantCode"].ToString(); em.TenantName = sdr["TenantName"].ToString(); em.TenantType = (EnumTenantType)sdr["TenantType"].ToInt(); } sdr.Close(); } } } return em; }
/// <summary> /// 查询用户下的租户信息 /// </summary> /// <param name="superTenantID"></param> /// <returns></returns> public IList<EMTenant> SelectMerchantOfPlat(string superTenantID) { List<EMTenant> list = new List<EMTenant>(); if (!string.IsNullOrEmpty(superTenantID)) { if (!string.IsNullOrEmpty(superTenantID)) { string sCmdText = string.Format(@"select * from movo_tenant where SuperTenantID={0} and TenantType={1}", superTenantID, EnumTenantType.OperatingMerchant); using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, sCmdText)) { if (sdr != null) { while (sdr.Read()) { EMTenant emt = new EMTenant(); emt.ContactName = sdr["ContactName"].ToString(); emt.CreateTime = sdr["CreateTime"].ToDateTime(); emt.Email = sdr["Email"].ToString(); emt.ExpireTime = sdr["ExpireTime"].ToDateTimeNull(); emt.IsFreeze = sdr["IsFreeze"].ToString() == "1" ? true : false;//1为冻结,0为不冻结 emt.LogoUrl = sdr["LogoUrl"].ToString(); emt.OperatorLevel = sdr["OperatorLevel"].ToIntNull(); emt.PhoneNumber = sdr["PhoneNumber"].ToString(); emt.QQ = sdr["QQ"].ToString(); emt.RegisterUserCode = sdr["RegisterUserCode"].ToString(); emt.RegisterUserName = sdr["RegisterUserName"].ToString(); emt.SuperTenantID = sdr["SuperTenantID"].ToString(); emt.TenantCode = sdr["TenantCode"].ToString(); emt.TenantName = sdr["TenantName"].ToString(); emt.TenantType = (EnumTenantType)sdr["TenantType"].ToInt(); list.Add(emt); } sdr.Close(); } } } } return list; }
/// <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; }
private MBTenantViewModel ConvertToMBTenant(EMTenant tenant) { MBTenantViewModel model = new MBTenantViewModel() { TenantCode = tenant.TenantCode, TenantName = tenant.TenantName, TenantType = (int)tenant.TenantType, ChildTenants = null }; return model; }
private DeviceManageViewModel GetDeviceManageVM(DateTime nowTime, EMVehicle vehicle, EMTenant tenant) { DeviceManageViewModel model = new DeviceManageViewModel(); model.CreateTime = vehicle.CreateTime; model.DeviceNo = vehicle.DeviceNo; model.ExpireTime = vehicle.ExpireTime; model.GPSCode = vehicle.GPSCode; model.GPSTypeID = vehicle.GPSTypeID; model.GPSTypeName = vehicle.GPSTypeName; model.GroupID = vehicle.GroupID; model.IconType = vehicle.IconType; model.InitMileage = vehicle.InitMileage; model.InstallTime = vehicle.InstallTime; model.IsStop = vehicle.IsStop; model.LicenceNumber = vehicle.LicenceNumber; model.SIMNo = vehicle.SIMNo; model.TenantCode = vehicle.TenantCode; model.VehicleCode = vehicle.VehicleCode; model.NowTime = nowTime; if (tenant != null) { model.Email = tenant.Email; model.PhoneNumber = tenant.PhoneNumber; model.RegisterUserName = tenant.RegisterUserName; model.TenantName = tenant.TenantName; } return model; }
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; }
/// <summary> /// 获取终端用户的车辆列表 /// </summary> /// <param name="tenantCode"></param> /// <returns></returns> public List<ChangeCusCarWithOMViewModel> GetEndCustomerCarList(string tenantCode, string iconSkin) { List<ChangeCusCarWithOMViewModel> list = new List<ChangeCusCarWithOMViewModel>(); ChangeCusCarWithOMViewModel car=new ChangeCusCarWithOMViewModel (); TenantDAL dal=new TenantDAL (); EMTenant emt=new EMTenant (); emt=dal.GetTenantBySuperTenantID(tenantCode); car.IsLastCreated = false; car.IsOM = emt.TenantType == EnumTenantType.EndCustomer; car.TenantCode = emt.TenantCode; car.TenantName = emt.TenantName; car.OperatorLevel = emt.OperatorLevel; car.Children = new List<ChangeCusCarWithOMViewModel>(); car.RegisterUserCode = emt.RegisterUserCode; car.VehicleCount = 0; car.VehicleOnlineNum = 0; car.iconSkin = "pIcon"; list.Add(car); List<EMVehicle> veList = new VehicleDAL().GetVehicleListByTenantCode(tenantCode); if (veList != null && veList.Count > 0) { List<ChangeCusCarWithOMViewModel> vechileList = new List<ChangeCusCarWithOMViewModel>(); for (int a = 0; a < veList.Count; a++) { ChangeCusCarWithOMViewModel ve = new ChangeCusCarWithOMViewModel(); ve.TenantCode = veList[a].VehicleCode.ToString(); ve.TenantName = veList[a].LicenceNumber; ve.iconSkin = "CarDeviceNo"; vechileList.Add(ve); } list[0].iconSkin = iconSkin; //值为CarDeviceNo表示是车辆的上一级可以选中,为空表示车辆的上一级不可以选中 list[0].Children.AddRange(vechileList); } return list; }
private EMTenant GetTenantInfoByTenantCode(string aTenantCode) { if (string.IsNullOrEmpty(aTenantCode)) return null; EMTenant res = null; string cmdText = string.Format("select * from movo_tenant where TenantCode='{0}'", aTenantCode); using (var sdr = MySqlDB.GetDataReader(CommandType.Text, cmdText)) { if (sdr != null) { if (sdr.Read()) { res = new EMTenant(); res.TenantCode = sdr["TenantCode"].ToString(); res.SuperTenantID = sdr["SuperTenantID"].ToString(); res.TenantName = sdr["TenantName"].ToString(); res.CreateTime = sdr["CreateTime"].ToDateTime(); res.ExpireTime = sdr["ExpireTime"].ToDateTimeNull(); res.ContactName = sdr["ContactName"].ToString(); res.PhoneNumber = sdr["PhoneNumber"].ToString(); res.TenantType = (EnumTenantType)sdr["TenantType"].ToInt(); res.IsFreeze = sdr["IsFreeze"].ToBoolean(); res.QQ = sdr["QQ"].ToString(); res.Email = sdr["Email"].ToString(); res.RegisterUserCode = sdr["RegisterUserCode"].ToString(); res.RegisterUserName = sdr["RegisterUserName"].ToString(); res.LogoUrl = sdr["LogoUrl"].ToString(); res.OperatorLevel = sdr["OperatorLevel"].ToIntNull(); } sdr.Close(); } } return res; }
/// <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; }
private TenantViewModel ConvertToViewModel(EMTenant tenant) { if (tenant == null) return null; TenantViewModel vm = ConvertHelper.ConvertObj<EMTenant, TenantViewModel>(tenant); return vm; }
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; }
private static EMTenant GetTenant(string tenantCode, string email, string QQ, string companyName, string registerUserName) { EMTenant tenant = new EMTenant() { TenantCode = tenantCode, CreateTime = DateTime.Now, Email = email, QQ = QQ, IsFreeze = false, SuperTenantID = RegSuperTenantCode, TenantName = companyName, TenantType = EnumTenantType.EndCustomer, RegisterUserName = registerUserName }; return tenant; }