aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RhSolutions.AddIn/Models/PriceListHeaders.cs11
-rw-r--r--RhSolutions.AddIn/Models/SourcePriceList.cs13
-rw-r--r--RhSolutions.AddIn/Models/TargetPriceList.cs15
-rw-r--r--RhSolutions.AddIn/Models/WorksheetExtensions.cs14
-rw-r--r--RhSolutions.AddIn/Services/AddInConfiguration.cs118
-rw-r--r--RhSolutions.AddIn/Services/IAddInConfiguration.cs18
6 files changed, 126 insertions, 63 deletions
diff --git a/RhSolutions.AddIn/Models/PriceListHeaders.cs b/RhSolutions.AddIn/Models/PriceListHeaders.cs
deleted file mode 100644
index c9a8370..0000000
--- a/RhSolutions.AddIn/Models/PriceListHeaders.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace RhSolutions.Models
-{
- internal static class PriceListHeaders
- {
- public static readonly string Amount = "Кол-во";
- public static readonly string OldSku = "Прежний материал";
- public static readonly string Sku = "Актуальный материал";
- public static readonly string Group = "Программа";
- public static readonly string Name = "Наименование";
- }
-} \ No newline at end of file
diff --git a/RhSolutions.AddIn/Models/SourcePriceList.cs b/RhSolutions.AddIn/Models/SourcePriceList.cs
index d6c2cfe..db691ec 100644
--- a/RhSolutions.AddIn/Models/SourcePriceList.cs
+++ b/RhSolutions.AddIn/Models/SourcePriceList.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using RhSolutions.AddIn;
+using System.IO;
namespace RhSolutions.Models;
@@ -16,12 +17,14 @@ internal class SourcePriceList : PriceListBase
Sheet = workbook.ActiveSheet;
Name = Path.GetFileNameWithoutExtension(workbook.FullName);
+ var pricelistParameters = RhSolutionsAddIn.Configuration.GetPriceListParameters();
+
Range[] cells = new[]
{
- AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
- SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
- GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
- NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
+ AmountCell = Sheet.Cells.Find(pricelistParameters["Amount"]),
+ SkuCell = Sheet.Cells.Find(pricelistParameters["Sku"]),
+ GroupCell = Sheet.Cells.Find(pricelistParameters["Group"]),
+ NameCell = Sheet.Cells.Find(pricelistParameters["Name"])
};
if (cells.Any(x => x == null))
diff --git a/RhSolutions.AddIn/Models/TargetPriceList.cs b/RhSolutions.AddIn/Models/TargetPriceList.cs
index 254b5b0..15ba066 100644
--- a/RhSolutions.AddIn/Models/TargetPriceList.cs
+++ b/RhSolutions.AddIn/Models/TargetPriceList.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using RhSolutions.AddIn;
+using System.IO;
namespace RhSolutions.Models;
@@ -17,15 +18,17 @@ internal class TargetPriceList : PriceListBase
Sheet = workbook.ActiveSheet;
Name = Path.GetFileNameWithoutExtension(workbook.FullName);
+ var pricelistParameters = RhSolutionsAddIn.Configuration.GetPriceListParameters();
+
Range[] cells = new[]
{
- AmountCell = Sheet.Cells.Find(PriceListHeaders.Amount),
- SkuCell = Sheet.Cells.Find(PriceListHeaders.Sku),
- GroupCell = Sheet.Cells.Find(PriceListHeaders.Group),
- NameCell = Sheet.Cells.Find(PriceListHeaders.Name)
+ AmountCell = Sheet.Cells.Find(pricelistParameters["Amount"]),
+ SkuCell = Sheet.Cells.Find(pricelistParameters["Sku"]),
+ GroupCell = Sheet.Cells.Find(pricelistParameters["Group"]),
+ NameCell = Sheet.Cells.Find(pricelistParameters["Name"])
};
- OldSkuCell = Sheet.Cells.Find(PriceListHeaders.OldSku);
+ OldSkuCell = Sheet.Cells.Find(pricelistParameters["OldSku"]);
if (cells.Any(x => x == null))
{
diff --git a/RhSolutions.AddIn/Models/WorksheetExtensions.cs b/RhSolutions.AddIn/Models/WorksheetExtensions.cs
index 24968e2..da38203 100644
--- a/RhSolutions.AddIn/Models/WorksheetExtensions.cs
+++ b/RhSolutions.AddIn/Models/WorksheetExtensions.cs
@@ -1,4 +1,6 @@
-namespace RhSolutions.Services;
+using RhSolutions.AddIn;
+
+namespace RhSolutions.Services;
public static class WorksheetExtensions
{
@@ -9,12 +11,14 @@ public static class WorksheetExtensions
Range groupCell;
Range nameCell;
+ var pricelistParameters = RhSolutionsAddIn.Configuration.GetPriceListParameters();
+
Range[] cells = new[]
{
- amountCell = worksheet.Cells.Find(PriceListHeaders.Amount),
- skuCell = worksheet.Cells.Find(PriceListHeaders.Sku),
- groupCell = worksheet.Cells.Find(PriceListHeaders.Group),
- nameCell = worksheet.Cells.Find(PriceListHeaders.Name)
+ amountCell = worksheet.Cells.Find(pricelistParameters["Amount"]),
+ skuCell = worksheet.Cells.Find(pricelistParameters["Sku"]),
+ groupCell = worksheet.Cells.Find(pricelistParameters["Group"]),
+ nameCell = worksheet.Cells.Find(pricelistParameters["Name"])
};
return cells.All(x => x != null);
diff --git a/RhSolutions.AddIn/Services/AddInConfiguration.cs b/RhSolutions.AddIn/Services/AddInConfiguration.cs
index 6b4be5f..970cf52 100644
--- a/RhSolutions.AddIn/Services/AddInConfiguration.cs
+++ b/RhSolutions.AddIn/Services/AddInConfiguration.cs
@@ -1,39 +1,103 @@
-using System;
-using System.Configuration;
+using System.Configuration;
using System.IO;
-namespace RhSolutions.Services
+namespace RhSolutions.Services;
+
+public class AddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
{
- public class AddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
+ private Dictionary<string, string> _priceListParameters;
+
+ public AddInConfiguration()
+ {
+ _priceListParameters = new Dictionary<string, string>()
+ {
+ ["Amount"] = AmountHeader,
+ ["OldSku"] = OldSkuHeader,
+ ["Sku"] = SkuHeader,
+ ["Group"] = GroupHeader,
+ ["Name"] = NameHeader
+ };
+ }
+
+ [UserScopedSetting]
+ [DefaultSettingValue("Кол-во")]
+ public string AmountHeader
+ {
+ get
+ {
+ return (string)this[nameof(AmountHeader)];
+ }
+ }
+
+ [UserScopedSetting]
+ [DefaultSettingValue("Прежний материал")]
+ public string OldSkuHeader
+ {
+ get
+ {
+ return (string)this[nameof(OldSkuHeader)];
+ }
+ }
+
+
+ [UserScopedSetting]
+ [DefaultSettingValue("Актуальный материал")]
+ public string SkuHeader
+ {
+ get
+ {
+ return (string)this[nameof(SkuHeader)];
+ }
+ }
+
+ [UserScopedSetting]
+ [DefaultSettingValue("Программа")]
+ public string GroupHeader
{
- [UserScopedSetting]
- public string PriceListPath
+ get
{
- get
- {
- return (string)this[nameof(PriceListPath)];
- }
- set
- {
- this[nameof(PriceListPath)] = value;
- }
+ return (string)this[nameof(GroupHeader)];
}
+ }
- public event SettingChangingEventHandler OnSettingsChange
+ [UserScopedSetting]
+ [DefaultSettingValue("Наименование")]
+ public string NameHeader
+ {
+ get
{
- add
- {
- base.SettingChanging += value;
- }
- remove
- {
- base.SettingChanging -= value;
- }
+ return (string)this[nameof(NameHeader)];
}
+ }
- public string GetPriceListFileName() => Path.GetFileName(PriceListPath);
- public string GetPriceListPath() => PriceListPath;
- public void SetPriceListPath(string value) => PriceListPath = value;
- public void SaveSettings() => base.Save();
+ [UserScopedSetting]
+ public string PriceListPath
+ {
+ get
+ {
+ return (string)this[nameof(PriceListPath)];
+ }
+ set
+ {
+ this[nameof(PriceListPath)] = value;
+ }
}
+
+ public event SettingChangingEventHandler OnSettingsChange
+ {
+ add
+ {
+ base.SettingChanging += value;
+ }
+ remove
+ {
+ base.SettingChanging -= value;
+ }
+ }
+
+ public string GetPriceListFileName() => Path.GetFileName(PriceListPath);
+ public string GetPriceListPath() => PriceListPath;
+ public void SetPriceListPath(string value) => PriceListPath = value;
+ public void SaveSettings() => base.Save();
+ public Dictionary<string, string> GetPriceListParameters() => _priceListParameters;
}
diff --git a/RhSolutions.AddIn/Services/IAddInConfiguration.cs b/RhSolutions.AddIn/Services/IAddInConfiguration.cs
index c6bed6a..3c09007 100644
--- a/RhSolutions.AddIn/Services/IAddInConfiguration.cs
+++ b/RhSolutions.AddIn/Services/IAddInConfiguration.cs
@@ -1,13 +1,13 @@
using System.Configuration;
-namespace RhSolutions.Services
+namespace RhSolutions.Services;
+
+public interface IAddInConfiguration
{
- public interface IAddInConfiguration
- {
- public string GetPriceListPath();
- public string GetPriceListFileName();
- public event SettingChangingEventHandler OnSettingsChange;
- public void SetPriceListPath(string value);
- public void SaveSettings();
- }
+ public string GetPriceListPath();
+ public string GetPriceListFileName();
+ public Dictionary<string, string> GetPriceListParameters();
+ public event SettingChangingEventHandler OnSettingsChange;
+ public void SetPriceListPath(string value);
+ public void SaveSettings();
} \ No newline at end of file