aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Assistant/HttpClientUtil.cs4
-rw-r--r--Source/Assistant/SkuAssist.cs11
-rw-r--r--Source/ExcelDNA/AddIn.cs11
3 files changed, 14 insertions, 12 deletions
diff --git a/Source/Assistant/HttpClientUtil.cs b/Source/Assistant/HttpClientUtil.cs
index 3ad5d85..6277770 100644
--- a/Source/Assistant/HttpClientUtil.cs
+++ b/Source/Assistant/HttpClientUtil.cs
@@ -30,14 +30,14 @@ namespace Rehau.Sku.Assist
return await context.OpenAsync(req => req.Content(content.Result));
}
- public static Uri ConvertToUri(this string request, ResponseOrder order)
+ public static Uri ConvertToUri(this string request)
{
UriBuilder baseUri = new UriBuilder("https", "shop-rehau.ru");
baseUri.Path = "/catalogsearch/result/index/";
string cleanedRequest = request._CleanRequest();
- switch (order)
+ switch (AddIn.responseOrder)
{
case ResponseOrder.Relevance:
baseUri.Query = "dir=asc&order=relevance&q=" + cleanedRequest;
diff --git a/Source/Assistant/SkuAssist.cs b/Source/Assistant/SkuAssist.cs
index e8ce789..a0195ba 100644
--- a/Source/Assistant/SkuAssist.cs
+++ b/Source/Assistant/SkuAssist.cs
@@ -10,15 +10,6 @@ using System.Threading.Tasks;
namespace Rehau.Sku.Assist
{
- public enum ResponseOrder
- {
- NoSettings,
- Relevance,
- Name,
- Price,
- Series
- }
-
public enum ProductField
{
Name,
@@ -30,7 +21,7 @@ namespace Rehau.Sku.Assist
{
public static async Task<IProduct> GetProduct(string request)
{
- Uri uri = request.ConvertToUri(ResponseOrder.NoSettings);
+ Uri uri = request.ConvertToUri();
Task<string> contentTask = Task.Run(() => HttpClientUtil.GetContentByUriAsync(uri));
Task<IDocument> documentTask = await contentTask.ContinueWith(content => HttpClientUtil.ContentToDocAsync(content));
diff --git a/Source/ExcelDNA/AddIn.cs b/Source/ExcelDNA/AddIn.cs
index b62412d..25e5bfd 100644
--- a/Source/ExcelDNA/AddIn.cs
+++ b/Source/ExcelDNA/AddIn.cs
@@ -4,13 +4,24 @@ using System.Net.Http;
namespace Rehau.Sku.Assist
{
+ public enum ResponseOrder
+ {
+ NoSettings,
+ Relevance,
+ Name,
+ Price,
+ Series
+ }
+
public class AddIn : IExcelAddIn
{
public static readonly HttpClient httpClient = new HttpClient();
+ public static ResponseOrder responseOrder;
public void AutoOpen()
{
RegisterFunctions();
+ responseOrder = ResponseOrder.NoSettings;
}
public void AutoClose()