コード例 #1
2
        public System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> GetGroupedRelatedItems(AccountItem itemCompareTo, bool searchingOnlyCurrentMonthData = true, System.Action<AccountItem> itemAdded = null)
        {
            System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> list = new System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel>();
            IOrderedEnumerable<AccountItem> source = from p in this.GetRelatedItems(itemCompareTo, searchingOnlyCurrentMonthData)
                                                     orderby p.CreateTime descending
                                                     select p;
            if (itemAdded == null)
            {
                itemAdded = delegate(AccountItem ai)
                {
                };
            }

            var dates = (from p in source select p.CreateTime.Date).Distinct<System.DateTime>();

            foreach (var item in dates)
            {
                GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item);

                source.Where(p => p.CreateTime.Date == item.Date).ToList<AccountItem>().ForEach(delegate(AccountItem x)
                {
                    agvm.Add(x);
                    itemAdded(x);
                });
                list.Add(agvm);
            }

            return list;
        }
コード例 #2
0
        public virtual void Load()
        {
            ViewModeConfig viewModeInfo = this.viewModeInfo;
            System.Collections.Generic.List<AccountItem> data = this.LoadingDataHandler(viewModeInfo, this.AccountItemType).ToList<AccountItem>();
            System.Collections.Generic.IEnumerable<DateTime> dates = (from p in data select p.CreateTime.Date).Distinct<System.DateTime>();
            GlobalIndicator.Instance.BusyForWork(AppResources.NowLoadingFormatter.FormatWith(new object[] { LocalizedStrings.GetCombinedText(this.AccountItemType.ToString(), "Record", true) }), new object[0]);
            Deployment.Current.Dispatcher.BeginInvoke(delegate
            {
                this.GroupItems.Clear();
                  
                foreach (var item in dates)
                {
                    GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item);

                    data.Where(p => p.CreateTime.Date == item.Date).ToList().ForEach(x => agvm.Add(x));

                    GroupItems.Add(agvm);
                }

                foreach (GroupByCreateTimeAccountItemViewModel model in this.GroupItems)
                {
                    foreach (AccountItem item in model)
                    {
                        item.RaisePropertyChangd(AccountItem.DescriptionWithPictureInfoProperty);
                    }
                }

                GlobalIndicator.Instance.WorkDone();
                this.IsDataLoaded = true;
            });
        }
コード例 #3
0
        public System.Collections.Generic.IEnumerable<GroupByCreateTimeAccountItemViewModel> GetGroupedRelatedItems(TallySchedule itemCompareTo, bool searchingOnlyCurrentMonthData = true, System.Action<AccountItem> itemAdded = null)
        {
            System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> list = new System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel>();
            IOrderedEnumerable<AccountItem> source = from p in this.GetRelatedItems(itemCompareTo, searchingOnlyCurrentMonthData)
                                                     orderby p.CreateTime descending
                                                     select p;
            if (itemAdded == null)
            {
                itemAdded = (ai) =>
                {
                };
            }

            foreach (var item in (from p in source select p.CreateTime.Date).Distinct<System.DateTime>())
            {
                GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item);

                (from p in source.Where<AccountItem>(p => p.CreateTime.Date == item.Date)
                 orderby p.Money
                 select p)
                 .ToList<AccountItem>()
                 .ForEach((x) =>
                 {
                     agvm.Add(x);
                     itemAdded(x);
                 });

                list.Add(agvm);
            }



            this.HasLoadAssociatedItemsForCurrentViewAccount = true;
            return list;
        }
