Ejemplo n.º 1
0
        HttpResponseMessage AddFeed(string name, RestMSFeed feed)
        {
            var addFeedCommand = new AddFeedCommand(
                domainName: name,
                name: feed.Name,
                type: feed.Type,
                title: feed.Title);

            commandProcessor.Send(addFeedCommand);

            return(BuildDomainItemCreatedReponse(name));
        }
Ejemplo n.º 2
0
        private void CreateFeed(SyndicationFeed syndicationFeed, string url)
        {
            var feed = new Feed
            {
                PartitionId = 0,
                Title       = syndicationFeed.Title != null ? syndicationFeed.Title.Text : "Untitled feed",
                Description = syndicationFeed.Description != null ? syndicationFeed.Description.Text : "No description",
                ImageUrl    = syndicationFeed.ImageUrl != null?syndicationFeed.ImageUrl.ToString() : null,
                                  LastCollected = DateTime.MinValue,
                                  Url           = url,
                                  Created       = DateTime.Now
            };
            var command = new AddFeedCommand(feed);

            _geekStreamDb.Execute(command);
        }
        public async Task <IActionResult> AddFeed([FromBody] AddFeedCommand addFeedCommand, CancellationToken cancellationToken)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            addFeedCommand.UserId = userId;
            var result = await _mediator.Send(addFeedCommand, cancellationToken);

            return(new ContentResult
            {
                StatusCode = (int)HttpStatusCode.Created,
                Content = new JObject
                {
                    { "id", result }
                }.ToString(),
                ContentType = "application/json"
            });
        }
Ejemplo n.º 4
0
        public static void Configure(CommandLineApplication app, CommandLineOptions options)
        {
            app.Command("test", c => TestCommand.Configure(c, options));
            app.Command("serverInfo", c => ApplicationInfoCommand.Configure(c, options));
            app.Command("login", c => LoginCommand.Configure(c, options));
            app.Command("changePassword", c => ChangePasswordCommand.Configure(c, options));
            app.Command("displayConfig", c => DisplayConfigurationCommand.Configure(c, options));
            app.Command("changeEndpoint", c => ChangeEndpointCommand.Configure(c, options));
            app.Command("getActiveJobs", c => GetJobsCommand.Configure(c, options));
            app.Command("getJobHistory", c => GetJobHistoryCommand.Configure(c, options));
            app.Command("addJob", c => AddJobCommand.Configure(c, options));
            app.Command("addFeed", c => AddFeedCommand.Configure(c, options));
            app.Command("testFeed", c => TestFeedCommand.Configure(c, options));
            app.Command("importFeeds", c => ImportFeedsCommand.Configure(c, options));
            app.Command("updateWeather", c => UpdateForecastsCommand.Configure(c, options));

            app.OnExecute(() =>
            {
                options.Command = new RootCommand(app);
                return(0);
            });
        }
Ejemplo n.º 5
0
 private void CreateFeed(SyndicationFeed syndicationFeed, string url)
 {
     var feed = new Feed
                    {
                        PartitionId = 0,
                        Title = syndicationFeed.Title != null ? syndicationFeed.Title.Text : "Untitled feed",
                        Description = syndicationFeed.Description != null ? syndicationFeed.Description.Text : "No description",
                        ImageUrl = syndicationFeed.ImageUrl != null ? syndicationFeed.ImageUrl.ToString() : null,
                        LastCollected = DateTime.MinValue,
                        Url = url,
                        Created = DateTime.Now
                    };
     var command = new AddFeedCommand(feed);
     _geekStreamDb.Execute(command);
 }
