/// <summary> /// Export из БД /// </summary> /// <param name="serverName"></param> /// <param name="dbName"></param> /// <param name="records"></param> /// <param name="path"></param> /// <param name="isOverwrite"></param> public static void Write(string serverName, string dbName, List <BreRecord> records, string path, bool isOverwrite) { var deploymentDriver = RuleAndVocabDbAdapter.GetDeploymentDriver(serverName, dbName); foreach (var record in records) //если флаг isOverwrite = false, проверяем на сущ-ие фаила на диске { if (!isOverwrite) { if (File.Exists(Path.Combine(path, $"{record.Name}-{record.MajorRevision}.{record.MinorRevision}.xml"))) { Error?.Invoke($@"фаил {record.Name}-{record.MajorRevision}.{record.MinorRevision} уже существует"); } } } foreach (var record in records) { if (record is RuleRecord) { var rule = (RuleRecord)record; deploymentDriver.ExportRuleSetToFileRuleStore(rule.RuleSetInfo, Path.Combine(path, $"{record.Name}-{record.MajorRevision}.{record.MinorRevision}.xml")); } else { var vocab = (VocabRecord)record; deploymentDriver.ExportVocabularyToFileRuleStore(vocab.VocabularyRecord, Path.Combine(path, $"{record.Name}-{record.MajorRevision}.{record.MinorRevision}.xml")); } } }
/// <summary> /// Import в БД /// </summary> /// <param name="serverName"></param> /// <param name="dbName"></param> /// <param name="records"></param> public static void Read(string serverName, string dbName, List <BreRecord> records) { var deploymentDriver = RuleAndVocabDbAdapter.GetDeploymentDriver(serverName, dbName); foreach (var record in records) //при записи в БД необходимо сначала записывать vocab. List<BreRecord> records - это parsed.BreRecods { if (record is VocabRecord) { deploymentDriver.ImportAndPublishFileRuleStore(record.FullFileName); } } foreach (var record in records) { if (record is RuleRecord) { deploymentDriver.ImportAndPublishFileRuleStore(record.FullFileName); } } }