예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        String _storId = Request.QueryString["storId"];

        if (!String.IsNullOrEmpty(_storId))
        {
            Stories _st = new Stories(ConfigurationManager.ConnectionStrings["TopRockConnection"].ConnectionString);
            _st.LitePopulate(_storId);

            if (!String.IsNullOrEmpty(CommonUtility.NullSafeString(_st.YouTubeLink, "").Trim()))
            {
                Literal _li = new Literal();
                _li.Text = _st.YouTubeLink;
                secureHolder.Controls.Add(_li);
            }
            else
            {
                if (!String.IsNullOrEmpty(CommonUtility.NullSafeString(_st.ImgType, "").Trim()))
                {
                    Image _img = new Image();
                    _img.ImageUrl = String.Format(ConfigurationManager.AppSettings["StoriesImagesPath"], _st.ID.ToString(), _st.ImgType);
                    secureHolder.Controls.Add(_img);
                }
            }

        }
    }
예제 #2
0
        public Task <IEnumerable <string> > GetCategories()
        {
            var cats = Stories
                       .Select(c => c.Categories.Split(','))
                       .ToList();

            var result = new List <string>();

            foreach (var s in cats)
            {
                result.AddRange(s);
            }

            return(Task.FromResult(result.Where(s => !string.IsNullOrWhiteSpace(s)).OrderBy(s => s).Distinct()));
        }
예제 #3
0
 public RundownViewModel(Rundown model)
 {
     Id        = model.Id;
     Title     = model.Title;
     StartTime = model.StartTime;
     EndTime   = model.EndTime;
     ShowId    = model.ShowId;
     Show      = model.Show;
     EndTime   = model.EndTime;
     if (model.Stories is null)
     {
         model.Stories = new List <Story>();
     }
     model.Stories.ForEach(x => Stories.Add(new StoryViewModel(x)));
     Active = model.Active;
 }
예제 #4
0
 public ActionResult Add(Stories post)
 {
     if (!ModelState.IsValid)
     {
         return(View(post));
     }
     storyPage.Title = post.Title;
     storyPage.Story = post.Story;
     storyPage.Email = post.Email;
     storyPage.Add();
     if (IsError())
     {
         return(errorActionRes);
     }
     return(Redirect("/Story/Number/" + storyPage.Id));
 }
        public void FindById_Should_Return_Correct_Subscribtion()
        {
            Stories.Add(new Story {
                Id = Guid.NewGuid()
            });
            Users.Add(new User {
                Id = Guid.NewGuid()
            });

            Stories[0].SubscribeComment(Users[0]);

            var storyId = Stories[0].Id;
            var userId  = Users[0].Id;

            Assert.NotNull(_commentSubscribtionRepository.FindById(storyId, userId));
        }
        public void CountByTag_Should_Return_Correct_Result()
        {
            var story1 = CreateStory();
            var story2 = CreateStory();
            var story3 = CreateStory();

            Stories.AddRange(new[] { story1 as Story, story2 as Story, story3 as Story });

            var tag = _factory.CreateTag("dummy");

            Stories.ForEach(s => s.AddTag(tag));

            var result = _storyRepository.CountByTag(tag.Id);

            Assert.Equal(3, result);
        }
        private void BaseTask_OnFinished(object sender, EventArgs e)
        {
            if (!(sender is BaseStory story))
            {
                return;
            }

            _finishedStoryCount++;

            var nextStoryIndex = Stories.IndexOf(story) + 1;

            if (nextStoryIndex < Stories.Count)
            {
                Stories[nextStoryIndex].Start(CancellationTokenSource, RefreshRate);
            }
        }
        public void FindPublishedByCategory_With_Category_Name_Should_Return_Paged_Result()
        {
            var story1 = CreateStory();
            var story2 = CreateStory();
            var story3 = CreateStory();

            var rnd = new Random();

            Stories.AddRange(new[] { story1 as Story, story2 as Story, story3 as Story });
            Stories.ForEach(s => s.Publish(SystemTime.Now().AddDays(-rnd.Next(1, 5)), rnd.Next(1, 10)));

            var pagedResult = _storyRepository.FindPublishedByCategory(Stories[0].Category.Name, 0, 10);

            Assert.Equal(3, pagedResult.Result.Count);
            Assert.Equal(3, pagedResult.Total);
        }
예제 #9
0
 public RundownOverviewViewModel(Rundown model)
 {
     this.Id        = model.Id;
     this.Title     = model.Title;
     this.StartTime = model.StartTime;
     this.ShowId    = model.ShowId;
     this.ShowTitle = model.Show?.Title;
     this.ShowColor = model.Show?.Color;
     this.EndTime   = model.EndTime;
     if (model.Stories is null)
     {
         model.Stories = new List <Story>();
     }
     model.Stories.ForEach(x => Stories.Add(new StoryViewModel(x)));
     this.Active = model.Active;
 }
