Example #1
0
        public DBProcessResult ModifyVehicle(EMVehicleViewModel view)
        {
            DBProcessResult result = new DBProcessResult();
            try
            {
                IEMVehicleService service = new EMVehicleService();
                IEMVehicleLogService logService = new EMVehicleLogService();
                IdentityNoService noService = new IdentityNoService();
                IEMGpsTypeService gpsTypeService = new EMGpsTypeService();

                EMVehicle entity = ConvertHelper.ConvertObj<EMVehicleViewModel, EMVehicle>(view);
                EMVehicle oldEntity = service.Select(view.VehicleCode);
                entity.ExpireTime = oldEntity.ExpireTime;
                entity.InstallTime = oldEntity.InstallTime;
                entity.CreateTime = oldEntity.CreateTime;
                entity.IsStop = oldEntity.IsStop;
                EMGpsType gpsTypeEntity = gpsTypeService.Get(entity.GPSTypeID);
                entity.GPSTypeName = gpsTypeEntity.TypeName;
                //如果设备号改变,要重新获取GPSCode,添加和修改日志
                if (entity.DeviceNo != oldEntity.DeviceNo)
                {
                    bool bo = service.IsExist(view.DeviceNo);
                    if (bo != true)
                    {

                        EnumGPSCodeRule codeType = (EnumGPSCodeRule)gpsTypeEntity.GPSCodeRule;

                        entity.GPSCode = GetGPSCodeHelper.GetGPSCode(gpsTypeEntity.PrefixCode, codeType, entity.SIMNo, entity.DeviceNo);
                        if (entity.DeviceNo.Length == gpsTypeEntity.MachineCodeLength)
                        {
                            //修改上一个日志
                            DateTime now = DateTime.Now;
                            EMVehicleLog lastLog = logService.GetLast(entity.VehicleCode);
                            if (lastLog != null)
                            {
                                lastLog.EndDate = now;
                                logService.Update(lastLog);
                            }

                            //新增一个日志
                            EMVehicleLog vehicleLog = new EMVehicleLog()
                            {
                                BeginDate = now,
                                LogID = noService.GetVehicleLogID(),
                                DeviceNo = entity.DeviceNo,
                                EndDate = null,
                                GPSCode = entity.GPSCode,
                                GPSTypeID = entity.GPSTypeID,
                                InitMileage = entity.InitMileage,
                                LicenceNumber = entity.LicenceNumber,
                                Operator = view.UserName,
                                SIMNo = entity.SIMNo,
                                TenantCode = entity.TenantCode,
                                GroupID = entity.GroupID,
                                VehicleCode = entity.VehicleCode
                            };
                            logService.Insert(vehicleLog);

                            entity.InstallTime = DateTime.Now;
                            service.Update(entity);
                            result.IsSuccess = true;
                        }
                        else
                        {
                            result.IsSuccess = false;
                            result.Message = "GPS设备号长度,不在指定范围内,请重新填写!";
                        }
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message = "GPS设备号已存在,请重新填写!";
                    }
                }
                else
                {
                    service.Update(entity);
                    result.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message = ex.Message;
            }
            return result;
        }
Example #2
0
 public DBProcessResult AddVehicleGroup(EMVehicleGroupViewModel view)
 {
     IdentityNoService noService = new IdentityNoService();
     DBProcessResult result = new DBProcessResult();
     try
     {
         EMVehicleGroup entity = ConvertHelper.ConvertObj<EMVehicleGroupViewModel, EMVehicleGroup>(view);
         entity.GroupID = noService.GetVehicleGroupID();
         entity.Remark = " ";
         EMVehicleGroupService service = new EMVehicleGroupService();
         service.Insert(entity);
         view.GroupID = entity.GroupID;
         result.IsSuccess = true;
     }
     catch (Exception ex)
     {
         result.IsSuccess = false;
         result.Message = ex.Message;
     }
     return result;
 }
Example #3
0
        // 修改
        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;
        }
Example #4
0
        public DBProcessResult AddVehicle(EMVehicleViewModel view)
        {

            DBProcessResult result = new DBProcessResult();
            try
            {
                EMVehicleService service = new EMVehicleService();
                EHistoryDataStoreConfigService configService = new EHistoryDataStoreConfigService();
                EMGpsTypeService gpsTypeService = new EMGpsTypeService();
                EMVehicleLogService logService = new EMVehicleLogService();
                IdentityNoService noService = new IdentityNoService();

                bool licenceNumberIsExist = service.IsExist(view.TenantCode, view.LicenceNumber);
                if (licenceNumberIsExist)
                {
                    result.IsSuccess = false;
                    result.Message = "已经有相同车牌号的车辆";
                    return result;
                }

                EMVehicle entity = ConvertHelper.ConvertObj<EMVehicleViewModel, EMVehicle>(view);
                EMGpsType gpsTypeEntity = gpsTypeService.Get(entity.GPSTypeID);
                Logger.Info("code line 290: gpsTypeService.Get(entity.GPSTypeID)");
                entity.GPSTypeName = gpsTypeEntity.TypeName;

                bool bo = service.IsExist(view.DeviceNo);
                if (bo != true)
                {
                    //新增车辆历史数据配置
                    string tableName = GetTableNameByCondition(gpsTypeEntity.PrefixCode);
                    EHisotryDataStoreTables table = configService.GetHistoryTable(tableName);
                    Logger.Info("code line 299: configService.GetHistoryTable(tableName)");
                    if (table == null)
                    {
                        result.IsSuccess = false;
                        result.Message = string.Format("找不到对应的历史数据表[{0}],请联系DBA!", tableName);
                        return result;
                    }

                    //新增车辆
                    EnumGPSCodeRule codeType = (EnumGPSCodeRule)gpsTypeEntity.GPSCodeRule;
                    entity.GPSCode = GetGPSCodeHelper.GetGPSCode(gpsTypeEntity.PrefixCode, codeType, entity.SIMNo, entity.DeviceNo);

                    if (entity.DeviceNo.Length == gpsTypeEntity.MachineCodeLength)
                    {
                        entity.CreateTime = DateTime.Now;
                        entity.InstallTime = DateTime.Now;
                        GetVehicleGroupID(entity);    //客户管理中新增车辆时,没有车辆组,默认增加到顶级车辆组
                        service.Insert(entity);

                        EHistoryDataStoreConfig configEntity = new EHistoryDataStoreConfig();
                        configEntity.CreateDate = DateTime.Now;
                        configEntity.Enable = true;
                        configEntity.StoreTable = table;
                        configEntity.VehicleCode = entity.VehicleCode;
                        configService.Insert(configEntity);

                        //新增车辆Log
                        EMVehicleLog vehicleLog = new EMVehicleLog()
                        {
                            BeginDate = DateTime.Now,
                            LogID = noService.GetVehicleLogID(),
                            DeviceNo = entity.DeviceNo,
                            EndDate = null,
                            GPSCode = entity.GPSCode,
                            GPSTypeID = entity.GPSTypeID,
                            InitMileage = entity.InitMileage,
                            LicenceNumber = entity.LicenceNumber,
                            Operator = view.UserName,
                            SIMNo = entity.SIMNo,
                            TenantCode = entity.TenantCode,
                            VehicleCode = entity.VehicleCode,
                            GroupID = entity.GroupID,
                        };
                        logService.Insert(vehicleLog);
                        view.VehicleCode = entity.VehicleCode;
                        result.IsSuccess = true;
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message = "GPS设备号长度,不在指定范围内,请重新填写!";
                    }
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message = "设备号已存在,请重新填写!";
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message = ex.Message;
                Logger.Info(ex.StackTrace + "【" + ex.Message + "】");
            }
            return result;
        }
Example #5
0
 public DBProcessResult<EMUserGroupViewModel> InsertUserGruop(EMUserGroupWithVehiclesViewModel viewModel)
 {
     DBProcessResult<EMUserGroupViewModel> result = new DBProcessResult<EMUserGroupViewModel>();
     try
     {
         IMUserGroupService userGroupSev = new MUserGroupService();
         bool isExists = userGroupSev.IsExist(viewModel.UserGourpView.UserGroupName
             , viewModel.UserGourpView.TenantCode);
         if (isExists)
         {
             result.IsSuccess = false;
             result.Message = "用户组名已经存在";
             return result;
         }
         IdentityNoService codeSec = new IdentityNoService();
         IEMVehicleInUserGroupService viuSev = new EMVehicleInUserGroupService();
         //新增用户组
         viewModel.UserGourpView.UserGroupID = codeSec.GetUserGroupID();
         EMUserGroup entity = ConvertHelper.ConvertObj<EMUserGroupViewModel, EMUserGroup>(viewModel.UserGourpView);
         userGroupSev.Add(entity);
         //新增车辆与用户组的关系
         List<EMVehicleInUserGroup> vehicleList = new List<EMVehicleInUserGroup>();
         foreach (EMVehicleInUserGroupViewModel vehicleView in viewModel.Vehicles)
         {
             EMVehicleInUserGroup vehicle = new EMVehicleInUserGroup();
             vehicle.UserGroupID = entity.UserGroupID;
             vehicle.VehicleCode = vehicleView.VehicleCode;
             vehicleList.Add(vehicle);
         }
         viuSev.Insert(vehicleList);
         result.IsSuccess = true;
         result.ReturnValue = viewModel.UserGourpView;
     }
     catch (Exception ex)
     {
         result.IsSuccess = false;
         result.Message = ex.Message;
         Logger.Error(ex.Message, ex);
     }
     return result;
 }
Example #6
0
        // 新增
        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;
        }
        public DBProcessResult AddVehicleOperate(EMVehicle entity, string sUserName)
        {
            DBProcessResult result = new DBProcessResult();
            try
            {
                VehicleDAL ve = new VehicleDAL();
                IdentityNoService noService = new IdentityNoService();
                bool isLiceNum = ve.IsLicenceNumber(entity.TenantCode, entity.LicenceNumber);
                if (isLiceNum)
                {
                    result.IsSuccess = false;
                    result.Message = "已经有相同车牌号的车辆";
                    return result;
                }

                //EMVehicle entity = ConvertHelper.ConvertObj<EMVehicleViewModel, EMVehicle>(view);
                EMGpsType gpsTypeEntity = ve.GetGpsTypeByGpsTypeId(entity.GPSTypeID);
                entity.GPSTypeName = gpsTypeEntity.TypeName;
                bool isDev = ve.IsDeviceNo(entity.DeviceNo);
                if (isDev != true)
                {
                    //新增车辆历史数据配置
                    string tableName = GetTableNameByCondition(gpsTypeEntity.PrefixCode);
                    EHisotryDataStoreTables table = ve.GetHistoryTable(tableName);
                    
                    if (table == null)
                    {
                        result.IsSuccess = false;
                        result.Message = string.Format("找不到对应的历史数据表[{0}],请联系DBA!", tableName);
                        return result;
                    }
                    //新增车辆
                    EnumGPSCodeRule codeType = (EnumGPSCodeRule)gpsTypeEntity.GPSCodeRule;
                    entity.GPSCode = GetGPSCodeHelper.GetGPSCode(gpsTypeEntity.PrefixCode, codeType, entity.SIMNo, entity.DeviceNo);

                    if (entity.DeviceNo.Length == gpsTypeEntity.MachineCodeLength)
                    {
                        GetVehicleGroupID(entity);    //客户管理中新增车辆时,没有车辆组,默认增加到顶级车辆组
                        Logger.Info("新增车辆: " + entity.LicenceNumber + "开始");
                        ve.AddVehicle(entity);
                        Logger.Info("新增车辆: " + entity.LicenceNumber + "结束");

                        EHistoryDataStoreConfig configEntity = new EHistoryDataStoreConfig();
                        configEntity.RecordID = Guid.NewGuid();
                        configEntity.CreateDate = DateTime.Now;
                        configEntity.Enable = true;
                        configEntity.StoreTable = table;
                        configEntity.VehicleCode = entity.VehicleCode;
                        Logger.Info("新增车辆 gps_historydatastoreconfig: " + configEntity.StoreTable.TableName + "开始");
                        ve.AddHistoryDataStoreConfig(configEntity);
                        Logger.Info("新增车辆 gps_historydatastoreconfig: " + configEntity.StoreTable.TableName + "结束");

                        //新增车辆Log
                        EMVehicleLog vehicleLog = new EMVehicleLog()
                        {
                            BeginDate = DateTime.Now,
                            LogID = noService.GetVehicleLogID(),
                            DeviceNo = entity.DeviceNo,
                            EndDate = null,
                            GPSCode = entity.GPSCode,
                            GPSTypeID = entity.GPSTypeID,
                            InitMileage = entity.InitMileage,
                            LicenceNumber = entity.LicenceNumber,
                            Operator = sUserName,
                            SIMNo = entity.SIMNo,
                            TenantCode = entity.TenantCode,
                            VehicleCode = entity.VehicleCode,
                            GroupID = entity.GroupID,
                        };
                        Logger.Info("新增车辆 movo_vehiclelog: " + configEntity.StoreTable.TableName + "开始");
                        ve.AddVehicleLog(vehicleLog);
                        Logger.Info("新增车辆 movo_vehiclelog: " + configEntity.StoreTable.TableName + "结束");

                        result.IsSuccess = true;
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message = string.Format(@"GPS设备号长度为{0},请重新填写!", gpsTypeEntity.MachineCodeLength);
                    }
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message = "设备号已存在,请重新填写!";
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message = ex.Message;
                Logger.Info("新增车辆:" + ex.StackTrace + "【" + ex.Message + "】");
            }
            return result;
            
          
        }
Example #8
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;
 }
 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;
 }
 private EMUserGroup GetEMUserGroup(IdentityNoService identityNoServ, string tenantCode, UserInfoViewModel userInfoViewModel)
 {
     EMUserGroup group;
     group = new EMUserGroup()
     {
         IsAdminGroup = true,
         UserGroupID = identityNoServ.GetUserGroupID(),
         UserGroupName = "管理员",
         TenantCode = tenantCode,
     };
     return group;
 }
 private EMVehicleGroup GetEMVehicleGroup(IdentityNoService identityNoServ, string userName, string tenantCode)
 {
     return new EMVehicleGroup()
     {
         GroupID = identityNoServ.GetVehicleGroupID(),
         GroupName = userName,
         TenantCode = tenantCode
     };
 }
        public CommandResultViewModel AddCustomer(CustomerInfoVM customerVM)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                UserService serv = new UserService();
                bool isExists = serv.ExistsUser(customerVM.UserInfo.UserName);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("用户名" + customerVM.UserInfo.UserName + "已经存在,请重新输入!");
                    return vm;
                }
                EMTenantService tenantServ = new EMTenantService();
                var tempTenant = tenantServ.SelectByName(customerVM.Tenant.TenantName);
                if (tempTenant != null)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("客户名称" + customerVM.Tenant.TenantName + "已经存在,请重新输入!");
                    return vm;
                }

                IdentityNoService identityNoServ = new IdentityNoService();
                string tenantCode = identityNoServ.GetTenantSerialNo();
                EMTenant tenant = GetEMTenant(tenantCode,customerVM.Tenant);
                EMUserGroup userGroup = GetEMUserGroup(identityNoServ, tenantCode,customerVM.UserInfo);
                EMVehicleGroup vehicleGroup = GetEMVehicleGroup(identityNoServ, customerVM.UserInfo.UserName, tenantCode);
                EMUser user = GetEMUser(identityNoServ, customerVM.UserInfo, tenant, userGroup);
                IBaseService baseServ = new BaseService();
                tenant.RegisterUserCode = user.UserCode;
                tenant.RegisterUserName = user.UserName;
                baseServ.Add<EMTenant>(tenant);
                baseServ.Add<EMUserGroup>(userGroup);
                baseServ.Add<EMVehicleGroup>(vehicleGroup);
                baseServ.Add<EMUser>(user);

                vm.CommandResult = EnumCommandResult.Success;
                vm.Msg = "新增用户成功!";
                return vm;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
                return vm;
            }
        }
