Example #1
0
        public void TestDate1()
        {
            JObject json = new JObject
            {
                { "message", "2014-01-31 08:23:47,123" }
            };

            string grokJson = @"{  
            ""TimberWinR"":{        
                ""Filters"":[  
	                {  
		            ""date"":{                          
		                ""match"":[  
			                ""message"",
			                ""yyyy-MM-dd HH:mm:ss,fff""
		                ]	               
		            }
	                }]
                }
            }";

            Configuration c = Configuration.FromString(grokJson);

            DateFilter date = c.Filters.First() as DateFilter;

            Assert.IsTrue(date.Apply(json));

            var ts = json["@timestamp"].ToString();

            Assert.AreEqual(ts, "1/31/2014 8:23:47 AM");
        }
        public async Task <HttpResponseMessage> GetSpendingSummaryAsync(DateFilter dateFilter)
        {
            if (DateTime.TryParseExact(dateFilter.FromDateRange.ToString(), "dd-MM-yy", new CultureInfo("en-GB"), DateTimeStyles.None, out DateTime fromDateRange))
            {
                dateFilter.FromDateRange = fromDateRange;
            }

            if (DateTime.TryParseExact(dateFilter.ToDateRange.ToString(), "dd-MM-yy", new CultureInfo("en-GB"), DateTimeStyles.None, out DateTime toDateRange))
            {
                dateFilter.ToDateRange = toDateRange;
            }

            var spendingsSummary = await spendingService.GetSpendingSummary(dateFilter);

            var spendingsSummary2 = await spendingService.GetSpendingSummary(dateFilter, summaryOverview : true);

            var spendingsSummary3 = await spendingService.GetSpendingSummaryOverview(dateFilter);

            var spendingsOverview = spendingsSummary3.Concat(spendingsSummary2).OrderByDescending(x => x.Total);

            dateFilter.DateField = "PayDate";
            decimal fuelIn = await cnwService.GetFuelIn(dateFilter);

            return(Request.CreateResponse(HttpStatusCode.OK,
                                          new {
                SpendingSummary = spendingsSummary,
                SpendingSummaryOverview = spendingsOverview,
                TotalSpent = spendingsSummary.Sum(x => x.Total),
                FuelIn = fuelIn
            }
                                          ));
        }
Example #3
0
        private IFilterStrategy DetermineFilter(FilterOptions options)
        {
            IFilterStrategy filterStrategy = null;

            if (options.Filter == FilterBy.Name && !string.IsNullOrEmpty(options.Name))
            {
                filterStrategy = new NameFilter(options);
            }
            else if (options.Filter == FilterBy.Email && !string.IsNullOrEmpty(options.Email))
            {
                filterStrategy = new EmailFilter(options);
            }
            else if (options.Filter == FilterBy.Phone && !string.IsNullOrEmpty(options.Phone))
            {
                filterStrategy = new PhoneFilter(options);
            }
            else if (options.Filter == FilterBy.From && options.From.HasValue)
            {
                filterStrategy = new FromFilter(options);
            }
            else if (options.Filter == FilterBy.To && options.To.HasValue)
            {
                filterStrategy = new ToFilter(options);
            }
            else if (options.Filter == FilterBy.Status)
            {
                filterStrategy = new StatusFIlter(options);
            }
            else if (options.Filter == FilterBy.Date && options.Date.HasValue)
            {
                filterStrategy = new DateFilter(options);
            }

            return(filterStrategy);
        }
Example #4
0
 public InquiriesVisitor(Accountant accountant, DateFilter rng, string baseCurrency, IEntitiesSerializer serializer)
 {
     m_Accountant   = accountant;
     m_BaseCurrency = baseCurrency;
     m_Serializer   = serializer;
     m_Rng          = rng;
 }
Example #5
0
        public async Task <decimal> GetFuelIn(DateFilter dateFilter)
        {
            var rates = await cnwRatesRepository.GetAsync();

            return((await cnwPaymentsRepository.GetAllAsync(dateFilter))
                   .Sum(x => rates.Mileage * x.ActualMiles) ?? 0);
        }
