Compare commits

..

2 Commits

Author SHA1 Message Date
cc32e4792c Add LX sleeves support 2024-05-25 15:15:17 +03:00
678bdb47b9 Bump ExcelDNA packages 2024-05-19 16:22:16 +03:00
7 changed files with 51 additions and 30 deletions

View File

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

View File

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

View File

@ -10,10 +10,10 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ExcelDna.AddIn" Version="1.7.0" />
<PackageReference Include="ExcelDna.Integration" Version="1.7.0" />
<PackageReference Include="ExcelDna.AddIn" Version="1.8.0" />
<PackageReference Include="ExcelDna.Integration" Version="1.8.0" />
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
<PackageReference Include="ExcelDna.Registration" Version="1.7.0" />
<PackageReference Include="ExcelDna.Registration" Version="1.8.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" />

View File

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

View File

@ -29,13 +29,17 @@ public class CanFillSleeves : IDisposable
var sleeves = _calculator.Calculate(products.First().Item2);
_writer.WriteProducts(sleeves);
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(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(3, _worksheet.Range["E7"].Value);
Assert.Equal(4, _worksheet.Range["E8"].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);
}
public void Dispose()

View File

@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
<PackageReference Include="ExcelDna.Testing" Version="1.7.0" />
<PackageReference Include="ExcelDna.Testing" Version="1.8.0" />
</ItemGroup>
<ItemGroup>