public RaiseCustomEventCommand(object notifId, object data, int methodOverload)
 {
     base.name = "RaiseCustomEventCommand";
     _raiseCustomeEventCommand           = new Alachisoft.NCache.Common.Protobuf.RaiseCustomEventCommand();
     _raiseCustomeEventCommand.notifIf   = (byte[])notifId;
     _raiseCustomeEventCommand.data      = (byte[])data;
     _raiseCustomeEventCommand.requestId = base.RequestId;
     _methodOverload = methodOverload;
 }
        //PROTOBUF
        private CommandInfo ParseCommand(Alachisoft.NCache.Common.Protobuf.Command command, ClientManager clientManager)
        {
            CommandInfo cmdInfo = new CommandInfo();

            Alachisoft.NCache.Common.Protobuf.RaiseCustomEventCommand raiseCustomEventCommand = command.raiseCustomEventCommand;
            cmdInfo.RequestId = raiseCustomEventCommand.requestId.ToString();

            return(cmdInfo);
        }
Beispiel #3
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            byte[]    data = null;
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            try
            {
                overload = command.MethodOverload;
                stopWatch.Start();
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                    //_resultPacket = clientManager.ReplyPacket(base.ExceptionPacket(exc, base.immatureId), base.ParsingExceptionMessage(exc));
                }
                return;
            }
            Alachisoft.NCache.Common.Protobuf.RaiseCustomEventCommand notifcommand = command.raiseCustomEventCommand;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                nCache.Cache.SendNotification(notifcommand.notifIf, notifcommand.data);

                Alachisoft.NCache.Common.Protobuf.RaiseCustomEventResponse raiseCustomEventResponse = new Alachisoft.NCache.Common.Protobuf.RaiseCustomEventResponse();

                if (clientManager.ClientVersion >= 5000)
                {
                    ResponseHelper.SetResponse(raiseCustomEventResponse, command.requestID, command.commandID);
                    _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(raiseCustomEventResponse, Common.Protobuf.Response.Type.RAISE_CUSTOM_EVENT));
                }
                else
                {
                    Common.Protobuf.Response response = new Common.Protobuf.Response();
                    response.raiseCustomEventResponse = raiseCustomEventResponse;
                    ResponseHelper.SetResponse(response, command.requestID, command.commandID, Common.Protobuf.Response.Type.RAISE_CUSTOM_EVENT);
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            catch (Exception exc)
            {
                exception = exc.ToString();
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
            }
            finally
            {
                stopWatch.Stop();
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.RaiseCustomEvent.ToLower());
                        log.GenerateraiseCustomAPILogItem(notifcommand.notifIf.Length, notifcommand.data.Length, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                    }
                }
                catch
                {
                }
            }
        }