private static int Param_OffLineTime = AppSetting.Param_OffLineTime;   //离线参数(m)

        #region ISysSettingWCFService 成员

        public CommandResultViewModel VehicleOilControl(Guid vehicleCode, string tenantCode, string userCode, EnumOilCommandType commandType)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                PositionService positionServ = new PositionService();
                IList<EGPSCurrentInfo> ltCurrent = positionServ.GetCurrentInfoList(new Guid[] { vehicleCode }.ToList());
                if (!CheckCommandCondition(ltCurrent, vm, commandType)) return vm;

                InsertBreakOilHistoryRecord(ltCurrent[0], tenantCode, userCode, commandType);
                vm.CommandResult = EnumCommandResult.Success;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
            }
            return vm;
        }
        private bool CheckCommandCondition(IList<EGPSCurrentInfo> ltCurrent, CommandResultViewModel vm,
            EnumOilCommandType commandType)
        {
            if (ltCurrent.IsNullOrEmpty())
            {
                vm.Msg = "车辆已经离线,无法操作";
                vm.CommandResult = EnumCommandResult.MisMatchCondition;
                return false;
            }
            TimeSpan timeSpan = DateTime.Now.Subtract(ltCurrent[0].ReportTime);
            if (timeSpan.TotalMinutes > Param_OffLineTime)
            {
                vm.Msg = "车辆已经离线,无法操作";
                vm.CommandResult = EnumCommandResult.MisMatchCondition;
                return false;
            }
            if (commandType == EnumOilCommandType.BreakOil)
            {
                if (ltCurrent[0].OilState != 1)          //1 表示油电路正常
                {
                    vm.Msg = "车辆油电路已经断开";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
                if (ltCurrent[0].Speed >= 30)
                {
                    vm.Msg = "此操作在速度30公里/时才能操作";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
            }
            else if (commandType == EnumOilCommandType.Support)
            {
                if (ltCurrent[0].OilState == 1)          //1 表示油电路正常
                {
                    vm.Msg = "车辆油电路已正常";
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    return false;
                }
            }

            return true;
        }
        public CommandResultViewModel UpdateUserCenterMyData(UpdateTenantViewModel model)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                EMTenantService tenantService = new EMTenantService();

                var isExists = tenantService.IsExists(model.TenantName, model.TenantCode);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("客户名称" + model.TenantName + "已经存在,请重新输入!");
                    return vm;
                }
                else
                {
                    EMTenant tenant = tenantService.Select(model.TenantCode);
                    tenant.Email = model.Email;
                    tenant.TenantName = model.TenantName;
                    tenant.PhoneNumber = model.PhoneNumber;
                    tenant.QQ = model.QQ;
                    tenantService.Update(tenant);
                    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;
            }
        }
        public CommandResultViewModel UpdateTenantInfo(TenantViewModel tenantVM)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                IEMTenantService tenantServ = new EMTenantService();
                var isExists = tenantServ.IsExists(tenantVM.TenantName, tenantVM.TenantCode);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("客户名称" + tenantVM.TenantName + "已经存在,请重新输入!");
                    return vm;
                }

                EMTenant newTenant = ConvertHelper.ConvertObj<TenantViewModel, EMTenant>(tenantVM);
                tenantServ.UpdateTenant(newTenant);
                IUserService serv = new UserService();
                serv.Update(newTenant.RegisterUserCode, tenantVM.PhoneNumber);

                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;
            }
        }
        public CommandResultViewModel UpdateOperateMyData(UpdateTenantViewModel model)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                EMTenantService tenantService = new EMTenantService();

                var isExists = tenantService.IsExists(model.TenantName, model.TenantCode);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("客户名称" + model.TenantName + "已经存在,请重新输入!");
                    return vm;
                }
                else
                {
                    EMTenant tenant = tenantService.Select(model.TenantCode);
                    tenant.Email = model.Email;
                    tenant.TenantName = model.TenantName;
                    tenant.PhoneNumber = model.PhoneNumber;
                    tenant.ContactName = model.ContactName;
                    tenant.QQ = model.QQ;
                    tenant.LogoUrl = UploadImageHelper.GetImgName(model.TenantLogoImgURl);
                    tenant.ExpireTime = model.ExpireTime;
                    tenantService.Update(tenant);
                    vm.CommandResult = EnumCommandResult.Success;
                    vm.Msg = "修改成功!";
                }
            }
            catch (Exception ex)
            {
                Logger.Error("OperateManagerWCFService.UpdateOperateMyData(UpdateTenantViewModel model)失败,错误:" + ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
            }
            return vm;
        }
        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;
            }
        }
Exemple #7
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;
            }
        }