private static void SaveApplicationObjectToFile(string filePath, IMetadataService metadataService, string metadataName) { string[] names = metadataName.Split('.'); if (names.Length != 2) { return; } string typeName = names[0]; string objectName = names[1]; ApplicationObject metaObject = null; Dictionary <Guid, ApplicationObject> collection = null; InfoBase infoBase = metadataService.LoadInfoBase(); if (typeName == "Справочник") { collection = infoBase.Catalogs; } else if (typeName == "Документ") { collection = infoBase.Documents; } else if (typeName == "ПланОбмена") { collection = infoBase.Publications; } else if (typeName == "РегистрСведений") { collection = infoBase.InformationRegisters; } else if (typeName == "РегистрНакопления") { collection = infoBase.AccumulationRegisters; } if (collection == null) { return; } metaObject = collection.Values.Where(o => o.Name == objectName).FirstOrDefault(); if (metaObject == null) { return; } byte[] fileData = metadataService.ReadBytes(metaObject.FileName.ToString()); if (fileData == null) { return; } using (StreamReader reader = metadataService.CreateReader(fileData)) using (StreamWriter writer = new StreamWriter(filePath, false, Encoding.UTF8)) { writer.Write(reader.ReadToEnd()); } }
private static void SaveConfigToFile(string filePath, IMetadataService metadataService) { string fileName = metadataService.GetConfigurationFileName(); byte[] fileData = metadataService.ReadBytes(fileName); using (StreamReader reader = metadataService.CreateReader(fileData)) using (StreamWriter writer = new StreamWriter(filePath, false, Encoding.UTF8)) { writer.Write(reader.ReadToEnd()); } }