aboutsummaryrefslogtreecommitdiff
path: root/src/Services
diff options
context:
space:
mode:
Diffstat (limited to 'src/Services')
-rw-r--r--src/Services/EventsUtil.cs35
-rw-r--r--src/Services/RegistryUtil.cs74
-rw-r--r--src/Services/RhDatabaseClient.cs52
3 files changed, 0 insertions, 161 deletions
diff --git a/src/Services/EventsUtil.cs b/src/Services/EventsUtil.cs
deleted file mode 100644
index bb37125..0000000
--- a/src/Services/EventsUtil.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Microsoft.Office.Interop.Excel;
-using RhSolutions.AddIn;
-using RhSolutions.Controllers;
-
-namespace RhSolutions.Services
-{
- internal static class EventsUtil
- {
- private static readonly Application Excel = RhSolutionsAddIn.Excel;
-
- public static void Initialize()
- {
- Excel.SheetSelectionChange += RefreshExportButton;
- Excel.SheetActivate += RefreshConvertButton;
- Excel.WorkbookActivate += RefreshConvertButton;
- }
-
- public static void Uninitialize()
- {
- Excel.SheetSelectionChange -= RefreshExportButton;
- Excel.SheetActivate -= RefreshConvertButton;
- Excel.WorkbookActivate -= RefreshConvertButton;
- }
-
- private static void RefreshConvertButton(object sh)
- {
- RibbonController.RefreshControl("convert");
- }
-
- private static void RefreshExportButton(object sh, Range target)
- {
- RibbonController.RefreshControl("export");
- }
- }
-}
diff --git a/src/Services/RegistryUtil.cs b/src/Services/RegistryUtil.cs
deleted file mode 100644
index 8b165ea..0000000
--- a/src/Services/RegistryUtil.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using Microsoft.Win32;
-using RhSolutions.Controllers;
-using RhSolutions.Models;
-using System;
-using System.IO;
-using System.Windows.Forms;
-
-namespace RhSolutions.Services
-{
- static class RegistryUtil
- {
- private static string priceListPath;
- private static RegistryKey RootKey { get; set; }
-
- public static void Initialize()
- {
- RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
- priceListPath = RootKey.GetValue("PriceListPath") as string;
- }
-
- public static void Uninitialize()
- {
- RootKey.Close();
- }
-
- public static string PriceListPath
- {
- get
- {
- if (string.IsNullOrEmpty(priceListPath) || !File.Exists(priceListPath))
- {
- DialogResult result = MessageBox.Show("Прайс-лист отсутствует или неверный файл шаблона прайс-листа. " +
- "Укажите файл шаблона прайс-листа.",
- "Нет файла шаблона",
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
-
- if (result == DialogResult.OK)
- {
- string fileName = Dialog.GetFilePath();
-
- if (string.IsNullOrEmpty(fileName))
- {
- throw new Exception("Нет файла шаблона");
- }
-
- priceListPath = fileName;
- RootKey.SetValue("PriceListPath", fileName);
- return priceListPath;
- }
-
- else
- throw new Exception("Нет файла шаблона");
- }
-
- else
- {
- return priceListPath;
- }
- }
-
- set
- {
- priceListPath = value;
- RootKey.SetValue("PriceListPath", value);
- RibbonController.RefreshControl("setPriceList");
- }
- }
-
- public static string GetPriceListName()
- {
- return Path.GetFileName(priceListPath);
- }
- }
-}
diff --git a/src/Services/RhDatabaseClient.cs b/src/Services/RhDatabaseClient.cs
deleted file mode 100644
index 70530ae..0000000
--- a/src/Services/RhDatabaseClient.cs
+++ /dev/null
@@ -1,52 +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
- {
- public static async Task<object> GetProduct(string line)
- {
- string request;
-
- if (Sku.TryParse(line, out var skus))
- {
- request = @"https://rh.cebotari.ru/api/products/" + skus.FirstOrDefault().ToString();
- }
-
- else
- {
- request = @"https://rh.cebotari.ru/api/search?query=" + line;
- }
-
- var response = await RhSolutionsAddIn.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
- {
- return $"{product.ProductSku} {product.Name}";
- }
- }
- catch
- {
- return $"Ошибка сервера {response.StatusCode}";
- }
- }
- }
-} \ No newline at end of file