Exemplo n.º 1
0
        public override void ExecuteCommand(ClientManager clientManager, Common.Protobuf.Command command)
        {
            long   requestId;
            short  callbackId;
            string taskId;
            string exception = null;

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

            Common.Protobuf.TaskCallbackCommand taskCallbackCommand = command.TaskCallbackCommand;
            requestId  = command.requestID;
            callbackId = (short)taskCallbackCommand.callbackId;
            taskId     = taskCallbackCommand.taskId;
            try
            {
                stopWatch.Start();
                ICommandExecuter tempVar = clientManager.CmdExecuter;
                NCache           nCache  = (NCache)((tempVar is NCache) ? tempVar : null);

                nCache.Cache.RegisterTaskNotificationCallback(taskId, new TaskCallbackInfo(clientManager.ClientID, callbackId), new Caching.OperationContext());
                stopWatch.Stop();
                Common.Protobuf.Response reponse = new Common.Protobuf.Response();
                reponse.requestId = requestId;
                reponse.commandID = command.commandID;
                Common.Protobuf.TaskCallbackResponse taskCallbackResp = new Common.Protobuf.TaskCallbackResponse();

                reponse.responseType         = Alachisoft.NCache.Common.Protobuf.Response.Type.TASK_CALLBACK;
                reponse.TaskCallbackResponse = taskCallbackResp;
                _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(reponse));
            }
            catch (Exception ex)
            {
                exception = exception.ToString();
                _serializedResponsePackets.Add(ResponseHelper.SerializeExceptionResponse(ex, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.GetTaskResult.ToLower());
                        log.GenerateGetTaskResultAPILogItem(taskId.ToString(), 1, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        protected override void CreateCommand()
        {
            try
            {
                base._command = new Common.Protobuf.Command();

                Common.Protobuf.TaskCallbackCommand taskCallbackCommand = new Common.Protobuf.TaskCallbackCommand();
                taskCallbackCommand.taskId     = this._taskId;
                taskCallbackCommand.callbackId = this._callbackId;
                base._command.requestID        = this.RequestId;

                base._command.TaskCallbackCommand = taskCallbackCommand;
                base._command.type = Common.Protobuf.Command.Type.TASK_CALLBACK;
            }
            catch (Exception ex)
            {
            }
        }