Namespace refactoring

This commit is contained in:
Sergey Chebotar 2022-12-20 12:27:47 +03:00
parent 3d186c22e8
commit 73569a4364
25 changed files with 79 additions and 77 deletions

View File

@ -1,12 +1,13 @@
using ExcelDna.Integration;
using ExcelDna.IntelliSense;
using Microsoft.Office.Interop.Excel;
using RhSolutions.Services;
using System.Net.Http;
using System.Runtime.Caching;
namespace RhSolutions
{
class AddIn : IExcelAddIn
class RhSolutionsAddIn : IExcelAddIn
{
public static Application Excel;
public static HttpClient httpClient;

View File

@ -1,11 +1,11 @@
using Microsoft.Office.Interop.Excel;
using RhSolutions.Interface;
using RhSolutions.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using Dialog = RhSolutions.Interface.Dialog;
using Dialog = RhSolutions.Models.Dialog;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Controllers
{
internal class CombineTool : ToolBase
{

View File

@ -1,6 +1,6 @@
using RhSolutions.Interface;
using RhSolutions.Models;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Controllers
{
internal class ConvertTool : ToolBase
{

View File

@ -1,9 +1,9 @@
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using RhSolutions.Interface;
using RhSolutions.Models;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Controllers
{
internal class ExportTool : ToolBase
{

View File

@ -1,9 +1,9 @@
using RhSolutions.Interface;
using RhSolutions.Models;
using System;
using System.Collections.Generic;
using System.Linq;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Controllers
{
internal class MergeTool : ToolBase
{

View File

@ -1,13 +1,13 @@
using ExcelDna.Integration.CustomUI;
using Microsoft.Office.Interop.Excel;
using RhSolutions.PriceListTools;
using RhSolutions.Services;
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace RhSolutions.Interface
namespace RhSolutions.Controllers
{
[ComVisible(true)]
public class RibbonController : ExcelRibbon
@ -52,7 +52,7 @@ namespace RhSolutions.Interface
}
public void OnSetPricePressed(IRibbonControl control)
{
string path = Dialog.GetFilePath();
string path = Models.Dialog.GetFilePath();
if (!string.IsNullOrEmpty(path))
{
@ -93,31 +93,31 @@ namespace RhSolutions.Interface
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
AddIn.Excel.StatusBar = false;
RhSolutionsAddIn.Excel.StatusBar = false;
return;
}
}
public bool GetConvertEnabled(IRibbonControl control)
{
if (AddIn.Excel.ActiveWorkbook == null)
if (RhSolutionsAddIn.Excel.ActiveWorkbook == null)
return false;
else
{
Worksheet worksheet = AddIn.Excel.ActiveWorkbook.ActiveSheet;
Worksheet worksheet = RhSolutionsAddIn.Excel.ActiveWorkbook.ActiveSheet;
return worksheet.IsRehauSource();
}
}
public bool GetExportEnabled(IRibbonControl control)
{
if (AddIn.Excel.ActiveWorkbook == null)
if (RhSolutionsAddIn.Excel.ActiveWorkbook == null)
return false;
else
{
Range selection = AddIn.Excel.Selection;
Range selection = RhSolutionsAddIn.Excel.Selection;
return selection.Columns.Count == 2;
}
}

View File

@ -1,15 +1,15 @@
using Microsoft.Office.Interop.Excel;
using RhSolutions.Interface;
using RhSolutions.Models;
using RhSolutions.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using ProgressBar = RhSolutions.Interface.ProgressBar;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Controllers
{
internal abstract class ToolBase
{
protected Application ExcelApp = AddIn.Excel;
protected Application ExcelApp = RhSolutionsAddIn.Excel;
protected TargetPriceList TargetFile { get; set; }
protected ResultBar ResultBar { get; set; }
protected ProgressBar ProgressBar { get; set; }

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Windows.Forms;
namespace RhSolutions.Interface
namespace RhSolutions.Models
{
static class Dialog
{

View File

@ -1,6 +1,6 @@
using Microsoft.Office.Interop.Excel;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Models
{
internal abstract class PriceListBase
{

View File

@ -1,4 +1,4 @@
namespace RhSolutions.PriceListTools
namespace RhSolutions.Models
{
internal static class PriceListHeaders
{

View File

@ -1,6 +1,6 @@
using System.Linq;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Models
{
public class Product
{

View File

@ -1,4 +1,4 @@
namespace RhSolutions.Interface
namespace RhSolutions.Models
{
internal class ProgressBar : StatusbarBase
{
@ -15,7 +15,7 @@
public override void Update()
{
double percent = (++CurrentProgress / TaskWeight) * 100;
double percent = ++CurrentProgress / TaskWeight * 100;
Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %";
}
}

View File

@ -1,7 +1,7 @@
using System;
using System.Text;
namespace RhSolutions.Interface
namespace RhSolutions.Models
{
internal class ResultBar : StatusbarBase
{

View File

@ -1,6 +1,6 @@
using System.Text.RegularExpressions;
namespace RhSolutions
namespace RhSolutions.Models
{
internal class Sku
{

View File

@ -1,6 +1,6 @@
using System.Text.RegularExpressions;
namespace RhSolutions
namespace RhSolutions.Models
{
static class SkuExtensions
{

View File

@ -3,9 +3,8 @@ using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using System.Linq;
using RhSolutions.Interface;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Models
{
internal class SourcePriceList : PriceListBase
{

View File

@ -4,17 +4,17 @@ using System;
using System.Threading;
using System.Threading.Tasks;
namespace RhSolutions.Interface
namespace RhSolutions.Models
{
internal abstract class StatusbarBase : IDisposable
{
protected Application Excel = AddIn.Excel;
protected Application Excel = RhSolutionsAddIn.Excel;
public abstract void Update();
private static void ResetStatusBar()
{
AddIn.Excel.StatusBar = false;
RhSolutionsAddIn.Excel.StatusBar = false;
}
public void Dispose()

View File

@ -2,7 +2,7 @@
using System;
using System.Linq;
namespace RhSolutions.PriceListTools
namespace RhSolutions.Models
{
internal class TargetPriceList : PriceListBase
{
@ -31,7 +31,7 @@ namespace RhSolutions.PriceListTools
if (cells.Any(x => x == null))
{
throw new ArgumentException($"Шаблон { Name } не является прайс-листом");
throw new ArgumentException($"Шаблон {Name} не является прайс-листом");
}
}
}

View File

@ -1,8 +1,8 @@
using Microsoft.Office.Interop.Excel;
using RhSolutions.PriceListTools;
using RhSolutions.Models;
using System.Linq;
namespace RhSolutions
namespace RhSolutions.Services
{
public static class WorksheetExtensions
{

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<DnaLibrary Name="RhSolutions Add-In" RuntimeVersion="v4.0" xmlns="http://schemas.excel-dna.net/addin/2020/07/dnalibrary">
<ExternalLibrary Path="RhExcelAddin.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="false" />
<ExternalLibrary Path="RhSolutions.AddIn.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="false" />
<!--
The RuntimeVersion attribute above allows only the following setting:

View File

@ -8,8 +8,8 @@
<ProjectGuid>{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RhExcelAddin</RootNamespace>
<AssemblyName>RhExcelAddin</AssemblyName>
<RootNamespace>RhSolutions.AddIn</RootNamespace>
<AssemblyName>RhSolutions.AddIn</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
@ -77,29 +77,29 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddIn\EventsUtil.cs" />
<Compile Include="AddIn\RhDatabaseClient.cs" />
<Compile Include="AddIn\Sku.cs" />
<Compile Include="Interface\StatusbarBase.cs" />
<Compile Include="Interface\Dialog.cs" />
<Compile Include="AddIn\RegistryUtil.cs" />
<Compile Include="AddIn\SkuExtensions.cs" />
<Compile Include="Interface\ProgressBar.cs" />
<Compile Include="Interface\ResultBar.cs" />
<Compile Include="PriceListTools\CombineTool.cs" />
<Compile Include="PriceListTools\ConvertTool.cs" />
<Compile Include="PriceListTools\Product.cs" />
<Compile Include="PriceListTools\ToolBase.cs" />
<Compile Include="PriceListTools\MergeTool.cs" />
<Compile Include="PriceListTools\PriceListBase.cs" />
<Compile Include="PriceListTools\PriceListHeaders.cs" />
<Compile Include="PriceListTools\SourcePriceList.cs" />
<Compile Include="PriceListTools\TargetPriceList.cs" />
<Compile Include="Interface\RibbonController.cs" />
<Compile Include="PriceListTools\ExportTool.cs" />
<Compile Include="AddIn\AddIn.cs" />
<Compile Include="AddIn\Functions.cs" />
<Compile Include="AddIn\WorksheetExtensions.cs" />
<Compile Include="Services\EventsUtil.cs" />
<Compile Include="Services\RhDatabaseClient.cs" />
<Compile Include="Models\Sku.cs" />
<Compile Include="Models\StatusbarBase.cs" />
<Compile Include="Models\Dialog.cs" />
<Compile Include="Services\RegistryUtil.cs" />
<Compile Include="Models\SkuExtensions.cs" />
<Compile Include="Models\ProgressBar.cs" />
<Compile Include="Models\ResultBar.cs" />
<Compile Include="Controllers\CombineTool.cs" />
<Compile Include="Controllers\ConvertTool.cs" />
<Compile Include="Models\Product.cs" />
<Compile Include="Controllers\ToolBase.cs" />
<Compile Include="Controllers\MergeTool.cs" />
<Compile Include="Models\PriceListBase.cs" />
<Compile Include="Models\PriceListHeaders.cs" />
<Compile Include="Models\SourcePriceList.cs" />
<Compile Include="Models\TargetPriceList.cs" />
<Compile Include="Controllers\RibbonController.cs" />
<Compile Include="Controllers\ExportTool.cs" />
<Compile Include="AddIn.cs" />
<Compile Include="Services\Functions.cs" />
<Compile Include="Models\WorksheetExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -1,10 +1,11 @@
using Microsoft.Office.Interop.Excel;
using RhSolutions.Controllers;
namespace RhSolutions
namespace RhSolutions.Services
{
internal static class EventsUtil
{
private static readonly Application Excel = AddIn.Excel;
private static readonly Application Excel = RhSolutionsAddIn.Excel;
public static void Initialize()
{
@ -22,12 +23,12 @@ namespace RhSolutions
private static void RefreshConvertButton(object sh)
{
Interface.RibbonController.RefreshControl("convert");
RibbonController.RefreshControl("convert");
}
private static void RefreshExportButton(object sh, Range target)
{
Interface.RibbonController.RefreshControl("export");
RibbonController.RefreshControl("export");
}
}
}

View File

@ -1,7 +1,7 @@
using ExcelDna.Integration;
using System;
namespace RhSolutions
namespace RhSolutions.Services
{
public class Functions
{

View File

@ -1,10 +1,11 @@
using Microsoft.Win32;
using RhSolutions.Interface;
using RhSolutions.Controllers;
using RhSolutions.Models;
using System;
using System.IO;
using System.Windows.Forms;
namespace RhSolutions
namespace RhSolutions.Services
{
static class RegistryUtil
{
@ -13,13 +14,13 @@ namespace RhSolutions
public static void Initialize()
{
RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
priceListPath = RootKey.GetValue("PriceListPath") as string;
}
public static void Uninitialize()
{
RootKey.Close();
RootKey.Close();
}
public static string PriceListPath

View File

@ -5,11 +5,11 @@ using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace RhSolutions
namespace RhSolutions.Services
{
public static class RhDatabaseClient
{
private static HttpClient httpClient = AddIn.httpClient;
private static HttpClient httpClient = RhSolutionsAddIn.httpClient;
public static async Task<object> GetProduct(string line)
{