Esempio n. 1
0
 public Channel(ChannelCategory category, string name)
 {
     Category = category;
     Name = name;
     PartitionKey = SlugService.ToSlug(Category.ToString());
     RowKey = SlugService.ToSlug(Name);
 }
Esempio n. 2
0
        public async Task HandleArchiveCommand(ITextChannel channel, [Remainder] string category)
        {
            if (string.IsNullOrEmpty(category))
            {
                return;
            }

            category = new CultureInfo("en-GB", false).TextInfo.ToTitleCase(category);
            string env = HARDCODED_ARCHIVE_PATH;

            Guild g = new Guild(new Snowflake(Context.Guild.Id), Context.Guild.Name, Context.Guild.IconUrl);
            var   discordCategory = channel.CategoryId.HasValue ? await channel.GetCategoryAsync() : null;

            ChannelCategory cc = new ChannelCategory(new Snowflake(channel.CategoryId.Value), discordCategory.Name, discordCategory.Position);
            Channel         c  = new Channel(new Snowflake(channel.Id), ChannelKind.GuildTextChat, g.Id, cc, channel.Name, channel.Position, channel.Topic);

            ExportRequest req = new ExportRequest(g, c, env + $"/{category}/Light/{channel.Name}.html", ExportFormat.HtmlLight,
                                                  null, null, PartitionLimit.Null, MessageFilter.Null, true, true, "yyyy-MM-dd hh:mm:ss");

            ExportRequest req2 = new ExportRequest(g, c, env + $"/{category}/Dark/{channel.Name}.html", ExportFormat.HtmlDark,
                                                   null, null, PartitionLimit.Null, MessageFilter.Null, true, true, "yyyy-MM-dd hh:mm:ss");

            bool   isLight = true;
            string path    = env + $"/{category}/{(isLight ? "Light" : "Dark")}/{channel.Name}.html_Files/";


            var message = await Context.Channel.SendMessageAsync("", false, Embeds.Archiving(Context.User, channel, "Starting")).ConfigureAwait(false);

            //Timer _timer = new Timer(async _ => await OnTick(), null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));


            try
            {
                await message.ModifyAsync(x => x.Embed = Embeds.Archiving(Context.User, channel, "Exporting Light Mode")).ConfigureAwait(false);

                await _exporter.ExportChannelAsync(req).ConfigureAwait(false);

                await message.ModifyAsync(x => x.Embed = Embeds.Archiving(Context.User, channel, "Exporting Dark Mode")).ConfigureAwait(false);

                isLight = false;
                await _exporter.ExportChannelAsync(req2).ConfigureAwait(false);

                await message.ModifyAsync(x => x.Embed = Embeds.Archiving(Context.User, channel, "Done"));
            }
            catch (Exception ex)
            {
                await message.ModifyAsync(x =>
                {
                    x.Content = $"Error occured: {ex}";
                    x.Embed   = null;
                });
            }

            //async Task OnTick()
            //{
            //    await message.ModifyAsync(x => x.Content = $"Exported: {Directory.GetFiles(path, "*.*").Length} files.");
            //}
        }
        public override async void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            base.OnNavigatedTo(e, viewModelState);
            ChannelCategory param = ChannelCategory.Hepsi;

            if (e.Parameter != null) // Navigated with channel category
            {
                param = (ChannelCategory)e.Parameter;
            }

            CurrentChannels = await OperateAsyncOperation(_channelRepository.GetChannels(param), "Kanallar yükleniyor");
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the channelcategory
        /// </summary>
        /// <param name="channelcategory">ChannelCategory</param>
        public virtual void UpdateChannelCategory(ChannelCategory channelcategory)
        {
            if (channelcategory == null)
            {
                throw new ArgumentNullException("channelcategory");
            }

            _channelcategoryRepository.Update(channelcategory);

            //event notification
            _eventPublisher.EntityUpdated(channelcategory);
        }
Esempio n. 5
0
        public void InsertChannelCategory(ChannelCategory channelcategory)
        {
            if (channelcategory == null)
            {
                throw new ArgumentNullException("channelcategory");
            }

            _channelcategoryRepository.Insert(channelcategory);

            //event notification
            _eventPublisher.EntityInserted(channelcategory);
        }