Example #6
0
        public void ShouldDisplayEventsBeetwenTwoDate()
        {
            IOConsole toDisplay = new IOConsole();

            string expectedConsole;
            var    consoleOut = new StringWriter();

            Events newEvents = new Events {
                { new Event("2015/01/01", "one", "test") },
                { new Event("2015/11/15", "two") },
                { new Event("2015/07/01", "three") },
                { new Event("2015/12/03", "four", "test1") },
                { new Event("2015/03/04", "five", "test2") },
                { new Event("2015/09/08", "six") }
            };

            SetExpectedResultToConsole("2015/09/08", "six", out expectedConsole, out consoleOut);

            DateFilter firstFilter       = new DateFilter("<", "2015/10/25");
            Events     firstFilteredList = firstFilter.ApplyFilter((newEvents));
            DateFilter eventsToDisplay   = new DateFilter(">", "2015/02/25");
            Events     filteredList      = eventsToDisplay.ApplyFilter(firstFilteredList);

            IOConsole newObj = new IOConsole(filteredList);

            newObj.DisplayEventsToConsole();
            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Example #7
0
        public void ShouldDisplayEventsFromCertainDate()
        {
            Events    newEvents = new Events();
            IOConsole toDisplay = new IOConsole();

            string expectedConsole;
            var    consoleOut = new StringWriter();

            string date        = "2019/12/25";
            string title       = "Christmas Day!";
            string description = "Santa Claus is comming in our house....";

            string date1        = "2015/10/25";
            string title1       = "Johana's Birtday!";
            string description1 = "Don't forget to call her...";

            SetExpectedResultToConsole(date1, title1, out expectedConsole, out consoleOut, description1);

            newEvents.EventsList.ShouldBeEmpty();
            newEvents.Add(date, title, description);
            newEvents.Add(date1, title1, description1);

            DateFilter eventsToDisplay = new DateFilter("=", "2015/10/25");
            Events     filteredList    = eventsToDisplay.ApplyFilter(newEvents);

            IOConsole newObj = new IOConsole(filteredList);

            newObj.DisplayEventsToConsole();
            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Example #8
0
        public JsonResult DeliverWithinDays(string days)
        {
            var deliveries = DateFilter.getDeliveriesWithinDays(company.Deliveries.ToList(), Convert.ToInt32(days));
            var routes     = DateFilter.getRoutesWithinDays(company.Routes.ToList(), Convert.ToInt32(days));

            Response.StatusCode = (int)HttpStatusCode.OK;
            List <ShipperSingleDeliveryMapViewModel> delsWithAddress = new List <ShipperSingleDeliveryMapViewModel>();

            foreach (Delivery delivery in deliveries)
            {
                ShipperSingleDeliveryMapViewModel model = new ShipperSingleDeliveryMapViewModel();
                model.Client        = delivery.Client;
                model.addressString = DirectionsService.getStringFromAddress(delivery.Client.Address);
                model.ID            = delivery.ID;

                string clientName      = delivery.Client.FirstName + " " + delivery.Client.LastName;
                string currentStatus   = StatusExtension.DisplayName(delivery.DeliveryStatus.Status);
                string deliverByDate   = delivery.DeliverBy.Value.Date.ToString();
                string deliverByString = deliverByDate.Substring(0, deliverByDate.IndexOf(" "));

                model.clientName    = clientName;
                model.currentStatus = currentStatus;
                model.deliverBy     = deliverByString;
                delsWithAddress.Add(model);
            }
            MapObjects result = new MapObjects(deliveries, routes, delsWithAddress, company);

            return(Json(result));
        }
Example #9
0
        public async Task <IActionResult> GetByDate(DateFilter dateFilter, int pageNumber, string returnUrl)
        {
            var messageSourse = await _messageOperationService.FilterByDate(dateFilter);

            var count  = messageSourse.Count();
            var result = messageSourse.Skip((pageNumber - 1) * PAGE_SIZE).Take(PAGE_SIZE).ToList();
            var user   = await _userManager.FindByEmailAsync(User.Identity.Name);

            for (int i = 0; i < result.Count; i++)
            {
                if (result[i].UserId != null)
                {
                    if (result[i].User == null)
                    {
                        result[i].User = await _userManager.FindByIdAsync(result[i].UserId.ToString());
                    }
                }
            }

            PageViewModel pageViewModel = new PageViewModel(count, pageNumber, PAGE_SIZE);
            TaskViewModel model         = new TaskViewModel
            {
                Tasks         = result,
                CurrentUser   = user,
                PageViewModel = pageViewModel
            };

            return(View("Index", model));
        }
Example #10
0
        public void PassesFilter_WithStringArguments_ReturnsExpected(string toTest, bool expected)
        {
            var filter = new DateFilter(DateFilter.DateFilterMethods.Greater, MiddleDate);
            var result = filter.PassesFilter(toTest);

            Assert.Equal(expected, result);
        }
Example #11
0
 public void Setup()
 {
     _filter     = new DateFilter();
     _bag        = new PropertyBag();
     _date       = DateTime.Now;
     _parameters = new [] { "" };
 }
Example #12
0
        public async Task <IViewComponentResult> InvokeAsync(IndexFiltersToShow filtersToShow)
        {
            var indexFiltersResult = new IndexFilterResult();

            if (filtersToShow.ShowCompaniesFlt)
            {
                indexFiltersResult.CompanyFilterValues = await FiltersHelper.GetCompaniesFilterListAsync(_context);
            }
            if (filtersToShow.ShowCurrencyFlt)
            {
                indexFiltersResult.CurrencyFilterValues = await FiltersHelper.GetCurrenciesFilterListAsync(_context);
            }
            if (filtersToShow.ShowDateFlt)
            {
                indexFiltersResult.DateFilterValues = DateFilter.GetDateFiltersSelectList();
            }
            if (filtersToShow.ShowPageSizeFlt)
            {
                indexFiltersResult.PageSizeFilterValues = FiltersHelper.GetPageSizeFiltersSelectList();
            }
            if (filtersToShow.ShowMaterialNatureFlt)
            {
                indexFiltersResult.MaterialNaturesFilterValues = FiltersHelper.GetWarehouseItemNaturesList();
            }
            if (filtersToShow.ShowTransactorTypeFlt)
            {
                indexFiltersResult.TransactorTypeFilterValues = await FiltersHelper.GetTransactorTypeFilterListAsync(_context);
            }

            indexFiltersResult.FiltersToShow = filtersToShow;
            return(View(indexFiltersResult));
        }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="View" /> class.
        /// </summary>
        public View()
            : base(HtmlTextWriterTag.Div)
        {
            _presenter        = new Presenter(this);
            _categoryDropDown = new DropDownList()
            {
                DataTextField  = "Name",
                DataValueField = "Id"
            };

            _dateFilter        = new DateFilter();
            _generateXMLButton = new Button()
            {
                Text = ResourceHelper.GetString("GenerateXMLButtonText")
            };

            _generateXMLButton.Click += GenerateXMLButton_Click;
            _questionRepeater         = new Repeater()
            {
                ItemTemplate = new QuestionItemTemplate()
                {
                    CheckBoxText = ResourceHelper.GetString("QuestionViewCheckboxText")
                }
            };
        }
Example #14
0
 public StructuredLogViewModel()
 {
     DateFilter             = new DateFilter();
     DateFilter.OnChanged  += DateFilter_OnChanged;
     LevelFilter            = new LevelFilter();
     LevelFilter.OnChanged += LevelFilter_OnChanged;
 }
Example #15
0
        public void ShouldSelectEventsOlderAndEqualThanSpecifiedPeriod()
        {
            Events newEvents = new Events {
                { new Event("2015/01/01", "one", "test") },
                { new Event("2015/11/15", "two") },
                { new Event("2015/07/01", "three") },
                { new Event("2015/12/03", "four", "test1") },
                { new Event("2015/03/04", "five", "test2") },
                { new Event("2015/09/08", "six") },
                { new Event("2015/10/25", "seven") }
            };

            List <Event> expectedList = new List <Event>
            {
                { new Event("2015/01/01", "one", "test") },
                { new Event("2015/07/01", "three") },
                { new Event("2015/03/04", "five", "test2") },
                { new Event("2015/09/08", "six") },
                { new Event("2015/10/25", "seven") }
            };

            DateFilter filteredListResult = new DateFilter("<=", "2015/10/25");
            Events     filteredList       = filteredListResult.ApplyFilter(newEvents);

            Utils.AssertAreEqual(filteredList, expectedList);
        }
        public override ICollection <EntryStatsView> GetPopularEntries(int blogId, DateFilter filter)
        {
            DateTime?minDate = null;

            if (filter == DateFilter.LastMonth)
            {
                minDate = CurrentDateTime.AddMonths(-1);
            }
            else if (filter == DateFilter.LastWeek)
            {
                minDate = CurrentDateTime.AddDays(-7);
            }
            else if (filter == DateFilter.LastYear)
            {
                minDate = CurrentDateTime.AddYears(-1);
            }

            using (IDataReader reader = _procedures.GetPopularPosts(BlogId, minDate))
            {
                return(reader.ReadCollection(r =>
                {
                    var entry = r.ReadEntryStatsView();
                    entry.PostType = PostType.BlogPost;
                    return entry;
                }));
            }
        }
Example #17
0
        public void AddFilter_AddDateFilterToEmptyList_AddsFilterToList()
        {
            DateFilter dateFilter = new DateFilter(DateTime);

            FilterList.AddFilter(dateFilter);
            Assert.Contains(dateFilter, FilterList.GetFilters());
        }
Example #18
0
        public static DateFilter DateRange(int day)
        {
            DateFilter the;
            var        now = ClientDateTime.Today;

            if (day == 0)
            {
                return(new DateFilter(
                           new DateTime(now.Year, now.Month, 1, 0, 0, 0, DateTimeKind.Utc),
                           new DateTime(now.Year, now.Month, 1, 0, 0, 0, DateTimeKind.Utc).AddMonths(1).AddDays(-1)));
            }

            if (now.Day > day)
            {
                the = new DateFilter(
                    new DateTime(now.Year, now.Month, day + 1, 0, 0, 0, DateTimeKind.Utc),
                    new DateTime(now.Year, now.Month, day, 0, 0, 0, DateTimeKind.Utc).AddMonths(1));
            }
            else
            {
                the = new DateFilter(
                    new DateTime(now.Year, now.Month, day + 1, 0, 0, 0, DateTimeKind.Utc).AddMonths(-1),
                    new DateTime(now.Year, now.Month, day, 0, 0, 0, DateTimeKind.Utc));
            }
            return(the);
        }
Example #19
0
    /// <inheritdoc />
    protected override async IAsyncEnumerable <string> ExecuteUnregister(
        IQueryCompounded <IDistributedQueryAtom> distQuery, DateFilter rng,
        IQueryCompounded <IVoucherQueryAtom> query, Session session)
    {
        await foreach (var a in Sort(session.Accountant.SelectAmortizationsAsync(distQuery)))
        {
            foreach (var item in a.Schedule.Where(item => item.Date.Within(rng)))
            {
                if (query != null)
                {
                    if (item.VoucherID == null)
                    {
                        continue;
                    }

                    var voucher = await session.Accountant.SelectVoucherAsync(item.VoucherID);

                    if (voucher != null)
                    {
                        if (!MatchHelper.IsMatch(query, voucher.IsMatch))
                        {
                            continue;
                        }
                    }
                }

                item.VoucherID = null;
            }

            yield return(await ListAmort(a, session));

            await session.Accountant.UpsertAsync(a);
        }
    }
Example #20
0
        private void LoadFilters()
        {
            var datePeriods = DateFilter.GetDateFiltersSelectList();

            // var datePeriodsJs = DateFilter.GetDateFiltersSelectList();

            ViewData["DataFilterValues"] = new SelectList(datePeriods, "Value", "Text");
            var pageFilterSize = PageFilter.GetPageSizeFiltersSelectList();

            ViewData["PageFilterSize"] = new SelectList(pageFilterSize, "Value", "Text");

            var dbCompanies = _context.Companies.OrderBy(p => p.Code).AsNoTracking();
            List <SelectListItem> companiesList = new List <SelectListItem>();

            companiesList.Add(new SelectListItem()
            {
                Value = 0.ToString(), Text = "{All Companies}"
            });
            foreach (var company in dbCompanies)
            {
                companiesList.Add(new SelectListItem()
                {
                    Value = company.Id.ToString(), Text = company.Code
                });
            }
            ViewData["CompanyFilter"] = new SelectList(companiesList, "Value", "Text");
        }
Example #21
0
        /// <inheritdoc />
        protected override IQueryResult ExecuteResetSoft(IQueryCompunded <IDistributedQueryAtom> distQuery,
                                                         DateFilter rng)
        {
            var cnt = 0L;

            foreach (var a in Accountant.SelectAssets(distQuery))
            {
                if (a.Schedule == null)
                {
                    continue;
                }

                var flag = false;
                foreach (var item in a.Schedule.Where(item => item.Date.Within(rng))
                         .Where(item => item.VoucherID != null)
                         .Where(item => Accountant.SelectVoucher(item.VoucherID) == null))
                {
                    item.VoucherID = null;
                    cnt++;
                    flag = true;
                }

                if (flag)
                {
                    Accountant.Upsert(a);
                }
            }

            return(new NumberAffected(cnt));
        }
Example #22
0
        public IActionResult Index()
        {
            var deliveries = DateFilter.getDeliveriesWithinDays(company.Deliveries.ToList(), 2);
            var depots     = company.PickUpLocations.ToList();
            List <ShipperSingleDeliveryMapViewModel> delsWithAddress = new List <ShipperSingleDeliveryMapViewModel>();

            foreach (Delivery delivery in deliveries)
            {
                ShipperSingleDeliveryMapViewModel model = new ShipperSingleDeliveryMapViewModel();
                model.Client        = delivery.Client;
                model.addressString = DirectionsService.getStringFromAddress(delivery.Client.Address);
                model.ID            = delivery.ID;

                string clientName      = delivery.Client.FirstName + " " + delivery.Client.LastName;
                string currentStatus   = StatusExtension.DisplayName(delivery.DeliveryStatus.Status);
                string deliverByDate   = delivery.DeliverBy.Value.Date.ToString();
                string deliverByString = deliverByDate.Substring(0, deliverByDate.IndexOf(" "));

                model.clientName    = clientName;
                model.currentStatus = currentStatus;
                model.deliverBy     = deliverByString;
                delsWithAddress.Add(model);
            }
            MapObjects objects = new MapObjects(deliveries, depots, company.Routes.ToList(), delsWithAddress, company);

            return(View(objects));
        }
Example #23
0
        /// <summary>
        ///     从上次计息日后一日起计算单利利息并整理还款
        /// </summary>
        /// <param name="info">借款信息</param>
        /// <param name="capitalIntegral">剩余本金</param>
        /// <param name="interestIntegral">剩余利息</param>
        /// <param name="lastSettlement">上次计息日</param>
        /// <param name="finalDay">截止日期</param>
        private void Regularize(LoanInfo info, ref double capitalIntegral, ref double interestIntegral,
            DateTime? lastSettlement, DateTime finalDay)
        {
            var capitalPattern = info.AsCapital();
            var interestPattern = info.AsInterest();
            DateFilter rng = lastSettlement.HasValue
                ? new(lastSettlement.Value.AddDays(1), finalDay)
                : new(null, finalDay);
            foreach (var grp in
                Accountant
                    .RunVoucherQuery($"{info.QueryMajor()} {rng.AsDateRange()}")
                    .GroupBy(v => v.Date)
                    .OrderBy(grp => grp.Key, new DateComparer()))
            {
                var key = grp.Key ?? throw new ApplicationException("无法处理无穷长时间以前的利息收入");

                lastSettlement ??= key;

                // Settle Interest
                interestIntegral += SettleInterest(
                    info,
                    capitalIntegral,
                    key.Subtract(lastSettlement.Value).Days,
                    grp.SingleOrDefault(
                        v =>
                            v.Details.Any(d => d.IsMatch(interestPattern, Dir())))
                    ?? new() { Date = key, Details = new() });
Example #24
0
        public void PassesFilter_WithEarlierDateAndSmallerMethod_ReturnsTrue()
        {
            var filter = new DateFilter(DateFilter.DateFilterMethods.Smaller, MiddleDate);
            var result = filter.PassesFilter(EarlyDate);

            Assert.True(result);
        }
Example #25
0
        protected override void ReadHeader(StreamReader sr)
        {
            base.ReadHeader(sr);

            string filterType;

            while ((filterType = sr.ReadLine()) != null)
            {
                Filter filter = null;

                switch (filterType)
                {
                case "StringFilter":
                    filter = new StringFilter(sr);
                    break;

                case "RatingFilter":
                    filter = new RatingFilter(sr);
                    break;

                case "DateFilter":
                    filter = new DateFilter(sr);
                    break;

                default:
                    throw new FileLoadException();
                }

                Filters.Add(filter);
            }
        }
        /// <summary>
        ///     格式化日期过滤器
        /// </summary>
        /// <param name="value">日期过滤器</param>
        /// <returns>格式化后的日期过滤器</returns>
        public static string AsDateRange(this DateFilter value)
        {
            if (value.NullOnly)
            {
                return("[null]");
            }

            if (value.EndDate.HasValue)
            {
                if (value.StartDate.HasValue)
                {
                    return(value.Nullable
                        ? $"[{value.StartDate.AsDate()}~~{value.EndDate.AsDate()}]"
                        : $"[{value.StartDate.AsDate()}~{value.EndDate.AsDate()}]");
                }

                return(value.Nullable
                    ? $"[~{value.EndDate.AsDate()}]"
                    : $"[={value.EndDate.AsDate()}]");
            }

            if (value.StartDate.HasValue)
            {
                return(value.Nullable
                    ? $"[{value.StartDate.AsDate()}~~]"
                    : $"[{value.StartDate.AsDate()}~]");
            }

            return(value.Nullable ? "[]" : "[~null]");
        }
Example #27
0
        public void PassesFilter_WithLaterDateAndSmallerMethod_ReturnsFalse()
        {
            var filter = new DateFilter(DateFilter.DateFilterMethods.Smaller, MiddleDate);
            var result = filter.PassesFilter(LateDate);

            Assert.False(result);
        }
Example #28
0
        public void PassesFilter_WithValidMethodArgumentAndParameter_ReturnsBool(DateTime argument, DateTime toTest,
                                                                                 DateFilter.DateFilterMethods method, bool expected)
        {
            var filter = new DateFilter(method, argument);
            var result = filter.PassesFilter(toTest);

            Assert.Equal(expected, result);
        }
Example #29
0
 public void EditDateFilter(DateFilter filter)
 {
     filterType_combobox.SelectedIndex = 5;
     old = new DateFilter(filter);
     SetDateFilterParams();
     filterParams_combobox.SelectedIndex = (int)filter.Unit;
     date_box.Value = filter.NumUnits;
 }
Example #30
0
    /// <summary>
    ///     执行查询
    /// </summary>
    /// <param name="rng">日期过滤器</param>
    /// <param name="inq">查询</param>
    /// <param name="baseCurrency">记账本位币</param>
    /// <param name="session">客户端会话</param>
    /// <returns>执行结果</returns>
    public async ValueTask <(string, double)> DoInquiry(DateFilter rng, BaseInquiry inq, string baseCurrency,
                                                        Session session)
    {
        var visitor = new InquiriesVisitor(session, rng, baseCurrency);
        var val     = await inq.Accept(visitor);

        return(visitor.Result, val);
    }
Example #31
0
        /// <summary>
        /// Binds the posts <see cref="List{T}"/> to the post list repeater.
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/>
        /// event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            FilterType = DateFilter.None;
            string filterTypeText = Request.QueryString["popular-posts"];
            string strCookieName = Config.CurrentBlog.BlogGroupId + "popular-posts";
            if (filterTypeText == null)
            {
                if (Request.Cookies[strCookieName] != null)
                {
                    filterTypeText = Request.Cookies[strCookieName].Value;
                }
            }

            Response.Cookies[strCookieName].Value = filterTypeText;
            Response.Cookies[strCookieName].Expires = DateTime.UtcNow.AddYears(1);

            if (!string.IsNullOrEmpty(filterTypeText))
            {
                try
                {
                    FilterType = (DateFilter)Enum.Parse(typeof(DateFilter), filterTypeText, true);
                }
                catch
                {
                }
            }

            ICollection<EntryStatsView> posts = Repository.GetPopularEntries(Blog.Id, FilterType);

            base.OnLoad(e);

            if (posts != null)
            {
                postList.DataSource = posts;
                postList.DataBind();
            }
            else
            {
                Controls.Clear();
                Visible = false;
            }
        }
Example #32
0
 public abstract ICollection<EntryStatsView> GetPopularEntries(int blogId, DateFilter filter);
Example #33
0
 public object ProfitAndLossPost(JObject json)
 {
     _total = false;
     initialiseReport(json);
     addTable("!AccountType");
     addTable("Account", "idAccount", "AccountCode", "AccountName", "AccountDescription");
     fieldFor("idAccount").Hide();
     fieldFor("AccountName")["sClass"] = "sa";
     fieldFor("Heading").MakeEssential().Hide();
     fieldFor("Negate").MakeEssential().Hide();
     fieldFor("BalanceSheet").MakeEssential().Hide();
     DateFilter date = new DateFilter("DocumentDate", DateRange.LastYear);
     ReportField cp = new ReportField("SUM(Amount) AS CurrentPeriod", "decimal", "Current Period");
     _fields.Add(cp);
     ReportField lp = new ReportField("SUM(Amount) AS PreviousPeriod", "decimal", "Previous Period");
     _fields.Add(lp);
     _filters.Add(date);
     setDefaultFields(json, "AcctType", "AccountName", "CurrentPeriod", "PreviousPeriod");
     _sortOrder = "AcctType";
     setFilters(json);
     // P & L needs 2 period buckets for the 2 columns
     DateTime[] cPeriod = date.CurrentPeriod();
     cp.FullFieldName = "SUM(CASE WHEN DocumentDate >= " + Database.Quote(cPeriod[0]) + " AND DocumentDate < " + Database.Quote(cPeriod[1]) + " THEN Amount ELSE 0 END) AS CurrentPeriod";
     cp["heading"] = date.PeriodName(cPeriod);
     DateTime[] lPeriod = date.PreviousPeriod();
     lp.FullFieldName = "SUM(CASE WHEN DocumentDate >= " + Database.Quote(lPeriod[0]) + " AND DocumentDate < " + Database.Quote(lPeriod[1]) + " THEN Amount ELSE 0 END) AS PreviousPeriod";
     lp["heading"] = date.PeriodName(lPeriod);
     string [] sort = new string[] { "AccountTypeId", "AccountCode", "AccountName" };
     string[] fields = _fields.Where(f => f.Include || f.Essential || _sortFields.Contains(f.Name)).Select(f => f.FullFieldName).Distinct().ToArray();
     JObjectEnumerable report = Database.Query("SELECT " + string.Join(",", fields)
         + @"
     FROM AccountType
     LEFT JOIN Account ON Account.AccountTypeId = AccountType.idAccountType
     JOIN Journal ON Journal.AccountId = Account.idAccount
     LEFT JOIN Document ON Document.idDocument = Journal.DocumentId
     "
         + "\r\nWHERE BalanceSheet = 0"
         + "\r\nAND ((DocumentDate >= " + Database.Quote(lPeriod[0])
         + "\r\nAND DocumentDate < " + Database.Quote(cPeriod[1]) + ")"
         + "\r\nOR Account.AccountTypeId = " + (int)AcctType.Security + ")"
         + "\r\nGROUP BY idAccount"
         + "\r\nORDER BY " + string.Join(",", sort.Select(s => s + (_sortDescending ? " DESC" : "")).ToArray())
         );
     // Needs further processing to add investment gains
     // total, etc.
     return reportJson(json, fixProfitAndLoss(addInvestmentGains(report.ToList(), "Old", lPeriod[0], "PreviousPeriod", cPeriod[0], "CurrentPeriod", cPeriod[1])), "AccountType", "Account");
 }
Example #34
0
 public object JournalsPost(JObject json)
 {
     initialiseReport(json);
     addTable("AccountType");
     fieldFor("idAccountType").Hide().Essential = false;
     addTable("Account", "idAccount", "AccountCode", "AccountName", "AccountDescription");
     addTable("!Journal");
     addTable("!NameAddress");
     addTable("Document", "idDocument", "DocumentDate", "DocumentIdentifier", "DocumentTypeId");
     fieldFor("idDocument").MakeEssential()["heading"] = "Trans no";
     addTable("DocumentType", "DocType");
     fieldFor("DocumentIdentifier")["heading"] = "Doc Id";
     fieldFor("DocumentDate").FullFieldName = "rDocDate AS DocumentDate";
     fieldFor("DocumentTypeId").MakeEssential().Hide().FullFieldName = "rDocType AS DocumentTypeId";
     fieldFor("Amount").FullFieldName = "Result.Amount";
     fieldFor("Credit").FullFieldName = "Result.Amount";
     fieldFor("Debit").FullFieldName = "Result.Amount";
     fieldFor("idAccount").Hide().Essential = true;
     DateFilter date = new DateFilter("DocumentDate", DateRange.ThisMonth);
     RecordFilter account = new RecordFilter("Account", "Journal.AccountId", _sel.Account(""));
     date.Apply = false;
     account.Apply = false;
     _filters.Add(date);
     _filters.Add(account);
     _filters.Add(new StringFilter("Id", "DocumentIdentifier"));
     _filters.Add(new RecordFilter("DocumentType", "DocumentTypeId", _sel.DocumentType("")));
     _filters.Add(new RecordFilter("NameAddress", "Journal.NameAddressId", _sel.Name("")));
     _filters.Add(new DecimalFilter("JournalAmount", "Result.Amount"));
     _filters.Add(new StringFilter("Memo", "Journal.Memo"));
     _sortOrder = "idAccountType,AcctType,AccountName";
     makeSortable("idAccountType,AcctType,AccountCode,AccountName=Account Type", "AccountName", "AccountCode,AccountName=AccountCode", "Name", "DocumentDate", "DocumentIdentifier=Doc Id", "DocType");
     setDefaultFields(json, "AcctType", "AccountName", "Amount", "Memo", "Name", "DocType", "DocumentDate", "DocumentIdentifier");
     setFilters(json);	// we need account filter now!
     string where = account.Active ? "\r\nAND " + account.Where() : "";
     // Need opening balance before start of period
     // Journals in period
     // Security gains/losses
     List<JObject> report = finishReport(@"(
     SELECT * FROM
     (SELECT Account.idAccount AS rAccount, Account.AccountTypeId as rAcctType, SUM(Journal.Amount) AS Amount, " + (int)DocType.OpeningBalance + " AS rDocType, 0 as rJournal, 0 as rDocument, 0 AS rJournalNum, "
     + Database.Cast(Database.Quote(date.CurrentPeriod()[0]), "DATETIME") + @" AS rDocDate
     FROM Account
     LEFT JOIN AccountType ON AccountType.idAccountType = Account.AccountTypeId
     LEFT JOIN Journal ON Journal.AccountId = Account.idAccount
     LEFT JOIN Document ON Document.idDocument = Journal.DocumentId
     WHERE DocumentDate < " + Database.Quote(date.CurrentPeriod()[0]) + @"
     AND BalanceSheet = 1" + where + @"
     GROUP BY AccountName) AS OpeningBalances
     WHERE Amount <> 0 OR rAcctType IN (" + (int)AcctType.Investment + "," + (int)AcctType.Security + @")
     UNION
     SELECT Account.idAccount AS rAccount, Account.AccountTypeId as rAcctType, Journal.Amount, DocumentTypeId As rDocType, idJournal AS rJournal, idDocument as rDocument,
     JournalNum as rJournal, DocumentDate AS rDocDate
     FROM Account
     LEFT JOIN AccountType ON AccountType.idAccountType = Account.AccountTypeId
     LEFT JOIN Journal ON Journal.AccountId = Account.idAccount
     LEFT JOIN Document ON Document.idDocument = Journal.DocumentId
     WHERE " + date.Where() + where + @"
     UNION
     SELECT Account.idAccount AS rAccount, Account.AccountTypeId as rAcctType, 0 AS Amount, " + (int)DocType.Gain + " AS rDocType, 0 as rJournal, 0 as rDocument, 0 AS rJournalNum, "
     + Database.Cast(Database.Quote(date.CurrentPeriod()[1].AddDays(-1)), "DATETIME") + @" AS rDocDate
     FROM Account
     WHERE AccountTypeId = " + (int)AcctType.Security + where.Replace("Journal.AccountId", "idAccount") + @"
     ) AS Result", "idAccountType,AccountName,DocumentDate,idDocument,JournalNum", @"
     LEFT JOIN Account on Account.idAccount = rAccount
     LEFT JOIN AccountType ON AccountType.idAccountType = Account.AccountTypeId
     LEFT JOIN Journal ON Journal.idJournal = rJournal
     LEFT JOIN NameAddress ON NameAddress.idNameAddress = Journal.NameAddressId
     LEFT JOIN Document ON Document.idDocument = rDocument
     LEFT JOIN DocumentType ON DocumentType.idDocumentType = rDocType
     ", json).ToList();
     return reportJson(json, addInvestmentGains(date.CurrentPeriod(), account, report), "Account", "AccountType");
 }
Example #35
0
 public object TrialBalancePost(JObject json)
 {
     _total = false;
     initialiseReport(json);
     addTable("!AccountType", "Heading", "AcctType");
     addTable("Account", "idAccount", "AccountCode", "AccountName", "AccountDescription");
     fieldFor("idAccount").Hide();
     addTable("Journal", "Amount");
     fieldFor("Amount").FullFieldName = "Amount";
     fieldFor("Credit").FullFieldName = "Amount";
     fieldFor("Debit").FullFieldName = "Amount";
     DateFilter date = new DateFilter("DocumentDate", DateRange.LastYear);
     _filters.Add(date);
     setDefaultFields(json, "AccountName", "Credit", "Debit");
     _sortOrder = "AcctType";
     setFilters(json);
     DateTime[] cPeriod = date.CurrentPeriod();
     string[] sort = new string[] { "AccountTypeId", "AccountCode", "AccountName" };
     string[] fields = _fields.Where(f => f.Include || f.Essential || _sortFields.Contains(f.Name)).Select(f => f.FullFieldName).Distinct().ToArray();
     // Need Old (= opening balance) and final values for each account
     JObjectEnumerable report = Database.Query("SELECT " + string.Join(",", fields) + @", BalanceSheet, Old
     FROM AccountType
     LEFT JOIN Account ON Account.AccountTypeId = AccountType.idAccountType
     JOIN (SELECT AccountId,
     SUM(CASE WHEN DocumentDate < " + Database.Quote(cPeriod[1]) + " AND DocumentDate >= " + Database.Quote(cPeriod[0]) + @" THEN Amount ELSE 0 END) AS Amount,
     SUM(CASE WHEN DocumentDate < " + Database.Quote(cPeriod[0]) + @" THEN Amount ELSE 0 END) AS Old
     FROM Journal
     LEFT JOIN Document ON Document.idDocument = Journal.DocumentId
     WHERE DocumentDate < " + Database.Quote(cPeriod[1]) + @"
     GROUP BY AccountId
     ) AS Summary ON AccountId = idAccount
     ORDER BY " + string.Join(",", sort.Select(s => s + (_sortDescending ? " DESC" : "")).ToArray())
         );
     _sortFields = new string[] { "Heading", "AcctType", "AccountCode", "AccountName" };
     // Need to add investment gains
     // then process further to sort, add opening balances where required, and total
     return reportJson(json, fixTrialBalance(addInvestmentGains(addRetainedEarnings(report), "Old", cPeriod[0], "Amount", cPeriod[1])), "AccountType", "Account");
 }
        public ColumnStats GetDateHistogram(int column, DateFilter type)
        {
            var stats = new ColumnStats();
            stats.Computed = true;
            stats.Buckets = 20;
            stats.TargetColumn = column;
            stats.DomainColumn = -1;
            table.Lock();
            stats.Max = double.MinValue;
            stats.Min = double.MaxValue;

            switch (type)
            {
                case DateFilter.Year:
                    ComputeDateRange(column, -1, out stats.BeginDate, out stats.EndDate);
                    stats.BeginDate = stats.BeginDate.Date;
                    stats.EndDate = stats.EndDate.Date;
                    var ts = stats.EndDate - stats.BeginDate;

                    stats.Buckets = (int)(ts.TotalDays + 1);
                    stats.DomainValues = new string[stats.Buckets];
                    var now = stats.BeginDate;
                    for(var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i]=now.ToShortDateString();
                        now = now.AddDays(1);
                    }

                    break;
                case DateFilter.Month:
                    stats.Buckets = 12;
                    stats.DomainValues = new string[stats.Buckets];

                    for(var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i] = UiTools.GetMonthName(i, false);
                    }
                    break;
                case DateFilter.Day:
                    stats.Buckets = 31;
                    stats.DomainValues = new string[stats.Buckets];

                    for(var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i] = (i+1).ToString();
                    }
                    break;
                case DateFilter.DayOfWeek:
                    stats.Buckets = 7;
                    stats.DomainValues = new string[stats.Buckets];

                    for(var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i] = UiTools.GetDayName(i, false);
                    }
                    break;
                case DateFilter.DayOfYear:
                    stats.Buckets = 366;
                    stats.DomainValues = new string[stats.Buckets];
                    for (var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i] = (i + 1).ToString();
                    }
                    break;
                case DateFilter.Hour:
                    stats.Buckets = 24;
                    stats.DomainValues = new string[stats.Buckets];

                    for(var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i] = UiTools.GetHourName(i);
                    }
                    break;
                case DateFilter.Minute:
                    stats.Buckets = 60;
                    stats.DomainValues = new string[stats.Buckets];

                    for(var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i] = i.ToString();
                    }
                    break;
                case DateFilter.Second:
                    stats.Buckets = 60;
                    stats.DomainValues = new string[stats.Buckets];

                    for(var i = 0; i < stats.Buckets; i++)
                    {
                        stats.DomainValues[i] = i.ToString();
                    }
                    break;
                default:
                    break;
            }

            stats.Histogram = new double[stats.Buckets];
            stats.BucketWidth = 1;
            stats.DateFilter = type;
            // First Pass - Basic statistics..
            foreach (var row in table.Rows)
            {
                var selected = Filters.Count == 0;
                var firstFilter = true;
                foreach (var fgt in Filters)
                {
                    var filter = fgt.Stats;
                    if (filter.Computed && (selected || firstFilter))
                    {
                        if (filter.IsSelected(row))
                        {
                            selected = true;
                        }
                        else
                        {
                            selected = false;
                        }
                        firstFilter = false;

                    }
                }
                if (selected)
                {
                    try
                    {
                        if (column > -1)
                        {

                            var date = ParseDate(row[column]);
                            var bucket = 0;
                            switch (type)
                            {
                                case DateFilter.Year:
                                    bucket = (date.Date - stats.BeginDate).Days;
                                    break;
                                case DateFilter.Month:
                                    bucket = date.Month - 1;
                                    break;
                                case DateFilter.Day:
                                    bucket = date.Day - 1;
                                    break;
                                case DateFilter.DayOfWeek:
                                    bucket = (int)date.DayOfWeek;
                                    break;
                                case DateFilter.DayOfYear:
                                    bucket = date.DayOfYear - 1;
                                    break;
                                case DateFilter.Hour:
                                    bucket = date.Hour;
                                    break;
                                case DateFilter.Minute:
                                    bucket = date.Minute;
                                    break;
                                case DateFilter.Second:
                                    bucket = date.Second;
                                    break;
                                default:
                                    break;
                            }

                            stats.Count++;
                            stats.Sum += 1;
                            stats.Histogram[bucket]++;
                        }

                    }
                    catch
                    {
                    }
                }
            }

            stats.Selected = new bool[stats.Buckets];
            for (var i = 0; i < stats.Buckets; i++)
            {
                stats.Selected[i] = false;
            }

            foreach (int max in stats.Histogram)
            {
                if (stats.HistogramMax < max)
                {
                    stats.HistogramMax = max;
                }
            }

            table.Unlock();

            return stats;
        }
