public OspDataDTO GetOspData(int userId, int ospId) { // Период получения документов в ОСА (30 дней). DateTime startPeriod = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(-30); DateTime endPeriod = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); // Получить общие списки. ICollection <AccessDTO> allAccesses = Accesses.GetAll(); ICollection <UserDTO> allUsers = Users.GetAll(); ICollection <CartridgeDTO> allCarts = Cartridges.GetAll(); ICollection <PrinterDTO> allPrints = Printers.GetAll(); ICollection <OspDTO> allOsps = Osps.GetAll(); // Получить данные по ОСП. ICollection <BalanceDTO> balances = Balance.Find(x => x.Osp.Id == ospId); ICollection <EmailDTO> emails = Emails.Find(x => x.Osp.Id == ospId); ICollection <ProviderDTO> providers = Providers.Find(x => x.Osp.Id == ospId); ICollection <ReceiptDTO> receipts = Receipts.Find(u => u.Osp.Id == ospId && u.Date >= startPeriod && u.Date <= endPeriod); ICollection <ExpenseDTO> expenses = Expenses.Find(u => u.Osp.Id == ospId && u.Date >= startPeriod && u.Date <= endPeriod); ICollection <ExpenseDTO> userExpenses = Expenses.Find(u => u.User.Id == userId && u.Osp.Id == ospId && u.Date >= startPeriod && u.Date <= endPeriod); // Создать объект данных для пользователя. var userDataDTO = new OspDataDTO() { Accesses = new ObservableCollection <AccessDTO>(allAccesses), Osps = new ObservableCollection <OspDTO>(allOsps), Cartridges = new ObservableCollection <CartridgeDTO>(allCarts), Printers = new ObservableCollection <PrinterDTO>(allPrints), Balance = new ObservableCollection <BalanceDTO>(balances), Expenses = new ObservableCollection <ExpenseDTO>(expenses), UserExpenses = new ObservableCollection <ExpenseDTO>(userExpenses), Providers = new ObservableCollection <ProviderDTO>(providers), Receipts = new ObservableCollection <ReceiptDTO>(receipts), Emails = new ObservableCollection <EmailDTO>(emails), Users = new ObservableCollection <UserDTO>(allUsers) }; return(userDataDTO); }
/// <summary> /// Инициализирует данные. /// </summary> /// <param name="userDataDTO"></param> public static void Init(OspDataDTO userDataDTO) { data = new AppData(userDataDTO); // Подписка на событие изменения свойств текущего пользователя. data.UserData.CurrentUser.PropChanged += CurrentUser_PropChanged; }
/// <summary> /// Конструктор. /// </summary> /// <param name="userDataDTO"></param> private AppData(OspDataDTO userDataDTO) { UserData = userDataDTO; }