- fix for offer thoughput set in the clone options page not being respected when creating target collection

This commit is contained in:
AlexDrenea 2019-04-23 08:04:17 +03:00
Родитель 019a66855e
Коммит d3cc92382c
5 изменённых файлов: 45 добавлений и 10 удалений

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

@ -19,5 +19,9 @@
<TextBlock Text="Offer Throughput" Style="{StaticResource TextBlockStyle}"/>
<TextBox x:Name="OfferThroughput" Text="10000" Style="{StaticResource TextBoxStyle}" VerticalAlignment="Top"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Image x:Name="ConnectionIcon" Width="30" Height="30"/>
<TextBlock Name="ConnectionTestMsg" TextWrapping="Wrap" />
</StackPanel>
</StackPanel>
</Page>

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

@ -27,5 +27,31 @@ namespace CosmicCloneUI
{
InitializeComponent();
}
public bool TestCloneOptions()
{
var result = true;
if (!int.TryParse(OfferThroughput.Text, out int RU))
result = false;
if (RU < 400) result = false;
if (RU % 100 != 0) result = false;
if (result)
{
var connectionIcon = (Image)this.FindName("ConnectionIcon");
ConnectionIcon.Source = new BitmapImage(new Uri("/Images/success.png", UriKind.Relative));
ConnectionTestMsg.Text = "Validation Passed";
}
else
{
var connectionIcon = (Image)this.FindName("ConnectionIcon");
ConnectionIcon.Source = new BitmapImage(new Uri("/Images/fail.png", UriKind.Relative));
ConnectionTestMsg.Text = "Invalid Throughput provided. Make sure it's a number greater than 400 and multiple of 100.";
}
return result;
}
}
}

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

@ -157,12 +157,17 @@ namespace CosmicCloneUI
}
else if (GetPageNumber(currentPage) == 2)
{
CloneSettings.CopyStoredProcedures = ((CheckBox)currentPage.FindName("SPs")).IsChecked.Value;
CloneSettings.CopyUDFs = ((CheckBox)currentPage.FindName("UDFs")).IsChecked.Value;
CloneSettings.CopyTriggers = ((CheckBox)currentPage.FindName("CosmosTriggers")).IsChecked.Value;
CloneSettings.CopyDocuments = ((CheckBox)currentPage.FindName("Documents")).IsChecked.Value;
CloneSettings.CopyIndexingPolicy = ((CheckBox)currentPage.FindName("IPs")).IsChecked.Value;
CloneSettings.CopyPartitionKey = ((CheckBox)currentPage.FindName("PKs")).IsChecked.Value;
var page = ((CloneOptionsPage)currentPage);
var valid = page.TestCloneOptions();
if (!valid) return false;
CloneSettings.CopyStoredProcedures = page.SPs.IsChecked.Value;
CloneSettings.CopyUDFs = page.UDFs.IsChecked.Value;
CloneSettings.CopyTriggers = page.CosmosTriggers.IsChecked.Value;
CloneSettings.CopyDocuments = page.Documents.IsChecked.Value;
CloneSettings.CopyIndexingPolicy = page.IPs.IsChecked.Value;
CloneSettings.CopyPartitionKey = page.PKs.IsChecked.Value;
CloneSettings.TargetMigrationOfferThroughputRUs = int.Parse(page.OfferThroughput.Text);
return true;
}

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

@ -8,7 +8,7 @@ namespace CosmosCloneCommon.Model
public static class RandomNumberGenerator
{
private static readonly Random _random = new Random(unchecked(Environment.TickCount * 31 + Thread.CurrentThread.ManagedThreadId));;
private static readonly Random _random = new Random(unchecked(Environment.TickCount * 31 + Thread.CurrentThread.ManagedThreadId));
public static int GetNext(int maxValue)
{

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

@ -69,8 +69,8 @@ namespace CosmosCloneCommon.Utility
EndpointUrl = targetConfigs["EndpointUrl"],
AccessKey = targetConfigs["AccessKey"],
DatabaseName = targetConfigs["DatabaseName"],
CollectionName = targetConfigs["CollectionName"]
// OfferThroughputRUs = int.Parse(sourceConfigs["OfferThroughputRUs"])
CollectionName = targetConfigs["CollectionName"],
OfferThroughputRUs = int.Parse(targetConfigs["OfferThroughputRUs"])
};
}
@ -95,6 +95,6 @@ namespace CosmosCloneCommon.Utility
public string AccessKey { get; set; }
public string DatabaseName { get; set; }
public string CollectionName { get; set; }
public int OfferThroughputRUs { get; set; }
}
}