Example #37
0
        public override ICollection<EntryStatsView> GetPopularEntries(int blogId, DateFilter filter)
        {
            DateTime? minDate = null;
            if (filter == DateFilter.LastMonth)
            {
                minDate = CurrentDateTimeUtc.AddMonths(-1);
            }
            else if (filter == DateFilter.LastWeek)
            {
                minDate = CurrentDateTimeUtc.AddDays(-7);
            }
            else if (filter == DateFilter.LastYear)
            {
                minDate = CurrentDateTimeUtc.AddYears(-1);
            }

            using (IDataReader reader = _procedures.GetPopularPosts(BlogId, minDate))
            {
                return reader.ReadCollection(r =>
                    {
                        var entry = r.ReadEntryStatsView();
                        entry.PostType = PostType.BlogPost;
                        return entry;
                    });
            }
        }
Example #38
0
 public object BalanceSheetPost(JObject json)
 {
     _total = false;
     initialiseReport(json);
     addTable("!AccountType");
     addTable("Account", "idAccount", "AccountCode", "AccountName", "AccountDescription");
     fieldFor("idAccount").Hide();
     fieldFor("AccountName")["sClass"] = "sa";
     fieldFor("Heading").MakeEssential();
     fieldFor("Negate").MakeEssential().Hide();
     fieldFor("BalanceSheet").MakeEssential().Hide();
     DateFilter date = new DateFilter("DocumentDate", DateRange.LastYear);
     ReportField cp = new ReportField("CurrentPeriod", "decimal", "Current Period");
     _fields.Add(cp);
     ReportField lp = new ReportField("PreviousPeriod", "decimal", "Previous Period");
     _fields.Add(lp);
     _filters.Add(date);
     setDefaultFields(json, "Heading", "AcctType", "AccountName", "CurrentPeriod", "PreviousPeriod");
     _sortOrder = "AcctType";
     setFilters(json);
     // Balance sheet needs 2 period buckets for the 2 columns
     DateTime[] cPeriod = date.CurrentPeriod();
     cp["heading"] = date.PeriodName(cPeriod);
     DateTime[] lPeriod = date.PreviousPeriod();
     lp["heading"] = date.PeriodName(lPeriod);
     string[] sort = new string[] { "AccountTypeId", "AccountCode", "AccountName" };
     string[] fields = _fields.Where(f => f.Include || f.Essential || _sortFields.Contains(f.Name)).Select(f => f.FullFieldName).Distinct().ToArray();
     // We want one record per account, with totals for each bucket, and an Old value
     // which is sum of all transactions before first bucket (opening balance)
     JObjectEnumerable report = Database.Query("SELECT " + string.Join(",", fields) + @", Old
     FROM AccountType
     LEFT JOIN Account ON Account.AccountTypeId = AccountType.idAccountType
     JOIN (SELECT AccountId,
     SUM(CASE WHEN DocumentDate < " + Database.Quote(cPeriod[1]) + " AND DocumentDate >= " + Database.Quote(cPeriod[0]) + @" THEN Amount ELSE 0 END) AS CurrentPeriod,
     SUM(CASE WHEN DocumentDate < " + Database.Quote(lPeriod[1]) + " AND DocumentDate >= " + Database.Quote(lPeriod[0]) + @" THEN Amount ELSE 0 END) AS PreviousPeriod,
     SUM(CASE WHEN DocumentDate < " + Database.Quote(lPeriod[0]) + @" THEN Amount ELSE 0 END) AS Old
     FROM Journal
     LEFT JOIN Document ON Document.idDocument = Journal.DocumentId
     WHERE DocumentDate < " + Database.Quote(cPeriod[1]) + @"
     GROUP BY AccountId
     ) AS Summary ON AccountId = idAccount
     ORDER BY " + string.Join(",", sort.Select(s => s + (_sortDescending ? " DESC" : "")).ToArray())
         );
     _sortFields = new string[] { "Heading", "AcctType", "AccountCode", "AccountName" };
     // Report now needs further processing to:
     // Calculate retained earnings account
     // Add investment gains
     // Consolidate P & L accounts and produce totals
     return reportJson(json, fixBalanceSheet(addInvestmentGains(addRetainedEarnings(report), "Old", lPeriod[0], "PreviousPeriod", cPeriod[0], "CurrentPeriod", cPeriod[1])), "AccountType", "Account");
 }
        public PartialViewResult GetConferences(string nameFilter, string locationFilter, int[] selectedTagsIds,
            DateFilter? dateFilter, int? page, bool filter = false)
        {
            _conferenceFilter.Conferences = Conferences.OrderBy(e => e.StartDate);
            _conferenceFilter.FilterByName(ViewData, nameFilter);
            _conferenceFilter.FilterByLocation(ViewData, locationFilter);
            _conferenceFilter.FilterByTags(ViewData, selectedTagsIds, Tags);
            if (dateFilter != null)
                _conferenceFilter.FilterByTime(ViewData, dateFilter.Value, _conferenceFilter.Conferences);

            if (_conferenceFilter.Conferences.Count() == 0)
                return PartialView("_NoResuls");

            if ((page ?? 0)*PageSize >= _conferenceFilter.Conferences.Count())
                return null;

            ViewData["ResultsCount"] = _controllerHelper.GetResultsCount(_conferenceFilter.Conferences.Count(), !filter);

            var pageSize = _controllerHelper.GetPageSize(page ?? 0, PageSize, _conferenceFilter.Conferences.Count());
            PagedConferences =
                _conferenceFilter.Conferences.ToList().GetRange((page ?? 0)*PageSize, pageSize);
            return PartialView("_ConferencesView", PagedConferences.ToList());
        }
 public void ViewBuilds(string projectName, string buildDefinition, string qualityFilter, DateFilter dateFilter)
 {
     _teamFoundationBuild.Value.BuildExplorer.CompletedView.Show(projectName, buildDefinition, qualityFilter, dateFilter);
 }
