コード例 #1
0
ファイル: MainDataContext.cs プロジェクト: yurseli/sambapos
        public void ResetCache()
        {
            Debug.Assert(_ticketWorkspace.Ticket == null);

            if (_tableWorkspace == null)
            {
                var selectedDepartment  = SelectedDepartment != null ? SelectedDepartment.Id : 0;
                var selectedTableScreen = SelectedTableScreen != null ? SelectedTableScreen.Id : 0;

                SelectedTableScreen = null;
                SelectedDepartment  = null;

                _tableScreens         = null;
                _departments          = null;
                _permittedDepartments = null;
                _reasons            = null;
                _lastTwoWorkPeriods = null;
                _users               = null;
                _rules               = null;
                _actions             = null;
                _vatTemplates        = null;
                _taxServiceTemplates = null;

                if (selectedTableScreen > 0 && TableScreens.Count(x => x.Id == selectedTableScreen) > 0)
                {
                    SelectedTableScreen = TableScreens.Single(x => x.Id == selectedTableScreen);
                }
                if (selectedDepartment > 0 && Departments.Count(x => x.Id == selectedDepartment) > 0)
                {
                    SelectedDepartment = Departments.Single(x => x.Id == selectedDepartment);
                }
            }
        }
        internal static void LoadToMongoDB()
        {
            try
            {
                _applicationLogs.WriteInformation("----LoadToMongoDB -> Process started-------");

                _client = new MongoClient("mongodb://localhost:27017");

                _database = _client.GetDatabase("AttendanceDB");
                _accessEventsCollection = _database.GetCollection <AccessEvent>("AccessEvents");
                _accessPointsCollection = _database.GetCollection <AccessPoint>("AccessPoints");

                _database            = _client.GetDatabase("EmployeeDB");
                _employeesCollection = _database.GetCollection <Employee>("Employees");

                _database = _client.GetDatabase("OperationalsDB");
                _departmentsCollection = _database.GetCollection <Department>("Departments");

                _database        = _client.GetDatabase("AuthDB");
                _usersCollection = _database.GetCollection <User>("Users");

                _applicationLogs.WriteInformation("Mongo Database loaded");
                _applicationLogs.WriteInformation($"Departments count:{Departments?.Count()}");
                foreach (var v in Departments)
                {
                    AddDepartment(v);
                }

                _applicationLogs.WriteInformation($"Employees count:{Employees?.Count()}");
                foreach (var v in Employees)
                {
                    AddEmployee(v);
                }

                _applicationLogs.WriteInformation($"AccessPoints count:{AccessPoints?.Count()}");
                foreach (var v in AccessPoints)
                {
                    AddAccessPoint(v);
                }

                _applicationLogs.WriteInformation($"MonthlyAccessLogs count:{MonthlyAccessLogs?.Count()}");
                foreach (var v in MonthlyAccessLogs)
                {
                    foreach (var e in v.AccessEvents)
                    {
                        AddAccessLog(e);
                    }
                }
                _applicationLogs.WriteInformation($"----LoadToMongoDB -> Process completed----");
            }
            catch (Exception ex)
            {
                _applicationLogs.WriteInformation($"Error:{ex.Message} \n {ex.StackTrace}\n {ex.StackTrace}");
            }
        }