private static DateTime GetFromPeriod(ITime time, FilterPeriod period)
        {
            DateTime fromDate = DateTime.Today;
            var      today    = time.GetAppNowTime().Date;

            switch (period)
            {
            case FilterPeriod.Day:     //Day
                fromDate = today;
                break;

            case FilterPeriod.Week:     //Week
                fromDate = today.AddDays(-7);
                break;

            case FilterPeriod.Month:     //Month
                fromDate = today.AddMonths(-1);
                break;

            case FilterPeriod.ThreeMonth:     //3 month
                fromDate = today.AddMonths(-3);
                break;
            }
            return(fromDate);
        }
        public static IList <SalesReportViewModel> GetAllByDate(IUnitOfWork db,
                                                                ITime time,
                                                                FilterPeriod period)
        {
            DateTime fromDate = GetFromPeriod(time, period);

            var items = db.SalesReports.GetSalesByDateReport(fromDate);

            return(items.Select(i => new SalesReportViewModel(i)).ToList());
        }
Beispiel #3
0
        public void PopulateDataGridView()
        {
            if (cbxFilterOptions.SelectedIndex == -1)
            {
                return;
            }

            FilterOptions selectedOption = (FilterOptions)cbxFilterOptions.SelectedIndex;
            FilterPeriod  selectedPeriod = (FilterPeriod)cbxFilterPeriod.SelectedIndex;

            DateTime selectedDateFrom = dtpPeriodFrom.Value.Date;
            DateTime selectedDateTo   = dtpPeriodTo.Value.Date;

            List <string> selectedTypes = clbFileTypes.CheckedItems.Cast <string>().ToList();

            switch (selectedOption)
            {
            case FilterOptions.ShowAll:
                ShowAllFiles(selectedTypes);
                break;

            case FilterOptions.TimeCreated:
                ShowFilesByPeriodOfTime("CreationTime", selectedPeriod, selectedDateFrom, selectedDateTo, selectedTypes);
                break;

            case FilterOptions.LastModifyTime:
                ShowFilesByPeriodOfTime("LastModificationTime", selectedPeriod, selectedDateFrom, selectedDateTo, selectedTypes);
                break;

            case FilterOptions.LastAccessTime:
                ShowFilesByPeriodOfTime("LastAccessTime", selectedPeriod, selectedDateFrom, selectedDateTo, selectedTypes);
                break;

            case FilterOptions.DeletedFiles:
                ShowDeletedFiles(selectedPeriod, selectedDateFrom, selectedDateTo, selectedTypes);
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        public void ShowDeletedFiles(FilterPeriod selectedPeriod, DateTime selectedDateFrom, DateTime selectedDateTo, List <string> selectedTypes)
        {
            try
            {
                switch (selectedPeriod)
                {
                case FilterPeriod.ForDay:
                    if (RecievedFolder == null)
                    {
                        dgvFiles.DataSource = database.GetDeletedFilesForFolder(selectedDrive, null, selectedTypes, selectedDateFrom);
                    }
                    else
                    {
                        dgvFiles.DataSource = database.GetDeletedFilesForFolder(selectedDrive, RecievedFolder.Name, selectedTypes, selectedDateFrom);
                    }
                    break;

                default:
                    if (RecievedFolder == null)
                    {
                        dgvFiles.DataSource = database.GetDeletedFilesForFolder(selectedDrive, null, selectedTypes, selectedDateFrom, selectedDateTo);
                    }
                    else
                    {
                        dgvFiles.DataSource = database.GetDeletedFilesForFolder(selectedDrive, RecievedFolder.Name, selectedTypes, selectedDateFrom, selectedDateTo);
                    }
                    break;
                }

                SetUpDataGridViewColumnsSettings();
                lblNumberOfFiles.Visible = true;
                lblNumberOfFiles.Text    = dgvFiles.Rows.Count.ToString();
            }
            catch (Exception)
            {
                lblErrorLabel.Visible = true;
            }
        }
Beispiel #5
0
        public void ShowFilesByPeriodOfTime(string columnName, FilterPeriod selectedPeriod, DateTime selectedDateFrom, DateTime selectedDateTo, List <string> selectedTypes)
        {
            try
            {
                switch (selectedPeriod)
                {
                case FilterPeriod.ForDay:
                    dgvFiles.DataSource = database.GetFilesByPeriodOfTime(selectedDrive, columnName, selectedTypes, selectedDateFrom).Distinct(new CacheModelComaparer()).ToList();
                    break;

                default:
                    dgvFiles.DataSource = database.GetFilesByPeriodOfTime(selectedDrive, columnName, selectedTypes, selectedDateFrom, selectedDateTo).Distinct(new CacheModelComaparer()).ToList();
                    break;
                }

                SetUpDataGridViewColumnsSettings();
                lblNumberOfFiles.Visible = true;
                lblNumberOfFiles.Text    = dgvFiles.Rows.Count.ToString();
            }
            catch (Exception)
            {
                lblErrorLabel.Visible = true;
            }
        }
        public static IQueryable <BuyBoxStatusViewModel> GetAll(IUnitOfWork db,
                                                                int market,
                                                                string marketplaceId,
                                                                FilterPeriod period,
                                                                bool inStock,
                                                                bool includeIgnored)
        {
            var items = db.BuyBoxStatus.GetAllWithItems()
                        .Where(bb => !String.IsNullOrEmpty(bb.ParentASIN))
                        .Select(bb => new BuyBoxStatusViewModel()
            {
                EntityId = bb.Id,

                ASIN          = bb.ASIN,
                Market        = (MarketType)bb.Market,
                MarketplaceId = bb.MarketplaceId,

                Status         = bb.Status,
                CheckedDate    = bb.CheckedDate,
                LostWinnerDate = bb.LostWinnerDate,

                WinnerMerchantName = bb.WinnerMerchantName,
                WinnerPrice        = bb.WinnerPrice,
                WinnerSalePrice    = bb.WinnerSalePrice,
                WinnerAmountSaved  = bb.WinnerAmountSaved,
                IsIgnored          = bb.IsIgnored,

                Price       = bb.Price,
                Quantity    = bb.Quantity < 0 ? 0 : bb.Quantity,
                ParentASIN  = bb.ParentASIN,
                Size        = bb.Size,
                Images      = bb.Images,
                SKU         = bb.SKU,
                StyleId     = bb.StyleId,
                StyleString = bb.StyleString
            });

            DateTime?fromDate = null;

            switch (period)
            {
            case FilterPeriod.NotWinAll:
                items = items.Where(i => i.Status == BuyBoxStatusCode.NotWin);
                break;

            case FilterPeriod.WinLostLastMonth:
                fromDate = DateTime.UtcNow.AddDays(-30);
                break;

            case FilterPeriod.WinLostLastWeek:
                fromDate = DateTime.UtcNow.AddDays(-7);
                break;

            case FilterPeriod.WinLostLastDay:
                fromDate = DateTime.UtcNow.AddDays(-1);
                break;
            }

            if (fromDate.HasValue)
            {
                items = items.Where(i => i.LostWinnerDate >= fromDate.Value);
            }

            if (!includeIgnored)
            {
                items = items.Where(i => !i.IsIgnored);
            }

            if (inStock)
            {
                items = items.Where(i => i.Quantity > 0);
            }

            if (market != 0)
            {
                items = items.Where(i => (int)i.Market == market);
            }

            if (!String.IsNullOrEmpty(marketplaceId))
            {
                items = items.Where(i => i.MarketplaceId == marketplaceId);
            }

            return(items);
        }