Example #13
0
 private static EMUserGroup GetEMUserGroup(IdentityNoService identityNoServ, string tenantCode)
 {
     EMUserGroup group;
     group = new EMUserGroup()
     {
         IsAdminGroup = true,
         UserGroupID = identityNoServ.GetUserGroupID(),
         UserGroupName = "管理员",
         TenantCode = tenantCode
     };
     return group;
 }
Example #14
0
 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 DBProcessResult<int> AddVehicleOperateTran(EMVehicle entity, string sUserName)
        {
            DBProcessResult<int> result = new DBProcessResult<int>();
            try
            {
                VehicleDAL ve = new VehicleDAL();
                IdentityNoService noService = new IdentityNoService();
                bool isLiceNum = ve.IsLicenceNumber(entity.TenantCode, entity.LicenceNumber);
                if (isLiceNum)
                {
                    result.IsSuccess = false;
                    result.Message = "已经有相同车牌号的车辆";
                    result.ReturnValue = -1;
                    return result;
                }
                EMGpsType gpsTypeEntity = ve.GetGpsTypeByGpsTypeId(entity.GPSTypeID);
                entity.GPSTypeName = gpsTypeEntity.TypeName;
                bool isDev = ve.IsDeviceNo(entity.DeviceNo);
                if (isDev != true)
                {
                    //新增车辆历史数据配置
                    string tableName = GetTableNameByCondition(gpsTypeEntity.PrefixCode);
                    EHisotryDataStoreTables table = ve.GetHistoryTable(tableName);

                    if (table == null)
                    {
                        result.IsSuccess = false;
                        result.Message = string.Format("找不到对应的历史数据表[{0}],请联系DBA!", tableName);
                        result.ReturnValue = -1;
                        return result;
                    }
                    //新增车辆
                    EnumGPSCodeRule codeType = (EnumGPSCodeRule)gpsTypeEntity.GPSCodeRule;
                    entity.GPSCode = GetGPSCodeHelper.GetGPSCode(gpsTypeEntity.PrefixCode, codeType, entity.SIMNo, entity.DeviceNo);

                    if (entity.DeviceNo.Length == gpsTypeEntity.MachineCodeLength)
                    {
                        GetVehicleGroupID(entity);    //客户管理中新增车辆时,没有车辆组,默认增加到顶级车辆组
                        
                        EHistoryDataStoreConfig configEntity = new EHistoryDataStoreConfig();
                        configEntity.RecordID = Guid.NewGuid();
                        configEntity.CreateDate = DateTime.Now;
                        configEntity.Enable = true;
                        configEntity.StoreTable = table;
                        configEntity.VehicleCode = entity.VehicleCode;
                       
                        //新增车辆Log
                        EMVehicleLog vehicleLog = new EMVehicleLog()
                        {
                            BeginDate = DateTime.Now,
                            LogID = noService.GetVehicleLogID(),
                            DeviceNo = entity.DeviceNo,
                            EndDate = null,
                            GPSCode = entity.GPSCode,
                            GPSTypeID = entity.GPSTypeID,
                            InitMileage = entity.InitMileage,
                            LicenceNumber = entity.LicenceNumber,
                            Operator = sUserName,
                            SIMNo = entity.SIMNo,
                            TenantCode = entity.TenantCode,
                            VehicleCode = entity.VehicleCode,
                            GroupID = entity.GroupID
                        };
                        var res = ve.AddVehicleOperTrans(entity, configEntity, vehicleLog);

                        result.IsSuccess = res.State;
                        result.Message = res.Msg;
                        result.ReturnValue = new VehicleDAL().SelectCount(entity.TenantCode.ToString());
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message = string.Format(@"GPS设备号长度为{0},请重新填写!", gpsTypeEntity.MachineCodeLength);
                        result.ReturnValue = -1;
                    }
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message = "设备号已存在,请重新填写!";
                    result.ReturnValue = -1;
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message = ex.Message;
                result.ReturnValue = -1;
                Logger.Error("VehicleManagerWCFService.AddVehicleOperateTran(EMVehicle entity, string sUserName);" + ex.Message, ex);
            }
            return result;
            
        }
Example #16
0
 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;
 }
