Ejemplo n.º 1
0
        public void OnMenuItemClick(object sender, EventArgs e)
        {
            ButtonMenu btn = (ButtonMenu)sender;

            btn.Selected = true;

            if (lastSelectedButton != null)
            {
                lastSelectedButton.Selected = false;
            }

            lastSelectedButton = btn;

            int index = 0;

            for (var i = 0; i < MenuViewModel.MenuItems.Count; i++)
            {
                if (MenuViewModel.MenuItems[i].page_title == btn.MenuItem.page_title)
                {
                    index = i;
                }
            }

            MenuClickEvent.Notify(btn.MenuItem.menu_title, btn.MenuItem.url, index);
        }
Ejemplo n.º 2
0
 public void Handle(MenuClickEvent message)
 {
     this.HandleEvent((StatEventBase)message);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化微信消息处理事件
        /// </summary>
        private void InitEventsHandle()
        {
            #region 普通消息
            //文本消息
            handlerList.Add(MessageType.Text, ReceiveEventType.None, (data) =>
            {
                ReceiveTextMessage?.Invoke(data.ConvertBodyTo <TextMessage>(), Replier.Create(data));
            });

            //图片消息
            handlerList.Add(MessageType.Image, ReceiveEventType.None, (data) =>
            {
                ReceiveImageMessage?.Invoke(data.ConvertBodyTo <ImageMessage>(), Replier.Create(data));
            });

            //语音消息
            handlerList.Add(MessageType.Voice, ReceiveEventType.None, (data) =>
            {
                ReceiveVoiceMessage?.Invoke(data.ConvertBodyTo <VoiceMessage>(), Replier.Create(data));
            });

            //视频消息
            handlerList.Add(MessageType.Video, ReceiveEventType.None, (data) =>
            {
                ReceiveVideoMessage?.Invoke(data.ConvertBodyTo <VideoMessage>(), Replier.Create(data));
            });

            //小视频消息
            handlerList.Add(MessageType.ShortVideo, ReceiveEventType.None, (data) =>
            {
                ReceiveShortVideoMessage?.Invoke(data.ConvertBodyTo <ShortVideoMessage>(), Replier.Create(data));
            });

            //地理位置消息
            handlerList.Add(MessageType.Location, ReceiveEventType.None, (data) =>
            {
                ReceiveLocationMessage?.Invoke(data.ConvertBodyTo <LocationMessage>(), Replier.Create(data));
            });

            //链接消息
            handlerList.Add(MessageType.Link, ReceiveEventType.None, (data) =>
            {
                ReceiveLinkMessage?.Invoke(data.ConvertBodyTo <LinkMessage>(), Replier.Create(data));
            });
            #endregion

            #region 事件消息
            //关注事件
            handlerList.Add(MessageType.Event, ReceiveEventType.Subscribe, (data) =>
            {
                var _event = data.ConvertBodyTo <ScanEventArgs>();
                if (string.IsNullOrEmpty(_event.EventKey))
                {
                    SubscribeEvent?.Invoke(_event, Replier.Create(data));
                }
                else
                {
                    _event.EventKey = _event.EventKey.Substring("qrscene_".Length);
                    ScanEvent?.Invoke(_event, Replier.Create(data));
                }
            });

            //取消关注事件
            handlerList.Add(MessageType.Event, ReceiveEventType.UnSubscribe, (data) =>
            {
                PassReply(data);
                UnSubscribeEvent?.Invoke(data.ConvertBodyTo <EventArgsBase>());
            });

            //扫描带参数二维码事件
            handlerList.Add(MessageType.Event, ReceiveEventType.Scan, (data) =>
            {
                ScanEvent?.Invoke(data.ConvertBodyTo <ScanEventArgs>(), Replier.Create(data));
            });

            //上报地理位置事件
            handlerList.Add(MessageType.Event, ReceiveEventType.Location, (data) =>
            {
                PassReply(data);
                LocationEvent?.Invoke(data.ConvertBodyTo <LocationEventArgs>());
            });

            //点击菜单拉取消息事件
            handlerList.Add(MessageType.Event, ReceiveEventType.Click, (data) =>
            {
                MenuClickEvent?.Invoke(data.ConvertBodyTo <WithKeyEventArgs>(), Replier.Create(data));
            });

            //点击菜单跳转链接事件
            handlerList.Add(MessageType.Event, ReceiveEventType.View, (data) =>
            {
                PassReply(data);
                ViewEvent?.Invoke(data.ConvertBodyTo <WithKeyEventArgs>());
            });

            //群发任务完成事件
            handlerList.Add(MessageType.Event, ReceiveEventType.MessageEndJobFinish, (data) =>
            {
                PassReply(data);
                MessageEndJobFinishEvent?.Invoke(data.ConvertBodyTo <MessageEndJobFinishEventArgs>());
            });

            //模板消息发送完成事件
            handlerList.Add(MessageType.Event, ReceiveEventType.TemplateSendJobFinish, (data) =>
            {
                PassReply(data);
                TemplateSendJobFinishEvent?.Invoke(data.ConvertBodyTo <TemplateSendJobFinishEventArgs>());
            });

            //买单事件推送
            handlerList.Add(MessageType.Event, ReceiveEventType.user_pay_from_pay_cell, (data) =>
            {
                PassReply(data);
                UserPayFromPayCellEvent?.Invoke(data.ConvertBodyTo <UserPayFromPayCellEventArgs>(), Replier.Create(data));
            });

            //卡券审核事件
            handlerList.Add(MessageType.Event, ReceiveEventType.card_pass_check, (data) =>
            {
                PassReply(data);
                CardPassCheckEvent?.Invoke(data.ConvertBodyTo <CardPassCheckEventArgs>(), Replier.Create(data));
            });

            //卡券领取事件
            handlerList.Add(MessageType.Event, ReceiveEventType.user_get_card, (data) =>
            {
                PassReply(data);
                UserGetCardEvent?.Invoke(data.ConvertBodyTo <UserGetCardEventArgs>(), Replier.Create(data));
            });

            //卡券转赠事件
            handlerList.Add(MessageType.Event, ReceiveEventType.user_gifting_card, (data) =>
            {
                PassReply(data);
                UserGiftingCardEvent?.Invoke(data.ConvertBodyTo <UserGiftingCardEventArgs>(), Replier.Create(data));
            });

            //卡券删除事件
            handlerList.Add(MessageType.Event, ReceiveEventType.user_del_card, (data) =>
            {
                PassReply(data);
                UserDelCardEvent?.Invoke(data.ConvertBodyTo <UserDelCardEventArgs>(), Replier.Create(data));
            });

            //卡券核销事件
            handlerList.Add(MessageType.Event, ReceiveEventType.user_consume_card, (data) =>
            {
                PassReply(data);
                UserConsumeCardEvent?.Invoke(data.ConvertBodyTo <UserConsumeCardEventArgs>(), Replier.Create(data));
            });

            //进入会员卡事件
            handlerList.Add(MessageType.Event, ReceiveEventType.user_view_card, (data) =>
            {
                PassReply(data);
                UserViewCardEvent?.Invoke(data.ConvertBodyTo <UserViewCardEventArgs>(), Replier.Create(data));
            });

            //从卡券进入公众号会话事件
            handlerList.Add(MessageType.Event, ReceiveEventType.user_enter_session_from_card, (data) =>
            {
                PassReply(data);
                UserEnterSessionFromCardEvent?.Invoke(data.ConvertBodyTo <UserEnterSessionFromCardEventArgs>(), Replier.Create(data));
            });

            //会员卡内容更新事件
            handlerList.Add(MessageType.Event, ReceiveEventType.update_member_card, (data) =>
            {
                PassReply(data);
                UpdateMemberCardEvent?.Invoke(data.ConvertBodyTo <UpdateMemberCardEventArgs>(), Replier.Create(data));
            });

            //会员卡激活事件推送
            handlerList.Add(MessageType.Event, ReceiveEventType.submit_membercard_user_info, (data) =>
            {
                PassReply(data);
                SubmitMemberCardUserInfoEvent?.Invoke(data.ConvertBodyTo <SubmitMemberCardUserInfoEventArgs>(), Replier.Create(data));
            });

            //库存报警事件
            handlerList.Add(MessageType.Event, ReceiveEventType.card_sku_remind, (data) =>
            {
                PassReply(data);
                CardSkuRemindEvent?.Invoke(data.ConvertBodyTo <CardSkuRemindEventArgs>(), Replier.Create(data));
            });

            //券点流水详情事件
            handlerList.Add(MessageType.Event, ReceiveEventType.card_pay_order, (data) =>
            {
                PassReply(data);
                CardPayOrderEvent?.Invoke(data.ConvertBodyTo <CardPayOrderEventArgs>(), Replier.Create(data));
            });

            #endregion
        }
Ejemplo n.º 4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title =
                new UILabel(new CGRect(60, 0, NavigationController.Toolbar.Frame.Width,
                                       NavigationController.Toolbar.Frame.Height))
            {
                TextColor       = Style.Header.TextColor,
                BackgroundColor = UIColor.Clear
            };

            GoBackButton = new UIButton(new CGRect(0, 0, 60, NavigationController.Toolbar.Frame.Height))
            {
                TintColor = Style.Header.TextColor,
                Hidden    = true
            };

            GoBackButton.TouchDown += OnClickGoBack;
            GoBackButton.SetImage(UIImage.FromBundle("back").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);

            GalleryView = new UIView()
            {
                Hidden = true
            };

            ChoosePicture       = UIButton.FromType(UIButtonType.RoundedRect);
            ChoosePicture.Frame = new CGRect(0, 0, View.Frame.Width / 2, 40);

            ChoosePicture.TintColor       = Style.Header.TextColor;
            ChoosePicture.BackgroundColor = UIColor.LightGray;

            ChoosePicture.SetTitle(Translator.GetText("choose_picture"), UIControlState.Normal);

            ChoosePicture.TouchDown += OnClickChoosePicture;

            TakePicture       = UIButton.FromType(UIButtonType.RoundedRect);
            TakePicture.Frame = new CGRect(View.Frame.Width / 2, 0, View.Frame.Width / 2, 40);

            TakePicture.TintColor       = Style.Header.TextColor;
            TakePicture.BackgroundColor = UIColor.LightGray;

            TakePicture.SetTitle(Translator.GetText("take_picture"), UIControlState.Normal);

            TakePicture.TouchDown += OnClickTakePicture;

            GalleryView.AddSubviews(ChoosePicture, TakePicture);

            NavigationController.NavigationBar.AddSubviews(GoBackButton);

            NavigationController.NavigationBar.TintColor    = Style.Header.TextColor;
            NavigationController.NavigationBar.BarTintColor = Style.Header.BackgroundColor;

            NavigationController.NavigationBar.AddSubviews(Title);

            var scrollView = new UIScrollView(View.Frame)
            {
                ShowsHorizontalScrollIndicator = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight
            };

            WebView = new UIWebView
            {
                ScalesPageToFit = true
            };

            scrollView.AddSubviews(WebView, GalleryView);

            Add(scrollView);

            View.AddConstraints(
                scrollView.AtLeftOf(View),
                scrollView.AtTopOf(View),
                scrollView.WithSameWidth(View),
                scrollView.WithSameHeight(View),

                WebView.AtLeftOf(scrollView),
                WebView.AtTopOf(scrollView),
                WebView.WithSameWidth(scrollView),
                WebView.WithSameHeight(scrollView),

                GalleryView.AtLeftOf(scrollView),
                GalleryView.AtTopOf(scrollView),
                GalleryView.WithSameWidth(scrollView),
                GalleryView.WithSameHeight(scrollView),

                TakePicture.AtLeftOf(GalleryView),
                TakePicture.AtTopOf(GalleryView),

                ChoosePicture.AtRightOf(GalleryView),
                ChoosePicture.AtTopOf(GalleryView)
                );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            MenuClickEvent.AddListener(this);

            var menuItem = MenuViewModel.MenuItems.First();

            OnMenuItemClick(menuItem.menu_title, menuItem.url, 0);

            _spinner = new Spinner(View);

            WebView.Delegate = new WebViewDelegate(_spinner, this);
        }
