Compare commits

..

No commits in common. "8ac323447347e31875e1db53d899d13a4ac51c1d" and "598ffe0d3c8ce810bd50039eedb3634e0433e6da" have entirely different histories.

28 changed files with 233 additions and 258 deletions

View File

@ -1,13 +1,12 @@
using ExcelDna.Integration; using ExcelDna.Integration;
using ExcelDna.IntelliSense; using ExcelDna.IntelliSense;
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RhSolutions.Services;
using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Runtime.Caching;
namespace RhSolutions.AddIn namespace RhSolutions
{ {
class RhSolutionsAddIn : IExcelAddIn class AddIn : IExcelAddIn
{ {
public static Application Excel; public static Application Excel;
public static HttpClient httpClient; public static HttpClient httpClient;
@ -19,11 +18,6 @@ namespace RhSolutions.AddIn
IntelliSenseServer.Install(); IntelliSenseServer.Install();
RegistryUtil.Initialize(); RegistryUtil.Initialize();
EventsUtil.Initialize(); EventsUtil.Initialize();
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls;
} }
public void AutoClose() public void AutoClose()

View File

@ -1,12 +1,10 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RhSolutions.AddIn;
using RhSolutions.Controllers;
namespace RhSolutions.Services namespace RhSolutions
{ {
internal static class EventsUtil internal static class EventsUtil
{ {
private static readonly Application Excel = RhSolutionsAddIn.Excel; private static readonly Application Excel = AddIn.Excel;
public static void Initialize() public static void Initialize()
{ {
@ -24,12 +22,12 @@ namespace RhSolutions.Services
private static void RefreshConvertButton(object sh) private static void RefreshConvertButton(object sh)
{ {
RibbonController.RefreshControl("convert"); Interface.RibbonController.RefreshControl("convert");
} }
private static void RefreshExportButton(object sh, Range target) private static void RefreshExportButton(object sh, Range target)
{ {
RibbonController.RefreshControl("export"); Interface.RibbonController.RefreshControl("export");
} }
} }
} }

View File

@ -1,10 +1,27 @@
using ExcelDna.Integration; using ExcelDna.Integration;
using RhSolutions.Services; using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace RhSolutions.AddIn namespace RhSolutions
{ {
public class Functions public class Functions
{ {
[ExcelFunction(Description = "Получение корректного артикула из строки")]
public static object GETRAUSKU([ExcelArgument(Name = "\"Строка\"", Description = "строка, содержащая актикул")] string line)
{
if (RauSku.TryParse(line, out RauSku rausku))
{
return rausku.ToString();
}
else return ExcelError.ExcelErrorNA;
}
[ExcelFunction(Description = "Запрос в удаленную базу данных")] [ExcelFunction(Description = "Запрос в удаленную базу данных")]
public static object RHSOLUTIONS([ExcelArgument(Name = "Запрос")] string line) public static object RHSOLUTIONS([ExcelArgument(Name = "Запрос")] string line)
{ {
@ -28,4 +45,40 @@ namespace RhSolutions.AddIn
return result; return result;
} }
} }
public static class RhDatabaseClient
{
private static HttpClient httpClient = AddIn.httpClient;
public static async Task<object> GetProduct(string line)
{
string request = @"https://rh.cebotari.ru/api/search?query=" + line;
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls;
string response = await httpClient.GetStringAsync(request);
var products = JsonConvert.DeserializeObject<IEnumerable<DbProduct>>(response);
var product = products.FirstOrDefault();
if (product == null)
{
return null;
}
else
{
return $"{product.productSku} {product.name}";
}
}
private class DbProduct
{
public string productSku { get; set; }
public string name { get; set; }
}
}
} }

View File

@ -1,11 +1,10 @@
using Microsoft.Win32; using Microsoft.Win32;
using RhSolutions.Controllers; using RhSolutions.Interface;
using RhSolutions.Models;
using System; using System;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
namespace RhSolutions.Services namespace RhSolutions
{ {
static class RegistryUtil static class RegistryUtil
{ {
@ -14,13 +13,13 @@ namespace RhSolutions.Services
public static void Initialize() public static void Initialize()
{ {
RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist"); RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
priceListPath = RootKey.GetValue("PriceListPath") as string; priceListPath = RootKey.GetValue("PriceListPath") as string;
} }
public static void Uninitialize() public static void Uninitialize()
{ {
RootKey.Close(); RootKey.Close();
} }
public static string PriceListPath public static string PriceListPath

View File

@ -1,19 +1,19 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace RhSolutions.Models namespace RhSolutions
{ {
internal class Sku internal class RauSku
{ {
public string Article { get; private set; } public string Sku { get; private set; }
public string Variant { get; private set; } public string Variant { get; private set; }
public Sku(string article, string variant) public RauSku(string sku, string variant)
{ {
Article = article; Sku = sku;
Variant = variant; Variant = variant;
} }
public static bool TryParse(string line, out Sku rehauSku) public static bool TryParse(string line, out RauSku rehauSku)
{ {
Match match; Match match;
match = Regex.Match(line, @"\b[1]\d{6}[1]\d{3}\b"); match = Regex.Match(line, @"\b[1]\d{6}[1]\d{3}\b");
@ -21,7 +21,7 @@ namespace RhSolutions.Models
{ {
string sku = match.Value.Substring(1, 6); string sku = match.Value.Substring(1, 6);
string variant = match.Value.Substring(8, 3); string variant = match.Value.Substring(8, 3);
rehauSku = new Sku(sku, variant); rehauSku = new RauSku(sku, variant);
return true; return true;
} }
@ -30,7 +30,7 @@ namespace RhSolutions.Models
{ {
string sku = match.Value.Substring(0, 6); string sku = match.Value.Substring(0, 6);
string variant = match.Value.Substring(7, 3); string variant = match.Value.Substring(7, 3);
rehauSku = new Sku(sku, variant); rehauSku = new RauSku(sku, variant);
return true; return true;
} }
@ -39,7 +39,7 @@ namespace RhSolutions.Models
{ {
string sku = match.Value.Substring(0, 6); string sku = match.Value.Substring(0, 6);
string variant = match.Value.Substring(6, 3); string variant = match.Value.Substring(6, 3);
rehauSku = new Sku(sku, variant); rehauSku = new RauSku(sku, variant);
return true; return true;
} }
@ -48,20 +48,20 @@ namespace RhSolutions.Models
{ {
string sku = match.Value.Substring(0, 6); string sku = match.Value.Substring(0, 6);
string variant = "001"; string variant = "001";
rehauSku = new Sku(sku, variant); rehauSku = new RauSku(sku, variant);
return true; return true;
} }
else else
{ {
rehauSku = null; rehauSku = null;
return false; return false;
} }
} }
public override string ToString() public override string ToString()
{ {
return $"1{Article}1{Variant}"; return $"1{Sku}1{Variant}";
} }
} }
} }

View File

@ -1,6 +1,6 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace RhSolutions.Models namespace RhSolutions
{ {
static class SkuExtensions static class SkuExtensions
{ {

View File

@ -1,8 +1,8 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RhSolutions.Models; using RhSolutions.PriceListTools;
using System.Linq; using System.Linq;
namespace RhSolutions.Services namespace RhSolutions
{ {
public static class WorksheetExtensions public static class WorksheetExtensions
{ {

View File

@ -0,0 +1,24 @@
using ExcelDna.Integration;
using Microsoft.Office.Interop.Excel;
using System;
namespace RhSolutions.Interface
{
internal abstract class AbstractBar : IDisposable
{
protected Application Excel = AddIn.Excel;
public abstract void Update();
[ExcelFunction]
public static void ResetStatusBar()
{
AddIn.Excel.StatusBar = false;
}
public void Dispose()
{
AddIn.Excel.OnTime(DateTime.Now + new TimeSpan(0, 0, 5), "ResetStatusBar");
}
}
}

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
namespace RhSolutions.Models namespace RhSolutions.Interface
{ {
static class Dialog static class Dialog
{ {

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Models namespace RhSolutions.Interface
{ {
internal class ProgressBar : StatusbarBase internal class ProgressBar : AbstractBar
{ {
private double CurrentProgress { get; set; } private double CurrentProgress { get; set; }
private readonly double TaskWeight; private readonly double TaskWeight;
@ -15,7 +15,7 @@
public override void Update() public override void Update()
{ {
double percent = ++CurrentProgress / TaskWeight * 100; double percent = (++CurrentProgress / TaskWeight) * 100;
Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %"; Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %";
} }
} }

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Text; using System.Text;
namespace RhSolutions.Models namespace RhSolutions.Interface
{ {
internal class ResultBar : StatusbarBase internal class ResultBar : AbstractBar
{ {
private int Success { get; set; } private int Success { get; set; }
private int Replaced { get; set; } private int Replaced { get; set; }

View File

@ -1,14 +1,13 @@
using ExcelDna.Integration.CustomUI; using ExcelDna.Integration.CustomUI;
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RhSolutions.AddIn; using RhSolutions.PriceListTools;
using RhSolutions.Services;
using System; using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
namespace RhSolutions.Controllers namespace RhSolutions.Interface
{ {
[ComVisible(true)] [ComVisible(true)]
public class RibbonController : ExcelRibbon public class RibbonController : ExcelRibbon
@ -53,7 +52,7 @@ namespace RhSolutions.Controllers
} }
public void OnSetPricePressed(IRibbonControl control) public void OnSetPricePressed(IRibbonControl control)
{ {
string path = Models.Dialog.GetFilePath(); string path = Dialog.GetFilePath();
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
@ -65,7 +64,7 @@ namespace RhSolutions.Controllers
{ {
try try
{ {
ToolBase tool; AbstractTool tool;
switch (control.Id) switch (control.Id)
{ {
case "export": case "export":
@ -94,31 +93,31 @@ namespace RhSolutions.Controllers
"Ошибка", "Ошибка",
MessageBoxButtons.OK, MessageBoxButtons.OK,
MessageBoxIcon.Information); MessageBoxIcon.Information);
RhSolutionsAddIn.Excel.StatusBar = false; AddIn.Excel.StatusBar = false;
return; return;
} }
} }
public bool GetConvertEnabled(IRibbonControl control) public bool GetConvertEnabled(IRibbonControl control)
{ {
if (RhSolutionsAddIn.Excel.ActiveWorkbook == null) if (AddIn.Excel.ActiveWorkbook == null)
return false; return false;
else else
{ {
Worksheet worksheet = RhSolutionsAddIn.Excel.ActiveWorkbook.ActiveSheet; Worksheet worksheet = AddIn.Excel.ActiveWorkbook.ActiveSheet;
return worksheet.IsRehauSource(); return worksheet.IsRehauSource();
} }
} }
public bool GetExportEnabled(IRibbonControl control) public bool GetExportEnabled(IRibbonControl control)
{ {
if (RhSolutionsAddIn.Excel.ActiveWorkbook == null) if (AddIn.Excel.ActiveWorkbook == null)
return false; return false;
else else
{ {
Range selection = RhSolutionsAddIn.Excel.Selection; Range selection = AddIn.Excel.Selection;
return selection.Columns.Count == 2; return selection.Columns.Count == 2;
} }
} }

View File

@ -1,35 +0,0 @@
using System.Linq;
namespace RhSolutions.Models
{
public class Product
{
public string ProductLine { get; set; }
public string ProductSku { get; set; }
public string Name { get; set; }
public override bool Equals(object obj)
{
if (obj as Product == null)
return false;
Product other = obj as Product;
return ProductLine == other.ProductLine &&
ProductSku == other.ProductSku &&
Name == other.Name;
}
public override int GetHashCode()
{
string[] properties = new[]
{
ProductLine,
ProductSku,
Name
};
return string.Concat(properties.Where(p => p != null)).GetHashCode();
}
}
}

View File

@ -1,26 +0,0 @@
using ExcelDna.Integration;
using Microsoft.Office.Interop.Excel;
using RhSolutions.AddIn;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace RhSolutions.Models
{
internal abstract class StatusbarBase : IDisposable
{
protected Application Excel = RhSolutionsAddIn.Excel;
public abstract void Update();
private static void ResetStatusBar()
{
RhSolutionsAddIn.Excel.StatusBar = false;
}
public void Dispose()
{
Task.Delay(5000).ContinueWith(t => ResetStatusBar());
}
}
}

View File

@ -1,8 +1,8 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
namespace RhSolutions.Models namespace RhSolutions.PriceListTools
{ {
internal abstract class PriceListBase internal abstract class AbstractPriceList
{ {
public Range AmountCell { get; protected set; } public Range AmountCell { get; protected set; }
public Range SkuCell { get; protected set; } public Range SkuCell { get; protected set; }

View File

@ -1,16 +1,15 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RhSolutions.AddIn; using RhSolutions.Interface;
using RhSolutions.Models;
using RhSolutions.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ProgressBar = RhSolutions.Interface.ProgressBar;
namespace RhSolutions.Controllers namespace RhSolutions.PriceListTools
{ {
internal abstract class ToolBase internal abstract class AbstractTool
{ {
protected Application ExcelApp = RhSolutionsAddIn.Excel; protected Application ExcelApp = AddIn.Excel;
protected TargetPriceList TargetFile { get; set; } protected TargetPriceList TargetFile { get; set; }
protected ResultBar ResultBar { get; set; } protected ResultBar ResultBar { get; set; }
protected ProgressBar ProgressBar { get; set; } protected ProgressBar ProgressBar { get; set; }
@ -44,13 +43,13 @@ namespace RhSolutions.Controllers
} }
} }
protected void FillPositionAmountToColumns(KeyValuePair<Product, double> positionAmount, params int[] columns) protected void FillPositionAmountToColumns(KeyValuePair<Position, double> positionAmount, params int[] columns)
{ {
Range worksheetCells = TargetFile.Sheet.Cells; Range worksheetCells = TargetFile.Sheet.Cells;
Range skuColumn = TargetFile.SkuCell.EntireColumn; Range skuColumn = TargetFile.SkuCell.EntireColumn;
Range oldSkuColumn = TargetFile.OldSkuCell.EntireColumn; Range oldSkuColumn = TargetFile.OldSkuCell.EntireColumn;
int? row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLine); int? row = GetPositionRow(skuColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
if (row != null) if (row != null)
{ {
@ -66,7 +65,7 @@ namespace RhSolutions.Controllers
if (TargetFile.OldSkuCell != null) if (TargetFile.OldSkuCell != null)
{ {
row = GetPositionRow(oldSkuColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLine); row = GetPositionRow(oldSkuColumn, positionAmount.Key.Sku, positionAmount.Key.Group);
if (row != null) if (row != null)
{ {
@ -81,8 +80,8 @@ namespace RhSolutions.Controllers
} }
} }
string sku = positionAmount.Key.ProductSku.Substring(1, 6); string sku = positionAmount.Key.Sku.Substring(1, 6);
row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLine); row = GetPositionRow(skuColumn, sku, positionAmount.Key.Group);
if (row != null) if (row != null)
{ {
@ -100,7 +99,7 @@ namespace RhSolutions.Controllers
ResultBar.IncrementNotFound(); ResultBar.IncrementNotFound();
} }
protected void FillMissing(KeyValuePair<Product, double> positionAmount, params int[] columns) protected void FillMissing(KeyValuePair<Position, double> positionAmount, params int[] columns)
{ {
Range worksheetCells = TargetFile.Sheet.Cells; Range worksheetCells = TargetFile.Sheet.Cells;
Range worksheetRows = TargetFile.Sheet.Rows; Range worksheetRows = TargetFile.Sheet.Rows;
@ -122,18 +121,18 @@ namespace RhSolutions.Controllers
previous.Copy(current); previous.Copy(current);
current.ClearContents(); current.ClearContents();
worksheetCells[row, groupColumn].Value2 = positionAmount.Key.ProductLine; worksheetCells[row, groupColumn].Value2 = positionAmount.Key.Group;
worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name; worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name;
if (TargetFile.OldSkuCell != null) if (TargetFile.OldSkuCell != null)
{ {
worksheetCells[row, skuColumn].Value2 = "Не найден"; worksheetCells[row, skuColumn].Value2 = "Не найден";
worksheetCells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.ProductSku; worksheetCells[row, TargetFile.OldSkuCell.Column].Value2 = positionAmount.Key.Sku;
} }
else else
{ {
worksheetCells[row, skuColumn].Value2 = positionAmount.Key.ProductSku; worksheetCells[row, skuColumn].Value2 = positionAmount.Key.Sku;
} }
foreach (int column in columns) foreach (int column in columns)

View File

@ -1,13 +1,13 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using RhSolutions.Models; using RhSolutions.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dialog = RhSolutions.Models.Dialog; using Dialog = RhSolutions.Interface.Dialog;
namespace RhSolutions.Controllers namespace RhSolutions.PriceListTools
{ {
internal class CombineTool : ToolBase internal class CombineTool : AbstractTool
{ {
private List<SourcePriceList> SourceFiles { get; set; } private List<SourcePriceList> SourceFiles { get; set; }

View File

@ -1,8 +1,8 @@
using RhSolutions.Models; using RhSolutions.Interface;
namespace RhSolutions.Controllers namespace RhSolutions.PriceListTools
{ {
internal class ConvertTool : ToolBase internal class ConvertTool : AbstractTool
{ {
private SourcePriceList Current { get; set; } private SourcePriceList Current { get; set; }

View File

@ -1,13 +1,13 @@
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using RhSolutions.Models; using RhSolutions.Interface;
namespace RhSolutions.Controllers namespace RhSolutions.PriceListTools
{ {
internal class ExportTool : ToolBase internal class ExportTool : AbstractTool
{ {
private Dictionary<Product, double> PositionAmount; private Dictionary<Position, double> PositionAmount;
private readonly Range Selection; private readonly Range Selection;
public ExportTool() public ExportTool()
@ -40,7 +40,7 @@ namespace RhSolutions.Controllers
private void GetSelected() private void GetSelected()
{ {
object[,] cells = Selection.Value2; object[,] cells = Selection.Value2;
PositionAmount = new Dictionary<Product, double>(); PositionAmount = new Dictionary<Position, double>();
int rowsCount = Selection.Rows.Count; int rowsCount = Selection.Rows.Count;
@ -56,7 +56,7 @@ namespace RhSolutions.Controllers
{ {
object current = cells[row, column]; object current = cells[row, column];
if (Sku.TryParse(current.ToString(), out Sku rauSku)) if (RauSku.TryParse(current.ToString(), out RauSku rauSku))
{ {
sku = rauSku.ToString(); sku = rauSku.ToString();
} }
@ -78,10 +78,7 @@ namespace RhSolutions.Controllers
continue; continue;
} }
Product position = new Product Position position = new Position(null, sku, null);
{
ProductSku = sku
};
if (PositionAmount.ContainsKey(position)) if (PositionAmount.ContainsKey(position))
{ {

View File

@ -1,11 +1,11 @@
using RhSolutions.Models; using RhSolutions.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace RhSolutions.Controllers namespace RhSolutions.PriceListTools
{ {
internal class MergeTool : ToolBase internal class MergeTool : AbstractTool
{ {
private List<SourcePriceList> SourceFiles { get; set; } private List<SourcePriceList> SourceFiles { get; set; }

View File

@ -0,0 +1,42 @@
using System.Linq;
namespace RhSolutions.PriceListTools
{
public class Position
{
public string Group { get; private set; }
public string Sku { get; private set; }
public string Name { get; private set; }
public Position(string group, string sku, string name)
{
Group = group;
Sku = sku;
Name = name;
}
public override bool Equals(object obj)
{
if (obj as Position == null)
return false;
Position other = obj as Position;
return Group == other.Group &&
Sku == other.Sku &&
Name == other.Name;
}
public override int GetHashCode()
{
string[] properties = new[]
{
Group,
Sku,
Name
};
return string.Concat(properties.Where(p => p != null)).GetHashCode();
}
}
}

View File

@ -1,4 +1,4 @@
namespace RhSolutions.Models namespace RhSolutions.PriceListTools
{ {
internal static class PriceListHeaders internal static class PriceListHeaders
{ {

View File

@ -3,12 +3,13 @@ using Microsoft.Office.Interop.Excel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using RhSolutions.Interface;
namespace RhSolutions.Models namespace RhSolutions.PriceListTools
{ {
internal class SourcePriceList : PriceListBase internal class SourcePriceList : AbstractPriceList
{ {
public Dictionary<Product, double> PositionAmount { get; private set; } public Dictionary<Position, double> PositionAmount { get; private set; }
public SourcePriceList(Workbook workbook) public SourcePriceList(Workbook workbook)
{ {
@ -72,7 +73,7 @@ namespace RhSolutions.Models
private void CreatePositionsDict() private void CreatePositionsDict()
{ {
PositionAmount = new Dictionary<Product, double>(); PositionAmount = new Dictionary<Position, double>();
for (int row = AmountCell.Row + 1; row <= Sheet.Cells[Sheet.Rows.Count, AmountCell.Column].End[XlDirection.xlUp].Row; row++) for (int row = AmountCell.Row + 1; row <= Sheet.Cells[Sheet.Rows.Count, AmountCell.Column].End[XlDirection.xlUp].Row; row++)
{ {
@ -90,12 +91,7 @@ namespace RhSolutions.Models
if (!sku.ToString().IsRehauSku()) if (!sku.ToString().IsRehauSku())
continue; continue;
Product p = new Product Position p = new Position(group.ToString(), sku.ToString(), name.ToString());
{
ProductSku = sku.ToString(),
ProductLine = group.ToString(),
Name = name.ToString()
};
if (PositionAmount.ContainsKey(p)) if (PositionAmount.ContainsKey(p))
{ {

View File

@ -2,9 +2,9 @@
using System; using System;
using System.Linq; using System.Linq;
namespace RhSolutions.Models namespace RhSolutions.PriceListTools
{ {
internal class TargetPriceList : PriceListBase internal class TargetPriceList : AbstractPriceList
{ {
public Range OldSkuCell { get; private set; } public Range OldSkuCell { get; private set; }
@ -31,7 +31,7 @@ namespace RhSolutions.Models
if (cells.Any(x => x == null)) if (cells.Any(x => x == null))
{ {
throw new ArgumentException($"Шаблон {Name} не является прайс-листом"); throw new ArgumentException($"Шаблон { Name } не является прайс-листом");
} }
} }
} }

View File

@ -5,10 +5,10 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("RhSolutions.AddIn")] [assembly: AssemblyTitle("RhXlPLugin")]
[assembly: AssemblyDescription("Excel AddIn for RhSolutions")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("RhSolutions")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RhXlPLugin")] [assembly: AssemblyProduct("RhXlPLugin")]
[assembly: AssemblyCopyright("Copyright © 2021-2023")] [assembly: AssemblyCopyright("Copyright © 2021-2023")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
@ -32,5 +32,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.2.0.0")] [assembly: AssemblyVersion("1.0.5.0")]
[assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyFileVersion("1.0.5.0")]

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<DnaLibrary Name="RhSolutions Add-In" RuntimeVersion="v4.0" xmlns="http://schemas.excel-dna.net/addin/2020/07/dnalibrary"> <DnaLibrary Name="RhSolutions Add-In" RuntimeVersion="v4.0" xmlns="http://schemas.excel-dna.net/addin/2020/07/dnalibrary">
<ExternalLibrary Path="RhSolutions.AddIn.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="false" /> <ExternalLibrary Path="RhExcelAddin.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="false" />
<Reference Path="ExcelDna.IntelliSense.dll" Pack="true" />
<Reference Path="Newtonsoft.Json.dll" Pack="true" />
<!-- <!--
The RuntimeVersion attribute above allows only the following setting: The RuntimeVersion attribute above allows only the following setting:

View File

@ -8,8 +8,8 @@
<ProjectGuid>{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}</ProjectGuid> <ProjectGuid>{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RhSolutions.AddIn</RootNamespace> <RootNamespace>RhExcelAddin</RootNamespace>
<AssemblyName>RhSolutions.AddIn</AssemblyName> <AssemblyName>RhExcelAddin</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
@ -77,29 +77,28 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Services\EventsUtil.cs" /> <Compile Include="AddIn\EventsUtil.cs" />
<Compile Include="Services\RhDatabaseClient.cs" /> <Compile Include="AddIn\RehauSku.cs" />
<Compile Include="Models\Sku.cs" /> <Compile Include="Interface\AbstractBar.cs" />
<Compile Include="Models\StatusbarBase.cs" /> <Compile Include="Interface\Dialog.cs" />
<Compile Include="Models\Dialog.cs" /> <Compile Include="AddIn\RegistryUtil.cs" />
<Compile Include="Services\RegistryUtil.cs" /> <Compile Include="AddIn\SkuExtensions.cs" />
<Compile Include="Models\SkuExtensions.cs" /> <Compile Include="Interface\ProgressBar.cs" />
<Compile Include="Models\ProgressBar.cs" /> <Compile Include="Interface\ResultBar.cs" />
<Compile Include="Models\ResultBar.cs" /> <Compile Include="PriceListTools\CombineTool.cs" />
<Compile Include="Controllers\CombineTool.cs" /> <Compile Include="PriceListTools\ConvertTool.cs" />
<Compile Include="Controllers\ConvertTool.cs" /> <Compile Include="PriceListTools\Position.cs" />
<Compile Include="Models\Product.cs" /> <Compile Include="PriceListTools\AbstractTool.cs" />
<Compile Include="Controllers\ToolBase.cs" /> <Compile Include="PriceListTools\MergeTool.cs" />
<Compile Include="Controllers\MergeTool.cs" /> <Compile Include="PriceListTools\AbstractPriceList.cs" />
<Compile Include="Models\PriceListBase.cs" /> <Compile Include="PriceListTools\PriceListHeaders.cs" />
<Compile Include="Models\PriceListHeaders.cs" /> <Compile Include="PriceListTools\SourcePriceList.cs" />
<Compile Include="Models\SourcePriceList.cs" /> <Compile Include="PriceListTools\TargetPriceList.cs" />
<Compile Include="Models\TargetPriceList.cs" /> <Compile Include="Interface\RibbonController.cs" />
<Compile Include="Controllers\RibbonController.cs" /> <Compile Include="PriceListTools\ExportTool.cs" />
<Compile Include="Controllers\ExportTool.cs" />
<Compile Include="AddIn\AddIn.cs" /> <Compile Include="AddIn\AddIn.cs" />
<Compile Include="AddIn\Functions.cs" /> <Compile Include="AddIn\Functions.cs" />
<Compile Include="Models\WorksheetExtensions.cs" /> <Compile Include="AddIn\WorksheetExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,62 +0,0 @@
using Newtonsoft.Json;
using RhSolutions.AddIn;
using RhSolutions.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
namespace RhSolutions.Services
{
public static class RhDatabaseClient
{
private static HttpClient httpClient = RhSolutionsAddIn.httpClient;
public static async Task<object> GetProduct(string line)
{
string request = string.Empty;
if (line.IsRehauSku())
{
request = @"https://rh.cebotari.ru/api/products/" + line;
}
else
{
request = @"https://rh.cebotari.ru/api/search?query=" + line;
}
var response = await httpClient.GetAsync(request);
try
{
response.EnsureSuccessStatusCode();
string json = await response.Content.ReadAsStringAsync();
var product = JsonConvert.DeserializeObject<IEnumerable<Product>>(json)
.FirstOrDefault();
if (product == null)
{
return null;
}
else
{
if (line.IsRehauSku())
{
return product.Name;
}
else
{
return $"{product.ProductSku} {product.Name}";
}
}
}
catch
{
return $"Ошибка сервера {response.StatusCode}";
}
}
}
}