示例#1
0
        public async Task <ActionResult> ChangeSet(int floor, int ceil, int max, bool isActiveSearch, string searchString, int requestedChange)
        {
            ActionResult  actionResult = null;
            Json311       dataHandler  = null;
            HomeViewModel model        = new HomeViewModel()
            {
                rowHandler = new RowHandler()
                {
                    Curr_min = floor,
                    Curr_max = ceil,
                    total    = max
                }
            };

            try
            {
                dataHandler = new Json311();
                if (isActiveSearch)
                {
                    string[] search;
                    DateTime?start, end;
                    string   agency = null;
                    if (searchString.Contains("-"))
                    {
                        search = searchString.Split('-');
                        start  = DateTime.Parse(search[0]);
                        if (search[1].Contains("|"))
                        {
                            search = search[1].Split('|');
                            end    = DateTime.Parse(search[0]);
                            agency = search[1];
                            //Create date + agency search
                        }
                        else
                        {
                            if (requestedChange > 0)
                            {
                                model.rowHandler.UpdateValuesUp();
                            }
                            else
                            {
                                model.rowHandler.UpdateValuesDown();
                            }
                            end            = DateTime.Parse(search[1]);
                            model.JsonData = dataHandler.GetDateFilteredList(model.rowHandler.Curr_min, model.rowHandler.Curr_max, start.Value, end.Value);
                        }
                    }
                }
                else
                {
                    return(await ChangeSetWithoutFilter(floor, ceil, max, requestedChange));
                }
            }
            catch (Exception ex)
            {
                actionResult = Json(new { Reroute = false, error = $"Error retrieving new DataSet: {ex.GetType()}" });
            }
            return(await Task.FromResult(actionResult));
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_dates(object sender, RoutedEventArgs e)
        {
            DateTime?      start     = Start.SelectedDate;
            DateTime?      end       = Start.SelectedDate;
            RowNumbers     rows      = Application.Current.Resources["RowNumbers"] as RowNumbers;
            SqlConnect     dbconnect = new SqlConnect();
            Json311        get_data  = new Json311();
            List <Json311> show_data = new List <Json311>();

            if (!start.HasValue)
            {
                MessageBox.Show("Select a date on the left");
            }
            else if (start.HasValue && !end.HasValue)
            {
                DateTime new_start = (DateTime)start;
                int      year      = new_start.Year;
                int      month     = new_start.Month;
                int      date      = new_start.Day;
                DateTime date1     = new DateTime(year, month, date, 0, 0, 0);
                DateTime date2     = new DateTime(year, month, date, 23, 59, 59);
                int      num_rows  = dbconnect.GetRows(date1, date2);
                if (num_rows == 0)
                {
                    MessageBox.Show("There are no values for the selected dates");
                }
                else
                {
                    rows.filter_min = 0;
                    if (num_rows > 500)
                    {
                        rows.filter_max = 500;
                    }
                    else
                    {
                        rows.filter_max = num_rows;
                    }
                    rows.filter_total         = num_rows;
                    rows.is_filter            = true;
                    show_data                 = get_data.GetDateFilteredList(0, 0, date1, date2);
                    DBDataBinding.ItemsSource = show_data;
                    this.NavigationService.Refresh();
                }
            }
            Application.Current.Resources["RowNumbers"] = rows;
        }
示例#3
0
        public async Task <ActionResult> Index(HomeViewModel model)
        {
            Json311      json         = new Json311();
            ActionResult actionResult = null;

            if (model.StartDate.HasValue)
            {
                model.rowHandler = new RowHandler()
                {
                    Curr_min = model.CurrentFloor,
                    Curr_max = model.CurrentCeil,
                    total    = model.CurrentMax
                };
                try
                {
                    DateTime?start, end;
                    start = model.StartDate;
                    if (model.EndDate.HasValue)
                    {
                        end = model.EndDate.Value;
                    }
                    else
                    {
                        end = DateTime.Now;
                    }
                    int offset = 0;
                    if (model.NextSet)
                    {
                        offset = model.CurrentCeil;
                    }
                    else if (model.PreviousSet)
                    {
                        if ((offset - 500) < 0)
                        {
                            offset = 0;
                        }
                        else
                        {
                            offset -= 500;
                        }
                    }
                    if (offset > model.CurrentMax)
                    {
                        offset = 0;
                    }

                    model.JsonData     = json.GetDateFilteredList(500, offset, start.Value, end.Value);
                    model.CurrentFloor = offset;
                    model.StartDate    = start;
                    model.EndDate      = end;
                    model.CurrentCeil  = model.CurrentFloor + model.JsonData.Count();
                    model.CurrentMax   = json.GetCount(start.Value, end.Value);

                    actionResult = View(model);
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                model.JsonData     = json.GetFullDataset(0, 500);
                model.CurrentFloor = 0;
                model.CurrentCeil  = model.JsonData.Count();
                model.CurrentMax   = json.GetCount();
                model.ChangeUp     = 500;
                model.ChangeDown   = -500;
                model.ActiveSearch = false;
                actionResult       = View(model);
            }

            return(await Task.FromResult(actionResult));
        }