commit
90307872c8
@ -96,6 +96,7 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Source\Assistant\RequestModifier.cs" />
|
||||||
<Compile Include="Source\DataExport\RibbonController.cs" />
|
<Compile Include="Source\DataExport\RibbonController.cs" />
|
||||||
<Compile Include="Source\Assistant\HttpClientUtil.cs" />
|
<Compile Include="Source\Assistant\HttpClientUtil.cs" />
|
||||||
<Compile Include="Source\Assistant\StoreResponse.cs" />
|
<Compile Include="Source\Assistant\StoreResponse.cs" />
|
||||||
|
@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.31829.152
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rehau.Sku.Assist", "Rehau.Sku.Assist.csproj", "{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rehau.Sku.Assist", "Rehau.Sku.Assist.csproj", "{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rehau.Sku.Testing", "..\Rehau.Sku.Testing\Rehau.Sku.Testing.csproj", "{3D257D07-0D29-4B5E-82E4-B341769E1B3F}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -15,6 +17,10 @@ Global
|
|||||||
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Release|Any CPU.Build.0 = Release|Any CPU
|
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3D257D07-0D29-4B5E-82E4-B341769E1B3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3D257D07-0D29-4B5E-82E4-B341769E1B3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3D257D07-0D29-4B5E-82E4-B341769E1B3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3D257D07-0D29-4B5E-82E4-B341769E1B3F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -4,7 +4,6 @@ using System;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Rehau.Sku.Assist
|
namespace Rehau.Sku.Assist
|
||||||
{
|
{
|
||||||
@ -35,7 +34,7 @@ namespace Rehau.Sku.Assist
|
|||||||
UriBuilder baseUri = new UriBuilder("https", "shop-rehau.ru");
|
UriBuilder baseUri = new UriBuilder("https", "shop-rehau.ru");
|
||||||
|
|
||||||
baseUri.Path = "/catalogsearch/result/index/";
|
baseUri.Path = "/catalogsearch/result/index/";
|
||||||
string cleanedRequest = request._CleanRequest();
|
string cleanedRequest = request.CleanRequest();
|
||||||
|
|
||||||
switch (AddIn.responseOrder)
|
switch (AddIn.responseOrder)
|
||||||
{
|
{
|
||||||
@ -58,16 +57,5 @@ namespace Rehau.Sku.Assist
|
|||||||
|
|
||||||
return baseUri.Uri;
|
return baseUri.Uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string _CleanRequest(this string input)
|
|
||||||
{
|
|
||||||
return new StringBuilder(input)
|
|
||||||
.Replace("+", " plus ")
|
|
||||||
.Replace("РХ", "")
|
|
||||||
.Replace("º", " ")
|
|
||||||
.Replace(".", " ")
|
|
||||||
.Replace("Ø", " ")
|
|
||||||
.ToString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
60
Source/Assistant/RequestModifier.cs
Normal file
60
Source/Assistant/RequestModifier.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Office.Interop.Excel;
|
using Microsoft.Office.Interop.Excel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Rehau.Sku.Assist
|
namespace Rehau.Sku.Assist
|
||||||
{
|
{
|
||||||
@ -10,12 +11,12 @@ namespace Rehau.Sku.Assist
|
|||||||
private Application xlApp;
|
private Application xlApp;
|
||||||
private Dictionary<string, double> SkuAmount { get; set; }
|
private Dictionary<string, double> SkuAmount { get; set; }
|
||||||
private object[,] SelectedCells { get; set; }
|
private object[,] SelectedCells { get; set; }
|
||||||
private string ExportFileName { get; set; }
|
private string WorkingFileName { get; set; }
|
||||||
|
|
||||||
public DataWriter()
|
public DataWriter()
|
||||||
{
|
{
|
||||||
this.xlApp = (Application)ExcelDnaUtil.Application;
|
this.xlApp = (Application)ExcelDnaUtil.Application;
|
||||||
this.ExportFileName = AddIn.priceListPath;
|
this.WorkingFileName = xlApp.ActiveWorkbook.FullName;
|
||||||
|
|
||||||
GetSelectedCells();
|
GetSelectedCells();
|
||||||
}
|
}
|
||||||
@ -71,25 +72,31 @@ namespace Rehau.Sku.Assist
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FillPriceList()
|
//public void FillPriceList()
|
||||||
{
|
//{
|
||||||
Workbook wb = xlApp.Workbooks.Open(ExportFileName);
|
// string exportFileName = "rehau-export_" + DateTime.Now + ".xlsm";
|
||||||
Worksheet ws = wb.ActiveSheet;
|
// 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];
|
// Workbook wb = xlApp.Workbooks.Open(PriceListFilePath);
|
||||||
//filter.AutoFilter(1, "<>");
|
// Worksheet ws = wb.ActiveSheet;
|
||||||
|
|
||||||
wb.Save();
|
// Range amountCell = ws.Cells.Find("Кол-во");
|
||||||
wb.Close();
|
|
||||||
}
|
// 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()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ namespace Ribbon
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dw.FillSkuAmountDict();
|
dw.FillSkuAmountDict();
|
||||||
dw.FillPriceList();
|
//dw.FillPriceList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user