예제 #10
0
        public void Search_Should_Return_Correct_Result()
        {
            var story1 = CreateStory();
            var story2 = CreateStory();

            Stories.AddRange(new[] { story1 as Story, story2 as Story });

            database.Setup(db => db.StorySearchResult).Returns((new List <Guid> {
                story1.Id, story2.Id
            }).AsQueryable());

            var pagedResult = _storyRepository.Search("Test", 0, 10);

            Assert.Equal(2, pagedResult.Result.Count);
            Assert.Equal(2, pagedResult.Total);
        }
예제 #11
0
        private IEnumerable <StoriesItem> GerarStoriesItem(Stories stories)
        {
            StoriesItem item = new StoriesItem
            {
                Stories     = stories,
                StoriesId   = stories.Id,
                Id          = GerarNumero(),
                Name        = GerarTexto(),
                Type        = GerarTexto(),
                ResourceURI = GerarTexto()
            };

            return(new List <StoriesItem> {
                item
            });
        }
예제 #12
0
        public StoryViewModel(List <Story> stories)
            : this()
        {
            foreach (Story story in stories)
            {
                if (string.IsNullOrEmpty(story.ImgLink) == false)
                {
                    string imageFullPath = Path.Combine(Constants.ImagesDirectory, story.ImgLink);

                    StoriesViewModel item = new StoriesViewModel(story);

                    item.ImgLink = imageFullPath.Replace(' ', '_');
                    Stories.Add(item);
                }
            }
        }
예제 #13
0
        public async Task <List <StoryItem> > GetNewStories(int page, int numberOfRecords)
        {
            Stories newStoryIds = _cacheService.GetStoryIds();

            if (newStoryIds == null)
            {
                newStoryIds = await GetStoryIds(LiveDataType.newstories);

                _cacheService.SetStoryIds(newStoryIds);
            }

            var pagedStoryIds = GetPagedStoryIds(newStoryIds, page, numberOfRecords);
            var results       = await GetAllStoriesFromIdsAsync(pagedStoryIds);

            return(results);
        }
예제 #14
0
        public void UnitTest()
        {
            Stories data = new Stories();

            data.writer = "jui";
            data.plot   = "中央氣象局今天上午9時55分發布大雨特報指出,鋒面通過及東北季風影響,今天南投以北山區、東北部山區及基隆北海岸有局部大雨發生的機率,請注意";

            Result <int> result = uco.Create(data);

            if (result.Success)
            {
            }

            int          id      = 33;
            Result <int> result1 = uco.Delete(id);

            if (result1.Success)
            {
            }

            id = 40;
            Result <int> result2 = uco.Update_UpVotes(id);

            if (result2.Success)
            {
            }

            data.id = 7;
            Result <int> result3 = uco.Update(data);

            if (result3.Success)
            {
            }

            //PageSize - 一頁幾筆
            Result <StoriesList> result4 = uco.GetStoriesList(1, 10);

            if (result4.Success)
            {
            }

            Result <StoriesList> result5 = uco.GetStoriesList();

            if (result5.Success)
            {
            }
        }
예제 #15
0
        /// <summary>
        /// Основной расчетный игровой метод
        /// 1) Вызывает Отрисовку WPF элементов карты и юнитов
        /// 2) Производит расчет игровой модели
        /// 3) Обновляет текущий момент времени
        /// После чего возвращает истории для исполнения интерфейсом
        /// </summary>
        /// <returns>Истории</returns>
        public static Stories UpdateTime()
        {
            Stories stories = new Stories();

            for (int i = 0; i < mainMap.Units.Count; i++)
            {
                var unit  = mainMap.Units[i];
                var story = new UnitStory(unit);

                ActionCombination(AttackActions());

                if (unit.CurrentAction != null)
                {
                    switch (unit.CurrentAction.GetType().Name)
                    {
                    case "MoveAction":
                        story.States.AddRange((List <UnitState>)((MoveAction)unit.CurrentAction).Now(unit, _gameTime));
                        stories.GetStories.Add(story);
                        break;

                    case "AttackAction":
                        story.States.AddRange((List <UnitState>)((AttackAction)unit.CurrentAction).Now(unit, _gameTime));
                        stories.GetStories.Add(story);
                        break;

                    case "BuildAction":
                        story.States.AddRange((List <UnitState>)((BuildAction)unit.CurrentAction).Now(unit, _gameTime));
                        stories.GetStories.Add(story);
                        break;

                    default:

                        // Nothing to do
                        break;
                    }

                    if (unit.CurrentAction.Completed)
                    {
                        unit.CurrentAction = null;
                        break;
                    }
                }
            }

            _gameTime += _gameTimeInterval;
            return(stories);
        }