Example #41
0
 /// <summary>
 /// Set up an audit trail report
 /// </summary>
 /// <param name="json">The posted report parameters</param>
 void initialiseAuditReport(JObject json)
 {
     initialiseReport(json);
     if (_changeTypeNotRequired) {
         addTable("!AuditTrail", "idAuditTrail", "DateChanged");
     } else {
         addTable("!AuditTrail", "idAuditTrail", "DateChanged", "ChangeType");
         fieldFor("ChangeType")["type"] = "select";
         fieldFor("ChangeType")["selectOptions"] = new JArray(_sel.AuditTypes());
     }
     fieldFor("DateChanged")["type"] = "dateTime";
     fieldFor("idAuditTrail").Hide();
     _dates = new DateFilter("DateChanged", DateRange.ThisMonth);
     _filters.Add(_dates);
 }
 public BuildManagerViewModel(Window owner, ITfsClientRepository repository, IMainView view, IEnumerable<IBuildController> controllers, IEnumerable<string> teamProjects, ITfsContext context)
 {
     this.owner = owner;
     this.repository = repository;
     this.view = view;
     this.context = context;
     this.BuildDefinitions = new ObservableCollection<BuildDefinitionViewModel>();
     this.Builds = new ObservableCollection<BuildViewModel>();
     this.BuildResources = new ObservableCollection<BuildResourceViewModel>();
     this.CleanDropsCommands = new DelegateCommand(this.OnCleanDrops);
     this.DeleteCommand = new DelegateCommand(this.OnDelete);
     this.OpenDropFolderCommand = new DelegateCommand(this.OnOpenDropfolder);
     this.RetainIndefinitelyCommand = new DelegateCommand(this.OnRetainIndefinitely);
     this.SetBuildQualityCommand = new DelegateCommand(this.OnSetBuildQuality);
     this.BuildNotesCommand = new DelegateCommand(this.OnBuildNotes);
     this.DeleteBuildCommand = new DelegateCommand(this.OnDeleteBuild);
     this.ShowDetailsCommand = new DelegateCommand(this.OnShowDetails);
     this.RetryCommand = new DelegateCommand(this.OnRetry);
     this.ViewBuildLogsCommand = new DelegateCommand(this.OnViewBuildLogs);
     this.ShowQueuedDetailsCommand = new DelegateCommand(this.OnShowQueuedDetails);
     this.StopBuildCommand = new DelegateCommand(this.OnStopBuild);
     this.DisabledQueuedDefinitionCommand = new DelegateCommand(this.OnDisabledQueuedDefinition);
     this.PauseQueuedDefinitionCommand = new DelegateCommand(this.OnPauseQueuedDefinition);
     this.ResumeBuildCommand = new DelegateCommand(this.OnResumeBuild);
     this.ChangeBuildTemplateCommand = new DelegateCommand(this.OnChangeBuildTemplate);
     this.SetDefaultBuildTemplateCommand = new DelegateCommand(this.OnSetDefaultBuildTemplate, this.OnCanSetDefaultBuildTemplate);
     this.AddBuildProcessTemplateCommand = new DelegateCommand(this.OnAddBuildProcessTemplate);
     this.RemoveBuildProcessTemplateCommand = new DelegateCommand(this.OnRemoveBuildProcessTemplate);
     this.EditControllerCommand = new DelegateCommand(this.OnEditController);
     this.EnableBuildResourceCommand = new DelegateCommand(this.OnEnableBuildResource);
     this.DisableBuildResourceCommand = new DelegateCommand(this.OnDisableBuildResource);
     this.RemoveCommand = new DelegateCommand(this.OnRemove);
     this.EnableCommand = new DelegateCommand(this.OnEnable);
     this.DisableCommand = new DelegateCommand(this.OnDisable);
     this.PauseCommand = new DelegateCommand(this.OnPause);
     this.SetRetentionPoliciesCommand = new DelegateCommand(this.OnSetRetentionsPolicies);
     this.ChangeBuildControllerCommand = new DelegateCommand(this.OnChangeBuildController);
     this.ChangeDefaultDropLocationCommand = new DelegateCommand(this.OnChangeDefaultDropLocation);
     this.ChangeOutputLocationAsConfiguredCommand = new DelegateCommand(this.OnChangeOutputLocationAsConfiguredCommand);
     this.ChangeOutputLocationPerProjectCommand = new DelegateCommand(this.OnChangeOutputLocationPerProjectCommand);
     this.ChangeOutputLocationSingleFolderCommand = new DelegateCommand(this.OnChangeOutputLocationSingleFolderCommand);
     this.ChangeTriggerCommand = new DelegateCommand(this.OnChangeTrigger);
     this.ExportDefinitionCommand = new DelegateCommand(this.OnExportBuildDefinition);
     this.CloneBuildsCommand = new DelegateCommand(this.OnCloneBuilds, this.OnCanCloneBuilds);
     this.CloneGitBuildsCommand = new DelegateCommand(this.OnCloneGitBuilds, this.OnCanCloneBuilds);
     this.CloneBuildToProjectCommand = new DelegateCommand(this.OnCloneBuildToProject, this.OnCanCloneBuilds);
     this.RemapWorkspacesCommand = new DelegateCommand(this.OnRemapWorkspaces, this.OnCanRemapWorkspaces);
     this.QueueBuildsCommand = new DelegateCommand(this.OnQueueBuilds, this.OnCanQueueBuilds);
     this.QueueHighBuildsCommand = new DelegateCommand(this.OnQueueHighBuilds, this.OnCanQueueBuilds);
     this.EditBuildDefinitionCommand = new DelegateCommand(this.OnEditBuildDefinition, this.OnCanEditBuildDefinition);
     this.GenerateBuildResourcesCommand = new DelegateCommand(this.OnGenerateBuildResources);
     this.Controllers = new ObservableCollection<string>(controllers.Select(c => c.Name));
     this.Controllers.Sort();
     this.RefreshCurrentView = new DelegateCommand(this.OnRefreshCurrentView);
     this.ImportBuildDefinition = new DelegateCommand(this.OnImportBuildDefinition);
     this.Controllers.Insert(0, AllItem);
     this.TeamProjects = new ObservableCollection<string>(teamProjects.Select(tp => tp));
     this.TeamProjects.Sort();
     this.TeamProjects.Insert(0, AllItem);
     this.SelectedBuildFilter = BuildFilter.Queued;
     this.includeDisabledBuildDefinitions = false;
     this.BuildViews = new ObservableCollection<BuildViewItem> { new BuildViewItem { Name = "Build Definitions", Value = BuildView.BuildDefinitions }, new BuildViewItem { Name = "Builds", Value = BuildView.Builds }, new BuildViewItem { Name = "Build Process Templates", Value = BuildView.BuildProcessTemplates }, new BuildViewItem { Name = "Build Resources", Value = BuildView.BuildResources } };
     this.DateFilters = new DateFilterCollection();
     this.SelectedBuildView = BuildView.BuildDefinitions;
     this.selectedBuildDateFilter = DateFilter.Today;
     this.BuildProcessTemplatess = new ObservableCollection<BuildTemplateViewModel>();
 }
        //TODO: unit tests!
        public void FilterByTime(ViewDataDictionary viewData, DateFilter dateFilter, IEnumerable<Conference> conferences)
        {
            switch (dateFilter)
            {
                case DateFilter.Upcoming:
                    Conferences = Conferences.Where(e => e.StartDate >= DateTime.Today).ToList();
                    break;

                case DateFilter.Past:
                    Conferences = Conferences.Where(e => e.StartDate < DateTime.Today).ToList();
                    break;
                case DateFilter.All:
                    Conferences = conferences;
                    break;
            }
        }