示例#1
0
        /// <summary>
        /// 保存Vault列表信息
        /// </summary>
        /// <param name="model"></param>
        public void SaveConfig(VaultConfigModel model)
        {
            var dir    = GetConfigFileDir(AppFolderName);
            var folder = Path.Combine(dir, model.UserId.ToString(CultureInfo.InvariantCulture));

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            var filePath = Path.Combine(folder, VaultConfigFileName);

            XmlSerializerUtil.SaveToXml(filePath, model, typeof(VaultConfigModel));
        }
示例#2
0
        /// <summary>
        /// 获取vault列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public VaultConfigModel LoadCurrVaultListConfig(long userId)
        {
            var dir      = GetConfigFileDir(AppFolderName);
            var folder   = Path.Combine(dir, userId.ToString(CultureInfo.InvariantCulture));
            var filePath = Path.Combine(folder, VaultConfigFileName);
            var models   = XmlSerializerUtil.LoadFromXml(filePath, typeof(VaultConfigModel));

            if (models == null)
            {
                return(new VaultConfigModel());
            }

            return(models as VaultConfigModel);
        }
示例#3
0
        /// <summary>
        /// 获取消息通知配置文件
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public NotificationConfigModel LoadCurrNotificationConfig(long userId)
        {
            var dir      = GetConfigFileDir(AppFolderName);
            var folder   = Path.Combine(dir, userId.ToString(CultureInfo.InvariantCulture));
            var filePath = Path.Combine(folder, NotificationConfigFileName);
            var model    = XmlSerializerUtil.LoadFromXml(filePath, typeof(NotificationConfigModel));

            if (model == null)
            {
                return(new NotificationConfigModel());
            }

            return(model as NotificationConfigModel);
        }
示例#4
0
        /// <summary>
        /// 获取所有用户配置
        /// </summary>
        /// <returns></returns>
        public List <UserConfigModel> LoadAllConfigs(string configName, Type configType)
        {
            var configs = new List <UserConfigModel>();

            var dir       = GetConfigFileDir(AppFolderName);
            var filesPath = GetAllConfiglPath(dir, configName);

            foreach (var path in filesPath)
            {
                var model = XmlSerializerUtil.LoadFromXml(path, configType)
                            as UserConfigModel;
                configs.Add(model);
            }

            return(configs);
        }