예제 #16
0
        public async void GetAllStoriesFromIdsAsync()
        {
            var returnData =
                "{\r\n  \"by\" : \"dhouston\",\r\n  \"descendants\" : 71,\r\n  \"id\" : 8863,\r\n  \"kids\" : [ 9224, 8917, 8952, 8958, 8884, 8887, 8869, 8940, 8908, 9005, 8873, 9671, 9067, 9055, 8865, 8881, 8872, 8955, 10403, 8903, 8928, 9125, 8998, 8901, 8902, 8907, 8894, 8870, 8878, 8980, 8934, 8943, 8876 ],\r\n  \"score\" : 104,\r\n  \"time\" : 1175714200,\r\n  \"title\" : \"My YC app: Dropbox - Throw away your USB drive\",\r\n  \"type\" : \"story\",\r\n  \"url\" : \"http://www.getdropbox.com/u/2/screencast.html\"\r\n}";
            var storyIds = new Stories {
                StoryIds = new List <int> {
                    1, 2, 3, 4
                }
            };

            _httpService.Setup(x => x.GetStringAsync(It.IsAny <string>())).ReturnsAsync(returnData);
            _newsStoriesService = new NewsStoriesService(_cacheService.Object, _configuration.Object, _httpService.Object);
            var stories = await _newsStoriesService.GetAllStoriesFromIdsAsync(storyIds);

            Assert.NotNull(stories);
            Assert.True(stories.Count == storyIds.StoryIds.Count);
        }
예제 #17
0
        public StoriesP(Panel StoryPanel, int x, int y, Action <List <Storie>, string> StoriesUsuario, Stories storie, string name, Action Update)
        {
            this.name           = name;
            this.StoryPanel     = StoryPanel;
            this.x              = x;
            this.y              = y;
            this.StoriesUsuario = StoriesUsuario;
            this.storie         = storie;
            this.Update         = Update;

            string url = Directory.GetCurrentDirectory();

            for (int i = 0; i < url.Length - 9; i++)
            {
                newURL += url[i];
            }
        }
        public void FindByTag_With_Tag_Name_Should_Return_Paged_Result()
        {
            var story1 = CreateStory();
            var story2 = CreateStory();
            var story3 = CreateStory();

            Stories.AddRange(new[] { story1 as Story, story2 as Story, story3 as Story });

            var tag = _factory.CreateTag("dummy");

            Stories.ForEach(s => s.AddTag(tag));

            var pagedResult = _storyRepository.FindByTag(tag.Name, 0, 10);

            Assert.Equal(3, pagedResult.Result.Count);
            Assert.Equal(3, pagedResult.Total);
        }
예제 #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String _stId = Request.QueryString["source"];
            if (!String.IsNullOrEmpty(_stId))
            {
                Stories _st = new Stories(this.ConnectionString);
                _st.LitePopulate(_stId, false, null);

                if (!_st.IsEmpty())
                {
                    lbl_Story.Text = _st.Story;
                    lbl_Title.Text = _st.Title;
                    tText.Text = "so.addVariable(\"text\",\"STORIES FROM THE TOP - <font size='22'>" + _st.CategoryDescription.ToUpper() + "</font>\")";

                    if (!String.IsNullOrEmpty(CommonUtility.NullSafeString(_st.YouTubeLink, "").Trim()))
                    {
                        div_Holder.InnerHtml = _st.YouTubeLink;
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(CommonUtility.NullSafeString(_st.ImgType, "").Trim()))
                        {
                            Image _img = new Image();
                            _img.ImageUrl = String.Format(ConfigurationManager.AppSettings["StoriesImagesPath"], _st.ID.ToString(), _st.ImgType);
                            div_Holder.Controls.Add(_img);
                        }
                        else
                        {
                            div_Holder.Visible = false;
                        }
                    }
                }
                else
                {
                    Response.Redirect("stotieslist.aspx");
                }

            }
            else
            {
                Response.Redirect("stotieslist.aspx");
            }
        }
    }