Example #17
0
        public CommandResultViewModel UserReg(string userName, string pwd, string email, string QQ, string companyName)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                IUserService serv = new UserService();
                bool isExists = serv.ExistsUser(userName);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("用户名" + userName + "已经存在,请重新输入!");
                    return vm;
                }

                IEMTenantService tenantServ = new EMTenantService();
                var tempTenant = tenantServ.SelectByName(companyName);
                if (tempTenant != null)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("姓名/公司名" + companyName + "已经存在,请重新输入!");
                    return vm;
                }
                
                IdentityNoService identityNoServ = new IdentityNoService();
                string tenantCode = identityNoServ.GetTenantSerialNo();
                EMTenant tenant = GetTenant(tenantCode,email,QQ,companyName,userName);
                EMUserGroup userGroup = GetEMUserGroup(identityNoServ, tenantCode);
                EMVehicleGroup vehicleGroup = GetEMVehicleGroup(identityNoServ,userName, tenantCode);
                EMUser user = GetEMUser(identityNoServ,userName, pwd, email,QQ, tenant, userGroup);
                IBaseService baseServ = new BaseService();
                tenant.RegisterUserCode = user.UserCode;
                baseServ.Add<EMTenant>(tenant);
                baseServ.Add<EMUserGroup>(userGroup);
                baseServ.Add<EMVehicleGroup>(vehicleGroup);
                baseServ.Add<EMUser>(user);

                vm.CommandResult = EnumCommandResult.Success;
                return vm;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
                return vm;
            }
        }