Esempio n. 6
0
        public async Task <ObservableCollection <ChannelModelView> > GetChannels(ChannelCategory category = ChannelCategory.Hepsi)
        {
            var _ret         = new ObservableCollection <ChannelModelView>();
            var mainChannels = await _channelService.GetChannels();

            if (category != ChannelCategory.Hepsi)
            {
                mainChannels = mainChannels.Where(a => a.Category == category).ToList();
            }

            var streamInformations = await _channelService.GetStreamInformations();

            foreach (var channel in mainChannels)
            {
                var model = new ChannelModelView(channel);
                try
                {
                    var channelImageFile = await ConfigurationContext.LocalFolder.GetItemAsync(string.Format("Images\\{0}.png", model.Channel.Id));

                    if (channelImageFile != null)
                    {
                        model.HasChannelImage = true;
                    }
                    else
                    {
                        model.HasChannelImage = false;
                    }
                }
                catch (Exception)
                {
                    model.HasChannelImage = false;
                }

                model.CurrentStream = await GetExactCurrentStreamByChannel(model.Channel.Id);

                if (ConfigurationContext.MainSettings.FavoritedChannelIds.Contains(model.Channel.Id))
                {
                    model.IsFavorited = true;
                }
                else
                {
                    model.IsFavorited = false;
                }

                _ret.Add(model);
            }

            return(_ret);
        }
Esempio n. 7
0
        public void DeleteChannelCategory(ChannelCategory channelcategory)
        {
            if (channelcategory == null)
            {
                throw new ArgumentNullException("channelcategory");
            }

            //channelcategory.IsDeleted = true;
            //UpdateChannelCategory(channelcategory);

            _channelcategoryRepository.Delete(channelcategory);

            //event notification
            _eventPublisher.EntityDeleted(channelcategory);
        }
        public IActionResult Put(int channelId, ChannelCategoryForAddRangeDto channelCategoriesDto)
        {
            ChannelCategory[] channelCategories = new ChannelCategory[channelCategoriesDto.CategoryIds.Length];

            for (int i = 0; i < channelCategoriesDto.CategoryIds.Length; i++)
            {
                this.RemoveCacheByContains(channelCategories[i] + "/category-channels");
                channelCategories[i] = new ChannelCategory {
                    ChannelId = channelId, CategoryId = channelCategoriesDto.CategoryIds[i]
                };
            }

            IResult result = _channelCategoryService.AddRange(channelCategories);

            if (result.IsSuccessful)
            {
                this.RemoveCacheByContains(channelId + "/channel-categories");
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
Esempio n. 9
0
 public IResult Delete(ChannelCategory channelCategory)
 {
     _channelCategoryDal.Delete(_channelCategoryDal.Get(category => category.CategoryId == channelCategory.CategoryId && category.ChannelId == channelCategory.ChannelId));
     return(new SuccessResult());
 }
Esempio n. 10
0
 public IDataResult <ChannelCategory> Add(ChannelCategory channelCategory)
 {
     _channelCategoryDal.Add(channelCategory);
     return(new SuccessDataResult <ChannelCategory>(channelCategory));
 }
Esempio n. 11
0
 public ChannelCategory GetChannelCategory(ulong categoryId)
 {
     return(ChannelCategory.Get(categoryId, this));
 }
Esempio n. 12
0
 public async Task <ChannelCategory> GetChannelCategoryAsync(ulong categoryId)
 {
     return(await ChannelCategory.GetAsync(categoryId, this));
 }
Esempio n. 13
0
 public static void PopulateInstance(IChannel obj, ChannelJson json, [CanBeNull] object state)
 {
     Switch(json, state, (json2, state2) => TextChannel.Populate((TextChannel)obj, json2, state2), (json2, state2) => TextChannel.Populate((TextChannel)obj, json2, state2), (json2, state2) => ChannelCategory.Populate((ChannelCategory)obj, json2, state2));
 }