Ejemplo n.º 1
0
        public void ProcessCue(CueRequest req)
        {
            Resolver        resolver;
            ResolverRequest request;

            lock (__lockObj)
            {
                SignalDbRecord signalDbRecord = DbEngine.Get <SignalDbRecord>(req.Id);
                Cue            cue            = req.Cue;
                ActionType     action         = new ActionType
                {
                    CueId   = cue.CueId,
                    Status  = StatusType.New,
                    IsValid = true,
                    Time    = DateTime.UtcNow
                };

                action.Variables = cue.Variables;

                if (signalDbRecord.Actions == null)
                {
                    signalDbRecord.Actions = new System.Collections.Generic.Dictionary <string, ActionType>();
                }

                resolver = signalDbRecord.Signal.Cues[cue.CueId].Resolver;
                request  = new ResolverRequest();

                try
                {
                    ValidateCue(signalDbRecord, cue);

                    request.Id       = cue.Id;
                    request.ActionId = req.ActionId;
                    request.CueId    = cue.CueId;

                    signalDbRecord.Status = StatusType.Received;
                }
                catch (Exception e)
                {
                    // TODO : Check for "Terminal" Status As Well.
                    if (signalDbRecord.Status != StatusType.Received)
                    {
                        signalDbRecord.Status = StatusType.Invalid;
                    }
                    action.Status        = StatusType.Error;
                    action.StatusMessage = e.Message;
                }

                signalDbRecord.Actions.Add(req.ActionId, action);
                signalDbRecord  = DbEngine.Update <SignalDbRecord>(signalDbRecord, true);
                request.Signal  = signalDbRecord.Signal;
                request.Actions = signalDbRecord.Actions;
                request.Trace   = signalDbRecord.Trace;
            }

            Logger.Info($"Sending To Resolver [{resolver.Name}].  {JsonTools.Serialize(request)}");
            SendToResolver(resolver, request);
        }
Ejemplo n.º 2
0
        public CueReply ReceiveCue(Cue cue)
        {
            string   actionId = Utils.GenerateId();
            CueReply reply    = new CueReply
            {
                ActionId      = actionId,
                Id            = cue.Id,
                StatusCode    = StatusCode.Success,
                Time          = DateTime.UtcNow,
                StatusMessage = "Cue Received"
            };

            try
            {
                SignalDbRecord signal = DbEngine.Get <SignalDbRecord>(cue.Id);
                if (signal == null)
                {
                    reply.StatusCode    = StatusCode.Failure;
                    reply.StatusMessage = $"Signal [{cue.Id}] Not Found.";
                }
                else if (signal.IsActive == false)
                {
                    reply.StatusCode    = StatusCode.NotActive;
                    reply.StatusMessage = $"Signal [{cue.Id}] Is Not Active.";
                }
                else
                {
                    reply.SignalDbRecord = signal;
                    CueRequest request = new CueRequest
                    {
                        ActionId = actionId,
                        Id       = cue.Id,
                        Cue      = cue
                    };

                    SendToCueProcessor(request);
                }
            }
            catch (Exception e)
            {
                reply.StatusCode    = StatusCode.Failure;
                reply.StatusMessage = e.Message;
            }

            return(reply);
        }
Ejemplo n.º 3
0
 public virtual void SendToCueProcessor(CueRequest request)
 {
     ProcessCue(request);
 }