Ejemplo n.º 5
0
        public static List <PendingStatisticsEvent> ConvertFromPendingEvents(List <object> pendingEvents)
        {
            List <PendingStatisticsEvent> pendingStatisticsEventList = new List <PendingStatisticsEvent>();

            foreach (object pendingEvent in pendingEvents)
            {
                PendingStatisticsEvent pendingStatisticsEvent = new PendingStatisticsEvent();
                if (pendingEvent is OpenUserEvent)
                {
                    pendingStatisticsEvent.event_name  = "OpenUserEvent";
                    pendingStatisticsEvent.user_id     = (pendingEvent as OpenUserEvent).UserId;
                    pendingStatisticsEvent.user_source = (pendingEvent as OpenUserEvent).Source;
                }
                else if (pendingEvent is OpenGroupEvent)
                {
                    pendingStatisticsEvent.event_name   = "OpenGroupEvent";
                    pendingStatisticsEvent.group_id     = (pendingEvent as OpenGroupEvent).GroupId;
                    pendingStatisticsEvent.group_source = (pendingEvent as OpenGroupEvent).Source;
                }
                else if (pendingEvent is ViewPostEvent)
                {
                    ViewPostEvent viewPostEvent = pendingEvent as ViewPostEvent;
                    pendingStatisticsEvent.event_name    = "ViewPostEvent";
                    pendingStatisticsEvent.post_id       = viewPostEvent.PostId;
                    pendingStatisticsEvent.repost_ids    = viewPostEvent.CopyPostIds;
                    pendingStatisticsEvent.item_position = viewPostEvent.Position;
                    pendingStatisticsEvent.FeedSource    = viewPostEvent.FeedSource;
                    pendingStatisticsEvent.Source        = viewPostEvent.Source;
                    pendingStatisticsEvent.ItemType      = viewPostEvent.ItemType;
                }
                else if (pendingEvent is ViewBlockEvent)
                {
                    ViewBlockEvent viewBlockEvent = pendingEvent as ViewBlockEvent;
                    pendingStatisticsEvent.event_name    = "ViewBlockEvent";
                    pendingStatisticsEvent.item_type     = viewBlockEvent.ItemType;
                    pendingStatisticsEvent.item_position = viewBlockEvent.Position;
                }
                else if (pendingEvent is OpenPostEvent)
                {
                    pendingStatisticsEvent.event_name = "OpenPostEvent";
                    OpenPostEvent openPostEvent = pendingEvent as OpenPostEvent;
                    pendingStatisticsEvent.post_id    = openPostEvent.PostId;
                    pendingStatisticsEvent.repost_ids = openPostEvent.CopyPostIds;
                }
                else if (pendingEvent is OpenVideoEvent)
                {
                    pendingStatisticsEvent.event_name = "OpenVideoEvent";
                    OpenVideoEvent openVideoEvent = pendingEvent as OpenVideoEvent;
                    pendingStatisticsEvent.video_id      = openVideoEvent.id;
                    pendingStatisticsEvent.source        = openVideoEvent.Source;
                    pendingStatisticsEvent.video_context = openVideoEvent.context;
                }
                else if (pendingEvent is VideoPlayEvent)
                {
                    pendingStatisticsEvent.event_name = "VideoPlayEvent";
                    VideoPlayEvent videoPlayEvent = pendingEvent as VideoPlayEvent;
                    pendingStatisticsEvent.video_id      = videoPlayEvent.id;
                    pendingStatisticsEvent.position      = videoPlayEvent.Position;
                    pendingStatisticsEvent.source        = videoPlayEvent.Source;
                    pendingStatisticsEvent.quality       = videoPlayEvent.quality;
                    pendingStatisticsEvent.video_context = videoPlayEvent.Context;
                }
                else if (pendingEvent is AudioPlayEvent)
                {
                    pendingStatisticsEvent.event_name = "AudioPlayEvent";
                    pendingStatisticsEvent.audio_id   = (pendingEvent as AudioPlayEvent).OwnerAndAudioId;
                    pendingStatisticsEvent.source     = (pendingEvent as AudioPlayEvent).Source;
                }
                else if (pendingEvent is MenuClickEvent)
                {
                    pendingStatisticsEvent.event_name = "MenuClickEvent";
                    MenuClickEvent menuClickEvent = pendingEvent as MenuClickEvent;
                    pendingStatisticsEvent.item = menuClickEvent.item;
                }
                else if (pendingEvent is TransitionFromPostEvent)
                {
                    pendingStatisticsEvent.event_name = "TransitionFromPostEvent";
                    TransitionFromPostEvent transitionFromPostEvent = pendingEvent as TransitionFromPostEvent;
                    pendingStatisticsEvent.post_id   = transitionFromPostEvent.post_id;
                    pendingStatisticsEvent.parent_id = transitionFromPostEvent.parent_id;
                }
                else if (pendingEvent is SubscriptionFromPostEvent)
                {
                    pendingStatisticsEvent.event_name = "SubscriptionFromPostEvent";
                    SubscriptionFromPostEvent subscriptionFromPostEvent = pendingEvent as SubscriptionFromPostEvent;
                    pendingStatisticsEvent.post_id = subscriptionFromPostEvent.post_id;
                }
                else if (pendingEvent is HyperlinkClickedEvent)
                {
                    pendingStatisticsEvent.event_name = "PostLinkClickEvent";
                    HyperlinkClickedEvent hyperlinkClickedEvent = pendingEvent as HyperlinkClickedEvent;
                    pendingStatisticsEvent.post_id = hyperlinkClickedEvent.HyperlinkOwnerId;
                }
                else if (pendingEvent is OpenGamesEvent)
                {
                    pendingStatisticsEvent.event_name = "OpenGamesEvent";
                    OpenGamesEvent openGamesEvent = pendingEvent as OpenGamesEvent;
                    pendingStatisticsEvent.visit_source = openGamesEvent.visit_source;
                }
                else if (pendingEvent is GamesActionEvent)
                {
                    pendingStatisticsEvent.event_name = "GamesActionEvent";
                    GamesActionEvent gamesActionEvent = pendingEvent as GamesActionEvent;
                    pendingStatisticsEvent.game_id      = gamesActionEvent.game_id;
                    pendingStatisticsEvent.action_type  = gamesActionEvent.action_type;
                    pendingStatisticsEvent.request_name = gamesActionEvent.request_name;
                    pendingStatisticsEvent.click_source = gamesActionEvent.click_source;
                    pendingStatisticsEvent.visit_source = gamesActionEvent.visit_source;
                }
                else if (pendingEvent is AdImpressionEvent)
                {
                    pendingStatisticsEvent.event_name         = "AdImpressionEvent";
                    pendingStatisticsEvent.ad_data_impression = (pendingEvent as AdImpressionEvent).AdDataImpression;
                }
                else if (pendingEvent is MarketItemActionEvent)
                {
                    pendingStatisticsEvent.event_name = "MarketItemActionEvent";
                    MarketItemActionEvent marketItemActionEvent = pendingEvent as MarketItemActionEvent;
                    pendingStatisticsEvent.market_item_source = marketItemActionEvent.source;
                    pendingStatisticsEvent.market_item_id     = marketItemActionEvent.itemId;
                }
                else if (pendingEvent is ProfileBlockClickEvent)
                {
                    pendingStatisticsEvent.event_name = "ProfileBlockClickEvent";
                    ProfileBlockClickEvent profileBlockClickEvent = pendingEvent as ProfileBlockClickEvent;
                    pendingStatisticsEvent.user_id            = profileBlockClickEvent.UserId;
                    pendingStatisticsEvent.profile_block_type = profileBlockClickEvent.BlockType;
                }
                else if (pendingEvent is DiscoverActionEvent)
                {
                    pendingStatisticsEvent.event_name = "DiscoverActionEvent";
                    DiscoverActionEvent discoverActionEvent = pendingEvent as DiscoverActionEvent;
                    pendingStatisticsEvent.discover_action_type  = discoverActionEvent.ActionType;
                    pendingStatisticsEvent.discover_action_param = discoverActionEvent.ActionParam;
                }
                else if (pendingEvent is MarketContactEvent)
                {
                    pendingStatisticsEvent.event_name = "MarketContactEvent";
                    MarketContactEvent marketContactEvent = pendingEvent as MarketContactEvent;
                    pendingStatisticsEvent.market_item_id      = marketContactEvent.ItemId;
                    pendingStatisticsEvent.MarketContactAction = marketContactEvent.Action;
                }
                else if (pendingEvent is BalanceTopupEvent)
                {
                    pendingStatisticsEvent.event_name = "BalanceTopupEvent";
                    BalanceTopupEvent balanceTopupEvent = pendingEvent as BalanceTopupEvent;
                    pendingStatisticsEvent.BalanceTopupSource = balanceTopupEvent.Source;
                    pendingStatisticsEvent.BalanceTopupAction = balanceTopupEvent.Action;
                }
                else if (pendingEvent is StickersPurchaseFunnelEvent)
                {
                    pendingStatisticsEvent.event_name = "StickersPurchaseFunnelEvent";
                    StickersPurchaseFunnelEvent purchaseFunnelEvent = pendingEvent as StickersPurchaseFunnelEvent;
                    pendingStatisticsEvent.StickersPurchaseFunnelSource = purchaseFunnelEvent.Source;
                    pendingStatisticsEvent.StickersPurchaseFunnelAction = purchaseFunnelEvent.Action;
                }
                else if (pendingEvent is GifPlayEvent)
                {
                    pendingStatisticsEvent.event_name = "GifPlayEvent";
                    GifPlayEvent gifPlayEvent = pendingEvent as GifPlayEvent;
                    pendingStatisticsEvent.GifPlayGifId     = gifPlayEvent.GifId;
                    pendingStatisticsEvent.GifPlayStartType = gifPlayEvent.StartType;
                    pendingStatisticsEvent.source           = gifPlayEvent.Source;
                }
                else if (pendingEvent is PostActionEvent)
                {
                    pendingStatisticsEvent.event_name = "PostActionEvent";
                    PostActionEvent postActionEvent = pendingEvent as PostActionEvent;
                    pendingStatisticsEvent.PostId     = postActionEvent.PostId;
                    pendingStatisticsEvent.ActionType = postActionEvent.ActionType;
                }
                else if (pendingEvent is AudioMessagePlayEvent)
                {
                    pendingStatisticsEvent.event_name = "AudioMessagePlayEvent";
                    AudioMessagePlayEvent messagePlayEvent = pendingEvent as AudioMessagePlayEvent;
                    pendingStatisticsEvent.AudioMessageId = messagePlayEvent.AudioMessageId;
                }
                else if (pendingEvent is GiftsPurchaseStepsEvent)
                {
                    pendingStatisticsEvent.event_name = "GiftsPurchaseStepsEvent";
                    GiftsPurchaseStepsEvent purchaseStepsEvent = pendingEvent as GiftsPurchaseStepsEvent;
                    pendingStatisticsEvent.GiftPurchaseStepsSource = purchaseStepsEvent.Source;
                    pendingStatisticsEvent.GiftPurchaseStepsAction = purchaseStepsEvent.Action;
                }
                else if (pendingEvent is PostInteractionEvent)
                {
                    pendingStatisticsEvent.event_name = "PostInteractionEvent";
                    PostInteractionEvent interactionEvent = pendingEvent as PostInteractionEvent;
                    pendingStatisticsEvent.PostId     = interactionEvent.PostId;
                    pendingStatisticsEvent.PostAction = interactionEvent.Action;
                    pendingStatisticsEvent.Link       = interactionEvent.Link;
                }
                if (pendingStatisticsEvent != null)
                {
                    pendingStatisticsEventList.Add(pendingStatisticsEvent);
                }
            }
            return(pendingStatisticsEventList);
        }