@@ -170,11 +170,19 @@ private void BtnTransferData_Click(object sender, EventArgs e)
170170 {
171171 if ( AdditionalConnectionDetails . Count > 0 )
172172 {
173+ if ( BtnTransferData . Text == "Cancel" )
174+ {
175+ _transferOperation . KeepRunning = false ;
176+ BtnTransferData . Enabled = false ;
177+ BtnTransferData . Text = "Transfer Data" ;
178+ return ;
179+ }
173180 InitializeLog ( ) ;
174181 _transferOperation . KeepRunning = true ;
175182 bool isErrorOccured = false ;
176183 List < string > fetchXmls = new List < string > ( ) ;
177184 List < int > tableIndexesForTransfer = new List < int > ( ) ;
185+ BtnTransferData . Text = "Cancel" ;
178186
179187 foreach ( DataGridViewRow row in FetchDataGridView . Rows )
180188 {
@@ -229,12 +237,16 @@ private void BtnTransferData_Click(object sender, EventArgs e)
229237 }
230238 fetchXmls . Clear ( ) ;
231239 SetLoadingDetails ( false ) ;
240+ BtnTransferData . Text = "Transfer Data" ;
232241 if ( isErrorOccured )
233242 LblInfo . Text = string . Empty ;
234243 else if ( _transferOperation . KeepRunning && ! isErrorOccured )
235244 MessageBox . Show ( "Data Migration Completed." , "Data Migration Completed" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
236245 else
246+ {
247+ BtnTransferData . Enabled = true ;
237248 MessageBox . Show ( "Migration is Stopped." , "Migration is Stopped" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
249+ }
238250 }
239251 }
240252 } ) ;
@@ -273,7 +285,6 @@ private void SetLoadingDetails(bool visible)
273285 }
274286 LblLoading . Visible = visible ;
275287 LblTitle . Visible = visible ;
276- pictureBoxStop . Visible = visible ;
277288 }
278289
279290 private void InitializeLog ( )
@@ -284,10 +295,11 @@ private void InitializeLog()
284295
285296 private void ChangeToolsState ( bool state )
286297 {
298+ //richTextBoxLogs.Enabled = state;
287299 pictureBoxRecBin . Enabled = state ;
288300 TxtLogsPath . Enabled = state ;
289301 BtnBrowseLogs . Enabled = state ;
290- BtnTransferData . Enabled = state ;
302+ // BtnTransferData.Enabled = state;
291303 BtnSelectTargetInstance . Enabled = state ;
292304 FetchDataGridView . Enabled = state ;
293305 pictureBoxAdd . Enabled = state ;
@@ -298,6 +310,8 @@ private void PictureBoxRecBin_Click(object sender, EventArgs e)
298310 _errorIndexes . Clear ( ) ;
299311 _errorPosition = 0 ;
300312 richTextBoxLogs . Text = null ;
313+ LblInfo . Text = string . Empty ;
314+ LblErrorText . Text = string . Empty ;
301315 }
302316
303317 private void PictureBoxAdd_Click ( object sender , EventArgs e )
@@ -311,46 +325,55 @@ private void PopupDialog(int rowIndex = -1)
311325 {
312326 if ( _popup . ShowDialog ( ) == DialogResult . OK )
313327 {
314- try
328+ WorkAsync ( new WorkAsyncInfo
315329 {
316- _dataverseService = new DataverseService ( Service ) ;
317- string fetch = _popup . TextBoxFetch . Text ;
318-
319- if ( rowIndex != - 1 && fetch == _popup . FetchXmls [ rowIndex ] )
320- {
321- return ;
322- }
323- string displayName = _dataverseService . GetDisplayName ( fetch ) ;
324- string logicalName = _dataverseService . GetLogicalName ( fetch ) ;
325-
326- if ( rowIndex != - 1 )
330+ Message = "Loading..." ,
331+ Work = ( worker , args ) =>
327332 {
328- _popup . FetchXmls [ rowIndex ] = fetch ;
329- fetchXmlDataBindingSource [ rowIndex ] = new FetchXmlData ( )
333+ try
330334 {
331- DisplayName = displayName ,
332- SchemaName = logicalName
333- } ;
334- _displayNames [ rowIndex ] = displayName ;
335- }
336- else
337- {
338- _displayNames . Add ( displayName ) ;
339- fetchXmlDataBindingSource . Add ( new FetchXmlData ( )
335+ ChangeToolsState ( false ) ;
336+ _dataverseService = new DataverseService ( Service ) ;
337+ string fetch = _popup . TextBoxFetch . Text ;
338+
339+ if ( rowIndex != - 1 && fetch == _popup . FetchXmls [ rowIndex ] )
340+ {
341+ return ;
342+ }
343+ string displayName = _dataverseService . GetDisplayName ( fetch ) ;
344+ string logicalName = _dataverseService . GetLogicalName ( fetch ) ;
345+
346+ if ( rowIndex != - 1 )
347+ {
348+ _popup . FetchXmls [ rowIndex ] = fetch ;
349+ fetchXmlDataBindingSource [ rowIndex ] = new FetchXmlData ( )
350+ {
351+ DisplayName = displayName ,
352+ SchemaName = logicalName
353+ } ;
354+ _displayNames [ rowIndex ] = displayName ;
355+ }
356+ else
357+ {
358+ _displayNames . Add ( displayName ) ;
359+ fetchXmlDataBindingSource . Add ( new FetchXmlData ( )
360+ {
361+ DisplayName = displayName ,
362+ SchemaName = logicalName
363+ } ) ;
364+ }
365+ }
366+ catch ( Exception ex )
340367 {
341- DisplayName = displayName ,
342- SchemaName = logicalName
343- } ) ;
344- }
345- }
346- catch ( Exception ex )
347- {
348- if ( rowIndex == - 1 )
349- {
350- _popup . FetchXmls . RemoveAt ( _popup . FetchXmls . Count - 1 ) ;
368+ if ( rowIndex == - 1 )
369+ {
370+ _popup . FetchXmls . RemoveAt ( _popup . FetchXmls . Count - 1 ) ;
371+ }
372+ MessageBox . Show ( $ "{ ex . Message } .", "Error Message" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
373+ }
374+ ChangeToolsState ( true ) ;
351375 }
352- MessageBox . Show ( $ "{ ex . Message } .", "Error Message" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
353- }
376+ } ) ;
354377 }
355378 }
356379
@@ -375,11 +398,6 @@ private void FetchDataGridView_CellContentClick(object sender, DataGridViewCellE
375398 }
376399 }
377400
378- private void PictureBoxStop_Click ( object sender , EventArgs e )
379- {
380- _transferOperation . KeepRunning = false ;
381- }
382-
383401 private void RichTextBoxLogs_TextChanged ( object sender , EventArgs e )
384402 {
385403 FindErrorIndexes ( ) ;
0 commit comments