コード例 #4
0
        public System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> LoadAssociatedItemsForAccount(
            Account itemCompareToCurrent, ObservableCollection<GroupByCreateTimeAccountItemViewModel> out_container)
        {
            HasLoadAssociatedItemsForCurrentViewAccount = true;

            var container = new List<GroupByCreateTimeAccountItemViewModel>();

            int recordCount = 0;
            var eachCount = 0;

            Action<int, string> showRecordTips = (count, name) =>
            {
                recordCount += count;
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    mangoProgressIndicator.GlobalIndicator.Instance.BusyForWork(AppResources.NowLoadingFormatter.FormatWith(AppResources.RecordCountTipsFormatter.FormatWith(count, name)));
                });

            };


            if (searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All
                || searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.Transcations)
            {
                var accountItemsData = ViewModelLocator.AccountItemViewModel
                    .AccountBookDataContext.AccountItems.Where(p => p.AccountId == itemCompareToCurrent.Id);

                if (searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All)
                {
                    accountItemsData = accountItemsData.Where(p => p.CreateTime.Date >= searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date
                                           && p.CreateTime.Date <= searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date);
                }

                accountItemsData = accountItemsData.OrderByDescending(p => p.Type)
                .OrderByDescending(p => p.CreateTime.Date);

                eachCount = accountItemsData.Count();

                showRecordTips(eachCount, AppResources.SelectAccountItemsLabel);

                var dates = accountItemsData.Select(p => p.CreateTime.Date).Distinct().ToList();
                foreach (var item in dates)
                {
                    var agvm = new GroupByCreateTimeAccountItemViewModel(item);
                    accountItemsData.Where(p => p.CreateTime.Date == item.Date)
                        .ForEach(x =>
                        {
                            var cx = new AccountItem();
                            cx.Account = x.Account;
                            cx.Money = x.Money;
                            cx.CreateTime = x.CreateTime;
                            cx.Category = x.Category;
                            cx.CategoryId = x.CategoryId;
                            cx.Description = x.Description;
                            cx.Id = x.Id;
                            cx.State = x.State;
                            cx.Type = x.Type;

                            cx.TypeInfo = LocalizedStrings.GetLanguageInfoByKey(x.Type.ToString());
                            if (x.Type == ItemType.Expense)
                                cx.Money = -x.Money;
                            cx.SecondInfo = x.NameInfo;

                            cx.PageNameGetter = PictureInfo.AccountItemsTag;
                            cx.ThirdInfo = x.Description;
                            agvm.Add(cx);
                            //OnItemAdding(x);
                        });

                    container.Add(agvm);
                }
            }

            if (searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All
               || searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.TransferingAccount)
            {
                // load Transfering list.

                var transfering = ViewModelLocator.TransferingHistoryViewModel
                    .AccountBookDataContext.TransferingItems.Where(p => (p.ToAccountId == itemCompareToCurrent.Id || p.FromAccountId == itemCompareToCurrent.Id)
                      );

                if (searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All)
                {
                    transfering = transfering.Where(p => p.TransferingDate.Date >= searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date
                      && p.TransferingDate.Date <= searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date);
                }

                transfering = transfering.OrderByDescending(p => p.TransferingDate.Date);

                eachCount = transfering.Count();

                var exchange = AppResources.TransferingAccount;
                showRecordTips(eachCount, exchange);

                var dates = transfering.Select(p => p.TransferingDate.Date).Distinct().ToList();

                foreach (var item in dates)
                {
                    var agvm = container.FirstOrDefault(p => p.Key.Date == item.Date);
                    bool hasToAdd = false;
                    if (agvm == null)
                    {
                        hasToAdd = true;
                        agvm = new GroupByCreateTimeAccountItemViewModel(item);
                    }

                    transfering.Where(p => p.TransferingDate.Date == item.Date)
                        .ForEach(x =>
                        {
                            var warp = new AccountItem();
                            warp.Account = itemCompareToCurrent;

                            warp.TypeInfo = exchange;

                            bool isOut = x.FromAccountId == itemCompareToCurrent.Id;
                            warp.Money = isOut ? -x.Amount : x.Amount;

                            var key = isOut ?
                                (AppResources.RolloutToSomeAccountName.FormatWith(x.ToAccountName))
                                : (AppResources.TransferFromAccountName.FormatWith(x.FromAccountName));

                            warp.SecondInfo = key;

                            warp.ThirdInfo = x.Notes;
                            agvm.Add(warp);
                        });

                    if (hasToAdd)
                        container.Add(agvm);
                }
            }

            if (searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All
               || searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.BorrowAndLean)
            {
                // load Transfering list.

                var borrowLoans = ViewModelLocator.BorrowLeanViewModel
                    .AccountBookDataContext.Repayments.Where(p => (p.FromAccountId == itemCompareToCurrent.Id && p.RepaymentRecordType == RepaymentType.MoneyBorrowOrLeanRepayment));

                if (searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All)
                {
                    //borrowLoans = borrowLoans.Where(p => p.ExecuteDate.Value.Date >= searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date
                    //  && ((DateTime)p.ExecuteDate).Date <= searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date);
                }

                borrowLoans = borrowLoans.OrderByDescending(p => ((DateTime)p.ExecuteDate).Date);

                eachCount = borrowLoans.Count();
                var borrowLoanName = AppResources.BorrowAndLean;

                showRecordTips(eachCount, borrowLoanName);


                var dates = borrowLoans.Select(p => p.ExecuteDate.Value.Date).Distinct().ToList();

                foreach (var item in dates)
                {
                    var agvm = container.FirstOrDefault(p => p.Key.Date == item.Date);
                    bool hasToAdd = false;
                    if (agvm == null)
                    {
                        hasToAdd = true;
                        agvm = new GroupByCreateTimeAccountItemViewModel(item);
                    }

                    borrowLoans.Where(p => ((DateTime)p.ExecuteDate).Date == item.Date)
                        .ForEach(x =>
                        {
                            var warp = new AccountItem();
                            warp.Account = itemCompareToCurrent;
                            warp.Id = x.Id;

                            warp.TypeInfo = borrowLoanName;

                            bool isOut = x.BorrowOrLean == LeanType.LoanOut || x.BorrowOrLean == LeanType.Repayment;
                            warp.Money = isOut ? -x.Amount : x.Amount;

                            var key = x.BorrowLoanInfoWithoutAmountInfo;

                            warp.SecondInfo = key;

                            warp.PageNameGetter = x.IsRepaymentOrReceieve ? "RepaymentsTableForReceieveOrPayBack" : "Repayments";
                            warp.ThirdInfo = x.Notes;
                            agvm.Add(warp);
                        });

                    if (hasToAdd)
                        container.Add(agvm);
                }
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                container.OrderByDescending(p => p.Key).ToList()
                    .ForEach(out_container.Add);
            });

            return container;
        }
