public void Update(GoalId Id, Action<GoalAggreagate> execute)
        {
            while (true)
            {

                EventStream eventStream = _eventStore.LoadEventStream(Id);
                GoalAggreagate goal = new GoalAggreagate(eventStream.Events);
                execute(goal);

                try
                {
                    _eventStore.AppendToStream(Id, eventStream.Version, goal.Changes);
                    return;
                }
                catch (OptimisticConcurrencyException ex)
                {
                    foreach (var goalEvent in goal.Changes)
                    {
                        foreach (var actualEvent in ex.ActualEvents)
                        {
                            if (ConflictsWith(goalEvent, actualEvent))
                            {
                                var msg = string.Format("Conflict between {0} and {1}",
                                    goalEvent, actualEvent);
                                throw new RealConcurrencyException(msg, ex);
                            }
                        }
                    }
                    _eventStore.AppendToStream(Id, ex.ActualVersion, goal.Changes);
                }
            }
        }
 public bool IsValidUser(GoalId goalId, string user)
 {
     Maybe<UserGoalsView> view;
     view = _reader.Get(goalId);
     if (!view.HasValue) return false;
     return view.Value.User.Equals(user);
 }
        public void Update(GoalId Id, Action <GoalAggreagate> execute)
        {
            while (true)
            {
                EventStream    eventStream = _eventStore.LoadEventStream(Id);
                GoalAggreagate goal        = new GoalAggreagate(eventStream.Events);
                execute(goal);

                try
                {
                    _eventStore.AppendToStream(Id, eventStream.Version, goal.Changes);
                    return;
                }
                catch (OptimisticConcurrencyException ex)
                {
                    foreach (var goalEvent in goal.Changes)
                    {
                        foreach (var actualEvent in ex.ActualEvents)
                        {
                            if (ConflictsWith(goalEvent, actualEvent))
                            {
                                var msg = string.Format("Conflict between {0} and {1}",
                                                        goalEvent, actualEvent);
                                throw new RealConcurrencyException(msg, ex);
                            }
                        }
                    }
                    _eventStore.AppendToStream(Id, ex.ActualVersion, goal.Changes);
                }
            }
        }
Example #4
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 23, Configuration.FieldSeparator),
                       Id,
                       ActionCode,
                       ActionDateTime.HasValue ? ActionDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       GoalId?.ToDelimitedString(),
                       GoalInstanceId?.ToDelimitedString(),
                       EpisodeOfCareId?.ToDelimitedString(),
                       GoalListPriority.HasValue ? GoalListPriority.Value.ToString(Consts.NumericFormat, culture) : null,
                       GoalEstablishedDateTime.HasValue ? GoalEstablishedDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ExpectedGoalAchieveDateTime.HasValue ? ExpectedGoalAchieveDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       GoalClassification?.ToDelimitedString(),
                       GoalManagementDiscipline?.ToDelimitedString(),
                       CurrentGoalReviewStatus?.ToDelimitedString(),
                       CurrentGoalReviewDateTime.HasValue ? CurrentGoalReviewDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       NextGoalReviewDateTime.HasValue ? NextGoalReviewDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       PreviousGoalReviewDateTime.HasValue ? PreviousGoalReviewDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       GoalReviewInterval,
                       GoalEvaluation?.ToDelimitedString(),
                       GoalEvaluationComment != null ? string.Join(Configuration.FieldRepeatSeparator, GoalEvaluationComment) : null,
                       GoalLifeCycleStatus?.ToDelimitedString(),
                       GoalLifeCycleStatusDateTime.HasValue ? GoalLifeCycleStatusDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       GoalTargetType != null ? string.Join(Configuration.FieldRepeatSeparator, GoalTargetType.Select(x => x.ToDelimitedString())) : null,
                       GoalTargetName != null ? string.Join(Configuration.FieldRepeatSeparator, GoalTargetName.Select(x => x.ToDelimitedString())) : null,
                       MoodCode?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Example #5
0
        public bool HasGoalBeenCreated(GoalId goalId)
        {
            Maybe <UserGoalsView> view;

            view = _reader.Get(goalId);
            return(view.HasValue);
        }
Example #6
0
        public override byte[] Serialize(bool partofsomethingelse)
        {
            List <byte[]> pieces = new List <byte[]>();

            if (Header == null)
            {
                Header = new Messages.std_msgs.Header();
            }
            pieces.Add(Header.Serialize(true));

            if (GoalId == null)
            {
                GoalId = new Messages.actionlib_msgs.GoalID();
            }
            pieces.Add(GoalId.Serialize(true));

            if (Goal == null)
            {
                Goal = new TGoal();
            }
            pieces.Add(Goal.Serialize(true));

            // combine every array in pieces into one array and return it
            int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length);
            int __a_b__e = 0;

            byte[] __a_b__d = new byte[__a_b__f];
            foreach (var __p__ in pieces)
            {
                Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length);
                __a_b__e += __p__.Length;
            }
            return(__a_b__d);
        }
