Compare commits
No commits in common. "6d9ff9365cf8deeadea6c410d518d1c9ccf7b1f8" and "4201b51511440aac385d518550aa8df478982ae1" have entirely different histories.
6d9ff9365c
...
4201b51511
@ -52,90 +52,4 @@ public class RhSolutionsFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[ExcelFunction]
|
|
||||||
public static object РЕХАУ(string line) => RHSOLUTIONS(line);
|
|
||||||
[ExcelFunction]
|
|
||||||
public static object РЕХАУАРТИКУЛ(string line)
|
|
||||||
{
|
|
||||||
if (ProductSku.TryParse(line, out var skus))
|
|
||||||
{
|
|
||||||
return skus.First().Id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return ExcelError.ExcelErrorNA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[ExcelFunction]
|
|
||||||
public static object РЕХАУИМЯ(string line)
|
|
||||||
{
|
|
||||||
if (!ProductSku.TryParse(line, out var skus))
|
|
||||||
{
|
|
||||||
return ExcelError.ExcelErrorNA;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var article = skus.First().Id;
|
|
||||||
IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>();
|
|
||||||
|
|
||||||
if (ExcelAsyncUtil.Run("Database request", line, delegate
|
|
||||||
{
|
|
||||||
return databaseClient.GetProducts(article)
|
|
||||||
.GetAwaiter()
|
|
||||||
.GetResult();
|
|
||||||
}) is not IEnumerable<Product> requestResult)
|
|
||||||
{
|
|
||||||
return "Загрузка...";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!requestResult.Any())
|
|
||||||
{
|
|
||||||
return ExcelError.ExcelErrorNA;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var firstProduct = requestResult.First();
|
|
||||||
return firstProduct.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[ExcelFunction]
|
|
||||||
public static object РЕХАУЦЕНА(string line)
|
|
||||||
{
|
|
||||||
if (!ProductSku.TryParse(line, out var skus))
|
|
||||||
{
|
|
||||||
return ExcelError.ExcelErrorNA;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var article = skus.First().Id;
|
|
||||||
IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>();
|
|
||||||
|
|
||||||
if (ExcelAsyncUtil.Run("Database request", line, delegate
|
|
||||||
{
|
|
||||||
return databaseClient.GetProducts(article)
|
|
||||||
.GetAwaiter()
|
|
||||||
.GetResult();
|
|
||||||
}) is not IEnumerable<Product> requestResult)
|
|
||||||
{
|
|
||||||
return "Загрузка...";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!requestResult.Any())
|
|
||||||
{
|
|
||||||
return ExcelError.ExcelErrorNA;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var firstProduct = requestResult.First();
|
|
||||||
return string.Format("{0:N2} €", firstProduct.Price * 1.2m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.6.2.0")]
|
[assembly: AssemblyVersion("1.6.1.5")]
|
||||||
[assembly: AssemblyFileVersion("1.6.2.0")]
|
[assembly: AssemblyFileVersion("1.6.1.5")]
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<Reference Path="Microsoft.Extensions.Primitives.dll" Pack="true" />
|
<Reference Path="Microsoft.Extensions.Primitives.dll" Pack="true" />
|
||||||
<Reference Path="Newtonsoft.Json.dll" Pack="true" />
|
<Reference Path="Newtonsoft.Json.dll" Pack="true" />
|
||||||
<Reference Path="netDxf.dll" Pack="true" />
|
<Reference Path="netDxf.dll" Pack="true" />
|
||||||
<Reference Path="RhSolutions.ProductSku.dll" Pack="true" />
|
<Reference Path="RhSolutions.Sku.dll" Pack="true" />
|
||||||
<Reference Path="System.Buffers.dll" Pack="true" />
|
<Reference Path="System.Buffers.dll" Pack="true" />
|
||||||
<Reference Path="System.Diagnostics.DiagnosticSource.dll" Pack="true" />
|
<Reference Path="System.Diagnostics.DiagnosticSource.dll" Pack="true" />
|
||||||
<Reference Path="System.Memory.dll" Pack="true" />
|
<Reference Path="System.Memory.dll" Pack="true" />
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
||||||
<PackageReference Include="netDxf" Version="2022.11.2" />
|
<PackageReference Include="netDxf" Version="2022.11.2" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="RhSolutions.ProductSku" Version="1.0.2" />
|
<PackageReference Include="RhSolutions.Sku" Version="0.1.8" />
|
||||||
<PackageReference Include="System.Buffers" Version="4.5.1" />
|
<PackageReference Include="System.Buffers" Version="4.5.1" />
|
||||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
|
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -38,6 +38,7 @@ public class DatabaseClient : IDatabaseClient
|
|||||||
string json = await response.Content.ReadAsStringAsync();
|
string json = await response.Content.ReadAsStringAsync();
|
||||||
return JsonConvert.DeserializeObject<IEnumerable<Product>>(json) ?? Enumerable.Empty<Product>();
|
return JsonConvert.DeserializeObject<IEnumerable<Product>>(json) ?? Enumerable.Empty<Product>();
|
||||||
}
|
}
|
||||||
|
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
StatusCode = response.StatusCode;
|
StatusCode = response.StatusCode;
|
||||||
|
@ -60,7 +60,7 @@ public class ExcelReader : IReader, IDisposable
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Product product = new(currentSku);
|
Product product = new() { ProductSku = new(currentSku) };
|
||||||
|
|
||||||
if (readResult.ContainsKey(product))
|
if (readResult.ContainsKey(product))
|
||||||
{
|
{
|
||||||
@ -124,9 +124,10 @@ public class ExcelReader : IReader, IDisposable
|
|||||||
if (!ProductSku.TryParse(sku.ToString(), out _))
|
if (!ProductSku.TryParse(sku.ToString(), out _))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Product p = new(sku.ToString())
|
Product p = new()
|
||||||
{
|
{
|
||||||
ProductLines = new List<string>() { productLine.ToString() },
|
ProductSku = new (sku.ToString()),
|
||||||
|
ProductLine = productLine.ToString(),
|
||||||
Name = name.ToString(),
|
Name = name.ToString(),
|
||||||
ProductMeasure = productMeasure
|
ProductMeasure = productMeasure
|
||||||
};
|
};
|
||||||
|
@ -110,7 +110,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
Range worksheetCells = _worksheet.Cells;
|
Range worksheetCells = _worksheet.Cells;
|
||||||
Range skuColumn = _skuCell.EntireColumn;
|
Range skuColumn = _skuCell.EntireColumn;
|
||||||
|
|
||||||
int? row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku.ToString(), positionAmount.Key.ProductLines.First());
|
int? row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku.ToString(), positionAmount.Key.ProductLine);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
|
|
||||||
if (_oldSkuCell != null)
|
if (_oldSkuCell != null)
|
||||||
{
|
{
|
||||||
row = GetPositionRow(_oldSkuCell.EntireColumn, positionAmount.Key.ProductSku.ToString(), positionAmount.Key.ProductLines.First());
|
row = GetPositionRow(_oldSkuCell.EntireColumn, positionAmount.Key.ProductSku.ToString(), positionAmount.Key.ProductLine);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -142,7 +142,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
string sku = positionAmount.Key.ProductSku.Article;
|
string sku = positionAmount.Key.ProductSku.Article;
|
||||||
row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLines.First());
|
row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLine);
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -182,7 +182,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
previous.Copy(current);
|
previous.Copy(current);
|
||||||
current.ClearContents();
|
current.ClearContents();
|
||||||
|
|
||||||
worksheetCells[row, groupColumn].Value2 = positionAmount.Key.ProductLines.First();
|
worksheetCells[row, groupColumn].Value2 = positionAmount.Key.ProductLine;
|
||||||
worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name;
|
worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name;
|
||||||
|
|
||||||
if (_oldSkuCell != null)
|
if (_oldSkuCell != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user