コード例 #5
0
        public System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> GetGroupedRelatedItems(System.Func<AccountItem, bool> searchingCondtion, bool searchingOnlyCurrentMonthData = true)
        {
            System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> list = new System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel>();
            IOrderedEnumerable<AccountItem> source = from p in this.AccountBookDataContext.AccountItems.Where<AccountItem>(searchingCondtion)
                                                     orderby p.CreateTime descending
                                                     select p;

            var dates = (from p in source select p.CreateTime.Date).Distinct<System.DateTime>();

            foreach (var item in dates)
            {
                GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item);

                source.Where(p => p.CreateTime.Date == item.Date).ToList<AccountItem>().ForEach(delegate(AccountItem x)
                {
                    agvm.Add(x);
                });
                list.Add(agvm);
            }
            return list;
        }
コード例 #6
0
        public System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> GetGroupedRelatedItems(System.Collections.Generic.IEnumerable<AccountItem> source, System.Action callBackWhenItemsAddedToGroup = null)
        {
            System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> list = new System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel>();
            IOrderedEnumerable<AccountItem> enumerable = from p in source
                                                         orderby p.CreateTime descending
                                                         select p;

            var dates = (from p in enumerable select p.CreateTime.Date).Distinct<System.DateTime>();

            foreach (var item in dates)
            {
                GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item);

                enumerable.Where(p => p.CreateTime.Date == item.Date).ToList().ForEach(x =>
                {
                    agvm.Add(x);
                    callBackWhenItemsAddedToGroup();
                });

                list.Add(agvm);
            }

            return list;
        }
