Exemplo n.º 1
0
        private void UserPopChannelRequest(BotCommandEventArgs obj)
        {
            //No parameters, for now
            try
            {
                Models.StoredChannels        firstStoredChannel;
                List <Models.StoredChannels> allChannelsUnderSameSubscriber;

                using (var db = new CoreContext())
                {
                    allChannelsUnderSameSubscriber = db.StoredChannels.Where(x => x.SubscriberId == this.Subscriber.SubscriberId).ToList();
                    firstStoredChannel             = allChannelsUnderSameSubscriber.First(x => x.ChannelId == 52);
                }

                if (firstStoredChannel.ParentChannelId != 0)
                {
                    var parent = ServerQueryConnection.QueryRunner.GetChannelInfo((uint)firstStoredChannel.ParentChannelId);

                    if (parent.IsErroneous)
                    {
                        throw new Exception("Parent channel no longer exists");
                    }
                }

                Props.ChannelWithSubChannelsPackager ChannelWithSubChannels = new Props.ChannelWithSubChannelsPackager(this.Subscriber.SubscriberId, this.Subscriber.SubscriberUniqueId);
                ChannelWithSubChannels.Pop(allChannelsUnderSameSubscriber, firstStoredChannel, PopChannel);

                //PopChannel((int)firstStoredChannel.ChannelId);
            }
            catch (Exception ex)
            {
                logger.Warn(ex, "Failed to pop channel by user {1} ({2})", obj.MessageInfo.InvokerClientId, obj.MessageInfo.InvokerNickname);
            }
        }
Exemplo n.º 2
0
        public void StoreChannel(int ChannelId)
        {
            var ThisChannelInfo = ServerQueryConnection.QueryRunner.GetChannelInfo((uint)ChannelId);

            Models.StoredChannels storedChannel = new Models.StoredChannels(this.Subscriber.SubscriberId, this.Subscriber.SubscriberUniqueId);

            List <ChannelListEntry> ChannelList      = ServerQueryConnection.QueryRunner.GetChannelList(true).ToList();
            ChannelListEntry        ThisChannelEntry = ChannelList.SingleOrDefault(x => x.ChannelId == ChannelId);

            Props.ChannelWithSubChannelsPackager ChannelWithSubChannels = new Props.ChannelWithSubChannelsPackager(this.Subscriber.SubscriberId, this.Subscriber.SubscriberUniqueId);
            ChannelWithSubChannels.Store(ServerQueryConnection.QueryRunner, ChannelList, ThisChannelInfo, ThisChannelEntry, StoreSingleChannel);
        }