From 4f448f203471a19a1444555a895f503515ad2fda Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 22 Mar 2023 08:36:13 +0300 Subject: Add basic test --- src/AddIn/Functions.cs | 56 ------------------------------------------- src/AddIn/RhSolutionsAddIn.cs | 35 --------------------------- 2 files changed, 91 deletions(-) delete mode 100644 src/AddIn/Functions.cs delete mode 100644 src/AddIn/RhSolutionsAddIn.cs (limited to 'src/AddIn') diff --git a/src/AddIn/Functions.cs b/src/AddIn/Functions.cs deleted file mode 100644 index 6a7fc54..0000000 --- a/src/AddIn/Functions.cs +++ /dev/null @@ -1,56 +0,0 @@ -using ExcelDna.Integration; -using RhSolutions.Models; -using RhSolutions.Services; -using System.Linq; - -namespace RhSolutions.AddIn -{ - public class Functions - { - [ExcelFunction(Description = "Распознать артикул и попробовать найти его в прайс-листе")] - public static object RHSOLUTIONS([ExcelArgument(Name = "\"Строка с названием материала\"")] string line) - { - object result; - - result = ExcelAsyncUtil.Run("Database request", line, delegate - { - return RhDatabaseClient.GetProduct(line).GetAwaiter().GetResult(); - }); - - string parsedSku = Sku.TryParse(line, out var skus) - ? skus.First().ToString() : string.Empty; - - if (result == null) - { - if (string.IsNullOrEmpty(parsedSku)) - { - return ExcelError.ExcelErrorNA; - } - else - { - return skus.First().ToString(); - } - } - - if (result.Equals(ExcelError.ExcelErrorNA)) - { - if (string.IsNullOrEmpty(parsedSku)) - { - return "Загрузка..."; - } - else - { - return skus.First().ToString(); - } - } - - return result; - } - - [ExcelFunction] - public static void _ResetStatusBar() - { - RhSolutionsAddIn.Excel.StatusBar = false; - } - } -} \ No newline at end of file diff --git a/src/AddIn/RhSolutionsAddIn.cs b/src/AddIn/RhSolutionsAddIn.cs deleted file mode 100644 index a4c6019..0000000 --- a/src/AddIn/RhSolutionsAddIn.cs +++ /dev/null @@ -1,35 +0,0 @@ -using ExcelDna.Integration; -using ExcelDna.IntelliSense; -using Microsoft.Office.Interop.Excel; -using RhSolutions.Services; -using System.Net; -using System.Net.Http; - -namespace RhSolutions.AddIn -{ - class RhSolutionsAddIn : IExcelAddIn - { - public static Application Excel { get; private set; } - public static HttpClient HttpClient { get; private set; } - - public void AutoOpen() - { - Excel = (Application)ExcelDnaUtil.Application; - HttpClient = new HttpClient(); - IntelliSenseServer.Install(); - RegistryUtil.Initialize(); - EventsUtil.Initialize(); - - ServicePointManager.SecurityProtocol = - SecurityProtocolType.Tls12; - } - - public void AutoClose() - { - IntelliSenseServer.Uninstall(); - RegistryUtil.Uninitialize(); - EventsUtil.Uninitialize(); - HttpClient.Dispose(); - } - } -} -- cgit v1.2.3