예제 #20
0
    protected void Save_Click(object sender, EventArgs e)
    {
        Stories _stor = new Stories(this.ConnectionString);

        _stor.Title = HttpUtility.HtmlEncode(txt_Title.Text);
        _stor.Story = HttpUtility.HtmlEncode(txt_Story.Text);
        _stor.Status = (Int32)Enums.enumStatuses.Pending;
        _stor.CategoryId = Convert.ToInt32(dd_Category.SelectedValue);

        string _imgType = "";
        if (fu_Image.HasFile)
        {
            _stor.YouTubeLink = "";
            _imgType = fu_Image.FileName.Split('.')[1];
            _stor.ImgType = _imgType;
        }
        else
        {
            if (Regex.IsMatch(txt_YouTube.Text, @"^<object[\s\S]+</object>$"))
            {
                _stor.YouTubeLink = GetYouTubeLink();
                _stor.ImgType = "";
            }
        }

        if (_stor.Save())
        {
            if (fu_Image.HasFile)
            {
                System.Drawing.Image _img = CoreLibrary.Utility.ImageUtility.FixedSize(fu_Image.FileContent,
                    Convert.ToInt32(ConfigurationManager.AppSettings["ImageStoryWidth"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["ImageStoryHight"]), System.Drawing.Color.Black);

                String _path = ConfigurationManager.AppSettings["StoriesImagesPath"];

                _path = Server.MapPath(String.Format(_path, _stor.ID.ToString(), _imgType));
                _img.Save(_path);
                _img.Dispose();
            }
            Response.Redirect("Default.aspx");
        }
        else
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('An unexpected error has occurred. Please try again..');", true);
        }
    }
