Compare commits
No commits in common. "cc32e4792c03d64bc4b2bf7c8e6b07eed5e714ba" and "0292348f03025716b055e161923e12db23fe84ea" have entirely different histories.
cc32e4792c
...
0292348f03
@ -1,4 +1,6 @@
|
||||
namespace RhSolutions.AddIn;
|
||||
using ExcelDna.Registration.Utils;
|
||||
|
||||
namespace RhSolutions.AddIn;
|
||||
|
||||
public static class CurrencyFunctions
|
||||
{
|
||||
@ -12,9 +14,10 @@ public static class CurrencyFunctions
|
||||
var functionName = nameof(GetEuroCurrencyRate);
|
||||
var parameters = new object[] { date };
|
||||
|
||||
var exchangeRate = ExcelAsyncUtil.RunTask(functionName, parameters, async () =>
|
||||
var exchangeRate = AsyncTaskUtil.RunTask(functionName, parameters, async () =>
|
||||
{
|
||||
var requestResult = await currencyClient.GetExchangeRate(date); return requestResult ?? -1m;
|
||||
var requestResult = await currencyClient.GetExchangeRate(date);
|
||||
return requestResult ?? -1m;
|
||||
});
|
||||
|
||||
if (exchangeRate is not decimal)
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace RhSolutions.AddIn;
|
||||
using ExcelDna.Registration.Utils;
|
||||
|
||||
namespace RhSolutions.AddIn;
|
||||
|
||||
public static class RhSolutionsFunctions
|
||||
{
|
||||
@ -12,7 +14,7 @@ public static class RhSolutionsFunctions
|
||||
{
|
||||
var functionName = nameof(ProductSearch);
|
||||
var parameters = new object[] { query };
|
||||
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () =>
|
||||
if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
|
||||
{
|
||||
return await databaseClient.GetProducts(query);
|
||||
}) is not IEnumerable<Product> products)
|
||||
@ -50,7 +52,7 @@ public static class RhSolutionsFunctions
|
||||
var article = skus.First().Id;
|
||||
var functionName = nameof(GetProductName);
|
||||
var parameters = new object[] { query };
|
||||
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () =>
|
||||
if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
|
||||
{
|
||||
return await databaseClient.GetProducts(article);
|
||||
}) is not IEnumerable<Product> requestResult)
|
||||
@ -79,7 +81,7 @@ public static class RhSolutionsFunctions
|
||||
var functionName = nameof(GetProductPrice);
|
||||
var parameters = new object[] { article };
|
||||
|
||||
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () =>
|
||||
if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
|
||||
{
|
||||
return await databaseClient.GetProducts(article);
|
||||
}) is not IEnumerable<Product> requestResult)
|
||||
@ -111,7 +113,7 @@ public static class RhSolutionsFunctions
|
||||
var functionName = nameof(GetProductPriceRub);
|
||||
var parameters = new object[] { date };
|
||||
|
||||
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () =>
|
||||
if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
|
||||
{
|
||||
var requestResult = await currencyClient.GetExchangeRate(date);
|
||||
return requestResult ?? -1m;
|
||||
@ -121,7 +123,7 @@ public static class RhSolutionsFunctions
|
||||
}
|
||||
|
||||
parameters = new object[] { query };
|
||||
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () =>
|
||||
if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
|
||||
{
|
||||
var products = await databaseClient.GetProducts(article);
|
||||
var product = products.FirstOrDefault();
|
||||
|
@ -10,10 +10,10 @@
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ExcelDna.AddIn" Version="1.8.0" />
|
||||
<PackageReference Include="ExcelDna.Integration" Version="1.8.0" />
|
||||
<PackageReference Include="ExcelDna.AddIn" Version="1.7.0" />
|
||||
<PackageReference Include="ExcelDna.Integration" Version="1.7.0" />
|
||||
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
|
||||
<PackageReference Include="ExcelDna.Registration" Version="1.8.0" />
|
||||
<PackageReference Include="ExcelDna.Registration" Version="1.7.0" />
|
||||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
|
@ -17,10 +17,6 @@ public class SleevesCalculator : IFittingsCalculator
|
||||
["20"] = 0,
|
||||
["25"] = 0,
|
||||
["32"] = 0,
|
||||
["16PX"] = 0,
|
||||
["20PX"] = 0,
|
||||
["25PX"] = 0,
|
||||
["32PX"] = 0,
|
||||
["40"] = 0,
|
||||
["50"] = 0,
|
||||
["63"] = 0,
|
||||
@ -34,16 +30,9 @@ public class SleevesCalculator : IFittingsCalculator
|
||||
{
|
||||
CaptureCollection collection = doubleCollection[0].Groups["Sleeve"].Captures;
|
||||
foreach (Capture sleeve in collection)
|
||||
{
|
||||
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40")
|
||||
{
|
||||
result[$"{sleeve.Value}PX"] += kvp.Value * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
result[sleeve.Value] += kvp.Value * 2;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
var singleCollection = Regex.Matches(kvp.Key.Name, singlePattern);
|
||||
@ -51,31 +40,20 @@ public class SleevesCalculator : IFittingsCalculator
|
||||
{
|
||||
CaptureCollection collection = singleCollection[0].Groups["Sleeve"].Captures;
|
||||
foreach (Capture sleeve in collection)
|
||||
{
|
||||
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40")
|
||||
{
|
||||
result[$"{sleeve.Value}PX"] += kvp.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
result[sleeve.Value] += kvp.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
.ToDictionary(kvp =>
|
||||
kvp.Key switch
|
||||
{
|
||||
"16" => new Product("11080011001"),
|
||||
"20" => new Product("11080021001"),
|
||||
"25" => new Product("11080031001"),
|
||||
"32" => new Product("11080041001"),
|
||||
"16PX" => new Product("11600011001"),
|
||||
"20PX" => new Product("11600021001"),
|
||||
"25PX" => new Product("11600031001"),
|
||||
"32PX" => new Product("11600041001"),
|
||||
"16" => new Product("11600011001"),
|
||||
"20" => new Product("11600021001"),
|
||||
"25" => new Product("11600031001"),
|
||||
"32" => new Product("11600041001"),
|
||||
"40" => new Product("11600051001"),
|
||||
"50" => new Product("11397711002"),
|
||||
"63" => new Product("11397811002"),
|
||||
|
@ -29,17 +29,13 @@ public class CanFillSleeves : IDisposable
|
||||
var sleeves = _calculator.Calculate(products.First().Item2);
|
||||
_writer.WriteProducts(sleeves);
|
||||
|
||||
Assert.Equal(22, _worksheet.Range["E2"].Value);
|
||||
Assert.Equal(12, _worksheet.Range["E3"].Value);
|
||||
Assert.Equal(5, _worksheet.Range["E4"].Value);
|
||||
Assert.Equal(6, _worksheet.Range["E5"].Value);
|
||||
Assert.Equal(3, _worksheet.Range["E6"].Value);
|
||||
Assert.Equal(25, _worksheet.Range["E2"].Value);
|
||||
Assert.Equal(15, _worksheet.Range["E3"].Value);
|
||||
Assert.Equal(7, _worksheet.Range["E4"].Value);
|
||||
Assert.Equal(8, _worksheet.Range["E5"].Value);
|
||||
Assert.Equal(1, _worksheet.Range["E6"].Value);
|
||||
Assert.Equal(3, _worksheet.Range["E7"].Value);
|
||||
Assert.Equal(2, _worksheet.Range["E8"].Value);
|
||||
Assert.Equal(2, _worksheet.Range["E9"].Value);
|
||||
Assert.Equal(1, _worksheet.Range["E10"].Value);
|
||||
Assert.Equal(3, _worksheet.Range["E11"].Value);
|
||||
Assert.Equal(4, _worksheet.Range["E12"].Value);
|
||||
Assert.Equal(4, _worksheet.Range["E8"].Value);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
|
||||
<PackageReference Include="ExcelDna.Testing" Version="1.8.0" />
|
||||
<PackageReference Include="ExcelDna.Testing" Version="1.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user