Skip to content

Commit 48d087a

Browse files
authored
Merge pull request #74 from Botinoc/dev
fix an issue with converting large files changed to the optimal number of elements at a time it writes 250,000 checkpoint objects at a time, with files containing more than 250,000 checkpoint objects As a result, everything is converted (and it takes ~ 9 minutes if it is a very large file)
2 parents b7a497e + e29798a commit 48d087a

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

MigrationBase/VendorConverter.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,17 @@ public void CreateSmartConnector(bool isNeedGenOpt = false, bool isCurrentOptimi
21702170
cpJsonObjects.RemoveAll(x => x == null);
21712171
#endregion
21722172

2173-
File.WriteAllText(cpObjectsJsonPath + cpObjectsJsonFN, JsonConvert.SerializeObject(cpJsonObjects, Formatting.Indented));
2173+
if (cpJsonObjects.Count > 250000)
2174+
{
2175+
File.WriteAllText(cpObjectsJsonPath + cpObjectsJsonFN, JsonConvert.SerializeObject(cpJsonObjects[0], Formatting.Indented));
2176+
2177+
for (var i = 1; i < cpJsonObjects.Count;)
2178+
{
2179+
var dest = cpJsonObjects.Skip(i).Take(250000).ToArray();
2180+
i += 250000;
2181+
File.AppendAllText(cpObjectsJsonPath + cpObjectsJsonFN, JsonConvert.SerializeObject(dest, Formatting.Indented));
2182+
}
2183+
} else File.WriteAllText(cpObjectsJsonPath + cpObjectsJsonFN, JsonConvert.SerializeObject(cpJsonObjects, Formatting.Indented));
21742184

21752185
string smartConnectorArchiveName = "smartconnector_" + _vendorFileName;
21762186
string smartConnectorArchivePath = _targetFolder + Path.DirectorySeparatorChar + smartConnectorArchiveName;

SmartMove/AnalyzeWindow.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ private async void Analyze_OnClickAsync(object sender, RoutedEventArgs e)
335335
"Reason: Policy exceeds the maximum number of supported policy layers.",
336336
"To assure the smooth conversion of your data, it is recommended to contact Check Point Professional Services by sending an e-mail to"));
337337
}
338+
else if (ex.Message.Contains("System.OutOfMemoryException"))
339+
{
340+
MainWindow.ShowMessage(null, MessageTypes.Error, null, null, null, null,
341+
String.Format("{1}{0}{2}", Environment.NewLine, "Could not analyze process file.",
342+
"Reason: Your device is low on memory."));
343+
}
338344
else
339345
{
340346
MainWindow.ShowMessage("Could not analyze process file.", "Message:\nModule:\nClass:\nMethod:", string.Format("{0}\n{1}\n{2}\n{3}", ex.Message, ex.Source, ex.TargetSite.ReflectedType.Name, ex.TargetSite.Name), MessageTypes.Error);

SmartMove/MainWindow.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,12 @@ private async void Go_OnClick(object sender, RoutedEventArgs e)
765765
}
766766
else
767767
{
768+
if (ex.Message.Contains("System.OutOfMemoryException"))
769+
{
770+
ShowMessage(null, MessageTypes.Error, null, null, null, null,
771+
String.Format("{1}{0}{2}", Environment.NewLine, "Could not convert configuration file.",
772+
"Reason: Your device is low on memory."));
773+
} else
768774
ShowMessage("Could not convert configuration file.", "Message:\nModule:\nClass:\nMethod:", string.Format("{0}\n{1}\n{2}\n{3}", ex.Message, ex.Source, ex.TargetSite.ReflectedType.Name, ex.TargetSite.Name), MessageTypes.Error);
769775
}
770776
return;

0 commit comments

Comments
 (0)