예제 #21
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                string  webRootPath = _hostingEnvironment.WebRootPath;
                Stories stories     = await _db.Stories.FindAsync(id);

                // delete blocks
                var blocks = _db.StoryBlocks.Where(b => b.StoriesId == id).ToList();
                if (blocks.Count > 0)
                {
                    foreach (var item in blocks)
                    {
                        _db.StoryBlocks.Remove(item);
                    }
                    var block_imgs = Path.Combine(webRootPath, SD.StoryFolder + @"\" + stories.Id);
                    Directory.Delete(block_imgs, true);
                }
                // delete comments
                var comments = _db.Comments.Where(c => c.StoriesId == id);
                if (comments != null)
                {
                    foreach (var item in comments)
                    {
                        _db.Comments.Remove(item);
                    }
                }
                // delete story
                var uploads   = Path.Combine(webRootPath, SD.ImageFolder);
                var extension = Path.GetExtension(stories.Image);

                if (System.IO.File.Exists(Path.Combine(uploads, stories.Id + extension)))
                {
                    System.IO.File.Delete(Path.Combine(uploads, stories.Id + extension));
                }

                _db.Stories.Remove(stories);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
예제 #22
0
        private async void ExecuteShowBrowseWindowCommand()
        {
            var b = new BrowseView();

            b.ShowDialog();

            var vm = (BrowseViewModel)b.DataContext;

            if (vm.C9Entries == null)
            {
                return;
            }

            IsBusy = true;

            await Task.Factory.StartNew(() =>
            {
                if (Stories == null)
                {
                    Stories = new ObservableCollection <Story>();
                }

                foreach (var item in vm.C9Entries)
                {
                    if (item.Selected)
                    {
                        var entryBody = GetEntryBody(item.EntryUrl);

                        DispatcherHelper.CheckBeginInvokeOnUI(
                            () =>
                        {
                            Stories.Add(new Story
                            {
                                Title    = item.Title,
                                ImageUrl = item.ImageUrl,
                                EntryUrl = item.EntryUrl,
                                BodyHtml = entryBody
                            });
                        });
                    }
                }
            });


            IsBusy = false;
        }
예제 #23
0
        protected override ManagerStory.Story PrintFormattedStory(StoryProgressionObject manager, string text, string summaryKey, object[] parameters, string[] extended, ManagerStory.StoryLogging logging)
        {
            if (manager == null)
            {
                manager = Deaths;
            }

            if (GetData <ManagerDeath.DyingSimData>(Sim).Notified)
            {
                return(null);
            }

            if (Sim.DeathStyle == SimDescription.DeathType.None)
            {
                return(null);
            }

            if (Notifications.HasSignificantRelationship(Household.ActiveHousehold, Sim))
            {
                Stories.AddSummary(manager, Sim, UnlocalizedName, null, logging);
                return(null);
            }

            SimDescription.DeathType deathStyle = Sim.DeathStyle;

            // Temporary until a story can be written
            switch (Sim.DeathStyle)
            {
            case SimDescription.DeathType.PetOldAgeBad:
            case SimDescription.DeathType.PetOldAgeGood:
                deathStyle = SimDescription.DeathType.OldAge;
                break;
            }

            text = "SimDied:" + deathStyle;

            ManagerStory.Story story = base.PrintFormattedStory(manager, ManagerDeath.ParseNotification(text, Sim.Household, Sim), summaryKey, parameters, extended, logging);

            if (story != null)
            {
                story.mShowNoImage = true;
            }

            return(story);
        }
예제 #24
0
        private void GetData()
        {
            Status = "Starting sync get data at " + DateTime.Now.ToLongTimeString();
            Stories.Clear();

            var    webClient = new System.Net.WebClient();
            string content   = webClient.DownloadString("https://sport.orf.at");

            Thread.Sleep(30_000);
            var findStoriesRegex = new Regex("ticker-story-headline.*?a href.*?>(.*?)<\\/a>",
                                             RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var matches = findStoriesRegex.Matches(content);

            foreach (Match match in matches)
            {
                Stories.Add(match.Groups[1].ToString().Trim());
            }
        }
예제 #25
0
 async void GetHashtagStories()
 {
     try
     {
         await Helper.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
         {
             var s = await Helper.InstaApi.HashtagProcessor.GetHashtagStoriesAsync(HashtagText);
             if (s.Succeeded)
             {
                 Reel = s.Value.ToReel();
                 Stories.Clear();
                 Stories.AddRange(s.Value.Items);
                 Owner = s.Value.Owner;
             }
         });
     }
     catch { }
 }
예제 #26
0
 public void ResetToDefault()
 {
     if (BiographyText != null)
     {
         BiographyText.Blocks.Clear();
     }
     MediaGeneratror.ResetCache();
     UserShort        = null;
     FriendshipStatus = null;
     User             = null;
     Username         = null;
     TVChannel        = null;
     Highlights.Clear();
     Stories.Clear();
     ChainingSuggestions.Clear();
     PrivateVisibility = NoPostsVisibility = ChainingVisibility = IGTVVisibility = HighlightsVisibility = Visibility.Collapsed;
     View = null;
 }
예제 #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HtmlGenericControl _nc = (HtmlGenericControl)Master.FindControl("navHistory");
            _nc.Attributes.Add("class", "active");

            StoryCategoriesCollection<StoryCategories> _cat = new StoryCategoriesCollection<StoryCategories>(this.ConnectionString);
            _cat.LitePopulate(new CoreLibrary.ArgumentsList());

            dd_Category.DataSource = _cat;
            dd_Category.DataTextField = "Description";
            dd_Category.DataValueField = "ID";
            dd_Category.DataBind();
            dd_Category.Items.Insert(0, new ListItem("---- Select One ----", ""));

            dd_Status.DataSource = this.LogedInUser.GetAllStatuses();
            dd_Status.DataTextField = "Description";
            dd_Status.DataValueField = "ID";
            dd_Status.DataBind();

            String _storId = Request.QueryString["storId"];
            if (!String.IsNullOrEmpty(_storId))
            {
                ViewState.Add("storId", _storId);

                Stories _stor = new Stories(this.ConnectionString);
                _stor.LitePopulate(_storId, false);

                if (dd_Category.Items.FindByValue(_stor.CategoryId.ToString()) != null)
                {
                    dd_Category.Items.FindByValue(_stor.CategoryId.ToString()).Selected = true;
                }

                txt_Title.Text = HttpUtility.HtmlDecode(_stor.Title);
                txt_Story.Text = HttpUtility.HtmlDecode(_stor.Story);
                txt_YouTube.Text = _stor.YouTubeLink;
                if (dd_Status.Items.FindByValue(_stor.Status.ToString()) != null)
                {
                    dd_Status.Items.FindByValue(_stor.Status.ToString()).Selected = true;
                }
            }
        }
    }
        public void FindCommentedByUser_Should_Return_Correct_Result()
        {
            var story1 = CreateStory();
            var story2 = CreateStory();
            var story3 = CreateStory();

            Stories.AddRange(new[] { story1 as Story, story2 as Story, story3 as Story });

            var user = _factory.CreateUser("commenter", "*****@*****.**", "xxxxxx");

            Stories.ForEach(s => Comments.Add(new StoryComment {
                User = (User)user, Story = s, IPAddress = "192.168.0.1", CreatedAt = SystemTime.Now().AddDays(-3), HtmlBody = "<p>This is a comment</p>", TextBody = "This is a comment."
            }));

            var pagedResult = _storyRepository.FindCommentedByUser(user.Id, 0, 10);

            Assert.Equal(3, pagedResult.Result.Count);
            Assert.Equal(3, pagedResult.Total);
        }
예제 #29
0
        public static void Seed(IApplicationBuilder app)
        {
            // if our DB has nothing in it. Fill it with this data
            AppDBContext context = app.ApplicationServices.GetRequiredService <AppDBContext>();

            context.Database.EnsureCreated();

            if (!context.Stories.Any())
            {
                Stories firstStory = new Stories()
                {
                    Name  = "The Life of Steve Jobs",
                    Story = "Steve Jobs was CEO of Apple"
                };

                context.Stories.Add(firstStory);
                context.SaveChanges();
            }
        }
        public void FindPromotedByUser_With_UserName_Should_Return_Correct_Result()
        {
            var story1 = CreateStory();
            var story2 = CreateStory();
            var story3 = CreateStory();

            Stories.AddRange(new[] { story1 as Story, story2 as Story, story3 as Story });

            var user = _factory.CreateUser("promoter", "*****@*****.**", "xxxxxx");

            Stories.ForEach(s => Votes.Add(new StoryVote {
                User = (User)user, Story = s, IPAddress = "192.168.0.1", Timestamp = SystemTime.Now().AddDays(-3)
            }));

            var pagedResult = _storyRepository.FindPromotedByUser(user.UserName, 0, 10);

            Assert.Equal(3, pagedResult.Result.Count);
            Assert.Equal(3, pagedResult.Total);
        }
