Merge branch 'develop' into feature/mobile-main-button

This commit is contained in:
Alexey Safronov 2021-12-07 16:24:43 +03:00 committed by GitHub
commit 4fe4080f52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
241 changed files with 1966 additions and 2323 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Files.Tests", "products\ASC.Files\Tests\ASC.Files.Tests.csproj", "{EFB99A37-EF25-4A0F-8D7A-786402B1554C}"
EndProject
@ -73,7 +73,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Webhooks.Tests", "commo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Webhooks.Service", "common\services\ASC.Webhooks.Service\ASC.Webhooks.Service.csproj", "{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASC.Web.Api.Tests", "common\Tests\ASC.Web.Api.Tests\ASC.Web.Api.Tests.csproj", "{14823E93-C749-4069-9E0A-95E63DE0B254}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Web.Api.Tests", "common\Tests\ASC.Web.Api.Tests\ASC.Web.Api.Tests.csproj", "{14823E93-C749-4069-9E0A-95E63DE0B254}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Backup.Core", "common\ASC.Data.Backup.Core\ASC.Data.Backup.Core.csproj", "{5E948877-52BD-42B9-95A9-0FF37931D0A5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Encryption", "common\ASC.Data.Encryption\ASC.Data.Encryption.csproj", "{9E572FE2-8C3C-46B2-A314-532F7198B3EB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.AuditTrail", "common\services\ASC.AuditTrail\ASC.AuditTrail.csproj", "{B53587B7-58F6-48A9-B122-69BEA3E2572A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -209,10 +215,6 @@ Global
{8FAD3D1B-3ADC-470C-9933-CAE1B95A8599}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FAD3D1B-3ADC-470C-9933-CAE1B95A8599}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FAD3D1B-3ADC-470C-9933-CAE1B95A8599}.Release|Any CPU.Build.0 = Release|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.Build.0 = Release|Any CPU
{A0475D4F-29B7-490C-85C2-8AFD60118B35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0475D4F-29B7-490C-85C2-8AFD60118B35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0475D4F-29B7-490C-85C2-8AFD60118B35}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -224,7 +226,23 @@ Global
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.Build.0 = Release|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Release|Any CPU.Build.0 = Release|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Release|Any CPU.Build.0 = Release|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection

View File

@ -6,6 +6,7 @@
ELK_VERSION=7.13.1
SERVICE_PORT=5050
CONTAINER_PREFIX=${PRODUCT}-
DOCUMENT_SERVER_IMAGE_NAME=onlyoffice/4testing-documentserver-ee:latest
DOCKER_TAG=latest
DOCKERFILE=Dockerfile.app

View File

@ -1,7 +1,7 @@
version: '3.6'
services:
onlyoffice-document-server:
image: "${REPO}/${STATUS}documentserver:latest"
image: "${DOCUMENT_SERVER_IMAGE_NAME}"
container_name: ${DOCUMENT_SERVER_HOST}
# Strings below enable the JSON Web Token validation.
environment:

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
@ -17,7 +17,7 @@
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="5.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />
</ItemGroup>

View File

@ -29,15 +29,15 @@ using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting;
using NLog;
using NLog.Extensions.Logging;
namespace ASC.Api.Core
{
public abstract class BaseStartup
{
{
public abstract class BaseStartup
{
public IConfiguration Configuration { get; }
public IHostEnvironment HostEnvironment { get; }
public virtual JsonConverter[] Converters { get; }
@ -52,14 +52,14 @@ namespace ASC.Api.Core
{
Configuration = configuration;
HostEnvironment = hostEnvironment;
DIHelper = new DIHelper();
DIHelper = new DIHelper();
if (bool.TryParse(Configuration["core:products"], out var loadProducts))
{
LoadProducts = loadProducts;
}
}
}
public virtual void ConfigureServices(IServiceCollection services)
public virtual void ConfigureServices(IServiceCollection services)
{
services.AddCustomHealthCheck(Configuration);
services.AddHttpContextAccessor();
@ -69,20 +69,20 @@ namespace ASC.Api.Core
services.AddSession();
DIHelper.Configure(services);
Action<JsonOptions> jsonOptions = options =>
{
options.JsonSerializerOptions.WriteIndented = false;
options.JsonSerializerOptions.IgnoreNullValues = true;
options.JsonSerializerOptions.Converters.Add(new ApiDateTimeConverter());
{
options.JsonSerializerOptions.WriteIndented = false;
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.JsonSerializerOptions.Converters.Add(new ApiDateTimeConverter());
if (Converters != null)
{
foreach (var c in Converters)
{
options.JsonSerializerOptions.Converters.Add(c);
}
}
if (Converters != null)
{
foreach (var c in Converters)
{
options.JsonSerializerOptions.Converters.Add(c);
}
}
};
services.AddControllers()
@ -110,19 +110,19 @@ namespace ASC.Api.Core
}
var builder = services.AddMvcCore(config =>
{
{
config.Conventions.Add(new ControllerNameAttributeConvention());
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
config.Filters.Add(new AuthorizeFilter(policy));
config.Filters.Add(new TypeFilterAttribute(typeof(TenantStatusFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(PaymentFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(IpSecurityFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(ProductSecurityFilter)));
config.Filters.Add(new AuthorizeFilter(policy));
config.Filters.Add(new TypeFilterAttribute(typeof(TenantStatusFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(PaymentFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(IpSecurityFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(ProductSecurityFilter)));
config.Filters.Add(new CustomResponseFilterAttribute());
config.Filters.Add(new CustomExceptionFilterAttribute());
config.Filters.Add(new TypeFilterAttribute(typeof(FormatFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(FormatFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(WebhooksGlobalFilterAttribute)));
config.OutputFormatters.RemoveType<XmlSerializerOutputFormatter>();
@ -149,7 +149,7 @@ namespace ASC.Api.Core
});
app.UseRouting();
if (AddAndUseSession)
app.UseSession();
@ -182,7 +182,7 @@ namespace ASC.Api.Core
{
builder.Register(Configuration, LoadProducts, LoadConsumers);
}
}
}
public static class LogNLogConfigureExtenstion
{

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<FileUpgradeFlags />
<UpgradeBackupLocation />
<AssemblyTitle>ASC.Common</AssemblyTitle>
@ -39,13 +39,12 @@
</PackageReference>
<PackageReference Include="JWT" Version="6.1.4" />
<PackageReference Include="log4net" Version="2.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<!-- <PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -56,7 +55,6 @@
</PackageReference> -->
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NVelocity" Version="1.2.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="protos\AscCacheItem.proto" />

View File

@ -50,12 +50,14 @@ namespace ASC.Security.Cryptography
public byte[] Encrypt(byte[] data)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = EKey();
hasher.IV = new byte[hasher.BlockSize >> 3];
using var ms = new MemoryStream();
using var ss = new CryptoStream(ms, hasher.CreateEncryptor(), CryptoStreamMode.Write);
ss.Write(data, 0, data.Length);
using var plainTextStream = new MemoryStream(data);
plainTextStream.CopyTo(ss);
ss.FlushFinalBlock();
hasher.Clear();
return ms.ToArray();
@ -63,23 +65,24 @@ namespace ASC.Security.Cryptography
public string Decrypt(string data)
{
return Encoding.UTF8.GetString(Decrypt(Convert.FromBase64String(data)));
return Decrypt(Convert.FromBase64String(data));
}
public byte[] Decrypt(byte[] data)
public string Decrypt(byte[] data)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = EKey();
hasher.IV = new byte[hasher.BlockSize >> 3];
using var ms = new MemoryStream(data);
using var ss = new CryptoStream(ms, hasher.CreateDecryptor(), CryptoStreamMode.Read);
var buffer = new byte[data.Length];
var size = ss.Read(buffer, 0, buffer.Length);
hasher.Clear();
var newBuffer = new byte[size];
Array.Copy(buffer, newBuffer, size);
return newBuffer;
using (MemoryStream msDecrypt = new MemoryStream(data))
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, hasher.CreateDecryptor(), CryptoStreamMode.Read))
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
// Read the decrypted bytes from the decrypting stream
// and place them in a string.
return srDecrypt.ReadToEnd();
}
}
private byte[] EKey()

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<ProjectGuid>{A51D0454-4AFA-46DE-89D4-B03D37E1816C}</ProjectGuid>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<FileUpgradeFlags />
<UpgradeBackupLocation />
<AssemblyTitle>ASC.Core.Common</AssemblyTitle>
@ -51,14 +51,13 @@
<ItemGroup>
<PackageReference Include="AWSSDK.Core" Version="3.5.1.25" />
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.5.0.27" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="Grpc.Tools" Version="2.32.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MailKit" Version="2.5.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />
<PackageReference Include="Telegram.Bot" Version="15.7.1" />
</ItemGroup>
<ItemGroup>

View File

@ -28,7 +28,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.ServiceModel;
@ -218,16 +218,17 @@ namespace ASC.Core.Billing
{
var url = _billingDomain + method;
var request = WebRequest.Create(url);
request.Method = "POST";
request.Timeout = 60000;
request.ContentType = "application/json";
var request = new HttpRequestMessage();
request.RequestUri = new Uri(url);
request.Method = HttpMethod.Post;
if (!string.IsNullOrEmpty(_billingKey))
{
request.Headers.Add("Authorization", CreateAuthToken(_billingKey, _billingSecret));
}
using var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMilliseconds(60000);
var data = new Dictionary<string, List<string>>();
if (!string.IsNullOrEmpty(portalId))
{
@ -244,35 +245,22 @@ namespace ASC.Core.Billing
data[parameter.Item1].Add(parameter.Item2);
}
}
var body = JsonSerializer.Serialize(data);
var bytes = Encoding.UTF8.GetBytes(body ?? "");
request.ContentLength = bytes.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(bytes, 0, bytes.Length);
}
var body = JsonSerializer.Serialize(data);
request.Content = new StringContent(body, Encoding.UTF8, "application/json");
string result;
try
using (var response = httpClient.Send(request))
using (var stream = response.Content.ReadAsStream())
{
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
if (stream == null)
{
if (stream == null)
{
throw new BillingNotConfiguredException("Billing response is null");
}
using (var readStream = new StreamReader(stream))
{
result = readStream.ReadToEnd();
}
throw new BillingNotConfiguredException("Billing response is null");
}
using (var readStream = new StreamReader(stream))
{
result = readStream.ReadToEnd();
}
}
catch (WebException)
{
request.Abort();
throw;
}
if (string.IsNullOrEmpty(result))

View File

@ -155,7 +155,7 @@ namespace ASC.Core.Common.Billing
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
const string applicationJson = "application/json";
var httpClient = new HttpClient { BaseAddress = BaseAddress, Timeout = TimeSpan.FromMinutes(3) };
using var httpClient = new HttpClient { BaseAddress = BaseAddress, Timeout = TimeSpan.FromMinutes(3) };
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", applicationJson);
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", applicationJson);
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Avangate-Authentication", CreateAuthHeader());

View File

@ -28,6 +28,7 @@ using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using ASC.Common.Module;
@ -77,17 +78,22 @@ namespace ASC.Core.Configuration
private static string GetAmiPublicDnsName()
{
try
{
var request = WebRequest.Create("http://169.254.169.254/latest/meta-data/public-hostname");
request.Timeout = 5000;
using var responce = request.GetResponse();
using var stream = responce.GetResponseStream();
{
var request = new HttpRequestMessage();
request.RequestUri = new Uri("http://169.254.169.254/latest/meta-data/public-hostname");
request.Method = HttpMethod.Get;
using var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMilliseconds(5000);
using var responce = httpClient.Send(request);
using var stream = responce.Content.ReadAsStream();
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
catch (WebException ex)
catch (HttpRequestException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
if (ex.StatusCode == HttpStatusCode.NotFound || ex.StatusCode == HttpStatusCode.Conflict)
{
throw;
}

View File

@ -27,8 +27,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
@ -40,8 +39,6 @@ using ASC.Core.Billing;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
namespace ASC.Core
{
@ -110,21 +107,15 @@ namespace ASC.Core
var now = DateTime.UtcNow;
var actionUrl = "/partnerapi/ActivateKey?code=" + HttpUtility.UrlEncode(key) + "&portal=" + HttpUtility.UrlEncode(TenantManager.GetCurrentTenant().TenantAlias);
using var webClient = new WebClient();
webClient.Headers.Add("Authorization", GetPartnerAuthHeader(actionUrl));
try
{
webClient.DownloadData(partnerUrl + actionUrl);
}
catch (WebException we)
{
var error = GetException(we);
if (error != null)
{
throw error;
}
throw;
}
var request = new HttpRequestMessage();
request.Headers.Add("Authorization", GetPartnerAuthHeader(actionUrl));
request.RequestUri = new Uri(partnerUrl + actionUrl);
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
tariffService.ClearCache(TenantManager.GetCurrentTenant().TenantId);
var timeout = DateTime.UtcNow - now - TimeSpan.FromSeconds(5);
@ -145,27 +136,5 @@ namespace ASC.Core
return string.Format("ASC :{0}:{1}", now, hash);
}
private static Exception GetException(WebException we)
{
var response = (HttpWebResponse)we.Response;
if (response.StatusCode == HttpStatusCode.InternalServerError)
{
using var stream = response.GetResponseStream();
using var reader = new StreamReader(stream, Encoding.UTF8);
var result = reader.ReadToEnd();
var excInfo = JsonConvert.DeserializeObject<ExceptionJson>(result);
return (Exception)Activator.CreateInstance(Type.GetType(excInfo.exceptionType, true), excInfo.exceptionMessage);
}
return null;
}
private class ExceptionJson
{
public string message = null;
public string exceptionMessage = null;
public string exceptionType = null;
public string stackTrace = null;
}
}
}

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model.Mail

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model.Resource

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,8 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF
{

View File

@ -142,11 +142,8 @@ namespace ASC.Core.Encryption
var array = new byte[length];
var array2 = new char[length];
var num = 0;
using (var rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(array);
}
array = RandomNumberGenerator.GetBytes(length);
for (var i = 0; i < length; i++)
{

View File

@ -26,8 +26,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.ServiceModel;
using System.Text;
@ -362,14 +363,24 @@ namespace ASC.Core.Notify.Signalr
private string MakeRequest(string method, object data)
{
if (!IsAvailable()) return "";
using var webClient = new WebClient();
var request = new HttpRequestMessage();
request.Headers.Add("Authorization", CreateAuthToken());
request.Method = HttpMethod.Post;
request.RequestUri = new Uri(GetMethod(method));
var jsonData = JsonConvert.SerializeObject(data);
Log.DebugFormat("Method:{0}, Data:{1}", method, jsonData);
webClient.Encoding = Encoding.UTF8;
webClient.Headers.Add("Authorization", CreateAuthToken());
webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
return webClient.UploadString(GetMethod(method), jsonData);
Log.DebugFormat("Method:{0}, Data:{1}", method, jsonData);
request.Content = new StringContent(jsonData, Encoding.UTF8, "application/json");
using (var httpClient = new HttpClient())
using (var response = httpClient.Send(request))
using (var stream = response.Content.ReadAsStream())
using (var streamReader = new StreamReader(stream))
{
return streamReader.ReadToEnd();
}
}
private T MakeRequest<T>(string method, object data)

View File

@ -138,7 +138,7 @@ namespace ASC.Core.Common.Notify
var buf = id.Concat(d).ToArray();
using var sha = new SHA256CryptoServiceProvider();
using var sha = SHA256.Create();
return Convert.ToBase64String(sha.ComputeHash(buf))
.Replace('+', '-').Replace('/', '_').Replace("=", ""); // make base64 url safe
}

View File

@ -58,68 +58,56 @@ namespace ASC.Core
public static string GetV(string data, int keyno, bool reverse)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = keyno == 1 ? GetSK1(false) : GetSK2(false);
hasher.IV = new byte[hasher.BlockSize >> 3];
string result;
if (reverse)
{
{
using var ms = new MemoryStream();
using var ss = new CryptoStream(ms, hasher.CreateEncryptor(), CryptoStreamMode.Write);
var buffer = Encoding.Unicode.GetBytes(data);
ss.Write(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream(Convert.FromBase64String(data));
plainTextStream.CopyTo(ss);
ss.FlushFinalBlock();
hasher.Clear();
result = Convert.ToBase64String(ms.ToArray());
return Convert.ToBase64String(ms.ToArray());
}
else
{
var bytes = Convert.FromBase64String(data);
using var ms = new MemoryStream(bytes);
using var ms = new MemoryStream(Convert.FromBase64String(data));
using var ss = new CryptoStream(ms, hasher.CreateDecryptor(), CryptoStreamMode.Read);
var buffer = new byte[bytes.Length];
var size = ss.Read(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream();
ss.CopyTo(plainTextStream);
hasher.Clear();
var newBuffer = new byte[size];
Array.Copy(buffer, newBuffer, size);
result = Encoding.Unicode.GetString(newBuffer);
return Encoding.Unicode.GetString(plainTextStream.ToArray());
}
return result;
}
internal static byte[] GetV(byte[] data, int keyno, bool reverse)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = keyno == 1 ? GetSK1(false) : GetSK2(false);
hasher.IV = new byte[hasher.BlockSize >> 3];
byte[] result;
if (reverse)
{
using var ms = new MemoryStream();
using var ss = new CryptoStream(ms, hasher.CreateEncryptor(), CryptoStreamMode.Write);
var buffer = data;
ss.Write(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream(data);
plainTextStream.CopyTo(ss);
ss.FlushFinalBlock();
hasher.Clear();
result = ms.ToArray();
return ms.ToArray();
}
else
{
var bytes = data;
using var ms = new MemoryStream(bytes);
using var ms = new MemoryStream(data);
using var ss = new CryptoStream(ms, hasher.CreateDecryptor(), CryptoStreamMode.Read);
var buffer = new byte[bytes.Length];
var size = ss.Read(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream();
ss.CopyTo(plainTextStream);
hasher.Clear();
var newBuffer = new byte[size];
Array.Copy(buffer, newBuffer, size);
result = newBuffer;
return plainTextStream.ToArray();
}
return result;
}
}
}

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
@ -13,8 +13,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
<PackageReference Include="Grpc" Version="2.32.0">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
@ -22,10 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="MySql.Data" Version="8.0.23" />
<PackageReference Include="SharpZipLib" Version="1.3.2" />
</ItemGroup>
<ItemGroup>

View File

@ -24,8 +24,6 @@
*/
using System.IO;
using ASC.Common.Utils;
using ASC.Data.Backup.Tasks.Modules;

View File

@ -24,8 +24,8 @@
*/
using System.Configuration;
using System.Configuration;
namespace ASC.Data.Backup.Utils
{
internal static class ConfigurationProvider

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>

View File

@ -186,16 +186,15 @@ namespace ASC.Data.Encryption
}
public SymmetricAlgorithm GetCryptographyAlgorithm()
{
return new RijndaelManaged
{
KeySize = keySize,
BlockSize = blockSize,
Key = Key,
IV = IV,
Padding = PaddingMode.PKCS7,
Mode = CipherMode.CBC
};
{
var aes = Aes.Create();
aes.KeySize = keySize;
aes.BlockSize = blockSize;
aes.Key = Key;
aes.IV = IV;
aes.Padding = PaddingMode.PKCS7;
aes.Mode = CipherMode.CBC;
return aes;
}
public void ComputeAndWriteHmacHash(Stream stream)
@ -245,10 +244,7 @@ namespace ASC.Data.Encryption
{
var random = new byte[length];
using (var rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(random);
}
random = RandomNumberGenerator.GetBytes(length);
return random;
}
@ -269,7 +265,7 @@ namespace ASC.Data.Encryption
{
var hmacKey = new byte[hmacKeyLength];
using (var sha512 = new SHA512Managed())
using (var sha512 = SHA512.Create())
{
hmacKey = sha512.ComputeHash(Key);
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@ -10,10 +10,6 @@
<NoWarn>1701;1702;NU1701;</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="UAParser" Version="3.1.44" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\web\ASC.Web.Core\ASC.Web.Core.csproj" />
<ProjectReference Include="..\ASC.Data.Storage\ASC.Data.Storage.csproj" />

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
@ -42,9 +42,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.5" />
<PackageReference Include="openstack.net" Version="1.7.9" />
<PackageReference Include="openstack.net" Version="1.8.0" />
</ItemGroup>
<ItemGroup>

View File

@ -83,7 +83,6 @@ namespace ASC.Data.Storage.DiscStorage
{
await context.Response.SendFileAsync(path);
}
context.Response.ContentType = MimeMapping.GetMimeMapping(path);
//TODO
//context.Response.Cache.SetVaryByCustom("*");

View File

@ -25,7 +25,6 @@
using System.Collections.Generic;
using System.IO;
using ASC.Common.Utils;

View File

@ -31,7 +31,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
@ -71,7 +70,7 @@ namespace ASC.Data.Storage.GoogleCloud
private Uri _bucketSSlRoot;
private bool _lowerCasing = true;
public GoogleCloudStorage(
TempStream tempStream,
TenantManager tenantManager,
@ -760,32 +759,17 @@ namespace ASC.Data.Storage.GoogleCloud
var totalBytes = "*";
var BufferSize = 2 * 4096;
if (chunkLength != defaultChunkSize)
totalBytes = Convert.ToString((chunkNumber - 1) * defaultChunkSize + chunkLength);
var contentRangeHeader = string.Format("bytes {0}-{1}/{2}", bytesRangeStart, bytesRangeEnd, totalBytes);
var request = HttpWebRequest.CreateHttp(uploadUri);
request.Method = HttpMethod.Put.ToString();
request.ContentLength = chunkLength;
var request = new HttpRequestMessage();
request.RequestUri = new Uri(uploadUri);
request.Method = HttpMethod.Put;
request.Headers.Add("Content-Range", contentRangeHeader);
request.Content = new StreamContent(stream);
using (var rs = request.GetRequestStream())
{
var buffer = new byte[BufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, BufferSize)) != 0)
{
rs.Write(buffer, 0, readed);
}
stream.Close();
}
long MAX_RETRIES = 100;
int millisecondsTimeout;
@ -798,16 +782,15 @@ namespace ASC.Data.Storage.GoogleCloud
try
{
var response = request.GetResponse();
var status = ((HttpWebResponse)response).StatusCode;
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
var status = response.StatusCode;
break;
}
catch (WebException ex)
catch (HttpRequestException ex)
{
var response = (HttpWebResponse)ex.Response;
var status = (int)response.StatusCode;
var status = (int)ex.StatusCode;
if (status == 408 || status == 500 || status == 502 || status == 503 || status == 504)
{

View File

@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using ASC.Common;
using ASC.Common.Logging;
@ -237,10 +238,13 @@ namespace ASC.Data.Storage
{
try
{
var request = (HttpWebRequest)WebRequest.Create(path);
request.Method = "HEAD";
using var resp = (HttpWebResponse)request.GetResponse();
return resp.StatusCode == HttpStatusCode.OK;
var request = new HttpRequestMessage();
request.RequestUri = new Uri(path);
request.Method = HttpMethod.Head;
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
return response.StatusCode == HttpStatusCode.OK;
}
catch (Exception)
{

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>

View File

@ -27,7 +27,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
namespace ASC.FederatedLogin.Helpers
@ -38,9 +38,13 @@ namespace ASC.FederatedLogin.Helpers
{
if (string.IsNullOrEmpty(uri)) throw new ArgumentNullException("uri");
var request = WebRequest.Create(uri);
request.Method = method;
request.Timeout = timeout;
var request = new HttpRequestMessage();
request.RequestUri = new Uri(uri);
request.Method = new HttpMethod(method);
using var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMilliseconds(timeout);
if (headers != null)
{
foreach (var key in headers.Keys)
@ -49,33 +53,22 @@ namespace ASC.FederatedLogin.Helpers
}
}
if (!string.IsNullOrEmpty(contentType))
{
request.ContentType = contentType;
}
var bytes = Encoding.UTF8.GetBytes(body ?? "");
if (request.Method != "GET" && bytes.Length > 0)
if (request.Method != HttpMethod.Get && bytes.Length > 0)
{
request.ContentLength = bytes.Length;
using var stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
request.Content = new ByteArrayContent(bytes, 0, bytes.Length);
if (!string.IsNullOrEmpty(contentType))
{
request.Headers.Add("Content-Type", contentType);
}
}
try
{
using var response = request.GetResponse();
using var stream = response.GetResponseStream();
if (stream == null) return null;
using var readStream = new StreamReader(stream);
return readStream.ReadToEnd();
}
catch (WebException)
{
request.Abort();
throw;
}
using var response = httpClient.Send(request);
using var stream = response.Content.ReadAsStream();
if (stream == null) return null;
using var readStream = new StreamReader(stream);
return readStream.ReadToEnd();
}
}
}

View File

@ -373,7 +373,7 @@ namespace ASC.FederatedLogin.Profile
internal void FromTransport(string transportstring)
{
var serialized = Encoding.UTF8.GetString(InstanceCrypto.Decrypt(WebEncoders.Base64UrlDecode(transportstring)));
var serialized = InstanceCrypto.Decrypt(WebEncoders.Base64UrlDecode(transportstring));
FromSerializedString(serialized);
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyTitle>ASC.Notify.Textile</AssemblyTitle>
<Company>Ascensio System SIA</Company>
<Product>ASC.Notify.Textile</Product>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -77,7 +77,7 @@ namespace ASC.VoipService.Twilio
{
if (!string.IsNullOrEmpty(settings.GreetingAudio))
{
response.Play(Uri.EscapeUriString(settings.GreetingAudio));
response.Play(Uri.EscapeDataString(settings.GreetingAudio));
}
response.Enqueue(settings.Queue.Name, GetEcho("Enqueue", agent != null), "POST",
@ -129,7 +129,7 @@ namespace ASC.VoipService.Twilio
if (!string.IsNullOrEmpty(queue.WaitUrl))
{
var gather = new Gather(method: "POST", action: GetEcho("gatherQueue"));
gather.Play(Uri.EscapeUriString(queue.WaitUrl));
gather.Play(Uri.EscapeDataString(queue.WaitUrl));
response.Gather(gather);
}
else
@ -156,7 +156,7 @@ namespace ASC.VoipService.Twilio
{
if (to == "hold")
{
return new VoiceResponse().Play(Uri.EscapeUriString(settings.HoldAudio), 0);
return new VoiceResponse().Play(Uri.EscapeDataString(settings.HoldAudio), 0);
}
@ -199,7 +199,7 @@ namespace ASC.VoipService.Twilio
{
return string.IsNullOrEmpty(settings.VoiceMail)
? response.Say("")
: response.Play(Uri.EscapeUriString(settings.VoiceMail)).Record(method: "POST", action: GetEcho("voiceMail"), maxLength: 30);
: response.Play(Uri.EscapeDataString(settings.VoiceMail)).Record(method: "POST", action: GetEcho("voiceMail"), maxLength: 30);
}
public string GetEcho(string action, bool user = true)

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<DefaultItemExcludes>$(DefaultItemExcludes);</DefaultItemExcludes>
<RazorCompileOnBuild>false</RazorCompileOnBuild>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.8" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" />
<PackageReference Include="Moq" Version="4.14.7" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<StartupObject>AutoMigrationCreator.Program</StartupObject>
</PropertyGroup>
@ -13,11 +13,11 @@
<ItemGroup>
<ProjectReference Include="..\..\..\products\ASC.Files\Core\ASC.Files.Core.csproj" />
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj" />
<PackageReference Include="Microsoft.Build" Version="16.11.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<PackageReference Include="Microsoft.Build" Version="17.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
</ItemGroup>
</Project>

View File

@ -1,6 +1,9 @@
using ASC.Core.Common.EF;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
namespace AutoMigrationCreator
@ -12,6 +15,10 @@ namespace AutoMigrationCreator
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkDesignTimeServices();
serviceCollection.AddDbContextDesignTimeServices(context);
serviceCollection.AddSingleton<MigrationsCodeGeneratorDependencies>();
serviceCollection.AddSingleton<AnnotationCodeGeneratorDependencies>();
serviceCollection.AddSingleton<IAnnotationCodeGenerator, AnnotationCodeGenerator>();
serviceCollection.AddSingleton(context.GetService<ITypeMappingSource>());
var designTimeServices = serviceCollection.BuildServiceProvider();

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyTitle>ASC.ApiSystem</AssemblyTitle>
<Company>Ascensio System SIA</Company>
<Product>ASC.ApiSystem</Product>
@ -17,10 +17,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -28,7 +28,8 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.RegularExpressions;
@ -168,18 +169,16 @@ namespace ASC.ApiSystem.Controllers
Log.DebugFormat("congratulations skiped");
return false;
}
var webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = WebRequestMethods.Http.Post;
webRequest.Accept = "application/x-www-form-urlencoded";
webRequest.ContentLength = 0;
var request = new HttpRequestMessage();
request.Method = HttpMethod.Post;
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/x-www-form-urlencoded"));
try
{
using var response = webRequest.GetResponse();
using var stream = response.GetResponseStream();
{
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
using var stream = response.Content.ReadAsStream();
using var reader = new StreamReader(stream, Encoding.UTF8);
var result = reader.ReadToEnd();
@ -305,18 +304,17 @@ namespace ASC.ApiSystem.Controllers
{
var data = string.Format("secret={0}&remoteip={1}&response={2}", Configuration["recaptcha:private-key"], ip, response);
var url = Configuration["recaptcha:verify-url"] ?? "https://www.recaptcha.net/recaptcha/api/siteverify";
var request = new HttpRequestMessage();
request.RequestUri = new Uri(url);
request.Method = HttpMethod.Post;
request.Content = new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded");
using var httpClient = new HttpClient();
using var httpClientResponse = httpClient.Send(request);
using var stream = httpClientResponse.Content.ReadAsStream();
using var reader = new StreamReader(stream);
var webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = WebRequestMethods.Http.Post;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = data.Length;
using (var writer = new StreamWriter(webRequest.GetRequestStream()))
{
writer.Write(data);
}
using var webResponse = webRequest.GetResponse();
using var reader = new StreamReader(webResponse.GetResponseStream());
var resp = reader.ReadToEnd();
var resObj = JObject.Parse(resp);

View File

@ -26,9 +26,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Web;
using ASC.ApiSystem.Classes;
@ -336,25 +338,20 @@ namespace ASC.ApiSystem.Controllers
string.IsNullOrEmpty(query) ? "" : "?" + query);
Log.Info(string.Format("CalDav: SendToApi: {0}", url));
var request = new HttpRequestMessage();
request.RequestUri = new Uri(url);
request.Method = new HttpMethod(httpMethod);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
var webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = httpMethod;
webRequest.Accept = "application/json";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = 0;
using var httpClient = new HttpClient();
if (data != null)
{
webRequest.ContentLength = data.Length;
using var writer = new StreamWriter(webRequest.GetRequestStream());
writer.Write(data);
request.Content = new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded");
}
using (webRequest.GetResponse())
{
}
httpClient.Send(request);
}
#endregion

View File

@ -46,7 +46,6 @@ namespace ASC.ApiSystem
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}

View File

@ -24,6 +24,8 @@
*/
using System.Text.Json.Serialization;
using ASC.Api.Core;
using ASC.ApiSystem.Classes;
using ASC.ApiSystem.Controllers;
@ -66,7 +68,7 @@ namespace ASC.ApiSystem
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.WriteIndented = false;
options.JsonSerializerOptions.IgnoreNullValues = true;
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
services.AddMemoryCache();

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@ -33,10 +33,9 @@
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj" />
<ProjectReference Include="..\..\ASC.Data.Encryption\ASC.Data.Encryption.csproj" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -21,6 +21,10 @@
</ItemGroup>
</Target>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ASC.Data.Backup.Core\ASC.Data.Backup.Core.csproj" />
</ItemGroup>

View File

@ -24,7 +24,7 @@ namespace ASC.Data.Backup
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -19,16 +19,15 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
<PackageReference Include="Grpc" Version="2.32.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Grpc" Version="2.32.0">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Grpc.Tools" Version="2.32.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="SharpCompress" Version="0.26.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<ProjectGuid>{AE1A0E06-6CD4-4E1D-8209-22BBBD6D5652}</ProjectGuid>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<FileUpgradeFlags />
<UpgradeBackupLocation />
<AssemblyTitle>ASC.ElasticSearch</AssemblyTitle>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -16,9 +16,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@ -13,7 +13,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
</ItemGroup>
<ItemGroup>
@ -21,8 +21,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -18,10 +18,9 @@
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="WebSocketSharpNetStandart" Version="1.0.3-rc12" />
</ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -19,9 +19,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@ -14,9 +14,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -16,10 +16,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Telegram.Bot" Version="15.7.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -25,9 +25,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
</Project>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -16,9 +16,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>

View File

@ -1,91 +1,91 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
using ASC.ElasticSearch;
using ASC.Web.CRM.Core.Search;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
using ASC.ElasticSearch;
using ASC.Web.CRM.Core.Search;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace ASC.CRM.BackgroundTasks
{
class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"appsettings.services.json", true)
.AddJsonFile("storage.json")
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace ASC.CRM.BackgroundTasks
{
class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"appsettings.services.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env}.json", true)
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args);
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
var diHelper = new DIHelper(services);
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCache<>));
.AddJsonFile($"notify.{env}.json", true)
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args);
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
var diHelper = new DIHelper(services);
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCache<>));
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
services.AddHostedService<ServiceLauncher>();
diHelper.TryAdd<ServiceLauncher>();
diHelper.TryAdd<FactoryIndexerCase>();
diHelper.TryAdd<FactoryIndexerContact>();
diHelper.TryAdd<FactoryIndexerContactInfo>();
diHelper.TryAdd<FactoryIndexerDeal>();
diHelper.TryAdd<FactoryIndexerEvents>();
diHelper.TryAdd<FactoryIndexerFieldValue>();
diHelper.TryAdd<FactoryIndexerInvoice>();
diHelper.TryAdd<FactoryIndexerTask>();
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, true, false, "search.json");
services.AddHostedService<ServiceLauncher>();
diHelper.TryAdd<ServiceLauncher>();
diHelper.TryAdd<FactoryIndexerCase>();
diHelper.TryAdd<FactoryIndexerContact>();
diHelper.TryAdd<FactoryIndexerContactInfo>();
diHelper.TryAdd<FactoryIndexerDeal>();
diHelper.TryAdd<FactoryIndexerEvents>();
diHelper.TryAdd<FactoryIndexerFieldValue>();
diHelper.TryAdd<FactoryIndexerInvoice>();
diHelper.TryAdd<FactoryIndexerTask>();
})
.ConfigureNLogLogging();
}
}
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, true, false, "search.json");
})
.ConfigureNLogLogging();
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@ -36,15 +36,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Grpc.Tools" Version="2.32.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="LumenWorksCsvReader" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="SharpZipLib" Version="1.3.2" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -43,7 +43,6 @@ using ASC.MessagingSystem;
using ASC.Web.Api.Routing;
using ASC.Web.Core.Users;
using ASC.Web.CRM.Services.NotifyService;
using ASC.Web.Files.Services.WCFService;
using AutoMapper;

View File

@ -35,7 +35,6 @@ using ASC.Core.Common.Settings;
using ASC.CRM.ApiModels;
using ASC.CRM.Core;
using ASC.CRM.Core.Dao;
using ASC.CRM.Core.Enums;
using ASC.Web.Api.Routing;
using ASC.Web.CRM.Classes;
using ASC.Web.Files.Services.DocumentService;

View File

@ -18,8 +18,9 @@ using ASC.Web.CRM.Services.NotifyService;
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
namespace ASC.CRM.Api
{
public class TasksController : BaseApiController

View File

@ -36,7 +36,6 @@ using ASC.Core.Common.Settings;
using ASC.CRM.ApiModels;
using ASC.CRM.Core;
using ASC.CRM.Core.Dao;
using ASC.CRM.Core.EF;
using ASC.CRM.Core.Entities;
using ASC.CRM.Core.Enums;
using ASC.CRM.Resources;

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace ASC.CRM.ApiModels
{

View File

@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using ASC.Api.Core;
using ASC.CRM.Core.Enums;
using Microsoft.AspNetCore.Mvc;
namespace ASC.CRM.ApiModels
{
public class AddTagToBatchContactsRequestDto

View File

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.CRM.Core.Enums;
using Microsoft.AspNetCore.Mvc;
namespace ASC.CRM.ApiModels
{
public class AddTagToBatchDealsRequestDto

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace ASC.CRM.ApiModels
{

View File

@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using ASC.CRM.Core.Enums;
using Microsoft.AspNetCore.Mvc;
namespace ASC.CRM.ApiModels
{
public class CreateContactInfoRequestDto

View File

@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace ASC.CRM.ApiModels
namespace ASC.CRM.ApiModels
{
public class CreateCurrencyRateRequestDto
{

Some files were not shown because too many files have changed in this diff Show More