Пример #1
0
        }                                          // Index in PostsList

        public AccountXDataDetails Add(AccountXDataDetails other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            PostsCount          += other.PostsCount;
            PostsVirtualsCount  += other.PostsVirtualsCount;
            PostsClearedCount   += other.PostsClearedCount;
            PostsLast7Count     += other.PostsLast7Count;
            PostsLast30Count    += other.PostsLast30Count;
            PostsThisMountCount += other.PostsThisMountCount;

            if (!EarliestPost.IsValid() || (other.EarliestPost.IsValid() && other.EarliestPost < EarliestPost))
            {
                EarliestPost = other.EarliestPost;
            }
            if (!EarliestClearedPost.IsValid() || (other.EarliestClearedPost.IsValid() && other.EarliestClearedPost < EarliestClearedPost))
            {
                EarliestClearedPost = other.EarliestClearedPost;
            }

            if (!LatestPost.IsValid() || (other.LatestPost.IsValid() && other.LatestPost > LatestPost))
            {
                LatestPost = other.LatestPost;
            }
            if (!LatestClearedPost.IsValid() || (other.LatestClearedPost.IsValid() && other.LatestClearedPost > LatestClearedPost))
            {
                LatestClearedPost = other.LatestClearedPost;
            }

            _Filenames.UnionWith(other.Filenames);
            _AccountsReferenced.UnionWith(other.AccountsReferenced);
            _PayeesReferenced.UnionWith(other.PayeesReferenced);

            return(this);
        }
Пример #2
0
        public void Update(Post post, bool gatherAll = false)
        {
            if (post == null)
            {
                throw new ArgumentNullException("post");
            }

            PostsCount++;

            if (post.Flags.HasFlag(SupportsFlagsEnum.POST_COST_VIRTUAL))
            {
                PostsVirtualsCount++;
            }

            if (gatherAll && post.HasPos)
            {
                _Filenames.Add(post.Pos.PathName);
            }

            Date date = post.GetDate();

            if (date.Year == TimesCommon.Current.CurrentDate.Year && date.Month == TimesCommon.Current.CurrentDate.Month)
            {
                PostsThisMountCount++;
            }

            if ((TimesCommon.Current.CurrentDate - date).Days <= 30)
            {
                PostsLast30Count++;
            }
            if ((TimesCommon.Current.CurrentDate - date).Days <= 7)
            {
                PostsLast7Count++;
            }

            if (!EarliestPost.IsValid() || date < EarliestPost)
            {
                EarliestPost = date;
            }
            if (!LatestPost.IsValid() || date > LatestPost)
            {
                LatestPost = date;
            }

            if (post.Checkin.HasValue && (EarliestCheckin.IsNotADateTime() || post.Checkin.Value < EarliestCheckin))
            {
                EarliestCheckin = post.Checkin.Value;
            }

            if (post.Checkout.HasValue && (LatestCheckout.IsNotADateTime() || post.Checkout.Value > LatestCheckout))
            {
                LatestCheckout        = post.Checkout.Value;
                LatestCheckoutCleared = post.State == ItemStateEnum.Cleared;
            }

            if (post.State == ItemStateEnum.Cleared)
            {
                PostsClearedCount++;

                if (!EarliestClearedPost.IsValid() || date < EarliestClearedPost)
                {
                    EarliestClearedPost = date;
                }
                if (!LatestClearedPost.IsValid() || date > LatestClearedPost)
                {
                    LatestClearedPost = date;
                }
            }

            if (gatherAll)
            {
                _AccountsReferenced.Add(post.Account.FullName);
                _PayeesReferenced.Add(post.Payee);
            }
        }