public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { int overload; string exception = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { overload = command.MethodOverload; cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID)); return; } int resultCount = 0; try { NCache nCache = clientManager.CmdExecuter as NCache; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); if (cmdInfo.CommandVersion <= 1) //NCache 3.8 SP4 and previous { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } resultSet = nCache.Cache.Search(cmdInfo.Query, cmdInfo.Values, operationContext); stopWatch.Stop(); SearchResponseBuilder.BuildResponse(resultSet, cmdInfo.RequestId, command.commandID, _serializedResponsePackets, cmdInfo.CommandVersion, out resultCount); } catch (Exception exc) { exception = exc.ToString(); _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, 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.Search.ToLower()); log.GenerateSearchAPILogItem(cmdInfo.Query, cmdInfo.Values, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resultCount); } } catch { } } }
private static char Delimitor = '|'; //Asif Imam public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } return; } try { NCache nCache = clientManager.CmdExecuter as NCache; QueryResultSet resultSet = null; Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation); if (cmdInfo.CommandVersion <= 1) //NCache 3.8 SP4 and previous { operationContext.Add(OperationContextFieldName.ClientLastViewId, forcedViewId); } else //NCache 4.1 SP1 or later { operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId); } resultSet = nCache.Cache.Search(cmdInfo.Query, cmdInfo.Values, operationContext); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); response.search = SearchResponseBuilder.BuildResponse(resultSet, cmdInfo.CommandVersion); response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.SEARCH; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { //PROTOBUF:RESPONSE _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }