private async Task<WebsocketAction> CreateRemoveWebsocketAction(Config oldConfig, string appId) { //获取app此时的配置列表合并继承的app配置 字典 var configs = await _configService.GetPublishedConfigsByAppIdWithInheritanced_Dictionary(appId); var oldKey = _configService.GenerateKey(oldConfig); //如果oldkey已经不存在,返回remove的action if (!configs.ContainsKey(oldKey)) { var action = new WebsocketAction { Action = ActionConst.Remove, Item = new ConfigItem { group = oldConfig.Group, key = oldConfig.Key, value = oldConfig.Value } }; return action; } else { //如果还在,那么说明有继承的app的配置项目的key跟oldkey一样,那么使用继承的配置的值 //返回update的action var config = configs[oldKey]; var action = new WebsocketAction { Action = ActionConst.Update, Item = new ConfigItem { group = config.Group, key = config.Key, value = config.Value }, OldItem = new ConfigItem { group = oldConfig.Group, key = oldConfig.Key, value = oldConfig.Value } }; return action; } }
public async Task <IActionResult> ExportJson(string appId) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentNullException("appId"); } var configs = await _configService.GetByAppIdAsync(appId); var dict = new Dictionary <string, string>(); configs.ForEach(x => { var key = _configService.GenerateKey(x); dict.Add(key, x.Value); }); var json = DictionaryConvertToJson.ToJson(dict); return(File(Encoding.UTF8.GetBytes(json), "application/json", $"{appId}.json")); }