示例#1
0
            public override void Send(IRingMasterBackendRequest req)
            {
                if (req == null)
                {
                    return;
                }

                List <Action> actions = new List <Action>();

                RequestResponse resp;

                if (req.RequestType == RingMasterRequestType.Multi && ((Backend.RequestMulti)req).ScheduledName != null)
                {
                    string scheduledName = ((Backend.RequestMulti)req).ScheduledName;
                    ((Backend.RequestMulti)req).ScheduledName = null;

                    Requests.RequestCreate crReq = new Requests.RequestCreate("/$metadata/scheduler/commands/" + scheduledName, ScheduledCommand.GetBytes(req, this.marshaller), null, CreateMode.Persistent);
                    RequestResponse        aux   = this.ProcessT(crReq, actions);

                    this.ev.PushEvent(this.ToString(crReq));

                    resp = new RequestResponse()
                    {
                        CallId  = 0,
                        Content = new List <OpResult>()
                        {
                            OpResult.GetOpResult(RingMasterRequestType.Create, aux)
                        }.AsReadOnly(),
                        ResponsePath = string.Empty,
                        Stat         = null,
                        ResultCode   = aux.ResultCode
                    };
                }
                else
                {
                    resp = this.Process(req.WrappedRequest, actions);
                    this.ev.PushEvent(this.ToString(req.WrappedRequest));
                }

                foreach (Action action in actions)
                {
                    action();
                }

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    req.NotifyComplete(resp.ResultCode, resp.Content, resp.Stat, resp.ResponsePath);
                });
            }