Skip to content

Commit

Permalink
Disable rewrite file
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillGutyrchik committed Oct 24, 2024
1 parent 668d8a6 commit 446d2c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/ProjectImportICP/ChannelBaseTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ public static string ModifyID(string newChannelDB, string oldChannelDB, IEnumera
.Where(t => t.NewID != null && t.OldID != null)
.ToDictionary(j => j.NewID, j => j.Enabled);


var replaceRegex = new Regex($@"(?<=<channels:id>){string.Join("|", IdToReplaced.Keys)}(?=<\/channels:id>)",
RegexOptions.None, TimeSpan.FromMilliseconds(10000));

var replaceEnableRegex = new Regex($@"(?<=<channels:id>(?<id>{string.Join("|", IdEnable.Keys)})<\/channels:id>[\d\w\s</>:]*<channels:enabled>)0",
RegexOptions.None, TimeSpan.FromMilliseconds(10000));

// enable used tags
var chbaseWithEnabled = replaceEnableRegex.Replace(newChannelDB, m => IdEnable[m.Groups["id"].Value]);

var replaceRegex = new Regex($@"(?<=<channels:id>){string.Join("|", IdToReplaced.Keys)}(?=<\/channels:id>)",
RegexOptions.None, TimeSpan.FromMilliseconds(10000));

return replaceRegex.Replace(chbaseWithEnabled, m => IdToReplaced[m.Value]);
}

Expand Down
6 changes: 1 addition & 5 deletions src/ProjectImportICP/ModifyChannelsDBDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@ private void ModifyBttn_Click(object sender, EventArgs e)
// Проверка совпадения индексов
ChannelBaseTransformer.CheckChbaseID(modifiedDstChbase);

// Смена названия файла для сохранения, если такой уже существует
var dstSavePath = needExport?
dstPath : Path.Combine(Path.GetDirectoryName(dstPath), Path.GetFileNameWithoutExtension(dstPath) + "_reindex.cdbx");

using (var writer = new StreamWriter(dstSavePath, false, Encoding.UTF8))
using (var writer = new StreamWriter(dstPath, false, Encoding.UTF8))
writer.Write(modifiedDstChbase);

Logs.SetProgress(100);
Expand Down

0 comments on commit 446d2c4

Please sign in to comment.