private void SaveSysConfigs()
        {
            try
            {
                var values = "";
                values += string.Format("{0}={1};", ConstStrings.SysLogExpireMonths,
                                        SysLogExpiredMonthsConfigViewModel.IsSelected ? SysLogExpiredMonthsConfigViewModel.Value : "0");

                values += string.Format("{0}={1};", ConstStrings.DeviceMngtLogExpiredMonths,
                                        DeviceMngtLogExpiredMonthsConfigViewModel.IsSelected ? DeviceMngtLogExpiredMonthsConfigViewModel.Value : "0");

                values += string.Format("{0}={1};", ConstStrings.DeviceTrafficLogExpiredMonths,
                                        DeviceTrafficLogExpiredMonthsConfigViewModel.IsSelected ? DeviceTrafficLogExpiredMonthsConfigViewModel.Value : "0");

                values += string.Format("{0}={1};", ConstStrings.DoorHistoryExpiredMonths,
                                        DoorHistoryExpiredMonthsConfigViewModel.IsSelected ? DoorHistoryExpiredMonthsConfigViewModel.Value : "0");

                var autoCleanConfig = _sysConfigRepository.Query(new Hashtable()).FirstOrDefault(x => x.Name == ConstStrings.AutoCleanConfig);

                autoCleanConfig.Value = values;
                _sysConfigRepository.Update(autoCleanConfig);

                Messenger.Default.Send(new NotificationMessage("保存成功!"), Tokens.DataCleanPage_ShowNotification);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Example #2
0
        private void SaveDataSyncSettings()
        {
            try
            {
                var defaultDepartmentConfig = _sysConfigRepository.Query(new Hashtable()).FirstOrDefault(x => x.Name == ConstStrings.DataSyncDefaultDepartment);
                var defaultRoleConfig       = _sysConfigRepository.Query(new Hashtable()).FirstOrDefault(x => x.Name == ConstStrings.DataSyncDefaultRole);
                var dataSyncConfig          = _sysConfigRepository.Query(new Hashtable()).FirstOrDefault(x => x.Name == ConstStrings.DataSyncConfig);

                Log.Info("保存缺省部门...");
                defaultDepartmentConfig.Value = DefaultDepartment.DepartmentID == 0? "" : DefaultDepartment.DepartmentID.ToString();
                _sysConfigRepository.Update(defaultDepartmentConfig);

                Log.Info("保存缺省角色...");
                defaultRoleConfig.Value = DefaultDeviceRole.DeviceRoleID == 0 ? "" : DefaultDeviceRole.DeviceRoleID.ToString();
                _sysConfigRepository.Update(defaultRoleConfig);

                Log.Info("保存同步时间...");
                string configValues = "";

                var enabledItems = DataSyncJobTimeConfigViewModels.FindAll(x => x.IsSelected);
                if (enabledItems.Any())
                {
                    configValues = string.Join(";", enabledItems.Select(x =>
                    {
                        var mydt = DateTime.Parse(x.Value);
                        return(mydt.ToString("HH:mm:ss"));
                    }));
                }

                dataSyncConfig.Value = configValues;
                _sysConfigRepository.Update(dataSyncConfig);

                Messenger.Default.Send(new NotificationMessage("保存成功!"), Tokens.DataSyncPage_ShowNotification);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }