-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R&D - New Repository Serializer #3543
base: master
Are you sure you want to change the base?
Changes from all commits
153ef0b
f9bda40
1c7b018
0d39388
0a61c82
5d2edc6
805d99d
b56e046
7740d35
b468e48
f4f259e
fbefb95
1ec9446
9211148
7a9f50d
54cc5d6
f2f593c
56860ac
e2ad278
a9d304b
4175f02
44b7ddb
cd9b233
57a1314
1499fb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,7 +274,15 @@ private async Task LoadChildItems(TreeViewItem treeViewItem) | |
if (hadDummyNode) | ||
{ | ||
SetRepositoryFolderIsExpanded(treeViewItem, isExpanded: true); | ||
Stopwatch stopwatch = new(); | ||
stopwatch.Start(); | ||
await SetTreeNodeItemChilds(treeViewItem); | ||
stopwatch.Stop(); | ||
System.Diagnostics.Debug.WriteLine($"All BusinessFlow UI Item loaded in {new DateTime(stopwatch.Elapsed.Ticks).ToString("ss:fff")}s"); | ||
Dispatcher.Invoke(() => | ||
{ | ||
Reporter.ToUser(eUserMsgKey.AllBusinessFlowLoadTime, new DateTime(stopwatch.Elapsed.Ticks).ToString("ss.fff")); | ||
}); | ||
GingerCore.General.DoEvents(); | ||
// remove the handler as expand data is cached now on tree | ||
WeakEventManager<TreeViewItem, RoutedEventArgs>.RemoveHandler(treeViewItem, nameof(TreeViewItem.Expanded), TVI_Expanded); | ||
|
@@ -315,7 +323,11 @@ private Task SetTreeNodeItemChilds(TreeViewItem TVI) | |
|
||
if (TVI.Tag is ITreeViewItem ITVI) | ||
{ | ||
Stopwatch stopwatch = new(); | ||
stopwatch.Start(); | ||
List<ITreeViewItem> Childs = ITVI.Childrens(); | ||
stopwatch.Stop(); | ||
Debug.WriteLine($"All BusinessFlow TreeViewItems loaded in {new DateTime(stopwatch.Elapsed.Ticks).ToString("ss.fff")}s"); | ||
|
||
TVI.Items.Clear(); | ||
if (Childs != null) | ||
|
@@ -325,26 +337,46 @@ private Task SetTreeNodeItemChilds(TreeViewItem TVI) | |
try | ||
{ | ||
mSetTreeNodeItemChildsEvent = new AutoResetEvent(false); | ||
foreach (ITreeViewItem item in Childs) | ||
Stopwatch stopwatch2 = new(); | ||
stopwatch2.Start(); | ||
Dispatcher.Invoke(() => | ||
{ | ||
|
||
if (TreeChildFolderOnly == true && item.IsExpandable() == false) | ||
//Stopwatch stopwatch3 = new(); | ||
//stopwatch3.Start(); | ||
foreach (ITreeViewItem item in Childs) | ||
{ | ||
continue; | ||
} | ||
if (TreeNodesFilterByField != null) | ||
{ | ||
if (IsTreeItemFitsFilter(item)) | ||
//Stopwatch stopwatch4 = new(); | ||
//stopwatch4.Start(); | ||
if (TreeChildFolderOnly == true && item.IsExpandable() == false) | ||
{ | ||
Dispatcher.Invoke(() => AddItem(item, TVI)); | ||
continue; | ||
} | ||
if (TreeNodesFilterByField != null) | ||
{ | ||
if (IsTreeItemFitsFilter(item)) | ||
{ | ||
//Dispatcher.Invoke(() => | ||
//{ | ||
AddItem(item, TVI); | ||
//}); | ||
} | ||
} | ||
else | ||
{ | ||
//Dispatcher.Invoke(() => | ||
//{ | ||
AddItem(item, TVI); | ||
//}); | ||
} | ||
//Thread.Sleep(5); | ||
//stopwatch4.Stop(); | ||
//Debug.WriteLine($"BusinessFlow TVI Item added to Tree in {stopwatch4.Elapsed.TotalMilliseconds}ms"); | ||
} | ||
else | ||
{ | ||
Dispatcher.Invoke(() => AddItem(item, TVI)); | ||
} | ||
Thread.Sleep(5); | ||
} | ||
//stopwatch3.Stop(); | ||
//Debug.WriteLine($"All BusinessFlow TVI Items added to Tree from Dispatcher in {stopwatch3.Elapsed.TotalSeconds}s"); | ||
}); | ||
stopwatch2.Stop(); | ||
Debug.WriteLine($"All BusinessFlow TVI Items added to Tree in {stopwatch2.Elapsed.TotalSeconds}s"); | ||
mSetTreeNodeItemChildsEvent.Set(); | ||
if (tviChildNodesLoadTaskMap.ContainsKey(TVI)) | ||
{ | ||
Comment on lines
337
to
382
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The use of a Stopwatch to measure the time taken to load TreeViewItems (lines 326-330) and the subsequent addition of items to the TreeView within a
- Stopwatch stopwatch2 = new();
- stopwatch2.Start();
+ // Consider abstracting the Stopwatch usage into a utility method for better code reuse and readability.
- Dispatcher.Invoke(() =>
- {
- foreach (ITreeViewItem item in Childs)
- {
- AddItem(item, TVI);
- }
- });
+ // Explore optimizing the Dispatcher.Invoke usage for batch updates to improve performance. |
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,13 +22,18 @@ limitations under the License. | |||||||||||||||||||||||||
using System.Drawing; | ||||||||||||||||||||||||||
using System.IO; | ||||||||||||||||||||||||||
using System.Linq; | ||||||||||||||||||||||||||
using System.Linq.Expressions; | ||||||||||||||||||||||||||
using System.Reflection; | ||||||||||||||||||||||||||
using System.Runtime.InteropServices; | ||||||||||||||||||||||||||
using System.Xml; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.Actions; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.Enums; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.GeneralLib; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.InterfacesLib; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.Repository; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.Repository.Serialization; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.SourceControlLib; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Common.UIElement; | ||||||||||||||||||||||||||
using Amdocs.Ginger.Repository; | ||||||||||||||||||||||||||
using GingerCore.Actions.Common; | ||||||||||||||||||||||||||
|
@@ -696,6 +701,37 @@ public ObservableList<FlowControl> ActFlowControls | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
private static Dictionary<string, Act> _nameToActMap = new(); | ||||||||||||||||||||||||||
private static readonly IEnumerable<string> ActAssemblyNames = new List<string>() | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
"GingerCoreCommon", | ||||||||||||||||||||||||||
"GingerCoreNET" | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
Comment on lines
+704
to
+709
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The introduction of a static dictionary - private static Dictionary<string, Act> _nameToActMap = new();
+ private static ConcurrentDictionary<string, Act> _nameToActMap = new ConcurrentDictionary<string, Act>(); Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
public Act() { } | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
public Act(DeserializedSnapshot snapshot) : base(snapshot) | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
Active = snapshot.GetValueAsBool(nameof(Active)); | ||||||||||||||||||||||||||
Description = snapshot.GetValue(nameof(Description)); | ||||||||||||||||||||||||||
Platform = snapshot.GetValueAsEnum<ePlatformType>(nameof(Platform)); | ||||||||||||||||||||||||||
RetryMechanismInterval = snapshot.GetValueAsInt(nameof(RetryMechanismInterval)); | ||||||||||||||||||||||||||
StatusConverter = snapshot.GetValueAsEnum<eStatusConverterOptions>(nameof(StatusConverter)); | ||||||||||||||||||||||||||
WindowsToCapture = snapshot.GetValueAsEnum<eWindowsToCapture>(nameof(WindowsToCapture)); | ||||||||||||||||||||||||||
InputValues = new(snapshot.GetValues<ActInputValue>(nameof(InputValues))); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
protected override SerializedSnapshot.Builder WriteSnapshotProperties(SerializedSnapshot.Builder snapshotBuilder) | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
return base.WriteSnapshotProperties(snapshotBuilder) | ||||||||||||||||||||||||||
.WithValue(nameof(Active), Active.ToString()) | ||||||||||||||||||||||||||
.WithValue(nameof(Description), Description) | ||||||||||||||||||||||||||
.WithValue(nameof(Platform), Platform.ToString()) | ||||||||||||||||||||||||||
.WithValue(nameof(RetryMechanismInterval), RetryMechanismInterval.ToString()) | ||||||||||||||||||||||||||
.WithValue(nameof(StatusConverter), StatusConverter.ToString()) | ||||||||||||||||||||||||||
.WithValue(nameof(WindowsToCapture), WindowsToCapture.ToString()) | ||||||||||||||||||||||||||
.WithValues(nameof(InputValues), InputValues.Cast<RepositoryItemBase>()); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
#region ActInputValues | ||||||||||||||||||||||||||
public void AddInputValueParam(string ParamName) | ||||||||||||||||||||||||||
|
@@ -2016,7 +2052,5 @@ public override string GetItemType() | |||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
return "Action"; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<MethodTimer /> | ||
</Weavers> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> | ||
<xs:element name="Weavers"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element name="MethodTimer" minOccurs="0" maxOccurs="1" type="xs:anyType" /> | ||
</xs:all> | ||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="GenerateXsd" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,12 @@ | |
<CodeAnalysisRuleSet>GingerCoreCommon.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="Repository\TempSerializers\**" /> | ||
<EmbeddedResource Remove="Repository\TempSerializers\**" /> | ||
<None Remove="Repository\TempSerializers\**" /> | ||
</ItemGroup> | ||
Comment on lines
+35
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removal of |
||
|
||
<ItemGroup> | ||
<PackageReference Include="Ginger.External" Version="1.0.0" /> | ||
<PackageReference Include="LiteDB" Version="5.0.17" /> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,10 +19,12 @@ | |||||||||||||||||||||||
using System; | ||||||||||||||||||||||||
using System.Collections.Generic; | ||||||||||||||||||||||||
using System.Linq; | ||||||||||||||||||||||||
using System.Xml; | ||||||||||||||||||||||||
using Amdocs.Ginger.Common; | ||||||||||||||||||||||||
using Amdocs.Ginger.Common.Enums; | ||||||||||||||||||||||||
using Amdocs.Ginger.Common.InterfacesLib; | ||||||||||||||||||||||||
using Amdocs.Ginger.Common.Repository; | ||||||||||||||||||||||||
using Amdocs.Ginger.Common.Repository.Serialization; | ||||||||||||||||||||||||
using Amdocs.Ginger.Common.WorkSpaceLib; | ||||||||||||||||||||||||
using Amdocs.Ginger.Repository; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
@@ -49,8 +51,19 @@ | |||||||||||||||||||||||
set { _executionLoggerStatus = value; } | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
public ActivitiesGroup() | ||||||||||||||||||||||||
public ActivitiesGroup() { } | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
public ActivitiesGroup(DeserializedSnapshot snapshot) : base(snapshot) | ||||||||||||||||||||||||
{ | ||||||||||||||||||||||||
Name = snapshot.GetValue(nameof(Name)); | ||||||||||||||||||||||||
ActivitiesIdentifiers = new(snapshot.GetValues<ActivityIdentifiers>(nameof(ActivitiesIdentifiers))); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
Comment on lines
+56
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The constructor + if (snapshot == null) throw new ArgumentNullException(nameof(snapshot)); Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
protected override SerializedSnapshot.Builder WriteSnapshotProperties(SerializedSnapshot.Builder snapshotBuilder) | ||||||||||||||||||||||||
{ | ||||||||||||||||||||||||
return base.WriteSnapshotProperties(snapshotBuilder) | ||||||||||||||||||||||||
.WithValue(nameof(Name), Name) | ||||||||||||||||||||||||
.WithValues(nameof(ActivitiesIdentifiers), ActivitiesIdentifiers.Cast<RepositoryItemBase>()); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
private string mName; | ||||||||||||||||||||||||
|
@@ -172,7 +185,7 @@ | |||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
[IsSerializedForLocalRepository] | ||||||||||||||||||||||||
public string ExternalID2 { get; set; } // used to store the actual TC ID when importing it from QC in case the TC type is linked TC | ||||||||||||||||||||||||
Check warning on line 188 in Ginger/GingerCoreCommon/Repository/BusinessFlowLib/ActivitiesGroup.cs GitHub Actions / Build Stage / build
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
public string AutomationPrecentage | ||||||||||||||||||||||||
|
@@ -520,6 +533,5 @@ | |||||||||||||||||||||||
ExternalIdCalculated = ve.ValueCalculated; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of the Stopwatch to measure the loading time of UI items and the use of
Dispatcher.Invoke
for UI updates are good practices for optimizing UI performance. However, consider the following improvements:System.Diagnostics.Debug
(line 281) is useful during development but consider using a more flexible logging framework for production. This allows for easier control over logging levels and destinations.new DateTime(stopwatch.Elapsed.Ticks).ToString("ss:fff")
for formatting the elapsed time is a bit unconventional. Instead, you can directly usestopwatch.Elapsed.ToString("ss\\.fff")
to achieve the same result with clearer intent.Reporter.ToUser
within theDispatcher.Invoke
block (lines 282-285) is a good way to provide feedback to the user. Ensure that this feedback mechanism is consistent with the rest of the application and that it does not disrupt the user experience with excessive notifications.Committable suggestion