private async Task <ResponseBase> ExecuteAction(ActionHandlerBase actionHandler, ExecuteCommand command, MethodInfo actionMethod, ExecutionContext executionContext) { logger.LogDebug("Execution of {actionHandlerName}.{actionName} started. ConnectionId: {connectionId}, ExecutionId: {executionId}", actionMethod.DeclaringType?.FullName, actionMethod.Name, Connection.Id, executionContext.Id); object result = actionMethod.Invoke(actionHandler, GetParameters(actionMethod, command)); if (result != null) { if (ActionHelper.HandleAsyncEnumerable(result, actionHandler.AsyncResult)) { result = null; } else { result = await ActionHelper.HandleAsyncResult(result); } } logger.LogInformation("Executed {actionHandlerName}.{actionName}. ConnectionId: {connectionId}, ExecutionId: {executionId}", actionMethod.DeclaringType?.FullName, actionMethod.Name, Connection.Id, executionContext.Id); return(new ExecuteResponse() { ReferenceId = command.ReferenceId, Result = result }); }
private async Task <ResponseBase> ExecuteAction(ActionHandlerBase actionHandler, ExecuteCommand command, MethodInfo actionMethod) { logger.LogInformation("Execution of " + actionMethod.DeclaringType?.FullName + "." + actionMethod.Name + " started"); object result = actionMethod.Invoke(actionHandler, GetParameters(actionMethod, command)); if (result != null) { if (ActionHelper.HandleAsyncEnumerable(result, actionHandler.AsyncResult)) { result = null; } else { result = await ActionHelper.HandleAsyncResult(result); } } logger.LogInformation("Executed " + actionMethod.DeclaringType?.FullName + "." + actionMethod.Name); return(new ExecuteResponse() { ReferenceId = command.ReferenceId, Result = result }); }
/// <summary> /// 处理 /// </summary> public void Request(CRANE_ACTION_RECORD_X record) { try { HandlerProvider handlerProvider = new HandlerProvider(); ActionHandlerBase handler = handlerProvider.GetHandler(record); if (handler != null) { VisitorProvider visitorProvider = new VisitorProvider(); VisitorBase visitor = visitorProvider.GetVisitor(record); handler.Handle(visitor); } } catch (Exception e) { log.WriteLog(E_ProcessLogType.Error, "物重处理异常。" + e.Message); } try { record.DEAL_SYMBOL = 2; CalculateWeightService.Instance.Update_CRANE_ACTION_RECORD_X(record); } catch (Exception e) { log.WriteLog(E_ProcessLogType.Error, "更新动作记录异常。" + e.Message); } }
/// <summary> /// 空包起吊 /// </summary> /// <param name="record"></param> public override void EmptyHoist(ActionHandlerBase handler) { PosManager.UpdatePos_CCM_Hoist(Wst.NUM, handler.Record.CRA_ID.CRA_NUM, handler.Record.CRA_ID.CRA_NUM); PosManager.EndPos(handler.Record.CRA_ID.CRA_NUM, handler.Record.CRA_ID.CRA_NUM); InsertCCMOutWeightRecord(handler.Record); }
/// <summary> /// 获取动作处理者 /// </summary> /// <param name="record"></param> /// <returns></returns> public ActionHandlerBase GetHandler(CRANE_ACTION_RECORD_X record) { ActionHandlerBase handler = null; switch (record.ACTION_SYMBOL) { case 1: //1空包起吊 handler = new EmptyHoistHandler(); break; case 2: //2重包起吊 handler = new FullHoistHandler(); break; case 3: //3空包放吊 handler = new EmptyDropHandler(); break; case 4: //4重包放吊 handler = new FullDropHandler(); break; case 5: //5兑物 handler = new PourHandler(); break; } if (handler != null) { handler.Record = record; } return(handler); }
public static bool CanExecuteAction(this MethodInfo methodInfo, HttpInformation httpInformation, ActionHandlerBase actionHandler, IServiceProvider serviceProvider) { List <ActionAuthAttribute> authAttributes = methodInfo.GetCustomAttributes <ActionAuthAttribute>(false).ToList(); return(HandleAuthAttributes(methodInfo.DeclaringType, authAttributes, httpInformation, SapphireAuthResource.OperationTypeEnum.Execute, actionHandler, serviceProvider)); }
/// <summary> /// 重包起吊 /// </summary> /// <param name="record"></param> public override void FullHoist(ActionHandlerBase handler) { PosManager.UpdatePos(Wst.NUM, handler.Record.CRA_ID.CRA_NUM, handler.Record.CRA_ID.CRA_NUM); string ladle = LadleManager.MatchLadle(Wst.NUM, handler.Record.CRA_ID.CRA_NUM); InsertBofOutWeightRecord(handler.Record, ladle); }
/// <summary> /// 获取数据类 /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="handler"></param> /// <param name="maps"></param> /// <returns></returns> public static TModel GetModel <TModel>( this ActionHandlerBase <ActionEnum, GoalEnum> handler, IMaps <ActionEnum, GoalEnum> maps ) where TModel : class, IModel { var mgr = maps.GetGameData <GameDataKeyEnum, AIModelMgr>(GameDataKeyEnum.AI_MODEL_MANAGER); return(mgr.GetModel <TModel>(handler.Label)); }
/// <summary> /// 兑物 /// </summary> /// <param name="record"></param> public override void Pour(ActionHandlerBase handler) { if (handler.Record.WEIGHT < 40000 && handler.Record.WEIGHT > 5000)//废钢兑物 { InsertScrapWeightRecord(handler.Record); } else if (handler.Record.WEIGHT < 200000 && handler.Record.WEIGHT > 40000)//铁水兑物 { InsertHmlWeightRecord(handler.Record); } }
private async Task <ResponseBase> GetActionDetails(ExecuteCommand command, HttpInformation context) { string[] actionParts = command?.Action.Split('.'); if (actionParts == null || actionParts.Length != 2) { return(command.CreateExceptionResponse <ExecuteResponse>( new FormatException("Wrong format of action name."))); } string actionHandlerName = actionParts[0]; string actionName = actionParts[1]; Type actionHandlerType = actionMapper.GetHandler(actionHandlerName); if (actionHandlerType != null) { MethodInfo actionMethod = actionMapper.GetAction(actionName, actionHandlerType); if (actionMethod != null) { ActionHandlerBase actionHandler = (ActionHandlerBase)serviceProvider.GetService(actionHandlerType); if (actionHandler != null) { actionHandler.connection = Connection; actionHandler.executeCommand = command; if (!actionHandlerType.CanExecuteAction(context, actionHandler, serviceProvider)) { return(command.CreateExceptionResponse <ExecuteResponse>( new UnauthorizedException("User is not allowed to execute actions of this handler"))); } if (!actionMethod.CanExecuteAction(context, actionHandler, serviceProvider)) { return(command.CreateExceptionResponse <ExecuteResponse>( new UnauthorizedException("User is not allowed to execute action"))); } return(await ExecuteAction(actionHandler, command, actionMethod)); } return(command.CreateExceptionResponse <ExecuteResponse>(new HandlerNotFoundException())); } return(command.CreateExceptionResponse <ExecuteResponse>(new ActionNotFoundException())); } return(command.CreateExceptionResponse <ExecuteResponse>(new ActionHandlerNotFoundException())); }
private async Task <ResponseBase> GetActionDetails(ExecuteCommand command, HttpInformation context) { string[] actionParts = command?.Action.Split('.'); if (actionParts == null || actionParts.Length != 2) { return(command.CreateExceptionResponse <ExecuteResponse>("The format the action name was false.")); } string actionHandlerName = actionParts[0]; string actionName = actionParts[1]; Type actionHandlerType = actionMapper.GetHandler(actionHandlerName); if (actionHandlerType != null) { MethodInfo actionMethod = actionMapper.GetAction(actionName, actionHandlerType); if (actionMethod != null) { ActionHandlerBase actionHandler = (ActionHandlerBase)serviceProvider.GetService(actionHandlerType); if (actionHandler != null) { actionHandler.connection = Connection; actionHandler.executeCommand = command; if (!actionHandlerType.CanExecuteAction(context, actionHandler, serviceProvider)) { return(command.CreateExceptionResponse <ExecuteResponse>( "User is not allowed to execute actions of this handler.")); } if (!actionMethod.CanExecuteAction(context, actionHandler, serviceProvider)) { return(command.CreateExceptionResponse <ExecuteResponse>("User is not allowed to execute action.")); } return(await ExecuteAction(actionHandler, command, actionMethod)); } return(command.CreateExceptionResponse <ExecuteResponse>("No handler was found.")); } return(command.CreateExceptionResponse <ExecuteResponse>("No action to execute was found.")); } return(command.CreateExceptionResponse <ExecuteResponse>("No action handler type was matching")); }
private async Task <ResponseBase> ExecuteAction(ActionHandlerBase actionHandler, ExecuteCommand command, MethodInfo actionMethod) { logger.LogInformation("Execution of " + actionMethod.DeclaringType.FullName + "." + actionMethod.Name + " started"); object result = actionMethod.Invoke(actionHandler, GetParameters(actionMethod, command)); if (result != null) { try { result = await(dynamic) result; } catch (RuntimeBinderException) { /* Do nothing because result is not an awaitable and already contains the expected result */ } } logger.LogInformation("Executed " + actionMethod.DeclaringType.FullName + "." + actionMethod.Name); return(new ExecuteResponse() { ReferenceId = command.ReferenceId, Result = result }); }
private async Task <ResponseBase> GetActionDetails(ExecuteCommand command, HttpInformation context) { Type actionHandlerType = actionMapper.GetHandler(command); if (actionHandlerType != null) { MethodInfo actionMethod = actionMapper.GetAction(command, actionHandlerType); if (actionMethod != null) { ActionHandlerBase actionHandler = (ActionHandlerBase)serviceProvider.GetService(actionHandlerType); if (actionHandler != null) { actionHandler.connection = Connection; actionHandler.executeCommand = command; if (!actionHandlerType.CanExecuteAction(context, actionHandler, serviceProvider)) { return(command.CreateExceptionResponse <ExecuteResponse>( "User is not allowed to execute actions of this handler.")); } if (!actionMethod.CanExecuteAction(context, actionHandler, serviceProvider)) { return(command.CreateExceptionResponse <ExecuteResponse>("User is not allowed to execute action.")); } return(await ExecuteAction(actionHandler, command, actionMethod)); } return(command.CreateExceptionResponse <ExecuteResponse>("No handler was found.")); } return(command.CreateExceptionResponse <ExecuteResponse>("No action to execute was found.")); } return(command.CreateExceptionResponse <ExecuteResponse>("No action handler type was matching")); }
/// <summary> /// 重包放吊 /// </summary> /// <param name="record"></param> public override void FullDrop(ActionHandlerBase handler) { }
/// <summary> /// 空包起吊 /// </summary> /// <param name="record"></param> public override void EmptyHoist(ActionHandlerBase handler) { }
/// <summary> /// 空包放吊 /// </summary> /// <param name="record"></param> public override void EmptyDrop(ActionHandlerBase handler) { }
/// <summary> /// 空包放吊 /// </summary> /// <param name="record"></param> public override void EmptyDrop(ActionHandlerBase handler) { PosManager.StartPos(Wst.NUM, handler.Record.CRA_ID.CRA_NUM); InsertBofInWeightRecord(handler.Record); }
public static bool CanExecuteAction(this Type type, HttpInformation httpInformation, ActionHandlerBase actionHandler, IServiceProvider serviceProvider) { return(HandleAuthAttributes(type.GetActionHandlerAttributesInfo().ActionAuthAttributes, httpInformation, SapphireAuthResource.OperationTypeEnum.Execute, actionHandler, serviceProvider)); }
/// <summary> /// 重包起吊 /// </summary> /// <param name="record"></param> public override void FullHoist(ActionHandlerBase handler) { PosManager.UpdatePos(Wst.NUM, handler.Record.CRA_ID.CRA_NUM, handler.Record.CRA_ID.CRA_NUM); InsertRefineOutWeightRecord(handler.Record); }
/// <summary> /// 重包起吊 /// </summary> /// <param name="record"></param> public abstract void FullHoist(ActionHandlerBase handler);
/// <summary> /// 空包放吊 /// </summary> /// <param name="record"></param> public abstract void EmptyDrop(ActionHandlerBase handler);
/// <summary> /// 空包起吊 /// </summary> /// <param name="record"></param> public abstract void EmptyHoist(ActionHandlerBase handler);
/// <summary> /// 空包起吊 /// </summary> /// <param name="record"></param> public override void EmptyHoist(ActionHandlerBase handler) { PosManager.EndPos(Wst.NUM, handler.Record.CRA_ID.CRA_NUM); }
/// <summary> /// 重包放吊 /// </summary> /// <param name="record"></param> public override void FullDrop(ActionHandlerBase handler) { PosManager.UpdatePos(handler.Record.CRA_ID.CRA_NUM, Wst.NUM, handler.Record.CRA_ID.CRA_NUM); InsertBofInWeightRecord(handler.Record); }
/// <summary> /// 重包起吊 /// </summary> /// <param name="record"></param> public override void FullHoist(ActionHandlerBase handler) { PosManager.UpdatePos(handler.Record.CRA_ID.SPA_ID.NUM, (int)handler.Record.COORD_X, (int)handler.Record.COORD_Y, handler.Record.CRA_ID.CRA_NUM, handler.Record.CRA_ID.CRA_NUM); }
/// <summary> /// 重包起吊 /// </summary> /// <param name="record"></param> public override void FullHoist(ActionHandlerBase handler) { }
/// <summary> /// 兑物 /// </summary> /// <param name="record"></param> public override void Pour(ActionHandlerBase handler) { }
/// <summary> /// 重包放吊 /// </summary> /// <param name="record"></param> public abstract void FullDrop(ActionHandlerBase handler);
/// <summary> /// 兑物 /// </summary> /// <param name="record"></param> public abstract void Pour(ActionHandlerBase handler);
public static bool CanExecuteAction(this Type type, HttpInformation httpInformation, ActionHandlerBase actionHandler, IServiceProvider serviceProvider) { return(HandleAuthAttributes(type, type.GetCustomAttributes <ActionAuthAttribute>(false).ToList(), httpInformation, SapphireAuthResource.OperationTypeEnum.Execute, actionHandler, serviceProvider)); }