Example #1
0
 private void Process(IStory story)
 {
     foreach (var handler in this.handlerProvider.Fire(story))
     {
         handler.OnStop(story);
     }
 }
Example #2
0
        public bool?IsValid(IStory story, DateTime time)
        {
            var entity = story.GetEntityByID(TargetObjectID);

            if (entity != null)
            {
                var timeentity = entity as ITimeSensitive;
                if (timeentity != null)
                {
                    if (time >= timeentity.BeginTime && time <= timeentity.EndTime)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            return(null);
        }
        public ICommentSubscribtion CreateCommentSubscribtion(IStory forStory, IUser byUser)
        {
            Check.Argument.IsNotNull(forStory, "forStory");
            Check.Argument.IsNotNull(byUser, "byUser");

            return(new CommentSubscribtion((Story)forStory, (User)byUser));
        }
Example #4
0
        public static IComment AddComment(this IStory forStory, string content, DateTime at, IUser byUser, string fromIpAddress)
        {
            var comment = IoC.Resolve <IDomainObjectFactory>().CreateComment(forStory, content, at, byUser, fromIpAddress);

            IoC.Resolve <ICommentRepository>().Add(comment);
            return(comment);
        }
Example #5
0
        public string FormatStory(IStory story, string handlerName)
        {
            StringBuilder str = new StringBuilder();
            str.AppendFormat("{0}\n  Story {1} ({2}) on rule {3}\n", story.StartDateTime, story.Name, story.InstanceId, handlerName);

            foreach (var item in story.GetDataValues())
            {
                if (item.Value != null)
                {
                    str.AppendFormat("  {0} - {1}\n", item.Key, item.Value.GetType().IsValueType ? item.Value : item.Value.Serialize());
                }
            }
            str.Append('\n');

            foreach (var line in story.GetLogs())
            {
                if (line.Severity < this.severityThreshold)
                {
                    continue;
                }

                str.AppendFormat("  +{0} ms {1} {2}\n", (line.DateTime - story.StartDateTime).TotalMilliseconds, line.Severity, line.Text/*, line.Origin*/);
            }
            str.Append('\n');

            AddStory(story, str, 1);
            str.Append('\n');

            return str.ToString();
        }
        protected long[,] GenerateTable(int max, IStory[] candidates, int maxPriority)
        {
            long[,] table = new long[candidates.Length+1, max+1];

            //for i from 1 to n do
            //  for j from 0 to W do
            //    if w[i] <= j then
            //      m[i, j] := max(m[i-1, j], m[i-1, j-w[i]] + v[i])
            //    else
            //      m[i, j] := m[i-1, j]
            //    end if
            //  end for
            //end for

            for (int i = 1; i <= candidates.Length; i++)
            {
                for (int j = 0; j <= max; j++)
                {
                    var candidate = candidates[i - 1];
                    if (candidate.Points <= j)
                    {
                        table[i, j] = Math.Max(table[i - 1, j],
                            table[i - 1, (j - candidate.Points)] + CalculateValue(candidate));
                    }
                    else
                    {
                        table[i, j] = table[i - 1, j];
                    }
                }
            }

            return table;
        }
        public ICollection <IStory> FindSimilar(IStory storyToFindSimilarTo)
        {
            var tags = storyToFindSimilarTo.Tags.Select(x => x.Name).ToList();

            tags = tags.Where(x => x != "C#").Where(x => x != ".Net").ToList();

            var similarsByTags = _context.Stories
                                 .OrderByDescending(x => x.CreatedAt)
                                 .SelectMany(x => x.StoryTags)
                                 .Where(x => tags.Contains(x.Tag.Name))
                                 .GroupBy(x => x.Story)
                                 .Select(x => new { Element = x.Key, Count = x.Count() })
                                 .OrderByDescending(x => x.Count)
                                 .Select(x => x.Element)
                                 .Where(x => x != storyToFindSimilarTo)
                                 .Cast <IStory>()
                                 .Take(11).ToList();

            if (similarsByTags.Count == 0)
            {
                var category           = storyToFindSimilarTo.BelongsTo.Id;
                var similarsByCategory = _context.Stories
                                         .OrderByDescending(x => x.CreatedAt)
                                         .Where(x => x.CategoryId == category)
                                         .Cast <IStory>()
                                         .Take(11).ToList();

                return(similarsByCategory);
            }
            else
            {
                return(similarsByTags);
            }
        }
Example #8
0
        public override void OnStop(IStory story)
        {
            Ensure.ArgumentNotNull(story, "story");

            string str = this.storyFormatter.FormatStory(story, this.Name);
            Trace.TraceInformation(str);
        }
        public async Task Play(IStory <IMessageActivity> story, CancellationToken cancellationToken = default(CancellationToken))
        {
            var builder = this.GetTestContainerBuilder();
            var player  = new UnitTestStoryPlayer(builder);

            await player.Play(story, cancellationToken);
        }
Example #10
0
 public override void OnStop(IStory story)
 {
     foreach (var storyHandler in this.storyHandlers)
     {
         storyHandler.OnStop(story);
     }
 }
        public virtual void StoryDemoted(IStory theStory, IUser byUser)
        {
            Check.Argument.IsNotNull(theStory, "theStory");
            Check.Argument.IsNotNull(byUser, "byUser");

            if (CanChangeScoreForStory(theStory, byUser))
            {
                // It might not decrease the same value which was increased when promoting the story
                // depending upon the story status(e.g. published/upcoming), but who cares!!!
                UserAction reason;
                decimal    score;

                if (theStory.IsPublished())
                {
                    score  = _userScoreTable.PublishedStoryPromoted;
                    reason = UserAction.PublishedStoryDemoted;
                }
                else
                {
                    score  = _userScoreTable.UpcomingStoryPromoted;
                    reason = UserAction.UpcomingStoryDemoted;
                }

                byUser.DecreaseScoreBy(score, reason);
            }
        }
Example #12
0
 private void Process(IStory story)
 {
     foreach (var handler in this.handlerProvider.Fire(story))
     {
         handler.OnStop(story);
     }
 }
        /// <summary>Evaluates the next story line.</summary>
        /// <param name="story">The story.</param>
        /// <param name="options">The options.</param>
        public virtual void EvaluateNextStoryLine(IStory story, ConsoleUserInterfaceOptions options)
        {
            if (story == null)
            {
                return;
            }

            story.Continue();

            Interpreter.RetrieveDebugSourceForLatestContent(story);

            OutputManager.ShowCurrentText(story, options);

            if (story.HasCurrentTags)
            {
                OutputManager.ShowTags(story.currentTags, options);
            }

            if ((Errors.Count > 0 || Warnings.Count > 0))
            {
                OutputManager.ShowWarningsAndErrors(Warnings, Errors, options);
            }

            Errors.Clear();
            Warnings.Clear();
        }
Example #14
0
 private static void PerformCheck(IStory forStory, DateTime at, IUser byUser, string fromIpAddress)
 {
     Check.Argument.IsNotNull(forStory, "forStory");
     Check.Argument.IsNotInFuture(at, "at");
     Check.Argument.IsNotNull(byUser, "byUser");
     Check.Argument.IsNotEmpty(fromIpAddress, "fromIpAddress");
 }
Example #15
0
        public Task AssertStory(
            IStory <IMessageActivity> story,
            List <PerformanceStep <IMessageActivity> > performanceSteps)
        {
            if (this.dialogResult.Exception != null)
            {
                var dialogFrame = story.StoryFrames.FirstOrDefault(x => x is DialogStoryFrame <IMessageActivity>) as DialogStoryFrame <IMessageActivity>;

                if (dialogFrame == null || dialogFrame.DialogStatus != DialogStatus.Failed)
                {
                    throw this.dialogResult.Exception;
                }
            }

            var storySteps = story.StoryFrames
                             .Select((storyFrame, stepIndex) => new StoryStep <IMessageActivity>(storyFrame, isDialogResultCheckupStep: storyFrame is DialogStoryFrame <IMessageActivity>)
            {
                Status    = StoryPlayerStepStatus.NotDone,
                StepIndex = stepIndex,
            })
                             .ToList();

            var stepsCount = Math.Max(storySteps.Count, performanceSteps.Count);

            for (var i = 0; i < stepsCount; i++)
            {
                this.AssertStoryStep(performanceSteps, storySteps, i);
            }

            return(Task.CompletedTask);
        }
Example #16
0
        public string FormatStory(IStory story, string handlerName)
        {
            StringBuilder str = new StringBuilder();

            str.AppendFormat("{0}\n  Story {1} ({2}) on rule {3}\n", story.StartDateTime, story.Name, story.InstanceId, handlerName);

            foreach (var item in story.GetDataValues())
            {
                if (item.Value != null)
                {
                    str.AppendFormat("  {0} - {1}\n", item.Key, item.Value.GetType().IsValueType ? item.Value : item.Value.Serialize());
                }
            }
            str.Append('\n');

            foreach (var line in story.GetLogs())
            {
                if (line.Severity < this.severityThreshold)
                {
                    continue;
                }

                str.AppendFormat("  +{0} ms {1} {2}\n", (line.DateTime - story.StartDateTime).TotalMilliseconds, line.Severity, line.Text /*, line.Origin*/);
            }
            str.Append('\n');

            AddStory(story, str, 1);
            str.Append('\n');

            return(str.ToString());
        }
Example #17
0
        public ActionResult MarkAsSpam(string id)
        {
            id = id.NullSafe();

            JsonViewData viewData = Validate <JsonViewData>(
                new Validation(() => string.IsNullOrEmpty(id), "Identyfikator artyku³u nie mo¿e byæ pusty."),
                new Validation(() => id.ToGuid().IsEmpty(), "Niepoprawny identyfikator artyku³u."),
                new Validation(() => !IsCurrentUserAuthenticated, "Nie jesteœ zalogowany.")
                );

            if (viewData == null)
            {
                try
                {
                    using (IUnitOfWork unitOfWork = UnitOfWork.Get())
                    {
                        IStory story = _storyRepository.FindById(id.ToGuid());

                        if (story == null)
                        {
                            viewData = new JsonViewData {
                                errorMessage = "Podany artyku³ nie istnieje."
                            };
                        }
                        else
                        {
                            if (!story.CanMarkAsSpam(CurrentUser))
                            {
                                viewData = story.HasMarkedAsSpam(CurrentUser) ?
                                           new JsonViewData {
                                    errorMessage = "Ju¿ zaznaczy³eœ ten artyku³ jako spam."
                                } :
                                new JsonViewData {
                                    errorMessage = "Nie masz uprawnieñ do zaznaczania tego artyku³u jako spam."
                                };
                            }
                            else
                            {
                                _storyService.MarkAsSpam(story, string.Concat(Settings.RootUrl, Url.RouteUrl("Detail", new { name = story.UniqueName })), CurrentUser, CurrentUserIPAddress);
                                unitOfWork.Commit();

                                viewData = new JsonViewData {
                                    isSuccessful = true
                                };
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Exception(e);

                    viewData = new JsonViewData {
                        errorMessage = FormatStrings.UnknownError.FormatWith("oznaczania artyku³u jako spam")
                    };
                }
            }

            return(Json(viewData));
        }
Example #18
0
        public ActionResult Promote(string id)
        {
            id = id.NullSafe();

            JsonViewData viewData = Validate <JsonViewData>(
                new Validation(() => string.IsNullOrEmpty(id), "Identyfikator artyku³u nie mo¿e byæ pusty."),
                new Validation(() => id.ToGuid().IsEmpty(), "Niepoprawny identyfikator artyku³u."),
                new Validation(() => !IsCurrentUserAuthenticated, "Nie jesteœ zalogowany.")
                );

            if (viewData == null)
            {
                try
                {
                    using (IUnitOfWork unitOfWork = UnitOfWork.Get())
                    {
                        IStory story = _storyRepository.FindById(id.ToGuid());

                        if (story == null)
                        {
                            viewData = new JsonViewData {
                                errorMessage = "Podany artyku³ nie istnieje."
                            };
                        }
                        else
                        {
                            if (!story.CanPromote(CurrentUser))
                            {
                                viewData = story.HasPromoted(CurrentUser) ?
                                           new JsonViewData {
                                    errorMessage = "Ju¿ wypromowa³eœ ten artyku³."
                                } :
                                new JsonViewData {
                                    errorMessage = "Nie mo¿esz promowaæ tego artyku³u."
                                };
                            }
                            else
                            {
                                _storyService.Promote(story, CurrentUser, CurrentUserIPAddress);
                                unitOfWork.Commit();

                                viewData = new JsonVoteViewData {
                                    isSuccessful = true, votes = story.VoteCount, text = GetText(story.VoteCount)
                                };
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Exception(e);

                    viewData = new JsonViewData {
                        errorMessage = FormatStrings.UnknownError.FormatWith("promowaniu artyku³u")
                    };
                }
            }

            return(Json(viewData));
        }
Example #19
0
        public ActionResult Detail(string name)
        {
            name = name.NullSafe();

            if (string.IsNullOrEmpty(name))
            {
                return(RedirectToRoute("Published"));
            }

            IStory story = _storyRepository.FindByUniqueName(name);

            if (story == null)
            {
                ThrowNotFound("Artyku³ nie istnieje.");
            }

            StoryDetailViewData viewData = CreateStoryViewData <StoryDetailViewData>();

            viewData.CaptchaEnabled = !CurrentUser.ShouldHideCaptcha();

            if (story != null)
            {
                viewData.Title           = "{0} - {1}".FormatWith(Settings.SiteTitle, story.Title);
                viewData.MetaDescription = story.StrippedDescription();
                viewData.Story           = story;
                viewData.CounterColors   = CounterColors;
            }

            return(View(viewData));
        }
Example #20
0
        public async Task <string> GetDetails(IStory story)
        {
            try
            {
                byte[] bytes;
                using (var httpClient = new HttpClient())
                    bytes = await httpClient.GetByteArrayAsync(story.Details);
                var html = _enc1251.GetString(bytes);

                var doc = new HtmlDocument();
                doc.LoadHtml(html);
                var node = doc.DocumentNode.SelectSingleNode("//div[@class='short-story-news']");

                return("<html>" +
                       "<head>" +
                       "<base href=\"https://www.rusfootball.info/\"></base>" +
                       "</head>" +
                       $"<body>{node.InnerHtml}</body>" +
                       "</html>");
            }
            catch (Exception e)
            {
                _logger.Error("Details error", e);
                return(String.Empty);
            }
        }
Example #21
0
        public async Task Play(IStory <IMessageActivity> story, ChannelAccount from, IServiceCollection services)
        {
            var provider = services.BuildServiceProvider();
            var player   = new StoryPlayer(provider);

            await player.Play(story);
        }
Example #22
0
 public void LoadTargetObject(IStory story, bool AutoDelete = false)
 {
     NodeList.ForEach(v =>
     {
         var o = story.GetEntityByID(v.TargetObjectID);
         if (o == null)
         {
             v.TargetObjectID = Guid.Empty;
         }
     });
     if (AutoDelete)
     {
         NodeList.RemoveAll(v => v.TargetObjectID == Guid.Empty);
     }
     ConnectionList.ForEach(v =>
     {
         var o = story.RelationList.FirstOrDefault(r => r.ObjectID == v.TargetObjectID);
         if (o == null)
         {
             v.TargetObjectID = Guid.Empty;
         }
     });
     if (AutoDelete)
     {
         ConnectionList.RemoveAll(v => v.TargetObjectID == Guid.Empty);
     }
 }
Example #23
0
 public Story(IStory baseStory)
 {
     Header       = baseStory.Header;
     Acts         = baseStory.Acts;
     Restrictions = baseStory.Restrictions;
     Sequences    = baseStory.Sequences;
 }
Example #24
0
        /// <summary>
        /// Get all values with the responding story from the story data in the story
        /// and from the children stories inside
        /// or an empty enumerable if not found
        /// </summary>
        public static IEnumerable <StoryDataValue> GetDataValues(this IStory story, string key)
        {
            Ensure.ArgumentNotNull(story, "story");

            List <StoryDataValue> result = null;

            // assume story.Data[key] returns null if not found
            object value = story.Data[key];

            if (value != null)
            {
                result = new List <StoryDataValue>();
                result.Add(new StoryDataValue(story, value));
            }

            if (story.Children != null)
            {
                foreach (var childStory in story.Children)
                {
                    var childResults = GetDataValues(childStory, key);
                    if (childResults.Any())
                    {
                        if (result == null)
                        {
                            result = new List <StoryDataValue>();
                        }

                        result.AddRange(childResults);
                    }
                }
            }

            return(result ?? Enumerable.Empty <StoryDataValue>());
        }
        /// <summary>
        /// Creates a new Story in a Board, based on user input.
        /// </summary>
        /// <param name="parameter">The name of the Story.</param>
        /// <returns>A string that reflects if the command was successful.</returns>
        public override string Execute(string parameter)
        {
            string      title;
            string      description;
            string      boardName;
            Priority    priority;
            Size        size;
            StoryStatus status;

            try
            {
                title = this._validator.ValidateTitle(parameter);
                Console.Write("Board: ");
                boardName = Console.ReadLine().Trim();
                var board = this._validator.ValidateExists(this._engine.Boards, boardName);
                board = this._validator.ValidateMoreThanOne(this._engine.Boards, boardName);
                Console.Write("Story Description(Single line): ");
                description = this._validator.ValidateDescription(Console.ReadLine().Trim());
                Console.Write("Story Priority(High/Medium/Low): ");
                priority = this._validator.ValidatePriority(Console.ReadLine().Trim());
                Console.Write("Story Size(Large/Medium/Small): ");
                size = this._validator.ValidateSize(Console.ReadLine().Trim());
                Console.Write("Story Status(NotDone/InProgress/Done): ");
                status = this._validator.ValidateStoryStatus(Console.ReadLine().Trim());
                IStory story = this._factory.CreateStory(title, description, priority, size, status);
                this._engine.WorkItems.Add(story);
                board.AddWorkItem(story);
                return($"Story with ID {this._engine.WorkItems.Count - 1}, Title {title} was created.");
            }
            catch (ArgumentException ex)
            {
                throw new ArgumentException($"{ex.Message} Unable to create story.");
            }
        }
Example #26
0
        public PublishedStory(IStory story)
        {
            Check.Argument.IsNotNull(story, "story");

            Story   = story;
            Weights = new Dictionary <string, double>();
        }
Example #27
0
        /// <summary>
        /// Get the first value from the story data in the story
        /// and the children stories inside (recursive)
        /// or null if not found
        /// </summary>
        public static object GetDataValue(this IStory story, string key, bool recursive = true)
        {
            Ensure.ArgumentNotNull(story, "story");

            // assume story.Data[key] returns null if not found
            object result = story.Data[key];

            if (result != null || recursive == false)
            {
                return(result);
            }

            if (story.Children != null)
            {
                foreach (var childStory in story.Children)
                {
                    result = childStory.GetDataValue(key, recursive);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            return(null);
        }
Example #28
0
 public override void OnStop(IStory story)
 {
     foreach (var storyHandler in this.storyHandlers)
     {
         storyHandler.OnStop(story);
     }
 }
        public async Task <List <PerformanceStep <IMessageActivity> > > Perform(IStory <IMessageActivity> testStory)
        {
            var steps = this.GetStorySteps(testStory);

            try
            {
                foreach (var step in steps)
                {
                    this.PushStartupMessageActivities();

                    await this.WriteUserMessageActivity(step);

                    this.ReadBotMessageActivities();

                    this.TrySetLatestOptions();
                }
            }
            catch (Exception ex)
            {
                this.wrappedDialogResult.DialogStatus = DialogStatus.Failed;
                this.wrappedDialogResult.Exception    = ex;
            }

            return(this.performanceStory.Steps);
        }
 private StoryMarkAsSpam CreateNewMarkAsSpam(IStory forStory, IUser byUser)
 {
     return((StoryMarkAsSpam)_domainFactory.CreateMarkAsSpam(forStory,
                                                             SystemTime.Now(),
                                                             byUser,
                                                             "127.0.0.1"));
 }
Example #31
0
 private StoryController(IStory story, Output output, CommandPrompt commandPrompt)
 {
     Context.Output        = output ?? throw new ArgumentNullException("output");
     Context.CommandPrompt = commandPrompt ?? throw new ArgumentNullException("commandPrompt");
     Context.Story         = story ?? throw new ArgumentNullException("story");
     Context.Parser        = new Parser();
 }
Example #32
0
 private void PingStory(StoryContent content, IStory story, string detailUrl)
 {
     if (_settings.SendPing && !string.IsNullOrEmpty(content.TrackBackUrl))
     {
         _contentService.Ping(content.TrackBackUrl, story.Title, detailUrl, "Dziêkujemy za publikacjê - Trackback z {0}".FormatWith(_settings.SiteTitle), _settings.SiteTitle);
     }
 }
Example #33
0
        public override void OnStop(IStory story)
        {
            Ensure.ArgumentNotNull(story, "story");

            string str = this.storyFormatter.FormatStory(story, this.Name);
            Console.WriteLine(str);
        }
Example #34
0
        public virtual void Update(IStory theStory, string uniqueName, DateTime createdAt, string title, string category, string description, string tags)
        {
            Check.Argument.IsNotNull(theStory, "theStory");

            if (string.IsNullOrEmpty(uniqueName))
            {
                uniqueName = theStory.UniqueName;
            }

            if (!createdAt.IsValid())
            {
                createdAt = theStory.CreatedAt;
            }

            theStory.ChangeNameAndCreatedAt(uniqueName, createdAt);

            if (!string.IsNullOrEmpty(title))
            {
                theStory.Title = title;
            }

            if ((!string.IsNullOrEmpty(category)) && (string.Compare(category, theStory.BelongsTo.UniqueName, StringComparison.OrdinalIgnoreCase) != 0))
            {
                ICategory storyCategory = _categoryRepository.FindByUniqueName(category);
                theStory.ChangeCategory(storyCategory);
            }

            if (!string.IsNullOrEmpty(description))
            {
                theStory.HtmlDescription = description.Trim();
            }

            AddTagsToContainers(tags, new[] { theStory });
        }
Example #35
0
        public List <FateEntity> GetFate(IStory story)
        {
            List <FateEntity> rl = new List <FateEntity>();
            var l = story.GetFate(this);

            //if(filterType== FilterType.Type)
            //{
            //    l = l.Where(v => v.Item1.GetType().Name == filter).ToList();
            //}
            //if(filterType== FilterType.Name)
            //{
            //    l = l.Where(v => v.Item1.Name == filter).ToList();
            //}
            l.ForEach(v =>
            {
                var fateEntity = new FateEntity()
                {
                    Name                = v.Item1.Name,
                    FateEntityType      = GetEntityType(v.Item1),
                    Description         = v.Item2.Memo,
                    BeginTime           = CommonProc.GetMaxTime(v.Item2.BeginTime, v.Item1.BeginTime),
                    EndTime             = CommonProc.GetMinTime(v.Item2.EndTime, v.Item1.EndTime),
                    RelationType        = v.Item2.RelationType,
                    RelationDescription = v.Item2.Memo
                };
                //fateEntity.KeywordList.AddRange(v.Item1.KeyWordList);
                rl.Add(fateEntity);
            });
            return(rl);
        }
Example #36
0
 /// <inheritDoc/>
 public void Add(IStory s)
 {
     lock (_lock)
     {
         _repository.Insert(s.Id, s);
     }
 }
Example #37
0
 /// <inheritDoc/>
 public void Add(IStory s)
 {
     lock (_lock)
     {
         _repository.Insert(s.Id, s);
     }
 }
Example #38
0
        public virtual void OnStop(IStory story, Task task)
        {
            Ensure.ArgumentNotNull(story, "story");
            Ensure.ArgumentNotNull(task, "task");

            string str = this.storyFormatter.FormatStory(story);
            Console.WriteLine(str);
        }
Example #39
0
 public static HourInfoList HourFetchInfoList(IStory story)
 {
     return HourInfoList.FetchHourInfoList(
         new HourDataCriteria
             {
                 StoryId = story.StoryId
             });
 }
Example #40
0
        public virtual void OnStop(IStory story, Task task)
        {
            Ensure.ArgumentNotNull(story, "story");
            Ensure.ArgumentNotNull(task, "task");

            string str = this.storyFormatter.FormatStory(story);
            Trace.TraceInformation(str);
        }
Example #41
0
        public override void OnStop(IStory story)
        {
            Ensure.ArgumentNotNull(story, "story");

            if (this.stopAction != null)
            {
                this.stopAction(story);
            }
        }
Example #42
0
        public void OnStart(IStory story)
        {
            Ensure.ArgumentNotNull(story, "story");

            if (this.startAction != null)
            {
                this.startAction(story);
            }
        }
Example #43
0
        public void OnStop(IStory story, Task task)
        {
            Ensure.ArgumentNotNull(story, "story");
            Ensure.ArgumentNotNull(task, "task");

            if (this.stopAction != null)
            {
                this.stopAction(story, task);
            }
        }
Example #44
0
 public StoryTimeController(MainWindow win)
 {
     window = win;
     del = (IStory)this;
     createANewStory();
     prompts = new List<String>();
     prompts.Add("Introduce your characters and the story setting. Tell us what they are doing here.");
     prompts.Add("This is the the scene of conflict or struggle. It's typically most exciting part of the story.");
     prompts.Add("How is the conflict resolved? How does your story end?");
 }
Example #45
0
 public void AddStory(IStory story, StringBuilder str, int level)
 {
     var spaces = new StringBuilder();
     spaces.Append(' ', level * 2);
     str.AppendFormat("{0}- Story \"{1}\" took {2} ms\n", spaces, story.Name, story.Elapsed.Milliseconds);
     foreach (var childStory in story.Children)
     {
         AddStory(childStory, str, level + 1);
     }
 }
        public StoryController(IStory story, Output output, CommandPrompt commandPrompt)
        {
            if (story == null) throw new ArgumentNullException("story");
            if (output == null) throw new ArgumentNullException("output");
            if (commandPrompt == null) throw new ArgumentNullException("commandPrompt");

            Context.Output = output;
            Context.CommandPrompt = commandPrompt;
            Context.Story = story;
            Context.Parser = new Parser();

        }
Example #47
0
        public string FormatStory(IStory story)
        {
            StringBuilder str = new StringBuilder();

            foreach (var entry in story.Log)
            {
                if (entry.Severity < this.severityThreshold)
                {
                    continue;
                }

                str.AppendFormat("{0}|{1}|{2}|{3}\n", entry.DateTime, entry.Severity, entry.Elapsed, entry.Text);
            }

            return str.ToString();
        }
Example #48
0
        public static StoryTableEntity ToStoryTableEntity(IStory story)
        {
            if (story == null)
            {
                return null;
            }

            var storyTableEntity = new StoryTableEntity()
            {
                Name = story.Name,
                Elapsed = story.Elapsed,
                StartDateTime = story.StartDateTime,
                InstanceId = story.InstanceId,
                Json = story.Serialize()
            };

            storyTableEntity.UpdateKeys(story);

            return storyTableEntity;
        }
Example #49
0
        public string FormatStory(IStory story)
        {
            StringBuilder str = new StringBuilder();
            str.AppendFormat("{0}\n  Story {1} took {2} ms\n", story.StartDateTime, story.Name, story.Elapsed.TotalMilliseconds);

            foreach (var item in story.Data)
            {
                if (item.Value != null)
                {
                    str.AppendFormat("  {0} - {1}\n", item.Key, item.Value.GetType().IsValueType ? item.Value : item.Value.Serialize());
                }
            }
            str.Append('\n');

            foreach (var line in story.Log)
            {
                str.AppendFormat("  +{0} ms {1} {2}\n", (line.DateTime - story.StartDateTime).TotalMilliseconds, line.Severity, line.Text/*, line.Origin*/);
            }

            return str.ToString();
        }
        protected IEnumerable<IStory> TraceSolution(int max, IStory[] candidates, long[,] table)
        {
            List<IStory> solution = new List<IStory>();
            int row = table.GetLength(0) - 1;
            int col = table.GetLength(1) - 1;

            long valueRemaining = table[row,col];

            // Walk backwards through the table until we have reached the end, or we have no story points left
            while (valueRemaining > 0 && row > 0)
            {
                // If in this step we added value then add the selected story to the solution
                if (table[row,col] != table[row - 1, col])
                {
                    //Must subtract 1 because row is 1 based and candidates is 0 based.
                    IStory nextStory = candidates[row - 1];
                    solution.Add(nextStory);

                    int weight = nextStory.Points;
                    long value = CalculateValue(nextStory);

                    //Move one row up and the number of columns equal to the weight left.
                    row--;
                    col -= weight;

                    valueRemaining -= value;
                }
                else
                {
                    // We didn't add value in this step, so simply move one row up
                    row--;
                }
            }

            // The solution was generated backwards, so we need to reverse it before returing
            solution.Reverse();

            return solution;
        }
Example #51
0
 public void OnStop(IStory story, Task task)
 {
     // TODO: what to do with the task here
     // consider removing task from OnStop and adding the important task information to the story itself
     _storiesSubject.OnNext(story);
 }
Example #52
0
 public virtual void OnStart(IStory story)
 {
 }
Example #53
0
 public Game(Story newstory)
 {
     Story = newstory;
     Init();
 }
Example #54
0
 private void UpdateKeys(IStory story)
 {
     PartitionKey = String.Format(story.StartDateTime.ToString("yyyyMMddHH"));
     RowKey = story.StartDateTime.ToString("mmssffff") + story.InstanceId;
 }
Example #55
0
 private static void RegisterStoryName(IStory story, List<string> loggedStoryNames)
 {
     loggedStoryNames.Add(story.Name);
     foreach (var child in story.Children)
     {
         RegisterStoryName(child, loggedStoryNames);
     }
 }
Example #56
0
 public StoryTimeController(MainWindow win)
 {
     window = win;
     del = (IStory)this;
 }
 public StoryController(IStory story) : this(story, new Output(Console.Out), new CommandPrompt(Console.Out, Console.In))
 {
     
 }
Example #58
0
 public SkeletonController(MainWindow win, IStory stDelegate)
 {
     window = win;
     del = stDelegate;
     frameCount = 0;
 }
Example #59
0
 public virtual void OnStop(IStory story)
 {
 }
Example #60
0
 public void OnStart(IStory story)
 {
 }