aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorSerghei Cebotari <51533848+schebotar@users.noreply.github.com>2021-12-08 09:46:11 +0300
committerGitHub <noreply@github.com>2021-12-08 09:46:11 +0300
commit90307872c8b1a17fc818554474971894f1c91294 (patch)
treebbd9aa53f299eed983f63f2a79324ff24bee5063 /Source
parentadf66ad2a2c358ec8d3edfc92f96ba0376888e74 (diff)
parent910ba4bf6ddf8415bf3a8db78d4c85e4ccd45bd6 (diff)
Merge pull request #7 from schebotar/test
Test
Diffstat (limited to 'Source')
-rw-r--r--Source/Assistant/HttpClientUtil.cs14
-rw-r--r--Source/Assistant/RequestModifier.cs60
-rw-r--r--Source/DataExport/DataWriter.cs41
-rw-r--r--Source/DataExport/RibbonController.cs2
4 files changed, 86 insertions, 31 deletions
diff --git a/Source/Assistant/HttpClientUtil.cs b/Source/Assistant/HttpClientUtil.cs
index 6eb0b69..2d439ea 100644
--- a/Source/Assistant/HttpClientUtil.cs
+++ b/Source/Assistant/HttpClientUtil.cs
@@ -4,7 +4,6 @@ using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
-using System.Text;
namespace Rehau.Sku.Assist
{
@@ -35,7 +34,7 @@ namespace Rehau.Sku.Assist
UriBuilder baseUri = new UriBuilder("https", "shop-rehau.ru");
baseUri.Path = "/catalogsearch/result/index/";
- string cleanedRequest = request._CleanRequest();
+ string cleanedRequest = request.CleanRequest();
switch (AddIn.responseOrder)
{
@@ -58,16 +57,5 @@ namespace Rehau.Sku.Assist
return baseUri.Uri;
}
-
- private static string _CleanRequest(this string input)
- {
- return new StringBuilder(input)
- .Replace("+", " plus ")
- .Replace("РХ", "")
- .Replace("º", " ")
- .Replace(".", " ")
- .Replace("Ø", " ")
- .ToString();
- }
}
} \ No newline at end of file
diff --git a/Source/Assistant/RequestModifier.cs b/Source/Assistant/RequestModifier.cs
new file mode 100644
index 0000000..28f5775
--- /dev/null
+++ b/Source/Assistant/RequestModifier.cs
@@ -0,0 +1,60 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Rehau.Sku.Assist
+{
+ public static class RequestModifier
+ {
+ public static string CleanRequest(this string input)
+ {
+ string replace = new StringBuilder(input)
+ .Replace("+", " plus ")
+ .Replace("РХ", "")
+ .Replace("º", " ")
+ .Replace(".", " ")
+ .Replace("Ø", " ")
+ .ToString();
+
+ return replace._tPiece();
+ }
+
+ private static string _tPiece(this string line)
+ {
+ if (!line.ToLower().Contains("тройник"))
+ return line;
+
+ string m = Regex.Match(line, @"\d{2}.\d{2}.\d{2}").Value;
+
+ int endFaceA = int.Parse($"{m[0]}{m[1]}");
+ int side = int.Parse($"{m[3]}{m[4]}");
+ int endFaceB = int.Parse($"{m[6]}{m[7]}");
+
+ int[] endFaces = new[] { endFaceA, endFaceB };
+
+ List<string> additions = new List<string>();
+
+ if (endFaces.All(x => x < side))
+ additions.Add("увеличенный боковой");
+
+ else
+ {
+ if (new[] { endFaceA, endFaceB, side }.Distinct().Count() == 1)
+ additions.Add("равнопроходной");
+ else
+ additions.Add("уменьшенный");
+
+ if (endFaces.Any(x => x > side))
+ additions.Add("боковой");
+ if (endFaceA != endFaceB)
+ additions.Add("торцевой");
+ }
+
+ string piece = $" {endFaces.Max()}-{side}-{endFaces.Min()} ";
+ string replace = string.Join(" ", additions) + piece;
+
+ return line.Replace(m, replace);
+ }
+ }
+} \ No newline at end of file
diff --git a/Source/DataExport/DataWriter.cs b/Source/DataExport/DataWriter.cs
index 7095577..30a3e83 100644
--- a/Source/DataExport/DataWriter.cs
+++ b/Source/DataExport/DataWriter.cs
@@ -2,6 +2,7 @@
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
+using System.IO;
namespace Rehau.Sku.Assist
{
@@ -10,12 +11,12 @@ namespace Rehau.Sku.Assist
private Application xlApp;
private Dictionary<string, double> SkuAmount { get; set; }
private object[,] SelectedCells { get; set; }
- private string ExportFileName { get; set; }
+ private string WorkingFileName { get; set; }
public DataWriter()
{
this.xlApp = (Application)ExcelDnaUtil.Application;
- this.ExportFileName = AddIn.priceListPath;
+ this.WorkingFileName = xlApp.ActiveWorkbook.FullName;
GetSelectedCells();
}
@@ -71,25 +72,31 @@ namespace Rehau.Sku.Assist
}
}
- public void FillPriceList()
- {
- Workbook wb = xlApp.Workbooks.Open(ExportFileName);
- Worksheet ws = wb.ActiveSheet;
+ //public void FillPriceList()
+ //{
+ // string exportFileName = "rehau-export_" + DateTime.Now + ".xlsm";
+ // string workingDir = xlApp.ActiveWorkbook.Path;
- Range amountCell = ws.Cells.Find("Кол-во");
+ // //File.Copy(Path.GetFullPath(PriceListFilePath), Path.Combine(WorkingFileName, exportFileName + ".xlsm"));
- foreach (KeyValuePair<string,double> kvp in SkuAmount)
- {
- Range cell = ws.Cells.Find(kvp.Key);
- ws.Cells[cell.Row, amountCell.Column].Value = kvp.Value;
- }
- //Range filter = ws.Cells[amountCell.Row + 1, amountCell.Column];
- //filter.AutoFilter(1, "<>");
+ // Workbook wb = xlApp.Workbooks.Open(PriceListFilePath);
+ // Worksheet ws = wb.ActiveSheet;
- wb.Save();
- wb.Close();
- }
+ // Range amountCell = ws.Cells.Find("Кол-во");
+
+ // foreach (KeyValuePair<string, double> kvp in SkuAmount)
+ // {
+ // Range cell = ws.Cells.Find(kvp.Key);
+ // ws.Cells[cell.Row, amountCell.Column].Value = kvp.Value;
+ // }
+
+ // //Range filter = ws.Range["H16:H4058"];
+ // ws.Cells.AutoFilter(7, "<>");
+
+ // //wb.Save();
+ // //wb.Close();
+ //}
public void Dispose()
{
diff --git a/Source/DataExport/RibbonController.cs b/Source/DataExport/RibbonController.cs
index 3ae9099..5c4045a 100644
--- a/Source/DataExport/RibbonController.cs
+++ b/Source/DataExport/RibbonController.cs
@@ -37,7 +37,7 @@ namespace Ribbon
else
{
dw.FillSkuAmountDict();
- dw.FillPriceList();
+ //dw.FillPriceList();
}
}
}