diff --git a/FIAS.Core/Extensions/IOExtensions.cs b/FIAS.Core/Extensions/IOExtensions.cs index d7ee51b..7edebf3 100644 --- a/FIAS.Core/Extensions/IOExtensions.cs +++ b/FIAS.Core/Extensions/IOExtensions.cs @@ -8,21 +8,20 @@ namespace FIAS.Core.Extensions { public static class IOExtensions { + public static Task CopyToAsync(this Stream source, Stream destination, int bufferSize) => CopyToAsync(source, destination, bufferSize, default, default); + + public static Task CopyToAsync(this Stream source, Stream destination, int bufferSize, IProgress progress) => CopyToAsync(source, destination, bufferSize, progress, default); + /// /// https://stackoverflow.com/a/46497896 /// - public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, IProgress progress = default, CancellationToken cancellationToken = default) + public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, IProgress progress, CancellationToken cancellationToken) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (!source.CanRead) - throw new ArgumentException("Has to be readable", nameof(source)); - if (destination == null) - throw new ArgumentNullException(nameof(destination)); - if (!destination.CanWrite) - throw new ArgumentException("Has to be writable", nameof(destination)); - if (bufferSize < 0) - throw new ArgumentOutOfRangeException(nameof(bufferSize)); + if (source is null) { throw new ArgumentNullException(nameof(source)); } + if (!source.CanRead) { throw new ArgumentException("Has to be readable", nameof(source)); } + if (destination is null) { throw new ArgumentNullException(nameof(destination)); } + if (!destination.CanWrite) { throw new ArgumentException("Has to be writable", nameof(destination)); } + if (bufferSize < 0) { throw new ArgumentOutOfRangeException(nameof(bufferSize)); } var buffer = new byte[bufferSize]; long totalBytesRead = 0; @@ -38,7 +37,12 @@ public static async Task CopyToAsync(this Stream source, Stream destination, int /// /// Асинхронно скачать файл /// - public static async Task DownloadAsync(this HttpClient client, string requestUri, Stream destination, CancellationToken cancellationToken = default) + public static Task DownloadAsync(this HttpClient client, string requestUri, Stream destination) => DownloadAsync(client, requestUri, destination, default(CancellationToken)); + + /// + /// Асинхронно скачать файл + /// + public static async Task DownloadAsync(this HttpClient client, string requestUri, Stream destination, CancellationToken cancellationToken) { // Считать только заголовок using (var response = await client.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken)) @@ -53,7 +57,12 @@ public static async Task DownloadAsync(this HttpClient client, string requestUri /// /// Асинхронно скачать файл с отчётом о прогрессе /// - public static async Task DownloadAsync(this HttpClient client, string requestUri, Stream destination, IProgress progress, CancellationToken cancellationToken = default) + public static Task DownloadAsync(this HttpClient client, string requestUri, Stream destination, IProgress progress) => DownloadAsync(client, requestUri, destination, progress, default); + + /// + /// Асинхронно скачать файл с отчётом о прогрессе + /// + public static async Task DownloadAsync(this HttpClient client, string requestUri, Stream destination, IProgress progress, CancellationToken cancellationToken) { // Get the http headers first to examine the content length using (var response = await client.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken)) diff --git a/FIASUpdate/ArchiveDownloader.cs b/FIASUpdate/ArchiveDownloader.cs index cc5ef42..bf3fbe9 100644 --- a/FIASUpdate/ArchiveDownloader.cs +++ b/FIASUpdate/ArchiveDownloader.cs @@ -24,7 +24,7 @@ public ArchiveDownloader() : this(4) { } /// Количество "потоков" для скачивания public ArchiveDownloader(int threads) { - Client = new HttpClient(new HttpClientHandler() { MaxConnectionsPerServer = threads }); + Client = new HttpClient(new HttpClientHandler { MaxConnectionsPerServer = threads }); Semaphore = new SemaphoreSlim(threads); } diff --git a/FIASUpdate/Controls/ToolStripTaskProgress.cs b/FIASUpdate/Controls/ToolStripTaskProgress.cs index 5342c42..740dda8 100644 --- a/FIASUpdate/Controls/ToolStripTaskProgress.cs +++ b/FIASUpdate/Controls/ToolStripTaskProgress.cs @@ -10,7 +10,6 @@ public class ToolStripTaskProgress : ToolStripStatusLabel public ToolStripTaskProgress() { Progress = new Progress(Handler); - UpdateText(); } public void Clear() diff --git a/FIASUpdate/Database/DBCreate.cs b/FIASUpdate/Database/DBCreate.cs index 2912744..d632e75 100644 --- a/FIASUpdate/Database/DBCreate.cs +++ b/FIASUpdate/Database/DBCreate.cs @@ -20,7 +20,7 @@ internal class DBCreate : DBClient public DBCreate() : this(default) { } - public DBCreate(IProgress TaskProgress) : base() + public DBCreate(IProgress TaskProgress) { SP = TaskProgress; } diff --git a/FIASUpdate/Database/DBImport.cs b/FIASUpdate/Database/DBImport.cs index 768a158..81ec6fa 100644 --- a/FIASUpdate/Database/DBImport.cs +++ b/FIASUpdate/Database/DBImport.cs @@ -18,7 +18,7 @@ internal abstract class DBImport : DBClient protected IProgress SP; protected CancellationToken Token; - protected DBImport() : base() + protected DBImport() { Events = new SyncEvent(this); } diff --git a/FIASUpdate/Forms/FormAddressSearch.Designer.cs b/FIASUpdate/Forms/FormAddressSearch.Designer.cs index 48f2839..261331e 100644 --- a/FIASUpdate/Forms/FormAddressSearch.Designer.cs +++ b/FIASUpdate/Forms/FormAddressSearch.Designer.cs @@ -452,7 +452,6 @@ private void InitializeComponent() internal System.Windows.Forms.TextBox TB_Address; internal System.Windows.Forms.TableLayoutPanel TableLayoutPanel3; internal System.Windows.Forms.Button B_Search; - internal System.Windows.Forms.Button B_Info; internal System.Windows.Forms.TableLayoutPanel TableLayoutPanel2; internal System.Windows.Forms.Label Label3; internal System.Windows.Forms.Button B_CopyGUID; diff --git a/FIASUpdate/Forms/FormAddressSearch.cs b/FIASUpdate/Forms/FormAddressSearch.cs index e7e31af..739c70b 100644 --- a/FIASUpdate/Forms/FormAddressSearch.cs +++ b/FIASUpdate/Forms/FormAddressSearch.cs @@ -67,6 +67,7 @@ private void UIState(bool value) TB_Search.ReadOnly = !value; B_Search.Enabled = value; CB_Level.Enabled = value; + NUD_Limit.Enabled = value; RB_ADM.Enabled = value; RB_MUN.Enabled = value; } @@ -170,7 +171,7 @@ private async void MI_Parameters_Click(object sender, EventArgs e) try { var parameters = await Store.GetObjectParameters(TB_GUID.Text); - var F = new FormDictionaryView() + var F = new FormDictionaryView { Text = "Параметры объекта", KeyHeader = "Параметр", diff --git a/FIASUpdate/Forms/FormDictionaryView.Designer.cs b/FIASUpdate/Forms/FormDictionaryView.Designer.cs index c041f35..7683f8a 100644 --- a/FIASUpdate/Forms/FormDictionaryView.Designer.cs +++ b/FIASUpdate/Forms/FormDictionaryView.Designer.cs @@ -120,8 +120,6 @@ private void InitializeComponent() private System.Windows.Forms.ListView LV; private System.Windows.Forms.ColumnHeader CH_Key; private System.Windows.Forms.ColumnHeader CH_Value; - private System.Windows.Forms.ContextMenuStrip CMS_LV; - private System.Windows.Forms.ToolStripMenuItem MI_Copy; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.Button B_Copy; } diff --git a/FIAS_GAR/adm/Functions/UF_RegistryChild.sql b/FIAS_GAR/adm/Functions/UF_RegistryChild.sql index f2a71ae..ea9b6d3 100644 --- a/FIAS_GAR/adm/Functions/UF_RegistryChild.sql +++ b/FIAS_GAR/adm/Functions/UF_RegistryChild.sql @@ -29,7 +29,7 @@ BEGIN , [R].[Name] , CAST([R].[AddressFull] AS VARCHAR(1000)) FROM - [FIAS_GAR].[adm].[A_IndexRegistry] [R] + [adm].[A_IndexRegistry] [R] WHERE [R].[ParentGUID] = @ObjectGUID UNION ALL SELECT @@ -40,7 +40,7 @@ BEGIN , [R].[Name] , [R].[AddressFull] FROM - [FIAS_GAR].[adm].[A_IndexRegistry] [R] + [adm].[A_IndexRegistry] [R] JOIN [Hierarchy] [H] ON [H].[ObjectGUID] = [R].[ParentGUID] WHERE [H].[ObjectGUID] IS NOT NULL) diff --git a/FIAS_GAR/mun/Functions/UF_RegistryChild.sql b/FIAS_GAR/mun/Functions/UF_RegistryChild.sql index 90b35b0..44aa12d 100644 --- a/FIAS_GAR/mun/Functions/UF_RegistryChild.sql +++ b/FIAS_GAR/mun/Functions/UF_RegistryChild.sql @@ -29,7 +29,7 @@ BEGIN , [R].[Name] , CAST([R].[AddressFull] AS VARCHAR(1000)) FROM - [FIAS_GAR].[mun].[A_IndexRegistry] [R] + [mun].[A_IndexRegistry] [R] WHERE [R].[ParentGUID] = @ObjectGUID UNION ALL SELECT @@ -40,7 +40,7 @@ BEGIN , [R].[Name] , [R].[AddressFull] FROM - [FIAS_GAR].[mun].[A_IndexRegistry] [R] + [mun].[A_IndexRegistry] [R] JOIN [Hierarchy] [H] ON [H].[ObjectGUID] = [R].[ParentGUID] WHERE [H].[ObjectGUID] IS NOT NULL)