Ejemplo n.º 6
0
        public FeedGroupPageViewModel(HohoemaApp hohoemaApp, PageManager pageManager, Views.Service.ContentSelectDialogService contentSelectDialogService)
            : base(hohoemaApp, pageManager)
        {
            ContentSelectDialogService = contentSelectDialogService;

            IsDeleted = new ReactiveProperty <bool>();

            FeedGroupName     = new ReactiveProperty <string>();
            MylistFeedSources = new ObservableCollection <FeedItemSourceListItem>();
            TagFeedSources    = new ObservableCollection <FeedItemSourceListItem>();
            UserFeedSources   = new ObservableCollection <FeedItemSourceListItem>();

            HasMylistFeedSource = MylistFeedSources.ObserveProperty(x => x.Count)
                                  .Select(x => x > 0)
                                  .ToReadOnlyReactiveProperty();
            HasTagFeedSource = TagFeedSources.ObserveProperty(x => x.Count)
                               .Select(x => x > 0)
                               .ToReadOnlyReactiveProperty();
            HasUserFeedSource = UserFeedSources.ObserveProperty(x => x.Count)
                                .Select(x => x > 0)
                                .ToReadOnlyReactiveProperty();


            MylistFavItems = new ObservableCollection <FollowItemInfo>();
            TagFavItems    = new ObservableCollection <FollowItemInfo>();
            UserFavItems   = new ObservableCollection <FollowItemInfo>();

            SelectFromFavItems = new ReactiveProperty <bool>(true);
            SelectedFavInfo    = new ReactiveProperty <FollowItemInfo>();

            FavItemType        = new ReactiveProperty <FollowItemType>();
            FeedSourceId       = new ReactiveProperty <string>();
            FeedSourceItemName = new ReactiveProperty <string>();
            ExistFeedSource    = new ReactiveProperty <bool>();
            IsPublicFeedSource = new ReactiveProperty <bool>();

            CanUseFeedSource = Observable.CombineLatest(
                ExistFeedSource,
                IsPublicFeedSource
                )
                               .Select(x => x.All(y => y))
                               .ToReactiveProperty();

            FavItemType.Subscribe(x =>
            {
                FeedSourceId.Value    = "";
                ExistFeedSource.Value = false;

                FeedSourceItemName.Value = "";


                // お気に入りアイテムがある場合は、「お気に入りから選択」をデフォルトに
                switch (x)
                {
                case FollowItemType.Tag:
                    SelectFromFavItems.Value = TagFavItems.Count > 0;
                    break;

                case FollowItemType.Mylist:
                    SelectFromFavItems.Value = MylistFavItems.Count > 0;
                    break;

                case FollowItemType.User:
                    SelectFromFavItems.Value = UserFavItems.Count > 0;
                    break;

                default:
                    break;
                }
            });

            FeedSourceId.ToUnit()
            .Subscribe(_ =>
            {
                ExistFeedSource.Value    = false;
                FeedSourceItemName.Value = "";
            });

            Observable.Merge(
                SelectFromFavItems.ToUnit(),

                SelectedFavInfo.ToUnit(),

                FavItemType.ToUnit(),
                FeedSourceId.ToUnit().Throttle(TimeSpan.FromSeconds(1))
                )
            .Subscribe(async x =>
            {
                if (SelectFromFavItems.Value)
                {
                    ExistFeedSource.Value    = SelectedFavInfo.Value != null;
                    IsPublicFeedSource.Value = true;
                    FeedSourceItemName.Value = "";
                    return;
                }

                ExistFeedSource.Value = false;

                if (FavItemType.Value == FollowItemType.Tag)
                {
                    ExistFeedSource.Value    = !string.IsNullOrWhiteSpace(FeedSourceId.Value);
                    IsPublicFeedSource.Value = true;
                    FeedSourceItemName.Value = FeedSourceId.Value;
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(FeedSourceId.Value))
                    {
                        ExistFeedSource.Value = false;
                    }
                    else
                    {
                        if (FavItemType.Value == FollowItemType.Mylist)
                        {
                            try
                            {
                                var mylistRes = await HohoemaApp.ContentFinder.GetMylistGroupDetail(FeedSourceId.Value);
                                var mylist    = mylistRes?.MylistGroup;

                                if (mylist != null)
                                {
                                    ExistFeedSource.Value    = true;
                                    IsPublicFeedSource.Value = mylist.IsPublic;
                                    FeedSourceItemName.Value = Mntone.Nico2.StringExtention.DecodeUTF8(mylist.Name);
                                }
                            }
                            catch
                            {
                                ExistFeedSource.Value = false;
                            }
                        }
                        else if (FavItemType.Value == FollowItemType.User)
                        {
                            try
                            {
                                var user = await HohoemaApp.ContentFinder.GetUserDetail(FeedSourceId.Value);
                                if (user != null)
                                {
                                    ExistFeedSource.Value    = true;
                                    IsPublicFeedSource.Value = !user.IsOwnerVideoPrivate;
                                    FeedSourceItemName.Value = user.Nickname;
                                }
                            }
                            catch
                            {
                                ExistFeedSource.Value = false;
                            }
                        }

                        if (!ExistFeedSource.Value)
                        {
                            IsPublicFeedSource.Value = false;
                            FeedSourceItemName.Value = "";
                        }
                    }
                }
            });

            AddFeedCommand =
                Observable.CombineLatest(
                    ExistFeedSource,
                    IsPublicFeedSource
                    )
                .Select(x => x.All(y => y == true))
                .ToReactiveCommand();

            AddFeedCommand.Subscribe(_ =>
            {
                string name = "";
                string id   = "";

                if (SelectFromFavItems.Value)
                {
                    var favInfo = SelectedFavInfo.Value;
                    name        = favInfo.Name;
                    id          = favInfo.Id;

                    if (favInfo.FollowItemType != FavItemType.Value)
                    {
                        throw new Exception();
                    }
                }
                else
                {
                    // idからMylistGroupを引く
                    // 公開されていない場合にはエラー
                    id   = FeedSourceId.Value;
                    name = FeedSourceItemName.Value;

                    FeedSourceItemName.Value = "";
                    FeedSourceId.Value       = "";
                }

                var favManager  = HohoemaApp.FollowManager;
                var feedManager = HohoemaApp.FeedManager;
                IFeedSource feedSource;
                switch (FavItemType.Value)
                {
                case FollowItemType.Tag:

                    feedSource = FeedGroup.AddTagFeedSource(id);
                    if (feedSource != null)
                    {
                        var favInfo = favManager.Tag.FollowInfoItems.SingleOrDefault(x => x.Id == id);
                        if (favInfo != null)
                        {
                            TagFavItems.Remove(favInfo);
                        }

                        TagFeedSources.Add(new FeedItemSourceListItem(feedSource, this));
                    }

                    break;

                case FollowItemType.Mylist:

                    feedSource = FeedGroup.AddMylistFeedSource(name, id);
                    if (feedSource != null)
                    {
                        var favInfo = favManager.Mylist.FollowInfoItems.SingleOrDefault(x => x.Id == id);
                        if (favInfo != null)
                        {
                            MylistFavItems.Remove(favInfo);
                        }

                        MylistFeedSources.Add(new FeedItemSourceListItem(feedSource, this));
                    }

                    break;

                case FollowItemType.User:

                    feedSource = FeedGroup.AddUserFeedSource(name, id);
                    if (feedSource != null)
                    {
                        var favInfo = favManager.User.FollowInfoItems.SingleOrDefault(x => x.Id == id);
                        if (favInfo != null)
                        {
                            UserFavItems.Remove(favInfo);
                        }

                        UserFeedSources.Add(new FeedItemSourceListItem(feedSource, this));
                    }

                    break;

                default:
                    break;
                }

                HohoemaApp.FeedManager.SaveOne(FeedGroup);
            });

            RenameApplyCommand = FeedGroupName
                                 .Where(x => HohoemaApp.FeedManager != null && x != null)
                                 .Select(x => HohoemaApp.FeedManager.CanAddLabel(x))
                                 .ToReactiveCommand();

            RenameApplyCommand.Subscribe(async _ =>
            {
                if (await FeedGroup.Rename(FeedGroupName.Value))
                {
                    UpdateTitle(FeedGroup.Label);
                }

                FeedGroupName.ForceNotify();
            });
        }