This commit is contained in:
Kranthi Kumar Medam 2019-01-16 23:34:44 +05:30
Родитель bab668c8f6
Коммит 0a79b0f589
2 изменённых файлов: 25 добавлений и 10 удалений

Просмотреть файл

@ -243,6 +243,7 @@ namespace CosmicCloneUI
void Worker_DoWork2(object sender, DoWorkEventArgs e)
{
Task.Delay(3000).Wait();
long readPercentProgress = 0;
long writePercentProgress = 0;
long scrubPercentProgress = 0;
@ -262,12 +263,22 @@ namespace CosmicCloneUI
readPercentProgress = (DocumentMigrator.TotalRecordsRetrieved * 100) / DocumentMigrator.TotalRecordsInSource;
writePercentProgress = (DocumentMigrator.TotalRecordsSent * 100) / DocumentMigrator.TotalRecordsInSource;
}
if(CloneSettings.ScrubbingRequired && DocumentMigrator.scrubRules!=null && DocumentMigrator.scrubRules.Count>0)
else
{
readPercentProgress = 100;
writePercentProgress = 100;
}
if (CloneSettings.ScrubbingRequired && DocumentMigrator.scrubRules != null && DocumentMigrator.scrubRules.Count > 0)
{
scrubPercentProgress = DocumentMigrator.ScrubPercentProgress;
}
else
{
if (DocumentMigrator.scrubRules == null || DocumentMigrator.scrubRules.Count == 0) scrubPercentProgress = 100;
else scrubPercentProgress = 0;
}
else scrubPercentProgress = 100;
}
@ -280,14 +291,15 @@ namespace CosmicCloneUI
{
int receivePercent = e.ProgressPercentage;
int writePercent = (receivePercent % 1000);
int readPercent = (receivePercent % 1000000) / 1000;
int scrubPercent = receivePercent/1000000;
int scrubPercent = receivePercent / 1000000;
((ProgressBar)pages[4].FindName("ReadProgress")).Value = readPercent;
((ProgressBar)pages[4].FindName("WriteProgress")).Value = writePercent;
((ProgressBar)pages[4].FindName("ScrubProgress")).Value = scrubPercent;
var statustextbox = ((TextBox)pages[4].FindName("StatusTextBlock"));
statustextbox.Text = logger.FullLog;
statustextbox.ScrollToEnd();

Просмотреть файл

@ -47,6 +47,7 @@ namespace CosmosCloneCommon.Migrator
public static long TotalRecordsSent { get; set; }
public static long TotalRecordsInSource { get; set; }
public static bool IsCodeMigrationComplete { get; set; }
protected static bool IsInitialized { get; set; }
public static int ScrubPercentProgress
{
@ -55,18 +56,19 @@ namespace CosmosCloneCommon.Migrator
if (scrubRules != null && scrubRules.Count > 0)
{
int totalRules = scrubRules.Count();
int noFilterRuleCompleteCount = scrubRules.Where(x => x.IsComplete == true && string.IsNullOrEmpty(x.FilterCondition) ).ToList().Count();
int noFilterRuleCompleteCount = scrubRules.Where(x => x.IsComplete == true && string.IsNullOrEmpty(x.FilterCondition)).ToList().Count();
int filterRuleCompleteCount = 0;
if(DataScrubMigrator.scrubRules!=null && DataScrubMigrator.scrubRules.Count>0)
if (DataScrubMigrator.scrubRules != null && DataScrubMigrator.scrubRules.Count > 0)
{
filterRuleCompleteCount = DataScrubMigrator.scrubRules.Where(x => x.IsComplete == true).ToList().Count();
}
var completedRules = scrubRules.Where(x => x.IsComplete == true).ToList().Count();
int percent = (int)((noFilterRuleCompleteCount + filterRuleCompleteCount) * 100 / scrubRules.Count());
return percent;
}
else return 100;
else if (IsInitialized) return 100;
else return 0;
}
}
@ -80,6 +82,7 @@ namespace CosmosCloneCommon.Migrator
}
public async Task<bool> StartCopy(List<ScrubRule> scrubRules = null)
{
IsCodeMigrationComplete = false;
DocumentMigrator.scrubRules = scrubRules;
await InitializeMigration();
@ -106,7 +109,6 @@ namespace CosmosCloneCommon.Migrator
logger.LogScrubRulesInformation(DocumentMigrator.scrubRules);
IsCodeMigrationComplete = false;
if (CloneSettings.CopyStoredProcedures) { await CopyStoredProcedures(); }
if (CloneSettings.CopyUDFs) { await CopyUDFs(); }
if (CloneSettings.CopyTriggers) { await CopyTriggers(); }
@ -120,6 +122,7 @@ namespace CosmosCloneCommon.Migrator
logger.LogInfo($"Source Database: {CloneSettings.SourceSettings.DatabaseName} Source Collection: {CloneSettings.SourceSettings.CollectionName}");
logger.LogInfo($"Target Database: {CloneSettings.TargetSettings.DatabaseName} Target Collection: {CloneSettings.TargetSettings.CollectionName}");
IsInitialized = true;
sourceClient = cosmosHelper.GetSourceDocumentDbClient();
sourceCollection = await cosmosHelper.GetSourceDocumentCollection(sourceClient);