예제 #31
0
        internal int Update(Stories data)
        {
            string sql = @"
--declare
--@id int =51,
--@plot  nvarchar(500) = 'aaddddddddddddddddddddddddddddd',
--@writer nvarchar(80) = 'aaaaaaaaaaaaaaaaaaaaa'
update  dbo.stories set plot = @plot , writer = @writer where id = @id
";
            Sql    u   = new Sql();

            using (SqlCommand cmd = new SqlCommand(sql))
            {
                cmd.Parameters.AddWithValue("@id", data.id);
                cmd.Parameters.AddWithValue("@writer", data.writer);
                cmd.Parameters.AddWithValue("@plot", data.plot);
                return(u.ExecSQL(cmd));
            }
        }
예제 #32
0
        public Task <BlogResult> GetStoriesByTerm(string term, int pageSize, int page)
        {
            var lowerTerm  = term.ToLowerInvariant();
            var totalCount = Stories.Count(s => s.Body.ToLowerInvariant().Contains(lowerTerm) ||
                                           s.Categories.ToLowerInvariant().Contains(lowerTerm) ||
                                           s.Title.ToLowerInvariant().Contains(lowerTerm));

            return(Task.FromResult(new BlogResult()
            {
                CurrentPage = page,
                TotalResults = totalCount,
                TotalPages = CalculatePages(totalCount, pageSize),
                Stories = Stories
                          .Where(s => s.Body.ToLowerInvariant().Contains(lowerTerm) ||
                                 s.Categories.ToLowerInvariant().Contains(lowerTerm) ||
                                 s.Title.ToLowerInvariant().Contains(lowerTerm))
                          .Skip((page - 1) * pageSize).Take(pageSize)
            }));
        }
예제 #33
0
 async void GetStories()
 {
     try
     {
         await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
         {
             var stories = await InstaApi.StoryProcessor.GetUsersStoriesAsHighlightsAsync(UserShort.Pk.ToString());
             if (stories.Succeeded)
             {
                 Stories.Clear();
                 if (stories.Value.Items?.Count > 0)
                 {
                     Stories.AddRange(stories.Value.Items);
                 }
             }
         });
     }
     catch { }
 }
예제 #34
0
        protected override ManagerStory.Story PrintFormattedStory(StoryProgressionObject manager, string text, string summaryKey, object[] parameters, string[] extended, ManagerStory.StoryLogging logging)
        {
            if (mInheritors.Count == 0)
            {
                return(null);
            }

            if (manager == null)
            {
                manager = Deaths;
            }

            if (text == null)
            {
                text = GetTitlePrefix(PrefixType.Summary);
            }

            return(Stories.PrintFormattedSummary(Deaths, text, summaryKey, Sim, new List <SimDescription>(mInheritors.Keys), extended, logging));
        }
예제 #35
0
 protected void Publish_Click(Object sender, EventArgs e)
 {
     Stories _st = null;
     foreach (GridViewRow I in dgStories.Rows)
     {
         Label _id = (Label)I.FindControl("lbl_StorId");
         if (_id != null)
         {
             DropDownList _ddst = (DropDownList)I.FindControl("dd_Status");
             _st = new Stories(this.ConnectionString);
             _st.LitePopulate(_id.Text, false);
             if (!_st.Status.ToString().Equals(_ddst.SelectedValue))
             {
                 _st.Status = Convert.ToInt32(_ddst.SelectedValue);
                 _st.Save();
             }
         }
     }
     this.DataBind();
 }
예제 #36
0
 List<Story> GetStories(RestRequest request)
 {
     var response = RestClient.Execute(request);
     
     var stories = new Stories();
     var serializer = new RestSharpXmlDeserializer();
     var el = ParseContent(response);
     stories.AddRange(el.Elements("story").Select(storey => serializer.Deserialize<Story>(storey.ToString())));
     return stories;
 }
예제 #37
0
        private void MigrateStory(Stories story)
        {
            FixBody(story.Body);

              var newStory = new BlogStory()
              {
            Title = story.Title,
            Body = story.Body,
            DatePublished = story.DatePosted,
            IsPublished = story.IsPublished,
            UniqueId = story.Permalink,
            Slug = story.GetSlug()
              };

              newStory.Categories = string.Join(",", _ctx.StoryCategories.Include(c => c.Category).Where(s => s.Story_Id == story.Id).Select(s => s.Category.Name).ToArray());

              _repo.AddStory(newStory);
        }
