public ResultContent UpdateUserIncludeVehicle(EMUserGroupOrViewModel userViewModel)
        {
            ResultContent rc = new ResultContent();
            try
            {
                IUserService userService = new UserService();

                EMUser newEntity = ConvertTo(userViewModel);
                EMUser oldEntity = userService.GetUser(newEntity.UserCode);
                newEntity.CreateTime = oldEntity.CreateTime;
                userService.Update(newEntity);
                IEMVehicleOfUserService vosSerive = new EMVehicleOfUserService();
                //先删除再添加
                vosSerive.Delete(newEntity.UserCode);
                if (userViewModel.UserGroupID == null)
                {
                    var query = from f in userViewModel.VehicleCodeList select new EMVehicleOfUser { UserCode = newEntity.UserCode, VehicleCode = f };
                    List<EMVehicleOfUser> vosList = query.ToList();
                    vosSerive.Insert(vosList);
                }
                rc.Result = true;
                rc.Message = "修改成功!";
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                rc.Result = false;
                rc.Message = ex.Message;
            }
            return rc;
        }
 public ResultContent TransferUserGroup(List<EMUserViewModel> list)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         if (list != null && list.Count > 0)
         {
             foreach (EMUserViewModel model in list)
             {
                 EMUser entity =ConvertTo(model);
                 userService.Update(entity);
             }
             rc.Result = true;
             rc.Message = "转移成功,共计(" + list.Count + ")!";
         }
         else
         {
             rc.Result = false;
             rc.Message = "没有选中数据!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
 public ResultContent AddUserIncludeVehicle(EMUserGroupOrViewModel userViewModel)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         bool bl = userService.ExistsUser(userViewModel.UserName);
         if (bl)
         {
             rc.Result = false;
             rc.Message = "用户名已存在!";
         }
         else
         {
             IdentityNoService identityNoServ = new IdentityNoService();
             userViewModel.UserCode = identityNoServ.GetUserSerialNo();
             userViewModel.CreateTime = DateTime.Now;
             EMUser entity = ConvertTo(userViewModel);
             entity.Tenant = new EMTenant() { TenantCode = entity.TenantCode };
             userService.Add(entity);
             if (userViewModel.UserGroupID == null)
             {
                 var query = from f in userViewModel.VehicleCodeList select new EMVehicleOfUser { UserCode = entity.UserCode, VehicleCode = f };
                 List<EMVehicleOfUser> vosList = query.ToList();
                 IEMVehicleOfUserService vosSerive = new EMVehicleOfUserService();
                 vosSerive.Insert(vosList);
             }
             rc.Result = true;
             rc.Message = "添加成功!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
        public ResultContent UpdateUser(UpdateUserViewModel userViewModel)
        {
            ResultContent rc = new ResultContent();
            try
            {
                IUserService userService = new UserService();

                EMUser newEntity = ConvertTo(userViewModel);
                userService.Update(newEntity);
                rc.Result = true;
                rc.Message = "修改成功!";
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                rc.Result = false;
                rc.Message = ex.Message;
            }
            return rc;
        }
 public ResultContent AddUser(EMUserViewModel userViewModel)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         bool bl = userService.ExistsUser(userViewModel.UserName);
         if (bl)
         {
             rc.Result = false;
             rc.Message = "用户名已存在!";
         }
         else
         {
             IdentityNoService identityNoServ = new IdentityNoService();
             userViewModel.UserCode = identityNoServ.GetUserSerialNo();
             userViewModel.CreateTime = DateTime.Now;
             EMUser entity = ConvertHelper.ConvertObj<EMUserViewModel, EMUser>(userViewModel);
             entity.Tenant = new EMTenant() { TenantCode = userViewModel.TenantCode };
             userService.Add(entity);
             rc.Result = true;
             rc.Message = "添加成功!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
 public ResultContent DeleteUser(string userCode)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         userService.Delete(userCode);
         rc.Result = true;
         rc.Message = "删除成功!";
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
 // 删除
 public ResultContent DeleteSmsQuery(ulong smsid)
 {
     ResultContent rc = new ResultContent();
     try
     {
         ISMSQueryVehicleService sqv = new SMSQueryVehicleService();
         sqv.Delete(smsid);
         rc.Result = true;
         rc.Message = "删除成功!";
     }
     catch (Exception ex)
     {
         rc.Result = false;
         rc.Message = ex.Message;
         Logger.Error(ex.Message, ex);
     }
     return rc;
 }
        // 修改
        public ResultContent UpdateSMSQuery(SmsQueryVehicleParam para)
        {
            ResultContent rc = new ResultContent();
            // 要校验
            try
            {
                ISMSQueryVehicleService sqv = new SMSQueryVehicleService();
                IdentityNoService identity = new IdentityNoService();
                EMSMSQueryVehicle entity = sqv.GetSMSQuery(para.smsid);

                //entity.CreateDate = DateTime.Now;
                entity.TenantCode = para.TenantCode;
                entity.CustomerName = para.CustomerName;
                entity.CustomerTelephone = para.Telphone;
                entity.IsProfessional = false;
                entity.SMSVehicle.Clear();
                if (!para.vehicleCodelist.IsNullOrEmpty())
                {
                    for (int i = 0; i < para.vehicleCodelist.Count; i++)
                    {
                        EMSMSVehicle vehicle = new EMSMSVehicle()
                        {
                            smsvehicle_id = identity.GetSMSVehicleID(),
                            VehicleCode = para.vehicleCodelist[i],
                            TenantCode = para.TenantCode,
                            LicenseNumber = para.LicenceNumberlist[i]
                        };
                        entity.SMSVehicle.Add(vehicle);
                    }
                }
                sqv.Modify(entity);
                rc.Result = true;
                rc.Message = "修改成功!";
            }
            catch (Exception ex)
            {
                rc.Result = false;
                rc.Message = ex.Message;
                Logger.Error(ex.Message, ex);
            }
            return rc;
        }
        // 新增
        public ResultContent AddSMSQuery(SmsQueryVehicleParam para)
        {
            ResultContent rc = new ResultContent();
            try
            {
                // 要校验
                IdentityNoService identity = new IdentityNoService();
                EMSMSQueryVehicle entity = new EMSMSQueryVehicle();
                entity.sms_vehicle_set_id = identity.GetSMSQueryVehicleSettingID();
                entity.CreateDate = DateTime.Now;
                entity.TenantCode = para.TenantCode;
                entity.CustomerName = para.CustomerName;
                entity.CustomerTelephone = para.Telphone;
                entity.IsProfessional = false;
                if (!para.vehicleCodelist.IsNullOrEmpty())
                {
                    entity.SMSVehicle = new List<EMSMSVehicle>();
                    for (int i = 0; i < para.vehicleCodelist.Count; i++)
                    {
                        EMSMSVehicle vehicle = new EMSMSVehicle()
                        {
                            smsvehicle_id = identity.GetSMSVehicleID(),
                            VehicleCode = para.vehicleCodelist[i],
                            TenantCode = para.TenantCode,
                            LicenseNumber = para.LicenceNumberlist[i]
                        };

                        entity.SMSVehicle.Add(vehicle);
                    }
                }

                SMSQueryVehicleService sqv = new SMSQueryVehicleService();
                sqv.Add(entity);
                rc.Message = "新增成功!";
                rc.Result = true;
            }
            catch (Exception ex)
            {
                rc.Result = false;
                rc.Message = ex.Message;
                Logger.Error(ex.Message, ex);
            }
            return rc;
        }