コード例 #7
0
 public GroupByCreateTimeAccountItemViewModel FindGroup(ObservableCollection<GroupByCreateTimeAccountItemViewModel> container, System.DateTime time, bool createGroupIfNot = true)
 {
     GroupByCreateTimeAccountItemViewModel item = container.FirstOrDefault<GroupByCreateTimeAccountItemViewModel>(p => p.Key.Date == time.Date);
     if (item == null && createGroupIfNot)
     {
         item = new GroupByCreateTimeAccountItemViewModel(time);
         if (container.Count > 0)
         {
             container.Insert(0, item);
             return item;
         }
         container.Add(item);
     }
     return item;
 }
コード例 #8
0
        public System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> LoadAssociatedItemsForAccount(Account itemCompareToCurrent, ObservableCollection<GroupByCreateTimeAccountItemViewModel> out_container)
        {
            this.HasLoadAssociatedItemsForCurrentViewAccount = true;
            System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> container = new System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel>();
            int recordCount = 0;
            int num = 0;
            System.Action<Int32, String> action = delegate(int count, string name)
            {
                recordCount += count;
                Deployment.Current.Dispatcher.BeginInvoke(delegate
                {
                    GlobalIndicator.Instance.BusyForWork(AppResources.NowLoadingFormatter.FormatWith(new object[] { AppResources.RecordCountTipsFormatter.FormatWith(new object[] { count, name }) }), new object[0]);
                });
            };
            if ((this.searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All) || (this.searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.Transcations))
            {
                IQueryable<AccountItem> source = from p in ViewModelLocator.AccountItemViewModel.AccountBookDataContext.AccountItems
                                                 where p.AccountId == itemCompareToCurrent.Id
                                                 select p;
                if (this.searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All)
                {
                    source = from p in source
                             where (p.CreateTime.Date > this.searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date) && (p.CreateTime.Date <= this.searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date)
                             select p;
                }
                source = from p in source
                         orderby p.Type descending
                         select p into p
                         orderby p.CreateTime.Date descending
                         select p;
                num = source.Count<AccountItem>();
                action(num, AppResources.SelectAccountItemsLabel);
                using (System.Collections.Generic.List<DateTime>.Enumerator enumerator = (from p in source select p.CreateTime.Date).Distinct<System.DateTime>().ToList<System.DateTime>().GetEnumerator())
                {
                    System.DateTime item;
                    while (enumerator.MoveNext())
                    {
                        item = enumerator.Current;
                        GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item);
                        ((System.Collections.Generic.IEnumerable<AccountItem>)(from p in source
                                                                               where p.CreateTime.Date == item.Date
                                                                               select p)).ForEach<AccountItem>(delegate(AccountItem x)
                        {
                            AccountItem item1 = new AccountItem
                            {
                                Account = x.Account,
                                Money = x.Money,
                                CreateTime = x.CreateTime,
                                Category = x.Category,
                                CategoryId = x.CategoryId,
                                Description = x.Description,
                                Id = x.Id,
                                State = x.State,
                                PageNameGetter = "AccountItems",
                                Type = x.Type,
                                TypeInfo = LocalizedStrings.GetLanguageInfoByKey(x.Type.ToString())
                            };
                            if (x.Type == ItemType.Expense)
                            {
                                item1.Money = -x.Money;
                            }
                            item1.SecondInfo = x.NameInfo;
                            item1.ThirdInfo = x.Description;
                            agvm.Add(item1);
                        });
                        container.Add(agvm);
                    }
                }
            }
            if ((this.searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All) || (this.searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.TransferingAccount))
            {
                IQueryable<TransferingItem> queryable2 = from p in ViewModelLocator.TransferingHistoryViewModel.AccountBookDataContext.TransferingItems
                                                         where (p.ToAccountId == itemCompareToCurrent.Id) || (p.FromAccountId == itemCompareToCurrent.Id)
                                                         select p;
                if (this.searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope != SearchingScope.All)
                {
                    queryable2 = from p in queryable2
                                 where (p.TransferingDate.Date > this.searchingConditionForAssociatedItemsForCurrentViewAccount.StartDate.Value.Date) && (p.TransferingDate.Date <= this.searchingConditionForAssociatedItemsForCurrentViewAccount.EndDate.Value.Date)
                                 select p;
                }
                queryable2 = from p in queryable2
                             orderby p.TransferingDate.Date descending
                             select p;
                num = queryable2.Count<TransferingItem>();
                string exchange = AppResources.TransferingAccount;
                action(num, exchange);
                using (System.Collections.Generic.List<DateTime>.Enumerator enumerator2 = (from p in queryable2 select p.TransferingDate.Date).Distinct<System.DateTime>().ToList<System.DateTime>().GetEnumerator())
                {
                    System.Func<GroupByCreateTimeAccountItemViewModel, Boolean> predicate = null;
                    System.DateTime item;
                    while (enumerator2.MoveNext())
                    {
                        item = enumerator2.Current;
                        if (predicate == null)
                        {
                            predicate = p => p.Key.Date == item.Date;
                        }
                        GroupByCreateTimeAccountItemViewModel agvm = container.FirstOrDefault<GroupByCreateTimeAccountItemViewModel>(predicate);
                        bool flag = false;
                        if (agvm == null)
                        {
                            flag = true;
                            agvm = new GroupByCreateTimeAccountItemViewModel(item);
                        }
                        ((System.Collections.Generic.IEnumerable<TransferingItem>)(from p in queryable2
                                                                                   where p.TransferingDate.Date == item.Date
                                                                                   select p)).ForEach<TransferingItem>(delegate(TransferingItem x)
                        {
                            AccountItem item1 = new AccountItem
                            {
                                Account = itemCompareToCurrent,
                                TypeInfo = exchange
                            };
                            flag = x.FromAccountId == itemCompareToCurrent.Id;
                            item1.Money = flag ? -x.Amount : x.Amount;
                            string str = flag ? AppResources.RolloutToSomeAccountName.FormatWith(new object[] { x.ToAccountName }) : AppResources.TransferFromAccountName.FormatWith(new object[] { x.FromAccountName });
                            item1.SecondInfo = str;
                            item1.PageNameGetter = "TransferingItems";
                            item1.ThirdInfo = x.Notes;
                            agvm.Add(item1);
                        });
                        if (flag)
                        {
                            container.Add(agvm);
                        }
                    }
                }
            }
            if ((this.searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.All)
                || (this.searchingConditionForAssociatedItemsForCurrentViewAccount.DataType == AssociatedItemType.BorrowAndLean))
            {
                IQueryable<Repayment> queryable3 = from p in ViewModelLocator.BorrowLeanViewModel.AccountBookDataContext.Repayments
                                                   where (p.FromAccountId == itemCompareToCurrent.Id) && (((int?)p.RepaymentRecordType) == ((int?)RepaymentType.MoneyBorrowOrLeanRepayment))
                                                   select p;
                SearchingScope searchingScope = this.searchingConditionForAssociatedItemsForCurrentViewAccount.SearchingScope;
                queryable3 = from p in queryable3
                             orderby ((System.DateTime)p.ExecuteDate).Date descending
                             select p;
                num = queryable3.Count<Repayment>();
                string borrowLoanName = AppResources.BorrowAndLean;
                action(num, borrowLoanName);
                using (System.Collections.Generic.List<DateTime>.Enumerator enumerator3 = (from p in queryable3 select p.ExecuteDate.Value.Date).Distinct<System.DateTime>().ToList<System.DateTime>().GetEnumerator())
                {
                    System.Func<GroupByCreateTimeAccountItemViewModel, Boolean> func2 = null;
                    System.DateTime item;
                    while (enumerator3.MoveNext())
                    {
                        item = enumerator3.Current;
                        if (func2 == null)
                        {
                            func2 = p => p.Key.Date == item.Date;
                        }
                        GroupByCreateTimeAccountItemViewModel agvm = container.FirstOrDefault<GroupByCreateTimeAccountItemViewModel>(func2);
                        bool flag2 = false;
                        if (agvm == null)
                        {
                            flag2 = true;
                            agvm = new GroupByCreateTimeAccountItemViewModel(item);
                        }
                        ((System.Collections.Generic.IEnumerable<Repayment>)(from p in queryable3
                                                                             where ((System.DateTime)p.ExecuteDate).Date == item.Date
                                                                             select p)).ForEach<Repayment>(delegate(Repayment x)
                        {
                            LeanType? borrowOrLean = LeanType.BorrowIn;
                            AccountItem item1 = new AccountItem
                            {
                                Id = x.Id,
                                Account = itemCompareToCurrent,
                                TypeInfo = borrowLoanName
                            };

                            if (((LeanType)x.BorrowOrLean) != LeanType.LoanOut)
                            {
                                borrowOrLean = x.BorrowOrLean;
                            }
                            bool flag = (((LeanType)borrowOrLean.GetValueOrDefault()) != LeanType.Repayment) || borrowOrLean.HasValue;
                            item1.Money = flag ? -x.Amount : x.Amount;
                            string borrowLoanInfoWithoutAmountInfo = x.BorrowLoanInfoWithoutAmountInfo;
                            item1.PageNameGetter = x.IsRepaymentOrReceieve ? "RepaymentsTableForReceieveOrPayBack" : "Repayments";
                            item1.SecondInfo = borrowLoanInfoWithoutAmountInfo;
                            item1.ThirdInfo = x.Notes;
                            agvm.Add(item1);
                        });
                        if (flag2)
                        {
                            container.Add(agvm);
                        }
                    }
                }
            }
            Deployment.Current.Dispatcher.BeginInvoke(delegate
            {
                (from p in container
                 orderby p.Key descending
                 select p).ToList<GroupByCreateTimeAccountItemViewModel>().ForEach(new System.Action<GroupByCreateTimeAccountItemViewModel>(out_container.Add));
            });
            return container;
        }
コード例 #9
0
 public System.Collections.Generic.IEnumerable<GroupByCreateTimeAccountItemViewModel> GetGroupedRelatedItems(TallySchedule itemCompareTo, bool searchingOnlyCurrentMonthData = true, System.Action<AccountItem> itemAdded = null)
 {
     System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel> list = new System.Collections.Generic.List<GroupByCreateTimeAccountItemViewModel>();
     IOrderedEnumerable<AccountItem> source = from p in this.GetRelatedItems(itemCompareTo, searchingOnlyCurrentMonthData)
                                              orderby p.CreateTime descending
                                              select p;
     if (itemAdded == null)
     {
         itemAdded = delegate(AccountItem ai)
         {
         };
     }
     using (System.Collections.Generic.IEnumerator<DateTime> enumerator = (from p in source select p.CreateTime.Date).Distinct<System.DateTime>().GetEnumerator())
     {
         System.Func<AccountItem, Boolean> predicate = null;
         System.DateTime item;
         while (enumerator.MoveNext())
         {
             item = enumerator.Current;
             GroupByCreateTimeAccountItemViewModel agvm = new GroupByCreateTimeAccountItemViewModel(item);
             if (predicate == null)
             {
                 predicate = p => p.CreateTime.Date == item.Date;
             }
             (from p in source.Where<AccountItem>(predicate)
              orderby p.Money
              select p).ToList<AccountItem>().ForEach(delegate(AccountItem x)
             {
                 agvm.Add(x);
                 itemAdded(x);
             });
             list.Add(agvm);
         }
     }
     this.HasLoadAssociatedItemsForCurrentViewAccount = true;
     return list;
 }