예제 #38
0
		public void UpdateStories(Stories stories)
		{
			if (Stories == null)
			{
				Stories = stories;
				return;
			}

			// we got some house keeping to do
			var downloadingFriendsStories = (from friendStory in Stories.FriendStories from story in friendStory.Stories where story.Story.IsDownloading select story.Story).ToList();
			var downloadingMyStories = (from story in Stories.MyStories where story.Story.IsDownloading select story.Story).ToList();

			foreach (var story in stories.FriendStories.SelectMany(friendStory => friendStory.Stories))
				foreach (var downloadingStory in downloadingFriendsStories.Where(downloadingStory => downloadingStory.Id == story.Story.Id))
				{
					story.Story.IsDownloading = true;
					break;
				}

			foreach (var story in stories.MyStories)
				foreach (var downloadingStory in downloadingMyStories.Where(downloadingStory => downloadingStory.Id == story.Story.Id))
				{
					story.Story.IsDownloading = true;
					break;
				}

			Stories = stories;
		}
예제 #39
0
        public static Stories.V3.StorySegment ConvertSegment(Stories.V2.StorySegment segment)
        {
            Stories.V3.StorySegment newSegment = new Stories.V3.StorySegment();
            //bool paramsNeeded = true; ;
            switch (segment.Action) {
                case Stories.V2.StorySegment.StoryAction.SaySlow: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Say;

                        newSegment.Parameters.Add("Text", segment.Data1);
                        newSegment.Parameters.Add("Mugshot", segment.Data3);
                        newSegment.Parameters.Add("Speed", segment.Data2);
                        newSegment.Parameters.Add("PauseLocation", segment.Data4);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Say: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Say;

                        newSegment.AddParameter("Text", segment.Data1);
                        newSegment.AddParameter("Mugshot", segment.Data3);
                        newSegment.Parameters.Add("Speed", "0");
                        newSegment.Parameters.Add("PauseLocation", "0");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Pause: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Pause;

                        newSegment.AddParameter("Length", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.MapVisibility;

                        newSegment.Parameters.Add("Visible", "False");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.MapVisibility;

                        newSegment.Parameters.Add("Visible", "True");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Unlock: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Padlock;

                        newSegment.AddParameter("State", "Unlock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Lock: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Padlock;

                        newSegment.AddParameter("State", "Lock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.PlayMusic: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayMusic;

                        newSegment.AddParameter("File", segment.Data1);
                        newSegment.AddParameter("HonorSettings", segment.Data2);
                        newSegment.AddParameter("Loop", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.StopMusic: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.StopMusic;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowImage: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowImage;

                        newSegment.AddParameter("File", segment.Data1);
                        newSegment.AddParameter("ImageID", segment.Data4);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideImage: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HideImage;

                        newSegment.AddParameter("ImageID", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.WarpToMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Warp;

                        newSegment.AddParameter("MapID", "s" + segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.LockPlayer: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayerPadlock;

                        newSegment.AddParameter("MovementState", "Lock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.UnlockPlayer: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayerPadlock;

                        newSegment.AddParameter("MovementState", "Unlock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowBackground: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowBackground;

                        newSegment.AddParameter("File", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideBackground: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HideBackground;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.CreateNPC: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.CreateFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("ParentMapID", segment.Data2);
                        newSegment.AddParameter("X", segment.Data3);
                        newSegment.AddParameter("Y", segment.Data4);
                        newSegment.AddParameter("Sprite", segment.Data5);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.MoveNPC: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.MoveFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                        newSegment.AddParameter("Speed", segment.Data4);
                        newSegment.AddParameter("Pause", segment.Data5);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.MoveNPCQuick: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.WarpFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ChangeNPCDir: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ChangeFNPCDir;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("Direction", segment.Data2);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.DeleteNPC: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.DeleteFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.StoryScript: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.RunScript;

                        newSegment.AddParameter("ScriptIndex", segment.Data1);
                        newSegment.AddParameter("Pause", segment.Data2);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HidePlayers: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HidePlayers;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowPlayers: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowPlayers;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.NPCEmotion: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.FNPCEmotion;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("Emotion", segment.Data2);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Weather: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ChangeWeather;

                        newSegment.AddParameter("Weather", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideNPCs: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HideNPCs;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowNPCs: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowNPCs;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.WaitForMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.WaitForMap;

                        newSegment.AddParameter("MapID", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.WaitForLoc: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.WaitForLoc;

                        newSegment.AddParameter("MapID", segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.AskQuestion: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.AskQuestion;

                        newSegment.AddParameter("Question", segment.Data1);
                        newSegment.AddParameter("SegmentOnYes", segment.Data2);
                        newSegment.AddParameter("SegmentOnNo", segment.Data3);
                        newSegment.AddParameter("Mugshot", segment.Data5); // I used Data5 instead of Data4 in the old system, for some reason...
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.GoToSegment: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.GoToSegment;

                        newSegment.AddParameter("Segment", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ScrollCamera: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ScrollCamera;

                        newSegment.AddParameter("X", segment.Data1);
                        newSegment.AddParameter("Y", segment.Data2);
                        newSegment.AddParameter("Speed", segment.Data3);
                        newSegment.AddParameter("Pause", segment.Data4);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ResetCamera: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ResetCamera;
                    }
                    break;
            }
            return newSegment;
        }
예제 #40
0
    protected void Save_Click(object sender, EventArgs e)
    {
        Stories _stor = new Stories(this.ConnectionString);
        if (ViewState["storId"] != null)
        {
            _stor.LitePopulate(Convert.ToInt32(ViewState["storId"]), false);
        }

        if (IsValidStory(_stor))
        {

            _stor.Title = HttpUtility.HtmlEncode(txt_Title.Text);
            _stor.Story = HttpUtility.HtmlEncode(txt_Story.Text);
            _stor.Status = Convert.ToInt32(dd_Status.SelectedValue);

            _stor.CategoryId = Convert.ToInt32(dd_Category.SelectedValue);

            String _imgType = null;
            if (ViewState["storId"] != null)
            {
                if (fu_Image.HasFile)
                {
                    _stor.YouTubeLink = "";
                    _imgType = fu_Image.FileName.Split('.')[1];
                    _stor.ImgType = _imgType;
                }
                else
                {
                    if (!String.IsNullOrEmpty(txt_YouTube.Text))
                    {
                        _stor.YouTubeLink = GetYouTubeLink();
                        _stor.ImgType = "";
                    }
                }
            }
            else
            {
                if (fu_Image.HasFile)
                {
                    _stor.YouTubeLink = "";
                    _imgType = fu_Image.FileName.Split('.')[1];
                    _stor.ImgType = _imgType;
                }
                else
                {
                    _stor.YouTubeLink = GetYouTubeLink();
                    _stor.ImgType = "";
                }
            }

            if (_stor.Save())
            {
                if (fu_Image.HasFile)
                {
                    String _path = Server.MapPath(String.Format(ConfigurationManager.AppSettings["StoriesImagesPath"], _stor.ID.ToString(), _imgType));
                    fu_Image.SaveAs(_path);
                }
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('Record has been updated successfully.');self.location = 'StoriesList.aspx';", true);
            }
            else
            {
                lbl_Error.Text = "An unexpected error has occurred. Please try again.";
                lbl_Error.Visible = true;
            }
        }
    }
예제 #41
0
        private List<Story> GetStoriesByIterationType(int projectId, string iterationType)
        {
            var request = BuildGetRequest();
            request.Resource = string.Format(SpecifiedIterationEndpoint, projectId, iterationType);
            var el = RestClient.ExecuteRequestWithChecks(request);

            var stories = new Stories();
            stories.AddRange(el[0]["stories"].Select(storey => storey.ToObject<Story>()));
            return stories;
        }
예제 #42
0
 List<Story> GetStoriesByIterationType(int projectId, string iterationType)
 {
     var request = BuildGetRequest();
     request.Resource = string.Format(SpecifiedIterationEndpoint, projectId, iterationType);
     var response = RestClient.Execute(request);
     
     var stories = new Stories();
     var serializer = new RestSharpXmlDeserializer();
     var el = ParseContent(response);
     stories.AddRange(el.Descendants("story").Select(storey => serializer.Deserialize<Story>(storey.ToString())));
     return stories;
 }
예제 #43
0
    private bool IsValidStory(Stories stor)
    {
        Boolean _ret = true;
        if (IsValid)
        {
            if (stor.ID != null)
            {
                if (String.IsNullOrEmpty(txt_YouTube.Text) && !fu_Image.HasFile)
                {
                    if (String.IsNullOrEmpty(CommonUtility.NullSafeString(stor.ImgType, "").Trim()) &&
                        String.IsNullOrEmpty(CommonUtility.NullSafeString(stor.YouTubeLink, "").Trim()))
                    {
                        _ret = false;
                    }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(txt_YouTube.Text) && !fu_Image.HasFile)
                {
                    _ret = false;
                }
            }
        }

        if (!_ret)
        {
            lbl_Error.Text = "Please enter Image Or YouTube link.";
            lbl_Error.Visible = true;
        }
        else
        {
            lbl_Error.Visible = false;
        }
        return _ret;
    }