예제 #1
0
        /// <summary>
        /// 返回具体事件类型
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        protected RequestMessageBase ToMessage(XmlNode node)
        {
            RequestMessageBase message = null;

            switch (this.Event)
            {
            case EventType.Click:
                message = this.Copy <RequestClickEventMessage>(o =>
                {
                    o.EventKey = node.GetInnerText("EventKey");
                });
                break;

            case EventType.Scan:
                //是二维码扫描事件
                message = this.Copy <RequestQCodeEventMessage>(o =>
                {
                    o.Ticket   = node.GetInnerText("Ticket");
                    o.EventKey = node.GetInnerText("EventKey");
                });
                break;

            case EventType.Location:
                //是地理位置事件
                message = this.Copy <RequestLocationEventMessage>(o =>
                {
                    o.Latitude  = Convert.ToDouble(node.GetInnerText("Latitude"));
                    o.Longitude = Convert.ToDouble(node.GetInnerText("Longitude"));
                    o.Precision = Convert.ToDouble(node.GetInnerText("Precision"));
                });
                break;

            case EventType.View:
                message = this.Copy <RequestViewEventMessage>(o =>
                {
                    o.EventKey = node.GetInnerText("EventKey");
                });
                break;

            case EventType.Subscribe:
                //分2种  用户未关注时,进行关注后的事件推送 / 关注事件
                string ticekt = node.GetInnerText("Ticket");
                if (ticekt == null)
                {
                    //是关注事件
                    message = this.Copy <RequestSubscribeEventMessage>(o =>
                    {
                        o.Subscribe = true;
                    });
                }
                else
                {
                    message = this.Copy <RequestQCodeEventMessage>(o =>
                    {
                        o.Ticket   = node.GetInnerText("Ticket");
                        o.EventKey = node.GetInnerText("EventKey");
                    });
                }
                break;

            case EventType.UnSubscribe:
                //是取消关注事件
                message = this.Copy <RequestSubscribeEventMessage>();
                break;

            case EventType.TEMPLATESENDJOBFINISH:
                message = new RequestTemplateSendJobFinishMessage(this, node.GetInnerText("Status"));
                break;

            default:
                message = this;
                break;
            }


            return(message);
        }