Example #7
0
 public void SetGoal(GoalId id, string description, DateTime startDate, int lengthOfGoalInDays, string user)
 {
     if (_state.Created)
     {
         throw new InvalidOperationException("Goal Already Set");
     }
     Apply(new GoalSet(id, description, startDate, lengthOfGoalInDays, user));
 }
 public DailyTaskScheduled(DailyTaskId id, GoalId goalId, DateTime taskDate, string description, string user)
 {
     this.Id = id;
     this.GoalId = goalId;
     this.TaskDate = taskDate;
     this.Description = description;
     this.User = user;
 }
        public void AssignDailyTask(DailyTaskId id,GoalId goalId,DateTime taskDate,string description, string user)
        {
            if (!goalService.HasGoalBeenCreated(goalId)) throw new InvalidOperationException("Goal Has not been created");
            if (_state.Created) throw new InvalidOperationException("This Task has already been assigned.");
            if (!goalService.IsValidUser(goalId, user)) throw new InvalidOperationException("You are not not assign tasks to this goal.");

            Apply(new DailyTaskScheduled(id,goalId,taskDate,description, user));
        }
Example #10
0
 public DailyTaskScheduled(DailyTaskId id, GoalId goalId, DateTime taskDate, string description, string user)
 {
     this.Id          = id;
     this.GoalId      = goalId;
     this.TaskDate    = taskDate;
     this.Description = description;
     this.User        = user;
 }
Example #11
0
 public GoalSet(GoalId Id, string description, DateTime startDate, int lengthOfGoalInDays, string user)
 {
     this.Id                 = Id;
     this.Description        = description;
     this.StartDate          = startDate;
     this.LengthOfGoalInDays = lengthOfGoalInDays;
     this.User               = user;
 }
Example #12
0
        public bool IsValidUser(GoalId goalId, string user)
        {
            Maybe <UserGoalsView> view;

            view = _reader.Get(goalId);
            if (!view.HasValue)
            {
                return(false);
            }
            return(view.Value.User.Equals(user));
        }
Example #13
0
        public bool Equals(GoalActionMessage <TGoal> message)
        {
            if (message == null)
            {
                return(false);
            }

            bool result = true;

            result &= Header.Equals(message.Header);
            result &= GoalId.Equals(message.GoalId);
            result &= Goal.Equals(message.Goal);

            return(result);
        }
Example #14
0
        public void AssignDailyTask(DailyTaskId id, GoalId goalId, DateTime taskDate, string description, string user)
        {
            if (!goalService.HasGoalBeenCreated(goalId))
            {
                throw new InvalidOperationException("Goal Has not been created");
            }
            if (_state.Created)
            {
                throw new InvalidOperationException("This Task has already been assigned.");
            }
            if (!goalService.IsValidUser(goalId, user))
            {
                throw new InvalidOperationException("You are not not assign tasks to this goal.");
            }

            Apply(new DailyTaskScheduled(id, goalId, taskDate, description, user));
        }
Example #15
0
    // Start is called before the first frame update
    void Start()
    {
        int    i  = (int.Parse(this.gameObject.name.Substring(7)) - 1);
        GoalId id = (GoalId)i;

        this.gameObject.GetComponentInChildren <Text>().text = id.ToString();
        Debug.Log("画像の名前" + ("Images/Animal" + i));

        this.gameObject.GetComponent <Button>().image.sprite = Resources.Load <Sprite>("Images/Animal" + i);
        image = this.gameObject.GetComponent <Button>().image;
        MainSpriteRenderer = gameObject.GetComponent <SpriteRenderer>();
        var colors = this.gameObject.GetComponent <Button>().colors;

        colors.normalColor      = colors4[(int)myKey];
        colors.highlightedColor = colors4[(int)myKey];
        colors.pressedColor     = colors4[(int)myKey];
        colors.selectedColor    = colors4[(int)myKey];
        colors.disabledColor    = colors4[(int)myKey];
        // this.gameObject.GetComponent<Button>().colors = colors;
        pressflag = false;
    }
Example #16
0
 public override void Randomize()
 {
     Header.Randomize();
     GoalId.Randomize();
     Goal.Randomize();
 }
 public bool HasGoalBeenCreated(GoalId goalId)
 {
     Maybe<UserGoalsView> view;
     view = _reader.Get(goalId);
     return view.HasValue;
 }
 public SetGoal(GoalId Id, string description, DateTime startDate, int lengthOfGoalInDays, string user)
 {
     this.Id = Id;
     this.Description = description;
     this.StartDate = startDate;
     this.LengthOfGoalInDays = lengthOfGoalInDays;
     this.User = user;
 }
 public void SetGoal(GoalId id, string description, DateTime startDate, int lengthOfGoalInDays, string user)
 {
     if (_state.Created) throw new InvalidOperationException("Goal Already Set");
     Apply(new GoalSet(id, description, startDate, lengthOfGoalInDays,user));
 }