Compare commits

..

No commits in common. "cc32e4792c03d64bc4b2bf7c8e6b07eed5e714ba" and "0292348f03025716b055e161923e12db23fe84ea" have entirely different histories.

7 changed files with 30 additions and 51 deletions

View File

@ -1,4 +1,6 @@
namespace RhSolutions.AddIn; using ExcelDna.Registration.Utils;
namespace RhSolutions.AddIn;
public static class CurrencyFunctions public static class CurrencyFunctions
{ {
@ -12,9 +14,10 @@ public static class CurrencyFunctions
var functionName = nameof(GetEuroCurrencyRate); var functionName = nameof(GetEuroCurrencyRate);
var parameters = new object[] { date }; 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) if (exchangeRate is not decimal)

View File

@ -1,4 +1,6 @@
namespace RhSolutions.AddIn; using ExcelDna.Registration.Utils;
namespace RhSolutions.AddIn;
public static class RhSolutionsFunctions public static class RhSolutionsFunctions
{ {
@ -12,7 +14,7 @@ public static class RhSolutionsFunctions
{ {
var functionName = nameof(ProductSearch); var functionName = nameof(ProductSearch);
var parameters = new object[] { query }; var parameters = new object[] { query };
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () => if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
{ {
return await databaseClient.GetProducts(query); return await databaseClient.GetProducts(query);
}) is not IEnumerable<Product> products) }) is not IEnumerable<Product> products)
@ -50,7 +52,7 @@ public static class RhSolutionsFunctions
var article = skus.First().Id; var article = skus.First().Id;
var functionName = nameof(GetProductName); var functionName = nameof(GetProductName);
var parameters = new object[] { query }; var parameters = new object[] { query };
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () => if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
{ {
return await databaseClient.GetProducts(article); return await databaseClient.GetProducts(article);
}) is not IEnumerable<Product> requestResult) }) is not IEnumerable<Product> requestResult)
@ -79,7 +81,7 @@ public static class RhSolutionsFunctions
var functionName = nameof(GetProductPrice); var functionName = nameof(GetProductPrice);
var parameters = new object[] { article }; var parameters = new object[] { article };
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () => if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
{ {
return await databaseClient.GetProducts(article); return await databaseClient.GetProducts(article);
}) is not IEnumerable<Product> requestResult) }) is not IEnumerable<Product> requestResult)
@ -111,7 +113,7 @@ public static class RhSolutionsFunctions
var functionName = nameof(GetProductPriceRub); var functionName = nameof(GetProductPriceRub);
var parameters = new object[] { date }; var parameters = new object[] { date };
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () => if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
{ {
var requestResult = await currencyClient.GetExchangeRate(date); var requestResult = await currencyClient.GetExchangeRate(date);
return requestResult ?? -1m; return requestResult ?? -1m;
@ -121,7 +123,7 @@ public static class RhSolutionsFunctions
} }
parameters = new object[] { query }; parameters = new object[] { query };
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () => if (AsyncTaskUtil.RunTask(functionName, parameters, async () =>
{ {
var products = await databaseClient.GetProducts(article); var products = await databaseClient.GetProducts(article);
var product = products.FirstOrDefault(); var product = products.FirstOrDefault();

View File

@ -10,10 +10,10 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets> <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ExcelDna.AddIn" Version="1.8.0" /> <PackageReference Include="ExcelDna.AddIn" Version="1.7.0" />
<PackageReference Include="ExcelDna.Integration" Version="1.8.0" /> <PackageReference Include="ExcelDna.Integration" Version="1.7.0" />
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" /> <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.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" /> <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

View File

@ -17,10 +17,6 @@ public class SleevesCalculator : IFittingsCalculator
["20"] = 0, ["20"] = 0,
["25"] = 0, ["25"] = 0,
["32"] = 0, ["32"] = 0,
["16PX"] = 0,
["20PX"] = 0,
["25PX"] = 0,
["32PX"] = 0,
["40"] = 0, ["40"] = 0,
["50"] = 0, ["50"] = 0,
["63"] = 0, ["63"] = 0,
@ -35,14 +31,7 @@ public class SleevesCalculator : IFittingsCalculator
CaptureCollection collection = doubleCollection[0].Groups["Sleeve"].Captures; CaptureCollection collection = doubleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection) foreach (Capture sleeve in collection)
{ {
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40") result[sleeve.Value] += kvp.Value * 2;
{
result[$"{sleeve.Value}PX"] += kvp.Value * 2;
}
else
{
result[sleeve.Value] += kvp.Value * 2;
}
} }
continue; continue;
} }
@ -52,14 +41,7 @@ public class SleevesCalculator : IFittingsCalculator
CaptureCollection collection = singleCollection[0].Groups["Sleeve"].Captures; CaptureCollection collection = singleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection) foreach (Capture sleeve in collection)
{ {
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40") result[sleeve.Value] += kvp.Value;
{
result[$"{sleeve.Value}PX"] += kvp.Value;
}
else
{
result[sleeve.Value] += kvp.Value;
}
} }
} }
} }
@ -68,14 +50,10 @@ public class SleevesCalculator : IFittingsCalculator
.ToDictionary(kvp => .ToDictionary(kvp =>
kvp.Key switch kvp.Key switch
{ {
"16" => new Product("11080011001"), "16" => new Product("11600011001"),
"20" => new Product("11080021001"), "20" => new Product("11600021001"),
"25" => new Product("11080031001"), "25" => new Product("11600031001"),
"32" => new Product("11080041001"), "32" => new Product("11600041001"),
"16PX" => new Product("11600011001"),
"20PX" => new Product("11600021001"),
"25PX" => new Product("11600031001"),
"32PX" => new Product("11600041001"),
"40" => new Product("11600051001"), "40" => new Product("11600051001"),
"50" => new Product("11397711002"), "50" => new Product("11397711002"),
"63" => new Product("11397811002"), "63" => new Product("11397811002"),

View File

@ -29,17 +29,13 @@ public class CanFillSleeves : IDisposable
var sleeves = _calculator.Calculate(products.First().Item2); var sleeves = _calculator.Calculate(products.First().Item2);
_writer.WriteProducts(sleeves); _writer.WriteProducts(sleeves);
Assert.Equal(22, _worksheet.Range["E2"].Value); Assert.Equal(25, _worksheet.Range["E2"].Value);
Assert.Equal(12, _worksheet.Range["E3"].Value); Assert.Equal(15, _worksheet.Range["E3"].Value);
Assert.Equal(5, _worksheet.Range["E4"].Value); Assert.Equal(7, _worksheet.Range["E4"].Value);
Assert.Equal(6, _worksheet.Range["E5"].Value); Assert.Equal(8, _worksheet.Range["E5"].Value);
Assert.Equal(3, _worksheet.Range["E6"].Value); Assert.Equal(1, _worksheet.Range["E6"].Value);
Assert.Equal(3, _worksheet.Range["E7"].Value); Assert.Equal(3, _worksheet.Range["E7"].Value);
Assert.Equal(2, _worksheet.Range["E8"].Value); Assert.Equal(4, _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);
} }
public void Dispose() public void Dispose()

View File

@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" /> <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>
<ItemGroup> <ItemGroup>