Skip to content

Commit

Permalink
Merge pull request #13 from BeverCRM/master
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
Hovhannes-Dilanyan authored Nov 17, 2022
2 parents 3345790 + c79b25b commit b320d50
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ publish/
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/

nuget/*.dll
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
Expand Down
102 changes: 60 additions & 42 deletions DataMigrationUsingFetchXml/DataMigrationUsingFetchXmlControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,19 @@ private void BtnTransferData_Click(object sender, EventArgs e)
{
if (AdditionalConnectionDetails.Count > 0)
{
if (BtnTransferData.Text == "Cancel")
{
_transferOperation.KeepRunning = false;
BtnTransferData.Enabled = false;
BtnTransferData.Text = "Transfer Data";
return;
}
InitializeLog();
_transferOperation.KeepRunning = true;
bool isErrorOccured = false;
List<string> fetchXmls = new List<string>();
List<int> tableIndexesForTransfer = new List<int>();
BtnTransferData.Text = "Cancel";

foreach (DataGridViewRow row in FetchDataGridView.Rows)
{
Expand Down Expand Up @@ -229,12 +237,16 @@ private void BtnTransferData_Click(object sender, EventArgs e)
}
fetchXmls.Clear();
SetLoadingDetails(false);
BtnTransferData.Text = "Transfer Data";
if (isErrorOccured)
LblInfo.Text = string.Empty;
else if (_transferOperation.KeepRunning && !isErrorOccured)
MessageBox.Show("Data Migration Completed.", "Data Migration Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
{
BtnTransferData.Enabled = true;
MessageBox.Show("Migration is Stopped.", "Migration is Stopped", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
});
Expand Down Expand Up @@ -273,7 +285,6 @@ private void SetLoadingDetails(bool visible)
}
LblLoading.Visible = visible;
LblTitle.Visible = visible;
pictureBoxStop.Visible = visible;
}

private void InitializeLog()
Expand All @@ -284,10 +295,11 @@ private void InitializeLog()

private void ChangeToolsState(bool state)
{
//richTextBoxLogs.Enabled = state;
pictureBoxRecBin.Enabled = state;
TxtLogsPath.Enabled = state;
BtnBrowseLogs.Enabled = state;
BtnTransferData.Enabled = state;
//BtnTransferData.Enabled = state;
BtnSelectTargetInstance.Enabled = state;
FetchDataGridView.Enabled = state;
pictureBoxAdd.Enabled = state;
Expand All @@ -298,6 +310,8 @@ private void PictureBoxRecBin_Click(object sender, EventArgs e)
_errorIndexes.Clear();
_errorPosition = 0;
richTextBoxLogs.Text = null;
LblInfo.Text = string.Empty;
LblErrorText.Text = string.Empty;
}

private void PictureBoxAdd_Click(object sender, EventArgs e)
Expand All @@ -311,46 +325,55 @@ private void PopupDialog(int rowIndex = -1)
{
if (_popup.ShowDialog() == DialogResult.OK)
{
try
WorkAsync(new WorkAsyncInfo
{
_dataverseService = new DataverseService(Service);
string fetch = _popup.TextBoxFetch.Text;

if (rowIndex != -1 && fetch == _popup.FetchXmls[rowIndex])
{
return;
}
string displayName = _dataverseService.GetDisplayName(fetch);
string logicalName = _dataverseService.GetLogicalName(fetch);

if (rowIndex != -1)
Message = "Loading...",
Work = (worker, args) =>
{
_popup.FetchXmls[rowIndex] = fetch;
fetchXmlDataBindingSource[rowIndex] = new FetchXmlData()
try
{
DisplayName = displayName,
SchemaName = logicalName
};
_displayNames[rowIndex] = displayName;
}
else
{
_displayNames.Add(displayName);
fetchXmlDataBindingSource.Add(new FetchXmlData()
ChangeToolsState(false);
_dataverseService = new DataverseService(Service);
string fetch = _popup.TextBoxFetch.Text;

if (rowIndex != -1 && fetch == _popup.FetchXmls[rowIndex])
{
return;
}
string displayName = _dataverseService.GetDisplayName(fetch);
string logicalName = _dataverseService.GetLogicalName(fetch);

if (rowIndex != -1)
{
_popup.FetchXmls[rowIndex] = fetch;
fetchXmlDataBindingSource[rowIndex] = new FetchXmlData()
{
DisplayName = displayName,
SchemaName = logicalName
};
_displayNames[rowIndex] = displayName;
}
else
{
_displayNames.Add(displayName);
fetchXmlDataBindingSource.Add(new FetchXmlData()
{
DisplayName = displayName,
SchemaName = logicalName
});
}
}
catch (Exception ex)
{
DisplayName = displayName,
SchemaName = logicalName
});
}
}
catch (Exception ex)
{
if (rowIndex == -1)
{
_popup.FetchXmls.RemoveAt(_popup.FetchXmls.Count - 1);
if (rowIndex == -1)
{
_popup.FetchXmls.RemoveAt(_popup.FetchXmls.Count - 1);
}
MessageBox.Show($"{ex.Message}.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
ChangeToolsState(true);
}
MessageBox.Show($"{ex.Message}.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
});
}
}

Expand All @@ -375,11 +398,6 @@ private void FetchDataGridView_CellContentClick(object sender, DataGridViewCellE
}
}

private void PictureBoxStop_Click(object sender, EventArgs e)
{
_transferOperation.KeepRunning = false;
}

private void RichTextBoxLogs_TextChanged(object sender, EventArgs e)
{
FindErrorIndexes();
Expand Down
Loading

0 comments on commit b320d50

Please sign in to comment.