public IHttpActionResult AddNewOpenGateReason(OpenGateReasonRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ReasonRemark) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } OpenGateReasonModel content = new OpenGateReasonModel() { Guid = Guid.NewGuid().ToString("N"), ProjectGuid = model.ProjectGuid, OpenType = model.OpenType, ReasonRemark = model.ReasonRemark }; if (!_openGateReasonManager.SaveOpenReason(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = "保存数据失败";// ApiBaseErrorCode.API_FAIL.ToString(); } return(Ok(response)); }
public IHttpActionResult CarUnLocked(CardServiceBaseRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.ProjectGuid) || string.IsNullOrWhiteSpace(model.CarNo)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "", "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.CarLocked", string.Format("车辆解锁必要参数不全,入参:{0}", Serializer.Serialize(model))); return(Ok(response)); } bool flag = _cardServiceManager.UnLockedCard(model.CarNo, model.ParkingCode); if (!flag) { response.IsSuccess = false; response.MessageCode = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR; response.MessageContent = _cardServiceManager.LastErrorDescribe; } return(Ok(response)); }
public IHttpActionResult ResetPasssword(ResetUserPassword model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.Guid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } UserAccountModel content = usermanager.GetUser(model.Guid); content.UserPswd = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes("fujica"))).Replace("-", ""); if (!usermanager.ModifyUser(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = usermanager.LastErrorDescribe; //ApiBaseErrorCode.API_FAIL.ToString(); } return(Ok(response)); }
public IHttpActionResult ModifyPasssword(ModifyUserPasswordRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.NewPassword) || string.IsNullOrWhiteSpace(model.OldPassword) ) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } UserAccountModel content = usermanager.GetUser(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid) { if (BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(model.OldPassword))).Replace("-", "") == content.UserPswd) { content.UserPswd = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(model.NewPassword))).Replace("-", ""); if (!usermanager.ModifyUser(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = usermanager.LastErrorDescribe; //ApiBaseErrorCode.API_FAIL.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = "旧密码验证失败"; } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiPersonnelErrorCode.API_DATA_NULL_ERROR; response.MessageContent = ApiPersonnelErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult MonthCardRenew(MonthCardServiceRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.ProjectGuid) || string.IsNullOrWhiteSpace(model.PayStyle) || string.IsNullOrWhiteSpace(model.CarTypeGuid) || model.PayAmount < 0 || string.IsNullOrWhiteSpace(model.CarNo) || model.StartDate == default(DateTime) || model.EndDate == default(DateTime)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "", "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.MonthCardRenew", string.Format("月卡延期必要参数不全,入参:{0}", Serializer.Serialize(model))); return(Ok(response)); } if (model.StartDate.Date != DateTime.Now.Date) { model.StartDate = DateTime.Now; //延期开始日期必须是当天 } CardServiceModel content = new CardServiceModel() { ProjectGuid = model.ProjectGuid, ParkCode = model.ParkingCode, CarNo = model.CarNo, StartDate = model.StartDate, EndDate = model.EndDate, PayAmount = model.PayAmount, PayStyle = model.PayStyle, CarTypeGuid = model.CarTypeGuid, PrimaryEndDate = model.PrimaryEndDate, RechargeOperator = model.RechargeOperator }; //需要加上报表存储逻辑 bool flag = _cardServiceManager.RenewCard(content); if (!flag) { response.IsSuccess = false; response.MessageCode = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR; response.MessageContent = _cardServiceManager.LastErrorDescribe; } return(Ok(response)); }
public IHttpActionResult SetVoiceCommand(VoiceCommandRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.DrivewayGuid) || string.IsNullOrWhiteSpace(model.ParkingCode) || model.CommandList.Count < 15 || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数不全,请检查"; return(Ok(response)); } //前端内容带有html字符,传输前进行了url编码 foreach (var item in model.CommandList) { item.ShowText = System.Web.HttpUtility.UrlDecode(item.ShowText); item.ShowVoice = System.Web.HttpUtility.UrlDecode(item.ShowVoice); } DrivewayModel drivewayModel = _parkLotManager.GetDriveway(model.DrivewayGuid); if (drivewayModel == null) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "车道不存在"; return(Ok(response)); } VoiceCommandModel content = new VoiceCommandModel() { ProjectGuid = model.ProjectGuid, ParkCode = model.ParkingCode, DrivewayGuid = model.DrivewayGuid, DeviceMacAddress = drivewayModel.DeviceMacAddress, CommandList = model.CommandList }; if (!_voiceCommandManager.SaveCommand(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiSystemErrorCode.API_DATA_SAVE_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult ModifyTrafficRestriction(ModifyTrafficRestrictionRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } TrafficRestrictionModel content = _trafficRestrictionManager.GetTrafficRestriction(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid) { string[] drivewayguids = (model.DrivewayGuid ?? "").Split(','); string[] cartypeguids = (model.CarTypeGuid ?? "").Split(','); content.DrivewayGuid = drivewayguids.ToList(); content.CarTypeGuid = cartypeguids.ToList();; content.AssignDays = model.AssignDays; content.StartTime = model.StartTime; content.EndTime = model.EndTime; List <DrivewayModel> drivewayList = _parkLotManager.AllDriveway(model.ParkingCode); if (!_trafficRestrictionManager.SaveTrafficRestriction(content, drivewayList)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = "保存数据失败";// ApiBaseErrorCode.API_FAIL.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiSystemErrorCode.API_DATA_NULL_ERROR; response.MessageContent = ApiSystemErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult ModifyOperator(ModifyUserRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.UserName) || string.IsNullOrWhiteSpace(model.UserPswd) || string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } UserAccountModel content = usermanager.GetUser(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid) { RolePermissionModel rolemodel = rolemanager.GetRole(model.RoleGuid); content.UserName = model.UserName; content.UserPswd = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(model.UserPswd))).Replace("-", ""); content.Mobile = model.Mobile; content.Privilege = rolemodel.ContentDetial; content.RoleGuid = model.RoleGuid; if (!usermanager.ModifyUser(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = usermanager.LastErrorDescribe;// ApiBaseErrorCode.API_FAIL.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiPersonnelErrorCode.API_DATA_NULL_ERROR; response.MessageContent = ApiPersonnelErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult ModifyValueCard(ModifyCardServiceRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.ProjectGuid) || string.IsNullOrWhiteSpace(model.CarOwnerName) || string.IsNullOrWhiteSpace(model.Mobile) || string.IsNullOrWhiteSpace(model.CarNo) || string.IsNullOrWhiteSpace(model.DrivewayGuidList) || string.IsNullOrWhiteSpace(model.CarTypeGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "", "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.ModifyValueCard", string.Format("储值卡修改必要参数不全,入参:{0}", Serializer.Serialize(model))); return(Ok(response)); } string[] drivewayguidarray = drivewayguidarray = model.DrivewayGuidList.Split(','); CardServiceModel content = new CardServiceModel() { ProjectGuid = model.ProjectGuid, ParkCode = model.ParkingCode, CarOwnerName = model.CarOwnerName, CarNo = model.CarNo, CarTypeGuid = model.CarTypeGuid, DrivewayGuidList = drivewayguidarray.ToList().FindAll(o => o != ""), Mobile = model.Mobile, RechargeOperator = model.RechargeOperator }; bool flag = _cardServiceManager.ModifyCard(content); if (!flag) { response.IsSuccess = false; response.MessageCode = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR; response.MessageContent = _cardServiceManager.LastErrorDescribe; } return(Ok(response)); }
public IHttpActionResult RemoveTrafficRestriction(ModifyTrafficRestrictionRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } TrafficRestrictionModel content = _trafficRestrictionManager.GetTrafficRestriction(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid && content.ParkCode == model.ParkingCode) { List <DrivewayModel> drivewayList = _parkLotManager.AllDriveway(content.ParkCode); if (!_trafficRestrictionManager.DeleteTrafficRestriction(content, drivewayList)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = _trafficRestrictionManager.LastErrorDescribe; } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiSystemErrorCode.API_DATA_NULL_ERROR; response.MessageContent = "未找到此限行规则";// ApiSystemErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult ModifyOpenGateReason(ModifyOpenGateReasonRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } OpenGateReasonModel content = _openGateReasonManager.GetOpenReason(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid) { content.OpenType = model.OpenType; content.ReasonRemark = model.ReasonRemark; if (!_openGateReasonManager.SaveOpenReason(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = "保存数据失败";// ApiBaseErrorCode.API_FAIL.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiSystemErrorCode.API_DATA_NULL_ERROR; response.MessageContent = ApiSystemErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult RemoveOperator(DeleteUserRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } UserAccountModel content = usermanager.GetUser(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid) { if (!usermanager.DeleteUser(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = ApiBaseErrorCode.API_FAIL.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiPersonnelErrorCode.API_DATA_NULL_ERROR; response.MessageContent = "未找到该操作员";// ApiPersonnelErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult OpenGate(Models.InPut.OpenGateRecordRequest model) { //考虑用异步的接口,然后实现返回拍照后的图片地址 ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.DeviceIdentify)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } OpenGateRecordModel content = new OpenGateRecordModel() { // Guid = Guid.NewGuid().ToString("N"), ParkingCode = model.ParkingCode, DeviceIdentify = model.DeviceIdentify, CarType = model.CarType, EntranceType = model.EntranceType, ThroughName = model.ThroughName, DiscernCamera = model.DiscernCamera, ThroughType = model.ThroughType, OpenGateOperator = model.OpenGateOperator, OpenGateReason = model.OpenGateReason, Remark = model.Remark, ImageUrl = model.ImageUrl, ErrorCode = model.ErrorCode, CarNo = model.CarNo }; if (!_openGateReasonManager.OpenGate(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = ApiBaseErrorCode.API_FAIL.ToString(); } return(Ok(response)); }
public IHttpActionResult CancelCar(CancelCardServiceRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.ProjectGuid) || string.IsNullOrWhiteSpace(model.CarNo) || model.RefundAmount < 0) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "", "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.CarLocked", string.Format("车辆注销时必要参数不全,入参:{0}", Serializer.Serialize(model))); return(Ok(response)); } CardServiceModel content = new CardServiceModel() { ProjectGuid = model.ProjectGuid, ParkCode = model.ParkingCode, CarNo = model.CarNo, PayAmount = model.RefundAmount, Remark = model.Remark, RechargeOperator = model.RechargeOperator }; //需要加上报表存储逻辑 bool flag = _cardServiceManager.DeleteCard(content); if (!flag) { response.IsSuccess = false; response.MessageCode = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR; response.MessageContent = _cardServiceManager.LastErrorDescribe; } return(Ok(response)); }
public IHttpActionResult AddNewTrafficRestriction(TrafficRestrictionRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } string[] drivewayguids = (model.DrivewayGuid ?? "").Split(','); string[] cartypeguids = (model.CarTypeGuid ?? "").Split(','); TrafficRestrictionModel content = new TrafficRestrictionModel() { Guid = Guid.NewGuid().ToString("N"), ProjectGuid = model.ProjectGuid, ParkCode = model.ParkingCode, DrivewayGuid = drivewayguids.ToList(), CarTypeGuid = cartypeguids.ToList(), AssignDays = model.AssignDays, StartTime = model.StartTime, EndTime = model.EndTime }; List <DrivewayModel> drivewayList = _parkLotManager.AllDriveway(model.ParkingCode); if (!_trafficRestrictionManager.SaveTrafficRestriction(content, drivewayList)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = "保存数据失败";// ApiBaseErrorCode.API_FAIL.ToString(); } return(Ok(response)); }
public IHttpActionResult CaptureSend(CaptureInOutModel model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = false, MessageCode = (int)ApiBaseErrorCode.API_FAIL, MessageContent = "请求失败" }; List <string> laneIds = new List <string>() { }; if (model.DriveWayMAC != null) { laneIds.Add(model.DriveWayMAC); } Clients.Groups(laneIds).broadcastMessage(model); //broadcastMessage response.IsSuccess = true; response.MessageCode = (int)ApiBaseErrorCode.API_SUCCESS; response.MessageContent = "请求成功"; return(Ok(response)); }
public IHttpActionResult HeartBeatSend(HeartBeatModel model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = false, MessageCode = (int)ApiBaseErrorCode.API_FAIL, MessageContent = "请求失败" }; List <string> laneIds = new List <string>() { }; if (model.ParkingCode != null && model.DeviceIdentify != null) { laneIds.Add(model.ParkingCode); } Clients.Groups(laneIds).heartBeatMessage(model); //broadcastMessage response.IsSuccess = true; response.MessageCode = (int)ApiBaseErrorCode.API_SUCCESS; response.MessageContent = "请求成功"; return(Ok(response)); }
public IHttpActionResult AddNewOperator(UserRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.UserName) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } //拿取角色权限字符串 RolePermissionModel rolemodel = rolemanager.GetRole(model.RoleGuid); UserAccountModel content = new UserAccountModel() { Guid = Guid.NewGuid().ToString("N"), ProjectGuid = model.ProjectGuid, UserName = model.UserName, UserPswd = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes("fujica"))).Replace("-", ""), Mobile = model.Mobile, Privilege = rolemodel.ContentDetial, RoleGuid = model.RoleGuid }; if (!usermanager.AddUser(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = usermanager.LastErrorDescribe; //ApiBaseErrorCode.API_FAIL.ToString(); } return(Ok(response)); }
public IHttpActionResult ChargeOpenGate(FreeOpenGateRequest model) { //考虑用异步的接口,然后实现返回拍照后的图片地址 ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.DeviceIdentify) || //设备标识 string.IsNullOrWhiteSpace(model.CarNo) || string.IsNullOrWhiteSpace(model.TolloPerator)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } FreeOpenGateModel content = new FreeOpenGateModel() { ParkingCode = model.ParkingCode, DeviceIdentify = model.DeviceIdentify, CarNo = model.CarNo, TolloPerator = model.TolloPerator, Remark = model.Remark }; if (!_openGateReasonManager.ChargeOpenGate(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = ApiBaseErrorCode.API_FAIL.ToString(); } return(Ok(response));; }
public IHttpActionResult ApplyNewCard(ApplyCardServiceRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.ParkingCode) || string.IsNullOrWhiteSpace(model.ProjectGuid) || string.IsNullOrWhiteSpace(model.CarOwnerName) || string.IsNullOrWhiteSpace(model.Mobile) || string.IsNullOrWhiteSpace(model.CarNo) || string.IsNullOrWhiteSpace(model.DrivewayGuidList) || string.IsNullOrWhiteSpace(model.CarTypeGuid) || model.PayAmount < 0 || string.IsNullOrWhiteSpace(model.PayStyle)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; Logger.LogWarn(LoggerLogicEnum.Interface, "", "", "", "Fujica.com.cn.Interface.Management.Controllers.CardServiceController.ApplyNewCard", string.Format("开卡必要参数不全,入参:{0}", Serializer.Serialize(model))); return(Ok(response)); } if (model.StartDate.Date != DateTime.Now.Date) { model.StartDate = DateTime.Now; //开始日期必须是当天 } string[] drivewayguidarray = drivewayguidarray = model.DrivewayGuidList.Split(','); CardServiceModel content = new CardServiceModel() { ProjectGuid = model.ProjectGuid, ParkCode = model.ParkingCode, CarOwnerName = model.CarOwnerName, CarNo = model.CarNo, CarTypeGuid = model.CarTypeGuid, DrivewayGuidList = drivewayguidarray.ToList().FindAll(o => o != ""), Mobile = model.Mobile, PayAmount = model.PayAmount, PayStyle = model.PayStyle, Remark = model.Remark, Balance = model.PayAmount, //新开卡时余额就等于支付金额(仅当储值卡时后端逻辑才会读取此值) StartDate = model.StartDate, PrimaryEndDate = model.StartDate, EndDate = model.EndDate, RechargeOperator = model.RechargeOperator, PauseDate = default(DateTime), Locked = false, Enable = true }; //需要加上报表存储逻辑 bool flag = _cardServiceManager.AddNewCard(content); if (!flag) { response.IsSuccess = false; response.MessageCode = (int)ApiCardServiceErrorCode.API_DATA_SAVE_ERROR; response.MessageContent = _cardServiceManager.LastErrorDescribe; } return(Ok(response)); }
/// <summary> /// 拦截验证请求参数 /// </summary> /// <param name="actionContext"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { //标记 AllowAnonymousAttribute 特性的Controller/Action不做验证 if (actionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any() || actionContext.ControllerContext.ControllerDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any()) { return; } //默认返回值 ResponseBaseCommon resp = new ResponseBaseCommon { IsSuccess = false, MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR, MessageContent = ApiBaseErrorCode.API_PARAM_ERROR.GetRemark(), }; //如果不是继承自BaseController,返回签名错误 if (!(actionContext.ControllerContext.Controller is BaseController)) { resp.MessageContent += ",请求未授权"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } m_stattime = DateTime.Now; var _baseController = ((BaseController)actionContext.ControllerContext.Controller); i_logger = _baseController.Logger; i_serializer = _baseController.Serializer; apiaccesscontrol = _baseController.Apiaccesscontrol; var appID = string.Empty; var sign = string.Empty; var timestamp = string.Empty; var appid_header = "appid"; var sign_header = "sign"; var timestamp_header = "timestamp"; #region 通过APPID读取缓存的项目信息 if (actionContext.Request.Headers.Contains(appid_header)) { appID = actionContext.Request.Headers.GetValues(appid_header).FirstOrDefault(); } //没有指定标头的请求都返回签名错误 if (string.IsNullOrWhiteSpace(appID)) { resp.MessageContent += ",缺少appid"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } //获取接入信息 APIAccessModel apiaccessmodel = apiaccesscontrol.Get(appID); //找不到接入信息,返回签名错误 if (apiaccessmodel == null) { resp.MessageContent += ",appid无效"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } //如果不允许接入api,返回权限不足 if (apiaccessmodel.Enable == 0) { resp.MessageCode = (int)ApiBaseErrorCode.API_Unauthorized; resp.MessageContent = ApiBaseErrorCode.API_Unauthorized.GetRemark(); actionContext.Response = actionContext.Request.CreateResponse(resp); return; } #endregion //1 时间戳验证、2 签名验证、 4 接口权限验证、 8参数验证 #region 验证时间戳 if ((apiaccessmodel.NeedVerify & 1) == 1) { if (actionContext.Request.Headers.Contains(timestamp_header)) { timestamp = actionContext.Request.Headers.GetValues(timestamp_header).FirstOrDefault(); } if (string.IsNullOrWhiteSpace(timestamp)) { resp.MessageContent += ",时间戳无效"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } long _timestamp = 0L; if (long.TryParse(timestamp, out _timestamp)) { var reqTime = DateTime.Parse("1970.1.1").AddSeconds(_timestamp); //请求时间在前后5分钟之外的,返回请求过期 if (reqTime > DateTime.UtcNow.AddMinutes(5) || reqTime < DateTime.UtcNow.AddMinutes(-5)) { resp.MessageContent = "请求已过期"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } } else { resp.MessageContent = "请求已过期"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } } #endregion #region 验证签名 //读取请求流,获取签名数据 var reqContent = string.Empty; if ((apiaccessmodel.NeedVerify & 2) == 2) { //如果公钥或secret为空,返回签名错误 if (string.IsNullOrWhiteSpace(apiaccessmodel.PublicKey) || string.IsNullOrWhiteSpace(apiaccessmodel.Secret)) { resp.MessageContent = "参数配置错误"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } if (actionContext.Request.Method.Method == "GET") { reqContent = HttpContext.Current.Request.QueryString.ToString(); if (!string.IsNullOrEmpty(reqContent)) { reqContent = reqContent.TrimStart('?'); } } else { var stream = await actionContext.Request.Content.ReadAsStreamAsync(); stream.Position = 0; var reader = new StreamReader(stream); reqContent = reader.ReadToEnd(); //重置请求流文件的状态 stream.Position = 0; } if (string.IsNullOrWhiteSpace(reqContent)) { resp.MessageContent += ",未检测到请求参数"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } if (actionContext.Request.Headers.Contains(sign_header)) { sign = actionContext.Request.Headers.GetValues(sign_header).FirstOrDefault(); } // sign标头值为空,则返回签名错误 if (string.IsNullOrWhiteSpace(sign)) { resp.MessageContent += ",签名无效"; actionContext.Response = actionContext.Request.CreateResponse(resp); return; } else { string signparam = string.Empty; try { //要签名的字符串为参数拼接后的字符串(或json字符串)+secret+timestamp signparam = string.Concat("param=", reqContent, "&secret=", apiaccessmodel.Secret, "×tamp=", timestamp); var result = Signature.verify(signparam, sign, apiaccessmodel.PublicKey, "UTF-8"); if (!result) { resp.MessageContent = "验证签名失败"; actionContext.Response = actionContext.Request.CreateResponse(resp); i_logger.LogLogic( LoggerLogicEnum.Filter, "", "", "", string.Concat(m_projectInfo, ".OnActionExecuting"), string.Format("请求参数:{0};appid:{1};sign:{2};signparam:{3};返回参数:{4}", reqContent, appID, sign, signparam, i_serializer.Serialize(resp)) ); return; } } catch (Exception ex) { resp.MessageContent = "验证签名失败"; actionContext.Response = actionContext.Request.CreateResponse(resp); i_logger.LogError( LoggerLogicEnum.Filter, "", "", "", string.Concat(m_projectInfo, ".OnActionExecuting"), string.Format("请求参数:{0};appid:{1};sign:{2};signparam:{3};返回参数:{4}", reqContent, appID, sign, signparam, i_serializer.Serialize(resp)), ex.ToString() ); return; } } } #endregion #region 接口权限验证 if ((apiaccessmodel.NeedVerify & 4) == 4) { var url = actionContext.ControllerContext.Request.RequestUri.ToString().Split('/'); if (url.Length == 6) { bool result = false; string[] test = { }; //todo 权限验证 foreach (var item in test) { if (url[5].Equals(item)) { result = true; break; } } if (!result) { resp.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; resp.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.GetRemark(); actionContext.Response = actionContext.Request.CreateResponse(resp); return; } } else { actionContext.Response = actionContext.Request.CreateResponse(resp); return; } } #endregion #region 验证参数规范 if ((apiaccessmodel.NeedVerify & 8) == 8) { if (!actionContext.ModelState.IsValid) { int num = 1; List <string> values = new List <string>(); //获取所有错误的Key List <string> Keys = actionContext.ModelState.Keys.ToList(); //获取每一个key对应的ModelStateDictionary foreach (var key in Keys) { var errors = actionContext.ModelState[key].Errors.ToList(); //将错误描述添加到sb中 foreach (var error in errors) { values.Add(string.Concat(num, ".", key + ":", error.ErrorMessage)); num++; } } resp.MessageContent = string.Concat(ApiBaseErrorCode.API_PARAM_ERROR.GetRemark(), ":", string.Join(";", values)); actionContext.Response = actionContext.Request.CreateResponse(resp); i_logger.LogLogic( LoggerLogicEnum.Filter, "", "", "", string.Concat(m_projectInfo, ".OnActionExecuting"), string.Format("请求参数:{0};appid:{1};sign:{2};返回参数:{3}", reqContent, appID, sign, i_serializer.Serialize(resp)) ); return; } } #endregion }
/// <summary> /// 记录请求日志 /// </summary> /// <param name="actionExecutedContext"></param> public async override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { //标记 AllowAnonymousAttribute 特性的Controller/Action不做验证 if (actionExecutedContext.ActionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any() || actionExecutedContext.ActionContext.ControllerContext.ControllerDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any()) { return; } base.OnActionExecuted(actionExecutedContext); var appid = string.Empty; var sign = string.Empty; var timestamp = string.Empty; if (actionExecutedContext.Request.Headers.Contains("appid")) { appid = actionExecutedContext.Request.Headers.GetValues("appid").FirstOrDefault(); } if (actionExecutedContext.Request.Headers.Contains("sign")) { sign = actionExecutedContext.Request.Headers.GetValues("sign").FirstOrDefault(); } if (actionExecutedContext.Request.Headers.Contains("timestamp")) { timestamp = actionExecutedContext.Request.Headers.GetValues("timestamp").FirstOrDefault(); } var reqContent = string.Empty; var resContent = string.Empty; var isError = 0; try { if (actionExecutedContext.Request.Method.Method == "GET") { reqContent = actionExecutedContext.Request.RequestUri.Query; if (!string.IsNullOrEmpty(reqContent)) { reqContent = reqContent.TrimStart('?'); } } else { var stream = await actionExecutedContext.Request.Content.ReadAsStreamAsync(); stream.Position = 0; var reader = new StreamReader(stream); reqContent = reader.ReadToEnd(); //重置请求流文件的状态 stream.Position = 0; } if (actionExecutedContext.Response == null) { isError = 1; // 获取异常信息 ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = false, MessageCode = (int)ApiBaseErrorCode.API_ERROR, MessageContent = string.Concat(actionExecutedContext.Exception.Message, actionExecutedContext.Exception.StackTrace) }; // 重新封装回传格式 actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(System.Net.HttpStatusCode.OK, response); resContent = i_serializer.Serialize(response); } else { resContent = actionExecutedContext.Response.Content.ReadAsStringAsync().Result; } } catch (Exception ex) { isError = 1; i_logger.LogError(LoggerLogicEnum.Filter, "", "", "", actionExecutedContext.Request.RequestUri.ToString(), string.Format("Filter出现异常:\r\n请求参数:{0}\r\nappid:{1}\r\nsign:{2}\r\ntimestamp:{3}\r\n返回结果:{4}", reqContent, appid, sign, timestamp, resContent), ex.ToString()); } var nowtime = DateTime.Now; var time = (nowtime - m_stattime).TotalSeconds; if (actionExecutedContext.Request.RequestUri.Segments.Length > 3) { var ip = string.Empty; var serviceName = string.Empty; string hostName = System.Net.Dns.GetHostName(); System.Net.IPAddress[] addresses = System.Net.Dns.GetHostAddresses(hostName); if (actionExecutedContext.Request.RequestUri.Segments.Length == 4) { serviceName = string.Concat(actionExecutedContext.Request.RequestUri.Segments[2].TrimEnd('/'), ".", actionExecutedContext.Request.RequestUri.Segments[3]); } else if (actionExecutedContext.Request.RequestUri.Segments.Length == 5) { serviceName = string.Concat(actionExecutedContext.Request.RequestUri.Segments[3].TrimEnd('/'), ".", actionExecutedContext.Request.RequestUri.Segments[4]); } for (int i = 0; i < addresses.Length; i++) { var item = addresses[i].ToString(); if (item.StartsWith("10.") || item.StartsWith("192.168.")) { ip = item; } } ; //int isSuccess = 0; //var result = i_serializer.Deserialize<ResponseBaseCommon>(resContent); //isSuccess = result.MessageCode; } i_logger.LogInfo(LoggerLogicEnum.Filter, "", "", "", actionExecutedContext.Request.RequestUri.ToString(), string.Format("\r\n请求参数:{0}\r\nappid:{1}\r\nsign:{2}\r\ntimestamp:{3}\r\n返回结果:{4}\r\n接口耗时:{5}秒", reqContent, appid, sign, timestamp, resContent, time) ); }
public IHttpActionResult ModifyRole(ModifyRoleRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (model.MenuSerials == null || string.IsNullOrWhiteSpace(model.RoleName) || string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } RolePermissionModel content = rolemanager.GetRole(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid) { //组建权限字符串 string privilegeStr = ""; MenuModel menumodel = menumanager.GetMenu(model.ProjectGuid); if (menumodel != null) { foreach (MenuDetialModel item in menumodel.MenuList) { string menuSerial = item.MenuSerial.PadLeft(3, '0'); if (model.MenuSerials.Exists(o => o == menuSerial)) { privilegeStr += (menuSerial + "1"); } else { privilegeStr += (menuSerial + "0"); } } } //授权停车场编号集合 string parkingCodeStr = ""; if (model.ParkingCodeList != null) { foreach (string item in model.ParkingCodeList) { parkingCodeStr += item + ","; } parkingCodeStr = parkingCodeStr.TrimEnd(','); } content.RoleName = model.RoleName; content.ContentDetial = privilegeStr; content.ParkingCodeList = parkingCodeStr; if (!rolemanager.ModifyRole(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = ApiBaseErrorCode.API_FAIL.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiPersonnelErrorCode.API_DATA_NULL_ERROR; response.MessageContent = ApiPersonnelErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }
public IHttpActionResult RemoveRole(RoleRequest model) { ResponseBaseCommon response = new ResponseBaseCommon() { IsSuccess = true, MessageCode = (int)ApiBaseErrorCode.API_SUCCESS, MessageContent = ApiBaseErrorCode.API_SUCCESS.ToString() }; if (string.IsNullOrWhiteSpace(model.Guid) || string.IsNullOrWhiteSpace(model.ProjectGuid)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_PARAM_ERROR; response.MessageContent = "必要参数缺失,请检查"; return(Ok(response)); } RolePermissionModel content = rolemanager.GetRole(model.Guid); if (content != null) { if (content.ProjectGuid == model.ProjectGuid) { //超级管理员不让删除(目前没有字段判断,只能针对名字来进行判断) if (content.RoleName == "超级管理员") { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = "超级管理员无法删除。"; return(Ok(response)); } //删除前需要验证该角色下是否含有操作员 List <UserAccountModel> userList = usermanager.GetUserList(model.ProjectGuid); if (userList != null) { int userCount = userList.Where(m => m.RoleGuid == model.Guid).Count(); if (userCount > 0) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = "该角色正在使用中,无法删除。"; return(Ok(response)); } } if (!rolemanager.DeleteRole(content)) { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_FAIL; response.MessageContent = ApiBaseErrorCode.API_FAIL.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiBaseErrorCode.API_INTERFACENAME_ERROR; response.MessageContent = ApiBaseErrorCode.API_INTERFACENAME_ERROR.ToString(); } } else { response.IsSuccess = false; response.MessageCode = (int)ApiPersonnelErrorCode.API_DATA_NULL_ERROR; response.MessageContent = ApiPersonnelErrorCode.API_DATA_NULL_ERROR.ToString(); } return(Ok(response)); }