@@ -71,44 +71,35 @@ codeunit 40021 "Cloud Mig. Replicate Data Mgt."
71
71
exit ( CanBeIncluded) ;
72
72
end ;
73
73
74
- procedure CheckAndIncludeExcludeTableListFromCloudMigration( TableIDList: List of [Integer ]; NewReplicateData: Boolean )
75
- var
76
- Company: Record Company;
74
+ procedure IncludeTableToReplication( TableID: Integer ; CompanyName: Text [30 ])
75
+ begin
76
+ IncludeExcludeTableFromReplication( TableID, CompanyName, true) ;
77
+ end ;
78
+
79
+ procedure ExcludeTableFromReplication( TableID: Integer ; CompanyName: Text [30 ])
77
80
begin
78
- if Company. FindSet() then
79
- repeat
80
- CheckAndIncludeExcludeTableListFromCloudMigration( TableIDList, Company. Name, NewReplicateData) ;
81
- until Company. Next() = 0 ;
82
- CheckAndIncludeExcludeTableListFromCloudMigration( TableIDList, ' ' , NewReplicateData) ;
81
+ IncludeExcludeTableFromReplication( TableID, CompanyName, false) ;
83
82
end ;
84
83
85
- procedure CheckAndIncludeExcludeTableListFromCloudMigration ( TableIDList: List of [ Integer ]; SelectedCompany : Text [30 ]; NewReplicateData: Boolean )
84
+ local procedure IncludeExcludeTableFromReplication ( TableID: Integer ; CompanyName : Text [30 ]; NewReplicateData: Boolean )
86
85
var
87
86
IntelligentCloudStatus: Record "Intelligent Cloud Status";
88
- TableIDFilter: Text ;
89
- TableID: Integer ;
90
- i: Integer ;
87
+ TablesModified: Text ;
91
88
SeparatorChar: Char ;
92
89
begin
93
- if TableIDList. Count = 0 then
90
+ IntelligentCloudStatus. SetRange( "Table Id", TableID) ;
91
+ IntelligentCloudStatus. SetRange( "Company Name", CompanyName) ;
92
+ if not IntelligentCloudStatus. FindSet() then
94
93
exit ;
95
94
96
- SeparatorChar := ' |' ;
97
- for i := 1 to TableIDList. Count do begin
98
- TableIDList. Get( i, TableID) ;
99
- TableIDFilter += Format( TableID) + SeparatorChar;
100
- end ;
101
- TableIDFilter := TableIDFilter. TrimEnd( SeparatorChar) ;
102
- IntelligentCloudStatus. SetRange( "Company Name", SelectedCompany) ;
103
- IntelligentCloudStatus. SetFilter( "Table Id", TableIDFilter) ;
104
- if IntelligentCloudStatus. FindSet() then
105
- repeat
106
- IntelligentCloudStatus. Mark( true) ;
107
- until IntelligentCloudStatus. Next() = 0 ;
108
- IntelligentCloudStatus. MarkedOnly() ;
109
-
110
95
CheckCanChangeTheTable( IntelligentCloudStatus) ;
111
- IncludeExcludeTablesFromCloudMigration( IntelligentCloudStatus, NewReplicateData) ;
96
+ SeparatorChar := ' ,' ;
97
+ IntelligentCloudStatus. FindSet() ;
98
+ repeat
99
+ UpdatePreserveDataForTable( IntelligentCloudStatus, TablesModified, SeparatorChar, NewReplicateData) ;
100
+ until IntelligentCloudStatus. Next() = 0 ;
101
+
102
+ LogMessageForChangedReplicateData( Format( TableID) , NewReplicateData) ;
112
103
end ;
113
104
114
105
internal procedure IncludeExcludeTablesFromCloudMigration( var IntelligentCloudStatus: Record "Intelligent Cloud Status"; NewReplicateData: Boolean )
@@ -123,22 +114,66 @@ codeunit 40021 "Cloud Mig. Replicate Data Mgt."
123
114
124
115
SeparatorChar := ' ,' ;
125
116
repeat
126
- if IntelligentCloudStatus. "Replicate Data" <> NewReplicateData then begin
127
- InsertInitialLog( IntelligentCloudStatus) ;
128
- IntelligentCloudStatus. "Replicate Data" := NewReplicateData;
129
- IntelligentCloudStatus. Modify () ;
130
- InsertModifyLog( IntelligentCloudStatus) ;
131
- TablesModified += IntelligentCloudStatus. "Table Name" + SeparatorChar;
132
- end ;
117
+ UpdatePreserveDataForTable( IntelligentCloudStatus, TablesModified, SeparatorChar, NewReplicateData) ;
133
118
until IntelligentCloudStatus. Next() = 0 ;
134
119
135
120
TablesModified := TablesModified. TrimEnd( SeparatorChar) ;
121
+ LogMessageForChangedReplicateData( TablesModified, NewReplicateData) ;
122
+ end ;
123
+
124
+ local procedure UpdateReplicateDataForTable( var IntelligentCloudStatus: Record "Intelligent Cloud Status"; var TablesModified: Text ; SeparatorChar: Char ; NewReplicateData: Boolean )
125
+ begin
126
+ if IntelligentCloudStatus. "Replicate Data" <> NewReplicateData then begin
127
+ InsertInitialLog( IntelligentCloudStatus) ;
128
+ IntelligentCloudStatus. "Replicate Data" := NewReplicateData;
129
+ IntelligentCloudStatus. Modify () ;
130
+ InsertModifyLog( IntelligentCloudStatus) ;
131
+ TablesModified += IntelligentCloudStatus. "Table Name" + SeparatorChar;
132
+ end ;
133
+ end ;
134
+
135
+ local procedure LogMessageForChangedReplicateData( TablesModified: Text ; NewReplicateData: Boolean )
136
+ var
137
+ HybridCloudManagement: Codeunit "Hybrid Cloud Management";
138
+ TelemetryDictionary: Dictionary of [Text , Text ];
139
+ begin
136
140
TelemetryDictionary. Add ( ' Category' , HybridCloudManagement. GetTelemetryCategory()) ;
137
141
TelemetryDictionary. Add ( ' TablesModified' , TablesModified) ;
138
142
TelemetryDictionary. Add ( ' ReplicateData' , Format( NewReplicateData, 0 , 9 )) ;
139
143
Session. LogMessage( ' 0000MRJ' , ChangedReplicationPropertyLbl, Verbosity ::Normal, DataClassification ::SystemMetadata, TelemetryScope::ExtensionPublisher, TelemetryDictionary) ;
140
144
end ;
141
145
146
+ procedure SetPreserveDataForTable( TableID: Integer ; CompanyName: Text [30 ])
147
+ begin
148
+ SetResetPreserveDataForTable( TableID, CompanyName, true) ;
149
+ end ;
150
+
151
+ procedure ResetPreserveDataForTable( TableID: Integer ; CompanyName: Text [30 ])
152
+ begin
153
+ SetResetPreserveDataForTable( TableID, CompanyName, false) ;
154
+ end ;
155
+
156
+ local procedure SetResetPreserveDataForTable( TableID: Integer ; CompanyName: Text [30 ]; NewPreserveCloudData: Boolean )
157
+ var
158
+ IntelligentCloudStatus: Record "Intelligent Cloud Status";
159
+ TablesModified: Text ;
160
+ SeparatorChar: Char ;
161
+ begin
162
+ IntelligentCloudStatus. SetRange( "Table Id", TableID) ;
163
+ IntelligentCloudStatus. SetRange( "Company Name", CompanyName) ;
164
+ if not IntelligentCloudStatus. FindSet() then
165
+ exit ;
166
+
167
+ CheckCanChangeTheTable( IntelligentCloudStatus) ;
168
+ SeparatorChar := ' ,' ;
169
+ IntelligentCloudStatus. FindSet() ;
170
+ repeat
171
+ UpdatePreserveDataForTable( IntelligentCloudStatus, TablesModified, SeparatorChar, NewPreserveCloudData) ;
172
+ until IntelligentCloudStatus. Next() = 0 ;
173
+
174
+ LogMessageForChangedPreserveData( Format( TableID) , NewPreserveCloudData) ;
175
+ end ;
176
+
142
177
internal procedure ChangePreserveCloudData( var IntelligentCloudStatus: Record "Intelligent Cloud Status"; NewPreserveCloudData: Boolean )
143
178
var
144
179
HybridCloudManagement: Codeunit "Hybrid Cloud Management";
@@ -151,21 +186,35 @@ codeunit 40021 "Cloud Mig. Replicate Data Mgt."
151
186
152
187
SeparatorChar := ' ,' ;
153
188
repeat
154
- if IntelligentCloudStatus. "Preserve Cloud Data" <> NewPreserveCloudData then begin
155
- if ( not NewPreserveCloudData) and ( IntelligentCloudStatus. "Table Id" = Database ::"Tenant Media") then
156
- Error( NotPossibleToReplaceTenantMediaTableErr) ;
157
-
158
- if ( NewPreserveCloudData) and ( IntelligentCloudStatus. "Company Name" = ' ' ) then
159
- Error( NotPossibleToDeltaSyncDataPerCompanyErr) ;
160
-
161
- InsertInitialLog( IntelligentCloudStatus) ;
162
- IntelligentCloudStatus. "Preserve Cloud Data" := NewPreserveCloudData;
163
- IntelligentCloudStatus. Modify () ;
164
- InsertModifyLog( IntelligentCloudStatus) ;
165
- end ;
189
+ UpdatePreserveDataForTable( IntelligentCloudStatus, TablesModified, SeparatorChar, NewPreserveCloudData) ;
166
190
until IntelligentCloudStatus. Next() = 0 ;
167
191
168
192
TablesModified := TablesModified. TrimEnd( SeparatorChar) ;
193
+ LogMessageForChangedPreserveData( TablesModified, NewPreserveCloudData) ;
194
+ end ;
195
+
196
+ local procedure UpdatePreserveDataForTable( var IntelligentCloudStatus: Record "Intelligent Cloud Status"; var TablesModified: Text ; SeparatorChar: Char ; NewPreserveCloudData: Boolean )
197
+ begin
198
+ if IntelligentCloudStatus. "Preserve Cloud Data" <> NewPreserveCloudData then begin
199
+ if ( not NewPreserveCloudData) and ( IntelligentCloudStatus. "Table Id" = Database ::"Tenant Media") then
200
+ Error( NotPossibleToReplaceTenantMediaTableErr) ;
201
+
202
+ if ( NewPreserveCloudData) and ( IntelligentCloudStatus. "Company Name" = ' ' ) then
203
+ Error( NotPossibleToDeltaSyncDataPerCompanyErr) ;
204
+
205
+ InsertInitialLog( IntelligentCloudStatus) ;
206
+ IntelligentCloudStatus. "Preserve Cloud Data" := NewPreserveCloudData;
207
+ IntelligentCloudStatus. Modify () ;
208
+ InsertModifyLog( IntelligentCloudStatus) ;
209
+ TablesModified += IntelligentCloudStatus. "Table Name" + SeparatorChar;
210
+ end ;
211
+ end ;
212
+
213
+ local procedure LogMessageForChangedPreserveData( TablesModified: Text ; NewPreserveCloudData: Boolean )
214
+ var
215
+ HybridCloudManagement: Codeunit "Hybrid Cloud Management";
216
+ TelemetryDictionary: Dictionary of [Text , Text ];
217
+ begin
169
218
TelemetryDictionary. Add ( ' Category' , HybridCloudManagement. GetTelemetryCategory()) ;
170
219
TelemetryDictionary. Add ( ' TablesModified' , TablesModified) ;
171
220
TelemetryDictionary. Add ( ' PreserveCloudData' , Format( NewPreserveCloudData, 0 , 9 )) ;
0 commit comments