using log4net;
using System.Windows;
using System.Windows.Controls;
using Agent.Models;
using Agent.Services;
using WinForms = System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Windows.Data;
using System.Linq;
namespace Agent.Views
{
///
/// Interaction logic for ReportPage.xaml
///
public partial class ReportPage : Page
{
private static readonly ILog log = LogManager.GetLogger(typeof(ReportPage));
private readonly ReportService _reportService = new ReportService();
private readonly CsvService _csvService = new CsvService();
private readonly CollectionViewSource _searchViewSource = new CollectionViewSource();
public ReportPage()
{
InitializeComponent();
ReportList.ItemsSource = _searchViewSource.View;
DatePicker.CustomFormat = "yyyy-MM-dd";
DatePicker.Format = WinForms.DateTimePickerFormat.Custom;
DatePicker.TextChanged += DatePicker_TextChanged;
DatePicker2.CustomFormat = "yyyy-MM-dd";
DatePicker2.Format = WinForms.DateTimePickerFormat.Custom;
DatePicker2.TextChanged += DatePicker_TextChanged;
FetchList();
}
private void DatePicker_TextChanged(object sender, EventArgs e)
{
FetchList();
}
public void FetchList()
{
RP_serarch_cb.SelectedIndex = 0;
RP_search_tb.Text = "";
_searchViewSource.Source = _reportService.GetDailyReports(DatePicker.Value.ToString("yyyy-MM-dd"), DatePicker2.Value.ToString("yyyy-MM-dd"));
ReportList.ItemsSource = _searchViewSource.View;
RP_title_tb.Text = $"{_searchViewSource.View.Cast