mirror of
https://github.com/ONLYOFFICE/CommunityServer.git
synced 2025-04-18 13:24:01 +03:00
Update to v11.6.0
This commit is contained in:
parent
4ac38fa04f
commit
473e5bab22
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,4 +0,0 @@
|
||||
[submodule "web/studio/ASC.Web.Studio/Products/Files/DocStore"]
|
||||
path = web/studio/ASC.Web.Studio/Products/Files/DocStore
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/community-server
|
@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<solution>
|
||||
<add key="disableSourceControlIntegration" value="true" />
|
||||
</solution>
|
||||
<config>
|
||||
<add key="repositorypath" value="$\..\..\packages" />
|
||||
</config>
|
||||
<packageSources>
|
||||
<add key="Custom NuGet Server" value="packages" />
|
||||
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageRestore>
|
||||
<add key="enabled" value="True" />
|
||||
<add key="automatic" value="True" />
|
||||
</packageRestore>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<solution>
|
||||
<add key="disableSourceControlIntegration" value="true" />
|
||||
</solution>
|
||||
<config>
|
||||
<add key="repositorypath" value="$\..\..\packages" />
|
||||
</config>
|
||||
<packageSources>
|
||||
<add key="Custom NuGet Server" value="packages" />
|
||||
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageRestore>
|
||||
<add key="enabled" value="True" />
|
||||
<add key="automatic" value="True" />
|
||||
</packageRestore>
|
||||
</configuration>
|
@ -1,131 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||
|
||||
<!-- Enable the restore command to run before builds -->
|
||||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||
|
||||
<!-- Property that enables building a package from a project -->
|
||||
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||
|
||||
<!-- Determines if package restore consent is required to restore packages -->
|
||||
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||
|
||||
<!-- Download NuGet.exe if it does not already exist -->
|
||||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||
<PackageSource Include="http://www.nuget.org/api/v2/" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||
<!-- Windows specific commands -->
|
||||
<NuGetToolsPath>$([System.IO.Path]::Combine($(TrunkDir), ".nuget"))</NuGetToolsPath>
|
||||
<PackagesConfig>$([System.IO.Path]::Combine($(NuGetToolsPath), "packages.config"))</PackagesConfig>
|
||||
<PackageOutputDir>$([System.IO.Path]::Combine($(NuGetToolsPath), "packages"))</PackageOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||
<NuGetToolsPath>$(TrunkDir).nuget</NuGetToolsPath>
|
||||
<PackagesConfig>$(NuGetToolsPath)/packages.config</PackagesConfig>
|
||||
<PackageOutputDir>$(NuGetToolsPath)/packages</PackageOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- NuGet command -->
|
||||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
|
||||
|
||||
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||
|
||||
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(TrunkDir) "</PaddedSolutionDir>
|
||||
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(TrunkDir)"</PaddedSolutionDir>
|
||||
|
||||
<!-- Commands -->
|
||||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||
|
||||
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||
RestorePackages;
|
||||
$(BuildDependsOn);
|
||||
</BuildDependsOn>
|
||||
|
||||
<!-- Make the build depend on restore packages -->
|
||||
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||
$(BuildDependsOn);
|
||||
BuildPackage;
|
||||
</BuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="CheckPrerequisites">
|
||||
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||
<!--
|
||||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||
parallel builds will have to wait for it to complete.
|
||||
-->
|
||||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="_DownloadNuGet">
|
||||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(BuildCommand)"
|
||||
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||
|
||||
<Exec Command="$(BuildCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
</Target>
|
||||
|
||||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<OutputFilename ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.Core" />
|
||||
<Using Namespace="System" />
|
||||
<Using Namespace="System.IO" />
|
||||
<Using Namespace="System.Net" />
|
||||
<Using Namespace="Microsoft.Build.Framework" />
|
||||
<Using Namespace="Microsoft.Build.Utilities" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
try {
|
||||
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||
|
||||
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.LogErrorFromException(ex);
|
||||
return false;
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
</Project>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||
|
||||
<!-- Enable the restore command to run before builds -->
|
||||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||
|
||||
<!-- Property that enables building a package from a project -->
|
||||
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||
|
||||
<!-- Determines if package restore consent is required to restore packages -->
|
||||
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||
|
||||
<!-- Download NuGet.exe if it does not already exist -->
|
||||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||
<PackageSource Include="http://www.nuget.org/api/v2/" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||
<!-- Windows specific commands -->
|
||||
<NuGetToolsPath>$([System.IO.Path]::Combine($(TrunkDir), ".nuget"))</NuGetToolsPath>
|
||||
<PackagesConfig>$([System.IO.Path]::Combine($(NuGetToolsPath), "packages.config"))</PackagesConfig>
|
||||
<PackageOutputDir>$([System.IO.Path]::Combine($(NuGetToolsPath), "packages"))</PackageOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||
<NuGetToolsPath>$(TrunkDir).nuget</NuGetToolsPath>
|
||||
<PackagesConfig>$(NuGetToolsPath)/packages.config</PackagesConfig>
|
||||
<PackageOutputDir>$(NuGetToolsPath)/packages</PackageOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- NuGet command -->
|
||||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
|
||||
|
||||
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||
|
||||
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(TrunkDir) "</PaddedSolutionDir>
|
||||
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(TrunkDir)"</PaddedSolutionDir>
|
||||
|
||||
<!-- Commands -->
|
||||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||
|
||||
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||
RestorePackages;
|
||||
$(BuildDependsOn);
|
||||
</BuildDependsOn>
|
||||
|
||||
<!-- Make the build depend on restore packages -->
|
||||
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||
$(BuildDependsOn);
|
||||
BuildPackage;
|
||||
</BuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="CheckPrerequisites">
|
||||
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||
<!--
|
||||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||
parallel builds will have to wait for it to complete.
|
||||
-->
|
||||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="_DownloadNuGet">
|
||||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(BuildCommand)"
|
||||
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||
|
||||
<Exec Command="$(BuildCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
</Target>
|
||||
|
||||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<OutputFilename ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.Core" />
|
||||
<Using Namespace="System" />
|
||||
<Using Namespace="System.IO" />
|
||||
<Using Namespace="System.Net" />
|
||||
<Using Namespace="Microsoft.Build.Framework" />
|
||||
<Using Namespace="Microsoft.Build.Utilities" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
try {
|
||||
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||
|
||||
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.LogErrorFromException(ex);
|
||||
return false;
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
</Project>
|
||||
|
2500
3rd-Party.txt
2500
3rd-Party.txt
File diff suppressed because it is too large
Load Diff
20
NuGet.Config
20
NuGet.Config
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="Custom NuGet Server" value=".nuget/packages" />
|
||||
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageRestore>
|
||||
<add key="enabled" value="True" />
|
||||
<add key="automatic" value="True" />
|
||||
</packageRestore>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="Custom NuGet Server" value=".nuget/packages" />
|
||||
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageRestore>
|
||||
<add key="enabled" value="True" />
|
||||
<add key="automatic" value="True" />
|
||||
</packageRestore>
|
||||
</configuration>
|
@ -4,7 +4,7 @@
|
||||
<hr />
|
||||
<p align="center">
|
||||
<a href="https://www.onlyoffice.com/">Website</a> |
|
||||
<a href="https://www.onlyoffice.com/workspace.aspx">ONLYOFFICE Workspace</a> |
|
||||
<a href="https://www.onlyoffice.com/server-solutions.aspx">Products</a> |
|
||||
<a href="https://helpcenter.onlyoffice.com/">Documentation</a> |
|
||||
<a href="https://api.onlyoffice.com/">API</a> |
|
||||
<a href="https://www.onlyoffice.com/about.aspx">About</a>
|
||||
@ -17,10 +17,10 @@
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="http://www.apache.org/licenses/LICENSE-2.0"><img alt="http://www.apache.org/licenses/LICENSE-2.0" src="https://img.shields.io/badge/License-Apache%20v2.0-green.svg?style=flat"></a>
|
||||
<a href="https://github.com/ONLYOFFICE/CommunityServer/releases"><img alt="https://github.com/ONLYOFFICE/CommunityServer/releases" src="https://img.shields.io/badge/release-11.0.0-blue.svg"></a>
|
||||
<a href="https://github.com/ONLYOFFICE/portals/releases"><img alt="https://github.com/ONLYOFFICE/portals/releases" src="https://img.shields.io/badge/release-11.0.0-blue.svg"></a>
|
||||
</p>
|
||||
|
||||
# Overview
|
||||
## Overview
|
||||
|
||||
ONLYOFFICE Community Server is a free open-source collaborative system developed to manage documents, projects, customer relationship and email correspondence, all in one place.
|
||||
|
||||
@ -54,7 +54,7 @@ Control Panel for administrating **ONLYOFFICE Workspace** can be found in [this
|
||||
|
||||
## Compiling
|
||||
|
||||
To compile source, follow this [instruction](https://helpcenter.onlyoffice.com/server/windows/community/compile-source-code.aspx).
|
||||
To compile the source code, follow this [instruction](https://helpcenter.onlyoffice.com/server/windows/community/compile-source-code.aspx).
|
||||
|
||||
## Connecting your own modules
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
set Constants=DEBUGINFO
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" msbuild\build.proj /fl1 /flp1:LogFile=Build.log;Verbosity=Normal /m -tv:Current -v:m
|
||||
set Constants=DEBUGINFO
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" msbuild\build.proj /fl1 /flp1:LogFile=Build.log;Verbosity=Normal /m -tv:Current -v:m
|
||||
pause
|
@ -1,7 +1,7 @@
|
||||
set Cultures=fr,de,es,ru,lv,pt-BR,pt,it,tr,el,zh-CN,pl,cs,uk,vi,fi,az-Latn-AZ,ko,ja,sl,sk,nl,bg
|
||||
|
||||
set BuildTargets=ReBuild
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" msbuild\build.proj /fl1 /flp1:LogFile=Build.log;Verbosity=Normal /m -v:m
|
||||
set BuildTargets=Build
|
||||
if %errorlevel% == 0 "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" msbuild\deploy.proj /fl1 /flp1:LogFile=Deploy.log;Verbosity=Normal /m -v:m
|
||||
pause
|
||||
set Cultures=fr,de,es,ru,lv,pt-BR,pt,it,tr,el,zh-CN,pl,cs,uk,vi,fi,az-Latn-AZ,ko,ja,sl,sk,nl,bg
|
||||
|
||||
set BuildTargets=ReBuild
|
||||
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" msbuild\build.proj /fl1 /flp1:LogFile=Build.log;Verbosity=Normal /m -v:m
|
||||
set BuildTargets=Build
|
||||
if %errorlevel% == 0 "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" msbuild\deploy.proj /fl1 /flp1:LogFile=Deploy.log;Verbosity=Normal /m -v:m
|
||||
pause
|
||||
|
@ -1,110 +1,110 @@
|
||||
echo off
|
||||
|
||||
set basepath=%cd%
|
||||
for %%D in ("%CD%") do set "parentdir=%%~nxD"
|
||||
set version=
|
||||
if not "%~2" == "" set version=%~2
|
||||
|
||||
SET parent=%~dp0
|
||||
FOR %%a IN ("%parent:~0,-1%") DO SET grandparent=%%~dpa
|
||||
|
||||
if "%~1" == "--install" (
|
||||
sc create Onlyoffice%parentdir%%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\"
|
||||
goto Exit
|
||||
)
|
||||
|
||||
if "%~1" == "--install-all" (
|
||||
sc create OnlyofficeNotify%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Notify.NotifyServiceLauncher, ASC.Notify\" --log Notify"
|
||||
sc create OnlyofficeJabber%version% start= delayed-auto binPath= "\"%grandparent%\Jabber\ASC.Xmpp.Server.Launcher.exe\""
|
||||
sc create OnlyofficeIndex%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.ElasticSearch.Launcher, ASC.ElasticSearch\" --log Index"
|
||||
sc create OnlyofficeRadicale%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Radicale.Launcher, ASC.Radicale\" --log Radicale"
|
||||
sc create OnlyOfficeStorageMigrate%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Data.Storage.Migration.Launcher,ASC.Data.Storage.Migration\" --log StorageMigrate"
|
||||
sc create OnlyOfficeStorageEncryption%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Data.Storage.Encryption.Launcher,ASC.Data.Storage.Encryption\" --log StorageEncryption"
|
||||
sc create OnlyofficeFeed%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Feed.Aggregator.FeedAggregatorLauncher, ASC.Feed.Aggregator\" --log Feed"
|
||||
sc create OnlyofficeBackup%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Data.Backup.Service.BackupServiceLauncher, ASC.Data.Backup\" --log Backup"
|
||||
sc create OnlyOfficeSocketIO%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Socket.IO.Svc.Launcher, ASC.Socket.IO.Svc\" --log SocketIO"
|
||||
sc create OnlyOfficeTelegram%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.TelegramService.Launcher, ASC.TelegramService\" --log Telegram"
|
||||
sc create OnlyofficeThumbnailBuilder%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Files.ThumbnailBuilder.Launcher, ASC.Files.ThumbnailBuilder\" --log ThumbnailBuilder"
|
||||
sc create OnlyOfficeThumb%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Thumbnails.Svc.Launcher,ASC.Thumbnails.Svc\" --log Thumb"
|
||||
sc create OnlyOfficeSsoAuth%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.SsoAuth.Svc.Launcher,ASC.SsoAuth.Svc\" --log SsoAuth"
|
||||
sc create OnlyOfficeUrlShortener%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.UrlShortener.Svc.Launcher,ASC.UrlShortener.Svc\" --log UrlShortener"
|
||||
sc create OnlyOfficeMailAggregator%version% start= delayed-auto binPath= "\"%grandparent%\MailAggregator\ASC.Mail.Aggregator.CollectionService.exe\""
|
||||
sc create OnlyOfficeMailWatchdog%version% start= delayed-auto binPath= "\"%grandparent%\MailWatchdog\ASC.Mail.Watchdog.Service.exe\""
|
||||
sc create OnlyOfficeMailCleaner%version% start= delayed-auto binPath= "\"%grandparent%\MailCleaner\ASC.Mail.StorageCleaner.exe\""
|
||||
|
||||
sc failure OnlyofficeNotify%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeJabber%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeIndex%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeRadicale%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeStorageMigrate%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeStorageEncryption%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeFeed%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeBackup%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeSocketIO%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeTelegram%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeThumbnailBuilder%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeThumb%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeSsoAuth%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeUrlShortener%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeMailAggregator%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeMailWatchdog%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeMailCleaner%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
|
||||
goto Exit
|
||||
)
|
||||
if "%~1" == "--uninstall" (
|
||||
net stop Onlyoffice%parentdir%%version%
|
||||
sc delete Onlyoffice%parentdir%%version%
|
||||
goto Exit
|
||||
)
|
||||
|
||||
if "%~1" == "--uninstall-all" (
|
||||
net stop OnlyofficeNotify%version%
|
||||
sc delete OnlyofficeNotify%version%
|
||||
net stop OnlyofficeJabber%version%
|
||||
sc delete OnlyofficeJabber%version%
|
||||
net stop OnlyofficeIndex%version%
|
||||
sc delete OnlyofficeIndex%version%
|
||||
net stop OnlyofficeRadicale%version%
|
||||
sc delete OnlyofficeRadicale%version%
|
||||
net stop OnlyOfficeStorageMigrate%version%
|
||||
sc delete OnlyOfficeStorageMigrate%version%
|
||||
net stop OnlyOfficeStorageEncryption%version%
|
||||
sc delete OnlyOfficeStorageEncryption%version%
|
||||
net stop OnlyofficeFeed%version%
|
||||
sc delete OnlyofficeFeed%version%
|
||||
net stop OnlyofficeBackup%version%
|
||||
sc delete OnlyofficeBackup%version%
|
||||
net stop OnlyOfficeSocketIO%version%
|
||||
sc delete OnlyOfficeSocketIO%version%
|
||||
net stop OnlyOfficeTelegram%version%
|
||||
sc delete OnlyOfficeTelegram%version%
|
||||
net stop OnlyOfficeThumb%version%
|
||||
sc delete OnlyOfficeThumb%version%
|
||||
net stop OnlyOfficeSsoAuth%version%
|
||||
sc delete OnlyOfficeSsoAuth%version%
|
||||
net stop OnlyOfficeUrlShortener%version%
|
||||
sc delete OnlyOfficeUrlShortener%version%
|
||||
net stop OnlyofficeThumbnailBuilder%version%
|
||||
sc delete OnlyofficeThumbnailBuilder%version%
|
||||
net stop OnlyOfficeMailAggregator%version%
|
||||
sc delete OnlyOfficeMailAggregator%version%
|
||||
net stop OnlyOfficeMailWatchdog%version%
|
||||
sc delete OnlyOfficeMailWatchdog%version%
|
||||
net stop OnlyOfficeMailCleaner%version%
|
||||
sc delete OnlyOfficeMailCleaner%version%
|
||||
|
||||
goto Exit
|
||||
)
|
||||
|
||||
:Help
|
||||
echo Usage: ManageServices.bat COMMAND [VERSION]
|
||||
echo COMMAND install or unistall services:
|
||||
echo --install - install service
|
||||
echo --uninstall - uninstall service
|
||||
echo --install-all - install all services from this folder
|
||||
echo --uninstall-all - uninstall all services from this folder
|
||||
echo VERSION service version, example: 8.5.1, can be empty
|
||||
|
||||
:Exit
|
||||
echo off
|
||||
|
||||
set basepath=%cd%
|
||||
for %%D in ("%CD%") do set "parentdir=%%~nxD"
|
||||
set version=
|
||||
if not "%~2" == "" set version=%~2
|
||||
|
||||
SET parent=%~dp0
|
||||
FOR %%a IN ("%parent:~0,-1%") DO SET grandparent=%%~dpa
|
||||
|
||||
if "%~1" == "--install" (
|
||||
sc create Onlyoffice%parentdir%%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\"
|
||||
goto Exit
|
||||
)
|
||||
|
||||
if "%~1" == "--install-all" (
|
||||
sc create OnlyofficeNotify%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Notify.NotifyServiceLauncher, ASC.Notify\" --log Notify"
|
||||
sc create OnlyofficeJabber%version% start= delayed-auto binPath= "\"%grandparent%\Jabber\ASC.Xmpp.Server.Launcher.exe\""
|
||||
sc create OnlyofficeIndex%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.ElasticSearch.Launcher, ASC.ElasticSearch\" --log Index"
|
||||
sc create OnlyofficeRadicale%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Radicale.Launcher, ASC.Radicale\" --log Radicale"
|
||||
sc create OnlyOfficeStorageMigrate%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Data.Storage.Migration.Launcher,ASC.Data.Storage.Migration\" --log StorageMigrate"
|
||||
sc create OnlyOfficeStorageEncryption%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Data.Storage.Encryption.Launcher,ASC.Data.Storage.Encryption\" --log StorageEncryption"
|
||||
sc create OnlyofficeFeed%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Feed.Aggregator.FeedAggregatorLauncher, ASC.Feed.Aggregator\" --log Feed"
|
||||
sc create OnlyofficeBackup%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Data.Backup.Service.BackupServiceLauncher, ASC.Data.Backup\" --log Backup"
|
||||
sc create OnlyOfficeSocketIO%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Socket.IO.Svc.Launcher, ASC.Socket.IO.Svc\" --log SocketIO"
|
||||
sc create OnlyOfficeTelegram%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.TelegramService.Launcher, ASC.TelegramService\" --log Telegram"
|
||||
sc create OnlyofficeThumbnailBuilder%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Files.ThumbnailBuilder.Launcher, ASC.Files.ThumbnailBuilder\" --log ThumbnailBuilder"
|
||||
sc create OnlyOfficeThumb%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.Thumbnails.Svc.Launcher,ASC.Thumbnails.Svc\" --log Thumb"
|
||||
sc create OnlyOfficeSsoAuth%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.SsoAuth.Svc.Launcher,ASC.SsoAuth.Svc\" --log SsoAuth"
|
||||
sc create OnlyOfficeUrlShortener%version% start= delayed-auto binPath= "\"%basepath%\TeamLabSvc.exe\" --service \"ASC.UrlShortener.Svc.Launcher,ASC.UrlShortener.Svc\" --log UrlShortener"
|
||||
sc create OnlyOfficeMailAggregator%version% start= delayed-auto binPath= "\"%grandparent%\MailAggregator\ASC.Mail.Aggregator.CollectionService.exe\""
|
||||
sc create OnlyOfficeMailWatchdog%version% start= delayed-auto binPath= "\"%grandparent%\MailWatchdog\ASC.Mail.Watchdog.Service.exe\""
|
||||
sc create OnlyOfficeMailCleaner%version% start= delayed-auto binPath= "\"%grandparent%\MailCleaner\ASC.Mail.StorageCleaner.exe\""
|
||||
|
||||
sc failure OnlyofficeNotify%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeJabber%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeIndex%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeRadicale%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeStorageMigrate%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeStorageEncryption%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeFeed%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeBackup%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeSocketIO%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeTelegram%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyofficeThumbnailBuilder%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeThumb%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeSsoAuth%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeUrlShortener%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeMailAggregator%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeMailWatchdog%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
sc failure OnlyOfficeMailCleaner%version% reset= 60 actions= restart/60000/restart/60000/restart/60000
|
||||
|
||||
goto Exit
|
||||
)
|
||||
if "%~1" == "--uninstall" (
|
||||
net stop Onlyoffice%parentdir%%version%
|
||||
sc delete Onlyoffice%parentdir%%version%
|
||||
goto Exit
|
||||
)
|
||||
|
||||
if "%~1" == "--uninstall-all" (
|
||||
net stop OnlyofficeNotify%version%
|
||||
sc delete OnlyofficeNotify%version%
|
||||
net stop OnlyofficeJabber%version%
|
||||
sc delete OnlyofficeJabber%version%
|
||||
net stop OnlyofficeIndex%version%
|
||||
sc delete OnlyofficeIndex%version%
|
||||
net stop OnlyofficeRadicale%version%
|
||||
sc delete OnlyofficeRadicale%version%
|
||||
net stop OnlyOfficeStorageMigrate%version%
|
||||
sc delete OnlyOfficeStorageMigrate%version%
|
||||
net stop OnlyOfficeStorageEncryption%version%
|
||||
sc delete OnlyOfficeStorageEncryption%version%
|
||||
net stop OnlyofficeFeed%version%
|
||||
sc delete OnlyofficeFeed%version%
|
||||
net stop OnlyofficeBackup%version%
|
||||
sc delete OnlyofficeBackup%version%
|
||||
net stop OnlyOfficeSocketIO%version%
|
||||
sc delete OnlyOfficeSocketIO%version%
|
||||
net stop OnlyOfficeTelegram%version%
|
||||
sc delete OnlyOfficeTelegram%version%
|
||||
net stop OnlyOfficeThumb%version%
|
||||
sc delete OnlyOfficeThumb%version%
|
||||
net stop OnlyOfficeSsoAuth%version%
|
||||
sc delete OnlyOfficeSsoAuth%version%
|
||||
net stop OnlyOfficeUrlShortener%version%
|
||||
sc delete OnlyOfficeUrlShortener%version%
|
||||
net stop OnlyofficeThumbnailBuilder%version%
|
||||
sc delete OnlyofficeThumbnailBuilder%version%
|
||||
net stop OnlyOfficeMailAggregator%version%
|
||||
sc delete OnlyOfficeMailAggregator%version%
|
||||
net stop OnlyOfficeMailWatchdog%version%
|
||||
sc delete OnlyOfficeMailWatchdog%version%
|
||||
net stop OnlyOfficeMailCleaner%version%
|
||||
sc delete OnlyOfficeMailCleaner%version%
|
||||
|
||||
goto Exit
|
||||
)
|
||||
|
||||
:Help
|
||||
echo Usage: ManageServices.bat COMMAND [VERSION]
|
||||
echo COMMAND install or unistall services:
|
||||
echo --install - install service
|
||||
echo --uninstall - uninstall service
|
||||
echo --install-all - install all services from this folder
|
||||
echo --uninstall-all - uninstall all services from this folder
|
||||
echo VERSION service version, example: 8.5.1, can be empty
|
||||
|
||||
:Exit
|
||||
echo on
|
@ -1,432 +1,436 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="teamlab" type="ASC.TeamLabSvc.Configuration.TeamLabSvcConfigurationSection, TeamLabSvc" />
|
||||
<section name="notify" type="ASC.Notify.Config.NotifyServiceCfgSectionHandler, ASC.Notify" />
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
|
||||
<section name="storage" type="ASC.Data.Storage.Configuration.StorageConfigurationSection, ASC.Data.Storage" />
|
||||
<section name="backup" type="ASC.Data.Backup.Service.BackupConfigurationSection, ASC.Data.Backup" />
|
||||
<section name="autoreply" type="ASC.Mail.Autoreply.AutoreplyServiceConfiguration, ASC.Mail.Autoreply" />
|
||||
<section name="feed" type="ASC.Feed.Aggregator.Config.FeedConfigurationSection, ASC.Feed.Aggregator" />
|
||||
<section name="healthCheck" type="ASC.HealthCheck.Settings.HealthCheckCfgSectionHandler, ASC.HealthCheck" />
|
||||
<section name="socketio" type="ASC.Socket.IO.Svc.SocketIOCfgSectionHandler, ASC.Socket.IO.Svc" />
|
||||
<section name="thumb" type="ASC.Thumbnails.Svc.ConfigHandler, ASC.Thumbnails.Svc" />
|
||||
<section name="ssoauth" type="ASC.SsoAuth.Svc.ConfigHandler, ASC.SsoAuth.Svc" />
|
||||
<section name="urlshortener" type="ASC.UrlShortener.Svc.ConfigHandler, ASC.UrlShortener.Svc" />
|
||||
<section name="radicale" type="ASC.Radicale.RadicaleCfgSectionHandler, ASC.Radicale" />
|
||||
<section name="apiClient" type="ASC.Api.Client.ApiClientConfiguration, ASC.Api.Client" />
|
||||
<section name="autofac" type="ASC.Common.DependencyInjection.AutofacConfigurationSection, ASC.Common" />
|
||||
<section name="consumers" type="ASC.Core.Common.Configuration.ConsumerConfigurationSection, ASC.Core.Common" />
|
||||
<section name="thumbnailBuilder" type="ASC.Files.ThumbnailBuilder.ConfigSection, ASC.Files.ThumbnailBuilder" />
|
||||
<section name="redisCacheClient" type="StackExchange.Redis.Extensions.LegacyConfiguration.RedisCachingSectionHandler, StackExchange.Redis.Extensions.LegacyConfiguration" />
|
||||
</configSections>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.8.6.1" newVersion="1.8.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Api.Gax" culture="neutral" publicKeyToken="3ec5ea7f18953e47" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Api.Gax.Rest" culture="neutral" publicKeyToken="3ec5ea7f18953e47" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.0" newVersion="1.45.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis.Auth" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.0" newVersion="1.45.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis.Core" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.0" newVersion="1.45.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis.Storage.v1" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.1911" newVersion="1.45.0.1911" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Protobuf" culture="neutral" publicKeyToken="a7d26565bac4d604" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.11.4.0" newVersion="3.11.4.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="log4net" culture="neutral" publicKeyToken="669e0ddf0bb1aa2a" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" culture="neutral" publicKeyToken="adb9793829ddae60" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="BouncyCastle.Crypto" culture="neutral" publicKeyToken="0e99375e54769942" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.8.5.0" newVersion="1.8.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="StackExchange.Redis.Extensions.Core" culture="neutral" publicKeyToken="d7d863643bcd13ef" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<clear />
|
||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
<appSettings>
|
||||
<add key="core.base-domain" value="localhost" />
|
||||
<add key="core.machinekey" value="Vskoproizvolny Salt par Chivreski" />
|
||||
<add key="files.docservice.secret" value="" />
|
||||
<add key="files.docservice.secret.header" value="" />
|
||||
<add key="files.docservice.timeout" value="50000" />
|
||||
<add key="files.docservice.url.public" value="" />
|
||||
<add key="files.docservice.url.internal" value="" />
|
||||
<add key="files.docservice.url.portal" value="" />
|
||||
<add key="files.index.formats" value=".pptx|.xlsx|.docx" />
|
||||
<add key="messaging.enabled" value="true" />
|
||||
<add key="temp" value="..\..\Data\temp" />
|
||||
<add key="web.help-center" value="https://helpcenter.onlyoffice.com/{ru|de|fr|es|lv|it}" />
|
||||
<add key="web.hub.internal" value="http://localhost:9899/" />
|
||||
<add key="web.controlpanel.url" value="" />
|
||||
<add key="license.file.path" value="" />
|
||||
<add key="resources.from-db" value="true" />
|
||||
<add key="mail.certificate-permit" value="true" />
|
||||
</appSettings>
|
||||
<connectionStrings>
|
||||
<clear />
|
||||
<add name="default" connectionString="Server=localhost;Database=onlyoffice;User ID=root;Password=;Pooling=True;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=true;Connection Timeout=30;Maximum Pool Size=300;" providerName="MySql.Data.MySqlClient" />
|
||||
</connectionStrings>
|
||||
<teamlab>
|
||||
<services>
|
||||
<add type="ASC.Socket.IO.Svc.Launcher, ASC.Socket.IO.Svc" />
|
||||
<add type="ASC.Radicale.Launcher, ASC.Radicale" />
|
||||
<add type="ASC.Notify.NotifyServiceLauncher, ASC.Notify" />
|
||||
<add type="ASC.Feed.Aggregator.FeedAggregatorLauncher, ASC.Feed.Aggregator" />
|
||||
<add type="ASC.Data.Backup.Service.BackupServiceLauncher, ASC.Data.Backup" />
|
||||
<!-- <add type="ASC.Mail.Autoreply.AutoreplyServiceController, ASC.Mail.Autoreply"/> -->
|
||||
<add type="ASC.Data.Storage.Migration.Launcher, ASC.Data.Storage.Migration" />
|
||||
<add type="ASC.ElasticSearch.Launcher, ASC.ElasticSearch" />
|
||||
<add type="ASC.Thumbnails.Svc.Launcher, ASC.Thumbnails.Svc" />
|
||||
<add type="ASC.SsoAuth.Svc.Launcher, ASC.SsoAuth.Svc" />
|
||||
<add type="ASC.UrlShortener.Svc.Launcher, ASC.UrlShortener.Svc" />
|
||||
<add type="ASC.TelegramService.Launcher, ASC.TelegramService" />
|
||||
<add type="ASC.Data.Storage.Encryption.Launcher, ASC.Data.Storage.Encryption" />
|
||||
<add type="ASC.Files.ThumbnailBuilder.Launcher, ASC.Files.ThumbnailBuilder" />
|
||||
</services>
|
||||
</teamlab>
|
||||
<apiClient root="/api/2.0/" scheme="Http" />
|
||||
<notify connectionStringName="default">
|
||||
<process maxThreads="2" bufferSize="10" maxAttempts="10" attemptsInterval="0:5:0" />
|
||||
<senders>
|
||||
<sender name="email.sender" type="ASC.Core.Notify.Senders.SmtpSender, ASC.Core.Common" host="" port="" userName="" password="" enableSsl="" useCoreSettings="true" />
|
||||
<sender name="messanger.sender" type="ASC.Core.Notify.Senders.JabberSender, ASC.Core.Common" />
|
||||
<sender name="telegram.sender" type="ASC.Core.Notify.Senders.TelegramSender, ASC.Core.Common" />
|
||||
</senders>
|
||||
<schedulers>
|
||||
<scheduler name="WhatsNew" register="ASC.Web.Studio.Core.Notify.NotifyConfiguration.RegisterSendMethods, ASC.Web.Studio" />
|
||||
<scheduler name="Calendar" register="ASC.Api.Calendar.Notification.CalendarNotifyClient.RegisterSendMethod, ASC.Api.Calendar" />
|
||||
<scheduler name="Projects" register="ASC.Web.Projects.Configuration.ProductEntryPoint.RegisterSendMethods, ASC.Web.Projects" />
|
||||
<scheduler name="Birthdays" register="ASC.Web.Community.Birthdays.BirthdaysModule.RegisterSendMethod, ASC.Web.Community" />
|
||||
<scheduler name="CRM" register="ASC.Web.CRM.Configuration.ProductEntryPoint.RegisterSendMethods, ASC.Web.CRM" />
|
||||
</schedulers>
|
||||
</notify>
|
||||
<feed aggregatePeriod="0:3:0" />
|
||||
<autoreply mailFolder="..\..\Logs\" />
|
||||
<socketio path="..\ASC.Socket.IO" port="9899">
|
||||
<redis host="" port="" />
|
||||
</socketio>
|
||||
<urlshortener path="..\ASC.UrlShortener" port="9999" />
|
||||
<thumb path="..\ASC.Thumbnails" port="9800" />
|
||||
<ssoauth path="..\ASC.SsoAuth" port="9834" />
|
||||
<radicale path="">
|
||||
</radicale>
|
||||
<thumbnailBuilder connectionStringName="default" serverRoot="http://localhost/" attemptsLimit="10" />
|
||||
<system.serviceModel>
|
||||
<services>
|
||||
<service name="ASC.ElasticSearch.Service.Service" behaviorConfiguration="index">
|
||||
<endpoint address="net.tcp://0:9866/teamlabIndex" binding="netTcpBinding" contract="ASC.ElasticSearch.Service.IService" bindingConfiguration="index" />
|
||||
</service>
|
||||
<service name="ASC.Notify.NotifyService" behaviorConfiguration="notify">
|
||||
<endpoint address="net.tcp://0:9871/teamlabNotify" binding="netTcpBinding" contract="ASC.Notify.INotifyService" bindingConfiguration="notify" />
|
||||
</service>
|
||||
<service name="ASC.Data.Backup.Service.BackupService" behaviorConfiguration="backup">
|
||||
<endpoint address="net.tcp://0:9882/teamlabBackup" binding="netTcpBinding" contract="ASC.Core.Common.Contracts.IBackupService" bindingConfiguration="backup" />
|
||||
</service>
|
||||
<service name="ASC.Data.Storage.Migration.Service" behaviorConfiguration="migrate">
|
||||
<endpoint address="net.tcp://0:9883/teamlabStorageMigrate" binding="netTcpBinding" contract="ASC.Data.Storage.Migration.IService" bindingConfiguration="migrate" />
|
||||
</service>
|
||||
<service name="ASC.Data.Storage.Encryption.EncryptionService" behaviorConfiguration="encryption">
|
||||
<endpoint address="net.tcp://0:9884/teamlabStorageEncryption" binding="netTcpBinding" contract="ASC.Data.Storage.Encryption.IEncryptionService" bindingConfiguration="encryption" />
|
||||
</service>
|
||||
<service name="ASC.TelegramService.TelegramService" behaviorConfiguration="telegram">
|
||||
<endpoint address="net.tcp://0:9885/teamlabTelegram" binding="netTcpBinding" contract="ASC.Core.Common.Notify.ITelegramService" bindingConfiguration="telegram" />
|
||||
</service>
|
||||
<service name="ASC.Files.ThumbnailBuilder.Service" behaviorConfiguration="thumbnailBuilder">
|
||||
<endpoint address="net.tcp://0:9886/teamlabThumbnailBuilder" binding="netTcpBinding" contract="ASC.Web.Core.Files.IThumbnailBuilderService" bindingConfiguration="thumbnailBuilder" />
|
||||
</service>
|
||||
<service name="ASC.Feed.Aggregator.HealthCheckService" behaviorConfiguration="feed">
|
||||
<endpoint address="http://localhost:9808/teamlabFeed/health" binding="webHttpBinding" contract="ASC.Core.Common.Contracts.IHealthCheckService" behaviorConfiguration="Web" />
|
||||
</service>
|
||||
</services>
|
||||
<bindings>
|
||||
<netTcpBinding>
|
||||
<binding name="jabber" maxReceivedMessageSize="1000000" maxBufferSize="1000000" maxBufferPoolSize="1000000" maxConnections="1000000" portSharingEnabled="false" transactionFlow="false" listenBacklog="1000000">
|
||||
<security mode="None">
|
||||
<message clientCredentialType="None" />
|
||||
<transport protectionLevel="None" clientCredentialType="None" />
|
||||
</security>
|
||||
<reliableSession enabled="false" />
|
||||
<readerQuotas maxStringContentLength="1000000" maxArrayLength="1000000" />
|
||||
</binding>
|
||||
<binding name="signalr" maxReceivedMessageSize="1000000" maxBufferSize="1000000" maxBufferPoolSize="1000000" maxConnections="1000000" portSharingEnabled="false" transactionFlow="false" listenBacklog="1000000">
|
||||
<security mode="None">
|
||||
<message clientCredentialType="None" />
|
||||
<transport protectionLevel="None" clientCredentialType="None" />
|
||||
</security>
|
||||
<reliableSession enabled="false" />
|
||||
<readerQuotas maxStringContentLength="1000000" maxArrayLength="1000000" />
|
||||
</binding>
|
||||
<binding name="index" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="notify" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="backup" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="migrate" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="encryption" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="telegram" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="thumbnailBuilder" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
</netTcpBinding>
|
||||
</bindings>
|
||||
<client>
|
||||
<endpoint address="net.tcp://localhost:9865/teamlabJabber" binding="netTcpBinding" contract="ASC.Core.Notify.Jabber.IJabberService" bindingConfiguration="jabber" />
|
||||
<endpoint address="net.tcp://localhost:9871/teamlabNotify" binding="netTcpBinding" contract="ASC.Notify.INotifyService" bindingConfiguration="notify" />
|
||||
<endpoint address="net.tcp://localhost:9882/teamlabBackup" binding="netTcpBinding" contract="ASC.Core.Common.Contracts.IBackupService" bindingConfiguration="backup" />
|
||||
<endpoint address="net.tcp://localhost:9866/teamlabIndex" binding="netTcpBinding" contract="ASC.ElasticSearch.Service.IService" bindingConfiguration="index" />
|
||||
<endpoint address="net.tcp://localhost:9884/teamlabStorageEncryption" binding="netTcpBinding" contract="ASC.Data.Storage.Encryption.IEncryptionService" bindingConfiguration="encryption" />
|
||||
<endpoint address="net.tcp://localhost:9885/teamlabTelegram" binding="netTcpBinding" contract="ASC.Core.Common.Notify.ITelegramService" bindingConfiguration="telegram" />
|
||||
<endpoint address="net.tcp://localhost:9886/teamlabThumbnailBuilder" binding="netTcpBinding" contract="ASC.Web.Core.Files.IThumbnailBuilderService" bindingConfiguration="thumbnailBuilder" />
|
||||
</client>
|
||||
<behaviors>
|
||||
<serviceBehaviors>
|
||||
<behavior name="feed">
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="index">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabIndex" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="notify">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabNotify" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="backup">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabBackup" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="migrate">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabStorageMigrate" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="encryption">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabStorageEncryption" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="telegram">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabTelegram" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="thumbnailBuilder">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabThumbnailBuilder" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="jabber">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabJabber" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="200" />
|
||||
</behavior>
|
||||
</serviceBehaviors>
|
||||
<endpointBehaviors>
|
||||
<behavior name="Web">
|
||||
<webHttp />
|
||||
</behavior>
|
||||
</endpointBehaviors>
|
||||
</behaviors>
|
||||
</system.serviceModel>
|
||||
<system.net>
|
||||
<connectionManagement>
|
||||
<add address="*" maxconnection="96" />
|
||||
</connectionManagement>
|
||||
</system.net>
|
||||
<storage file="..\..\WebStudio\web.storage.config" />
|
||||
<log4net>
|
||||
<addProperty os="UNIX">
|
||||
<key>UNIX:LogDirectory</key>
|
||||
<value>/var/log/onlyoffice/</value>
|
||||
</addProperty>
|
||||
<addProperty os="WINDOWS">
|
||||
<key>WINDOWS:LogDirectory</key>
|
||||
<value>..\..\Logs\</value>
|
||||
</addProperty>
|
||||
<logger name="ASC">
|
||||
<appender-ref ref="File" />
|
||||
<appender-ref ref="Console" />
|
||||
<level value="WARN" />
|
||||
</logger>
|
||||
<logger name="ASC.SQL" additivity="false">
|
||||
<level value="OFF" />
|
||||
</logger>
|
||||
<appender name="Console" type="log4net.Appender.ConsoleAppender">
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %-5level %logger - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="File" type="ASC.Common.Logging.SelfCleaningAppender, ASC.Common">
|
||||
<file type="log4net.Util.PatternString">
|
||||
<converter>
|
||||
<name value="folder" />
|
||||
<type value="ASC.Common.Logging.SpecialFolderPathConverter, ASC.Common" />
|
||||
</converter>
|
||||
<conversionPattern value="%folder{LogDirectory}svc%folder{CommandLine:--log}" />
|
||||
</file>
|
||||
<encoding value="utf-8" />
|
||||
<staticLogFileName value="false" />
|
||||
<preserveLogFileNameExtension value="true" />
|
||||
<rollingStyle value="Composite" />
|
||||
<datePattern value=".MM-dd.lo\g" />
|
||||
<maximumFileSize value="50MB" />
|
||||
<maxSizeRollBackups value="-1" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %-5level [%thread] %logger - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="Sql" type="ASC.Common.Logging.SelfCleaningAppender, ASC.Common">
|
||||
<file type="log4net.Util.PatternString">
|
||||
<converter>
|
||||
<name value="folder" />
|
||||
<type value="ASC.Common.Logging.SpecialFolderPathConverter, ASC.Common" />
|
||||
</converter>
|
||||
<conversionPattern value="%folder{LogDirectory}svc%folder{CommandLine:--log}.sql.log" />
|
||||
</file>
|
||||
<encoding value="utf-8" />
|
||||
<staticLogFileName value="false" />
|
||||
<preserveLogFileNameExtension value="true" />
|
||||
<rollingStyle value="Composite" />
|
||||
<datePattern value=".MM-dd" />
|
||||
<maximumFileSize value="50MB" />
|
||||
<maxSizeRollBackups value="-1" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%utcdate|%thread|%property{duration}|%message|%property{sql}|%property{sqlParams}%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
</log4net>
|
||||
<nlog>
|
||||
<extensions>
|
||||
<add assembly="ASC.Common" />
|
||||
</extensions>
|
||||
<variable name="logDirectory" value="..\..\Logs\" />
|
||||
<variable name="svcName" value="" />
|
||||
<conversionPattern value="" />
|
||||
<targets async="true">
|
||||
<default-target-parameters type="SelfCleaning" encoding="utf-8" archiveNumbering="DateAndSequence" archiveEvery="Day" archiveAboveSize="52428800" archiveDateFormat="MM-dd" keepFileOpen="true" enableArchiveFileCompression="true" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message} ${exception:format=ToString}" />
|
||||
<target name="Console" type="Console" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message}" />
|
||||
<target name="web" type="SelfCleaning" fileName="${logDirectory}svc${var:svcName}.log" />
|
||||
<target name="indexer" type="SelfCleaning" fileName="${logDirectory}svcIndexer.data.log" />
|
||||
<target name="sql" type="SelfCleaning" fileName="${logDirectory}svc${var:svcName}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=duration}|${message}|${event-properties:item=sql}|${event-properties:item=sqlParams}" />
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="ASC.SQL" minlevel="Warn" writeTo="" final="true" />
|
||||
<logger name="ASC.Indexer" minlevel="Error" writeTo="indexer,Console" final="true" />
|
||||
<logger name="ASC*" minlevel="Warn" writeTo="web,Console" />
|
||||
</rules>
|
||||
</nlog>
|
||||
<consumers configSource="web.consumers.config" />
|
||||
<autofac configSource="web.autofac.config" />
|
||||
<redisCacheClient ssl="false" connectTimeout="5000" database="0" password="">
|
||||
<hosts>
|
||||
<add host="127.0.0.1" cachePort="6379" />
|
||||
</hosts>
|
||||
</redisCacheClient>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="teamlab" type="ASC.TeamLabSvc.Configuration.TeamLabSvcConfigurationSection, TeamLabSvc" />
|
||||
<section name="notify" type="ASC.Notify.Config.NotifyServiceCfgSectionHandler, ASC.Notify" />
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
|
||||
<section name="storage" type="ASC.Data.Storage.Configuration.StorageConfigurationSection, ASC.Data.Storage" />
|
||||
<section name="backup" type="ASC.Data.Backup.Service.BackupConfigurationSection, ASC.Data.Backup" />
|
||||
<section name="autoreply" type="ASC.Mail.Autoreply.AutoreplyServiceConfiguration, ASC.Mail.Autoreply" />
|
||||
<section name="feed" type="ASC.Feed.Aggregator.Config.FeedConfigurationSection, ASC.Feed.Aggregator" />
|
||||
<section name="healthCheck" type="ASC.HealthCheck.Settings.HealthCheckCfgSectionHandler, ASC.HealthCheck" />
|
||||
<section name="socketio" type="ASC.Socket.IO.Svc.SocketIOCfgSectionHandler, ASC.Socket.IO.Svc" />
|
||||
<section name="thumb" type="ASC.Thumbnails.Svc.ConfigHandler, ASC.Thumbnails.Svc" />
|
||||
<section name="ssoauth" type="ASC.SsoAuth.Svc.ConfigHandler, ASC.SsoAuth.Svc" />
|
||||
<section name="urlshortener" type="ASC.UrlShortener.Svc.ConfigHandler, ASC.UrlShortener.Svc" />
|
||||
<section name="radicale" type="ASC.Radicale.RadicaleCfgSectionHandler, ASC.Radicale" />
|
||||
<section name="apiClient" type="ASC.Api.Client.ApiClientConfiguration, ASC.Api.Client" />
|
||||
<section name="autofac" type="ASC.Common.DependencyInjection.AutofacConfigurationSection, ASC.Common" />
|
||||
<section name="consumers" type="ASC.Core.Common.Configuration.ConsumerConfigurationSection, ASC.Core.Common" />
|
||||
<section name="thumbnailBuilder" type="ASC.Files.ThumbnailBuilder.ConfigSection, ASC.Files.ThumbnailBuilder" />
|
||||
<section name="redisCacheClient" type="StackExchange.Redis.Extensions.LegacyConfiguration.RedisCachingSectionHandler, StackExchange.Redis.Extensions.LegacyConfiguration" />
|
||||
</configSections>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.8.6.1" newVersion="1.8.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Api.Gax" culture="neutral" publicKeyToken="3ec5ea7f18953e47" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Api.Gax.Rest" culture="neutral" publicKeyToken="3ec5ea7f18953e47" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.0" newVersion="1.45.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis.Auth" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.0" newVersion="1.45.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis.Core" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.0" newVersion="1.45.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Apis.Storage.v1" culture="neutral" publicKeyToken="4b01fa6e34db77ab" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.45.0.1911" newVersion="1.45.0.1911" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Protobuf" culture="neutral" publicKeyToken="a7d26565bac4d604" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.11.4.0" newVersion="3.11.4.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="log4net" culture="neutral" publicKeyToken="669e0ddf0bb1aa2a" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" culture="neutral" publicKeyToken="adb9793829ddae60" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="BouncyCastle.Crypto" culture="neutral" publicKeyToken="0e99375e54769942" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.8.5.0" newVersion="1.8.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="StackExchange.Redis.Extensions.Core" culture="neutral" publicKeyToken="d7d863643bcd13ef" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<clear />
|
||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
<appSettings>
|
||||
<add key="core.base-domain" value="localhost" />
|
||||
<add key="core.machinekey" value="Vskoproizvolny Salt par Chivreski" />
|
||||
<add key="files.docservice.secret" value="" />
|
||||
<add key="files.docservice.secret.header" value="" />
|
||||
<add key="files.docservice.timeout" value="50000" />
|
||||
<add key="files.docservice.url.public" value="" />
|
||||
<add key="files.docservice.url.internal" value="" />
|
||||
<add key="files.docservice.url.portal" value="" />
|
||||
<add key="files.index.formats" value=".pptx|.xlsx|.docx" />
|
||||
<add key="messaging.enabled" value="true" />
|
||||
<add key="temp" value="..\..\Data\temp" />
|
||||
<add key="web.help-center" value="https://helpcenter.onlyoffice.com/{ru|de|fr|es|lv|it}" />
|
||||
<add key="web.hub.internal" value="http://localhost:9899/" />
|
||||
<add key="web.controlpanel.url" value="" />
|
||||
<add key="license.file.path" value="" />
|
||||
<add key="resources.from-db" value="true" />
|
||||
<add key="mail.certificate-permit" value="true" />
|
||||
</appSettings>
|
||||
<connectionStrings>
|
||||
<clear />
|
||||
<add name="default" connectionString="Server=localhost;Database=onlyoffice;User ID=root;Password=;Pooling=True;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=true;Connection Timeout=30;Maximum Pool Size=300;" providerName="MySql.Data.MySqlClient" />
|
||||
</connectionStrings>
|
||||
<teamlab>
|
||||
<services>
|
||||
<add type="ASC.Socket.IO.Svc.Launcher, ASC.Socket.IO.Svc" />
|
||||
<add type="ASC.Radicale.Launcher, ASC.Radicale" />
|
||||
<add type="ASC.Notify.NotifyServiceLauncher, ASC.Notify" />
|
||||
<add type="ASC.Feed.Aggregator.FeedAggregatorLauncher, ASC.Feed.Aggregator" />
|
||||
<add type="ASC.Data.Backup.Service.BackupServiceLauncher, ASC.Data.Backup" />
|
||||
<!-- <add type="ASC.Mail.Autoreply.AutoreplyServiceController, ASC.Mail.Autoreply"/> -->
|
||||
<add type="ASC.Data.Storage.Migration.Launcher, ASC.Data.Storage.Migration" />
|
||||
<add type="ASC.ElasticSearch.Launcher, ASC.ElasticSearch" />
|
||||
<add type="ASC.Thumbnails.Svc.Launcher, ASC.Thumbnails.Svc" />
|
||||
<add type="ASC.SsoAuth.Svc.Launcher, ASC.SsoAuth.Svc" />
|
||||
<add type="ASC.UrlShortener.Svc.Launcher, ASC.UrlShortener.Svc" />
|
||||
<add type="ASC.TelegramService.Launcher, ASC.TelegramService" />
|
||||
<add type="ASC.Data.Storage.Encryption.Launcher, ASC.Data.Storage.Encryption" />
|
||||
<add type="ASC.Files.ThumbnailBuilder.Launcher, ASC.Files.ThumbnailBuilder" />
|
||||
</services>
|
||||
</teamlab>
|
||||
<apiClient root="/api/2.0/" scheme="Http" />
|
||||
<notify connectionStringName="default">
|
||||
<process maxThreads="2" bufferSize="10" maxAttempts="10" attemptsInterval="0:5:0" />
|
||||
<senders>
|
||||
<sender name="email.sender" type="ASC.Core.Notify.Senders.SmtpSender, ASC.Core.Common" host="" port="" userName="" password="" enableSsl="" useCoreSettings="true" />
|
||||
<sender name="messanger.sender" type="ASC.Core.Notify.Senders.JabberSender, ASC.Core.Common" />
|
||||
<sender name="telegram.sender" type="ASC.Core.Notify.Senders.TelegramSender, ASC.Core.Common" />
|
||||
</senders>
|
||||
<schedulers>
|
||||
<scheduler name="WhatsNew" register="ASC.Web.Studio.Core.Notify.NotifyConfiguration.RegisterSendMethods, ASC.Web.Studio" />
|
||||
<scheduler name="Calendar" register="ASC.Api.Calendar.Notification.CalendarNotifyClient.RegisterSendMethod, ASC.Api.Calendar" />
|
||||
<scheduler name="Projects" register="ASC.Web.Projects.Configuration.ProductEntryPoint.RegisterSendMethods, ASC.Web.Projects" />
|
||||
<scheduler name="Birthdays" register="ASC.Web.Community.Birthdays.BirthdaysModule.RegisterSendMethod, ASC.Web.Community" />
|
||||
<scheduler name="CRM" register="ASC.Web.CRM.Configuration.ProductEntryPoint.RegisterSendMethods, ASC.Web.CRM" />
|
||||
</schedulers>
|
||||
</notify>
|
||||
<backup>
|
||||
<cleaner />
|
||||
<scheduler />
|
||||
</backup>
|
||||
<feed aggregatePeriod="0:3:0" />
|
||||
<autoreply mailFolder="..\..\Logs\" />
|
||||
<socketio path="..\ASC.Socket.IO" port="9899">
|
||||
<redis host="" port="" />
|
||||
</socketio>
|
||||
<urlshortener path="..\ASC.UrlShortener" port="9999" />
|
||||
<thumb path="..\ASC.Thumbnails" port="9800" />
|
||||
<ssoauth path="..\ASC.SsoAuth" port="9834" />
|
||||
<radicale path="">
|
||||
</radicale>
|
||||
<thumbnailBuilder connectionStringName="default" serverRoot="http://localhost/" attemptsLimit="10" />
|
||||
<system.serviceModel>
|
||||
<services>
|
||||
<service name="ASC.ElasticSearch.Service.Service" behaviorConfiguration="index">
|
||||
<endpoint address="net.tcp://0:9866/teamlabIndex" binding="netTcpBinding" contract="ASC.ElasticSearch.Service.IService" bindingConfiguration="index" />
|
||||
</service>
|
||||
<service name="ASC.Notify.NotifyService" behaviorConfiguration="notify">
|
||||
<endpoint address="net.tcp://0:9871/teamlabNotify" binding="netTcpBinding" contract="ASC.Notify.INotifyService" bindingConfiguration="notify" />
|
||||
</service>
|
||||
<service name="ASC.Data.Backup.Service.BackupService" behaviorConfiguration="backup">
|
||||
<endpoint address="net.tcp://0:9882/teamlabBackup" binding="netTcpBinding" contract="ASC.Core.Common.Contracts.IBackupService" bindingConfiguration="backup" />
|
||||
</service>
|
||||
<service name="ASC.Data.Storage.Migration.Service" behaviorConfiguration="migrate">
|
||||
<endpoint address="net.tcp://0:9883/teamlabStorageMigrate" binding="netTcpBinding" contract="ASC.Data.Storage.Migration.IService" bindingConfiguration="migrate" />
|
||||
</service>
|
||||
<service name="ASC.Data.Storage.Encryption.EncryptionService" behaviorConfiguration="encryption">
|
||||
<endpoint address="net.tcp://0:9884/teamlabStorageEncryption" binding="netTcpBinding" contract="ASC.Data.Storage.Encryption.IEncryptionService" bindingConfiguration="encryption" />
|
||||
</service>
|
||||
<service name="ASC.TelegramService.TelegramService" behaviorConfiguration="telegram">
|
||||
<endpoint address="net.tcp://0:9885/teamlabTelegram" binding="netTcpBinding" contract="ASC.Core.Common.Notify.ITelegramService" bindingConfiguration="telegram" />
|
||||
</service>
|
||||
<service name="ASC.Files.ThumbnailBuilder.Service" behaviorConfiguration="thumbnailBuilder">
|
||||
<endpoint address="net.tcp://0:9886/teamlabThumbnailBuilder" binding="netTcpBinding" contract="ASC.Web.Core.Files.IThumbnailBuilderService" bindingConfiguration="thumbnailBuilder" />
|
||||
</service>
|
||||
<service name="ASC.Feed.Aggregator.HealthCheckService" behaviorConfiguration="feed">
|
||||
<endpoint address="http://localhost:9808/teamlabFeed/health" binding="webHttpBinding" contract="ASC.Core.Common.Contracts.IHealthCheckService" behaviorConfiguration="Web" />
|
||||
</service>
|
||||
</services>
|
||||
<bindings>
|
||||
<netTcpBinding>
|
||||
<binding name="jabber" maxReceivedMessageSize="1000000" maxBufferSize="1000000" maxBufferPoolSize="1000000" maxConnections="1000000" portSharingEnabled="false" transactionFlow="false" listenBacklog="1000000">
|
||||
<security mode="None">
|
||||
<message clientCredentialType="None" />
|
||||
<transport protectionLevel="None" clientCredentialType="None" />
|
||||
</security>
|
||||
<reliableSession enabled="false" />
|
||||
<readerQuotas maxStringContentLength="1000000" maxArrayLength="1000000" />
|
||||
</binding>
|
||||
<binding name="signalr" maxReceivedMessageSize="1000000" maxBufferSize="1000000" maxBufferPoolSize="1000000" maxConnections="1000000" portSharingEnabled="false" transactionFlow="false" listenBacklog="1000000">
|
||||
<security mode="None">
|
||||
<message clientCredentialType="None" />
|
||||
<transport protectionLevel="None" clientCredentialType="None" />
|
||||
</security>
|
||||
<reliableSession enabled="false" />
|
||||
<readerQuotas maxStringContentLength="1000000" maxArrayLength="1000000" />
|
||||
</binding>
|
||||
<binding name="index" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="notify" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="backup" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="migrate" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="encryption" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="telegram" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
<binding name="thumbnailBuilder" openTimeout="0:0:10" receiveTimeout="0:0:10" sendTimeout="0:0:10">
|
||||
<security mode="None" />
|
||||
<readerQuotas maxStringContentLength="1000000" />
|
||||
</binding>
|
||||
</netTcpBinding>
|
||||
</bindings>
|
||||
<client>
|
||||
<endpoint address="net.tcp://localhost:9865/teamlabJabber" binding="netTcpBinding" contract="ASC.Core.Notify.Jabber.IJabberService" bindingConfiguration="jabber" />
|
||||
<endpoint address="net.tcp://localhost:9871/teamlabNotify" binding="netTcpBinding" contract="ASC.Notify.INotifyService" bindingConfiguration="notify" />
|
||||
<endpoint address="net.tcp://localhost:9882/teamlabBackup" binding="netTcpBinding" contract="ASC.Core.Common.Contracts.IBackupService" bindingConfiguration="backup" />
|
||||
<endpoint address="net.tcp://localhost:9866/teamlabIndex" binding="netTcpBinding" contract="ASC.ElasticSearch.Service.IService" bindingConfiguration="index" />
|
||||
<endpoint address="net.tcp://localhost:9884/teamlabStorageEncryption" binding="netTcpBinding" contract="ASC.Data.Storage.Encryption.IEncryptionService" bindingConfiguration="encryption" />
|
||||
<endpoint address="net.tcp://localhost:9885/teamlabTelegram" binding="netTcpBinding" contract="ASC.Core.Common.Notify.ITelegramService" bindingConfiguration="telegram" />
|
||||
<endpoint address="net.tcp://localhost:9886/teamlabThumbnailBuilder" binding="netTcpBinding" contract="ASC.Web.Core.Files.IThumbnailBuilderService" bindingConfiguration="thumbnailBuilder" />
|
||||
</client>
|
||||
<behaviors>
|
||||
<serviceBehaviors>
|
||||
<behavior name="feed">
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="index">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabIndex" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="notify">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabNotify" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="backup">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabBackup" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="migrate">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabStorageMigrate" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="encryption">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabStorageEncryption" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="telegram">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabTelegram" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="thumbnailBuilder">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabThumbnailBuilder" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
<behavior name="jabber">
|
||||
<serviceHealth httpGetEnabled="true" httpGetUrl="http://localhost:9810/teamlabJabber" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="200" />
|
||||
</behavior>
|
||||
</serviceBehaviors>
|
||||
<endpointBehaviors>
|
||||
<behavior name="Web">
|
||||
<webHttp />
|
||||
</behavior>
|
||||
</endpointBehaviors>
|
||||
</behaviors>
|
||||
</system.serviceModel>
|
||||
<system.net>
|
||||
<connectionManagement>
|
||||
<add address="*" maxconnection="96" />
|
||||
</connectionManagement>
|
||||
</system.net>
|
||||
<storage file="..\..\WebStudio\web.storage.config" />
|
||||
<log4net>
|
||||
<addProperty os="UNIX">
|
||||
<key>UNIX:LogDirectory</key>
|
||||
<value>/var/log/onlyoffice/</value>
|
||||
</addProperty>
|
||||
<addProperty os="WINDOWS">
|
||||
<key>WINDOWS:LogDirectory</key>
|
||||
<value>..\..\Logs\</value>
|
||||
</addProperty>
|
||||
<logger name="ASC">
|
||||
<appender-ref ref="File" />
|
||||
<appender-ref ref="Console" />
|
||||
<level value="WARN" />
|
||||
</logger>
|
||||
<logger name="ASC.SQL" additivity="false">
|
||||
<level value="OFF" />
|
||||
</logger>
|
||||
<appender name="Console" type="log4net.Appender.ConsoleAppender">
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %-5level %logger - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="File" type="ASC.Common.Logging.SelfCleaningAppender, ASC.Common">
|
||||
<file type="log4net.Util.PatternString">
|
||||
<converter>
|
||||
<name value="folder" />
|
||||
<type value="ASC.Common.Logging.SpecialFolderPathConverter, ASC.Common" />
|
||||
</converter>
|
||||
<conversionPattern value="%folder{LogDirectory}svc%folder{CommandLine:--log}" />
|
||||
</file>
|
||||
<encoding value="utf-8" />
|
||||
<staticLogFileName value="false" />
|
||||
<preserveLogFileNameExtension value="true" />
|
||||
<rollingStyle value="Composite" />
|
||||
<datePattern value=".MM-dd.lo\g" />
|
||||
<maximumFileSize value="50MB" />
|
||||
<maxSizeRollBackups value="-1" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %-5level [%thread] %logger - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="Sql" type="ASC.Common.Logging.SelfCleaningAppender, ASC.Common">
|
||||
<file type="log4net.Util.PatternString">
|
||||
<converter>
|
||||
<name value="folder" />
|
||||
<type value="ASC.Common.Logging.SpecialFolderPathConverter, ASC.Common" />
|
||||
</converter>
|
||||
<conversionPattern value="%folder{LogDirectory}svc%folder{CommandLine:--log}.sql.log" />
|
||||
</file>
|
||||
<encoding value="utf-8" />
|
||||
<staticLogFileName value="false" />
|
||||
<preserveLogFileNameExtension value="true" />
|
||||
<rollingStyle value="Composite" />
|
||||
<datePattern value=".MM-dd" />
|
||||
<maximumFileSize value="50MB" />
|
||||
<maxSizeRollBackups value="-1" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%utcdate|%thread|%property{duration}|%message|%property{sql}|%property{sqlParams}%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
</log4net>
|
||||
<nlog>
|
||||
<extensions>
|
||||
<add assembly="ASC.Common" />
|
||||
</extensions>
|
||||
<variable name="logDirectory" value="..\..\Logs\" />
|
||||
<variable name="svcName" value="" />
|
||||
<conversionPattern value="" />
|
||||
<targets async="true">
|
||||
<default-target-parameters type="SelfCleaning" encoding="utf-8" archiveNumbering="DateAndSequence" archiveEvery="Day" archiveAboveSize="52428800" archiveDateFormat="MM-dd" keepFileOpen="true" enableArchiveFileCompression="true" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message} ${exception:format=ToString}" />
|
||||
<target name="Console" type="Console" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message}" />
|
||||
<target name="web" type="SelfCleaning" fileName="${logDirectory}svc${var:svcName}.log" />
|
||||
<target name="indexer" type="SelfCleaning" fileName="${logDirectory}svcIndexer.data.log" />
|
||||
<target name="sql" type="SelfCleaning" fileName="${logDirectory}svc${var:svcName}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=sqlThread}|${event-properties:item=duration}|${message}|${event-properties:item=sql}|${event-properties:item=sqlParams}" />
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="ASC.SQL" minlevel="Warn" writeTo="" final="true" />
|
||||
<logger name="ASC.Indexer" minlevel="Error" writeTo="indexer,Console" final="true" />
|
||||
<logger name="ASC*" minlevel="Warn" writeTo="web,Console" />
|
||||
</rules>
|
||||
</nlog>
|
||||
<consumers configSource="web.consumers.config" />
|
||||
<autofac configSource="web.autofac.config" />
|
||||
<redisCacheClient ssl="false" connectTimeout="5000" database="0" password="">
|
||||
<hosts>
|
||||
<add host="127.0.0.1" cachePort="6379" />
|
||||
</hosts>
|
||||
</redisCacheClient>
|
||||
</configuration>
|
@ -2,7 +2,7 @@ dictionary = { "teamlabNotify" => 9811, "teamlabBackup" => 9812, "teamlabIndex"
|
||||
|
||||
%w{Notify Backup Index StorageMigrate Telegram StorageEncryption ThumbnailBuilder MailCleaner MailWatchdog Feed}.each do |serviceName|
|
||||
God.watch do |w|
|
||||
w.name = serviceName
|
||||
w.name = "onlyoffice#{serviceName}"
|
||||
w.group = "onlyoffice"
|
||||
w.grace = 15.seconds
|
||||
w.start = "systemctl start onlyoffice#{serviceName}"
|
||||
|
@ -78,6 +78,9 @@ server {
|
||||
server {
|
||||
listen 0.0.0.0:443 ssl http2;
|
||||
listen [::]:443 ssl http2 default_server;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
server_tokens off;
|
||||
|
||||
## Increase this if you want to upload large attachments
|
||||
|
@ -43,6 +43,8 @@ map $request_uri $header_x_frame_options {
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
add_header Access-Control-Allow-Origin $header_access_control_allow_origin;
|
||||
add_header X-Frame-Options $header_x_frame_options;
|
||||
|
||||
|
@ -43,6 +43,8 @@ map $request_uri $header_x_frame_options {
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
add_header Access-Control-Allow-Origin $header_access_control_allow_origin;
|
||||
add_header X-Frame-Options $header_x_frame_options;
|
||||
|
||||
|
@ -1,220 +1,220 @@
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: {{package_sysname}}-communityserver
|
||||
Source: {{package_header_tag_url}}
|
||||
|
||||
Files: *
|
||||
Copyright: {{package_header_tag_vendor}}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: {{package_sysname}}-communityserver
|
||||
Source: {{package_header_tag_url}}
|
||||
|
||||
Files: *
|
||||
Copyright: {{package_header_tag_vendor}}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -40,7 +40,7 @@ apply_connection_string(){
|
||||
if [ -d /var/www/{{package_sysname}}/ ]; then
|
||||
for i in "${!binDirs[@]}";
|
||||
do
|
||||
find "/var/www/{{package_sysname}}/${binDirs[$i]}" -type f -name "*.[cC]onfig" -exec sed -i "s/connectionString=.*/connectionString=\"Server=$DB_HOST;Database=$DB_NAME;User ID=$DB_USER;Password=$DB_PWD;Pooling=true;Character Set=utf8;AutoEnlist=false\" providerName=\"MySql.Data.MySqlClient\"\/>/" {} \;
|
||||
find "/var/www/{{package_sysname}}/${binDirs[$i]}" -type f -name "*.[cC]onfig" -exec sed -i "s/connectionString=.*/connectionString=\"Server=$DB_HOST;Database=$DB_NAME;User ID=$DB_USER;Password=$DB_PWD;Pooling=true;Character Set=utf8;AutoEnlist=false;SSL Mode=none;AllowPublicKeyRetrieval=true;Connection Timeout=30;Maximum Pool Size=300;\" providerName=\"MySql.Data.MySqlClient\"\/>/" {} \;
|
||||
done
|
||||
fi
|
||||
|
||||
@ -264,7 +264,7 @@ END
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade requests
|
||||
python3 -m pip install --upgrade radicale
|
||||
python3 -m pip install --upgrade radicale==3.0.5
|
||||
python3 -m pip install --upgrade $DIR/Tools/radicale/plugins/app_auth_plugin/.
|
||||
python3 -m pip install --upgrade $DIR/Tools/radicale/plugins/app_store_plugin/.
|
||||
python3 -m pip install --upgrade $DIR/Tools/radicale/plugins/app_rights_plugin/.
|
||||
@ -305,6 +305,12 @@ END
|
||||
if grep -q "HeapDumpOnOutOfMemoryError" /etc/elasticsearch/jvm.options; then
|
||||
sed "/-XX:+HeapDumpOnOutOfMemoryError/d" -i /etc/elasticsearch/jvm.options
|
||||
fi
|
||||
|
||||
if ! grep -q "Dlog4j2.formatMsgNoLookups" /etc/elasticsearch/jvm.options; then
|
||||
echo "-Dlog4j2.formatMsgNoLookups=true" >> /etc/elasticsearch/jvm.options
|
||||
else
|
||||
sed -i "s/Dlog4j2.formatMsgNoLookups.*/Dlog4j2.formatMsgNoLookups=true/" /etc/elasticsearch/jvm.options
|
||||
fi
|
||||
|
||||
TOTAL_MEMORY=$(free -m | grep -oP '\d+' | head -n 1);
|
||||
MEMORY_REQUIREMENTS=12228; #RAM ~4*3Gb
|
||||
@ -416,6 +422,11 @@ EOF
|
||||
if dpkg -l | grep -q "{{package_sysname}}-xmppserver"; then
|
||||
sed '/web\.talk/s/value=\"\S*\"/value=\"true\"/g' -i ${APP_ROOT_DIR}/web.appsettings.config
|
||||
fi
|
||||
|
||||
if [ -f /etc/god/conf.d/{{package_sysname}}.god ]; then
|
||||
rm -rf /etc/god/conf.d/{{package_sysname}}.god
|
||||
service god restart >/dev/null 2>&1
|
||||
fi
|
||||
# end
|
||||
|
||||
# call db_stop to prevent installation hang
|
||||
|
@ -2,7 +2,7 @@ dictionary = { "teamlabNotify" => 9811, "teamlabBackup" => 9812, "teamlabIndex"
|
||||
|
||||
%w{Notify Backup Index StorageMigrate Telegram StorageEncryption ThumbnailBuilder MailCleaner MailWatchdog Feed}.each do |serviceName|
|
||||
God.watch do |w|
|
||||
w.name = serviceName
|
||||
w.name = "onlyoffice#{serviceName}"
|
||||
w.group = "onlyoffice"
|
||||
w.grace = 15.seconds
|
||||
w.start = "systemctl start onlyoffice#{serviceName}"
|
||||
|
@ -49,6 +49,7 @@ map $request_uri $header_x_frame_options {
|
||||
server {
|
||||
listen 0.0.0.0:80 default_server;
|
||||
listen [::]:80;
|
||||
|
||||
server_name _;
|
||||
server_tokens off;
|
||||
|
||||
@ -78,6 +79,9 @@ server {
|
||||
server {
|
||||
listen 0.0.0.0:443 ssl http2;
|
||||
listen [::]:443 ssl http2 default_server;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
server_tokens off;
|
||||
|
||||
## Increase this if you want to upload large attachments
|
||||
|
@ -43,6 +43,8 @@ map $request_uri $header_x_frame_options {
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
add_header Access-Control-Allow-Origin $header_access_control_allow_origin;
|
||||
add_header X-Frame-Options $header_x_frame_options;
|
||||
|
||||
|
@ -44,6 +44,8 @@ map $request_uri $header_x_frame_options {
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
charset utf-8;
|
||||
|
||||
add_header Access-Control-Allow-Origin $header_access_control_allow_origin;
|
||||
add_header X-Frame-Options $header_x_frame_options;
|
||||
|
||||
|
@ -152,7 +152,7 @@ DIR="/var/www/%{package_sysname}"
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install --upgrade requests
|
||||
python3 -m pip install --upgrade radicale
|
||||
python3 -m pip install --upgrade radicale==3.0.5
|
||||
python3 -m pip install --upgrade $DIR/Tools/radicale/plugins/app_auth_plugin/.
|
||||
python3 -m pip install --upgrade $DIR/Tools/radicale/plugins/app_store_plugin/.
|
||||
python3 -m pip install --upgrade $DIR/Tools/radicale/plugins/app_rights_plugin/.
|
||||
@ -227,7 +227,7 @@ EOF
|
||||
fi
|
||||
|
||||
|
||||
for SVC in monoserve onlyofficeThumb onlyofficeThumbnailBuilder
|
||||
for SVC in monoserve %{package_sysname}Thumb %{package_sysname}ThumbnailBuilder
|
||||
do
|
||||
if systemctl is-active $SVC | grep -q "active"; then
|
||||
systemctl restart $SVC
|
||||
@ -276,7 +276,7 @@ if [ $1 -ge 2 ]; then
|
||||
CONN_STR=$(grep -oP "Server=[^\"]*(?=\")" $DIR/WebStudio/web.connections.config | head -1)
|
||||
|
||||
if [ -f $DIR/WebStudio/web.appsettings.config.rpmsave ]; then
|
||||
CORE_MACHINEKEY="$(sudo sed -n '/"core.machinekey"/s!.*value\s*=\s*"\([^"]*\)".*!\1!p' ${DIR}/WebStudio/web.appsettings.config.rpmsave)";
|
||||
CORE_MACHINEKEY="$(sed -n '/"core.machinekey"/s!.*value\s*=\s*"\([^"]*\)".*!\1!p' ${DIR}/WebStudio/web.appsettings.config.rpmsave)";
|
||||
fi
|
||||
|
||||
binDirs=("WebStudio" "ApiSystem" "Services/TeamLabSvc" "Services/MailAggregator" "Services/MailCleaner" "Services/MailWatchdog")
|
||||
@ -310,13 +310,18 @@ if [ $1 -ge 2 ]; then
|
||||
fi
|
||||
|
||||
if [ ! -d "$APP_INDEX_DIR" ]; then
|
||||
systemctl stop god onlyofficeIndex elasticsearch
|
||||
systemctl daemon-reload
|
||||
systemctl stop god %{package_sysname}Index elasticsearch
|
||||
mysql --silent -h ${MYSQL_SERVER_HOST} -u ${MYSQL_SERVER_USER} --password=${MYSQL_SERVER_PASS} -D "$MYSQL_SERVER_DB_NAME" -e "TRUNCATE webstudio_index";
|
||||
fi
|
||||
|
||||
for i in $(ls $DIR/Sql/%{package_sysname}.upgrade*); do
|
||||
mysql --silent -h ${MYSQL_SERVER_HOST} -u ${MYSQL_SERVER_USER} --password=${MYSQL_SERVER_PASS} -D "$MYSQL_SERVER_DB_NAME" < ${i};
|
||||
done
|
||||
|
||||
if [ -f /etc/god/conf.d/%{package_sysname}.god ]; then
|
||||
rm -rf /etc/god/conf.d/%{package_sysname}.god
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -365,6 +370,12 @@ if grep -q "HeapDumpOnOutOfMemoryError" ${ELASTIC_SEARCH_JAVA_CONF_PATH}; then
|
||||
sed "/-XX:+HeapDumpOnOutOfMemoryError/d" -i ${ELASTIC_SEARCH_JAVA_CONF_PATH}
|
||||
fi
|
||||
|
||||
if ! grep -q "Dlog4j2.formatMsgNoLookups" ${ELASTIC_SEARCH_JAVA_CONF_PATH}; then
|
||||
echo "-Dlog4j2.formatMsgNoLookups=true" >> ${ELASTIC_SEARCH_JAVA_CONF_PATH}
|
||||
else
|
||||
sed -i "s/Dlog4j2.formatMsgNoLookups.*/Dlog4j2.formatMsgNoLookups=true/" ${ELASTIC_SEARCH_JAVA_CONF_PATH}
|
||||
fi
|
||||
|
||||
TOTAL_MEMORY=$(free -m | grep -oP '\d+' | head -n 1);
|
||||
MEMORY_REQUIREMENTS=12228; #RAM ~4*3Gb
|
||||
|
||||
@ -425,12 +436,14 @@ if %{getenforce} >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
systemctl daemon-reload
|
||||
for SVC in %{package_services}; do
|
||||
if [ -e /usr/lib/systemd/system/$SVC.service ]; then
|
||||
systemctl enable $SVC
|
||||
systemctl restart $SVC
|
||||
fi
|
||||
done
|
||||
if [ $1 -ge 2 ]; then
|
||||
for SVC in %{package_services}; do
|
||||
if [ -e /usr/lib/systemd/system/$SVC.service ]; then
|
||||
systemctl enable $SVC
|
||||
systemctl restart $SVC
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if systemctl is-active monoserve | grep -q "active"; then
|
||||
curl --silent --output /dev/null http://127.0.0.1/api/2.0/warmup/restart.json || true
|
||||
|
Binary file not shown.
@ -1,30 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup>
|
||||
<RootDir Condition="$(RootDir)==''">..\..\..\</RootDir>
|
||||
<MsbuildDir>$(RootDir)build\msbuild\</MsbuildDir>
|
||||
<CopyrightDir>$(MsbuildDir)Copyright\</CopyrightDir>
|
||||
<ChangeCopyright Condition="'$(ChangeCopyright)' == ''">0</ChangeCopyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask AssemblyFile="$(MsbuildDir)ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.WriteCopyrightText" />
|
||||
|
||||
<Target Name="Build">
|
||||
<CallTarget Targets="WriteCopyrightText" Condition=" '$(ChangeCopyright)' == '1' "/>
|
||||
</Target>
|
||||
|
||||
<Target Name="WriteCopyrightText">
|
||||
<!--
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" CopyrightFile="$(CopyrightDir)empty.txt" Ignore="file:$(CopyrightDir)Ignore.txt"/>
|
||||
-->
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" CopyrightFile="$(CopyrightDir)NKTCopyright.txt" Ignore="file:$(CopyrightDir)Ignore.txt"/>
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" CopyrightFile="$(CopyrightDir)NKT.txt" Include="*AssemblyInfo.cs" Ignore="file:$(CopyrightDir)IgnoreSimple.txt" Replace="file:$(CopyrightDir)AscensioSystem.txt"/>
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" CopyrightFile="$(CopyrightDir)R7.txt" Include="*.license" Ignore="\common\ASC.Billing.Service\" Replace="file:$(CopyrightDir)Onlyoffice.txt"/>
|
||||
<!--
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" CopyrightFile="$(CopyrightDir)NKT.txt" Include="file:include.txt" Ignore="file:$(CopyrightDir)IgnoreSimple.txt" Replace="file:$(CopyrightDir)AscensioSystem.txt"/>
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" CopyrightFile="$(CopyrightDir)R7Domain.txt" Include="file:include.txt" Ignore="file:$(CopyrightDir)IgnoreSimple.txt" Replace="file:$(CopyrightDir)OnlyofficeDomain.txt"/>
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" CopyrightFile="$(CopyrightDir)R7.txt" Include="file:include.txt" Ignore="file:$(CopyrightDir)IgnoreSimple.txt" Replace="file:$(CopyrightDir)Onlyoffice.txt"/>
|
||||
-->
|
||||
</Target>
|
||||
|
||||
</Project>
|
Binary file not shown.
@ -1,22 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup>
|
||||
<RootDir Condition="$(RootDir)==''">..\..\..\</RootDir>
|
||||
<MsbuildDir>$(RootDir)build\msbuild\</MsbuildDir>
|
||||
<CopyrightDir>$(MsbuildDir)Copyright\</CopyrightDir>
|
||||
<ChangeCopyright Condition="'$(ChangeCopyright)' == ''">0</ChangeCopyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask AssemblyFile="$(MsbuildDir)ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.WriteCopyrightText" />
|
||||
|
||||
<Target Name="Build">
|
||||
<CallTarget Targets="WriteCopyrightText" Condition=" '$(ChangeCopyright)' == '1' "/>
|
||||
</Target>
|
||||
|
||||
<Target Name="WriteCopyrightText">
|
||||
|
||||
<WriteCopyrightText Writer="$(CopyrightDir)crwriter.exe" StartDirectory="$(RootDir)" Ignore="file:$(CopyrightDir)Ignore.txt"/>
|
||||
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,389 +1,389 @@
|
||||
<!--
|
||||
***********************************************************************************************
|
||||
Microsoft.WebApplication.targets
|
||||
|
||||
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
|
||||
created a backup copy. Incorrect changes to this file will make it
|
||||
impossible to load or build your web deploy projects from the command-line or the IDE.
|
||||
|
||||
This file defines the steps in the standard build process for web application projects.
|
||||
|
||||
Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
***********************************************************************************************
|
||||
-->
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<UsingTask TaskName="Microsoft.WebApplication.Build.Tasks.GetSilverlightItemsFromProperty" AssemblyFile="Microsoft.WebApplication.Build.Tasks.dll" />
|
||||
<UsingTask TaskName="Microsoft.WebApplication.Build.Tasks.CopyFilesToFolders" AssemblyFile="Microsoft.WebApplication.Build.Tasks.dll" />
|
||||
|
||||
<PropertyGroup>
|
||||
<IsDesktopBuild Condition="'$(IsDesktopBuild)'=='' And '$(TeamFoundationServerUrl)' != ''">False</IsDesktopBuild>
|
||||
<WebProjectOutputDirInsideProjectDefault>True</WebProjectOutputDirInsideProjectDefault>
|
||||
<WebProjectOutputDirInsideProjectDefault Condition="('$(OutDir)' != '$(OutputPath)') Or ('$(IsDesktopBuild)' == 'False')" >False</WebProjectOutputDirInsideProjectDefault>
|
||||
<WebProjectOutputDirInsideProject Condition="'$(WebProjectOutputDirInsideProject)' == ''">$(WebProjectOutputDirInsideProjectDefault)</WebProjectOutputDirInsideProject>
|
||||
<DisableLinkInCopyWebApplicaton Condition="'$(DisableLinkInCopyWebApplicaton)'==''">False</DisableLinkInCopyWebApplicaton>
|
||||
<Disable_CopyWebApplication Condition="'$(Disable_CopyWebApplication)' == ''">False</Disable_CopyWebApplication>
|
||||
<UseWPP_CopyWebApplication Condition="'$(UseWPP_CopyWebApplication)' == ''">False</UseWPP_CopyWebApplication>
|
||||
<CleanWebProjectOutputDir>True</CleanWebProjectOutputDir>
|
||||
<CleanWebProjectOutputDir Condition="$(WebProjectOutputDirInsideProject)" >False</CleanWebProjectOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--Only setup $(WebProjectOutputDir) iff user haven't set it up-->
|
||||
<PropertyGroup Condition="'$(WebProjectOutputDir)'==''">
|
||||
<WebProjectOutputDir>$(MSBuildProjectDirectory)</WebProjectOutputDir>
|
||||
<WebProjectOutputDir Condition="!$(WebProjectOutputDirInsideProject)">$(OutDir)_PublishedWebsites\$(MSBuildProjectName)</WebProjectOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PrepareForRunDependsOn>
|
||||
$(PrepareForRunDependsOn);
|
||||
CopySilverlightApplications;
|
||||
_CopyBinDeployableAssemblies;
|
||||
</PrepareForRunDependsOn>
|
||||
<PrepareForRunDependsOn Condition="!$(Disable_CopyWebApplication)">
|
||||
$(PrepareForRunDependsOn);
|
||||
_CopyWebApplication;
|
||||
_BuiltWebOutputGroupOutput
|
||||
</PrepareForRunDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--***************************************************************-->
|
||||
<!--Global setting for Clean target -->
|
||||
<!--***************************************************************-->
|
||||
<PropertyGroup>
|
||||
<CleanDependsOn>
|
||||
$(CleanDependsOn);
|
||||
CleanWebProjectOutputDir;
|
||||
</CleanDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--********************************************************************-->
|
||||
<!-- CleanWebProjectOutputDir -->
|
||||
<!-- ********************************************************************-->
|
||||
<PropertyGroup>
|
||||
<CleanWebProjectOutputDirDependsOn Condition="'$(CleanWebProjectOutputDirDependsOn)' == ''">
|
||||
</CleanWebProjectOutputDirDependsOn>
|
||||
</PropertyGroup>
|
||||
<Target Name="CleanWebProjectOutputDir"
|
||||
Condition="$(CleanWebProjectOutputDir)"
|
||||
DependsOnTargets="$(CleanWebProjectOutputDirDependsOn)">
|
||||
<!--Assertion check-->
|
||||
<!--In the case of Clean Packaging/Publish, we simply delete the WebProjectOutputDir-->
|
||||
<RemoveDir Condition="Exists($(WebProjectOutputDir))" Directories="$(WebProjectOutputDir)" ContinueOnError="true" />
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_CopyWebApplication
|
||||
|
||||
This target will copy the build outputs along with the
|
||||
content files into a _PublishedWebsites folder.
|
||||
|
||||
This Task is only necessary when $(OutDir) has been redirected
|
||||
to a folder other than ~\bin such as is the case with Team Build.
|
||||
|
||||
The original _CopyWebApplication is now a Legacy, you can still use it by setting $(UseWPP_CopyWebApplication) to true.
|
||||
By default, it now change to use _WPPCopyWebApplication target in Microsoft.Web.Publish.targets. It allow to leverage the web.config trsnaformation.
|
||||
============================================================
|
||||
-->
|
||||
|
||||
<PropertyGroup>
|
||||
<!--This will be overwrite by ..\web\Microsoft.Web.Publishing.targets when $(UseWPP_CopyWebApplication) set to true-->
|
||||
<OnBefore_CopyWebApplicationDefault>
|
||||
_CopyWebApplicationLegacy;
|
||||
</OnBefore_CopyWebApplicationDefault>
|
||||
<OnBefore_CopyWebApplicationDefault Condition="$(UseWPP_CopyWebApplication) AND Exists('$(MSBuildThisFileDirectory)\..\Web\Microsoft.Web.Publishing.targets')">
|
||||
_WPPCopyWebApplication;
|
||||
</OnBefore_CopyWebApplicationDefault>
|
||||
<OnBefore_CopyWebApplication Condition="'$(OnBefore_CopyWebApplication)'==''">
|
||||
$(OnBefore_CopyWebApplicationDefault);
|
||||
</OnBefore_CopyWebApplication>
|
||||
|
||||
<OnAfter_CopyWebApplication Condition="'$(OnAfter_CopyWebApplication)'==''">
|
||||
</OnAfter_CopyWebApplication>
|
||||
|
||||
<_CopyWebApplicationDependsOn Condition="'$(_CopyWebApplicationDependsOn)'==''">
|
||||
$(OnBefore_CopyWebApplication);
|
||||
</_CopyWebApplicationDependsOn>
|
||||
|
||||
</PropertyGroup>
|
||||
<Target Name="_CopyWebApplication"
|
||||
Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'"
|
||||
DependsOnTargets="$(_CopyWebApplicationDependsOn)">
|
||||
|
||||
<CallTarget Condition="'$(OnAfter_CopyWebApplication)' != ''" Targets="$(OnAfter_CopyWebApplication)" RunEachTargetSeparately="true" />
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_CopyWebApplicationLegacy
|
||||
|
||||
This target will copy the build outputs along with the
|
||||
content files into a _PublishedWebsites folder.
|
||||
|
||||
This Task is only necessary when $(OutDir) has been redirected
|
||||
to a folder other than ~\bin such as is the case with Team Build.
|
||||
============================================================
|
||||
-->
|
||||
<Target Name="_CopyWebApplicationLegacy" Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'" >
|
||||
<!-- Log tasks -->
|
||||
<Message Text="Copying Web Application Project Files for $(MSBuildProjectName)" />
|
||||
|
||||
<!-- Create the _PublishedWebsites\app\bin folder -->
|
||||
<MakeDir Directories="$(WebProjectOutputDir)\bin" />
|
||||
|
||||
<!-- Copy build outputs to _PublishedWebsites\app\bin folder -->
|
||||
<Copy SourceFiles="@(IntermediateAssembly)" DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(AddModules)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="$(IntermediateOutputPath)$(_SGenDllName)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\%(Content.SubFolder)%(Content.RecursiveDir)"
|
||||
SkipUnchangedFiles="true"
|
||||
Condition="'$(_SGenDllCreated)'=='true'"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="$(IntermediateOutputPath)$(TargetName).pdb"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Condition="'$(_DebugSymbolsProduced)'=='true'"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(DocFileItem)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Condition="'$(_DocumentationFileProduced)'=='true'"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)"
|
||||
DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(WebProjectOutputDir)\bin\%(Culture)\$(TargetName).resources.dll')"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
|
||||
<Copy SourceFiles="@(ReferenceCopyLocalPaths)"
|
||||
DestinationFiles="@(ReferenceCopyLocalPaths->'$(WebProjectOutputDir)\bin\%(DestinationSubDirectory)%(Filename)%(Extension)')"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy content files recursively to _PublishedWebsites\app\ folder -->
|
||||
<Copy SourceFiles="@(Content)" Condition="'%(Content.Link)' == ''"
|
||||
DestinationFolder="$(WebProjectOutputDir)\%(Content.RelativeDir)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
|
||||
<Copy SourceFiles="@(Content)" Condition="!$(DisableLinkInCopyWebApplicaton) And '%(Content.Link)' != ''"
|
||||
DestinationFiles="$(WebProjectOutputDir)\%(Content.Link)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy items that have been marked to be copied to the bin folder -->
|
||||
<Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectory)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectoryAlways)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="false"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy Silverlight Zip and Xzp file to _PublishedWebsites\app\ folder-->
|
||||
<Copy SourceFiles="@(_WebApplicationSilverlightXapFiles)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\%(_WebApplicationSilverlightXapFiles.RelativeDir)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy items that need to be bin deployed to the bin folder -->
|
||||
<Copy SourceFiles="@(_binDeployableAssemblies)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin\%(_binDeployableAssemblies.DestinationRelPath)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_BuiltWebOutputGroupOutput
|
||||
|
||||
This target creates and populates BuiltWebOutputGroupOutput
|
||||
with contents of bin along with the @(Content) files
|
||||
============================================================
|
||||
-->
|
||||
<Target Name ="_BuiltWebOutputGroupOutput"
|
||||
Condition="!$(Disable_CopyWebApplication)"
|
||||
Outputs="@(BuiltWebOutputGroupOutput)">
|
||||
<CreateItem Include="$(WebProjectOutputDir)\bin\**\*.*;@(Content->'%(FullPath)')" Condition="'$(OutDir)' == '$(OutputPath)'">
|
||||
<Output ItemName="BuiltWebOutputGroupOutput" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<CreateItem Include="$(WebProjectOutputDir)\**\*.*" Condition="'$(OutDir)' != '$(OutputPath)'">
|
||||
<Output ItemName="BuiltWebOutputGroupOutput" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_GetSilverlightApplications
|
||||
|
||||
Converts the list of Silverlight Applications that are defined
|
||||
in the property $(SilverlightApplicationList) to ITaskItems that
|
||||
can be used by teh CopySilverlightApplication task
|
||||
The format of $(SilverlightApplicationList) is:
|
||||
{projGuid}|relPath|tgtFolder;{projGuid2}|relPathToProject2|tgtFolder2;...
|
||||
============================================================
|
||||
-->
|
||||
<Target
|
||||
Name="_GetSilverlightApplications"
|
||||
Condition="'$(SilverlightApplicationList)' != ''">
|
||||
|
||||
<GetSilverlightItemsFromProperty
|
||||
SilverlightReferences="$(SilverlightApplicationList)"
|
||||
ProjectPath="$(MSBuildProjectFullPath)">
|
||||
|
||||
<Output TaskParameter="SilverlightApplications" ItemName="_AllSilverlightApplications"/>
|
||||
</GetSilverlightItemsFromProperty>
|
||||
|
||||
<!-- Break the silverlight application list into two lists: those that exist on disk and those that don't. -->
|
||||
<ItemGroup>
|
||||
<_SilverlightApplications Include="@(_AllSilverlightApplications)" Condition="Exists('%(Identity)')"/>
|
||||
<_SilverlightApplicationsNotExist Include="@(_AllSilverlightApplications)" Condition="!Exists('%(Identity)')"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
CopySilverlightApplications
|
||||
|
||||
This target copies the output xap files from referenced
|
||||
Silverlight application projects to the target folder.
|
||||
============================================================
|
||||
-->
|
||||
<Target
|
||||
Name="CopySilverlightApplications"
|
||||
DependsOnTargets="_GetSilverlightApplications"
|
||||
Outputs="@(_WebApplicationSilverlightXapFiles)"
|
||||
Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
|
||||
<!--
|
||||
When building this project from the IDE or when building a .SLN from the command-line,
|
||||
just gather the referenced build outputs (Xap files). The code that builds the .SLN will already have
|
||||
built the project, so there's no need to do it again here. Since Silverlight only supports AnyCPU that is
|
||||
what we use for the platform
|
||||
|
||||
The ContinueOnError setting is here so that, during project load, as
|
||||
much information as possible will be passed to the compilers.
|
||||
-->
|
||||
<MSBuild
|
||||
Projects="@(_SilverlightApplications)"
|
||||
Targets="GetXapOutputFile"
|
||||
BuildInParallel= "false"
|
||||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);Platform=AnyCPU;BuildingSolutionFile=false"
|
||||
Condition="'@(_SilverlightApplications)' != ''"
|
||||
ContinueOnError="!$(BuildingProject)">
|
||||
|
||||
<Output TaskParameter="TargetOutputs" ItemName="_SilverlightXapFiles"/>
|
||||
|
||||
</MSBuild>
|
||||
|
||||
<!--
|
||||
Build referenced projects when building from the command line.
|
||||
|
||||
The $(ProjectReferenceBuildTargets) will normally be blank so that the project's default
|
||||
target is used during a P2P reference. However if a custom build process requires that
|
||||
the referenced project has a different target to build it can be specified.
|
||||
-->
|
||||
<MSBuild
|
||||
Projects="@(_SilverlightApplications)"
|
||||
Targets="$(ProjectReferenceBuildTargets)"
|
||||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);Platform=AnyCPU;BuildingSolutionFile=false"
|
||||
BuildInParallel="false"
|
||||
Condition="'$(BuildingInsideVisualStudio)' != 'true' and '@(_SilverlightApplications)' != ''">
|
||||
</MSBuild>
|
||||
|
||||
<!--Copy the outputs to the target folder-->
|
||||
<CopyFilesToFolders SourceFiles="@(_SilverlightXapFiles)"
|
||||
SilverlightApplications="@(_SilverlightApplications)"
|
||||
ConfigName="$(Configuration)"
|
||||
Condition="'@(_SilverlightXapFiles)' != ''">
|
||||
<Output TaskParameter="DestinationFiles" ItemName="_WebApplicationSilverlightXapFiles" />
|
||||
</CopyFilesToFolders>
|
||||
|
||||
<!-- Issue a warning for each non-existent project. -->
|
||||
<Warning
|
||||
Text="The referenced Silverlight project '%(_SilverlightApplicationsNotExist.Identity)' does not exist."
|
||||
Condition="'@(_SilverlightApplicationsNotExist)'!=''"/>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_CopyBinDeployableAssemblies
|
||||
|
||||
This target copies the contents of ProjectDir\_bin_deployableAssemblies to the bin
|
||||
folder, preserving the relative paths
|
||||
============================================================
|
||||
-->
|
||||
<Target
|
||||
Name="_CopyBinDeployableAssemblies"
|
||||
Condition="Exists('$(MSBuildProjectDirectory)\_bin_deployableAssemblies')">
|
||||
|
||||
<PropertyGroup>
|
||||
<BinDeployableFolder Condition="'$(BinDeployableFolder)' == ''">_bin_deployableAssemblies\</BinDeployableFolder>
|
||||
<BinDeployableFolderFullPath>$([System.IO.Path]::GetFullPath($(BinDeployableFolder)))</BinDeployableFolderFullPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--Pick up the deployable items from the $(None) collection that are under the _bin_deployableAssemblies folder -->
|
||||
<CreateItem Include="@(None->'%(Identity)')" Condition="'%(None.FullPath)' != '' And $([System.String]::new('%(None.FullPath)').StartsWith($(BinDeployableFolderFullPath), StringComparison.OrdinalIgnoreCase ))" >
|
||||
<Output ItemName="__binDeployableAssemblies" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<!--Add metadata which holds the destination relative folder to copy them to-->
|
||||
<ItemGroup>
|
||||
<_binDeployableAssemblies Include ="@(__binDeployableAssemblies)" Condition="'@(__binDeployableAssemblies)' != ''">
|
||||
<DestinationRelPath>$([System.String]::Concat($([System.IO.Path]::GetDirectoryName($([System.String]::new('%(__binDeployableAssemblies.FullPath)')))),'\').SubString($(BinDeployableFolderFullPath.Length)))</DestinationRelPath>
|
||||
</_binDeployableAssemblies>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Do the copy-->
|
||||
<Copy SourceFiles="@(_binDeployableAssemblies)" DestinationFolder="$(OutDir)%(_binDeployableAssemblies.DestinationRelPath)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!--Add the items just copied to the collection of items to delete when doing a clean-->
|
||||
<ItemGroup>
|
||||
<FileWrites Include ="@(_binDeployableAssemblies->'$(OutDir)%(DestinationRelPath)%(Filename)%(Extension)')" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!--Import publishing target-->
|
||||
<Import Project="..\Web\Microsoft.Web.Publishing.targets" Condition="Exists('..\Web\Microsoft.Web.Publishing.targets')" />
|
||||
|
||||
|
||||
<!--Ensure the Siliverlight zap file is created and copied to the bin folder for the Microsoft.Web.Publishing.targets-->
|
||||
<PropertyGroup>
|
||||
<OnBeforePipelineCollectFilesPhase>
|
||||
$(OnBeforePipelineCollectFilesPhase);
|
||||
CopySilverlightApplications;
|
||||
</OnBeforePipelineCollectFilesPhase>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
<!--
|
||||
***********************************************************************************************
|
||||
Microsoft.WebApplication.targets
|
||||
|
||||
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
|
||||
created a backup copy. Incorrect changes to this file will make it
|
||||
impossible to load or build your web deploy projects from the command-line or the IDE.
|
||||
|
||||
This file defines the steps in the standard build process for web application projects.
|
||||
|
||||
Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
***********************************************************************************************
|
||||
-->
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<UsingTask TaskName="Microsoft.WebApplication.Build.Tasks.GetSilverlightItemsFromProperty" AssemblyFile="Microsoft.WebApplication.Build.Tasks.dll" />
|
||||
<UsingTask TaskName="Microsoft.WebApplication.Build.Tasks.CopyFilesToFolders" AssemblyFile="Microsoft.WebApplication.Build.Tasks.dll" />
|
||||
|
||||
<PropertyGroup>
|
||||
<IsDesktopBuild Condition="'$(IsDesktopBuild)'=='' And '$(TeamFoundationServerUrl)' != ''">False</IsDesktopBuild>
|
||||
<WebProjectOutputDirInsideProjectDefault>True</WebProjectOutputDirInsideProjectDefault>
|
||||
<WebProjectOutputDirInsideProjectDefault Condition="('$(OutDir)' != '$(OutputPath)') Or ('$(IsDesktopBuild)' == 'False')" >False</WebProjectOutputDirInsideProjectDefault>
|
||||
<WebProjectOutputDirInsideProject Condition="'$(WebProjectOutputDirInsideProject)' == ''">$(WebProjectOutputDirInsideProjectDefault)</WebProjectOutputDirInsideProject>
|
||||
<DisableLinkInCopyWebApplicaton Condition="'$(DisableLinkInCopyWebApplicaton)'==''">False</DisableLinkInCopyWebApplicaton>
|
||||
<Disable_CopyWebApplication Condition="'$(Disable_CopyWebApplication)' == ''">False</Disable_CopyWebApplication>
|
||||
<UseWPP_CopyWebApplication Condition="'$(UseWPP_CopyWebApplication)' == ''">False</UseWPP_CopyWebApplication>
|
||||
<CleanWebProjectOutputDir>True</CleanWebProjectOutputDir>
|
||||
<CleanWebProjectOutputDir Condition="$(WebProjectOutputDirInsideProject)" >False</CleanWebProjectOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--Only setup $(WebProjectOutputDir) iff user haven't set it up-->
|
||||
<PropertyGroup Condition="'$(WebProjectOutputDir)'==''">
|
||||
<WebProjectOutputDir>$(MSBuildProjectDirectory)</WebProjectOutputDir>
|
||||
<WebProjectOutputDir Condition="!$(WebProjectOutputDirInsideProject)">$(OutDir)_PublishedWebsites\$(MSBuildProjectName)</WebProjectOutputDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PrepareForRunDependsOn>
|
||||
$(PrepareForRunDependsOn);
|
||||
CopySilverlightApplications;
|
||||
_CopyBinDeployableAssemblies;
|
||||
</PrepareForRunDependsOn>
|
||||
<PrepareForRunDependsOn Condition="!$(Disable_CopyWebApplication)">
|
||||
$(PrepareForRunDependsOn);
|
||||
_CopyWebApplication;
|
||||
_BuiltWebOutputGroupOutput
|
||||
</PrepareForRunDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--***************************************************************-->
|
||||
<!--Global setting for Clean target -->
|
||||
<!--***************************************************************-->
|
||||
<PropertyGroup>
|
||||
<CleanDependsOn>
|
||||
$(CleanDependsOn);
|
||||
CleanWebProjectOutputDir;
|
||||
</CleanDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--********************************************************************-->
|
||||
<!-- CleanWebProjectOutputDir -->
|
||||
<!-- ********************************************************************-->
|
||||
<PropertyGroup>
|
||||
<CleanWebProjectOutputDirDependsOn Condition="'$(CleanWebProjectOutputDirDependsOn)' == ''">
|
||||
</CleanWebProjectOutputDirDependsOn>
|
||||
</PropertyGroup>
|
||||
<Target Name="CleanWebProjectOutputDir"
|
||||
Condition="$(CleanWebProjectOutputDir)"
|
||||
DependsOnTargets="$(CleanWebProjectOutputDirDependsOn)">
|
||||
<!--Assertion check-->
|
||||
<!--In the case of Clean Packaging/Publish, we simply delete the WebProjectOutputDir-->
|
||||
<RemoveDir Condition="Exists($(WebProjectOutputDir))" Directories="$(WebProjectOutputDir)" ContinueOnError="true" />
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_CopyWebApplication
|
||||
|
||||
This target will copy the build outputs along with the
|
||||
content files into a _PublishedWebsites folder.
|
||||
|
||||
This Task is only necessary when $(OutDir) has been redirected
|
||||
to a folder other than ~\bin such as is the case with Team Build.
|
||||
|
||||
The original _CopyWebApplication is now a Legacy, you can still use it by setting $(UseWPP_CopyWebApplication) to true.
|
||||
By default, it now change to use _WPPCopyWebApplication target in Microsoft.Web.Publish.targets. It allow to leverage the web.config trsnaformation.
|
||||
============================================================
|
||||
-->
|
||||
|
||||
<PropertyGroup>
|
||||
<!--This will be overwrite by ..\web\Microsoft.Web.Publishing.targets when $(UseWPP_CopyWebApplication) set to true-->
|
||||
<OnBefore_CopyWebApplicationDefault>
|
||||
_CopyWebApplicationLegacy;
|
||||
</OnBefore_CopyWebApplicationDefault>
|
||||
<OnBefore_CopyWebApplicationDefault Condition="$(UseWPP_CopyWebApplication) AND Exists('$(MSBuildThisFileDirectory)\..\Web\Microsoft.Web.Publishing.targets')">
|
||||
_WPPCopyWebApplication;
|
||||
</OnBefore_CopyWebApplicationDefault>
|
||||
<OnBefore_CopyWebApplication Condition="'$(OnBefore_CopyWebApplication)'==''">
|
||||
$(OnBefore_CopyWebApplicationDefault);
|
||||
</OnBefore_CopyWebApplication>
|
||||
|
||||
<OnAfter_CopyWebApplication Condition="'$(OnAfter_CopyWebApplication)'==''">
|
||||
</OnAfter_CopyWebApplication>
|
||||
|
||||
<_CopyWebApplicationDependsOn Condition="'$(_CopyWebApplicationDependsOn)'==''">
|
||||
$(OnBefore_CopyWebApplication);
|
||||
</_CopyWebApplicationDependsOn>
|
||||
|
||||
</PropertyGroup>
|
||||
<Target Name="_CopyWebApplication"
|
||||
Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'"
|
||||
DependsOnTargets="$(_CopyWebApplicationDependsOn)">
|
||||
|
||||
<CallTarget Condition="'$(OnAfter_CopyWebApplication)' != ''" Targets="$(OnAfter_CopyWebApplication)" RunEachTargetSeparately="true" />
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_CopyWebApplicationLegacy
|
||||
|
||||
This target will copy the build outputs along with the
|
||||
content files into a _PublishedWebsites folder.
|
||||
|
||||
This Task is only necessary when $(OutDir) has been redirected
|
||||
to a folder other than ~\bin such as is the case with Team Build.
|
||||
============================================================
|
||||
-->
|
||||
<Target Name="_CopyWebApplicationLegacy" Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'" >
|
||||
<!-- Log tasks -->
|
||||
<Message Text="Copying Web Application Project Files for $(MSBuildProjectName)" />
|
||||
|
||||
<!-- Create the _PublishedWebsites\app\bin folder -->
|
||||
<MakeDir Directories="$(WebProjectOutputDir)\bin" />
|
||||
|
||||
<!-- Copy build outputs to _PublishedWebsites\app\bin folder -->
|
||||
<Copy SourceFiles="@(IntermediateAssembly)" DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(AddModules)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="$(IntermediateOutputPath)$(_SGenDllName)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\%(Content.SubFolder)%(Content.RecursiveDir)"
|
||||
SkipUnchangedFiles="true"
|
||||
Condition="'$(_SGenDllCreated)'=='true'"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="$(IntermediateOutputPath)$(TargetName).pdb"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Condition="'$(_DebugSymbolsProduced)'=='true'"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(DocFileItem)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Condition="'$(_DocumentationFileProduced)'=='true'"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(IntermediateSatelliteAssembliesWithTargetPath)"
|
||||
DestinationFiles="@(IntermediateSatelliteAssembliesWithTargetPath->'$(WebProjectOutputDir)\bin\%(Culture)\$(TargetName).resources.dll')"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- copy any referenced assemblies to _PublishedWebsites\app\bin folder -->
|
||||
<Copy SourceFiles="@(ReferenceCopyLocalPaths)"
|
||||
DestinationFiles="@(ReferenceCopyLocalPaths->'$(WebProjectOutputDir)\bin\%(DestinationSubDirectory)%(Filename)%(Extension)')"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy content files recursively to _PublishedWebsites\app\ folder -->
|
||||
<Copy SourceFiles="@(Content)" Condition="'%(Content.Link)' == ''"
|
||||
DestinationFolder="$(WebProjectOutputDir)\%(Content.RelativeDir)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
|
||||
<Copy SourceFiles="@(Content)" Condition="!$(DisableLinkInCopyWebApplicaton) And '%(Content.Link)' != ''"
|
||||
DestinationFiles="$(WebProjectOutputDir)\%(Content.Link)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy items that have been marked to be copied to the bin folder -->
|
||||
<Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectory)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
<Copy SourceFiles="@(_SourceItemsToCopyToOutputDirectoryAlways)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin"
|
||||
SkipUnchangedFiles="false"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy Silverlight Zip and Xzp file to _PublishedWebsites\app\ folder-->
|
||||
<Copy SourceFiles="@(_WebApplicationSilverlightXapFiles)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\%(_WebApplicationSilverlightXapFiles.RelativeDir)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!-- Copy items that need to be bin deployed to the bin folder -->
|
||||
<Copy SourceFiles="@(_binDeployableAssemblies)"
|
||||
DestinationFolder="$(WebProjectOutputDir)\bin\%(_binDeployableAssemblies.DestinationRelPath)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_BuiltWebOutputGroupOutput
|
||||
|
||||
This target creates and populates BuiltWebOutputGroupOutput
|
||||
with contents of bin along with the @(Content) files
|
||||
============================================================
|
||||
-->
|
||||
<Target Name ="_BuiltWebOutputGroupOutput"
|
||||
Condition="!$(Disable_CopyWebApplication)"
|
||||
Outputs="@(BuiltWebOutputGroupOutput)">
|
||||
<CreateItem Include="$(WebProjectOutputDir)\bin\**\*.*;@(Content->'%(FullPath)')" Condition="'$(OutDir)' == '$(OutputPath)'">
|
||||
<Output ItemName="BuiltWebOutputGroupOutput" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<CreateItem Include="$(WebProjectOutputDir)\**\*.*" Condition="'$(OutDir)' != '$(OutputPath)'">
|
||||
<Output ItemName="BuiltWebOutputGroupOutput" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_GetSilverlightApplications
|
||||
|
||||
Converts the list of Silverlight Applications that are defined
|
||||
in the property $(SilverlightApplicationList) to ITaskItems that
|
||||
can be used by teh CopySilverlightApplication task
|
||||
The format of $(SilverlightApplicationList) is:
|
||||
{projGuid}|relPath|tgtFolder;{projGuid2}|relPathToProject2|tgtFolder2;...
|
||||
============================================================
|
||||
-->
|
||||
<Target
|
||||
Name="_GetSilverlightApplications"
|
||||
Condition="'$(SilverlightApplicationList)' != ''">
|
||||
|
||||
<GetSilverlightItemsFromProperty
|
||||
SilverlightReferences="$(SilverlightApplicationList)"
|
||||
ProjectPath="$(MSBuildProjectFullPath)">
|
||||
|
||||
<Output TaskParameter="SilverlightApplications" ItemName="_AllSilverlightApplications"/>
|
||||
</GetSilverlightItemsFromProperty>
|
||||
|
||||
<!-- Break the silverlight application list into two lists: those that exist on disk and those that don't. -->
|
||||
<ItemGroup>
|
||||
<_SilverlightApplications Include="@(_AllSilverlightApplications)" Condition="Exists('%(Identity)')"/>
|
||||
<_SilverlightApplicationsNotExist Include="@(_AllSilverlightApplications)" Condition="!Exists('%(Identity)')"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
CopySilverlightApplications
|
||||
|
||||
This target copies the output xap files from referenced
|
||||
Silverlight application projects to the target folder.
|
||||
============================================================
|
||||
-->
|
||||
<Target
|
||||
Name="CopySilverlightApplications"
|
||||
DependsOnTargets="_GetSilverlightApplications"
|
||||
Outputs="@(_WebApplicationSilverlightXapFiles)"
|
||||
Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
|
||||
<!--
|
||||
When building this project from the IDE or when building a .SLN from the command-line,
|
||||
just gather the referenced build outputs (Xap files). The code that builds the .SLN will already have
|
||||
built the project, so there's no need to do it again here. Since Silverlight only supports AnyCPU that is
|
||||
what we use for the platform
|
||||
|
||||
The ContinueOnError setting is here so that, during project load, as
|
||||
much information as possible will be passed to the compilers.
|
||||
-->
|
||||
<MSBuild
|
||||
Projects="@(_SilverlightApplications)"
|
||||
Targets="GetXapOutputFile"
|
||||
BuildInParallel= "false"
|
||||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);Platform=AnyCPU;BuildingSolutionFile=false"
|
||||
Condition="'@(_SilverlightApplications)' != ''"
|
||||
ContinueOnError="!$(BuildingProject)">
|
||||
|
||||
<Output TaskParameter="TargetOutputs" ItemName="_SilverlightXapFiles"/>
|
||||
|
||||
</MSBuild>
|
||||
|
||||
<!--
|
||||
Build referenced projects when building from the command line.
|
||||
|
||||
The $(ProjectReferenceBuildTargets) will normally be blank so that the project's default
|
||||
target is used during a P2P reference. However if a custom build process requires that
|
||||
the referenced project has a different target to build it can be specified.
|
||||
-->
|
||||
<MSBuild
|
||||
Projects="@(_SilverlightApplications)"
|
||||
Targets="$(ProjectReferenceBuildTargets)"
|
||||
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);Platform=AnyCPU;BuildingSolutionFile=false"
|
||||
BuildInParallel="false"
|
||||
Condition="'$(BuildingInsideVisualStudio)' != 'true' and '@(_SilverlightApplications)' != ''">
|
||||
</MSBuild>
|
||||
|
||||
<!--Copy the outputs to the target folder-->
|
||||
<CopyFilesToFolders SourceFiles="@(_SilverlightXapFiles)"
|
||||
SilverlightApplications="@(_SilverlightApplications)"
|
||||
ConfigName="$(Configuration)"
|
||||
Condition="'@(_SilverlightXapFiles)' != ''">
|
||||
<Output TaskParameter="DestinationFiles" ItemName="_WebApplicationSilverlightXapFiles" />
|
||||
</CopyFilesToFolders>
|
||||
|
||||
<!-- Issue a warning for each non-existent project. -->
|
||||
<Warning
|
||||
Text="The referenced Silverlight project '%(_SilverlightApplicationsNotExist.Identity)' does not exist."
|
||||
Condition="'@(_SilverlightApplicationsNotExist)'!=''"/>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
============================================================
|
||||
_CopyBinDeployableAssemblies
|
||||
|
||||
This target copies the contents of ProjectDir\_bin_deployableAssemblies to the bin
|
||||
folder, preserving the relative paths
|
||||
============================================================
|
||||
-->
|
||||
<Target
|
||||
Name="_CopyBinDeployableAssemblies"
|
||||
Condition="Exists('$(MSBuildProjectDirectory)\_bin_deployableAssemblies')">
|
||||
|
||||
<PropertyGroup>
|
||||
<BinDeployableFolder Condition="'$(BinDeployableFolder)' == ''">_bin_deployableAssemblies\</BinDeployableFolder>
|
||||
<BinDeployableFolderFullPath>$([System.IO.Path]::GetFullPath($(BinDeployableFolder)))</BinDeployableFolderFullPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--Pick up the deployable items from the $(None) collection that are under the _bin_deployableAssemblies folder -->
|
||||
<CreateItem Include="@(None->'%(Identity)')" Condition="'%(None.FullPath)' != '' And $([System.String]::new('%(None.FullPath)').StartsWith($(BinDeployableFolderFullPath), StringComparison.OrdinalIgnoreCase ))" >
|
||||
<Output ItemName="__binDeployableAssemblies" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<!--Add metadata which holds the destination relative folder to copy them to-->
|
||||
<ItemGroup>
|
||||
<_binDeployableAssemblies Include ="@(__binDeployableAssemblies)" Condition="'@(__binDeployableAssemblies)' != ''">
|
||||
<DestinationRelPath>$([System.String]::Concat($([System.IO.Path]::GetDirectoryName($([System.String]::new('%(__binDeployableAssemblies.FullPath)')))),'\').SubString($(BinDeployableFolderFullPath.Length)))</DestinationRelPath>
|
||||
</_binDeployableAssemblies>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Do the copy-->
|
||||
<Copy SourceFiles="@(_binDeployableAssemblies)" DestinationFolder="$(OutDir)%(_binDeployableAssemblies.DestinationRelPath)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="$(CopyRetryCount)"
|
||||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
|
||||
|
||||
<!--Add the items just copied to the collection of items to delete when doing a clean-->
|
||||
<ItemGroup>
|
||||
<FileWrites Include ="@(_binDeployableAssemblies->'$(OutDir)%(DestinationRelPath)%(Filename)%(Extension)')" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!--Import publishing target-->
|
||||
<Import Project="..\Web\Microsoft.Web.Publishing.targets" Condition="Exists('..\Web\Microsoft.Web.Publishing.targets')" />
|
||||
|
||||
|
||||
<!--Ensure the Siliverlight zap file is created and copied to the bin folder for the Microsoft.Web.Publishing.targets-->
|
||||
<PropertyGroup>
|
||||
<OnBeforePipelineCollectFilesPhase>
|
||||
$(OnBeforePipelineCollectFilesPhase);
|
||||
CopySilverlightApplications;
|
||||
</OnBeforePipelineCollectFilesPhase>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
@ -1,134 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Deploy">
|
||||
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.XmlUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.Xml.XmlMassUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CopyDirectory" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RemoveDuplicatesAssemblies" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RegexReplace" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition="$(Configuration)==''">Debug</Configuration>
|
||||
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
|
||||
<DeployTo Condition="$(DeployTo)==''">localhost</DeployTo>
|
||||
<DeployDir Condition="$(DeployDir)==''">$(RootDir)build\deploy\</DeployDir>
|
||||
<MailFilesDir>$(DeployDir)MailFiles\</MailFilesDir>
|
||||
<OutDir Condition="$(OutDir)==''">$(DeployDir)$(DeployTo)\</OutDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MailFiles Include="$(MailFilesDir)/Services/**/*" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Deploy">
|
||||
<Message Text="Deploy parameters:"/>
|
||||
<Message Text=" DeployTo = $(DeployTo)"/>
|
||||
|
||||
<RemoveDir Directories="$(OutDir)" ContinueOnError="true" Condition="'$(LeaveOutDir)' != '0'" />
|
||||
|
||||
<Copy
|
||||
SourceFiles="@(MailFiles)"
|
||||
DestinationFolder="$(OutDir)/Services/%(MailFiles.RecursiveDir)"/>
|
||||
|
||||
<CallTarget Targets="ChangeConfigs" Condition=" Exists( '$(MailFilesDir)Substitutions\' ) "/>
|
||||
|
||||
</Target>
|
||||
|
||||
<Target Name="ChangeConfigs">
|
||||
<ItemGroup>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\web.autofac.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Autofac.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\web.consumers.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Consumers.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\web.storage.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Storage.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\mail.agg.log4net.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\mail.agg.nlog.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\ASC.Mail.Aggregator.CollectionService.exe.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\ASC.Mail.EmlDownloader.exe.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregatorSrv\web.autofac.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Autofac.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregatorSrv\web.consumers.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Consumers.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregatorSrv\web.storage.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Storage.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregatorSrv\mail.agg.log4net.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.Srv.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregatorSrv\mail.agg.nlog.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.Srv.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregatorSrv\ASC.Mail.Aggregator.CollectionService.exe.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.Srv.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregatorSrv\ASC.Mail.EmlDownloader.exe.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Agg.Srv.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\web.autofac.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Autofac.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\ASC.Mail.Watchdog.Service.exe.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Dog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.log4net.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Dog.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.nlog.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Dog.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\web.autofac.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Autofac.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\web.storage.config" >
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Web.Storage.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\ASC.Mail.StorageCleaner.exe.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Cln.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\mail.cln.log4net.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Cln.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\mail.cln.nlog.config">
|
||||
<SubstitutionsFile>$(MailFilesDir)\Substitutions\Mail.Cln.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
|
||||
<ConfigFiles Remove="@(ConfigFiles)" Condition="!Exists('%(ConfigFiles.SubstitutionsFile)')"/>
|
||||
</ItemGroup>
|
||||
|
||||
<RegexReplace Expression="(.+)\." Input="$(DeployTo)">
|
||||
<Output PropertyName="Substitution" TaskParameter="Output"/>
|
||||
</RegexReplace>
|
||||
|
||||
<XmlMassUpdate
|
||||
Condition="$(Substitution) != $(DeployTo)"
|
||||
ContentFile="%(ConfigFiles.FullPath)"
|
||||
ContentRoot="/"
|
||||
SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)"
|
||||
SubstitutionsRoot="/configuration/substitutions/$(Substitution)"
|
||||
NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity"/>
|
||||
<XmlMassUpdate
|
||||
ContentFile="%(ConfigFiles.FullPath)"
|
||||
ContentRoot="/"
|
||||
SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)"
|
||||
SubstitutionsRoot="/configuration/substitutions/$(DeployTo)"
|
||||
NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity"/>
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,67 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.AssemblyInfo" />
|
||||
<UsingTask AssemblyFile="$(ASCDir)web\core\ASC.Web.Core.BuildTask\bin\$(Configuration)\ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.ReplaceResources" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ASCDir>..\..\</ASCDir>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<ConfigurationSites Condition=" '$(ConfigurationSites)' == '' ">Debug</ConfigurationSites>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == '' ">Restore;Build</BuildTargets>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == 'ReBuild' ">Restore;ReBuild</BuildTargets>
|
||||
<ReplaceResources Condition="$(ReplaceResources)==''">0</ReplaceResources>
|
||||
<DeploySites Condition="'$(DeploySites)' == ''">0</DeploySites>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="BuildTask">
|
||||
<MSBuild
|
||||
BuildInParallel="true"
|
||||
Projects="$(ASCDir)web\core\ASC.Web.Core.sln"
|
||||
Targets="Restore;Build"
|
||||
Properties="Configuration=$(Configuration);AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true"
|
||||
StopOnFirstFailure="true"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="ReplaceResources">
|
||||
<CallTarget Targets="BuildTask" />
|
||||
<ReplaceResources BaseFolder="$(ASCDir)" ResourceFile="$(ASCDir)build\sql\r7.resources.json" />
|
||||
</Target>
|
||||
|
||||
|
||||
<Target Name="Build">
|
||||
<CreateItem Include="$(ASCDir)\build\msbuild\">
|
||||
<Output ItemName="AlToolPath" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<CallTarget Targets="ReplaceResources" Condition=" '$(ReplaceResources)' == '1' "/>
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="true"
|
||||
Projects="$(ASCDir)Studio.sln"
|
||||
Targets="$(BuildTargets)"
|
||||
Properties="Configuration=$(Configuration);DeployTo=$(DeployTo);AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants)"
|
||||
RebaseOutputs="true"
|
||||
StopOnFirstFailure="true"/>
|
||||
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.Socket.IO\" ContinueOnError="true"/>
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.Thumbnails\" ContinueOnError="true"/>
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.SsoAuth\" ContinueOnError="true"/>
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.UrlShortener\" ContinueOnError="true"/>
|
||||
|
||||
</Target>
|
||||
|
||||
<Target Name="SetAssemblyInfo">
|
||||
<Message Text="%(ProjectToBuild.Filename)"/>
|
||||
<AssemblyInfo CodeLanguage="CS"
|
||||
OutputFile="%(ProjectToBuild.RootDir)%(ProjectToBuild.Directory)Properties\AssemblyInfo.cs"
|
||||
AssemblyProduct="ONLYOFFICE"
|
||||
AssemblyTitle="%(ProjectToBuild.Filename)"
|
||||
AssemblyCompany="Ascensio System SIA"
|
||||
AssemblyCopyright="Ascensio System SIA 2015"
|
||||
AssemblyTrademark="ONLYOFFICE™"
|
||||
AssemblyVersion="8.0.0.0"
|
||||
AssemblyFileVersion="8.0.0.0"/>
|
||||
</Target>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.AssemblyInfo" />
|
||||
<UsingTask AssemblyFile="$(ASCDir)web\core\ASC.Web.Core.BuildTask\bin\$(Configuration)\ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.ReplaceResources" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ASCDir>..\..\</ASCDir>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<ConfigurationSites Condition=" '$(ConfigurationSites)' == '' ">Debug</ConfigurationSites>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == '' ">Restore;Build</BuildTargets>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == 'ReBuild' ">Restore;ReBuild</BuildTargets>
|
||||
<ReplaceResources Condition="$(ReplaceResources)==''">0</ReplaceResources>
|
||||
<DeploySites Condition="'$(DeploySites)' == ''">0</DeploySites>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="BuildTask">
|
||||
<MSBuild
|
||||
BuildInParallel="true"
|
||||
Projects="$(ASCDir)web\core\ASC.Web.Core.sln"
|
||||
Targets="Restore;Build"
|
||||
Properties="Configuration=$(Configuration);AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true"
|
||||
StopOnFirstFailure="true"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="ReplaceResources">
|
||||
<CallTarget Targets="BuildTask" />
|
||||
<ReplaceResources BaseFolder="$(ASCDir)" ResourceFile="$(ASCDir)build\sql\custom.resources.json" />
|
||||
</Target>
|
||||
|
||||
|
||||
<Target Name="Build">
|
||||
<CreateItem Include="$(ASCDir)\build\msbuild\">
|
||||
<Output ItemName="AlToolPath" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<CallTarget Targets="ReplaceResources" Condition=" '$(ReplaceResources)' == '1' "/>
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="true"
|
||||
Projects="$(ASCDir)Studio.sln"
|
||||
Targets="$(BuildTargets)"
|
||||
Properties="Configuration=$(Configuration);DeployTo=$(DeployTo);AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants)"
|
||||
RebaseOutputs="true"
|
||||
StopOnFirstFailure="true"/>
|
||||
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.Socket.IO\" ContinueOnError="true"/>
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.Thumbnails\" ContinueOnError="true"/>
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.SsoAuth\" ContinueOnError="true"/>
|
||||
<Exec Command="yarn install --frozen-lockfile" WorkingDirectory="$(ASCDir)module\ASC.UrlShortener\" ContinueOnError="true"/>
|
||||
|
||||
</Target>
|
||||
|
||||
<Target Name="SetAssemblyInfo">
|
||||
<Message Text="%(ProjectToBuild.Filename)"/>
|
||||
<AssemblyInfo CodeLanguage="CS"
|
||||
OutputFile="%(ProjectToBuild.RootDir)%(ProjectToBuild.Directory)Properties\AssemblyInfo.cs"
|
||||
AssemblyProduct="ONLYOFFICE"
|
||||
AssemblyTitle="%(ProjectToBuild.Filename)"
|
||||
AssemblyCompany="Ascensio System SIA"
|
||||
AssemblyCopyright="Ascensio System SIA 2015"
|
||||
AssemblyTrademark="ONLYOFFICE™"
|
||||
AssemblyVersion="8.0.0.0"
|
||||
AssemblyFileVersion="8.0.0.0"/>
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.AssemblyInfo" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ASCDir>..\..\</ASCDir>
|
||||
<ConfigurationSites Condition=" '$(ConfigurationSites)' == '' ">Debug</ConfigurationSites>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == '' ">Restore;Build</BuildTargets>
|
||||
<DeploySites Condition="'$(DeploySites)' == ''">0</DeploySites>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="Build">
|
||||
<Message Text="$(BuildTargets) projects ($(Configuration)):"/>
|
||||
<Message Text="- %(ProjectSitesToBuild.Filename)%(ProjectSitesToBuild.Extension)"/>
|
||||
<Message Text=" "/>
|
||||
|
||||
<CreateItem Include="$(ASCDir)\build\msbuild\">
|
||||
<Output ItemName="AlToolPath" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="true"
|
||||
Projects="$(ASCDir)Sites.sln"
|
||||
Targets="$(BuildTargets)"
|
||||
Properties="Configuration=$(ConfigurationSites);DeployTo=$(DeployTo);AlToolPath=%(AlToolPath.FullPath)"
|
||||
RebaseOutputs="true"
|
||||
StopOnFirstFailure="true"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="SetAssemblyInfo">
|
||||
<Message Text="%(ProjectToBuild.Filename)"/>
|
||||
<AssemblyInfo CodeLanguage="CS"
|
||||
OutputFile="%(ProjectToBuild.RootDir)%(ProjectToBuild.Directory)Properties\AssemblyInfo.cs"
|
||||
AssemblyProduct="ONLYOFFICE"
|
||||
AssemblyTitle="%(ProjectToBuild.Filename)"
|
||||
AssemblyCompany="Ascensio System SIA"
|
||||
AssemblyCopyright="Ascensio System SIA 2015"
|
||||
AssemblyTrademark="ONLYOFFICE™"
|
||||
AssemblyVersion="8.0.0.0"
|
||||
AssemblyFileVersion="8.0.0.0"/>
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.AssemblyInfo" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ASCDir>..\..\</ASCDir>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<ConfigurationSites Condition=" '$(ConfigurationSites)' == '' ">Debug</ConfigurationSites>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == '' ">Build</BuildTargets>
|
||||
|
||||
<DeploySites Condition="'$(DeploySites)' == ''">0</DeploySites>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">$(ASCDir).nuget\NuGet.exe</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono $(ASCDir).nuget\NuGet.exe</NuGetCommand>
|
||||
<PackagesConfig>$(ASCDir)Tests.sln</PackagesConfig>
|
||||
<RestoreCommand>$(NuGetCommand) restore $(PackagesConfig)</RestoreCommand>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="Build">
|
||||
<CreateItem Include="$(ASCDir)\build\msbuild\">
|
||||
<Output ItemName="AlToolPath" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
|
||||
<Exec Command="$(RestoreCommand)" Condition="Exists('$(PackagesConfig)')" />
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="true"
|
||||
Projects="$(ASCDir)Tests.sln"
|
||||
Targets="$(BuildTargets)"
|
||||
Properties="Configuration=$(Configuration);DeployTo=$(DeployTo);AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants)"
|
||||
RebaseOutputs="true"
|
||||
StopOnFirstFailure="true"/>
|
||||
|
||||
</Target>
|
||||
|
||||
<Target Name="SetAssemblyInfo">
|
||||
<Message Text="%(ProjectToBuild.Filename)"/>
|
||||
<AssemblyInfo CodeLanguage="CS"
|
||||
OutputFile="%(ProjectToBuild.RootDir)%(ProjectToBuild.Directory)Properties\AssemblyInfo.cs"
|
||||
AssemblyProduct="ONLYOFFICE"
|
||||
AssemblyTitle="%(ProjectToBuild.Filename)"
|
||||
AssemblyCompany="Ascensio System SIA"
|
||||
AssemblyCopyright="Ascensio System SIA 2015"
|
||||
AssemblyTrademark="ONLYOFFICE™"
|
||||
AssemblyVersion="8.0.0.0"
|
||||
AssemblyFileVersion="8.0.0.0"/>
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,364 +1,364 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Deploy">
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.XmlUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.Xml.XmlMassUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CopyDirectory" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CopyFiles" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RemoveDuplicatesAssemblies" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RegexReplace" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CssCompress" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.FileUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.XmlRead" />
|
||||
<UsingTask AssemblyFile="$(RootDir)web\core\ASC.Web.Core.BuildTask\bin\$(Configuration)\ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.GenerateBundle" />
|
||||
<UsingTask AssemblyFile="$(RootDir)web\core\ASC.Web.Core.BuildTask\bin\$(Configuration)\ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.GenerateHelpCenterHtml" />
|
||||
<PropertyGroup>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == 'Build' ">Restore;Build</BuildTargets>
|
||||
<Configuration Condition="$(Configuration)==''">Debug</Configuration>
|
||||
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
|
||||
<BinDir>$(RootDir)web\studio\ASC.Web.Studio\bin\</BinDir>
|
||||
<DeployTo Condition="$(DeployTo)==''">OPENSOURCE.SERVER</DeployTo>
|
||||
<DeployDir Condition="$(DeployDir)==''">$(RootDir)build\deploy\</DeployDir>
|
||||
<OutDir Condition="$(OutDir)==''">$(DeployDir)$(DeployTo)\</OutDir>
|
||||
<SplitServices Condition="$(SplitServices)==''">0</SplitServices>
|
||||
<LessCompile Condition="$(LessCompile)==''">1</LessCompile>
|
||||
<CssMinify Condition="$(CssMinify)==''">1</CssMinify>
|
||||
<GenerateBundle Condition="$(GenerateBundle)==''">0</GenerateBundle>
|
||||
<GenerateHelpCenterHtml Condition="$(GenerateHelpCenterHtml)==''">0</GenerateHelpCenterHtml>
|
||||
<Uploads Condition="'$(Uploads)' == ''">1</Uploads>
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">$(RootDir).nuget\NuGet.exe</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono $(RootDir).nuget\NuGet.exe</NuGetCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<LessCommand Condition=" '$(OS)' == 'Windows_NT'">$(RootDir)packages\dotless.1.5.2\tool\dotless.compiler.exe</LessCommand>
|
||||
<LessCommand Condition=" '$(OS)' != 'Windows_NT' ">mono $(RootDir)packages\dotless.1.5.2\tool\dotless.compiler.exe</LessCommand>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<MailServiceToDeploy Include="MailAggregator">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.Aggregator.CollectionService\ASC.Mail.Aggregator.CollectionService.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailAggregator">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.EmlDownloader\ASC.Mail.EmlDownloader.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailWatchdog">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.Watchdog.Service\ASC.Mail.Watchdog.Service.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailCleaner">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.StorageCleaner\ASC.Mail.StorageCleaner.Service.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ServiceToDeploy Include="SocketIO">
|
||||
<Launcher>ASC.Socket.IO.Svc.Launcher, ASC.Socket.IO.Svc</Launcher>
|
||||
<ProjPath>module\ASC.Socket.IO.Svc\ASC.Socket.IO.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Telegram">
|
||||
<Launcher>ASC.TelegramService.Launcher, ASC.TelegramService</Launcher>
|
||||
<ProjPath>module\ASC.TelegramService\ASC.TelegramService.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Thumbnails">
|
||||
<Launcher>ASC.Thumbnails.Svc.Launcher, ASC.Thumbnails.Svc</Launcher>
|
||||
<ProjPath>module\ASC.Thumbnails.Svc\ASC.Thumbnails.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="SsoAuth">
|
||||
<Launcher>ASC.SsoAuth.Svc.Launcher, ASC.SsoAuth.Svc</Launcher>
|
||||
<ProjPath>module\ASC.SsoAuth.Svc\ASC.SsoAuth.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="UrlShortener">
|
||||
<Launcher>ASC.UrlShortener.Svc.Launcher, ASC.UrlShortener.Svc</Launcher>
|
||||
<ProjPath>module\ASC.UrlShortener.Svc\ASC.UrlShortener.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Radicale">
|
||||
<Launcher>ASC.Radicale.Launcher, ASC.Radicale</Launcher>
|
||||
<ProjPath>module\ASC.Radicale\ASC.Radicale.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Notify">
|
||||
<Launcher>ASC.Notify.NotifyServiceLauncher, ASC.Notify</Launcher>
|
||||
<ProjPath>module\ASC.Notify\ASC.Notify\ASC.Notify.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Index">
|
||||
<Launcher>ASC.ElasticSearch.Launcher, ASC.ElasticSearch</Launcher>
|
||||
<ProjPath>module\ASC.ElasticSearch\ASC.ElasticSearch.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Feed">
|
||||
<Launcher>ASC.Feed.Aggregator.FeedAggregatorLauncher, ASC.Feed.Aggregator</Launcher>
|
||||
<ProjPath>module\ASC.Feed.Aggregator\ASC.Feed.Aggregator.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Backup">
|
||||
<Launcher>ASC.Data.Backup.Service.BackupServiceLauncher, ASC.Data.Backup</Launcher>
|
||||
<ProjPath>common\ASC.Data.Backup\ASC.Data.Backup.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Migrate">
|
||||
<Launcher>ASC.Data.Storage.Migration.Launcher, ASC.Data.Storage.Migration</Launcher>
|
||||
<ProjPath>common\ASC.Data.Storage.Migration\ASC.Data.Storage.Migration.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Encryption">
|
||||
<Launcher>ASC.Data.Storage.Encryption.Launcher, ASC.Data.Storage.Encryption</Launcher>
|
||||
<ProjPath>common\ASC.Data.Storage.Encryption\ASC.Data.Storage.Encryption.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="ThumbnailBuilder">
|
||||
<Launcher>ASC.Files.ThumbnailBuilder.Launcher, ASC.Files.ThumbnailBuilder</Launcher>
|
||||
<ProjPath>module\ASC.Files.ThumbnailBuilder\ASC.Files.ThumbnailBuilder.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WebToDeploy Include="$(RootDir)module\ASC.Files.Thirdparty\ASC.Files.Thirdparty.csproj" />
|
||||
<WebToDeploy Include="$(RootDir)web\studio\ASC.Web.Studio\Products\**\ASC.Web.*.csproj" Exclude="$(RootDir)web\studio\ASC.Web.Studio\Products\**\ASC.Web.*.Tests.csproj" />
|
||||
<WebToDeploy Include="$(RootDir)web\studio\ASC.Web.Studio\addons\**\ASC.Web.*.csproj" Exclude="$(RootDir)web\studio\ASC.Web.Studio\addons\**\ASC.Web.*.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CommunityDeleteList Include="SingleSignOnSettings\SingleSignOnSettings.ascx" />
|
||||
<CommunityDeleteList Include="AdditionalWhiteLabel\AdditionalWhiteLabel.ascx" />
|
||||
<CommunityDeleteList Include="WhiteLabel\WhiteLabel.ascx" />
|
||||
<CommunityDeleteList Include="Restore\Restore.ascx" />
|
||||
<CommunityDeleteList Include="Backup\Backup.ascx" />
|
||||
<CommunityDeleteList Include="AuditTrail\AuditTrail.ascx" />
|
||||
<CommunityDeleteList Include="LdapSettings\LdapSettings.ascx" />
|
||||
<CommunityDeleteList Include="StorageSettings\StorageSettings.ascx" />
|
||||
</ItemGroup>
|
||||
<Target Name="Deploy">
|
||||
<Message Text="Deploy parameters:" />
|
||||
<Message Text=" SplitServices = $(SplitServices)" />
|
||||
<RemoveDir Directories="$(OutDir)" ContinueOnError="true" Condition="'$(LeaveOutDir)' != '0'" />
|
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="DeployService" Properties="OutDir=$(OutDir);DeployTo=$(DeployTo);ServiceName=%(ServiceToDeploy.Identity);ProjPath=%(ServiceToDeploy.ProjPath);ServiceLauncher=%(ServiceToDeploy.Launcher);Disable_CopyWebApplication=true" />
|
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="DeployMail" Properties="OutDir=$(OutDir);DeployTo=$(DeployTo);ServiceName=%(MailServiceToDeploy.Identity);ProjPath=%(MailServiceToDeploy.ProjPath);Disable_CopyWebApplication=true" />
|
||||
<CopyDirectory SourceFolder="$(RootDir)web\studio\ASC.Web.Studio\" DestinationFolder="$(OutDir)WebStudio" ExcludeRegex="\\Products\\Projects\\Test\\|\\Products\\People\\Tests\\|\\Data\\|\\obj\\|\\bin\\.*\.xml$|\\bin\\.*\.pdb$|\.sln$|\.cs$|\.csproj$|\.suo$|\.user$|\.mdb$|\.userprefs$|\.pfx$|\\static\\helpcenter\\.+" />
|
||||
<RemoveDuplicatesAssemblies SourceFolder="$(OutDir)WebStudio" />
|
||||
<CallTarget Targets="CssMinify" Condition=" '$(CssMinify)' == '1' " />
|
||||
<CallTarget Targets="LessCompile" Condition=" '$(LessCompile)' == '1' " />
|
||||
<CallTarget Targets="GenerateBundle" Condition=" '$(GenerateBundle)' == '1' " />
|
||||
<CallTarget Targets="GenerateHelpCenterHtml" Condition=" '$(GenerateHelpCenterHtml)' == '1' " />
|
||||
<CopyDirectory Condition=" '$(Uploads)' == '1' AND Exists('$(RootDir)web\studio\ASC.Web.Upload\') " SourceFolder="$(RootDir)web\studio\ASC.Web.Upload\" DestinationFolder="$(OutDir)Uploads" ExcludeRegex="\\Data\\|\\obj\\|\\bin\\.*\.xml$|\\bin\\.*\.pdb$|\.sln$|\.cs$|\.csproj$|\.suo$|\.user$|\.mdb$|\.userprefs$" />
|
||||
<CallTarget Targets="ChangeConfigs" Condition=" Exists( '$(RootDir)build\config\private\' ) " />
|
||||
<CreateItem Include="$(OutDir)WebStudio\web.appsettings.config;$(OutDir)WebStudio\web.connections.config;$(OutDir)WebStudio\web.storage.config;$(OutDir)WebStudio\web.autofac.config;$(OutDir)WebStudio\web.consumers.config">
|
||||
<Output ItemName="WebConfigurationFiles" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<Copy Condition="Exists('$(RootDir)build\ManageServices.bat')" SourceFiles="$(RootDir)build\ManageServices.bat" DestinationFolder="$(OutDir)Services\TeamLabSvc\" />
|
||||
<Copy Condition="Exists('$(OutDir)Uploads\')" SourceFiles="@(WebConfigurationFiles)" DestinationFolder="$(OutDir)Uploads\" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.storage.config" DestinationFiles="$(OutDir)Services\MailAggregator\web.storage.config" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.consumers.config" DestinationFolder="$(OutDir)Services\MailAggregator\" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.storage.config" DestinationFolder="$(OutDir)Services\MailCleaner\" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.autofac.config" DestinationFolder="$(OutDir)Services\%(MailServiceToDeploy.Identity)\" />
|
||||
<Copy SourceFiles="$(RootDir)build\config\private\sp.pfx" DestinationFolder="$(OutDir)WebStudio\Certificates\" Condition="'$(DeployTo)'=='COM' Or '$(DeployTo)'=='EU.COM' Or '$(DeployTo)'=='SG.COM' Or '$(DeployTo)'=='INFO'" />
|
||||
<Delete Files="@(CommunityDeleteList->'$(OutDir)WebStudio\UserControls\Management\%(Identity)')" Condition="'$(DeployTo)'=='SERVER' Or '$(DeployTo)'=='UNIX.SERVER' Or '$(DeployTo)'=='AMI.SERVER'" />
|
||||
<Delete Files="$(OutDir)WebStudio\bin\Microsoft.VisualBasic.Activities.Compiler.dll" Condition=" Exists( '$(OutDir)WebStudio\bin\Microsoft.VisualBasic.Activities.Compiler.dll' ) " />
|
||||
<XmlUpdate XmlFileName="$(OutDir)Services\MailAggregator\web.storage.config" XPath="/storage/handler/add[@name='disc']/property/@value" Value="..\..\Data\" />
|
||||
<XmlUpdate XmlFileName="$(OutDir)Services\MailCleaner\web.storage.config" XPath="/storage/handler/add[@name='disc']/property/@value" Value="..\..\Data\" />
|
||||
<ItemGroup>
|
||||
<EncryptionDeleteList Include="$(OutDir)**\ASC.Data.Encryption.*" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(EncryptionDeleteList)" Condition="'$(DeployTo)'=='RU' Or '$(DeployTo)'=='R7-OFFICE.RU' Or '$(DeployTo)'=='R7-OFFICE.SERVER' Or '$(DeployTo)'=='R7-OFFICE.UNIX.SERVER'" />
|
||||
</Target>
|
||||
<Target Name="DeployService">
|
||||
<Message Text="Deploying service $(ServiceName)" />
|
||||
<PropertyGroup>
|
||||
<ServicePath Condition=" '$(SplitServices)' == '1' ">$(OutDir)Services\$(ServiceName)\</ServicePath>
|
||||
<ServicePath Condition=" '$(SplitServices)' != '1' ">$(OutDir)Services\TeamLabSvc\</ServicePath>
|
||||
</PropertyGroup>
|
||||
<Message Text="Deploying service path $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'))" />
|
||||
<MSBuild BuildInParallel="true" Projects="$(RootDir)$(ProjPath)" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
<ItemGroup>
|
||||
<ServiceFiles Include="$(RootDir)\web\studio\ASC.Web.Studio\web.autofac.config;$(RootDir)\web\studio\ASC.Web.Studio\web.consumers.config; $(RootDir)build\config\TeamLabSvc.exe.config;$(RootDir)module\ASC.TeamLabSvc\ASC.TeamLabSvc\bin\$(Configuration)\TeamLabSvc.exe" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="%(ServiceFiles.Identity)" DestinationFolder="$(ServicePath)" />
|
||||
<MSBuild Condition=" $(ServiceName) == 'Index' OR $(ServiceName) == 'Backup' OR $(ServiceName) == 'Notify'" BuildInParallel="true" Projects="%(WebToDeploy.Identity)" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
<MSBuild Condition="$(ServiceName) == 'Backup' OR $(ServiceName) == 'Notify'" BuildInParallel="true" Projects="$(RootDir)module\ASC.Api\ASC.Api.Calendar\ASC.Api.Calendar.csproj" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'SocketIO' AND Exists('$(RootDir)module\ASC.Socket.IO\') " SourceFolder="$(RootDir)module\ASC.Socket.IO\" DestinationFolder="$(OutDir)Services\ASC.Socket.IO" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'Thumbnails' AND Exists('$(RootDir)module\ASC.Thumbnails\') " SourceFolder="$(RootDir)module\ASC.Thumbnails\" DestinationFolder="$(OutDir)Services\ASC.Thumbnails" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'SsoAuth' AND Exists('$(RootDir)module\ASC.SsoAuth\') " SourceFolder="$(RootDir)module\ASC.SsoAuth\" DestinationFolder="$(OutDir)Services\ASC.SsoAuth" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'UrlShortener' AND Exists('$(RootDir)module\ASC.UrlShortener\') " SourceFolder="$(RootDir)module\ASC.UrlShortener\" DestinationFolder="$(OutDir)Services\ASC.UrlShortener" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<RegexReplace Expression=".+\." Input="$(DeployTo)">
|
||||
<Output PropertyName="Substitution" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<CreateItem Include="$(Substitution)" Condition=" $(Substitution) != $(DeployTo) ">
|
||||
<Output ItemName="ConfigSubstitutionRoot" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<RegexReplace Expression="^[^.]*\." Input="$(DeployTo)">
|
||||
<Output PropertyName="SubstitutionNext" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<CreateItem Include="$(SubstitutionNext)" Condition="$(Substitution) != $(SubstitutionNext) ">
|
||||
<Output ItemName="ConfigSubstitutionRoot" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<CreateItem Include="$(DeployTo)">
|
||||
<Output ItemName="ConfigSubstitutionRoot" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<XmlMassUpdate Condition="'%(ConfigSubstitutionRoot.Identity)' != '' AND Exists('..\config\private\TeamLabSvc.exe.Config.Substitutions.xml')" ContentFile="$(ServicePath)\TeamLabSvc.exe.config" SubstitutionsFile="..\config\private\TeamLabSvc.exe.Config.Substitutions.xml" ContentRoot="/" SubstitutionsRoot="/configuration/substitutions/%(ConfigSubstitutionRoot.Identity)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<XmlMassUpdate Condition="'%(ConfigSubstitutionRoot.Identity)' != '' AND Exists('..\config\private\Web.Consumers.Config.Substitutions.xml')" ContentFile="$(ServicePath)\web.consumers.config" SubstitutionsFile="..\config\private\Web.Consumers.Config.Substitutions.xml" ContentRoot="/" SubstitutionsRoot="/configuration/substitutions/%(ConfigSubstitutionRoot.Identity)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<XmlMassUpdate Condition="'%(ConfigSubstitutionRoot.Identity)' != '' AND Exists('..\config\private\Web.Autofac.Config.Substitutions.xml')" ContentFile="$(ServicePath)\web.autofac.config" SubstitutionsFile="..\config\private\Web.Autofac.Config.Substitutions.xml" ContentRoot="/" SubstitutionsRoot="/configuration/substitutions/%(ConfigSubstitutionRoot.Identity)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<XmlUpdate Condition="'$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/teamlab/services/add[not(@type='$(ServiceLauncher)')]" Delete="true" />
|
||||
<XmlUpdate Condition="'$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/log4net/appender[@name='File']/file/conversionPattern/@value" Value="%folder{LogDirectory}svc$(ServiceName)" />
|
||||
<XmlUpdate Condition="'$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/log4net/appender[@name='Sql']/file/conversionPattern/@value" Value="%folder{LogDirectory}svc$(ServiceName).SQL.log" />
|
||||
<XmlUpdate Condition="'$(ServiceLauncher)' != '' AND '$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/nlog/variable[@name='svcName']/@value" Value="$(ServiceName)" />
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_portal_url']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicalePortalUrl" />
|
||||
</XmlRead>
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_filesystem_folder']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicaleFilesystemFolder" />
|
||||
</XmlRead>
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_machine_key']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicaleMachineKey" />
|
||||
</XmlRead>
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_log_file']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicaleLogFile" />
|
||||
</XmlRead>
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.config" Encoding="ASCII" Regex="portal_url =.+" ReplacementText="portal_url = $(RadicalePortalUrl)" />
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.config" Encoding="ASCII" Regex="filesystem_folder =.+" ReplacementText="filesystem_folder = $(RadicaleFilesystemFolder)" />
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.log.config" Encoding="ASCII" Regex="args = .+" ReplacementText="args = ($(RadicaleLogFile),'midnight', 1, 7)" />
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.config" Encoding="ASCII" Regex="machine_key =.+" ReplacementText="machine_key = $(RadicaleMachineKey)" />
|
||||
</Target>
|
||||
<Target Name="DeployMail">
|
||||
<Message Text="Deploying service $(ServiceName)" />
|
||||
<PropertyGroup>
|
||||
<ServicePath>$(OutDir)Services\$(ServiceName)\</ServicePath>
|
||||
</PropertyGroup>
|
||||
<Message Text="Deploying service path $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'))" />
|
||||
<MSBuild BuildInParallel="true" Projects="$(RootDir)$(ProjPath)" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
</Target>
|
||||
<Target Name="BuildTask">
|
||||
<MSBuild BuildInParallel="true" Projects="$(RootDir)web\core\ASC.Web.Core.sln" Targets="Restore;ReBuild" Properties="Configuration=$(Configuration);AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
</Target>
|
||||
<Target Name="GenerateBundle">
|
||||
<CallTarget Targets="BuildTask" />
|
||||
<GenerateBundle WebStudioFolder="$(OutDir)\WebStudio\" />
|
||||
</Target>
|
||||
<Target Name="GenerateHelpCenterHtml">
|
||||
<CallTarget Targets="BuildTask" Condition=" '$(GenerateBundle)' == '0' " />
|
||||
<GenerateHelpCenterHtml WebStudioFolder="$(OutDir)\WebStudio\" />
|
||||
</Target>
|
||||
<Target Name="LessCompile">
|
||||
<ItemGroup>
|
||||
<LessFilesInclude Include="$(OutDir)WebStudio\**\*.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\calendar\UserControls\fullcalendar\css\fullcalendar.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\Products\Files\Controls\Tree\tree.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\Products\CRM\App_Themes\Default\css\base.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\UserControls\Common\SharingSettings\css\default\baseparams.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\UserControls\Common\SharingSettings\css\default\sharingsettings.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\base.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\actionpanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\buttons.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\common.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\common_style.wide-screen.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\contentmenu.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\headers.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\links.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\lists.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\*\params.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\sidepanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\tl-combobox.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\topstudiopanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\voip.phone.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\whitelabel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\jquery-advansedfilter-theme.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\jstree\**\*.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\icons.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\autocomplete.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\message.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\tags.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\attachments.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\popup.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\accountspanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\accounts.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\contacts.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\settings.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\crm_integration.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\accountpopup.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\print.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\administration.less" />
|
||||
<LessFiles Include="@(LessFilesInclude)" Exclude="@(LessFilesExlude)" />
|
||||
</ItemGroup>
|
||||
<Exec Command="$(NuGetCommand) install dotless -Version 1.5.2 -OutputDirectory $(RootDir)packages" />
|
||||
<Exec Command="$(LessCommand) -m "%(LessFiles.FullPath)" "%(LessFiles->%(RootDir)%(Directory)%(Filename).min.css"" />
|
||||
</Target>
|
||||
<Target Name="CssMinify">
|
||||
<ItemGroup>
|
||||
<CssFiles Include="$(OutDir)WebStudio\**\*.css" />
|
||||
</ItemGroup>
|
||||
<CssCompress SourceFiles="@(CssFiles)" DestinationFiles="%(RootDir)%(Directory)%(Filename).min.css" />
|
||||
</Target>
|
||||
<Target Name="ChangeConfigs">
|
||||
<ItemGroup>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\Web.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.connections.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Connections.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.appsettings.config">
|
||||
<SubstitutionsFile>..\config\private\Web.AppSettings.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.autofac.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Autofac.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.consumers.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Consumers.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Log4net.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Web.NLog.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.storage.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Storage.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\ASC.Mail.Aggregator.CollectionService.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\ASC.Mail.EmlDownloader.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\mail.agg.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\mail.agg.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\ASC.Mail.Watchdog.Service.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\ASC.Mail.StorageCleaner.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Cln.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\mail.cln.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Cln.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\mail.cln.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Cln.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Remove="@(ConfigFiles)" Condition="!Exists('%(ConfigFiles.SubstitutionsFile)')" />
|
||||
</ItemGroup>
|
||||
<RegexReplace Expression="(.+)\." Input="$(DeployTo)">
|
||||
<Output PropertyName="Substitution" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<Message Text="ChangeConfigs: SubstitutionsRoot: /configuration/substitutions/$(Substitution)" />
|
||||
<XmlMassUpdate Condition="$(Substitution) != $(DeployTo)" ContentFile="%(ConfigFiles.FullPath)" ContentRoot="/" SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)" SubstitutionsRoot="/configuration/substitutions/$(Substitution)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<RegexReplace Expression="^[^.]*\." Input="$(DeployTo)">
|
||||
<Output PropertyName="SubstitutionNext" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<Message Text="ChangeConfigs: SubstitutionsRoot: /configuration/substitutions/$(SubstitutionNext)" />
|
||||
<XmlMassUpdate Condition="$(Substitution) != $(SubstitutionNext)" ContentFile="%(ConfigFiles.FullPath)" ContentRoot="/" SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)" SubstitutionsRoot="/configuration/substitutions/$(SubstitutionNext)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<Message Text="ChangeConfigs: SubstitutionsRoot: /configuration/substitutions/$(DeployTo)" />
|
||||
<XmlMassUpdate ContentFile="%(ConfigFiles.FullPath)" ContentRoot="/" SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)" SubstitutionsRoot="/configuration/substitutions/$(DeployTo)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
</Target>
|
||||
<Target Name="CopyConfigsForBackup">
|
||||
<CreateItem Include="$(Regions)">
|
||||
<Output ItemName="RegionsArray" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="CopyConfigForBackup" Properties="DeployTo=$(DeployTo);Region=%(RegionsArray.Identity)" />
|
||||
</Target>
|
||||
<Target Name="CopyConfigForBackup">
|
||||
<CreateItem Include="$(DeployDir)$(Region)\WebStudio\*.config">
|
||||
<Output ItemName="ConfigFiles" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<Copy Condition="Exists('$(OutDir)Services\TeamLabSvc\')" SourceFiles="@(ConfigFiles)" DestinationFolder="$(OutDir)Services\TeamLabSvc\$(Region)\" />
|
||||
<Copy Condition="Exists('$(OutDir)Services\Backup\')" SourceFiles="@(ConfigFiles)" DestinationFolder="$(OutDir)Services\Backup\$(Region)\" />
|
||||
</Target>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Deploy">
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.XmlUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.Xml.XmlMassUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CopyDirectory" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CopyFiles" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RemoveDuplicatesAssemblies" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RegexReplace" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CssCompress" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.FileUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.XmlRead" />
|
||||
<UsingTask AssemblyFile="$(RootDir)web\core\ASC.Web.Core.BuildTask\bin\$(Configuration)\ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.GenerateBundle" />
|
||||
<UsingTask AssemblyFile="$(RootDir)web\core\ASC.Web.Core.BuildTask\bin\$(Configuration)\ASC.Web.Core.BuildTask.dll" TaskName="ASC.Web.Core.BuildTask.GenerateHelpCenterHtml" />
|
||||
<PropertyGroup>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == 'Build' ">Restore;Build</BuildTargets>
|
||||
<Configuration Condition="$(Configuration)==''">Debug</Configuration>
|
||||
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
|
||||
<BinDir>$(RootDir)web\studio\ASC.Web.Studio\bin\</BinDir>
|
||||
<DeployTo Condition="$(DeployTo)==''">OPENSOURCE.SERVER</DeployTo>
|
||||
<DeployDir Condition="$(DeployDir)==''">$(RootDir)build\deploy\</DeployDir>
|
||||
<OutDir Condition="$(OutDir)==''">$(DeployDir)$(DeployTo)\</OutDir>
|
||||
<SplitServices Condition="$(SplitServices)==''">0</SplitServices>
|
||||
<LessCompile Condition="$(LessCompile)==''">1</LessCompile>
|
||||
<CssMinify Condition="$(CssMinify)==''">1</CssMinify>
|
||||
<GenerateBundle Condition="$(GenerateBundle)==''">0</GenerateBundle>
|
||||
<GenerateHelpCenterHtml Condition="$(GenerateHelpCenterHtml)==''">0</GenerateHelpCenterHtml>
|
||||
<Uploads Condition="'$(Uploads)' == ''">1</Uploads>
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">$(RootDir).nuget\NuGet.exe</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono $(RootDir).nuget\NuGet.exe</NuGetCommand>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<LessCommand Condition=" '$(OS)' == 'Windows_NT'">$(RootDir)packages\dotless.1.5.2\tool\dotless.compiler.exe</LessCommand>
|
||||
<LessCommand Condition=" '$(OS)' != 'Windows_NT' ">mono $(RootDir)packages\dotless.1.5.2\tool\dotless.compiler.exe</LessCommand>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<MailServiceToDeploy Include="MailAggregator">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.Aggregator.CollectionService\ASC.Mail.Aggregator.CollectionService.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailAggregator">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.EmlDownloader\ASC.Mail.EmlDownloader.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailWatchdog">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.Watchdog.Service\ASC.Mail.Watchdog.Service.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailCleaner">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.StorageCleaner\ASC.Mail.StorageCleaner.Service.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ServiceToDeploy Include="SocketIO">
|
||||
<Launcher>ASC.Socket.IO.Svc.Launcher, ASC.Socket.IO.Svc</Launcher>
|
||||
<ProjPath>module\ASC.Socket.IO.Svc\ASC.Socket.IO.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Telegram">
|
||||
<Launcher>ASC.TelegramService.Launcher, ASC.TelegramService</Launcher>
|
||||
<ProjPath>module\ASC.TelegramService\ASC.TelegramService.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Thumbnails">
|
||||
<Launcher>ASC.Thumbnails.Svc.Launcher, ASC.Thumbnails.Svc</Launcher>
|
||||
<ProjPath>module\ASC.Thumbnails.Svc\ASC.Thumbnails.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="SsoAuth">
|
||||
<Launcher>ASC.SsoAuth.Svc.Launcher, ASC.SsoAuth.Svc</Launcher>
|
||||
<ProjPath>module\ASC.SsoAuth.Svc\ASC.SsoAuth.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="UrlShortener">
|
||||
<Launcher>ASC.UrlShortener.Svc.Launcher, ASC.UrlShortener.Svc</Launcher>
|
||||
<ProjPath>module\ASC.UrlShortener.Svc\ASC.UrlShortener.Svc.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Radicale">
|
||||
<Launcher>ASC.Radicale.Launcher, ASC.Radicale</Launcher>
|
||||
<ProjPath>module\ASC.Radicale\ASC.Radicale.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Notify">
|
||||
<Launcher>ASC.Notify.NotifyServiceLauncher, ASC.Notify</Launcher>
|
||||
<ProjPath>module\ASC.Notify\ASC.Notify\ASC.Notify.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Index">
|
||||
<Launcher>ASC.ElasticSearch.Launcher, ASC.ElasticSearch</Launcher>
|
||||
<ProjPath>module\ASC.ElasticSearch\ASC.ElasticSearch.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Feed">
|
||||
<Launcher>ASC.Feed.Aggregator.FeedAggregatorLauncher, ASC.Feed.Aggregator</Launcher>
|
||||
<ProjPath>module\ASC.Feed.Aggregator\ASC.Feed.Aggregator.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Backup">
|
||||
<Launcher>ASC.Data.Backup.Service.BackupServiceLauncher, ASC.Data.Backup</Launcher>
|
||||
<ProjPath>common\ASC.Data.Backup\ASC.Data.Backup.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Migrate">
|
||||
<Launcher>ASC.Data.Storage.Migration.Launcher, ASC.Data.Storage.Migration</Launcher>
|
||||
<ProjPath>common\ASC.Data.Storage.Migration\ASC.Data.Storage.Migration.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="Encryption">
|
||||
<Launcher>ASC.Data.Storage.Encryption.Launcher, ASC.Data.Storage.Encryption</Launcher>
|
||||
<ProjPath>common\ASC.Data.Storage.Encryption\ASC.Data.Storage.Encryption.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
<ServiceToDeploy Include="ThumbnailBuilder">
|
||||
<Launcher>ASC.Files.ThumbnailBuilder.Launcher, ASC.Files.ThumbnailBuilder</Launcher>
|
||||
<ProjPath>module\ASC.Files.ThumbnailBuilder\ASC.Files.ThumbnailBuilder.csproj</ProjPath>
|
||||
</ServiceToDeploy>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WebToDeploy Include="$(RootDir)module\ASC.Files.Thirdparty\ASC.Files.Thirdparty.csproj" />
|
||||
<WebToDeploy Include="$(RootDir)web\studio\ASC.Web.Studio\Products\**\ASC.Web.*.csproj" Exclude="$(RootDir)web\studio\ASC.Web.Studio\Products\**\ASC.Web.*.Tests.csproj" />
|
||||
<WebToDeploy Include="$(RootDir)web\studio\ASC.Web.Studio\addons\**\ASC.Web.*.csproj" Exclude="$(RootDir)web\studio\ASC.Web.Studio\addons\**\ASC.Web.*.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CommunityDeleteList Include="SingleSignOnSettings\SingleSignOnSettings.ascx" />
|
||||
<CommunityDeleteList Include="AdditionalWhiteLabel\AdditionalWhiteLabel.ascx" />
|
||||
<CommunityDeleteList Include="WhiteLabel\WhiteLabel.ascx" />
|
||||
<CommunityDeleteList Include="Restore\Restore.ascx" />
|
||||
<CommunityDeleteList Include="Backup\Backup.ascx" />
|
||||
<CommunityDeleteList Include="AuditTrail\AuditTrail.ascx" />
|
||||
<CommunityDeleteList Include="LdapSettings\LdapSettings.ascx" />
|
||||
<CommunityDeleteList Include="StorageSettings\StorageSettings.ascx" />
|
||||
</ItemGroup>
|
||||
<Target Name="Deploy">
|
||||
<Message Text="Deploy parameters:" />
|
||||
<Message Text=" SplitServices = $(SplitServices)" />
|
||||
<RemoveDir Directories="$(OutDir)" ContinueOnError="true" Condition="'$(LeaveOutDir)' != '0'" />
|
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="DeployService" Properties="OutDir=$(OutDir);DeployTo=$(DeployTo);ServiceName=%(ServiceToDeploy.Identity);ProjPath=%(ServiceToDeploy.ProjPath);ServiceLauncher=%(ServiceToDeploy.Launcher);Disable_CopyWebApplication=true" />
|
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="DeployMail" Properties="OutDir=$(OutDir);DeployTo=$(DeployTo);ServiceName=%(MailServiceToDeploy.Identity);ProjPath=%(MailServiceToDeploy.ProjPath);Disable_CopyWebApplication=true" />
|
||||
<CopyDirectory SourceFolder="$(RootDir)web\studio\ASC.Web.Studio\" DestinationFolder="$(OutDir)WebStudio" ExcludeRegex="\\Products\\Projects\\Test\\|\\Products\\People\\Tests\\|\\Data\\|\\obj\\|\\bin\\.*\.xml$|\\bin\\.*\.pdb$|\.sln$|\.cs$|\.csproj$|\.suo$|\.user$|\.mdb$|\.userprefs$|\.pfx$|\\static\\helpcenter\\.+" />
|
||||
<RemoveDuplicatesAssemblies SourceFolder="$(OutDir)WebStudio" />
|
||||
<CallTarget Targets="CssMinify" Condition=" '$(CssMinify)' == '1' " />
|
||||
<CallTarget Targets="LessCompile" Condition=" '$(LessCompile)' == '1' " />
|
||||
<CallTarget Targets="GenerateBundle" Condition=" '$(GenerateBundle)' == '1' " />
|
||||
<CallTarget Targets="GenerateHelpCenterHtml" Condition=" '$(GenerateHelpCenterHtml)' == '1' " />
|
||||
<CopyDirectory Condition=" '$(Uploads)' == '1' AND Exists('$(RootDir)web\studio\ASC.Web.Upload\') " SourceFolder="$(RootDir)web\studio\ASC.Web.Upload\" DestinationFolder="$(OutDir)Uploads" ExcludeRegex="\\Data\\|\\obj\\|\\bin\\.*\.xml$|\\bin\\.*\.pdb$|\.sln$|\.cs$|\.csproj$|\.suo$|\.user$|\.mdb$|\.userprefs$" />
|
||||
<CallTarget Targets="ChangeConfigs" Condition=" Exists( '$(RootDir)build\config\private\' ) " />
|
||||
<CreateItem Include="$(OutDir)WebStudio\web.appsettings.config;$(OutDir)WebStudio\web.connections.config;$(OutDir)WebStudio\web.storage.config;$(OutDir)WebStudio\web.autofac.config;$(OutDir)WebStudio\web.consumers.config">
|
||||
<Output ItemName="WebConfigurationFiles" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<Copy Condition="Exists('$(RootDir)build\ManageServices.bat')" SourceFiles="$(RootDir)build\ManageServices.bat" DestinationFolder="$(OutDir)Services\TeamLabSvc\" />
|
||||
<Copy Condition="Exists('$(OutDir)Uploads\')" SourceFiles="@(WebConfigurationFiles)" DestinationFolder="$(OutDir)Uploads\" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.storage.config" DestinationFiles="$(OutDir)Services\MailAggregator\web.storage.config" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.consumers.config" DestinationFolder="$(OutDir)Services\MailAggregator\" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.storage.config" DestinationFolder="$(OutDir)Services\MailCleaner\" />
|
||||
<Copy SourceFiles="$(OutDir)WebStudio\web.autofac.config" DestinationFolder="$(OutDir)Services\%(MailServiceToDeploy.Identity)\" />
|
||||
<Copy SourceFiles="$(RootDir)build\config\private\sp.pfx" DestinationFolder="$(OutDir)WebStudio\Certificates\" Condition="'$(DeployTo)'=='COM' Or '$(DeployTo)'=='EU.COM' Or '$(DeployTo)'=='SG.COM' Or '$(DeployTo)'=='INFO'" />
|
||||
<Delete Files="@(CommunityDeleteList->'$(OutDir)WebStudio\UserControls\Management\%(Identity)')" Condition="'$(DeployTo)'=='SERVER' Or '$(DeployTo)'=='UNIX.SERVER' Or '$(DeployTo)'=='AMI.SERVER'" />
|
||||
<Delete Files="$(OutDir)WebStudio\bin\Microsoft.VisualBasic.Activities.Compiler.dll" Condition=" Exists( '$(OutDir)WebStudio\bin\Microsoft.VisualBasic.Activities.Compiler.dll' ) " />
|
||||
<XmlUpdate XmlFileName="$(OutDir)Services\MailAggregator\web.storage.config" XPath="/storage/handler/add[@name='disc']/property/@value" Value="..\..\Data\" />
|
||||
<XmlUpdate XmlFileName="$(OutDir)Services\MailCleaner\web.storage.config" XPath="/storage/handler/add[@name='disc']/property/@value" Value="..\..\Data\" />
|
||||
<ItemGroup>
|
||||
<EncryptionDeleteList Include="$(OutDir)**\ASC.Data.Encryption.*" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(EncryptionDeleteList)" Condition="'$(DeployTo)'=='RU' Or '$(DeployTo)'=='R7-OFFICE.RU' Or '$(DeployTo)'=='R7-OFFICE.SERVER' Or '$(DeployTo)'=='R7-OFFICE.UNIX.SERVER'" />
|
||||
</Target>
|
||||
<Target Name="DeployService">
|
||||
<Message Text="Deploying service $(ServiceName)" />
|
||||
<PropertyGroup>
|
||||
<ServicePath Condition=" '$(SplitServices)' == '1' ">$(OutDir)Services\$(ServiceName)\</ServicePath>
|
||||
<ServicePath Condition=" '$(SplitServices)' != '1' ">$(OutDir)Services\TeamLabSvc\</ServicePath>
|
||||
</PropertyGroup>
|
||||
<Message Text="Deploying service path $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'))" />
|
||||
<MSBuild BuildInParallel="true" Projects="$(RootDir)$(ProjPath)" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
<ItemGroup>
|
||||
<ServiceFiles Include="$(RootDir)\web\studio\ASC.Web.Studio\web.autofac.config;$(RootDir)\web\studio\ASC.Web.Studio\web.consumers.config; $(RootDir)build\config\TeamLabSvc.exe.config;$(RootDir)module\ASC.TeamLabSvc\ASC.TeamLabSvc\bin\$(Configuration)\TeamLabSvc.exe" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="%(ServiceFiles.Identity)" DestinationFolder="$(ServicePath)" />
|
||||
<MSBuild Condition=" $(ServiceName) == 'Index' OR $(ServiceName) == 'Backup' OR $(ServiceName) == 'Notify'" BuildInParallel="true" Projects="%(WebToDeploy.Identity)" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
<MSBuild Condition="$(ServiceName) == 'Backup' OR $(ServiceName) == 'Notify'" BuildInParallel="true" Projects="$(RootDir)module\ASC.Api\ASC.Api.Calendar\ASC.Api.Calendar.csproj" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'SocketIO' AND Exists('$(RootDir)module\ASC.Socket.IO\') " SourceFolder="$(RootDir)module\ASC.Socket.IO\" DestinationFolder="$(OutDir)Services\ASC.Socket.IO" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'Thumbnails' AND Exists('$(RootDir)module\ASC.Thumbnails\') " SourceFolder="$(RootDir)module\ASC.Thumbnails\" DestinationFolder="$(OutDir)Services\ASC.Thumbnails" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'SsoAuth' AND Exists('$(RootDir)module\ASC.SsoAuth\') " SourceFolder="$(RootDir)module\ASC.SsoAuth\" DestinationFolder="$(OutDir)Services\ASC.SsoAuth" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<CopyDirectory Condition=" $(ServiceName) == 'UrlShortener' AND Exists('$(RootDir)module\ASC.UrlShortener\') " SourceFolder="$(RootDir)module\ASC.UrlShortener\" DestinationFolder="$(OutDir)Services\ASC.UrlShortener" ExcludeRegex="\\typings\\|\.njsproj$|typings\.json$" />
|
||||
<RegexReplace Expression=".+\." Input="$(DeployTo)">
|
||||
<Output PropertyName="Substitution" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<CreateItem Include="$(Substitution)" Condition=" $(Substitution) != $(DeployTo) ">
|
||||
<Output ItemName="ConfigSubstitutionRoot" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<RegexReplace Expression="^[^.]*\." Input="$(DeployTo)">
|
||||
<Output PropertyName="SubstitutionNext" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<CreateItem Include="$(SubstitutionNext)" Condition="$(Substitution) != $(SubstitutionNext) ">
|
||||
<Output ItemName="ConfigSubstitutionRoot" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<CreateItem Include="$(DeployTo)">
|
||||
<Output ItemName="ConfigSubstitutionRoot" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<XmlMassUpdate Condition="'%(ConfigSubstitutionRoot.Identity)' != '' AND Exists('..\config\private\TeamLabSvc.exe.Config.Substitutions.xml')" ContentFile="$(ServicePath)\TeamLabSvc.exe.config" SubstitutionsFile="..\config\private\TeamLabSvc.exe.Config.Substitutions.xml" ContentRoot="/" SubstitutionsRoot="/configuration/substitutions/%(ConfigSubstitutionRoot.Identity)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<XmlMassUpdate Condition="'%(ConfigSubstitutionRoot.Identity)' != '' AND Exists('..\config\private\Web.Consumers.Config.Substitutions.xml')" ContentFile="$(ServicePath)\web.consumers.config" SubstitutionsFile="..\config\private\Web.Consumers.Config.Substitutions.xml" ContentRoot="/" SubstitutionsRoot="/configuration/substitutions/%(ConfigSubstitutionRoot.Identity)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<XmlMassUpdate Condition="'%(ConfigSubstitutionRoot.Identity)' != '' AND Exists('..\config\private\Web.Autofac.Config.Substitutions.xml')" ContentFile="$(ServicePath)\web.autofac.config" SubstitutionsFile="..\config\private\Web.Autofac.Config.Substitutions.xml" ContentRoot="/" SubstitutionsRoot="/configuration/substitutions/%(ConfigSubstitutionRoot.Identity)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<XmlUpdate Condition="'$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/teamlab/services/add[not(@type='$(ServiceLauncher)')]" Delete="true" />
|
||||
<XmlUpdate Condition="'$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/log4net/appender[@name='File']/file/conversionPattern/@value" Value="%folder{LogDirectory}svc$(ServiceName)" />
|
||||
<XmlUpdate Condition="'$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/log4net/appender[@name='Sql']/file/conversionPattern/@value" Value="%folder{LogDirectory}svc$(ServiceName).SQL.log" />
|
||||
<XmlUpdate Condition="'$(ServiceLauncher)' != '' AND '$(SplitServices)' == '1'" XmlFileName="$(ServicePath)\TeamLabSvc.exe.config" XPath="/configuration/nlog/variable[@name='svcName']/@value" Value="$(ServiceName)" />
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_portal_url']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicalePortalUrl" />
|
||||
</XmlRead>
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_filesystem_folder']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicaleFilesystemFolder" />
|
||||
</XmlRead>
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_machine_key']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicaleMachineKey" />
|
||||
</XmlRead>
|
||||
<XmlRead Condition="Exists('..\config\private\Radicale.Config.Substitutions.xml')" Namespace="http://nant.sf.net/release/0.85/nant.xsd" Prefix="n" XPath="/n:configuration/n:substitutions/n:$(DeployTo)/n:property[@name='radicale_log_file']/@value" XmlFileName="..\config\private\Radicale.Config.Substitutions.xml">
|
||||
<Output TaskParameter="Value" PropertyName="RadicaleLogFile" />
|
||||
</XmlRead>
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.config" Encoding="ASCII" Regex="portal_url =.+" ReplacementText="portal_url = $(RadicalePortalUrl)" />
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.config" Encoding="ASCII" Regex="filesystem_folder =.+" ReplacementText="filesystem_folder = $(RadicaleFilesystemFolder)" />
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.log.config" Encoding="ASCII" Regex="args = .+" ReplacementText="args = ($(RadicaleLogFile),'midnight', 1, 7)" />
|
||||
<FileUpdate Condition=" $(ServiceName) == 'Radicale'" Files="$(ServicePath)\radicale.config" Encoding="ASCII" Regex="machine_key =.+" ReplacementText="machine_key = $(RadicaleMachineKey)" />
|
||||
</Target>
|
||||
<Target Name="DeployMail">
|
||||
<Message Text="Deploying service $(ServiceName)" />
|
||||
<PropertyGroup>
|
||||
<ServicePath>$(OutDir)Services\$(ServiceName)\</ServicePath>
|
||||
</PropertyGroup>
|
||||
<Message Text="Deploying service path $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'))" />
|
||||
<MSBuild BuildInParallel="true" Projects="$(RootDir)$(ProjPath)" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
</Target>
|
||||
<Target Name="BuildTask">
|
||||
<MSBuild BuildInParallel="true" Projects="$(RootDir)web\core\ASC.Web.Core.sln" Targets="Restore;ReBuild" Properties="Configuration=$(Configuration);AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true" StopOnFirstFailure="true" />
|
||||
</Target>
|
||||
<Target Name="GenerateBundle">
|
||||
<CallTarget Targets="BuildTask" />
|
||||
<GenerateBundle WebStudioFolder="$(OutDir)\WebStudio\" />
|
||||
</Target>
|
||||
<Target Name="GenerateHelpCenterHtml">
|
||||
<CallTarget Targets="BuildTask" Condition=" '$(GenerateBundle)' == '0' " />
|
||||
<GenerateHelpCenterHtml WebStudioFolder="$(OutDir)\WebStudio\" />
|
||||
</Target>
|
||||
<Target Name="LessCompile">
|
||||
<ItemGroup>
|
||||
<LessFilesInclude Include="$(OutDir)WebStudio\**\*.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\calendar\UserControls\fullcalendar\css\fullcalendar.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\Products\Files\Controls\Tree\tree.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\Products\CRM\App_Themes\Default\css\base.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\UserControls\Common\SharingSettings\css\default\baseparams.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\UserControls\Common\SharingSettings\css\default\sharingsettings.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\base.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\actionpanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\buttons.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\common.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\common_style.wide-screen.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\contentmenu.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\headers.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\links.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\lists.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\*\params.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\sidepanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\tl-combobox.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\topstudiopanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\voip.phone.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\whitelabel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\jquery-advansedfilter-theme.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\skins\default\jstree\**\*.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\icons.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\autocomplete.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\message.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\tags.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\attachments.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\popup.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\accountspanel.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\accounts.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\contacts.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\settings.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\crm_integration.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\accountpopup.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\print.less" />
|
||||
<LessFilesExlude Include="$(OutDir)WebStudio\addons\mail\App_Themes\Default\less\administration.less" />
|
||||
<LessFiles Include="@(LessFilesInclude)" Exclude="@(LessFilesExlude)" />
|
||||
</ItemGroup>
|
||||
<Exec Command="$(NuGetCommand) install dotless -Version 1.5.2 -OutputDirectory $(RootDir)packages" />
|
||||
<Exec Command="$(LessCommand) -m "%(LessFiles.FullPath)" "%(LessFiles->%(RootDir)%(Directory)%(Filename).min.css"" />
|
||||
</Target>
|
||||
<Target Name="CssMinify">
|
||||
<ItemGroup>
|
||||
<CssFiles Include="$(OutDir)WebStudio\**\*.css" />
|
||||
</ItemGroup>
|
||||
<CssCompress SourceFiles="@(CssFiles)" DestinationFiles="%(RootDir)%(Directory)%(Filename).min.css" />
|
||||
</Target>
|
||||
<Target Name="ChangeConfigs">
|
||||
<ItemGroup>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\Web.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.connections.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Connections.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.appsettings.config">
|
||||
<SubstitutionsFile>..\config\private\Web.AppSettings.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.autofac.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Autofac.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.consumers.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Consumers.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Log4net.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Web.NLog.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)WebStudio\web.storage.config">
|
||||
<SubstitutionsFile>..\config\private\Web.Storage.Config.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\ASC.Mail.Aggregator.CollectionService.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\ASC.Mail.EmlDownloader.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\mail.agg.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailAggregator\mail.agg.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Agg.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\ASC.Mail.Watchdog.Service.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailWatchdog\mail.dog.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Dog.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\ASC.Mail.StorageCleaner.exe.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Cln.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\mail.cln.log4net.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Cln.Log4net.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Include="$(OutDir)Services\MailCleaner\mail.cln.nlog.config">
|
||||
<SubstitutionsFile>..\config\private\Mail.Cln.NLog.Substitutions.xml</SubstitutionsFile>
|
||||
</ConfigFiles>
|
||||
<ConfigFiles Remove="@(ConfigFiles)" Condition="!Exists('%(ConfigFiles.SubstitutionsFile)')" />
|
||||
</ItemGroup>
|
||||
<RegexReplace Expression="(.+)\." Input="$(DeployTo)">
|
||||
<Output PropertyName="Substitution" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<Message Text="ChangeConfigs: SubstitutionsRoot: /configuration/substitutions/$(Substitution)" />
|
||||
<XmlMassUpdate Condition="$(Substitution) != $(DeployTo)" ContentFile="%(ConfigFiles.FullPath)" ContentRoot="/" SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)" SubstitutionsRoot="/configuration/substitutions/$(Substitution)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<RegexReplace Expression="^[^.]*\." Input="$(DeployTo)">
|
||||
<Output PropertyName="SubstitutionNext" TaskParameter="Output" />
|
||||
</RegexReplace>
|
||||
<Message Text="ChangeConfigs: SubstitutionsRoot: /configuration/substitutions/$(SubstitutionNext)" />
|
||||
<XmlMassUpdate Condition="$(Substitution) != $(SubstitutionNext)" ContentFile="%(ConfigFiles.FullPath)" ContentRoot="/" SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)" SubstitutionsRoot="/configuration/substitutions/$(SubstitutionNext)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
<Message Text="ChangeConfigs: SubstitutionsRoot: /configuration/substitutions/$(DeployTo)" />
|
||||
<XmlMassUpdate ContentFile="%(ConfigFiles.FullPath)" ContentRoot="/" SubstitutionsFile="%(ConfigFiles.SubstitutionsFile)" SubstitutionsRoot="/configuration/substitutions/$(DeployTo)" NamespaceDefinitions="un=http://schemas.microsoft.com/practices/2010/unity" />
|
||||
</Target>
|
||||
<Target Name="CopyConfigsForBackup">
|
||||
<CreateItem Include="$(Regions)">
|
||||
<Output ItemName="RegionsArray" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="CopyConfigForBackup" Properties="DeployTo=$(DeployTo);Region=%(RegionsArray.Identity)" />
|
||||
</Target>
|
||||
<Target Name="CopyConfigForBackup">
|
||||
<CreateItem Include="$(DeployDir)$(Region)\WebStudio\*.config">
|
||||
<Output ItemName="ConfigFiles" TaskParameter="Include" />
|
||||
</CreateItem>
|
||||
<Copy Condition="Exists('$(OutDir)Services\TeamLabSvc\')" SourceFiles="@(ConfigFiles)" DestinationFolder="$(OutDir)Services\TeamLabSvc\$(Region)\" />
|
||||
<Copy Condition="Exists('$(OutDir)Services\Backup\')" SourceFiles="@(ConfigFiles)" DestinationFolder="$(OutDir)Services\Backup\$(Region)\" />
|
||||
</Target>
|
||||
</Project>
|
@ -1,143 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Deploy">
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.XmlUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.Xml.XmlMassUpdate" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.CopyDirectory" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RemoveDuplicatesAssemblies" />
|
||||
<UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.RegexReplace" />
|
||||
<PropertyGroup>
|
||||
<BuildTargets Condition=" '$(BuildTargets)' == 'Build' ">Restore;Build</BuildTargets>
|
||||
<Configuration Condition="$(Configuration)==''">Debug</Configuration>
|
||||
<RootDir Condition="$(RootDir)==''">..\..\</RootDir>
|
||||
<BinDir>$(RootDir)web\studio\ASC.Web.Studio\bin\</BinDir>
|
||||
<DeployTo>MailFiles</DeployTo>
|
||||
<DeployDir Condition="$(DeployDir)==''">$(RootDir)build\deploy\</DeployDir>
|
||||
<OutDir Condition="$(OutDir)==''">$(DeployDir)$(DeployTo)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<MailServiceToDeploy Include="MailAggregator">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.Aggregator.CollectionService\ASC.Mail.Aggregator.CollectionService.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailAggregator">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.EmlDownloader\ASC.Mail.EmlDownloader.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailAggregatorSrv">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.Aggregator.CollectionService\ASC.Mail.Aggregator.CollectionService.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailAggregatorSrv">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.EmlDownloader\ASC.Mail.EmlDownloader.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailWatchdog">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.Watchdog.Service\ASC.Mail.Watchdog.Service.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
<MailServiceToDeploy Include="MailCleaner">
|
||||
<ProjPath>module\ASC.Mail\Services\ASC.Mail.StorageCleaner\ASC.Mail.StorageCleaner.Service.csproj</ProjPath>
|
||||
</MailServiceToDeploy>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Web.Autofac.Config.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Web.Consumers.Config.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Web.Storage.Config.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Agg.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Agg.Log4net.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Agg.NLog.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Agg.Srv.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Agg.Srv.Log4net.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Agg.Srv.NLog.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Dog.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Dog.Log4net.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Dog.NLog.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Cln.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Cln.Log4net.Substitutions.xml"/>
|
||||
<SubstitutionsFiles Include="$(RootDir)build\config\private\Mail.Cln.NLog.Substitutions.xml"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<SystemdFiles Include="$(RootDir)build\msdeploy\SAAS.MAIL\onlyofficeMailAggregator.service"/>
|
||||
<SystemdFiles Include="$(RootDir)build\msdeploy\SAAS.MAIL\onlyofficeMailAggregatorSrv.service"/>
|
||||
<SystemdFiles Include="$(RootDir)build\msdeploy\SAAS.MAIL\onlyofficeMailCleaner.service"/>
|
||||
<SystemdFiles Include="$(RootDir)build\msdeploy\SAAS.MAIL\onlyofficeMailWatchdog.service"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Deploy">
|
||||
|
||||
<RemoveDir Directories="$(OutDir)" ContinueOnError="true" Condition="'$(LeaveOutDir)' != '0'" />
|
||||
|
||||
<MSBuild
|
||||
Projects="$(MSBuildProjectFullPath)"
|
||||
Targets="DeployMail"
|
||||
Properties="OutDir=$(OutDir);DeployTo=$(DeployTo);ServiceName=%(MailServiceToDeploy.Identity);ProjPath=%(MailServiceToDeploy.ProjPath);Disable_CopyWebApplication=true"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="@(SubstitutionsFiles)"
|
||||
DestinationFiles="@(SubstitutionsFiles->'$(OutDir)Substitutions\%(Filename)%(Extension)')"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="@(SystemdFiles)"
|
||||
DestinationFiles="@(SystemdFiles->'$(OutDir)Systemd\%(Filename)%(Extension)')"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="$(RootDir)web\studio\ASC.Web.Studio\web.consumers.config"
|
||||
DestinationFolder="$(OutDir)Services\MailAggregator\"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="$(RootDir)web\studio\ASC.Web.Studio\web.storage.config"
|
||||
DestinationFolder="$(OutDir)Services\MailAggregator\"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="$(RootDir)web\studio\ASC.Web.Studio\web.consumers.config"
|
||||
DestinationFolder="$(OutDir)Services\MailAggregatorSrv\"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="$(RootDir)web\studio\ASC.Web.Studio\web.storage.config"
|
||||
DestinationFolder="$(OutDir)Services\MailAggregatorSrv\"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="$(RootDir)web\studio\ASC.Web.Studio\web.autofac.config"
|
||||
DestinationFolder="$(OutDir)Services\%(MailServiceToDeploy.Identity)\"/>
|
||||
|
||||
<Copy
|
||||
SourceFiles="$(RootDir)web\studio\ASC.Web.Studio\web.storage.config"
|
||||
DestinationFolder="$(OutDir)Services\MailCleaner\"/>
|
||||
|
||||
|
||||
<Delete
|
||||
Files="$(OutDir)Services\MailAggregator\Mono.Security.dll;$(OutDir)Services\MailAggregatorSrv\Mono.Security.dll;$(OutDir)Services\MailCleaner\Mono.Security.dll;$(OutDir)Services\MailWatchdog\Mono.Security.dll"
|
||||
TreatErrorsAsWarnings="true"/>
|
||||
|
||||
<XmlUpdate
|
||||
XmlFileName="$(OutDir)Services\MailAggregator\web.storage.config"
|
||||
XPath="/storage/handler/add[@name='disc']/property/@value"
|
||||
Value="..\..\Data\"/>
|
||||
|
||||
<XmlUpdate
|
||||
XmlFileName="$(OutDir)Services\MailAggregatorSrv\web.storage.config"
|
||||
XPath="/storage/handler/add[@name='disc']/property/@value"
|
||||
Value="..\..\Data\"/>
|
||||
|
||||
<XmlUpdate
|
||||
XmlFileName="$(OutDir)Services\MailCleaner\web.storage.config"
|
||||
XPath="/storage/handler/add[@name='disc']/property/@value"
|
||||
Value="..\..\Data\"/>
|
||||
|
||||
</Target>
|
||||
|
||||
<Target Name="DeployMail">
|
||||
<Message Text="Deploying service $(ServiceName)"/>
|
||||
|
||||
<PropertyGroup>
|
||||
<ServicePath>$(OutDir)Services\$(ServiceName)\</ServicePath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Message Text="Deploying service path $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'))"/>
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="true"
|
||||
Projects="$(RootDir)$(ProjPath)"
|
||||
Targets="$(BuildTargets)"
|
||||
Properties="Configuration=$(Configuration);OutDir=$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(ServicePath)'));AlToolPath=%(AlToolPath.FullPath);Constants=$(Constants);Disable_CopyWebApplication=true"
|
||||
StopOnFirstFailure="true"/>
|
||||
|
||||
</Target>
|
||||
|
||||
</Project>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
29
build/sql/onlyoffice.upgradev116.sql
Normal file
29
build/sql/onlyoffice.upgradev116.sql
Normal file
@ -0,0 +1,29 @@
|
||||
DELIMITER DLM00
|
||||
|
||||
DROP PROCEDURE IF EXISTS upgrade116 DLM00
|
||||
|
||||
CREATE PROCEDURE upgrade116()
|
||||
BEGIN
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `files_link` (
|
||||
`source_id` varchar(32) NOT NULL,
|
||||
`linked_id` varchar(32) NOT NULL,
|
||||
`linked_for` char(38) NOT NULL,
|
||||
`tenant_id` int(10) NOT NULL,
|
||||
PRIMARY KEY (`tenant_id`, `source_id`, `linked_id`),
|
||||
KEY `linked_for` (`tenant_id`, `source_id`, `linked_id`, `linked_for`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.docx', '.docxf');
|
||||
INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.docxf', '.docx');
|
||||
INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.docxf', '.odt');
|
||||
INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.docxf', '.oform');
|
||||
INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.docxf', '.pdf');
|
||||
INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.docxf', '.rtf');
|
||||
INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.docxf', '.txt');
|
||||
|
||||
END DLM00
|
||||
|
||||
CALL upgrade116() DLM00
|
||||
|
||||
DELIMITER ;
|
@ -1,73 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0A0DEE40-360E-4556-8114-7191C4DE5BE5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ASC.ActiveDirectory.Tests</RootNamespace>
|
||||
<AssemblyName>ASC.ActiveDirectory.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\..\..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Login\LoginAcceptedTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Query\ParseTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj">
|
||||
<Project>{76de7717-3d4b-4a5b-b740-15b8913df0cb}</Project>
|
||||
<Name>ASC.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj">
|
||||
<Project>{a51d0454-4afa-46de-89d4-b03d37e1816c}</Project>
|
||||
<Name>ASC.Core.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ASC.ActiveDirectory.csproj">
|
||||
<Project>{e588e818-f163-470c-802c-3a6e45b36080}</Project>
|
||||
<Name>ASC.ActiveDirectory</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0A0DEE40-360E-4556-8114-7191C4DE5BE5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ASC.ActiveDirectory.Tests</RootNamespace>
|
||||
<AssemblyName>ASC.ActiveDirectory.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\..\..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Login\LoginAcceptedTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Query\ParseTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj">
|
||||
<Project>{76de7717-3d4b-4a5b-b740-15b8913df0cb}</Project>
|
||||
<Name>ASC.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj">
|
||||
<Project>{a51d0454-4afa-46de-89d4-b03d37e1816c}</Project>
|
||||
<Name>ASC.Core.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ASC.ActiveDirectory.csproj">
|
||||
<Project>{e588e818-f163-470c-802c-3a6e45b36080}</Project>
|
||||
<Name>ASC.ActiveDirectory</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@ -1,107 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E588E818-F163-470C-802C-3A6E45B36080}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ASC.ActiveDirectory</RootNamespace>
|
||||
<AssemblyName>ASC.ActiveDirectory</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<OutputPath>..\..\web\studio\ASC.Web.Studio\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Security">
|
||||
<HintPath>..\..\packages\Mono.Security.3.2.3.0\lib\net45\Mono.Security.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Base\Data\LdapObjectExtension.cs" />
|
||||
<Compile Include="Base\Data\LdapLogin.cs" />
|
||||
<Compile Include="Base\Data\LdapObject.cs" />
|
||||
<Compile Include="Base\LdapHelper.cs" />
|
||||
<Compile Include="Base\LdapNotifySource.cs" />
|
||||
<Compile Include="Base\LdapUserImporter.cs" />
|
||||
<Compile Include="Base\LdapNotifyHelper.cs" />
|
||||
<Compile Include="Base\LdapNotifyConstants.cs" />
|
||||
<Compile Include="Base\Settings\LdapSettingsChecker.cs" />
|
||||
<Compile Include="Base\Settings\LdapSettingsStatus.cs" />
|
||||
<Compile Include="Base\Settings\LdapSettings.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapItemChange.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapChangeCollection.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapChangeEnums.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapChange.cs" />
|
||||
<Compile Include="ComplexOperations\LdapLocalization.cs" />
|
||||
<Compile Include="ComplexOperations\LdapOperation.cs" />
|
||||
<Compile Include="ComplexOperations\LdapOperationType.cs" />
|
||||
<Compile Include="ComplexOperations\LdapSaveSyncOperation.cs" />
|
||||
<Compile Include="LdapUserManager.cs" />
|
||||
<Compile Include="ComplexOperations\LdapOperationStatus.cs" />
|
||||
<Compile Include="Base\LdapConstants.cs" />
|
||||
<Compile Include="Base\Expressions\Criteria.cs" />
|
||||
<Compile Include="Base\Expressions\CriteriaType.cs" />
|
||||
<Compile Include="Base\Expressions\Expression.cs" />
|
||||
<Compile Include="Base\Expressions\Op.cs" />
|
||||
<Compile Include="LdapUtils.cs" />
|
||||
<Compile Include="Novell\Data\NovellLdapObject.cs" />
|
||||
<Compile Include="Novell\NovellLdapUserImporter.cs" />
|
||||
<Compile Include="Base\Data\LdapCertificateConfirmRequest.cs" />
|
||||
<Compile Include="Novell\Extensions\NovellLdapEntryExtension.cs" />
|
||||
<Compile Include="Novell\NovellLdapHelper.cs" />
|
||||
<Compile Include="Novell\Exceptions\NovellLdapTlsCertificateRequestedException.cs" />
|
||||
<Compile Include="Novell\NovellLdapSearcher.cs" />
|
||||
<Compile Include="Novell\NovellLdapSettingsChecker.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\web\core\ASC.Web.Core\ASC.Web.Core.csproj">
|
||||
<Project>{02C40A64-FE22-41D0-9037-69F0D6F787A9}</Project>
|
||||
<Name>ASC.Web.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ASC.Common\ASC.Common.csproj">
|
||||
<Project>{76de7717-3d4b-4a5b-b740-15b8913df0cb}</Project>
|
||||
<Name>ASC.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ASC.Core.Common\ASC.Core.Common.csproj">
|
||||
<Project>{a51d0454-4afa-46de-89d4-b03d37e1816c}</Project>
|
||||
<Name>ASC.Core.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac">
|
||||
<Version>5.1.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Mono.Security">
|
||||
<Version>3.2.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Novell.Directory.LDAP">
|
||||
<Version>2.3.8.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E588E818-F163-470C-802C-3A6E45B36080}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ASC.ActiveDirectory</RootNamespace>
|
||||
<AssemblyName>ASC.ActiveDirectory</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<OutputPath>..\..\web\studio\ASC.Web.Studio\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Security">
|
||||
<HintPath>..\..\packages\Mono.Security.3.2.3.0\lib\net45\Mono.Security.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Base\Data\LdapObjectExtension.cs" />
|
||||
<Compile Include="Base\Data\LdapLogin.cs" />
|
||||
<Compile Include="Base\Data\LdapObject.cs" />
|
||||
<Compile Include="Base\LdapHelper.cs" />
|
||||
<Compile Include="Base\LdapNotifySource.cs" />
|
||||
<Compile Include="Base\LdapUserImporter.cs" />
|
||||
<Compile Include="Base\LdapNotifyHelper.cs" />
|
||||
<Compile Include="Base\LdapNotifyConstants.cs" />
|
||||
<Compile Include="Base\Settings\LdapSettingsChecker.cs" />
|
||||
<Compile Include="Base\Settings\LdapSettingsStatus.cs" />
|
||||
<Compile Include="Base\Settings\LdapSettings.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapItemChange.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapChangeCollection.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapChangeEnums.cs" />
|
||||
<Compile Include="ComplexOperations\Data\LdapChange.cs" />
|
||||
<Compile Include="ComplexOperations\LdapLocalization.cs" />
|
||||
<Compile Include="ComplexOperations\LdapOperation.cs" />
|
||||
<Compile Include="ComplexOperations\LdapOperationType.cs" />
|
||||
<Compile Include="ComplexOperations\LdapSaveSyncOperation.cs" />
|
||||
<Compile Include="LdapUserManager.cs" />
|
||||
<Compile Include="ComplexOperations\LdapOperationStatus.cs" />
|
||||
<Compile Include="Base\LdapConstants.cs" />
|
||||
<Compile Include="Base\Expressions\Criteria.cs" />
|
||||
<Compile Include="Base\Expressions\CriteriaType.cs" />
|
||||
<Compile Include="Base\Expressions\Expression.cs" />
|
||||
<Compile Include="Base\Expressions\Op.cs" />
|
||||
<Compile Include="LdapUtils.cs" />
|
||||
<Compile Include="Novell\Data\NovellLdapObject.cs" />
|
||||
<Compile Include="Novell\NovellLdapUserImporter.cs" />
|
||||
<Compile Include="Base\Data\LdapCertificateConfirmRequest.cs" />
|
||||
<Compile Include="Novell\Extensions\NovellLdapEntryExtension.cs" />
|
||||
<Compile Include="Novell\NovellLdapHelper.cs" />
|
||||
<Compile Include="Novell\Exceptions\NovellLdapTlsCertificateRequestedException.cs" />
|
||||
<Compile Include="Novell\NovellLdapSearcher.cs" />
|
||||
<Compile Include="Novell\NovellLdapSettingsChecker.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\web\core\ASC.Web.Core\ASC.Web.Core.csproj">
|
||||
<Project>{02C40A64-FE22-41D0-9037-69F0D6F787A9}</Project>
|
||||
<Name>ASC.Web.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ASC.Common\ASC.Common.csproj">
|
||||
<Project>{76de7717-3d4b-4a5b-b740-15b8913df0cb}</Project>
|
||||
<Name>ASC.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ASC.Core.Common\ASC.Core.Common.csproj">
|
||||
<Project>{a51d0454-4afa-46de-89d4-b03d37e1816c}</Project>
|
||||
<Name>ASC.Core.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac">
|
||||
<Version>5.1.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Mono.Security">
|
||||
<Version>3.2.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Novell.Directory.LDAP">
|
||||
<Version>2.3.8.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -75,7 +75,7 @@ namespace ASC.ActiveDirectory.Base
|
||||
{
|
||||
var task = new Task(() =>
|
||||
{
|
||||
var tenants = CoreContext.TenantManager.GetTenants();
|
||||
var tenants = CoreContext.TenantManager.GetTenants(new LdapSettings().GetTenants());
|
||||
foreach (var t in tenants)
|
||||
{
|
||||
var tId = t.TenantId;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,16 +18,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
using ASC.Common.Data;
|
||||
using ASC.Common.Data.Sql;
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
using ASC.Core;
|
||||
using ASC.Core.Common.Settings;
|
||||
using ASC.Web.Core;
|
||||
|
||||
using ASC.Web.Core;
|
||||
namespace ASC.ActiveDirectory.Base.Settings
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract]
|
||||
{
|
||||
[Serializable]
|
||||
[DataContract]
|
||||
public class LdapSettings : BaseSettings<LdapSettings>, ICloneable
|
||||
{
|
||||
public override Guid ID
|
||||
@ -79,7 +81,22 @@ namespace ASC.ActiveDirectory.Base.Settings
|
||||
{ AccessRight.Community, WebItemManager.CommunityProductID },
|
||||
{ AccessRight.People, WebItemManager.PeopleProductID },
|
||||
{ AccessRight.Mail, WebItemManager.MailProductID }
|
||||
};
|
||||
};
|
||||
|
||||
public List<int> GetTenants()
|
||||
{
|
||||
var query = new SqlQuery("webstudio_settings t1")
|
||||
.Select("tt.id")
|
||||
.InnerJoin("tenants_tenants tt", Exp.EqColumns("tt.id", "t1.TenantID"))
|
||||
.Where("t1.id", ID)
|
||||
.Where("IFNULL(JSON_EXTRACT(`Data`, '$.EnableLdapAuthentication'), 'false')", "true")
|
||||
.Distinct();
|
||||
|
||||
using (var dbManager = DbManager.FromHttpContext("default", 180000))
|
||||
{
|
||||
return dbManager.ExecuteList(query).ConvertAll(r => Convert.ToInt32(r[0]));
|
||||
}
|
||||
}
|
||||
|
||||
public override ISettings GetDefault()
|
||||
{
|
||||
|
@ -1,35 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ASC.ActiveDirectory")]
|
||||
[assembly: AssemblyDescription("ASC.ActiveDirectory library")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("ASC.ActiveDirectory")]
|
||||
[assembly: AssemblyCopyright("(c) Ascensio System SIA. All rights reserved")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8e4d3183-8aad-428b-b9e3-26d7b1f54801")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ASC.ActiveDirectory")]
|
||||
[assembly: AssemblyDescription("ASC.ActiveDirectory library")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("ASC.ActiveDirectory")]
|
||||
[assembly: AssemblyCopyright("(c) Ascensio System SIA. All rights reserved")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8e4d3183-8aad-428b-b9e3-26d7b1f54801")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@ -1,290 +1,290 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{76DE7717-3D4B-4A5B-B740-15B8913DF0CB}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>ASC.Common</RootNamespace>
|
||||
<AssemblyName>ASC.Common</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<OutputPath>..\..\web\studio\ASC.Web.Studio\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Caching\AscCache.cs" />
|
||||
<Compile Include="Caching\CacheNotifyAction.cs" />
|
||||
<Compile Include="Caching\ICache.cs" />
|
||||
<Compile Include="Caching\ICacheNotify.cs" />
|
||||
<Compile Include="Caching\RedisCache.cs" />
|
||||
<Compile Include="Collections\CachedDictionaryBase.cs" />
|
||||
<Compile Include="Collections\HttpRequestDictionary.cs" />
|
||||
<Compile Include="Data\AdoProxy\DbCommandProxy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Data\AdoProxy\DbConnectionProxy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Data\AdoProxy\DbTransactionProxy.cs" />
|
||||
<Compile Include="Data\AdoProxy\ExecuteHelper.cs" />
|
||||
<Compile Include="Data\AdoProxy\ProxyContext.cs" />
|
||||
<Compile Include="Data\AdoProxy\EventArgs.cs" />
|
||||
<Compile Include="Data\DbNestedTransaction.cs" />
|
||||
<Compile Include="Data\DataExtensions.cs" />
|
||||
<Compile Include="Data\DbManager.cs" />
|
||||
<Compile Include="Data\DbRegistry.cs" />
|
||||
<Compile Include="Data\DbTransaction.cs" />
|
||||
<Compile Include="Data\IDbManager.cs" />
|
||||
<Compile Include="Data\MultiRegionalDbManager.cs" />
|
||||
<Compile Include="Data\TempPath.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\SumExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\IfExp.cs" />
|
||||
<Compile Include="Data\Sql\SqlDebugView.cs" />
|
||||
<Compile Include="Data\Sql\Dialects\SQLiteDialect.cs" />
|
||||
<Compile Include="Data\Sql\Dialects\MySQLDialect.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\BetweenExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\ExistsExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\LGtExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\AsExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\EqColumnsExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\EqExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\Exp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\InExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\JunctionExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\LikeExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\SelectAgregate.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\SqlExp.cs" />
|
||||
<Compile Include="Data\Sql\ISqlDialect.cs" />
|
||||
<Compile Include="Data\Sql\ISqlInstruction.cs" />
|
||||
<Compile Include="Data\Sql\SqlCreate.cs" />
|
||||
<Compile Include="Data\Sql\SqlDelete.cs" />
|
||||
<Compile Include="Data\Sql\Dialects\SqlDialect.cs" />
|
||||
<Compile Include="Data\Sql\SqlIdentifier.cs" />
|
||||
<Compile Include="Data\Sql\SqlInsert.cs" />
|
||||
<Compile Include="Data\Sql\SqlQuery.cs" />
|
||||
<Compile Include="Data\Sql\SqlUpdate.cs" />
|
||||
<Compile Include="Data\StreamExtension.cs" />
|
||||
<Compile Include="Data\TempStream.cs" />
|
||||
<Compile Include="DependencyInjection\AutofacConfigLoader.cs" />
|
||||
<Compile Include="DependencyInjection\AutofacConfigurationSection.cs" />
|
||||
<Compile Include="DependencyInjection\ComponentElement.cs" />
|
||||
<Compile Include="DependencyInjection\ContainerElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ConfigurationElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\DictionaryElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ListElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ListItemElement.cs" />
|
||||
<Compile Include="DependencyInjection\NamedConfigurationElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ParameterElement.cs" />
|
||||
<Compile Include="DependencyInjection\ParameterElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\TypeManipulation.cs" />
|
||||
<Compile Include="Geolocation\IPGeolocationInfo.cs" />
|
||||
<Compile Include="Geolocation\GeolocationHelper.cs" />
|
||||
<Compile Include="Logging\SelfCleaningTarget.cs" />
|
||||
<Compile Include="Logging\Log.cs" />
|
||||
<Compile Include="Logging\SelfCleaningAppender.cs" />
|
||||
<Compile Include="Logging\SpecialFolderPathConverter.cs" />
|
||||
<Compile Include="Module\BaseWcfClient.cs" />
|
||||
<Compile Include="Module\IServiceController.cs" />
|
||||
<Compile Include="Notify\Channels\ISenderChannel.cs" />
|
||||
<Compile Include="Notify\Channels\SenderChannel.cs" />
|
||||
<Compile Include="Notify\Context.cs" />
|
||||
<Compile Include="Notify\INotifyRegistry.cs" />
|
||||
<Compile Include="Notify\Cron\CronExpression.cs" />
|
||||
<Compile Include="Notify\Cron\ISet.cs" />
|
||||
<Compile Include="Notify\Cron\ISortedSet.cs" />
|
||||
<Compile Include="Notify\Cron\TreeSet.cs" />
|
||||
<Compile Include="Notify\Engine\DispatchEngine.cs" />
|
||||
<Compile Include="Notify\Engine\INotifyEngine.cs" />
|
||||
<Compile Include="Notify\Engine\InterceptorStorage.cs" />
|
||||
<Compile Include="Notify\Engine\NotifyEngine.cs" />
|
||||
<Compile Include="Notify\Engine\NotifyRequest.cs" />
|
||||
<Compile Include="Notify\Engine\SendInterceptorSkeleton.cs" />
|
||||
<Compile Include="Notify\Engine\SingleRecipientInterceptor.cs" />
|
||||
<Compile Include="Notify\InitiatorInterceptor.cs" />
|
||||
<Compile Include="Notify\INotifyClient.cs" />
|
||||
<Compile Include="Notify\InterceptorLifetime.cs" />
|
||||
<Compile Include="Notify\InterceptorPlace.cs" />
|
||||
<Compile Include="Notify\ISendInterceptor.cs" />
|
||||
<Compile Include="Notify\INotifyService.cs" />
|
||||
<Compile Include="Notify\Messages\INoticeMessage.cs" />
|
||||
<Compile Include="Notify\Messages\NoticeMessage.cs" />
|
||||
<Compile Include="Notify\Messages\NotifyMessage.cs" />
|
||||
<Compile Include="Notify\Model\TopSubscriptionProvider.cs" />
|
||||
<Compile Include="Notify\NotifyResult.cs" />
|
||||
<Compile Include="Notify\Messages\SendResponse.cs" />
|
||||
<Compile Include="Notify\Messages\SendResult.cs" />
|
||||
<Compile Include="Notify\Model\ConstActionProvider.cs" />
|
||||
<Compile Include="Notify\Model\IActionProvider.cs" />
|
||||
<Compile Include="Notify\Model\INotifyAction.cs" />
|
||||
<Compile Include="Notify\Model\INotifySource.cs" />
|
||||
<Compile Include="Notify\Model\ISubscriptionProvider.cs" />
|
||||
<Compile Include="Notify\Model\NotifyAction.cs" />
|
||||
<Compile Include="Notify\Model\NotifyClientImpl.cs" />
|
||||
<Compile Include="Notify\NotifyException.cs" />
|
||||
<Compile Include="Notify\Patterns\XmlPatternProvider2.cs" />
|
||||
<Compile Include="Notify\Patterns\IPatternStyler.cs" />
|
||||
<Compile Include="Notify\Patterns\NVelocityPatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\IPattern.cs" />
|
||||
<Compile Include="Notify\Patterns\IPatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\IPatternProvider.cs" />
|
||||
<Compile Include="Notify\Patterns\ITagValue.cs" />
|
||||
<Compile Include="Notify\Patterns\Pattern.cs" />
|
||||
<Compile Include="Notify\Patterns\PatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\ReplacePatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\TagValue.cs" />
|
||||
<Compile Include="Notify\Recipients\DirectRecipient.cs" />
|
||||
<Compile Include="Notify\Recipients\IDirectRecipient.cs" />
|
||||
<Compile Include="Notify\Recipients\IRecipient.cs" />
|
||||
<Compile Include="Notify\Recipients\IRecipientsGroup.cs" />
|
||||
<Compile Include="Notify\Recipients\IRecipientsProvider.cs" />
|
||||
<Compile Include="Notify\Recipients\RecipientsGroup.cs" />
|
||||
<Compile Include="Notify\Sinks\DispatchSink.cs" />
|
||||
<Compile Include="Notify\Sinks\ISink.cs" />
|
||||
<Compile Include="Notify\Sinks\Sink.cs" />
|
||||
<Compile Include="Security\AscRandom.cs" />
|
||||
<Compile Include="Security\Authentication\SystemAccount.cs" />
|
||||
<Compile Include="Security\Authorizing\AzObjectIdHelper.cs" />
|
||||
<Compile Include="Security\Authorizing\AzObjectSecurityProviderHelper.cs" />
|
||||
<Compile Include="Security\Cryptography\InstanceCrypto.cs" />
|
||||
<Compile Include="Security\Cryptography\MachinePseudoKeys.cs" />
|
||||
<Compile Include="Security\Cryptography\PasswordHasher.cs" />
|
||||
<Compile Include="Security\ISecurityObject.cs" />
|
||||
<Compile Include="Security\SecurityCallContext.cs" />
|
||||
<Compile Include="Security\SecurityObjectId.cs" />
|
||||
<Compile Include="Security\Cryptography\HashAlg.cs" />
|
||||
<Compile Include="Security\Cryptography\Hasher.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Security\Authentication\Account.cs" />
|
||||
<Compile Include="Security\Authentication\IAccount.cs" />
|
||||
<Compile Include="Security\Authentication\ISystemAccount.cs" />
|
||||
<Compile Include="Security\Authentication\IUserAccount.cs" />
|
||||
<Compile Include="Security\Authorizing\AuthorizingException.cs" />
|
||||
<Compile Include="Security\Authorizing\Constants.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\Ace.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\AceType.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\Action.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\Role.cs" />
|
||||
<Compile Include="Security\Authorizing\AzManager.cs" />
|
||||
<Compile Include="Security\IPermissionProvider.cs" />
|
||||
<Compile Include="Security\Authorizing\Interfaces\IAction.cs" />
|
||||
<Compile Include="Security\IPermissionResolver.cs" />
|
||||
<Compile Include="Security\Authorizing\Interfaces\IRole.cs" />
|
||||
<Compile Include="Security\Authorizing\Interfaces\ISubject.cs" />
|
||||
<Compile Include="Security\IRoleProvider.cs" />
|
||||
<Compile Include="Security\ISecurityObjectId.cs" />
|
||||
<Compile Include="Security\ISecurityObjectProvider.cs" />
|
||||
<Compile Include="Threading\DistributedTaskStatus.cs" />
|
||||
<Compile Include="Threading\DistributedTask.cs" />
|
||||
<Compile Include="Threading\LimitedConcurrencyLevelTaskScheduler.cs" />
|
||||
<Compile Include="Threading\Progress\IProgressItem.cs" />
|
||||
<Compile Include="Threading\Progress\ProgressBase.cs" />
|
||||
<Compile Include="Threading\Progress\ProgressQueue.cs" />
|
||||
<Compile Include="Threading\DistributedTaskQueue.cs" />
|
||||
<Compile Include="Utils\ConfigurationManagerExtension.cs" />
|
||||
<Compile Include="Utils\DnsLookup.cs" />
|
||||
<Compile Include="Utils\HttpRequestExtensions.cs" />
|
||||
<Compile Include="Utils\MailAddressUtils.cs" />
|
||||
<Compile Include="Utils\MimeHeaderUtils.cs" />
|
||||
<Compile Include="Utils\RandomString.cs" />
|
||||
<Compile Include="Utils\TimeZoneConverter\TimeZoneConverter.cs" />
|
||||
<Compile Include="Utils\Signature.cs" />
|
||||
<Compile Include="Utils\VelocityFormatter.cs" />
|
||||
<Compile Include="Utils\HtmlUtil.cs" />
|
||||
<Compile Include="Utils\Wildcard.cs" />
|
||||
<Compile Include="Threading\Workers\WorkerQueue.cs" />
|
||||
<Compile Include="Threading\Workers\WorkItem.cs" />
|
||||
<Compile Include="Web\AbstractHttpAsyncHandler.cs" />
|
||||
<Compile Include="Web\DisposableHttpContext.cs" />
|
||||
<Compile Include="Web\DisposableHttpContextHttpModule.cs" />
|
||||
<Compile Include="Web\MimeMapping.cs" />
|
||||
<Compile Include="Web\RouteCallInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Utils\TimeZoneConverter\windowsZones.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Utils\TimeZoneConverter\timeZoneNames.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ARSoft.Tools.Net">
|
||||
<Version>2.2.9</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Autofac">
|
||||
<Version>5.1.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="HtmlAgilityPack">
|
||||
<Version>1.6.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="log4net">
|
||||
<Version>2.0.8</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation">
|
||||
<Version>3.1.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MySql.Data">
|
||||
<Version>8.0.23</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog">
|
||||
<Version>4.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NVelocity">
|
||||
<Version>1.2.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StackExchange.Redis">
|
||||
<Version>2.0.519</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StackExchange.Redis.Extensions.LegacyConfiguration">
|
||||
<Version>4.0.5</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Buffers">
|
||||
<Version>4.5.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Memory">
|
||||
<Version>4.5.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Ubiety.Dns.Core">
|
||||
<Version>2.4.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{76DE7717-3D4B-4A5B-B740-15B8913DF0CB}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>ASC.Common</RootNamespace>
|
||||
<AssemblyName>ASC.Common</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<OutputPath>..\..\web\studio\ASC.Web.Studio\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Caching\AscCache.cs" />
|
||||
<Compile Include="Caching\CacheNotifyAction.cs" />
|
||||
<Compile Include="Caching\ICache.cs" />
|
||||
<Compile Include="Caching\ICacheNotify.cs" />
|
||||
<Compile Include="Caching\RedisCache.cs" />
|
||||
<Compile Include="Collections\CachedDictionaryBase.cs" />
|
||||
<Compile Include="Collections\HttpRequestDictionary.cs" />
|
||||
<Compile Include="Data\AdoProxy\DbCommandProxy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Data\AdoProxy\DbConnectionProxy.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Data\AdoProxy\DbTransactionProxy.cs" />
|
||||
<Compile Include="Data\AdoProxy\ExecuteHelper.cs" />
|
||||
<Compile Include="Data\AdoProxy\ProxyContext.cs" />
|
||||
<Compile Include="Data\AdoProxy\EventArgs.cs" />
|
||||
<Compile Include="Data\DbNestedTransaction.cs" />
|
||||
<Compile Include="Data\DataExtensions.cs" />
|
||||
<Compile Include="Data\DbManager.cs" />
|
||||
<Compile Include="Data\DbRegistry.cs" />
|
||||
<Compile Include="Data\DbTransaction.cs" />
|
||||
<Compile Include="Data\IDbManager.cs" />
|
||||
<Compile Include="Data\MultiRegionalDbManager.cs" />
|
||||
<Compile Include="Data\TempPath.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\SumExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\IfExp.cs" />
|
||||
<Compile Include="Data\Sql\SqlDebugView.cs" />
|
||||
<Compile Include="Data\Sql\Dialects\SQLiteDialect.cs" />
|
||||
<Compile Include="Data\Sql\Dialects\MySQLDialect.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\BetweenExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\ExistsExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\LGtExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\AsExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\EqColumnsExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\EqExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\Exp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\InExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\JunctionExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\LikeExp.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\SelectAgregate.cs" />
|
||||
<Compile Include="Data\Sql\Expressions\SqlExp.cs" />
|
||||
<Compile Include="Data\Sql\ISqlDialect.cs" />
|
||||
<Compile Include="Data\Sql\ISqlInstruction.cs" />
|
||||
<Compile Include="Data\Sql\SqlCreate.cs" />
|
||||
<Compile Include="Data\Sql\SqlDelete.cs" />
|
||||
<Compile Include="Data\Sql\Dialects\SqlDialect.cs" />
|
||||
<Compile Include="Data\Sql\SqlIdentifier.cs" />
|
||||
<Compile Include="Data\Sql\SqlInsert.cs" />
|
||||
<Compile Include="Data\Sql\SqlQuery.cs" />
|
||||
<Compile Include="Data\Sql\SqlUpdate.cs" />
|
||||
<Compile Include="Data\StreamExtension.cs" />
|
||||
<Compile Include="Data\TempStream.cs" />
|
||||
<Compile Include="DependencyInjection\AutofacConfigLoader.cs" />
|
||||
<Compile Include="DependencyInjection\AutofacConfigurationSection.cs" />
|
||||
<Compile Include="DependencyInjection\ComponentElement.cs" />
|
||||
<Compile Include="DependencyInjection\ContainerElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ConfigurationElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\DictionaryElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ListElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ListItemElement.cs" />
|
||||
<Compile Include="DependencyInjection\NamedConfigurationElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\ParameterElement.cs" />
|
||||
<Compile Include="DependencyInjection\ParameterElementCollection.cs" />
|
||||
<Compile Include="DependencyInjection\TypeManipulation.cs" />
|
||||
<Compile Include="Geolocation\IPGeolocationInfo.cs" />
|
||||
<Compile Include="Geolocation\GeolocationHelper.cs" />
|
||||
<Compile Include="Logging\SelfCleaningTarget.cs" />
|
||||
<Compile Include="Logging\Log.cs" />
|
||||
<Compile Include="Logging\SelfCleaningAppender.cs" />
|
||||
<Compile Include="Logging\SpecialFolderPathConverter.cs" />
|
||||
<Compile Include="Module\BaseWcfClient.cs" />
|
||||
<Compile Include="Module\IServiceController.cs" />
|
||||
<Compile Include="Notify\Channels\ISenderChannel.cs" />
|
||||
<Compile Include="Notify\Channels\SenderChannel.cs" />
|
||||
<Compile Include="Notify\Context.cs" />
|
||||
<Compile Include="Notify\INotifyRegistry.cs" />
|
||||
<Compile Include="Notify\Cron\CronExpression.cs" />
|
||||
<Compile Include="Notify\Cron\ISet.cs" />
|
||||
<Compile Include="Notify\Cron\ISortedSet.cs" />
|
||||
<Compile Include="Notify\Cron\TreeSet.cs" />
|
||||
<Compile Include="Notify\Engine\DispatchEngine.cs" />
|
||||
<Compile Include="Notify\Engine\INotifyEngine.cs" />
|
||||
<Compile Include="Notify\Engine\InterceptorStorage.cs" />
|
||||
<Compile Include="Notify\Engine\NotifyEngine.cs" />
|
||||
<Compile Include="Notify\Engine\NotifyRequest.cs" />
|
||||
<Compile Include="Notify\Engine\SendInterceptorSkeleton.cs" />
|
||||
<Compile Include="Notify\Engine\SingleRecipientInterceptor.cs" />
|
||||
<Compile Include="Notify\InitiatorInterceptor.cs" />
|
||||
<Compile Include="Notify\INotifyClient.cs" />
|
||||
<Compile Include="Notify\InterceptorLifetime.cs" />
|
||||
<Compile Include="Notify\InterceptorPlace.cs" />
|
||||
<Compile Include="Notify\ISendInterceptor.cs" />
|
||||
<Compile Include="Notify\INotifyService.cs" />
|
||||
<Compile Include="Notify\Messages\INoticeMessage.cs" />
|
||||
<Compile Include="Notify\Messages\NoticeMessage.cs" />
|
||||
<Compile Include="Notify\Messages\NotifyMessage.cs" />
|
||||
<Compile Include="Notify\Model\TopSubscriptionProvider.cs" />
|
||||
<Compile Include="Notify\NotifyResult.cs" />
|
||||
<Compile Include="Notify\Messages\SendResponse.cs" />
|
||||
<Compile Include="Notify\Messages\SendResult.cs" />
|
||||
<Compile Include="Notify\Model\ConstActionProvider.cs" />
|
||||
<Compile Include="Notify\Model\IActionProvider.cs" />
|
||||
<Compile Include="Notify\Model\INotifyAction.cs" />
|
||||
<Compile Include="Notify\Model\INotifySource.cs" />
|
||||
<Compile Include="Notify\Model\ISubscriptionProvider.cs" />
|
||||
<Compile Include="Notify\Model\NotifyAction.cs" />
|
||||
<Compile Include="Notify\Model\NotifyClientImpl.cs" />
|
||||
<Compile Include="Notify\NotifyException.cs" />
|
||||
<Compile Include="Notify\Patterns\XmlPatternProvider2.cs" />
|
||||
<Compile Include="Notify\Patterns\IPatternStyler.cs" />
|
||||
<Compile Include="Notify\Patterns\NVelocityPatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\IPattern.cs" />
|
||||
<Compile Include="Notify\Patterns\IPatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\IPatternProvider.cs" />
|
||||
<Compile Include="Notify\Patterns\ITagValue.cs" />
|
||||
<Compile Include="Notify\Patterns\Pattern.cs" />
|
||||
<Compile Include="Notify\Patterns\PatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\ReplacePatternFormatter.cs" />
|
||||
<Compile Include="Notify\Patterns\TagValue.cs" />
|
||||
<Compile Include="Notify\Recipients\DirectRecipient.cs" />
|
||||
<Compile Include="Notify\Recipients\IDirectRecipient.cs" />
|
||||
<Compile Include="Notify\Recipients\IRecipient.cs" />
|
||||
<Compile Include="Notify\Recipients\IRecipientsGroup.cs" />
|
||||
<Compile Include="Notify\Recipients\IRecipientsProvider.cs" />
|
||||
<Compile Include="Notify\Recipients\RecipientsGroup.cs" />
|
||||
<Compile Include="Notify\Sinks\DispatchSink.cs" />
|
||||
<Compile Include="Notify\Sinks\ISink.cs" />
|
||||
<Compile Include="Notify\Sinks\Sink.cs" />
|
||||
<Compile Include="Security\AscRandom.cs" />
|
||||
<Compile Include="Security\Authentication\SystemAccount.cs" />
|
||||
<Compile Include="Security\Authorizing\AzObjectIdHelper.cs" />
|
||||
<Compile Include="Security\Authorizing\AzObjectSecurityProviderHelper.cs" />
|
||||
<Compile Include="Security\Cryptography\InstanceCrypto.cs" />
|
||||
<Compile Include="Security\Cryptography\MachinePseudoKeys.cs" />
|
||||
<Compile Include="Security\Cryptography\PasswordHasher.cs" />
|
||||
<Compile Include="Security\ISecurityObject.cs" />
|
||||
<Compile Include="Security\SecurityCallContext.cs" />
|
||||
<Compile Include="Security\SecurityObjectId.cs" />
|
||||
<Compile Include="Security\Cryptography\HashAlg.cs" />
|
||||
<Compile Include="Security\Cryptography\Hasher.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Security\Authentication\Account.cs" />
|
||||
<Compile Include="Security\Authentication\IAccount.cs" />
|
||||
<Compile Include="Security\Authentication\ISystemAccount.cs" />
|
||||
<Compile Include="Security\Authentication\IUserAccount.cs" />
|
||||
<Compile Include="Security\Authorizing\AuthorizingException.cs" />
|
||||
<Compile Include="Security\Authorizing\Constants.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\Ace.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\AceType.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\Action.cs" />
|
||||
<Compile Include="Security\Authorizing\Domain\Role.cs" />
|
||||
<Compile Include="Security\Authorizing\AzManager.cs" />
|
||||
<Compile Include="Security\IPermissionProvider.cs" />
|
||||
<Compile Include="Security\Authorizing\Interfaces\IAction.cs" />
|
||||
<Compile Include="Security\IPermissionResolver.cs" />
|
||||
<Compile Include="Security\Authorizing\Interfaces\IRole.cs" />
|
||||
<Compile Include="Security\Authorizing\Interfaces\ISubject.cs" />
|
||||
<Compile Include="Security\IRoleProvider.cs" />
|
||||
<Compile Include="Security\ISecurityObjectId.cs" />
|
||||
<Compile Include="Security\ISecurityObjectProvider.cs" />
|
||||
<Compile Include="Threading\DistributedTaskStatus.cs" />
|
||||
<Compile Include="Threading\DistributedTask.cs" />
|
||||
<Compile Include="Threading\LimitedConcurrencyLevelTaskScheduler.cs" />
|
||||
<Compile Include="Threading\Progress\IProgressItem.cs" />
|
||||
<Compile Include="Threading\Progress\ProgressBase.cs" />
|
||||
<Compile Include="Threading\Progress\ProgressQueue.cs" />
|
||||
<Compile Include="Threading\DistributedTaskQueue.cs" />
|
||||
<Compile Include="Utils\ConfigurationManagerExtension.cs" />
|
||||
<Compile Include="Utils\DnsLookup.cs" />
|
||||
<Compile Include="Utils\HttpRequestExtensions.cs" />
|
||||
<Compile Include="Utils\MailAddressUtils.cs" />
|
||||
<Compile Include="Utils\MimeHeaderUtils.cs" />
|
||||
<Compile Include="Utils\RandomString.cs" />
|
||||
<Compile Include="Utils\TimeZoneConverter\TimeZoneConverter.cs" />
|
||||
<Compile Include="Utils\Signature.cs" />
|
||||
<Compile Include="Utils\VelocityFormatter.cs" />
|
||||
<Compile Include="Utils\HtmlUtil.cs" />
|
||||
<Compile Include="Utils\Wildcard.cs" />
|
||||
<Compile Include="Threading\Workers\WorkerQueue.cs" />
|
||||
<Compile Include="Threading\Workers\WorkItem.cs" />
|
||||
<Compile Include="Web\AbstractHttpAsyncHandler.cs" />
|
||||
<Compile Include="Web\DisposableHttpContext.cs" />
|
||||
<Compile Include="Web\DisposableHttpContextHttpModule.cs" />
|
||||
<Compile Include="Web\MimeMapping.cs" />
|
||||
<Compile Include="Web\RouteCallInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Utils\TimeZoneConverter\windowsZones.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Utils\TimeZoneConverter\timeZoneNames.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ARSoft.Tools.Net">
|
||||
<Version>2.2.9</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Autofac">
|
||||
<Version>5.1.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="HtmlAgilityPack">
|
||||
<Version>1.6.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="log4net">
|
||||
<Version>2.0.8</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation">
|
||||
<Version>3.1.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MySql.Data">
|
||||
<Version>8.0.25</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog">
|
||||
<Version>4.7.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NVelocity">
|
||||
<Version>1.2.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StackExchange.Redis">
|
||||
<Version>2.0.519</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StackExchange.Redis.Extensions.LegacyConfiguration">
|
||||
<Version>4.0.5</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Buffers">
|
||||
<Version>4.5.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Memory">
|
||||
<Version>4.5.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Ubiety.Dns.Core">
|
||||
<Version>2.4.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -1,210 +1,210 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Runtime.Caching;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using StackExchange.Redis.Extensions.Core.Extensions;
|
||||
|
||||
namespace ASC.Common.Caching
|
||||
{
|
||||
public class AscCache : ICache, ICacheNotify
|
||||
{
|
||||
public static readonly ICache Default;
|
||||
|
||||
public static readonly ICache Memory;
|
||||
|
||||
public static readonly ICacheNotify Notify;
|
||||
|
||||
|
||||
private readonly ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>> actions =
|
||||
new ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>>();
|
||||
|
||||
static AscCache()
|
||||
{
|
||||
Memory = new AscCache();
|
||||
Default = ConfigurationManagerExtension.GetSection("redisCacheClient") != null ? new RedisCache() : Memory;
|
||||
Notify = (ICacheNotify)Default;
|
||||
try
|
||||
{
|
||||
Notify.Subscribe<AscCacheItem>((item, action) => { OnClearCache(); });
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private AscCache()
|
||||
{
|
||||
}
|
||||
|
||||
public T Get<T>(string key) where T : class
|
||||
{
|
||||
var cache = GetCache();
|
||||
return cache.Get(key) as T;
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, TimeSpan sligingExpiration)
|
||||
{
|
||||
var cache = GetCache();
|
||||
cache.Set(key, value, new CacheItemPolicy { SlidingExpiration = sligingExpiration });
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, DateTime absolutExpiration)
|
||||
{
|
||||
var cache = GetCache();
|
||||
cache.Set(key, value,
|
||||
absolutExpiration == DateTime.MaxValue ? DateTimeOffset.MaxValue : new DateTimeOffset(absolutExpiration));
|
||||
}
|
||||
|
||||
public void Remove(string key)
|
||||
{
|
||||
var cache = GetCache();
|
||||
cache.Remove(key);
|
||||
}
|
||||
|
||||
public void Remove(Regex pattern)
|
||||
{
|
||||
var cache = GetCache();
|
||||
|
||||
var copy = cache.ToDictionary(p => p.Key, p => p.Value);
|
||||
|
||||
var keys = copy.Select(p => p.Key).Where(k => pattern.IsMatch(k)).ToArray();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
cache.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IDictionary<string, T> HashGetAll<T>(string key)
|
||||
{
|
||||
var cache = GetCache();
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
return dic != null ? new Dictionary<string, T>(dic) : new Dictionary<string, T>();
|
||||
}
|
||||
|
||||
public T HashGet<T>(string key, string field)
|
||||
{
|
||||
var cache = GetCache();
|
||||
T value;
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
if (dic != null && dic.TryGetValue(field, out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public void HashSet<T>(string key, string field, T value)
|
||||
{
|
||||
var cache = GetCache();
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
if (value != null)
|
||||
{
|
||||
if (dic == null)
|
||||
{
|
||||
dic = new Dictionary<string, T>();
|
||||
}
|
||||
dic[field] = value;
|
||||
cache.Set(key, dic, null);
|
||||
}
|
||||
else if (dic != null)
|
||||
{
|
||||
dic.Remove(field);
|
||||
if (dic.Count == 0)
|
||||
{
|
||||
cache.Remove(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
cache.Set(key, dic, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Subscribe<T>(Action<T, CacheNotifyAction> onchange)
|
||||
{
|
||||
if (onchange != null)
|
||||
{
|
||||
Action<object, CacheNotifyAction> action = (o, a) => onchange((T)o, a);
|
||||
actions.AddOrUpdate(typeof(T),
|
||||
new ConcurrentBag<Action<object, CacheNotifyAction>> { action },
|
||||
(type, bag) =>
|
||||
{
|
||||
bag.Add(action);
|
||||
return bag;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> removed;
|
||||
actions.TryRemove(typeof(T), out removed);
|
||||
}
|
||||
}
|
||||
|
||||
public void Publish<T>(T obj, CacheNotifyAction action)
|
||||
{
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> onchange;
|
||||
actions.TryGetValue(typeof(T), out onchange);
|
||||
|
||||
if (onchange != null)
|
||||
{
|
||||
onchange.ToArray().ForEach(r => r(obj, action));
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
Notify.Publish(new AscCacheItem(), CacheNotifyAction.Any);
|
||||
}
|
||||
|
||||
private MemoryCache GetCache()
|
||||
{
|
||||
return MemoryCache.Default;
|
||||
}
|
||||
|
||||
public static void OnClearCache()
|
||||
{
|
||||
Default.Remove(new Regex(".*"));
|
||||
var keys = MemoryCache.Default.Select(r => r.Key).ToList();
|
||||
|
||||
foreach (var k in keys)
|
||||
{
|
||||
MemoryCache.Default.Remove(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AscCacheItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public AscCacheItem()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Runtime.Caching;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using StackExchange.Redis.Extensions.Core.Extensions;
|
||||
|
||||
namespace ASC.Common.Caching
|
||||
{
|
||||
public class AscCache : ICache, ICacheNotify
|
||||
{
|
||||
public static readonly ICache Default;
|
||||
|
||||
public static readonly ICache Memory;
|
||||
|
||||
public static readonly ICacheNotify Notify;
|
||||
|
||||
|
||||
private readonly ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>> actions =
|
||||
new ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>>();
|
||||
|
||||
static AscCache()
|
||||
{
|
||||
Memory = new AscCache();
|
||||
Default = ConfigurationManagerExtension.GetSection("redisCacheClient") != null ? new RedisCache() : Memory;
|
||||
Notify = (ICacheNotify)Default;
|
||||
try
|
||||
{
|
||||
Notify.Subscribe<AscCacheItem>((item, action) => { OnClearCache(); });
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private AscCache()
|
||||
{
|
||||
}
|
||||
|
||||
public T Get<T>(string key) where T : class
|
||||
{
|
||||
var cache = GetCache();
|
||||
return cache.Get(key) as T;
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, TimeSpan sligingExpiration)
|
||||
{
|
||||
var cache = GetCache();
|
||||
cache.Set(key, value, new CacheItemPolicy { SlidingExpiration = sligingExpiration });
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, DateTime absolutExpiration)
|
||||
{
|
||||
var cache = GetCache();
|
||||
cache.Set(key, value,
|
||||
absolutExpiration == DateTime.MaxValue ? DateTimeOffset.MaxValue : new DateTimeOffset(absolutExpiration));
|
||||
}
|
||||
|
||||
public void Remove(string key)
|
||||
{
|
||||
var cache = GetCache();
|
||||
cache.Remove(key);
|
||||
}
|
||||
|
||||
public void Remove(Regex pattern)
|
||||
{
|
||||
var cache = GetCache();
|
||||
|
||||
var copy = cache.ToDictionary(p => p.Key, p => p.Value);
|
||||
|
||||
var keys = copy.Select(p => p.Key).Where(k => pattern.IsMatch(k)).ToArray();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
cache.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IDictionary<string, T> HashGetAll<T>(string key)
|
||||
{
|
||||
var cache = GetCache();
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
return dic != null ? new Dictionary<string, T>(dic) : new Dictionary<string, T>();
|
||||
}
|
||||
|
||||
public T HashGet<T>(string key, string field)
|
||||
{
|
||||
var cache = GetCache();
|
||||
T value;
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
if (dic != null && dic.TryGetValue(field, out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public void HashSet<T>(string key, string field, T value)
|
||||
{
|
||||
var cache = GetCache();
|
||||
var dic = (IDictionary<string, T>)cache.Get(key);
|
||||
if (value != null)
|
||||
{
|
||||
if (dic == null)
|
||||
{
|
||||
dic = new Dictionary<string, T>();
|
||||
}
|
||||
dic[field] = value;
|
||||
cache.Set(key, dic, null);
|
||||
}
|
||||
else if (dic != null)
|
||||
{
|
||||
dic.Remove(field);
|
||||
if (dic.Count == 0)
|
||||
{
|
||||
cache.Remove(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
cache.Set(key, dic, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Subscribe<T>(Action<T, CacheNotifyAction> onchange)
|
||||
{
|
||||
if (onchange != null)
|
||||
{
|
||||
Action<object, CacheNotifyAction> action = (o, a) => onchange((T)o, a);
|
||||
actions.AddOrUpdate(typeof(T),
|
||||
new ConcurrentBag<Action<object, CacheNotifyAction>> { action },
|
||||
(type, bag) =>
|
||||
{
|
||||
bag.Add(action);
|
||||
return bag;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> removed;
|
||||
actions.TryRemove(typeof(T), out removed);
|
||||
}
|
||||
}
|
||||
|
||||
public void Publish<T>(T obj, CacheNotifyAction action)
|
||||
{
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> onchange;
|
||||
actions.TryGetValue(typeof(T), out onchange);
|
||||
|
||||
if (onchange != null)
|
||||
{
|
||||
onchange.ToArray().ForEach(r => r(obj, action));
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
Notify.Publish(new AscCacheItem(), CacheNotifyAction.Any);
|
||||
}
|
||||
|
||||
private MemoryCache GetCache()
|
||||
{
|
||||
return MemoryCache.Default;
|
||||
}
|
||||
|
||||
public static void OnClearCache()
|
||||
{
|
||||
Default.Remove(new Regex(".*"));
|
||||
var keys = MemoryCache.Default.Select(r => r.Key).ToList();
|
||||
|
||||
foreach (var k in keys)
|
||||
{
|
||||
MemoryCache.Default.Remove(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AscCacheItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public AscCacheItem()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,286 +1,286 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common.Logging;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
using StackExchange.Redis;
|
||||
using StackExchange.Redis.Extensions.Core;
|
||||
using StackExchange.Redis.Extensions.Core.Extensions;
|
||||
using StackExchange.Redis.Extensions.LegacyConfiguration;
|
||||
|
||||
namespace ASC.Common.Caching
|
||||
{
|
||||
public class RedisCache : ICache, ICacheNotify
|
||||
{
|
||||
private readonly string CacheId = Guid.NewGuid().ToString();
|
||||
private readonly StackExchangeRedisCacheClient redis;
|
||||
private readonly ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>> actions = new ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>>();
|
||||
|
||||
|
||||
public RedisCache()
|
||||
{
|
||||
var configuration = ConfigurationManagerExtension.GetSection("redisCacheClient") as RedisCachingSectionHandler;
|
||||
if (configuration == null)
|
||||
throw new ConfigurationErrorsException("Unable to locate <redisCacheClient> section into your configuration file. Take a look https://github.com/imperugo/StackExchange.Redis.Extensions");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
using (var stream = new StringWriter(stringBuilder))
|
||||
{
|
||||
var opts = RedisCachingSectionHandler.GetConfig().ConfigurationOptions;
|
||||
opts.SyncTimeout = 60000;
|
||||
var connectionMultiplexer = (IConnectionMultiplexer)ConnectionMultiplexer.Connect(opts, stream);
|
||||
redis = new StackExchangeRedisCacheClient(connectionMultiplexer, new Serializer());
|
||||
LogManager.GetLogger("ASC").Debug(stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T Get<T>(string key) where T : class
|
||||
{
|
||||
return redis.Get<T>(key);
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, TimeSpan sligingExpiration)
|
||||
{
|
||||
redis.Replace(key, value, sligingExpiration);
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, DateTime absolutExpiration)
|
||||
{
|
||||
redis.Replace(key, value, absolutExpiration == DateTime.MaxValue ? DateTimeOffset.MaxValue : new DateTimeOffset(absolutExpiration));
|
||||
}
|
||||
|
||||
public void Remove(string key)
|
||||
{
|
||||
redis.Remove(key);
|
||||
}
|
||||
|
||||
public void Remove(Regex pattern)
|
||||
{
|
||||
var glob = pattern.ToString().Replace(".*", "*").Replace(".", "?");
|
||||
var keys = redis.SearchKeys(glob);
|
||||
if (keys.Any())
|
||||
{
|
||||
redis.RemoveAll(keys);
|
||||
}
|
||||
}
|
||||
|
||||
public IDictionary<string, T> HashGetAll<T>(string key)
|
||||
{
|
||||
var dic = redis.Database.HashGetAll(key);
|
||||
return dic
|
||||
.Select(e =>
|
||||
{
|
||||
var val = default(T);
|
||||
try
|
||||
{
|
||||
val = (string)e.Value != null ? JsonConvert.DeserializeObject<T>(e.Value) : default(T);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!e.Value.IsNullOrEmpty)
|
||||
{
|
||||
LogManager.GetLogger("ASC").ErrorFormat("RedisCache HashGetAll value: {0}", e.Value);
|
||||
}
|
||||
|
||||
LogManager.GetLogger("ASC").Error(string.Format("RedisCache HashGetAll key: {0}", key), ex);
|
||||
}
|
||||
|
||||
return new { Key = (string)e.Name, Value = val };
|
||||
})
|
||||
.Where(e => e.Value != null && !e.Value.Equals(default(T)))
|
||||
.ToDictionary(e => e.Key, e => e.Value);
|
||||
}
|
||||
|
||||
public T HashGet<T>(string key, string field)
|
||||
{
|
||||
var value = (string)redis.Database.HashGet(key, field);
|
||||
try
|
||||
{
|
||||
return value != null ? JsonConvert.DeserializeObject<T>(value) : default(T);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error(string.Format("RedisCache HashGet key: {0}, field: {1}", key, field), ex);
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public void HashSet<T>(string key, string field, T value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
redis.Database.HashSet(key, field, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
redis.Database.HashDelete(key, field);
|
||||
}
|
||||
}
|
||||
|
||||
public void Publish<T>(T obj, CacheNotifyAction action)
|
||||
{
|
||||
redis.Publish("asc:channel:" + typeof(T).FullName, new RedisCachePubSubItem<T>() { CacheId = CacheId, Object = obj, Action = action });
|
||||
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> onchange;
|
||||
actions.TryGetValue(typeof(T), out onchange);
|
||||
if (onchange != null)
|
||||
{
|
||||
onchange.ToArray().ForEach(r => r(obj, action));
|
||||
}
|
||||
}
|
||||
|
||||
public void Subscribe<T>(Action<T, CacheNotifyAction> onchange)
|
||||
{
|
||||
redis.Subscribe<RedisCachePubSubItem<T>>("asc:channel:" + typeof(T).FullName, (i) =>
|
||||
{
|
||||
if (i.CacheId != CacheId)
|
||||
{
|
||||
onchange(i.Object, i.Action);
|
||||
}
|
||||
});
|
||||
|
||||
if (onchange != null)
|
||||
{
|
||||
Action<object, CacheNotifyAction> action = (o, a) => onchange((T)o, a);
|
||||
actions.AddOrUpdate(typeof(T),
|
||||
new ConcurrentBag<Action<object, CacheNotifyAction>> { action },
|
||||
(type, bag) =>
|
||||
{
|
||||
bag.Add(action);
|
||||
return bag;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> removed;
|
||||
actions.TryRemove(typeof(T), out removed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
class RedisCachePubSubItem<T>
|
||||
{
|
||||
public string CacheId { get; set; }
|
||||
|
||||
public T Object { get; set; }
|
||||
|
||||
public CacheNotifyAction Action { get; set; }
|
||||
}
|
||||
|
||||
class Serializer : ISerializer
|
||||
{
|
||||
private readonly Encoding enc = Encoding.UTF8;
|
||||
|
||||
|
||||
public byte[] Serialize(object item)
|
||||
{
|
||||
try
|
||||
{
|
||||
var s = JsonConvert.SerializeObject(item);
|
||||
return enc.GetBytes(s);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error("Redis Serialize", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public object Deserialize(byte[] obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resolver = new ContractResolver();
|
||||
var settings = new JsonSerializerSettings { ContractResolver = resolver };
|
||||
var s = enc.GetString(obj);
|
||||
return JsonConvert.DeserializeObject(s, typeof(object), settings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error("Redis Deserialize", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public T Deserialize<T>(byte[] obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resolver = new ContractResolver();
|
||||
var settings = new JsonSerializerSettings { ContractResolver = resolver };
|
||||
var s = enc.GetString(obj);
|
||||
return JsonConvert.DeserializeObject<T>(s, settings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error("Redis Deserialize<T>", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<byte[]> SerializeAsync(object item)
|
||||
{
|
||||
return await Task.Factory.StartNew(() => Serialize(item));
|
||||
}
|
||||
|
||||
public Task<object> DeserializeAsync(byte[] obj)
|
||||
{
|
||||
return Task.Factory.StartNew(() => Deserialize(obj));
|
||||
}
|
||||
|
||||
public Task<T> DeserializeAsync<T>(byte[] obj)
|
||||
{
|
||||
return Task.Factory.StartNew(() => Deserialize<T>(obj));
|
||||
}
|
||||
|
||||
|
||||
class ContractResolver : DefaultContractResolver
|
||||
{
|
||||
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
|
||||
{
|
||||
var prop = base.CreateProperty(member, memberSerialization);
|
||||
if (!prop.Writable)
|
||||
{
|
||||
var property = member as PropertyInfo;
|
||||
if (property != null)
|
||||
{
|
||||
var hasPrivateSetter = property.GetSetMethod(true) != null;
|
||||
prop.Writable = hasPrivateSetter;
|
||||
}
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common.Logging;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
using StackExchange.Redis;
|
||||
using StackExchange.Redis.Extensions.Core;
|
||||
using StackExchange.Redis.Extensions.Core.Extensions;
|
||||
using StackExchange.Redis.Extensions.LegacyConfiguration;
|
||||
|
||||
namespace ASC.Common.Caching
|
||||
{
|
||||
public class RedisCache : ICache, ICacheNotify
|
||||
{
|
||||
private readonly string CacheId = Guid.NewGuid().ToString();
|
||||
private readonly StackExchangeRedisCacheClient redis;
|
||||
private readonly ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>> actions = new ConcurrentDictionary<Type, ConcurrentBag<Action<object, CacheNotifyAction>>>();
|
||||
|
||||
|
||||
public RedisCache()
|
||||
{
|
||||
var configuration = ConfigurationManagerExtension.GetSection("redisCacheClient") as RedisCachingSectionHandler;
|
||||
if (configuration == null)
|
||||
throw new ConfigurationErrorsException("Unable to locate <redisCacheClient> section into your configuration file. Take a look https://github.com/imperugo/StackExchange.Redis.Extensions");
|
||||
|
||||
var stringBuilder = new StringBuilder();
|
||||
using (var stream = new StringWriter(stringBuilder))
|
||||
{
|
||||
var opts = RedisCachingSectionHandler.GetConfig().ConfigurationOptions;
|
||||
opts.SyncTimeout = 60000;
|
||||
var connectionMultiplexer = (IConnectionMultiplexer)ConnectionMultiplexer.Connect(opts, stream);
|
||||
redis = new StackExchangeRedisCacheClient(connectionMultiplexer, new Serializer());
|
||||
LogManager.GetLogger("ASC").Debug(stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T Get<T>(string key) where T : class
|
||||
{
|
||||
return redis.Get<T>(key);
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, TimeSpan sligingExpiration)
|
||||
{
|
||||
redis.Replace(key, value, sligingExpiration);
|
||||
}
|
||||
|
||||
public void Insert(string key, object value, DateTime absolutExpiration)
|
||||
{
|
||||
redis.Replace(key, value, absolutExpiration == DateTime.MaxValue ? DateTimeOffset.MaxValue : new DateTimeOffset(absolutExpiration));
|
||||
}
|
||||
|
||||
public void Remove(string key)
|
||||
{
|
||||
redis.Remove(key);
|
||||
}
|
||||
|
||||
public void Remove(Regex pattern)
|
||||
{
|
||||
var glob = pattern.ToString().Replace(".*", "*").Replace(".", "?");
|
||||
var keys = redis.SearchKeys(glob);
|
||||
if (keys.Any())
|
||||
{
|
||||
redis.RemoveAll(keys);
|
||||
}
|
||||
}
|
||||
|
||||
public IDictionary<string, T> HashGetAll<T>(string key)
|
||||
{
|
||||
var dic = redis.Database.HashGetAll(key);
|
||||
return dic
|
||||
.Select(e =>
|
||||
{
|
||||
var val = default(T);
|
||||
try
|
||||
{
|
||||
val = (string)e.Value != null ? JsonConvert.DeserializeObject<T>(e.Value) : default(T);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!e.Value.IsNullOrEmpty)
|
||||
{
|
||||
LogManager.GetLogger("ASC").ErrorFormat("RedisCache HashGetAll value: {0}", e.Value);
|
||||
}
|
||||
|
||||
LogManager.GetLogger("ASC").Error(string.Format("RedisCache HashGetAll key: {0}", key), ex);
|
||||
}
|
||||
|
||||
return new { Key = (string)e.Name, Value = val };
|
||||
})
|
||||
.Where(e => e.Value != null && !e.Value.Equals(default(T)))
|
||||
.ToDictionary(e => e.Key, e => e.Value);
|
||||
}
|
||||
|
||||
public T HashGet<T>(string key, string field)
|
||||
{
|
||||
var value = (string)redis.Database.HashGet(key, field);
|
||||
try
|
||||
{
|
||||
return value != null ? JsonConvert.DeserializeObject<T>(value) : default(T);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error(string.Format("RedisCache HashGet key: {0}, field: {1}", key, field), ex);
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public void HashSet<T>(string key, string field, T value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
redis.Database.HashSet(key, field, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
redis.Database.HashDelete(key, field);
|
||||
}
|
||||
}
|
||||
|
||||
public void Publish<T>(T obj, CacheNotifyAction action)
|
||||
{
|
||||
redis.Publish("asc:channel:" + typeof(T).FullName, new RedisCachePubSubItem<T>() { CacheId = CacheId, Object = obj, Action = action });
|
||||
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> onchange;
|
||||
actions.TryGetValue(typeof(T), out onchange);
|
||||
if (onchange != null)
|
||||
{
|
||||
onchange.ToArray().ForEach(r => r(obj, action));
|
||||
}
|
||||
}
|
||||
|
||||
public void Subscribe<T>(Action<T, CacheNotifyAction> onchange)
|
||||
{
|
||||
redis.Subscribe<RedisCachePubSubItem<T>>("asc:channel:" + typeof(T).FullName, (i) =>
|
||||
{
|
||||
if (i.CacheId != CacheId)
|
||||
{
|
||||
onchange(i.Object, i.Action);
|
||||
}
|
||||
});
|
||||
|
||||
if (onchange != null)
|
||||
{
|
||||
Action<object, CacheNotifyAction> action = (o, a) => onchange((T)o, a);
|
||||
actions.AddOrUpdate(typeof(T),
|
||||
new ConcurrentBag<Action<object, CacheNotifyAction>> { action },
|
||||
(type, bag) =>
|
||||
{
|
||||
bag.Add(action);
|
||||
return bag;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ConcurrentBag<Action<object, CacheNotifyAction>> removed;
|
||||
actions.TryRemove(typeof(T), out removed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
class RedisCachePubSubItem<T>
|
||||
{
|
||||
public string CacheId { get; set; }
|
||||
|
||||
public T Object { get; set; }
|
||||
|
||||
public CacheNotifyAction Action { get; set; }
|
||||
}
|
||||
|
||||
class Serializer : ISerializer
|
||||
{
|
||||
private readonly Encoding enc = Encoding.UTF8;
|
||||
|
||||
|
||||
public byte[] Serialize(object item)
|
||||
{
|
||||
try
|
||||
{
|
||||
var s = JsonConvert.SerializeObject(item);
|
||||
return enc.GetBytes(s);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error("Redis Serialize", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public object Deserialize(byte[] obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resolver = new ContractResolver();
|
||||
var settings = new JsonSerializerSettings { ContractResolver = resolver };
|
||||
var s = enc.GetString(obj);
|
||||
return JsonConvert.DeserializeObject(s, typeof(object), settings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error("Redis Deserialize", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public T Deserialize<T>(byte[] obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resolver = new ContractResolver();
|
||||
var settings = new JsonSerializerSettings { ContractResolver = resolver };
|
||||
var s = enc.GetString(obj);
|
||||
return JsonConvert.DeserializeObject<T>(s, settings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogManager.GetLogger("ASC").Error("Redis Deserialize<T>", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<byte[]> SerializeAsync(object item)
|
||||
{
|
||||
return await Task.Factory.StartNew(() => Serialize(item));
|
||||
}
|
||||
|
||||
public Task<object> DeserializeAsync(byte[] obj)
|
||||
{
|
||||
return Task.Factory.StartNew(() => Deserialize(obj));
|
||||
}
|
||||
|
||||
public Task<T> DeserializeAsync<T>(byte[] obj)
|
||||
{
|
||||
return Task.Factory.StartNew(() => Deserialize<T>(obj));
|
||||
}
|
||||
|
||||
|
||||
class ContractResolver : DefaultContractResolver
|
||||
{
|
||||
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
|
||||
{
|
||||
var prop = base.CreateProperty(member, memberSerialization);
|
||||
if (!prop.Writable)
|
||||
{
|
||||
var property = member as PropertyInfo;
|
||||
if (property != null)
|
||||
{
|
||||
var hasPrivateSetter = property.GetSetMethod(true) != null;
|
||||
prop.Writable = hasPrivateSetter;
|
||||
}
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,142 +1,142 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace ASC.Collections
|
||||
{
|
||||
public abstract class CachedDictionaryBase<T>
|
||||
{
|
||||
protected string baseKey;
|
||||
protected Func<T, bool> condition;
|
||||
|
||||
public T this[string key]
|
||||
{
|
||||
get { return Get(key); }
|
||||
}
|
||||
|
||||
public T this[Func<T> @default]
|
||||
{
|
||||
get { return Get(@default); }
|
||||
}
|
||||
|
||||
protected abstract void InsertRootKey(string rootKey);
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
InsertRootKey(baseKey);
|
||||
}
|
||||
|
||||
public void Clear(string rootKey)
|
||||
{
|
||||
InsertRootKey(BuildKey(string.Empty, rootKey));
|
||||
}
|
||||
|
||||
public void Reset(string key)
|
||||
{
|
||||
Reset(string.Empty, key);
|
||||
}
|
||||
|
||||
public abstract void Reset(string rootKey, string key);
|
||||
|
||||
public T Get(string key)
|
||||
{
|
||||
return Get(string.Empty, key, null);
|
||||
}
|
||||
|
||||
public T Get(string key, Func<T> defaults)
|
||||
{
|
||||
return Get(string.Empty, key, defaults);
|
||||
}
|
||||
|
||||
|
||||
public void Add(string key, T newValue)
|
||||
{
|
||||
Add(string.Empty, key, newValue);
|
||||
}
|
||||
|
||||
public abstract void Add(string rootkey, string key, T newValue);
|
||||
|
||||
public bool HasItem(string key)
|
||||
{
|
||||
return !Equals(Get(key), default(T));
|
||||
}
|
||||
|
||||
protected string BuildKey(string key, string rootkey)
|
||||
{
|
||||
return string.Format("{0}-{1}-{2}", baseKey, rootkey, key);
|
||||
}
|
||||
|
||||
protected abstract object GetObjectFromCache(string fullKey);
|
||||
|
||||
public T Get(Func<T> @default)
|
||||
{
|
||||
string key = string.Format("func {0} {2}.{1}({3})", @default.Method.ReturnType, @default.Method.Name,
|
||||
@default.Method.DeclaringType.FullName,
|
||||
string.Join(",",
|
||||
@default.Method.GetGenericArguments().Select(x => x.FullName).ToArray
|
||||
()));
|
||||
return Get(key, @default);
|
||||
}
|
||||
|
||||
protected virtual bool FitsCondition(object cached)
|
||||
{
|
||||
return cached != null && cached is T;
|
||||
}
|
||||
|
||||
public virtual T Get(string rootkey, string key, Func<T> defaults)
|
||||
{
|
||||
string fullKey = BuildKey(key, rootkey);
|
||||
object objectCache = GetObjectFromCache(fullKey);
|
||||
if (FitsCondition(objectCache))
|
||||
{
|
||||
OnHit(fullKey);
|
||||
return ReturnCached(objectCache);
|
||||
}
|
||||
if (defaults != null)
|
||||
{
|
||||
OnMiss(fullKey);
|
||||
T newValue = defaults();
|
||||
if (condition == null || condition(newValue))
|
||||
{
|
||||
Add(rootkey, key, newValue);
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
protected virtual T ReturnCached(object objectCache)
|
||||
{
|
||||
return (T)objectCache;
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
protected virtual void OnHit(string fullKey)
|
||||
{
|
||||
Debug.Print("cache hit:{0}", fullKey);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
protected virtual void OnMiss(string fullKey)
|
||||
{
|
||||
Debug.Print("cache miss:{0}", fullKey);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace ASC.Collections
|
||||
{
|
||||
public abstract class CachedDictionaryBase<T>
|
||||
{
|
||||
protected string baseKey;
|
||||
protected Func<T, bool> condition;
|
||||
|
||||
public T this[string key]
|
||||
{
|
||||
get { return Get(key); }
|
||||
}
|
||||
|
||||
public T this[Func<T> @default]
|
||||
{
|
||||
get { return Get(@default); }
|
||||
}
|
||||
|
||||
protected abstract void InsertRootKey(string rootKey);
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
InsertRootKey(baseKey);
|
||||
}
|
||||
|
||||
public void Clear(string rootKey)
|
||||
{
|
||||
InsertRootKey(BuildKey(string.Empty, rootKey));
|
||||
}
|
||||
|
||||
public void Reset(string key)
|
||||
{
|
||||
Reset(string.Empty, key);
|
||||
}
|
||||
|
||||
public abstract void Reset(string rootKey, string key);
|
||||
|
||||
public T Get(string key)
|
||||
{
|
||||
return Get(string.Empty, key, null);
|
||||
}
|
||||
|
||||
public T Get(string key, Func<T> defaults)
|
||||
{
|
||||
return Get(string.Empty, key, defaults);
|
||||
}
|
||||
|
||||
|
||||
public void Add(string key, T newValue)
|
||||
{
|
||||
Add(string.Empty, key, newValue);
|
||||
}
|
||||
|
||||
public abstract void Add(string rootkey, string key, T newValue);
|
||||
|
||||
public bool HasItem(string key)
|
||||
{
|
||||
return !Equals(Get(key), default(T));
|
||||
}
|
||||
|
||||
protected string BuildKey(string key, string rootkey)
|
||||
{
|
||||
return string.Format("{0}-{1}-{2}", baseKey, rootkey, key);
|
||||
}
|
||||
|
||||
protected abstract object GetObjectFromCache(string fullKey);
|
||||
|
||||
public T Get(Func<T> @default)
|
||||
{
|
||||
string key = string.Format("func {0} {2}.{1}({3})", @default.Method.ReturnType, @default.Method.Name,
|
||||
@default.Method.DeclaringType.FullName,
|
||||
string.Join(",",
|
||||
@default.Method.GetGenericArguments().Select(x => x.FullName).ToArray
|
||||
()));
|
||||
return Get(key, @default);
|
||||
}
|
||||
|
||||
protected virtual bool FitsCondition(object cached)
|
||||
{
|
||||
return cached != null && cached is T;
|
||||
}
|
||||
|
||||
public virtual T Get(string rootkey, string key, Func<T> defaults)
|
||||
{
|
||||
string fullKey = BuildKey(key, rootkey);
|
||||
object objectCache = GetObjectFromCache(fullKey);
|
||||
if (FitsCondition(objectCache))
|
||||
{
|
||||
OnHit(fullKey);
|
||||
return ReturnCached(objectCache);
|
||||
}
|
||||
if (defaults != null)
|
||||
{
|
||||
OnMiss(fullKey);
|
||||
T newValue = defaults();
|
||||
if (condition == null || condition(newValue))
|
||||
{
|
||||
Add(rootkey, key, newValue);
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
protected virtual T ReturnCached(object objectCache)
|
||||
{
|
||||
return (T)objectCache;
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
protected virtual void OnHit(string fullKey)
|
||||
{
|
||||
Debug.Print("cache hit:{0}", fullKey);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
protected virtual void OnMiss(string fullKey)
|
||||
{
|
||||
Debug.Print("cache miss:{0}", fullKey);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,95 +1,95 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Web;
|
||||
|
||||
namespace ASC.Collections
|
||||
{
|
||||
public sealed class HttpRequestDictionary<T> : CachedDictionaryBase<T>
|
||||
{
|
||||
private class CachedItem
|
||||
{
|
||||
internal T Value { get; set; }
|
||||
|
||||
internal CachedItem(T value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpRequestDictionary(string baseKey)
|
||||
{
|
||||
condition = (T) => true;
|
||||
this.baseKey = baseKey;
|
||||
}
|
||||
|
||||
protected override void InsertRootKey(string rootKey)
|
||||
{
|
||||
//We can't expire in HtppContext in such way
|
||||
}
|
||||
|
||||
public override void Reset(string rootKey, string key)
|
||||
{
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var builtkey = BuildKey(key, rootKey);
|
||||
HttpContext.Current.Items[builtkey] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Add(string rootkey, string key, T newValue)
|
||||
{
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var builtkey = BuildKey(key, rootkey);
|
||||
HttpContext.Current.Items[builtkey] = new CachedItem(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected override object GetObjectFromCache(string fullKey)
|
||||
{
|
||||
return HttpContext.Current != null ? HttpContext.Current.Items[fullKey] : null;
|
||||
}
|
||||
|
||||
protected override bool FitsCondition(object cached)
|
||||
{
|
||||
return cached is CachedItem;
|
||||
}
|
||||
protected override T ReturnCached(object objectCache)
|
||||
{
|
||||
return ((CachedItem)objectCache).Value;
|
||||
}
|
||||
|
||||
protected override void OnHit(string fullKey)
|
||||
{
|
||||
Debug.Print("{0} http cache hit:{1}", HttpContext.Current.Request.Url, fullKey);
|
||||
}
|
||||
|
||||
protected override void OnMiss(string fullKey)
|
||||
{
|
||||
Uri uri = null;
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
uri = HttpContext.Current.Request.Url;
|
||||
}
|
||||
Debug.Print("{0} http cache miss:{1}", uri == null ? "no-context" : uri.AbsolutePath, fullKey);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Web;
|
||||
|
||||
namespace ASC.Collections
|
||||
{
|
||||
public sealed class HttpRequestDictionary<T> : CachedDictionaryBase<T>
|
||||
{
|
||||
private class CachedItem
|
||||
{
|
||||
internal T Value { get; set; }
|
||||
|
||||
internal CachedItem(T value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpRequestDictionary(string baseKey)
|
||||
{
|
||||
condition = (T) => true;
|
||||
this.baseKey = baseKey;
|
||||
}
|
||||
|
||||
protected override void InsertRootKey(string rootKey)
|
||||
{
|
||||
//We can't expire in HtppContext in such way
|
||||
}
|
||||
|
||||
public override void Reset(string rootKey, string key)
|
||||
{
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var builtkey = BuildKey(key, rootKey);
|
||||
HttpContext.Current.Items[builtkey] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Add(string rootkey, string key, T newValue)
|
||||
{
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var builtkey = BuildKey(key, rootkey);
|
||||
HttpContext.Current.Items[builtkey] = new CachedItem(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected override object GetObjectFromCache(string fullKey)
|
||||
{
|
||||
return HttpContext.Current != null ? HttpContext.Current.Items[fullKey] : null;
|
||||
}
|
||||
|
||||
protected override bool FitsCondition(object cached)
|
||||
{
|
||||
return cached is CachedItem;
|
||||
}
|
||||
protected override T ReturnCached(object objectCache)
|
||||
{
|
||||
return ((CachedItem)objectCache).Value;
|
||||
}
|
||||
|
||||
protected override void OnHit(string fullKey)
|
||||
{
|
||||
Debug.Print("{0} http cache hit:{1}", HttpContext.Current.Request.Url, fullKey);
|
||||
}
|
||||
|
||||
protected override void OnMiss(string fullKey)
|
||||
{
|
||||
Uri uri = null;
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
uri = HttpContext.Current.Request.Url;
|
||||
}
|
||||
Debug.Print("{0} http cache miss:{1}", uri == null ? "no-context" : uri.AbsolutePath, fullKey);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,145 +1,146 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class DbCommandProxy : DbCommand
|
||||
{
|
||||
private readonly DbCommand command;
|
||||
private readonly ProxyContext context;
|
||||
private bool disposed;
|
||||
|
||||
|
||||
public DbCommandProxy(DbCommand command, ProxyContext ctx)
|
||||
{
|
||||
if (command == null) throw new ArgumentNullException("command");
|
||||
if (ctx == null) throw new ArgumentNullException("ctx");
|
||||
|
||||
this.command = command;
|
||||
context = ctx;
|
||||
}
|
||||
|
||||
|
||||
public override void Cancel()
|
||||
{
|
||||
command.Cancel();
|
||||
}
|
||||
|
||||
public override string CommandText
|
||||
{
|
||||
get { return command.CommandText; }
|
||||
set { command.CommandText = value; }
|
||||
}
|
||||
|
||||
public override int CommandTimeout
|
||||
{
|
||||
get { return command.CommandTimeout; }
|
||||
set { command.CommandTimeout = value; }
|
||||
}
|
||||
|
||||
public override CommandType CommandType
|
||||
{
|
||||
get { return command.CommandType; }
|
||||
set { command.CommandType = value; }
|
||||
}
|
||||
|
||||
protected override DbConnection DbConnection
|
||||
{
|
||||
get { return new DbConnectionProxy(command.Connection, context); }
|
||||
set { command.Connection = value is DbConnectionProxy ? value : new DbConnectionProxy(value, context); }
|
||||
}
|
||||
|
||||
protected override DbParameter CreateDbParameter()
|
||||
{
|
||||
return command.CreateParameter();
|
||||
}
|
||||
|
||||
public override int ExecuteNonQuery()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "ExecuteNonQuery", dur)))
|
||||
{
|
||||
return command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, string.Format("ExecuteReader({0})", behavior), dur)))
|
||||
{
|
||||
return command.ExecuteReader(behavior);
|
||||
}
|
||||
}
|
||||
|
||||
public override object ExecuteScalar()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "ExecuteScalar", dur)))
|
||||
{
|
||||
return command.ExecuteScalar();
|
||||
}
|
||||
}
|
||||
|
||||
protected override DbParameterCollection DbParameterCollection
|
||||
{
|
||||
get { return command.Parameters; }
|
||||
}
|
||||
|
||||
public override void Prepare()
|
||||
{
|
||||
command.Prepare();
|
||||
}
|
||||
|
||||
protected override System.Data.Common.DbTransaction DbTransaction
|
||||
{
|
||||
get { return command.Transaction == null ? null : new DbTransactionProxy(command.Transaction, context); }
|
||||
set { command.Transaction = value is DbTransactionProxy ? ((DbTransactionProxy)value).Transaction : value; }
|
||||
}
|
||||
|
||||
public override bool DesignTimeVisible
|
||||
{
|
||||
get { return command.DesignTimeVisible; }
|
||||
set { command.DesignTimeVisible = value; }
|
||||
}
|
||||
|
||||
public override UpdateRowSource UpdatedRowSource
|
||||
{
|
||||
get { return command.UpdatedRowSource; }
|
||||
set { command.UpdatedRowSource = value; }
|
||||
}
|
||||
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
command.Dispose();
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
~DbCommandProxy()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class DbCommandProxy : DbCommand
|
||||
{
|
||||
private readonly DbCommand command;
|
||||
private readonly ProxyContext context;
|
||||
private bool disposed;
|
||||
|
||||
public DbCommandProxy(DbCommand command, ProxyContext ctx, DbConnectionProxy dbConnectionProxy)
|
||||
{
|
||||
if (command == null) throw new ArgumentNullException("command");
|
||||
if (ctx == null) throw new ArgumentNullException("ctx");
|
||||
|
||||
this.command = command;
|
||||
context = ctx;
|
||||
DbConnectionProxy = dbConnectionProxy;
|
||||
}
|
||||
|
||||
|
||||
public override void Cancel()
|
||||
{
|
||||
command.Cancel();
|
||||
}
|
||||
|
||||
public override string CommandText
|
||||
{
|
||||
get { return command.CommandText; }
|
||||
set { command.CommandText = value; }
|
||||
}
|
||||
|
||||
public override int CommandTimeout
|
||||
{
|
||||
get { return command.CommandTimeout; }
|
||||
set { command.CommandTimeout = value; }
|
||||
}
|
||||
|
||||
public override CommandType CommandType
|
||||
{
|
||||
get { return command.CommandType; }
|
||||
set { command.CommandType = value; }
|
||||
}
|
||||
|
||||
protected DbConnectionProxy DbConnectionProxy;
|
||||
protected override DbConnection DbConnection
|
||||
{
|
||||
get { return DbConnectionProxy != null ? DbConnectionProxy : (DbConnectionProxy = new DbConnectionProxy(command.Connection, context)); }
|
||||
set { command.Connection = value is DbConnectionProxy ? value : (DbConnectionProxy = new DbConnectionProxy(value, context)); }
|
||||
}
|
||||
|
||||
protected override DbParameter CreateDbParameter()
|
||||
{
|
||||
return command.CreateParameter();
|
||||
}
|
||||
|
||||
public override int ExecuteNonQuery()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "ExecuteNonQuery", dur, DbConnectionProxy.GetThreadId())))
|
||||
{
|
||||
return command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, string.Format("ExecuteReader({0})", behavior), dur , DbConnectionProxy.GetThreadId())))
|
||||
{
|
||||
return command.ExecuteReader(behavior);
|
||||
}
|
||||
}
|
||||
|
||||
public override object ExecuteScalar()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "ExecuteScalar", dur, DbConnectionProxy.GetThreadId())))
|
||||
{
|
||||
return command.ExecuteScalar();
|
||||
}
|
||||
}
|
||||
|
||||
protected override DbParameterCollection DbParameterCollection
|
||||
{
|
||||
get { return command.Parameters; }
|
||||
}
|
||||
|
||||
public override void Prepare()
|
||||
{
|
||||
command.Prepare();
|
||||
}
|
||||
|
||||
protected override System.Data.Common.DbTransaction DbTransaction
|
||||
{
|
||||
get { return command.Transaction == null ? null : new DbTransactionProxy(command.Transaction, context, DbConnectionProxy.GetThreadId()); }
|
||||
set { command.Transaction = value is DbTransactionProxy ? ((DbTransactionProxy)value).Transaction : value; }
|
||||
}
|
||||
|
||||
public override bool DesignTimeVisible
|
||||
{
|
||||
get { return command.DesignTimeVisible; }
|
||||
set { command.DesignTimeVisible = value; }
|
||||
}
|
||||
|
||||
public override UpdateRowSource UpdatedRowSource
|
||||
{
|
||||
get { return command.UpdatedRowSource; }
|
||||
set { command.UpdatedRowSource = value; }
|
||||
}
|
||||
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
command.Dispose();
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
~DbCommandProxy()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,122 +1,151 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class DbConnectionProxy : DbConnection
|
||||
{
|
||||
private readonly DbConnection connection;
|
||||
private readonly ProxyContext context;
|
||||
private bool disposed;
|
||||
|
||||
|
||||
public DbConnectionProxy(DbConnection connection, ProxyContext ctx)
|
||||
{
|
||||
if (connection == null) throw new ArgumentNullException("connection");
|
||||
if (ctx == null) throw new ArgumentNullException("ctx");
|
||||
|
||||
this.connection = connection;
|
||||
context = ctx;
|
||||
}
|
||||
|
||||
protected override System.Data.Common.DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "BeginTransaction", dur)))
|
||||
{
|
||||
return new DbTransactionProxy(connection.BeginTransaction(), context);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ChangeDatabase(string databaseName)
|
||||
{
|
||||
connection.ChangeDatabase(databaseName);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
public override string ConnectionString
|
||||
{
|
||||
get { return connection.ConnectionString; }
|
||||
set { connection.ConnectionString = value; }
|
||||
}
|
||||
|
||||
public override int ConnectionTimeout
|
||||
{
|
||||
get { return connection.ConnectionTimeout; }
|
||||
}
|
||||
|
||||
protected override DbCommand CreateDbCommand()
|
||||
{
|
||||
return new DbCommandProxy(connection.CreateCommand(), context);
|
||||
}
|
||||
|
||||
public override string Database
|
||||
{
|
||||
get { return connection.Database; }
|
||||
}
|
||||
|
||||
public override string DataSource
|
||||
{
|
||||
get { return connection.DataSource; }
|
||||
}
|
||||
|
||||
public override void Open()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "Open", dur)))
|
||||
{
|
||||
connection.Open();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ServerVersion
|
||||
{
|
||||
get { return connection.ServerVersion; }
|
||||
}
|
||||
|
||||
public override ConnectionState State
|
||||
{
|
||||
get { return connection.State; }
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "Dispose", dur)))
|
||||
{
|
||||
connection.Dispose();
|
||||
}
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
~DbConnectionProxy()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class DbConnectionProxy : DbConnection
|
||||
{
|
||||
private readonly DbConnection connection;
|
||||
private DbCommandProxy dbCommandProxy;
|
||||
private readonly ProxyContext context;
|
||||
private bool disposed;
|
||||
private int threadId;
|
||||
|
||||
|
||||
public DbConnectionProxy(DbConnection connection, ProxyContext ctx)
|
||||
{
|
||||
if (connection == null) throw new ArgumentNullException("connection");
|
||||
if (ctx == null) throw new ArgumentNullException("ctx");
|
||||
|
||||
this.connection = connection;
|
||||
context = ctx;
|
||||
threadId = GetThreadId();
|
||||
}
|
||||
|
||||
protected override System.Data.Common.DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent("BeginTransaction", dur, GetThreadId())))
|
||||
{
|
||||
return new DbTransactionProxy(connection.BeginTransaction(), context, GetThreadId());
|
||||
}
|
||||
}
|
||||
|
||||
public override void ChangeDatabase(string databaseName)
|
||||
{
|
||||
connection.ChangeDatabase(databaseName);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
public override string ConnectionString
|
||||
{
|
||||
get { return connection.ConnectionString; }
|
||||
set { connection.ConnectionString = value; }
|
||||
}
|
||||
|
||||
public override int ConnectionTimeout
|
||||
{
|
||||
get { return connection.ConnectionTimeout; }
|
||||
}
|
||||
|
||||
protected override DbCommand CreateDbCommand()
|
||||
{
|
||||
if (dbCommandProxy != null)
|
||||
{
|
||||
dbCommandProxy.Parameters.Clear();
|
||||
return dbCommandProxy;
|
||||
}
|
||||
dbCommandProxy = new DbCommandProxy(connection.CreateCommand(), context, this);
|
||||
return dbCommandProxy;
|
||||
}
|
||||
|
||||
public override string Database
|
||||
{
|
||||
get { return connection.Database; }
|
||||
}
|
||||
|
||||
public override string DataSource
|
||||
{
|
||||
get { return connection.DataSource; }
|
||||
}
|
||||
|
||||
public override void Open()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent("Open", dur, GetThreadId())))
|
||||
{
|
||||
connection.Open();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ServerVersion
|
||||
{
|
||||
get { return connection.ServerVersion; }
|
||||
}
|
||||
|
||||
public override ConnectionState State
|
||||
{
|
||||
get { return connection.State; }
|
||||
}
|
||||
|
||||
internal int GetThreadId()
|
||||
{
|
||||
if (threadId != 0) return threadId;
|
||||
|
||||
if (connection is MySqlConnection mySqlConnection &&
|
||||
connection.State > ConnectionState.Closed)
|
||||
{
|
||||
threadId = mySqlConnection.ServerThread;
|
||||
}
|
||||
|
||||
return threadId;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
var threadId = GetThreadId();
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent("Dispose", dur, threadId)))
|
||||
{
|
||||
if (dbCommandProxy != null)
|
||||
{
|
||||
dbCommandProxy.Dispose();
|
||||
}
|
||||
connection.Dispose();
|
||||
}
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
~DbConnectionProxy()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,83 +1,85 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class DbTransactionProxy : System.Data.Common.DbTransaction
|
||||
{
|
||||
private bool disposed;
|
||||
private readonly ProxyContext context;
|
||||
public readonly System.Data.Common.DbTransaction Transaction;
|
||||
|
||||
public DbTransactionProxy(System.Data.Common.DbTransaction transaction, ProxyContext ctx)
|
||||
{
|
||||
if (transaction == null) throw new ArgumentNullException("transaction");
|
||||
if (ctx == null) throw new ArgumentNullException("ctx");
|
||||
|
||||
Transaction = transaction;
|
||||
context = ctx;
|
||||
}
|
||||
|
||||
|
||||
public override void Commit()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "Commit", dur)))
|
||||
{
|
||||
Transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
protected override DbConnection DbConnection
|
||||
{
|
||||
get { return (DbConnection)Transaction.Connection; }
|
||||
}
|
||||
|
||||
public override IsolationLevel IsolationLevel
|
||||
{
|
||||
get { return Transaction.IsolationLevel; }
|
||||
}
|
||||
|
||||
public override void Rollback()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "Rollback", dur)))
|
||||
{
|
||||
Transaction.Rollback();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Transaction.Dispose();
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
~DbTransactionProxy()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class DbTransactionProxy : System.Data.Common.DbTransaction
|
||||
{
|
||||
private bool disposed;
|
||||
private readonly ProxyContext context;
|
||||
private readonly int threadId;
|
||||
public readonly System.Data.Common.DbTransaction Transaction;
|
||||
|
||||
public DbTransactionProxy(System.Data.Common.DbTransaction transaction, ProxyContext ctx, int threadId)
|
||||
{
|
||||
if (transaction == null) throw new ArgumentNullException("transaction");
|
||||
if (ctx == null) throw new ArgumentNullException("ctx");
|
||||
|
||||
Transaction = transaction;
|
||||
context = ctx;
|
||||
this.threadId = threadId;
|
||||
}
|
||||
|
||||
|
||||
public override void Commit()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "Commit", dur, threadId)))
|
||||
{
|
||||
Transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
protected override DbConnection DbConnection
|
||||
{
|
||||
get { return Transaction.Connection; }
|
||||
}
|
||||
|
||||
public override IsolationLevel IsolationLevel
|
||||
{
|
||||
get { return Transaction.IsolationLevel; }
|
||||
}
|
||||
|
||||
public override void Rollback()
|
||||
{
|
||||
using (ExecuteHelper.Begin(dur => context.FireExecuteEvent(this, "Rollback", dur, threadId)))
|
||||
{
|
||||
Transaction.Rollback();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Transaction.Dispose();
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
~DbTransactionProxy()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +1,67 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class ExecutedEventArgs : EventArgs
|
||||
{
|
||||
public TimeSpan Duration { get; private set; }
|
||||
|
||||
public string SqlMethod { get; private set; }
|
||||
|
||||
public string Sql { get; private set; }
|
||||
|
||||
public string SqlParameters { get; private set; }
|
||||
|
||||
|
||||
public ExecutedEventArgs(string method, TimeSpan duration)
|
||||
: this(method, duration, null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ExecutedEventArgs(string method, TimeSpan duration, DbCommand command)
|
||||
{
|
||||
SqlMethod = method;
|
||||
Duration = duration;
|
||||
if (command != null)
|
||||
{
|
||||
Sql = command.CommandText;
|
||||
|
||||
if (0 < command.Parameters.Count)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
foreach (IDbDataParameter p in command.Parameters)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(p.ParameterName)) stringBuilder.AppendFormat("{0}=", p.ParameterName);
|
||||
stringBuilder.AppendFormat("{0}, ", p.Value == null || DBNull.Value.Equals(p.Value) ? "NULL" : p.Value.ToString());
|
||||
}
|
||||
SqlParameters = stringBuilder.ToString(0, stringBuilder.Length - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class ExecutedEventArgs : EventArgs
|
||||
{
|
||||
public TimeSpan Duration { get; private set; }
|
||||
|
||||
public string SqlMethod { get; private set; }
|
||||
|
||||
public string Sql { get; private set; }
|
||||
|
||||
public string SqlParameters { get; private set; }
|
||||
|
||||
public int SqlThread { get; private set; }
|
||||
|
||||
|
||||
public ExecutedEventArgs(string method, TimeSpan duration, int sqlThread = 0)
|
||||
: this(method, duration, null, sqlThread)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ExecutedEventArgs(string method, TimeSpan duration, DbCommand command, int sqlThread = 0)
|
||||
{
|
||||
SqlMethod = method;
|
||||
Duration = duration;
|
||||
SqlThread = sqlThread;
|
||||
|
||||
if (command != null)
|
||||
{
|
||||
Sql = command.CommandText;
|
||||
|
||||
if (0 < command.Parameters.Count)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
foreach (IDbDataParameter p in command.Parameters)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(p.ParameterName)) stringBuilder.AppendFormat("{0}=", p.ParameterName);
|
||||
stringBuilder.AppendFormat("{0}, ", p.Value == null || DBNull.Value.Equals(p.Value) ? "NULL" : p.Value.ToString());
|
||||
}
|
||||
SqlParameters = stringBuilder.ToString(0, stringBuilder.Length - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +1,54 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class ExecuteHelper : IDisposable
|
||||
{
|
||||
private readonly Stopwatch stopwatch;
|
||||
private readonly Action<TimeSpan> onStop;
|
||||
|
||||
|
||||
private ExecuteHelper(Action<TimeSpan> onStop)
|
||||
{
|
||||
if (onStop == null) throw new ArgumentNullException("onStop");
|
||||
|
||||
this.onStop = onStop;
|
||||
stopwatch = Stopwatch.StartNew();
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
stopwatch.Stop();
|
||||
try
|
||||
{
|
||||
onStop(stopwatch.Elapsed);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
||||
public static IDisposable Begin(Action<TimeSpan> onStop)
|
||||
{
|
||||
return new ExecuteHelper(onStop);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class ExecuteHelper : IDisposable
|
||||
{
|
||||
private readonly Stopwatch stopwatch;
|
||||
private readonly Action<TimeSpan> onStop;
|
||||
|
||||
|
||||
private ExecuteHelper(Action<TimeSpan> onStop)
|
||||
{
|
||||
if (onStop == null) throw new ArgumentNullException("onStop");
|
||||
|
||||
this.onStop = onStop;
|
||||
stopwatch = Stopwatch.StartNew();
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
stopwatch.Stop();
|
||||
try
|
||||
{
|
||||
onStop(stopwatch.Elapsed);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
||||
public static IDisposable Begin(Action<TimeSpan> onStop)
|
||||
{
|
||||
return new ExecuteHelper(onStop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +1,53 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class ProxyContext
|
||||
{
|
||||
private readonly Action<ExecutedEventArgs> executedEvent;
|
||||
|
||||
|
||||
public ProxyContext(Action<ExecutedEventArgs> executedEvent)
|
||||
{
|
||||
if (executedEvent == null)
|
||||
{
|
||||
throw new ArgumentNullException("executedEvent");
|
||||
}
|
||||
this.executedEvent = executedEvent;
|
||||
}
|
||||
|
||||
|
||||
public void FireExecuteEvent(DbCommand cmd, string method, TimeSpan duration)
|
||||
{
|
||||
executedEvent(new ExecutedEventArgs("Command." + method, duration, cmd));
|
||||
}
|
||||
|
||||
public void FireExecuteEvent(IDbConnection conn, string method, TimeSpan duration)
|
||||
{
|
||||
executedEvent(new ExecutedEventArgs("Connection." + method, duration));
|
||||
}
|
||||
|
||||
public void FireExecuteEvent(IDbTransaction tx, string method, TimeSpan duration)
|
||||
{
|
||||
executedEvent(new ExecutedEventArgs("Transaction." + method, duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data.AdoProxy
|
||||
{
|
||||
class ProxyContext
|
||||
{
|
||||
private readonly Action<ExecutedEventArgs> executedEvent;
|
||||
|
||||
|
||||
public ProxyContext(Action<ExecutedEventArgs> executedEvent)
|
||||
{
|
||||
if (executedEvent == null)
|
||||
{
|
||||
throw new ArgumentNullException("executedEvent");
|
||||
}
|
||||
this.executedEvent = executedEvent;
|
||||
}
|
||||
|
||||
|
||||
public void FireExecuteEvent(DbCommandProxy cmd, string method, TimeSpan duration, int sqlThread)
|
||||
{
|
||||
executedEvent(new ExecutedEventArgs("Command." + method, duration, cmd, sqlThread));
|
||||
}
|
||||
|
||||
public void FireExecuteEvent(string method, TimeSpan duration, int sqlThread)
|
||||
{
|
||||
executedEvent(new ExecutedEventArgs("Connection." + method, duration, sqlThread));
|
||||
}
|
||||
|
||||
public void FireExecuteEvent(IDbTransaction tx, string method, TimeSpan duration, int sqlThread)
|
||||
{
|
||||
executedEvent(new ExecutedEventArgs("Transaction." + method, duration, sqlThread));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,332 +1,335 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public static class DataExtensions
|
||||
{
|
||||
public static List<object[]> ExecuteList(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
return command.ExecuteList(sql, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
return command.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public static int ExecuteNonQuery(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
return command.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public static DbCommand CreateCommand(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = sql;
|
||||
command.AddParameters(parameters);
|
||||
return command;
|
||||
}
|
||||
|
||||
|
||||
public static DbCommand AddParameter(this DbCommand command, string name, object value)
|
||||
{
|
||||
var p = command.CreateParameter();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
p.ParameterName = name.StartsWith("@") ? name : "@" + name;
|
||||
}
|
||||
|
||||
p.Value = GetParameterValue(value);
|
||||
|
||||
command.Parameters.Add(p);
|
||||
return command;
|
||||
}
|
||||
|
||||
public static object GetParameterValue(object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return DBNull.Value;
|
||||
}
|
||||
|
||||
var @enum = value as Enum;
|
||||
if (@enum != null)
|
||||
{
|
||||
return @enum.ToString("d");
|
||||
}
|
||||
|
||||
if (value is DateTime)
|
||||
{
|
||||
var d = (DateTime)value;
|
||||
return new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second, DateTimeKind.Unspecified);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DbCommand AddParameters(this DbCommand command, params object[] parameters)
|
||||
{
|
||||
if (parameters == null) return command;
|
||||
foreach (var value in parameters)
|
||||
{
|
||||
if (value != null && IsAnonymousType(value.GetType()))
|
||||
{
|
||||
foreach (var p in value.GetType().GetProperties())
|
||||
{
|
||||
command.AddParameter(p.Name, p.GetValue(value, null));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
command.AddParameter(null, value);
|
||||
}
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
public static List<object[]> ExecuteList(this DbCommand command)
|
||||
{
|
||||
return ExecuteList(command, command.CommandText, null);
|
||||
}
|
||||
|
||||
public static Task<List<object[]>> ExecuteListAsync(this DbCommand command)
|
||||
{
|
||||
return ExecuteListAsync(command, command.CommandText, null);
|
||||
}
|
||||
|
||||
public static List<object[]> ExecuteList(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
return ExecuteListReader(command.PrepareCommand(sql, parameters));
|
||||
}
|
||||
|
||||
public static Task<List<object[]>> ExecuteListAsync(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
return ExecuteListReaderAsync(command.PrepareCommand(sql, parameters));
|
||||
}
|
||||
|
||||
private static List<object[]> ExecuteListReader(DbCommand command)
|
||||
{
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
return ExecuteListReaderResult(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<List<object[]>> ExecuteListReaderAsync(DbCommand command)
|
||||
{
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
return ExecuteListReaderResult(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<object[]> ExecuteListReaderResult(IDataReader reader)
|
||||
{
|
||||
var result = new List<object[]>();
|
||||
var fieldCount = reader.FieldCount;
|
||||
while (reader.Read())
|
||||
{
|
||||
var row = new object[fieldCount];
|
||||
for (var i = 0; i < fieldCount; i++)
|
||||
{
|
||||
row[i] = reader[i];
|
||||
if (DBNull.Value.Equals(row[i])) row[i] = null;
|
||||
}
|
||||
result.Add(row);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbCommand command)
|
||||
{
|
||||
return ExecuteScalar<T>(command, command.CommandText, null);
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
|
||||
var scalar = command.ExecuteScalar();
|
||||
|
||||
if (scalar == null || scalar == DBNull.Value)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
var scalarType = typeof(T);
|
||||
if (scalarType == typeof(object))
|
||||
{
|
||||
return (T)scalar;
|
||||
}
|
||||
if (scalarType.Name == "Nullable`1")
|
||||
{
|
||||
scalarType = scalarType.GetGenericArguments()[0];
|
||||
}
|
||||
return (T)Convert.ChangeType(scalar, scalarType);
|
||||
}
|
||||
|
||||
public static async Task<T> ExecuteScalarAsync<T>(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
|
||||
var scalar = await command.ExecuteScalarAsync();
|
||||
|
||||
if (scalar == null || scalar == DBNull.Value)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
var scalarType = typeof(T);
|
||||
if (scalarType == typeof(object))
|
||||
{
|
||||
return (T)scalar;
|
||||
}
|
||||
if (scalarType.Name == "Nullable`1")
|
||||
{
|
||||
scalarType = scalarType.GetGenericArguments()[0];
|
||||
}
|
||||
return (T)Convert.ChangeType(scalar, scalarType);
|
||||
}
|
||||
|
||||
public static int ExecuteNonQuery(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
return command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static Task<int> ExecuteNonQueryAsync(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
return command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
public static List<object[]> ExecuteList(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteList();
|
||||
}
|
||||
|
||||
public static Task<List<object[]>> ExecuteListAsync(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteListAsync();
|
||||
}
|
||||
|
||||
public static List<T> ExecuteList<T>(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect, Converter<IDataRecord, T> mapper)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
var result = new List<T>();
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(mapper(reader));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteScalar<T>();
|
||||
}
|
||||
|
||||
public static int ExecuteNonQuery(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
private static void ApplySqlInstruction(DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
var sqlStr = sql.ToString(dialect);
|
||||
var parameters = sql.GetParameters();
|
||||
command.Parameters.Clear();
|
||||
|
||||
var sqlParts = sqlStr.Split('?');
|
||||
var sqlBuilder = new StringBuilder();
|
||||
for (var i = 0; i < sqlParts.Length - 1; i++)
|
||||
{
|
||||
var name = "p" + i;
|
||||
command.AddParameter(name, parameters[i]);
|
||||
sqlBuilder.AppendFormat("{0}@{1}", sqlParts[i], name);
|
||||
}
|
||||
sqlBuilder.Append(sqlParts[sqlParts.Length - 1]);
|
||||
command.CommandText = sqlBuilder.ToString();
|
||||
}
|
||||
|
||||
|
||||
public static T Get<T>(this IDataRecord r, int i)
|
||||
{
|
||||
if (r.IsDBNull(i))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
var value = r.GetValue(i);
|
||||
if (typeof(T) == typeof(Guid))
|
||||
{
|
||||
value = r.GetGuid(i);
|
||||
}
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
}
|
||||
|
||||
public static T Get<T>(this IDataRecord r, string name)
|
||||
{
|
||||
return Get<T>(r, r.GetOrdinal(name));
|
||||
}
|
||||
|
||||
private static bool IsAnonymousType(Type type)
|
||||
{
|
||||
return type.IsGenericType
|
||||
&& (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic
|
||||
&& (type.Name.StartsWith("<>", StringComparison.OrdinalIgnoreCase) || type.Name.StartsWith("VB$", StringComparison.OrdinalIgnoreCase))
|
||||
&& (type.Name.Contains("AnonymousType") || type.Name.Contains("AnonType"))
|
||||
&& Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute), false);
|
||||
}
|
||||
|
||||
private static DbCommand PrepareCommand(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.CommandText = sql;
|
||||
if (parameters != null)
|
||||
{
|
||||
command.Parameters.Clear();
|
||||
command.AddParameters(parameters);
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public static class DataExtensions
|
||||
{
|
||||
public static List<object[]> ExecuteList(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
return command.ExecuteList(sql, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
return command.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public static int ExecuteNonQuery(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
using (var command = connection.CreateCommand())
|
||||
{
|
||||
return command.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public static DbCommand CreateCommand(this DbConnection connection, string sql, params object[] parameters)
|
||||
{
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = sql;
|
||||
command.AddParameters(parameters);
|
||||
return command;
|
||||
}
|
||||
|
||||
|
||||
public static DbCommand AddParameter(this DbCommand command, string name, object value)
|
||||
{
|
||||
var p = command.CreateParameter();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
p.ParameterName = name.StartsWith("@") ? name : "@" + name;
|
||||
}
|
||||
|
||||
p.Value = GetParameterValue(value);
|
||||
|
||||
command.Parameters.Add(p);
|
||||
return command;
|
||||
}
|
||||
|
||||
public static object GetParameterValue(object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return DBNull.Value;
|
||||
}
|
||||
|
||||
var @enum = value as Enum;
|
||||
if (@enum != null)
|
||||
{
|
||||
return @enum.ToString("d");
|
||||
}
|
||||
|
||||
if (value is DateTime)
|
||||
{
|
||||
var d = (DateTime)value;
|
||||
return new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second, DateTimeKind.Unspecified);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DbCommand AddParameters(this DbCommand command, params object[] parameters)
|
||||
{
|
||||
if (parameters == null) return command;
|
||||
foreach (var value in parameters)
|
||||
{
|
||||
if (value != null && IsAnonymousType(value.GetType()))
|
||||
{
|
||||
foreach (var p in value.GetType().GetProperties())
|
||||
{
|
||||
command.AddParameter(p.Name, p.GetValue(value, null));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
command.AddParameter(null, value);
|
||||
}
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
public static List<object[]> ExecuteList(this DbCommand command)
|
||||
{
|
||||
return ExecuteList(command, command.CommandText, null);
|
||||
}
|
||||
|
||||
public static Task<List<object[]>> ExecuteListAsync(this DbCommand command)
|
||||
{
|
||||
return ExecuteListAsync(command, command.CommandText, null);
|
||||
}
|
||||
|
||||
public static List<object[]> ExecuteList(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
return ExecuteListReader(command.PrepareCommand(sql, parameters));
|
||||
}
|
||||
|
||||
public static Task<List<object[]>> ExecuteListAsync(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
return ExecuteListReaderAsync(command.PrepareCommand(sql, parameters));
|
||||
}
|
||||
|
||||
private static List<object[]> ExecuteListReader(DbCommand command)
|
||||
{
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
return ExecuteListReaderResult(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<List<object[]>> ExecuteListReaderAsync(DbCommand command)
|
||||
{
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
return ExecuteListReaderResult(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<object[]> ExecuteListReaderResult(IDataReader reader)
|
||||
{
|
||||
var result = new List<object[]>();
|
||||
var fieldCount = reader.FieldCount;
|
||||
while (reader.Read())
|
||||
{
|
||||
var row = new object[fieldCount];
|
||||
for (var i = 0; i < fieldCount; i++)
|
||||
{
|
||||
row[i] = reader[i];
|
||||
if (DBNull.Value.Equals(row[i])) row[i] = null;
|
||||
}
|
||||
result.Add(row);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbCommand command)
|
||||
{
|
||||
return ExecuteScalar<T>(command, command.CommandText, null);
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
|
||||
var scalar = command.ExecuteScalar();
|
||||
|
||||
if (scalar == null || scalar == DBNull.Value)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
var scalarType = typeof(T);
|
||||
if (scalarType == typeof(object))
|
||||
{
|
||||
return (T)scalar;
|
||||
}
|
||||
if (scalarType.Name == "Nullable`1")
|
||||
{
|
||||
scalarType = scalarType.GetGenericArguments()[0];
|
||||
}
|
||||
return (T)Convert.ChangeType(scalar, scalarType);
|
||||
}
|
||||
|
||||
public static async Task<T> ExecuteScalarAsync<T>(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
|
||||
var scalar = await command.ExecuteScalarAsync();
|
||||
|
||||
if (scalar == null || scalar == DBNull.Value)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
var scalarType = typeof(T);
|
||||
if (scalarType == typeof(object))
|
||||
{
|
||||
return (T)scalar;
|
||||
}
|
||||
if (scalarType.Name == "Nullable`1")
|
||||
{
|
||||
scalarType = scalarType.GetGenericArguments()[0];
|
||||
}
|
||||
return (T)Convert.ChangeType(scalar, scalarType);
|
||||
}
|
||||
|
||||
public static int ExecuteNonQuery(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
return command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public static Task<int> ExecuteNonQueryAsync(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.PrepareCommand(sql, parameters);
|
||||
return command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
public static List<object[]> ExecuteList(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteList();
|
||||
}
|
||||
|
||||
public static Task<List<object[]>> ExecuteListAsync(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteListAsync();
|
||||
}
|
||||
|
||||
public static List<T> ExecuteList<T>(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect, Converter<IDataRecord, T> mapper)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
var result = new List<T>();
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(mapper(reader));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static T ExecuteScalar<T>(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteScalar<T>();
|
||||
}
|
||||
|
||||
public static int ExecuteNonQuery(this DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
ApplySqlInstruction(command, sql, dialect);
|
||||
return command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
private static void ApplySqlInstruction(DbCommand command, ISqlInstruction sql, ISqlDialect dialect)
|
||||
{
|
||||
var sqlStr = sql.ToString(dialect);
|
||||
var parameters = sql.GetParameters();
|
||||
command.Parameters.Clear();
|
||||
|
||||
var sqlParts = sqlStr.Split('?');
|
||||
var sqlBuilder = new StringBuilder();
|
||||
var i = 0;
|
||||
foreach(var p in parameters)
|
||||
{
|
||||
var name = $"p{i}";
|
||||
command.AddParameter(name, p);
|
||||
sqlBuilder.AppendFormat("{0}@{1}", sqlParts[i], name);
|
||||
i++;
|
||||
}
|
||||
|
||||
sqlBuilder.Append(sqlParts[sqlParts.Length - 1]);
|
||||
command.CommandText = sqlBuilder.ToString();
|
||||
}
|
||||
|
||||
|
||||
public static T Get<T>(this IDataRecord r, int i)
|
||||
{
|
||||
if (r.IsDBNull(i))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
var value = r.GetValue(i);
|
||||
if (typeof(T) == typeof(Guid))
|
||||
{
|
||||
value = r.GetGuid(i);
|
||||
}
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
}
|
||||
|
||||
public static T Get<T>(this IDataRecord r, string name)
|
||||
{
|
||||
return Get<T>(r, r.GetOrdinal(name));
|
||||
}
|
||||
|
||||
private static bool IsAnonymousType(Type type)
|
||||
{
|
||||
return type.IsGenericType
|
||||
&& (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic
|
||||
&& (type.Name.StartsWith("<>", StringComparison.OrdinalIgnoreCase) || type.Name.StartsWith("VB$", StringComparison.OrdinalIgnoreCase))
|
||||
&& (type.Name.Contains("AnonymousType") || type.Name.Contains("AnonType"))
|
||||
&& Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute), false);
|
||||
}
|
||||
|
||||
private static DbCommand PrepareCommand(this DbCommand command, string sql, params object[] parameters)
|
||||
{
|
||||
command.CommandText = sql;
|
||||
if (parameters != null)
|
||||
{
|
||||
command.Parameters.Clear();
|
||||
command.AddParameters(parameters);
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,396 +1,366 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
using ASC.Common.Data.AdoProxy;
|
||||
using ASC.Common.Data.Sql;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Web;
|
||||
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public class DbManager : IDbManager
|
||||
{
|
||||
private readonly ILog logger = LogManager.GetLogger("ASC.SQL");
|
||||
private readonly ProxyContext proxyContext;
|
||||
private readonly bool shared;
|
||||
|
||||
private DbCommand command;
|
||||
private ISqlDialect dialect;
|
||||
private volatile bool disposed;
|
||||
|
||||
private readonly int? commandTimeout;
|
||||
|
||||
private DbCommand Command
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckDispose();
|
||||
if (command == null)
|
||||
{
|
||||
command = OpenConnection().CreateCommand();
|
||||
}
|
||||
if (command.Connection.State == ConnectionState.Closed || command.Connection.State == ConnectionState.Broken)
|
||||
{
|
||||
command = OpenConnection().CreateCommand();
|
||||
}
|
||||
|
||||
if (commandTimeout.HasValue)
|
||||
{
|
||||
command.CommandTimeout = commandTimeout.Value;
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
public string DatabaseId { get; private set; }
|
||||
|
||||
public bool InTransaction
|
||||
{
|
||||
get { return Command.Transaction != null; }
|
||||
}
|
||||
|
||||
public DbConnection Connection
|
||||
{
|
||||
get { return Command.Connection; }
|
||||
}
|
||||
|
||||
|
||||
public DbManager(string databaseId, int? commandTimeout = null)
|
||||
: this(databaseId, true, commandTimeout)
|
||||
{
|
||||
}
|
||||
|
||||
public DbManager(string databaseId, bool shared, int? commandTimeout = null)
|
||||
{
|
||||
if (databaseId == null) throw new ArgumentNullException("databaseId");
|
||||
DatabaseId = databaseId;
|
||||
this.shared = shared;
|
||||
|
||||
if (logger.IsDebugEnabled)
|
||||
{
|
||||
proxyContext = new ProxyContext(AdoProxyExecutedEventHandler);
|
||||
}
|
||||
|
||||
if (commandTimeout.HasValue)
|
||||
{
|
||||
this.commandTimeout = commandTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
if (command != null)
|
||||
{
|
||||
if (command.Connection != null) command.Connection.Dispose();
|
||||
command.Dispose();
|
||||
command = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static IDbManager FromHttpContext(string databaseId)
|
||||
{
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var dbManager = DisposableHttpContext.Current[databaseId] as DbManager;
|
||||
if (dbManager == null || dbManager.disposed)
|
||||
{
|
||||
var localDbManager = new DbManager(databaseId);
|
||||
var dbManagerAdapter = new DbManagerProxy(localDbManager);
|
||||
DisposableHttpContext.Current[databaseId] = localDbManager;
|
||||
return dbManagerAdapter;
|
||||
}
|
||||
return new DbManagerProxy(dbManager);
|
||||
}
|
||||
return new DbManager(databaseId);
|
||||
}
|
||||
|
||||
private DbConnection OpenConnection()
|
||||
{
|
||||
var connection = GetConnection();
|
||||
connection.Open();
|
||||
return connection;
|
||||
}
|
||||
|
||||
private DbConnection GetConnection()
|
||||
{
|
||||
CheckDispose();
|
||||
DbConnection connection = null;
|
||||
string key = null;
|
||||
if (shared && HttpContext.Current != null)
|
||||
{
|
||||
key = string.Format("Connection {0}|{1}", GetDialect(), DbRegistry.GetConnectionString(DatabaseId));
|
||||
connection = DisposableHttpContext.Current[key] as DbConnection;
|
||||
if (connection != null)
|
||||
{
|
||||
var state = ConnectionState.Closed;
|
||||
var disposed = false;
|
||||
try
|
||||
{
|
||||
state = connection.State;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
disposed = true;
|
||||
}
|
||||
if (!disposed && (state == ConnectionState.Closed || state == ConnectionState.Broken))
|
||||
{
|
||||
if (string.IsNullOrEmpty(connection.ConnectionString))
|
||||
{
|
||||
connection.ConnectionString = DbRegistry.GetConnectionString(DatabaseId).ConnectionString;
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
connection = DbRegistry.CreateDbConnection(DatabaseId);
|
||||
if (proxyContext != null)
|
||||
{
|
||||
connection = new DbConnectionProxy(connection, proxyContext);
|
||||
}
|
||||
if (shared && HttpContext.Current != null) DisposableHttpContext.Current[key] = connection;
|
||||
return connection;
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction()
|
||||
{
|
||||
if (InTransaction) throw new InvalidOperationException("Transaction already open.");
|
||||
|
||||
Command.Transaction = Command.Connection.BeginTransaction();
|
||||
|
||||
var tx = new DbTransaction(Command.Transaction);
|
||||
tx.Unavailable += TransactionUnavailable;
|
||||
return tx;
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(IsolationLevel il)
|
||||
{
|
||||
if (InTransaction) throw new InvalidOperationException("Transaction already open.");
|
||||
|
||||
il = GetDialect().GetSupportedIsolationLevel(il);
|
||||
Command.Transaction = Command.Connection.BeginTransaction(il);
|
||||
|
||||
var tx = new DbTransaction(Command.Transaction);
|
||||
tx.Unavailable += TransactionUnavailable;
|
||||
return tx;
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen)
|
||||
{
|
||||
return nestedIfAlreadyOpen && InTransaction ? new DbNestedTransaction(Command.Transaction) : BeginTransaction();
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteList(sql, parameters);
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteListAsync(sql, parameters);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteList(sql, GetDialect());
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteListAsync(sql, GetDialect());
|
||||
}
|
||||
|
||||
public List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter)
|
||||
{
|
||||
return Command.ExecuteList(sql, GetDialect(), converter);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteScalar<T>(sql, GetDialect());
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
|
||||
public Task<int> ExecuteNonQueryAsync(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteNonQueryAsync(sql, parameters);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteNonQuery(sql, GetDialect());
|
||||
}
|
||||
|
||||
public int ExecuteBatch(IEnumerable<ISqlInstruction> batch)
|
||||
{
|
||||
if (batch == null) throw new ArgumentNullException("batch");
|
||||
|
||||
var affected = 0;
|
||||
using (var tx = BeginTransaction())
|
||||
{
|
||||
foreach (var sql in batch)
|
||||
{
|
||||
affected += ExecuteNonQuery(sql);
|
||||
}
|
||||
tx.Commit();
|
||||
}
|
||||
return affected;
|
||||
}
|
||||
|
||||
private void TransactionUnavailable(object sender, EventArgs e)
|
||||
{
|
||||
if (Command.Transaction != null)
|
||||
{
|
||||
Command.Transaction = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckDispose()
|
||||
{
|
||||
if (disposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
}
|
||||
|
||||
private ISqlDialect GetDialect()
|
||||
{
|
||||
return dialect ?? (dialect = DbRegistry.GetSqlDialect(DatabaseId));
|
||||
}
|
||||
|
||||
private void AdoProxyExecutedEventHandler(ExecutedEventArgs a)
|
||||
{
|
||||
logger.DebugWithProps(a.SqlMethod,
|
||||
new KeyValuePair<string, object>("duration", a.Duration.TotalMilliseconds),
|
||||
new KeyValuePair<string, object>("sql", RemoveWhiteSpaces(a.Sql)),
|
||||
new KeyValuePair<string, object>("sqlParams", RemoveWhiteSpaces(a.SqlParameters))
|
||||
);
|
||||
}
|
||||
|
||||
private string RemoveWhiteSpaces(string str)
|
||||
{
|
||||
return !string.IsNullOrEmpty(str) ?
|
||||
str.Replace(Environment.NewLine, " ").Replace("\n", "").Replace("\r", "").Replace("\t", " ") :
|
||||
string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public class DbManagerProxy : IDbManager
|
||||
{
|
||||
private DbManager dbManager { get; set; }
|
||||
|
||||
public DbManagerProxy(DbManager dbManager)
|
||||
{
|
||||
this.dbManager = dbManager;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
dbManager.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public DbConnection Connection { get { return dbManager.Connection; } }
|
||||
public string DatabaseId { get { return dbManager.DatabaseId; } }
|
||||
public bool InTransaction { get { return dbManager.InTransaction; } }
|
||||
|
||||
public IDbTransaction BeginTransaction()
|
||||
{
|
||||
return dbManager.BeginTransaction();
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
|
||||
{
|
||||
return dbManager.BeginTransaction(isolationLevel);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen)
|
||||
{
|
||||
return dbManager.BeginTransaction(nestedIfAlreadyOpen);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(string sql, params object[] parameters)
|
||||
{
|
||||
return dbManager.ExecuteList(sql, parameters);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteList(sql);
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteListAsync(sql);
|
||||
}
|
||||
|
||||
public List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter)
|
||||
{
|
||||
return dbManager.ExecuteList<T>(sql, converter);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(string sql, params object[] parameters)
|
||||
{
|
||||
return dbManager.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteScalar<T>(sql);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string sql, params object[] parameters)
|
||||
{
|
||||
return dbManager.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteNonQuery(sql);
|
||||
}
|
||||
|
||||
public int ExecuteBatch(IEnumerable<ISqlInstruction> batch)
|
||||
{
|
||||
return dbManager.ExecuteBatch(batch);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
using ASC.Common.Data.AdoProxy;
|
||||
using ASC.Common.Data.Sql;
|
||||
using ASC.Common.Logging;
|
||||
using ASC.Common.Web;
|
||||
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public class DbManager : IDbManager
|
||||
{
|
||||
private readonly ILog logger = LogManager.GetLogger("ASC.SQL");
|
||||
private readonly ProxyContext proxyContext;
|
||||
|
||||
private DbCommand command;
|
||||
private ISqlDialect dialect;
|
||||
private volatile bool disposed;
|
||||
|
||||
private readonly int? commandTimeout;
|
||||
|
||||
private DbCommand Command
|
||||
{
|
||||
get
|
||||
{
|
||||
CheckDispose();
|
||||
if (command == null)
|
||||
{
|
||||
command = OpenConnection().CreateCommand();
|
||||
}
|
||||
if (command.Connection.State == ConnectionState.Closed || command.Connection.State == ConnectionState.Broken)
|
||||
{
|
||||
command = OpenConnection().CreateCommand();
|
||||
}
|
||||
|
||||
if (commandTimeout.HasValue)
|
||||
{
|
||||
command.CommandTimeout = commandTimeout.Value;
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
public string DatabaseId { get; private set; }
|
||||
|
||||
public bool InTransaction
|
||||
{
|
||||
get { return Command.Transaction != null; }
|
||||
}
|
||||
|
||||
public DbConnection Connection
|
||||
{
|
||||
get { return Command.Connection; }
|
||||
}
|
||||
|
||||
|
||||
private DbManager(string databaseId, int? commandTimeout = null)
|
||||
{
|
||||
if (databaseId == null) throw new ArgumentNullException("databaseId");
|
||||
DatabaseId = databaseId;
|
||||
|
||||
if (logger.IsDebugEnabled)
|
||||
{
|
||||
proxyContext = new ProxyContext(AdoProxyExecutedEventHandler);
|
||||
}
|
||||
|
||||
if (commandTimeout.HasValue)
|
||||
{
|
||||
this.commandTimeout = commandTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
if (command != null)
|
||||
{
|
||||
if (command.Connection != null) command.Connection.Dispose();
|
||||
command.Dispose();
|
||||
command = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static IDbManager FromHttpContext(string databaseId, int? commandTimeout = null)
|
||||
{
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
var dbManager = DisposableHttpContext.Current[databaseId] as DbManager;
|
||||
if (dbManager == null || dbManager.disposed)
|
||||
{
|
||||
var localDbManager = new DbManager(databaseId, commandTimeout);
|
||||
var dbManagerAdapter = new DbManagerProxy(localDbManager);
|
||||
DisposableHttpContext.Current[databaseId] = localDbManager;
|
||||
return dbManagerAdapter;
|
||||
}
|
||||
return new DbManagerProxy(dbManager);
|
||||
}
|
||||
return new DbManager(databaseId, commandTimeout);
|
||||
}
|
||||
|
||||
private DbConnection OpenConnection()
|
||||
{
|
||||
var connection = GetConnection();
|
||||
connection.Open();
|
||||
return connection;
|
||||
}
|
||||
|
||||
private DbConnection GetConnection()
|
||||
{
|
||||
CheckDispose();
|
||||
var connection = DbRegistry.CreateDbConnection(DatabaseId);
|
||||
if (proxyContext != null)
|
||||
{
|
||||
connection = new DbConnectionProxy(connection, proxyContext);
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction()
|
||||
{
|
||||
if (InTransaction) throw new InvalidOperationException("Transaction already open.");
|
||||
|
||||
Command.Transaction = Command.Connection.BeginTransaction();
|
||||
|
||||
var tx = new DbTransaction(Command.Transaction);
|
||||
tx.Unavailable += TransactionUnavailable;
|
||||
return tx;
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(IsolationLevel il)
|
||||
{
|
||||
if (InTransaction) throw new InvalidOperationException("Transaction already open.");
|
||||
|
||||
il = GetDialect().GetSupportedIsolationLevel(il);
|
||||
Command.Transaction = Command.Connection.BeginTransaction(il);
|
||||
|
||||
var tx = new DbTransaction(Command.Transaction);
|
||||
tx.Unavailable += TransactionUnavailable;
|
||||
return tx;
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen)
|
||||
{
|
||||
return nestedIfAlreadyOpen && InTransaction ? new DbNestedTransaction(Command.Transaction) : BeginTransaction();
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteList(sql, parameters);
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteListAsync(sql, parameters);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteList(sql, GetDialect());
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteListAsync(sql, GetDialect());
|
||||
}
|
||||
|
||||
public List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter)
|
||||
{
|
||||
return Command.ExecuteList(sql, GetDialect(), converter);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteScalar<T>(sql, GetDialect());
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
|
||||
public Task<int> ExecuteNonQueryAsync(string sql, params object[] parameters)
|
||||
{
|
||||
return Command.ExecuteNonQueryAsync(sql, parameters);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(ISqlInstruction sql)
|
||||
{
|
||||
return Command.ExecuteNonQuery(sql, GetDialect());
|
||||
}
|
||||
|
||||
public int ExecuteBatch(IEnumerable<ISqlInstruction> batch)
|
||||
{
|
||||
if (batch == null) throw new ArgumentNullException("batch");
|
||||
|
||||
var affected = 0;
|
||||
using (var tx = BeginTransaction())
|
||||
{
|
||||
foreach (var sql in batch)
|
||||
{
|
||||
affected += ExecuteNonQuery(sql);
|
||||
}
|
||||
tx.Commit();
|
||||
}
|
||||
return affected;
|
||||
}
|
||||
|
||||
private void TransactionUnavailable(object sender, EventArgs e)
|
||||
{
|
||||
if (Command.Transaction != null)
|
||||
{
|
||||
Command.Transaction = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckDispose()
|
||||
{
|
||||
if (disposed) throw new ObjectDisposedException(GetType().FullName);
|
||||
}
|
||||
|
||||
private ISqlDialect GetDialect()
|
||||
{
|
||||
return dialect ?? (dialect = DbRegistry.GetSqlDialect(DatabaseId));
|
||||
}
|
||||
|
||||
private void AdoProxyExecutedEventHandler(ExecutedEventArgs a)
|
||||
{
|
||||
logger.DebugWithProps(a.SqlMethod,
|
||||
new KeyValuePair<string, object>("duration", a.Duration.TotalMilliseconds),
|
||||
new KeyValuePair<string, object>("sql", RemoveWhiteSpaces(a.Sql)),
|
||||
new KeyValuePair<string, object>("sqlParams", RemoveWhiteSpaces(a.SqlParameters)),
|
||||
new KeyValuePair<string, object>("sqlThread", a.SqlThread)
|
||||
);
|
||||
}
|
||||
|
||||
private string RemoveWhiteSpaces(string str)
|
||||
{
|
||||
return !string.IsNullOrEmpty(str) ?
|
||||
str.Replace(Environment.NewLine, " ").Replace("\n", "").Replace("\r", "").Replace("\t", " ") :
|
||||
string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public class DbManagerProxy : IDbManager
|
||||
{
|
||||
private DbManager dbManager { get; set; }
|
||||
|
||||
public DbManagerProxy(DbManager dbManager)
|
||||
{
|
||||
this.dbManager = dbManager;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
dbManager.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public DbConnection Connection { get { return dbManager.Connection; } }
|
||||
public string DatabaseId { get { return dbManager.DatabaseId; } }
|
||||
public bool InTransaction { get { return dbManager.InTransaction; } }
|
||||
|
||||
public IDbTransaction BeginTransaction()
|
||||
{
|
||||
return dbManager.BeginTransaction();
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
|
||||
{
|
||||
return dbManager.BeginTransaction(isolationLevel);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen)
|
||||
{
|
||||
return dbManager.BeginTransaction(nestedIfAlreadyOpen);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(string sql, params object[] parameters)
|
||||
{
|
||||
return dbManager.ExecuteList(sql, parameters);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteList(sql);
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteListAsync(sql);
|
||||
}
|
||||
|
||||
public List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter)
|
||||
{
|
||||
return dbManager.ExecuteList<T>(sql, converter);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(string sql, params object[] parameters)
|
||||
{
|
||||
return dbManager.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteScalar<T>(sql);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string sql, params object[] parameters)
|
||||
{
|
||||
return dbManager.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(ISqlInstruction sql)
|
||||
{
|
||||
return dbManager.ExecuteNonQuery(sql);
|
||||
}
|
||||
|
||||
public int ExecuteBatch(IEnumerable<ISqlInstruction> batch)
|
||||
{
|
||||
return dbManager.ExecuteBatch(batch);
|
||||
}
|
||||
|
||||
public Task<int> ExecuteNonQueryAsync(string sql, params object[] parameters)
|
||||
{
|
||||
return dbManager.ExecuteNonQueryAsync(sql, parameters);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +1,56 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
class DbNestedTransaction : IDbTransaction
|
||||
{
|
||||
private readonly IDbTransaction transaction;
|
||||
|
||||
|
||||
public DbNestedTransaction(IDbTransaction transaction)
|
||||
{
|
||||
if (transaction == null) throw new ArgumentNullException("transaction");
|
||||
this.transaction = transaction;
|
||||
}
|
||||
|
||||
public IDbConnection Connection
|
||||
{
|
||||
get { return transaction.Connection; }
|
||||
}
|
||||
|
||||
public IsolationLevel IsolationLevel
|
||||
{
|
||||
get { return transaction.IsolationLevel; }
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
}
|
||||
|
||||
public void Rollback()
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
class DbNestedTransaction : IDbTransaction
|
||||
{
|
||||
private readonly IDbTransaction transaction;
|
||||
|
||||
|
||||
public DbNestedTransaction(IDbTransaction transaction)
|
||||
{
|
||||
if (transaction == null) throw new ArgumentNullException("transaction");
|
||||
this.transaction = transaction;
|
||||
}
|
||||
|
||||
public IDbConnection Connection
|
||||
{
|
||||
get { return transaction.Connection; }
|
||||
}
|
||||
|
||||
public IsolationLevel IsolationLevel
|
||||
{
|
||||
get { return transaction.IsolationLevel; }
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
}
|
||||
|
||||
public void Rollback()
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -1,184 +1,184 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
using ASC.Common.Data.Sql.Dialects;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public static class DbRegistry
|
||||
{
|
||||
private const string DEFAULT = "DEFAULT";
|
||||
private static readonly object syncRoot = new object();
|
||||
private static readonly IDictionary<string, DbProviderFactory> providers = new Dictionary<string, DbProviderFactory>(StringComparer.InvariantCultureIgnoreCase);
|
||||
private static readonly IDictionary<string, string> connnectionStrings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
private static readonly IDictionary<string, ISqlDialect> dialects = new Dictionary<string, ISqlDialect>(StringComparer.InvariantCultureIgnoreCase);
|
||||
private static volatile bool configured = false;
|
||||
|
||||
static DbRegistry()
|
||||
{
|
||||
dialects["MySql.Data.MySqlClient.MySqlClientFactory"] = new MySQLDialect();
|
||||
dialects["System.Data.SQLite.SQLiteFactory"] = new SQLiteDialect();
|
||||
}
|
||||
|
||||
internal static void RegisterDatabase(string databaseId, DbProviderFactory providerFactory, string connectionString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(databaseId)) throw new ArgumentNullException("databaseId");
|
||||
if (providerFactory == null) throw new ArgumentNullException("providerFactory");
|
||||
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
providers.Add(databaseId, providerFactory);
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
connnectionStrings.Add(databaseId, connectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void RegisterDatabase(string databaseId, string providerInvariantName, string connectionString)
|
||||
{
|
||||
RegisterDatabase(databaseId, DbProviderFactories.GetFactory(providerInvariantName), connectionString);
|
||||
}
|
||||
|
||||
public static void RegisterDatabase(string databaseId, ConnectionStringSettings connectionString)
|
||||
{
|
||||
RegisterDatabase(databaseId, connectionString.ProviderName, connectionString.ConnectionString);
|
||||
}
|
||||
|
||||
public static void UnRegisterDatabase(string databaseId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(databaseId)) throw new ArgumentNullException("databaseId");
|
||||
|
||||
if (providers.ContainsKey(databaseId))
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (providers.ContainsKey(databaseId))
|
||||
{
|
||||
providers.Remove(databaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
connnectionStrings.Remove(databaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDatabaseRegistered(string databaseId)
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
return providers.ContainsKey(databaseId);
|
||||
}
|
||||
}
|
||||
|
||||
public static DbConnection CreateDbConnection(string databaseId)
|
||||
{
|
||||
Configure();
|
||||
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
databaseId = DEFAULT;
|
||||
}
|
||||
|
||||
var connection = providers[databaseId].CreateConnection();
|
||||
if (connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
connection.ConnectionString = connnectionStrings[databaseId];
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static DbProviderFactory GetDbProviderFactory(string databaseId)
|
||||
{
|
||||
Configure();
|
||||
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
databaseId = DEFAULT;
|
||||
}
|
||||
return providers.ContainsKey(databaseId) ? providers[databaseId] : null;
|
||||
}
|
||||
|
||||
public static ConnectionStringSettings GetConnectionString(string databaseId)
|
||||
{
|
||||
Configure();
|
||||
|
||||
if (!connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
databaseId = DEFAULT;
|
||||
}
|
||||
return connnectionStrings.ContainsKey(databaseId) ? new ConnectionStringSettings(databaseId, connnectionStrings[databaseId], providers[databaseId].GetType().Name) : null;
|
||||
}
|
||||
|
||||
public static ISqlDialect GetSqlDialect(string databaseId)
|
||||
{
|
||||
var provider = GetDbProviderFactory(databaseId);
|
||||
if (provider != null && dialects.ContainsKey(provider.GetType().FullName))
|
||||
{
|
||||
return dialects[provider.GetType().FullName];
|
||||
}
|
||||
return SqlDialect.Default;
|
||||
}
|
||||
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
if (!configured)
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (!configured)
|
||||
{
|
||||
var factories = DbProviderFactories.GetFactoryClasses();
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", Environment.CurrentDirectory); //SQLite
|
||||
foreach (ConnectionStringSettings cs in ConfigurationManagerExtension.ConnectionStrings)
|
||||
{
|
||||
var factory = factories.Rows.Find(cs.ProviderName);
|
||||
if (factory == null)
|
||||
{
|
||||
throw new ConfigurationErrorsException("Db factory " + cs.ProviderName + " not found.");
|
||||
}
|
||||
RegisterDatabase(cs.Name, cs);
|
||||
}
|
||||
configured = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
using ASC.Common.Data.Sql.Dialects;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public static class DbRegistry
|
||||
{
|
||||
private const string DEFAULT = "DEFAULT";
|
||||
private static readonly object syncRoot = new object();
|
||||
private static readonly IDictionary<string, DbProviderFactory> providers = new Dictionary<string, DbProviderFactory>(StringComparer.InvariantCultureIgnoreCase);
|
||||
private static readonly IDictionary<string, string> connnectionStrings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
private static readonly IDictionary<string, ISqlDialect> dialects = new Dictionary<string, ISqlDialect>(StringComparer.InvariantCultureIgnoreCase);
|
||||
private static volatile bool configured = false;
|
||||
|
||||
static DbRegistry()
|
||||
{
|
||||
dialects["MySql.Data.MySqlClient.MySqlClientFactory"] = new MySQLDialect();
|
||||
dialects["System.Data.SQLite.SQLiteFactory"] = new SQLiteDialect();
|
||||
}
|
||||
|
||||
internal static void RegisterDatabase(string databaseId, DbProviderFactory providerFactory, string connectionString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(databaseId)) throw new ArgumentNullException("databaseId");
|
||||
if (providerFactory == null) throw new ArgumentNullException("providerFactory");
|
||||
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
providers.Add(databaseId, providerFactory);
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
connnectionStrings.Add(databaseId, connectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void RegisterDatabase(string databaseId, string providerInvariantName, string connectionString)
|
||||
{
|
||||
RegisterDatabase(databaseId, DbProviderFactories.GetFactory(providerInvariantName), connectionString);
|
||||
}
|
||||
|
||||
public static void RegisterDatabase(string databaseId, ConnectionStringSettings connectionString)
|
||||
{
|
||||
RegisterDatabase(databaseId, connectionString.ProviderName, connectionString.ConnectionString);
|
||||
}
|
||||
|
||||
public static void UnRegisterDatabase(string databaseId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(databaseId)) throw new ArgumentNullException("databaseId");
|
||||
|
||||
if (providers.ContainsKey(databaseId))
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (providers.ContainsKey(databaseId))
|
||||
{
|
||||
providers.Remove(databaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
connnectionStrings.Remove(databaseId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDatabaseRegistered(string databaseId)
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
return providers.ContainsKey(databaseId);
|
||||
}
|
||||
}
|
||||
|
||||
public static DbConnection CreateDbConnection(string databaseId)
|
||||
{
|
||||
Configure();
|
||||
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
databaseId = DEFAULT;
|
||||
}
|
||||
|
||||
var connection = providers[databaseId].CreateConnection();
|
||||
if (connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
connection.ConnectionString = connnectionStrings[databaseId];
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static DbProviderFactory GetDbProviderFactory(string databaseId)
|
||||
{
|
||||
Configure();
|
||||
|
||||
if (!providers.ContainsKey(databaseId))
|
||||
{
|
||||
databaseId = DEFAULT;
|
||||
}
|
||||
return providers.ContainsKey(databaseId) ? providers[databaseId] : null;
|
||||
}
|
||||
|
||||
public static ConnectionStringSettings GetConnectionString(string databaseId)
|
||||
{
|
||||
Configure();
|
||||
|
||||
if (!connnectionStrings.ContainsKey(databaseId))
|
||||
{
|
||||
databaseId = DEFAULT;
|
||||
}
|
||||
return connnectionStrings.ContainsKey(databaseId) ? new ConnectionStringSettings(databaseId, connnectionStrings[databaseId], providers[databaseId].GetType().Name) : null;
|
||||
}
|
||||
|
||||
public static ISqlDialect GetSqlDialect(string databaseId)
|
||||
{
|
||||
var provider = GetDbProviderFactory(databaseId);
|
||||
if (provider != null && dialects.ContainsKey(provider.GetType().FullName))
|
||||
{
|
||||
return dialects[provider.GetType().FullName];
|
||||
}
|
||||
return SqlDialect.Default;
|
||||
}
|
||||
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
if (!configured)
|
||||
{
|
||||
lock (syncRoot)
|
||||
{
|
||||
if (!configured)
|
||||
{
|
||||
var factories = DbProviderFactories.GetFactoryClasses();
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", Environment.CurrentDirectory); //SQLite
|
||||
foreach (ConnectionStringSettings cs in ConfigurationManagerExtension.ConnectionStrings)
|
||||
{
|
||||
var factory = factories.Rows.Find(cs.ProviderName);
|
||||
if (factory == null)
|
||||
{
|
||||
throw new ConfigurationErrorsException("Db factory " + cs.ProviderName + " not found.");
|
||||
}
|
||||
RegisterDatabase(cs.Name, cs);
|
||||
}
|
||||
configured = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,100 +1,100 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public class DbTransaction : IDbTransaction
|
||||
{
|
||||
public DbTransaction(IDbTransaction transaction)
|
||||
{
|
||||
if (transaction == null) throw new ArgumentNullException("transaction");
|
||||
Transaction = transaction;
|
||||
}
|
||||
|
||||
internal IDbTransaction Transaction { get; private set; }
|
||||
|
||||
#region IDbTransaction Members
|
||||
|
||||
public IDbConnection Connection
|
||||
{
|
||||
get { return Transaction.Connection; }
|
||||
}
|
||||
|
||||
public IsolationLevel IsolationLevel
|
||||
{
|
||||
get { return Transaction.IsolationLevel; }
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction.Commit();
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
public void Rollback()
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction.Rollback();
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction.Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event EventHandler Unavailable;
|
||||
|
||||
private void OnUnavailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Unavailable != null) Unavailable(this, EventArgs.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public class DbTransaction : IDbTransaction
|
||||
{
|
||||
public DbTransaction(IDbTransaction transaction)
|
||||
{
|
||||
if (transaction == null) throw new ArgumentNullException("transaction");
|
||||
Transaction = transaction;
|
||||
}
|
||||
|
||||
internal IDbTransaction Transaction { get; private set; }
|
||||
|
||||
#region IDbTransaction Members
|
||||
|
||||
public IDbConnection Connection
|
||||
{
|
||||
get { return Transaction.Connection; }
|
||||
}
|
||||
|
||||
public IsolationLevel IsolationLevel
|
||||
{
|
||||
get { return Transaction.IsolationLevel; }
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction.Commit();
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
public void Rollback()
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction.Rollback();
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction.Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event EventHandler Unavailable;
|
||||
|
||||
private void OnUnavailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Unavailable != null) Unavailable(this, EventArgs.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +1,60 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public interface IDbManager : IDisposable
|
||||
{
|
||||
DbConnection Connection { get; }
|
||||
string DatabaseId { get; }
|
||||
bool InTransaction { get; }
|
||||
|
||||
IDbTransaction BeginTransaction();
|
||||
|
||||
IDbTransaction BeginTransaction(IsolationLevel isolationLevel);
|
||||
|
||||
IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen);
|
||||
|
||||
List<object[]> ExecuteList(string sql, params object[] parameters);
|
||||
|
||||
List<object[]> ExecuteList(ISqlInstruction sql);
|
||||
|
||||
Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql);
|
||||
|
||||
List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter);
|
||||
|
||||
T ExecuteScalar<T>(string sql, params object[] parameters);
|
||||
|
||||
T ExecuteScalar<T>(ISqlInstruction sql);
|
||||
|
||||
int ExecuteNonQuery(string sql, params object[] parameters);
|
||||
|
||||
int ExecuteNonQuery(ISqlInstruction sql);
|
||||
|
||||
int ExecuteBatch(IEnumerable<ISqlInstruction> batch);
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public interface IDbManager : IDisposable
|
||||
{
|
||||
DbConnection Connection { get; }
|
||||
string DatabaseId { get; }
|
||||
bool InTransaction { get; }
|
||||
|
||||
IDbTransaction BeginTransaction();
|
||||
|
||||
IDbTransaction BeginTransaction(IsolationLevel isolationLevel);
|
||||
|
||||
IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen);
|
||||
|
||||
List<object[]> ExecuteList(string sql, params object[] parameters);
|
||||
|
||||
List<object[]> ExecuteList(ISqlInstruction sql);
|
||||
|
||||
Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql);
|
||||
|
||||
List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter);
|
||||
|
||||
T ExecuteScalar<T>(string sql, params object[] parameters);
|
||||
|
||||
T ExecuteScalar<T>(ISqlInstruction sql);
|
||||
|
||||
int ExecuteNonQuery(string sql, params object[] parameters);
|
||||
|
||||
Task<int> ExecuteNonQueryAsync(string sql, params object[] parameters);
|
||||
|
||||
int ExecuteNonQuery(ISqlInstruction sql);
|
||||
|
||||
int ExecuteBatch(IEnumerable<ISqlInstruction> batch);
|
||||
}
|
||||
}
|
@ -1,171 +1,171 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public class MultiRegionalDbManager : IDbManager
|
||||
{
|
||||
private readonly List<IDbManager> databases;
|
||||
|
||||
private readonly IDbManager localDb;
|
||||
|
||||
private volatile bool disposed;
|
||||
|
||||
|
||||
public string DatabaseId { get; private set; }
|
||||
public bool InTransaction { get { return localDb.InTransaction; } }
|
||||
|
||||
public DbConnection Connection
|
||||
{
|
||||
get { return localDb.Connection; }
|
||||
}
|
||||
|
||||
|
||||
public MultiRegionalDbManager(string dbId)
|
||||
{
|
||||
const StringComparison cmp = StringComparison.InvariantCultureIgnoreCase;
|
||||
DatabaseId = dbId;
|
||||
databases = ConfigurationManager.ConnectionStrings.OfType<ConnectionStringSettings>()
|
||||
.Where(c => c.Name.Equals(dbId, cmp) || c.Name.StartsWith(dbId + ".", cmp))
|
||||
.Select(
|
||||
c =>
|
||||
HttpContext.Current != null
|
||||
? DbManager.FromHttpContext(c.Name)
|
||||
: new DbManager(c.Name))
|
||||
.ToList();
|
||||
localDb = databases.SingleOrDefault(db => db.DatabaseId.Equals(dbId, cmp));
|
||||
}
|
||||
|
||||
public MultiRegionalDbManager(IEnumerable<IDbManager> databases)
|
||||
{
|
||||
this.databases = databases.ToList();
|
||||
localDb = databases.FirstOrDefault();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
databases.ForEach(db => db.Dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public static MultiRegionalDbManager FromHttpContext(string databaseId)
|
||||
{
|
||||
return new MultiRegionalDbManager(databaseId);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
|
||||
{
|
||||
return localDb.BeginTransaction(isolationLevel);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen)
|
||||
{
|
||||
return localDb.BeginTransaction(nestedIfAlreadyOpen);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(string sql, params object[] parameters)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql, parameters)).ToList();
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(ISqlInstruction sql)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql)).ToList();
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql)
|
||||
{
|
||||
throw new NotImplementedException(); //TODO: implement
|
||||
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteListWithRegion(ISqlInstruction sql)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql)
|
||||
.Select(oldArray =>
|
||||
{
|
||||
var newArray = new object[oldArray.Count() + 1];
|
||||
oldArray.CopyTo(newArray, 0);
|
||||
newArray[oldArray.Count()] =
|
||||
db.DatabaseId.IndexOf('.') > -1
|
||||
? db.DatabaseId.Substring(db.DatabaseId.IndexOf('.') + 1)
|
||||
: "";
|
||||
|
||||
return newArray;
|
||||
})).ToList();
|
||||
}
|
||||
|
||||
public List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql, converter)).ToList();
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(string sql, params object[] parameters)
|
||||
{
|
||||
return localDb.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(ISqlInstruction sql)
|
||||
{
|
||||
return localDb.ExecuteScalar<T>(sql);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string sql, params object[] parameters)
|
||||
{
|
||||
return localDb.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(ISqlInstruction sql)
|
||||
{
|
||||
return localDb.ExecuteNonQuery(sql);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string region, ISqlInstruction sql)
|
||||
{
|
||||
var db = string.IsNullOrEmpty(region)
|
||||
? localDb
|
||||
: databases.FirstOrDefault(x => x.DatabaseId.EndsWith(region));
|
||||
if (db != null) return db.ExecuteNonQuery(sql);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int ExecuteBatch(IEnumerable<ISqlInstruction> batch)
|
||||
{
|
||||
return localDb.ExecuteBatch(batch);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction()
|
||||
{
|
||||
return localDb.BeginTransaction();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common.Data.Sql;
|
||||
|
||||
namespace ASC.Common.Data
|
||||
{
|
||||
public class MultiRegionalDbManager : IDbManager
|
||||
{
|
||||
private readonly List<IDbManager> databases;
|
||||
|
||||
private readonly IDbManager localDb;
|
||||
|
||||
private volatile bool disposed;
|
||||
|
||||
|
||||
public string DatabaseId { get; private set; }
|
||||
public bool InTransaction { get { return localDb.InTransaction; } }
|
||||
|
||||
public DbConnection Connection
|
||||
{
|
||||
get { return localDb.Connection; }
|
||||
}
|
||||
|
||||
|
||||
public MultiRegionalDbManager(string dbId)
|
||||
{
|
||||
const StringComparison cmp = StringComparison.InvariantCultureIgnoreCase;
|
||||
DatabaseId = dbId;
|
||||
databases = ConfigurationManager.ConnectionStrings.OfType<ConnectionStringSettings>()
|
||||
.Where(c => c.Name.Equals(dbId, cmp) || c.Name.StartsWith(dbId + ".", cmp))
|
||||
.Select(c => DbManager.FromHttpContext(c.Name))
|
||||
.ToList();
|
||||
localDb = databases.SingleOrDefault(db => db.DatabaseId.Equals(dbId, cmp));
|
||||
}
|
||||
|
||||
public MultiRegionalDbManager(IEnumerable<IDbManager> databases)
|
||||
{
|
||||
this.databases = databases.ToList();
|
||||
localDb = databases.FirstOrDefault();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
databases.ForEach(db => db.Dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public static MultiRegionalDbManager FromHttpContext(string databaseId)
|
||||
{
|
||||
return new MultiRegionalDbManager(databaseId);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
|
||||
{
|
||||
return localDb.BeginTransaction(isolationLevel);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction(bool nestedIfAlreadyOpen)
|
||||
{
|
||||
return localDb.BeginTransaction(nestedIfAlreadyOpen);
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(string sql, params object[] parameters)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql, parameters)).ToList();
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteList(ISqlInstruction sql)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql)).ToList();
|
||||
}
|
||||
|
||||
public Task<List<object[]>> ExecuteListAsync(ISqlInstruction sql)
|
||||
{
|
||||
throw new NotImplementedException(); //TODO: implement
|
||||
|
||||
}
|
||||
|
||||
public List<object[]> ExecuteListWithRegion(ISqlInstruction sql)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql)
|
||||
.Select(oldArray =>
|
||||
{
|
||||
var newArray = new object[oldArray.Count() + 1];
|
||||
oldArray.CopyTo(newArray, 0);
|
||||
newArray[oldArray.Count()] =
|
||||
db.DatabaseId.IndexOf('.') > -1
|
||||
? db.DatabaseId.Substring(db.DatabaseId.IndexOf('.') + 1)
|
||||
: "";
|
||||
|
||||
return newArray;
|
||||
})).ToList();
|
||||
}
|
||||
|
||||
public List<T> ExecuteList<T>(ISqlInstruction sql, Converter<IDataRecord, T> converter)
|
||||
{
|
||||
return databases.SelectMany(db => db.ExecuteList(sql, converter)).ToList();
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(string sql, params object[] parameters)
|
||||
{
|
||||
return localDb.ExecuteScalar<T>(sql, parameters);
|
||||
}
|
||||
|
||||
public T ExecuteScalar<T>(ISqlInstruction sql)
|
||||
{
|
||||
return localDb.ExecuteScalar<T>(sql);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string sql, params object[] parameters)
|
||||
{
|
||||
return localDb.ExecuteNonQuery(sql, parameters);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(ISqlInstruction sql)
|
||||
{
|
||||
return localDb.ExecuteNonQuery(sql);
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery(string region, ISqlInstruction sql)
|
||||
{
|
||||
var db = string.IsNullOrEmpty(region)
|
||||
? localDb
|
||||
: databases.FirstOrDefault(x => x.DatabaseId.EndsWith(region));
|
||||
if (db != null) return db.ExecuteNonQuery(sql);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int ExecuteBatch(IEnumerable<ISqlInstruction> batch)
|
||||
{
|
||||
return localDb.ExecuteBatch(batch);
|
||||
}
|
||||
|
||||
public IDbTransaction BeginTransaction()
|
||||
{
|
||||
return localDb.BeginTransaction();
|
||||
}
|
||||
|
||||
public Task<int> ExecuteNonQueryAsync(string sql, params object[] parameters)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +1,129 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Dialects
|
||||
{
|
||||
class MySQLDialect : ISqlDialect
|
||||
{
|
||||
public string IdentityQuery
|
||||
{
|
||||
get { return "last_insert_id()"; }
|
||||
}
|
||||
|
||||
public string Autoincrement
|
||||
{
|
||||
get { return "auto_increment"; }
|
||||
}
|
||||
|
||||
public virtual string InsertIgnore
|
||||
{
|
||||
get { return "insert ignore"; }
|
||||
}
|
||||
|
||||
public bool SupportMultiTableUpdate
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool SeparateCreateIndex
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public string DbTypeToString(DbType type, int size, int precision)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DbType.Guid:
|
||||
return "char(38)";
|
||||
|
||||
case DbType.AnsiString:
|
||||
case DbType.String:
|
||||
if (size <= 8192) return string.Format("VARCHAR({0})", size);
|
||||
else if (size <= UInt16.MaxValue) return "TEXT";
|
||||
else if (size <= ((int)Math.Pow(2, 24) - 1)) return "MEDIUMTEXT";
|
||||
else return "LONGTEXT";
|
||||
|
||||
case DbType.AnsiStringFixedLength:
|
||||
case DbType.StringFixedLength:
|
||||
return string.Format("CHAR({0})", size);
|
||||
|
||||
case DbType.Xml:
|
||||
return "MEDIUMTEXT";
|
||||
|
||||
case DbType.Binary:
|
||||
case DbType.Object:
|
||||
if (size <= 8192) return string.Format("BINARY({0})", size);
|
||||
else if (size <= UInt16.MaxValue) return "BLOB";
|
||||
else if (size <= ((int)Math.Pow(2, 24) - 1)) return "MEDIUMBLOB";
|
||||
else return "LONGBLOB";
|
||||
|
||||
case DbType.Boolean:
|
||||
case DbType.Byte:
|
||||
return "TINYINY";
|
||||
case DbType.SByte:
|
||||
return "TINYINY UNSIGNED";
|
||||
|
||||
case DbType.Int16:
|
||||
return "SMALLINT";
|
||||
case DbType.UInt16:
|
||||
return "SMALLINT UNSIGNED";
|
||||
|
||||
case DbType.Int32:
|
||||
return "INT";
|
||||
case DbType.UInt32:
|
||||
return "INT UNSIGNED";
|
||||
|
||||
case DbType.Int64:
|
||||
return "BIGINT";
|
||||
case DbType.UInt64:
|
||||
return "BIGINT UNSIGNED";
|
||||
|
||||
case DbType.Date:
|
||||
return "DATE";
|
||||
case DbType.DateTime:
|
||||
case DbType.DateTime2:
|
||||
return "DATETIME";
|
||||
case DbType.Time:
|
||||
return "TIME";
|
||||
|
||||
case DbType.Decimal:
|
||||
return string.Format("DECIMAL({0},{1})", size, precision);
|
||||
case DbType.Double:
|
||||
return "DOUBLE";
|
||||
case DbType.Single:
|
||||
return "FLOAT";
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(type.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public IsolationLevel GetSupportedIsolationLevel(IsolationLevel il)
|
||||
{
|
||||
return il;
|
||||
}
|
||||
|
||||
public string UseIndex(string index)
|
||||
{
|
||||
return string.Format("use index ({0})", index);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Dialects
|
||||
{
|
||||
class MySQLDialect : ISqlDialect
|
||||
{
|
||||
public string IdentityQuery
|
||||
{
|
||||
get { return "last_insert_id()"; }
|
||||
}
|
||||
|
||||
public string Autoincrement
|
||||
{
|
||||
get { return "auto_increment"; }
|
||||
}
|
||||
|
||||
public virtual string InsertIgnore
|
||||
{
|
||||
get { return "insert ignore"; }
|
||||
}
|
||||
|
||||
public bool SupportMultiTableUpdate
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool SeparateCreateIndex
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public string DbTypeToString(DbType type, int size, int precision)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DbType.Guid:
|
||||
return "char(38)";
|
||||
|
||||
case DbType.AnsiString:
|
||||
case DbType.String:
|
||||
if (size <= 8192) return string.Format("VARCHAR({0})", size);
|
||||
else if (size <= UInt16.MaxValue) return "TEXT";
|
||||
else if (size <= ((int)Math.Pow(2, 24) - 1)) return "MEDIUMTEXT";
|
||||
else return "LONGTEXT";
|
||||
|
||||
case DbType.AnsiStringFixedLength:
|
||||
case DbType.StringFixedLength:
|
||||
return string.Format("CHAR({0})", size);
|
||||
|
||||
case DbType.Xml:
|
||||
return "MEDIUMTEXT";
|
||||
|
||||
case DbType.Binary:
|
||||
case DbType.Object:
|
||||
if (size <= 8192) return string.Format("BINARY({0})", size);
|
||||
else if (size <= UInt16.MaxValue) return "BLOB";
|
||||
else if (size <= ((int)Math.Pow(2, 24) - 1)) return "MEDIUMBLOB";
|
||||
else return "LONGBLOB";
|
||||
|
||||
case DbType.Boolean:
|
||||
case DbType.Byte:
|
||||
return "TINYINY";
|
||||
case DbType.SByte:
|
||||
return "TINYINY UNSIGNED";
|
||||
|
||||
case DbType.Int16:
|
||||
return "SMALLINT";
|
||||
case DbType.UInt16:
|
||||
return "SMALLINT UNSIGNED";
|
||||
|
||||
case DbType.Int32:
|
||||
return "INT";
|
||||
case DbType.UInt32:
|
||||
return "INT UNSIGNED";
|
||||
|
||||
case DbType.Int64:
|
||||
return "BIGINT";
|
||||
case DbType.UInt64:
|
||||
return "BIGINT UNSIGNED";
|
||||
|
||||
case DbType.Date:
|
||||
return "DATE";
|
||||
case DbType.DateTime:
|
||||
case DbType.DateTime2:
|
||||
return "DATETIME";
|
||||
case DbType.Time:
|
||||
return "TIME";
|
||||
|
||||
case DbType.Decimal:
|
||||
return string.Format("DECIMAL({0},{1})", size, precision);
|
||||
case DbType.Double:
|
||||
return "DOUBLE";
|
||||
case DbType.Single:
|
||||
return "FLOAT";
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(type.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public IsolationLevel GetSupportedIsolationLevel(IsolationLevel il)
|
||||
{
|
||||
return il;
|
||||
}
|
||||
|
||||
public string UseIndex(string index)
|
||||
{
|
||||
return string.Format("use index ({0})", index);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,108 +1,108 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public class SQLiteDialect : ISqlDialect
|
||||
{
|
||||
public string IdentityQuery
|
||||
{
|
||||
get { return "last_insert_rowid()"; }
|
||||
}
|
||||
|
||||
public string Autoincrement
|
||||
{
|
||||
get { return "autoincrement"; }
|
||||
}
|
||||
|
||||
public virtual string InsertIgnore
|
||||
{
|
||||
get { return "insert or ignore"; }
|
||||
}
|
||||
|
||||
public bool SupportMultiTableUpdate
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool SeparateCreateIndex
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
|
||||
public string DbTypeToString(DbType type, int size, int precision)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DbType.AnsiString:
|
||||
case DbType.AnsiStringFixedLength:
|
||||
case DbType.String:
|
||||
case DbType.StringFixedLength:
|
||||
case DbType.Xml:
|
||||
case DbType.Guid:
|
||||
return "TEXT";
|
||||
|
||||
case DbType.Binary:
|
||||
case DbType.Object:
|
||||
return "BLOB";
|
||||
|
||||
case DbType.Boolean:
|
||||
case DbType.Currency:
|
||||
case DbType.Decimal:
|
||||
case DbType.VarNumeric:
|
||||
return "NUMERIC";
|
||||
|
||||
case DbType.Date:
|
||||
case DbType.DateTime:
|
||||
case DbType.DateTime2:
|
||||
case DbType.DateTimeOffset:
|
||||
case DbType.Time:
|
||||
return "DATETIME";
|
||||
|
||||
case DbType.Byte:
|
||||
case DbType.Int16:
|
||||
case DbType.Int32:
|
||||
case DbType.Int64:
|
||||
case DbType.SByte:
|
||||
case DbType.UInt16:
|
||||
case DbType.UInt32:
|
||||
case DbType.UInt64:
|
||||
return "INTEGER";
|
||||
|
||||
case DbType.Double:
|
||||
case DbType.Single:
|
||||
return "REAL";
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(type.ToString());
|
||||
}
|
||||
|
||||
public IsolationLevel GetSupportedIsolationLevel(IsolationLevel il)
|
||||
{
|
||||
if (il <= IsolationLevel.ReadCommitted) return IsolationLevel.ReadCommitted;
|
||||
return IsolationLevel.Serializable;
|
||||
}
|
||||
|
||||
public string UseIndex(string index)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public class SQLiteDialect : ISqlDialect
|
||||
{
|
||||
public string IdentityQuery
|
||||
{
|
||||
get { return "last_insert_rowid()"; }
|
||||
}
|
||||
|
||||
public string Autoincrement
|
||||
{
|
||||
get { return "autoincrement"; }
|
||||
}
|
||||
|
||||
public virtual string InsertIgnore
|
||||
{
|
||||
get { return "insert or ignore"; }
|
||||
}
|
||||
|
||||
public bool SupportMultiTableUpdate
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool SeparateCreateIndex
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
|
||||
public string DbTypeToString(DbType type, int size, int precision)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DbType.AnsiString:
|
||||
case DbType.AnsiStringFixedLength:
|
||||
case DbType.String:
|
||||
case DbType.StringFixedLength:
|
||||
case DbType.Xml:
|
||||
case DbType.Guid:
|
||||
return "TEXT";
|
||||
|
||||
case DbType.Binary:
|
||||
case DbType.Object:
|
||||
return "BLOB";
|
||||
|
||||
case DbType.Boolean:
|
||||
case DbType.Currency:
|
||||
case DbType.Decimal:
|
||||
case DbType.VarNumeric:
|
||||
return "NUMERIC";
|
||||
|
||||
case DbType.Date:
|
||||
case DbType.DateTime:
|
||||
case DbType.DateTime2:
|
||||
case DbType.DateTimeOffset:
|
||||
case DbType.Time:
|
||||
return "DATETIME";
|
||||
|
||||
case DbType.Byte:
|
||||
case DbType.Int16:
|
||||
case DbType.Int32:
|
||||
case DbType.Int64:
|
||||
case DbType.SByte:
|
||||
case DbType.UInt16:
|
||||
case DbType.UInt32:
|
||||
case DbType.UInt64:
|
||||
return "INTEGER";
|
||||
|
||||
case DbType.Double:
|
||||
case DbType.Single:
|
||||
return "REAL";
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(type.ToString());
|
||||
}
|
||||
|
||||
public IsolationLevel GetSupportedIsolationLevel(IsolationLevel il)
|
||||
{
|
||||
if (il <= IsolationLevel.ReadCommitted) return IsolationLevel.ReadCommitted;
|
||||
return IsolationLevel.Serializable;
|
||||
}
|
||||
|
||||
public string UseIndex(string index)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,75 +1,75 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public class SqlDialect : ISqlDialect
|
||||
{
|
||||
public static readonly ISqlDialect Default = new SqlDialect();
|
||||
|
||||
|
||||
public virtual string IdentityQuery
|
||||
{
|
||||
get { return "@@identity"; }
|
||||
}
|
||||
|
||||
public virtual string Autoincrement
|
||||
{
|
||||
get { return "AUTOINCREMENT"; }
|
||||
}
|
||||
|
||||
public virtual string InsertIgnore
|
||||
{
|
||||
get { return "insert ignore"; }
|
||||
}
|
||||
|
||||
|
||||
public virtual bool SupportMultiTableUpdate
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public virtual bool SeparateCreateIndex
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
|
||||
public virtual string DbTypeToString(DbType type, int size, int precision)
|
||||
{
|
||||
var s = new StringBuilder(type.ToString().ToLower());
|
||||
if (0 < size)
|
||||
{
|
||||
s.AppendFormat(0 < precision ? "({0}, {1})" : "({0})", size, precision);
|
||||
}
|
||||
return s.ToString();
|
||||
}
|
||||
|
||||
public virtual IsolationLevel GetSupportedIsolationLevel(IsolationLevel il)
|
||||
{
|
||||
return il;
|
||||
}
|
||||
|
||||
public string UseIndex(string index)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public class SqlDialect : ISqlDialect
|
||||
{
|
||||
public static readonly ISqlDialect Default = new SqlDialect();
|
||||
|
||||
|
||||
public virtual string IdentityQuery
|
||||
{
|
||||
get { return "@@identity"; }
|
||||
}
|
||||
|
||||
public virtual string Autoincrement
|
||||
{
|
||||
get { return "AUTOINCREMENT"; }
|
||||
}
|
||||
|
||||
public virtual string InsertIgnore
|
||||
{
|
||||
get { return "insert ignore"; }
|
||||
}
|
||||
|
||||
|
||||
public virtual bool SupportMultiTableUpdate
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public virtual bool SeparateCreateIndex
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
|
||||
public virtual string DbTypeToString(DbType type, int size, int precision)
|
||||
{
|
||||
var s = new StringBuilder(type.ToString().ToLower());
|
||||
if (0 < size)
|
||||
{
|
||||
s.AppendFormat(0 < precision ? "({0}, {1})" : "({0})", size, precision);
|
||||
}
|
||||
return s.ToString();
|
||||
}
|
||||
|
||||
public virtual IsolationLevel GetSupportedIsolationLevel(IsolationLevel il)
|
||||
{
|
||||
return il;
|
||||
}
|
||||
|
||||
public string UseIndex(string index)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +1,49 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class AsExp : Exp
|
||||
{
|
||||
private readonly string alias;
|
||||
private readonly SqlQuery subQuery;
|
||||
|
||||
public AsExp(SqlQuery subQuery)
|
||||
: this(subQuery, null)
|
||||
{
|
||||
}
|
||||
|
||||
public AsExp(SqlQuery subQuery, string alias)
|
||||
{
|
||||
this.subQuery = subQuery;
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("({0}){1}", subQuery.ToString(dialect),
|
||||
string.IsNullOrEmpty(alias) ? string.Empty : " as " + alias);
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return subQuery.GetParameters();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class AsExp : Exp
|
||||
{
|
||||
private readonly string alias;
|
||||
private readonly SqlQuery subQuery;
|
||||
|
||||
public AsExp(SqlQuery subQuery)
|
||||
: this(subQuery, null)
|
||||
{
|
||||
}
|
||||
|
||||
public AsExp(SqlQuery subQuery, string alias)
|
||||
{
|
||||
this.subQuery = subQuery;
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("({0}){1}", subQuery.ToString(dialect),
|
||||
string.IsNullOrEmpty(alias) ? string.Empty : " as " + alias);
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return subQuery.GetParameters();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +1,45 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class BetweenExp : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly object maxValue;
|
||||
private readonly object minValue;
|
||||
|
||||
public BetweenExp(string column, object minValue, object maxValue)
|
||||
{
|
||||
this.column = column;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0} {1}between ? and ?", column, Not ? "not " : string.Empty);
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return new[] { minValue, maxValue };
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class BetweenExp : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly object maxValue;
|
||||
private readonly object minValue;
|
||||
|
||||
public BetweenExp(string column, object minValue, object maxValue)
|
||||
{
|
||||
this.column = column;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0} {1}between ? and ?", column, Not ? "not " : string.Empty);
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return new[] { minValue, maxValue };
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +1,52 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class EqColumnsExp : Exp
|
||||
{
|
||||
private readonly ISqlInstruction column1;
|
||||
private readonly ISqlInstruction column2;
|
||||
|
||||
public EqColumnsExp(string column1, string column2)
|
||||
{
|
||||
this.column1 = (SqlIdentifier)column1;
|
||||
this.column2 = (SqlIdentifier)column2;
|
||||
}
|
||||
|
||||
public EqColumnsExp(string column1, SqlQuery query)
|
||||
{
|
||||
this.column1 = (SqlIdentifier)column1;
|
||||
column2 = new AsExp(query);
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0} {1} {2}",
|
||||
column1.ToString(dialect),
|
||||
Not ? "<>" : "=",
|
||||
column2.ToString(dialect));
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return column2.GetParameters();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class EqColumnsExp : Exp
|
||||
{
|
||||
private readonly ISqlInstruction column1;
|
||||
private readonly ISqlInstruction column2;
|
||||
|
||||
public EqColumnsExp(string column1, string column2)
|
||||
{
|
||||
this.column1 = (SqlIdentifier)column1;
|
||||
this.column2 = (SqlIdentifier)column2;
|
||||
}
|
||||
|
||||
public EqColumnsExp(string column1, SqlQuery query)
|
||||
{
|
||||
this.column1 = (SqlIdentifier)column1;
|
||||
column2 = new AsExp(query);
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0} {1} {2}",
|
||||
column1.ToString(dialect),
|
||||
Not ? "<>" : "=",
|
||||
column2.ToString(dialect));
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return column2.GetParameters();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +1,45 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class EqExp : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly object value;
|
||||
|
||||
public EqExp(string column, object value)
|
||||
{
|
||||
this.column = column;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0} {1}",
|
||||
column,
|
||||
value != null ? (Not ? "<> ?" : "= ?") : (Not ? "is not null" : "is null"));
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return value == null ? new object[0] : new[] { value };
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class EqExp : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly object value;
|
||||
|
||||
public EqExp(string column, object value)
|
||||
{
|
||||
this.column = column;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0} {1}",
|
||||
column,
|
||||
value != null ? (Not ? "<> ?" : "= ?") : (Not ? "is not null" : "is null"));
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return value == null ? new object[0] : new[] { value };
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class ExistsExp : Exp
|
||||
{
|
||||
private readonly SqlQuery query;
|
||||
|
||||
|
||||
public ExistsExp(SqlQuery query)
|
||||
{
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0}exists({1})", Not ? "not " : string.Empty, query.ToString(dialect));
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return query != null ? query.GetParameters() : new object[0];
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class ExistsExp : Exp
|
||||
{
|
||||
private readonly SqlQuery query;
|
||||
|
||||
|
||||
public ExistsExp(SqlQuery query)
|
||||
{
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0}exists({1})", Not ? "not " : string.Empty, query.ToString(dialect));
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return query != null ? query.GetParameters() : new object[0];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,174 +1,171 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public abstract class Exp : ISqlInstruction
|
||||
{
|
||||
public static readonly Exp Empty;
|
||||
|
||||
public static Exp True
|
||||
{
|
||||
get { return new EqColumnsExp("1", "1"); }
|
||||
}
|
||||
|
||||
public static Exp False
|
||||
{
|
||||
get { return new EqColumnsExp("1", "0"); }
|
||||
}
|
||||
|
||||
|
||||
protected bool Not { get; private set; }
|
||||
|
||||
|
||||
public abstract string ToString(ISqlDialect dialect);
|
||||
|
||||
public virtual object[] GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
|
||||
public static Exp Eq(string column, object value)
|
||||
{
|
||||
return new EqExp(column, value);
|
||||
}
|
||||
|
||||
public static Exp EqColumns(string column1, string column2)
|
||||
{
|
||||
return new EqColumnsExp(column1, column2);
|
||||
}
|
||||
|
||||
public static Exp EqColumns(string column1, SqlQuery query)
|
||||
{
|
||||
return new EqColumnsExp(column1, query);
|
||||
}
|
||||
|
||||
public static Exp And(Exp exp1, Exp exp2)
|
||||
{
|
||||
return Junction(exp1, exp2, true);
|
||||
}
|
||||
|
||||
public static Exp Or(Exp exp1, Exp exp2)
|
||||
{
|
||||
return Junction(exp1, exp2, false);
|
||||
}
|
||||
|
||||
private static Exp Junction(Exp exp1, Exp exp2, bool and)
|
||||
{
|
||||
if (exp1 == null && exp2 == null) return null;
|
||||
if (exp1 == null) return exp2;
|
||||
if (exp2 == null) return exp1;
|
||||
return new JunctionExp(exp1, exp2, and);
|
||||
}
|
||||
|
||||
public static Exp Like(string column, string value)
|
||||
{
|
||||
return Like(column, value, SqlLike.AnyWhere);
|
||||
}
|
||||
|
||||
public static Exp Like(string column, string value, SqlLike like)
|
||||
{
|
||||
return new LikeExp(column, value, like);
|
||||
}
|
||||
|
||||
public static Exp In(string column, ICollection values)
|
||||
{
|
||||
return new InExp(column, new ArrayList(values).ToArray());
|
||||
}
|
||||
|
||||
public static Exp In(string column, object[] values)
|
||||
{
|
||||
return new InExp(column, values);
|
||||
}
|
||||
|
||||
public static Exp In(string column, SqlQuery subQuery)
|
||||
{
|
||||
return new InExp(column, subQuery);
|
||||
}
|
||||
|
||||
public static Exp Between(string column, object minValue, object maxValue)
|
||||
{
|
||||
return new BetweenExp(column, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static Exp Lt(string column, object value)
|
||||
{
|
||||
return new LGExp(column, value, false);
|
||||
}
|
||||
|
||||
public static Exp Le(string column, object value)
|
||||
{
|
||||
return new LGExp(column, value, true);
|
||||
}
|
||||
|
||||
public static Exp Gt(string column, object value)
|
||||
{
|
||||
return !Le(column, value);
|
||||
}
|
||||
|
||||
public static Exp Ge(string column, object value)
|
||||
{
|
||||
return !Lt(column, value);
|
||||
}
|
||||
|
||||
public static Exp Sql(string sql)
|
||||
{
|
||||
return new SqlExp(sql);
|
||||
}
|
||||
|
||||
public static Exp Exists(SqlQuery query)
|
||||
{
|
||||
return new ExistsExp(query);
|
||||
}
|
||||
|
||||
public static Exp Sum(Exp exp)
|
||||
{
|
||||
return new SumExp(exp);
|
||||
}
|
||||
|
||||
public static Exp If(Exp exp, object trueValue, object falseValue)
|
||||
{
|
||||
return new IfExp(exp, trueValue, falseValue);
|
||||
}
|
||||
|
||||
public static Exp operator &(Exp exp1, Exp exp2)
|
||||
{
|
||||
return And(exp1, exp2);
|
||||
}
|
||||
|
||||
public static Exp operator |(Exp exp1, Exp exp2)
|
||||
{
|
||||
return Or(exp1, exp2);
|
||||
}
|
||||
|
||||
public static Exp operator !(Exp exp)
|
||||
{
|
||||
exp.Not = !exp.Not;
|
||||
return exp;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public abstract class Exp : ISqlInstruction
|
||||
{
|
||||
public static readonly Exp Empty;
|
||||
|
||||
public static Exp True
|
||||
{
|
||||
get { return new EqColumnsExp("1", "1"); }
|
||||
}
|
||||
|
||||
public static Exp False
|
||||
{
|
||||
get { return new EqColumnsExp("1", "0"); }
|
||||
}
|
||||
|
||||
|
||||
protected bool Not { get; private set; }
|
||||
|
||||
|
||||
public abstract string ToString(ISqlDialect dialect);
|
||||
|
||||
public virtual IEnumerable<object> GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
|
||||
public static Exp Eq(string column, object value)
|
||||
{
|
||||
return new EqExp(column, value);
|
||||
}
|
||||
|
||||
public static Exp EqColumns(string column1, string column2)
|
||||
{
|
||||
return new EqColumnsExp(column1, column2);
|
||||
}
|
||||
|
||||
public static Exp EqColumns(string column1, SqlQuery query)
|
||||
{
|
||||
return new EqColumnsExp(column1, query);
|
||||
}
|
||||
|
||||
public static Exp And(Exp exp1, Exp exp2)
|
||||
{
|
||||
return Junction(exp1, exp2, true);
|
||||
}
|
||||
|
||||
public static Exp Or(Exp exp1, Exp exp2)
|
||||
{
|
||||
return Junction(exp1, exp2, false);
|
||||
}
|
||||
|
||||
private static Exp Junction(Exp exp1, Exp exp2, bool and)
|
||||
{
|
||||
if (exp1 == null && exp2 == null) return null;
|
||||
if (exp1 == null) return exp2;
|
||||
if (exp2 == null) return exp1;
|
||||
return new JunctionExp(exp1, exp2, and);
|
||||
}
|
||||
|
||||
public static Exp Like(string column, string value)
|
||||
{
|
||||
return Like(column, value, SqlLike.AnyWhere);
|
||||
}
|
||||
|
||||
public static Exp Like(string column, string value, SqlLike like)
|
||||
{
|
||||
return new LikeExp(column, value, like);
|
||||
}
|
||||
|
||||
|
||||
public static Exp In<T>(string column, IEnumerable<T> values)
|
||||
{
|
||||
return new InExp<T>(column, values);
|
||||
}
|
||||
|
||||
|
||||
public static Exp In(string column, SqlQuery subQuery)
|
||||
{
|
||||
return new InExp<object>(column, subQuery);
|
||||
}
|
||||
|
||||
public static Exp Between(string column, object minValue, object maxValue)
|
||||
{
|
||||
return new BetweenExp(column, minValue, maxValue);
|
||||
}
|
||||
|
||||
public static Exp Lt(string column, object value)
|
||||
{
|
||||
return new LGExp(column, value, false);
|
||||
}
|
||||
|
||||
public static Exp Le(string column, object value)
|
||||
{
|
||||
return new LGExp(column, value, true);
|
||||
}
|
||||
|
||||
public static Exp Gt(string column, object value)
|
||||
{
|
||||
return !Le(column, value);
|
||||
}
|
||||
|
||||
public static Exp Ge(string column, object value)
|
||||
{
|
||||
return !Lt(column, value);
|
||||
}
|
||||
|
||||
public static Exp Sql(string sql)
|
||||
{
|
||||
return new SqlExp(sql);
|
||||
}
|
||||
|
||||
public static Exp Exists(SqlQuery query)
|
||||
{
|
||||
return new ExistsExp(query);
|
||||
}
|
||||
|
||||
public static Exp Sum(Exp exp)
|
||||
{
|
||||
return new SumExp(exp);
|
||||
}
|
||||
|
||||
public static Exp If(Exp exp, object trueValue, object falseValue)
|
||||
{
|
||||
return new IfExp(exp, trueValue, falseValue);
|
||||
}
|
||||
|
||||
public static Exp operator &(Exp exp1, Exp exp2)
|
||||
{
|
||||
return And(exp1, exp2);
|
||||
}
|
||||
|
||||
public static Exp operator |(Exp exp1, Exp exp2)
|
||||
{
|
||||
return Or(exp1, exp2);
|
||||
}
|
||||
|
||||
public static Exp operator !(Exp exp)
|
||||
{
|
||||
exp.Not = !exp.Not;
|
||||
return exp;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
}
|
||||
}
|
@ -37,12 +37,12 @@ namespace ASC.Common.Data.Sql.Expressions
|
||||
return string.Format("if({0}, ?, ?)", _condition.ToString(dialect));
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
parameters.AddRange(_condition.GetParameters());
|
||||
parameters.AddRange(new[] { _trueValue, _falseValue });
|
||||
return parameters.ToArray();
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,71 +1,72 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class InExp : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly SqlQuery subQuery;
|
||||
private readonly object[] values;
|
||||
|
||||
public InExp(string column, object[] values)
|
||||
{
|
||||
this.column = column;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public InExp(string column, SqlQuery subQuery)
|
||||
{
|
||||
this.column = column;
|
||||
this.subQuery = subQuery;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
if (values != null && values.Count() < 2)
|
||||
{
|
||||
var exp = values.Count() == 0 ? Exp.False : Exp.Eq(column, values.ElementAt(0));
|
||||
return (Not ? !exp : exp).ToString(dialect);
|
||||
}
|
||||
|
||||
var sql = new StringBuilder(column);
|
||||
if (Not) sql.Append(" not");
|
||||
sql.Append(" in (");
|
||||
|
||||
if (values != null)
|
||||
{
|
||||
sql.Append(string.Join(",", Enumerable.Repeat("?", values.Count()).ToArray()));
|
||||
}
|
||||
if (subQuery != null)
|
||||
{
|
||||
sql.Append(subQuery.ToString(dialect));
|
||||
}
|
||||
return sql.Append(")").ToString();
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
if (values != null) return values;
|
||||
if (subQuery != null) return subQuery.GetParameters();
|
||||
return new object[0];
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class InExp<T> : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly SqlQuery subQuery;
|
||||
private readonly IEnumerable<T> values;
|
||||
|
||||
public InExp(string column, IEnumerable<T> values)
|
||||
{
|
||||
this.column = column;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public InExp(string column, SqlQuery subQuery)
|
||||
{
|
||||
this.column = column;
|
||||
this.subQuery = subQuery;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
if (values != null && values.Count() < 2)
|
||||
{
|
||||
var exp = values.Count() == 0 ? Exp.False : Exp.Eq(column, values.ElementAt(0));
|
||||
return (Not ? !exp : exp).ToString(dialect);
|
||||
}
|
||||
|
||||
var sql = new StringBuilder(column);
|
||||
if (Not) sql.Append(" not");
|
||||
sql.Append(" in (");
|
||||
|
||||
if (values != null)
|
||||
{
|
||||
sql.Append(string.Join(",", Enumerable.Repeat("?", values.Count()).ToArray()));
|
||||
}
|
||||
if (subQuery != null)
|
||||
{
|
||||
sql.Append(subQuery.ToString(dialect));
|
||||
}
|
||||
return sql.Append(")").ToString();
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
if (values != null) return values.Cast<object>().ToList();
|
||||
if (subQuery != null) return subQuery.GetParameters();
|
||||
return new object[0];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +1,54 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class JunctionExp : Exp
|
||||
{
|
||||
private readonly bool and;
|
||||
private readonly Exp exp1;
|
||||
private readonly Exp exp2;
|
||||
|
||||
public JunctionExp(Exp exp1, Exp exp2, bool and)
|
||||
{
|
||||
this.exp1 = exp1;
|
||||
this.exp2 = exp2;
|
||||
this.and = and;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
string format = exp1 is JunctionExp && ((JunctionExp)exp1).and != and ? "({0})" : "{0}";
|
||||
format += " {1} ";
|
||||
format += exp2 is JunctionExp && ((JunctionExp)exp2).and != and ? "({2})" : "{2}";
|
||||
return Not
|
||||
? string.Format(format, (!exp1).ToString(dialect), and ? "or" : "and",
|
||||
(!exp2).ToString(dialect))
|
||||
: string.Format(format, exp1.ToString(dialect), and ? "and" : "or", exp2.ToString(dialect));
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
parameters.AddRange(exp1.GetParameters());
|
||||
parameters.AddRange(exp2.GetParameters());
|
||||
return parameters.ToArray();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class JunctionExp : Exp
|
||||
{
|
||||
private readonly bool and;
|
||||
private readonly Exp exp1;
|
||||
private readonly Exp exp2;
|
||||
|
||||
public JunctionExp(Exp exp1, Exp exp2, bool and)
|
||||
{
|
||||
this.exp1 = exp1;
|
||||
this.exp2 = exp2;
|
||||
this.and = and;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
string format = exp1 is JunctionExp && ((JunctionExp)exp1).and != and ? "({0})" : "{0}";
|
||||
format += " {1} ";
|
||||
format += exp2 is JunctionExp && ((JunctionExp)exp2).and != and ? "({2})" : "{2}";
|
||||
return Not
|
||||
? string.Format(format, (!exp1).ToString(dialect), and ? "or" : "and",
|
||||
(!exp2).ToString(dialect))
|
||||
: string.Format(format, exp1.ToString(dialect), and ? "and" : "or", exp2.ToString(dialect));
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
parameters.AddRange(exp1.GetParameters());
|
||||
parameters.AddRange(exp2.GetParameters());
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +1,47 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class LGExp : Exp
|
||||
{
|
||||
private readonly SqlIdentifier column;
|
||||
private readonly bool equal;
|
||||
private readonly object value;
|
||||
|
||||
public LGExp(string column, object value, bool equal)
|
||||
{
|
||||
this.column = (SqlIdentifier)column;
|
||||
this.value = value;
|
||||
this.equal = equal;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return Not
|
||||
? string.Format("{0} >{1} ?", column.ToString(dialect), !equal ? "=" : string.Empty)
|
||||
: string.Format("{0} <{1} ?", column.ToString(dialect), equal ? "=" : string.Empty);
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return new[] { value };
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class LGExp : Exp
|
||||
{
|
||||
private readonly SqlIdentifier column;
|
||||
private readonly bool equal;
|
||||
private readonly object value;
|
||||
|
||||
public LGExp(string column, object value, bool equal)
|
||||
{
|
||||
this.column = (SqlIdentifier)column;
|
||||
this.value = value;
|
||||
this.equal = equal;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return Not
|
||||
? string.Format("{0} >{1} ?", column.ToString(dialect), !equal ? "=" : string.Empty)
|
||||
: string.Format("{0} <{1} ?", column.ToString(dialect), equal ? "=" : string.Empty);
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return new[] { value };
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +1,59 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
[Flags]
|
||||
public enum SqlLike
|
||||
{
|
||||
StartWith = 1,
|
||||
EndWith = 2,
|
||||
AnyWhere = StartWith | EndWith,
|
||||
}
|
||||
|
||||
public class LikeExp : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly string str;
|
||||
|
||||
public LikeExp(string column, string str, SqlLike like)
|
||||
{
|
||||
this.column = column;
|
||||
if (str != null)
|
||||
{
|
||||
if ((like & SqlLike.StartWith) == SqlLike.StartWith) str += "%";
|
||||
if ((like & SqlLike.EndWith) == SqlLike.EndWith) str = "%" + str;
|
||||
}
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return str != null
|
||||
? string.Format("{0} {1}like ?", column, Not ? "not " : string.Empty)
|
||||
: string.Format("{0} is {1}null", column, Not ? "not " : string.Empty);
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return str == null ? new object[0] : new object[] { str };
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
[Flags]
|
||||
public enum SqlLike
|
||||
{
|
||||
StartWith = 1,
|
||||
EndWith = 2,
|
||||
AnyWhere = StartWith | EndWith,
|
||||
}
|
||||
|
||||
public class LikeExp : Exp
|
||||
{
|
||||
private readonly string column;
|
||||
private readonly string str;
|
||||
|
||||
public LikeExp(string column, string str, SqlLike like)
|
||||
{
|
||||
this.column = column;
|
||||
if (str != null)
|
||||
{
|
||||
if ((like & SqlLike.StartWith) == SqlLike.StartWith) str += "%";
|
||||
if ((like & SqlLike.EndWith) == SqlLike.EndWith) str = "%" + str;
|
||||
}
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return str != null
|
||||
? string.Format("{0} {1}like ?", column, Not ? "not " : string.Empty)
|
||||
: string.Format("{0} is {1}null", column, Not ? "not " : string.Empty);
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return str == null ? new object[0] : new object[] { str };
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +1,62 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
enum AgregateType
|
||||
{
|
||||
count,
|
||||
min,
|
||||
max,
|
||||
avg,
|
||||
sum
|
||||
}
|
||||
|
||||
class SelectAgregate : ISqlInstruction
|
||||
{
|
||||
private readonly AgregateType agregateType;
|
||||
private readonly string column;
|
||||
|
||||
public SelectAgregate(AgregateType agregateType)
|
||||
: this(agregateType, null)
|
||||
{
|
||||
}
|
||||
|
||||
public SelectAgregate(AgregateType agregateType, string column)
|
||||
{
|
||||
this.agregateType = agregateType;
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0}({1})", agregateType, column == null ? "*" : column);
|
||||
}
|
||||
|
||||
public object[] GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
enum AgregateType
|
||||
{
|
||||
count,
|
||||
min,
|
||||
max,
|
||||
avg,
|
||||
sum
|
||||
}
|
||||
|
||||
class SelectAgregate : ISqlInstruction
|
||||
{
|
||||
private readonly AgregateType agregateType;
|
||||
private readonly string column;
|
||||
|
||||
public SelectAgregate(AgregateType agregateType)
|
||||
: this(agregateType, null)
|
||||
{
|
||||
}
|
||||
|
||||
public SelectAgregate(AgregateType agregateType, string column)
|
||||
{
|
||||
this.agregateType = agregateType;
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return string.Format("{0}({1})", agregateType, column == null ? "*" : column);
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +1,49 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class SqlExp : Exp
|
||||
{
|
||||
private readonly string sql;
|
||||
private readonly object[] parameters;
|
||||
private readonly ISqlInstruction ins;
|
||||
|
||||
public SqlExp(string sql, params object[] parameters)
|
||||
{
|
||||
this.sql = sql;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public SqlExp(ISqlInstruction sql)
|
||||
{
|
||||
this.ins = sql;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return ins != null ? ins.ToString(dialect) : sql;
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
{
|
||||
return ins != null ? ins.GetParameters() : (parameters ?? new object[0]);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class SqlExp : Exp
|
||||
{
|
||||
private readonly string sql;
|
||||
private readonly object[] parameters;
|
||||
private readonly ISqlInstruction ins;
|
||||
|
||||
public SqlExp(string sql, params object[] parameters)
|
||||
{
|
||||
this.sql = sql;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public SqlExp(ISqlInstruction sql)
|
||||
{
|
||||
this.ins = sql;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return ins != null ? ins.ToString(dialect) : sql;
|
||||
}
|
||||
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return ins != null ? ins.GetParameters() : (parameters ?? new object[0]);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql.Expressions
|
||||
{
|
||||
public class SumExp : Exp
|
||||
@ -36,7 +38,7 @@ namespace ASC.Common.Data.Sql.Expressions
|
||||
return string.Format("sum({0})", _exp.ToString(dialect));
|
||||
}
|
||||
|
||||
public override object[] GetParameters()
|
||||
public override IEnumerable<object> GetParameters()
|
||||
{
|
||||
return _exp.GetParameters();
|
||||
}
|
||||
|
@ -1,42 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public interface ISqlDialect
|
||||
{
|
||||
string IdentityQuery { get; }
|
||||
|
||||
string Autoincrement { get; }
|
||||
|
||||
string InsertIgnore { get; }
|
||||
|
||||
|
||||
bool SupportMultiTableUpdate { get; }
|
||||
|
||||
bool SeparateCreateIndex { get; }
|
||||
|
||||
|
||||
string DbTypeToString(DbType type, int size, int precision);
|
||||
|
||||
IsolationLevel GetSupportedIsolationLevel(IsolationLevel il);
|
||||
|
||||
string UseIndex(string index);
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Data;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public interface ISqlDialect
|
||||
{
|
||||
string IdentityQuery { get; }
|
||||
|
||||
string Autoincrement { get; }
|
||||
|
||||
string InsertIgnore { get; }
|
||||
|
||||
|
||||
bool SupportMultiTableUpdate { get; }
|
||||
|
||||
bool SeparateCreateIndex { get; }
|
||||
|
||||
|
||||
string DbTypeToString(DbType type, int size, int precision);
|
||||
|
||||
IsolationLevel GetSupportedIsolationLevel(IsolationLevel il);
|
||||
|
||||
string UseIndex(string index);
|
||||
}
|
||||
}
|
@ -1,25 +1,27 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public interface ISqlInstruction
|
||||
{
|
||||
string ToString(ISqlDialect dialect);
|
||||
object[] GetParameters();
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public interface ISqlInstruction
|
||||
{
|
||||
string ToString(ISqlDialect dialect);
|
||||
IEnumerable<object> GetParameters();
|
||||
}
|
||||
}
|
@ -1,282 +1,282 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public abstract class SqlCreate : ISqlInstruction
|
||||
{
|
||||
protected string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
protected SqlCreate(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
|
||||
public abstract string ToString(ISqlDialect dialect);
|
||||
|
||||
public object[] GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
|
||||
public class Table : SqlCreate
|
||||
{
|
||||
private bool ifNotExists;
|
||||
private readonly List<string> primaryKey = new List<string>();
|
||||
private readonly List<Column> columns = new List<Column>();
|
||||
private readonly List<Index> indexes = new List<Index>();
|
||||
|
||||
|
||||
public Table(string name)
|
||||
: base(name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Table(string name, bool ifNotExists)
|
||||
: this(name)
|
||||
{
|
||||
IfNotExists(ifNotExists);
|
||||
}
|
||||
|
||||
public Table IfNotExists(bool ifNotExists)
|
||||
{
|
||||
this.ifNotExists = ifNotExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(Column column)
|
||||
{
|
||||
this.columns.Add(column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type)
|
||||
{
|
||||
AddColumn(name, type, 0, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type, int size)
|
||||
{
|
||||
AddColumn(name, type, size, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type, bool notNull)
|
||||
{
|
||||
AddColumn(name, type, 0, notNull);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type, int size, bool notNull)
|
||||
{
|
||||
AddColumn(new Column(name, type, size).NotNull(notNull));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table PrimaryKey(params string[] columns)
|
||||
{
|
||||
primaryKey.AddRange(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddIndex(Index index)
|
||||
{
|
||||
index.IfNotExists(ifNotExists);
|
||||
this.indexes.Add(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddIndex(string name, params string[] columns)
|
||||
{
|
||||
AddIndex(new Index(name, Name, columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder("create table ");
|
||||
if (ifNotExists) sql.Append("if not exists ");
|
||||
sql.AppendFormat("{0} (", Name);
|
||||
|
||||
foreach (var c in columns)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c.ToString(dialect));
|
||||
}
|
||||
if (0 < primaryKey.Count)
|
||||
{
|
||||
sql.Append("primary key (");
|
||||
foreach (var c in primaryKey)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c);
|
||||
}
|
||||
sql.Replace(", ", "), ", sql.Length - 2, 2);
|
||||
}
|
||||
if (dialect.SeparateCreateIndex)
|
||||
{
|
||||
sql.Replace(", ", ");", sql.Length - 2, 2);
|
||||
sql.AppendLine();
|
||||
indexes.ForEach(i => sql.AppendLine(i.ToString(dialect)));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var i in indexes)
|
||||
{
|
||||
sql.AppendFormat("index {0}{1} (", i.unique ? "unique " : string.Empty, i.Name);
|
||||
foreach (var c in i.columns)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c);
|
||||
}
|
||||
sql.Replace(", ", "), ", sql.Length - 2, 2);
|
||||
}
|
||||
sql.Replace(", ", ");", sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
return sql.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class Column : SqlCreate
|
||||
{
|
||||
private readonly DbType type;
|
||||
private readonly int size;
|
||||
private readonly int precision;
|
||||
private bool notNull;
|
||||
private bool primaryKey;
|
||||
private bool autoinc;
|
||||
private object defaultValue;
|
||||
|
||||
|
||||
public Column(string name, DbType type)
|
||||
: this(name, type, 0, 0)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Column(string name, DbType type, int size)
|
||||
: this(name, type, size, 0)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Column(string name, DbType type, int size, int precision)
|
||||
: base(name)
|
||||
{
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
|
||||
public Column NotNull(bool notNull)
|
||||
{
|
||||
this.notNull = notNull;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Column Autoincrement(bool autoincrement)
|
||||
{
|
||||
this.autoinc = autoincrement;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Column PrimaryKey(bool primaryKey)
|
||||
{
|
||||
this.primaryKey = primaryKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Column Default(object value)
|
||||
{
|
||||
this.defaultValue = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder().AppendFormat("{0} {1} {2} ", Name, dialect.DbTypeToString(type, size, precision), notNull ? "not null" : "null");
|
||||
if (defaultValue != null) sql.AppendFormat("default {0} ", defaultValue);
|
||||
if (primaryKey) sql.Append("primary key ");
|
||||
if (autoinc) sql.Append(dialect.Autoincrement);
|
||||
|
||||
return sql.ToString().Trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Index : SqlCreate
|
||||
{
|
||||
private readonly string table;
|
||||
internal string[] columns;
|
||||
internal bool unique;
|
||||
private bool ifNotExists;
|
||||
|
||||
|
||||
public Index(string name, string table, params string[] columns)
|
||||
: base(name)
|
||||
{
|
||||
this.table = table;
|
||||
this.columns = columns ?? new string[0];
|
||||
}
|
||||
|
||||
public Index Unique(bool unique)
|
||||
{
|
||||
this.unique = unique;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Index IfNotExists(bool ifNotExists)
|
||||
{
|
||||
this.ifNotExists = ifNotExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder("create ");
|
||||
if (unique) sql.Append("unique ");
|
||||
sql.Append("index ");
|
||||
if (ifNotExists) sql.Append("if not exists ");
|
||||
sql.AppendFormat("{0} on {1} (", Name, table);
|
||||
|
||||
foreach (var c in columns)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c);
|
||||
}
|
||||
|
||||
return sql.Replace(", ", ");", sql.Length - 2, 2).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
public abstract class SqlCreate : ISqlInstruction
|
||||
{
|
||||
protected string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
protected SqlCreate(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
|
||||
public abstract string ToString(ISqlDialect dialect);
|
||||
|
||||
public IEnumerable<object> GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
|
||||
public class Table : SqlCreate
|
||||
{
|
||||
private bool ifNotExists;
|
||||
private readonly List<string> primaryKey = new List<string>();
|
||||
private readonly List<Column> columns = new List<Column>();
|
||||
private readonly List<Index> indexes = new List<Index>();
|
||||
|
||||
|
||||
public Table(string name)
|
||||
: base(name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Table(string name, bool ifNotExists)
|
||||
: this(name)
|
||||
{
|
||||
IfNotExists(ifNotExists);
|
||||
}
|
||||
|
||||
public Table IfNotExists(bool ifNotExists)
|
||||
{
|
||||
this.ifNotExists = ifNotExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(Column column)
|
||||
{
|
||||
this.columns.Add(column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type)
|
||||
{
|
||||
AddColumn(name, type, 0, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type, int size)
|
||||
{
|
||||
AddColumn(name, type, size, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type, bool notNull)
|
||||
{
|
||||
AddColumn(name, type, 0, notNull);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddColumn(string name, DbType type, int size, bool notNull)
|
||||
{
|
||||
AddColumn(new Column(name, type, size).NotNull(notNull));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table PrimaryKey(params string[] columns)
|
||||
{
|
||||
primaryKey.AddRange(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddIndex(Index index)
|
||||
{
|
||||
index.IfNotExists(ifNotExists);
|
||||
this.indexes.Add(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table AddIndex(string name, params string[] columns)
|
||||
{
|
||||
AddIndex(new Index(name, Name, columns));
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder("create table ");
|
||||
if (ifNotExists) sql.Append("if not exists ");
|
||||
sql.AppendFormat("{0} (", Name);
|
||||
|
||||
foreach (var c in columns)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c.ToString(dialect));
|
||||
}
|
||||
if (0 < primaryKey.Count)
|
||||
{
|
||||
sql.Append("primary key (");
|
||||
foreach (var c in primaryKey)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c);
|
||||
}
|
||||
sql.Replace(", ", "), ", sql.Length - 2, 2);
|
||||
}
|
||||
if (dialect.SeparateCreateIndex)
|
||||
{
|
||||
sql.Replace(", ", ");", sql.Length - 2, 2);
|
||||
sql.AppendLine();
|
||||
indexes.ForEach(i => sql.AppendLine(i.ToString(dialect)));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var i in indexes)
|
||||
{
|
||||
sql.AppendFormat("index {0}{1} (", i.unique ? "unique " : string.Empty, i.Name);
|
||||
foreach (var c in i.columns)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c);
|
||||
}
|
||||
sql.Replace(", ", "), ", sql.Length - 2, 2);
|
||||
}
|
||||
sql.Replace(", ", ");", sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
return sql.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class Column : SqlCreate
|
||||
{
|
||||
private readonly DbType type;
|
||||
private readonly int size;
|
||||
private readonly int precision;
|
||||
private bool notNull;
|
||||
private bool primaryKey;
|
||||
private bool autoinc;
|
||||
private object defaultValue;
|
||||
|
||||
|
||||
public Column(string name, DbType type)
|
||||
: this(name, type, 0, 0)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Column(string name, DbType type, int size)
|
||||
: this(name, type, size, 0)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Column(string name, DbType type, int size, int precision)
|
||||
: base(name)
|
||||
{
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
|
||||
public Column NotNull(bool notNull)
|
||||
{
|
||||
this.notNull = notNull;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Column Autoincrement(bool autoincrement)
|
||||
{
|
||||
this.autoinc = autoincrement;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Column PrimaryKey(bool primaryKey)
|
||||
{
|
||||
this.primaryKey = primaryKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Column Default(object value)
|
||||
{
|
||||
this.defaultValue = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder().AppendFormat("{0} {1} {2} ", Name, dialect.DbTypeToString(type, size, precision), notNull ? "not null" : "null");
|
||||
if (defaultValue != null) sql.AppendFormat("default {0} ", defaultValue);
|
||||
if (primaryKey) sql.Append("primary key ");
|
||||
if (autoinc) sql.Append(dialect.Autoincrement);
|
||||
|
||||
return sql.ToString().Trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Index : SqlCreate
|
||||
{
|
||||
private readonly string table;
|
||||
internal string[] columns;
|
||||
internal bool unique;
|
||||
private bool ifNotExists;
|
||||
|
||||
|
||||
public Index(string name, string table, params string[] columns)
|
||||
: base(name)
|
||||
{
|
||||
this.table = table;
|
||||
this.columns = columns ?? new string[0];
|
||||
}
|
||||
|
||||
public Index Unique(bool unique)
|
||||
{
|
||||
this.unique = unique;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Index IfNotExists(bool ifNotExists)
|
||||
{
|
||||
this.ifNotExists = ifNotExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder("create ");
|
||||
if (unique) sql.Append("unique ");
|
||||
sql.Append("index ");
|
||||
if (ifNotExists) sql.Append("if not exists ");
|
||||
sql.AppendFormat("{0} on {1} (", Name, table);
|
||||
|
||||
foreach (var c in columns)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", c);
|
||||
}
|
||||
|
||||
return sql.Replace(", ", ");", sql.Length - 2, 2).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,74 +1,78 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
class SqlDebugView
|
||||
{
|
||||
private readonly ISqlInstruction instruction;
|
||||
|
||||
|
||||
public string Sql
|
||||
{
|
||||
get { return GetSqlWithParameters(); }
|
||||
}
|
||||
|
||||
public object[] Parameters
|
||||
{
|
||||
get { return instruction.GetParameters(); }
|
||||
}
|
||||
|
||||
|
||||
public SqlDebugView(ISqlInstruction instruction)
|
||||
{
|
||||
this.instruction = instruction;
|
||||
}
|
||||
|
||||
private string GetSqlWithParameters()
|
||||
{
|
||||
var sql = instruction.ToString();
|
||||
var parameters = instruction.GetParameters();
|
||||
var sb = new StringBuilder();
|
||||
var i = 0;
|
||||
foreach (var part in sql.Split('?'))
|
||||
{
|
||||
sb.Append(part);
|
||||
if (i < parameters.Length)
|
||||
{
|
||||
var p = parameters[i];
|
||||
if (p == null)
|
||||
{
|
||||
sb.Append("null");
|
||||
}
|
||||
else if (p is string || p is char || p is DateTime || p is Guid)
|
||||
{
|
||||
sb.AppendFormat("'{0}'", p);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(p);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
class SqlDebugView
|
||||
{
|
||||
private readonly ISqlInstruction instruction;
|
||||
|
||||
|
||||
public string Sql
|
||||
{
|
||||
get { return GetSqlWithParameters(); }
|
||||
}
|
||||
|
||||
public IEnumerable<object> Parameters
|
||||
{
|
||||
get { return instruction.GetParameters(); }
|
||||
}
|
||||
|
||||
|
||||
public SqlDebugView(ISqlInstruction instruction)
|
||||
{
|
||||
this.instruction = instruction;
|
||||
}
|
||||
|
||||
private string GetSqlWithParameters()
|
||||
{
|
||||
var sql = instruction.ToString();
|
||||
var parameters = instruction.GetParameters();
|
||||
var sb = new StringBuilder();
|
||||
var i = 0;
|
||||
var sqlParts = sql.Split('?');
|
||||
var pCount = parameters.Count();
|
||||
|
||||
foreach (var p in parameters)
|
||||
{
|
||||
sb.Append(sqlParts[i]);
|
||||
if (i < pCount)
|
||||
{
|
||||
if (p == null)
|
||||
{
|
||||
sb.Append("null");
|
||||
}
|
||||
else if (p is string || p is char || p is DateTime || p is Guid)
|
||||
{
|
||||
sb.AppendFormat("'{0}'", p);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(p);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,73 +1,74 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#region usings
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlDelete : ISqlInstruction
|
||||
{
|
||||
private readonly string table;
|
||||
private Exp where = Exp.Empty;
|
||||
|
||||
public SqlDelete(string table)
|
||||
{
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
#region ISqlInstruction Members
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
sql.AppendFormat("delete from {0}", table);
|
||||
if (where != Exp.Empty) sql.AppendFormat(" where {0}", where.ToString(dialect));
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public object[] GetParameters()
|
||||
{
|
||||
return where != Exp.Empty ? where.GetParameters() : new object[0];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public SqlDelete Where(Exp where)
|
||||
{
|
||||
this.where = this.where & where;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlDelete Where(string column, object value)
|
||||
{
|
||||
return Where(Exp.Eq(column, value));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#region usings
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlDelete : ISqlInstruction
|
||||
{
|
||||
private readonly string table;
|
||||
private Exp where = Exp.Empty;
|
||||
|
||||
public SqlDelete(string table)
|
||||
{
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
#region ISqlInstruction Members
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
sql.AppendFormat("delete from {0}", table);
|
||||
if (where != Exp.Empty) sql.AppendFormat(" where {0}", where.ToString(dialect));
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetParameters()
|
||||
{
|
||||
return where != Exp.Empty ? where.GetParameters() : new object[0];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public SqlDelete Where(Exp where)
|
||||
{
|
||||
this.where = this.where & where;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlDelete Where(string column, object value)
|
||||
{
|
||||
return Where(Exp.Eq(column, value));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +1,51 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
class SqlIdentifier : ISqlInstruction
|
||||
{
|
||||
public string Identifier
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
public SqlIdentifier(string identifier)
|
||||
{
|
||||
Identifier = identifier;
|
||||
}
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return Identifier;
|
||||
}
|
||||
|
||||
public object[] GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
public static explicit operator SqlIdentifier(string identifier)
|
||||
{
|
||||
return new SqlIdentifier(identifier);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
class SqlIdentifier : ISqlInstruction
|
||||
{
|
||||
public string Identifier
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
public SqlIdentifier(string identifier)
|
||||
{
|
||||
Identifier = identifier;
|
||||
}
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
return Identifier;
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetParameters()
|
||||
{
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
public static explicit operator SqlIdentifier(string identifier)
|
||||
{
|
||||
return new SqlIdentifier(identifier);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,193 +1,193 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlInsert : ISqlInstruction
|
||||
{
|
||||
private readonly List<string> columns = new List<string>();
|
||||
private readonly string table;
|
||||
private readonly List<object> values = new List<object>();
|
||||
private int identityPosition = -1;
|
||||
private object nullValue;
|
||||
private SqlQuery query;
|
||||
private bool replaceExists;
|
||||
private bool ignoreExists;
|
||||
private bool returnIdentity;
|
||||
|
||||
|
||||
public SqlInsert(string table)
|
||||
: this(table, false)
|
||||
{
|
||||
}
|
||||
|
||||
public SqlInsert(string table, bool replaceExists)
|
||||
{
|
||||
this.table = table;
|
||||
ReplaceExists(replaceExists);
|
||||
}
|
||||
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
|
||||
if (ignoreExists)
|
||||
{
|
||||
sql.Append(dialect.InsertIgnore);
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Append(replaceExists ? "replace" : "insert");
|
||||
}
|
||||
sql.AppendFormat(" into {0}", table);
|
||||
bool identityInsert = IsIdentityInsert();
|
||||
if (0 < columns.Count)
|
||||
{
|
||||
sql.Append("(");
|
||||
for (int i = 0; i < columns.Count; i++)
|
||||
{
|
||||
if (identityInsert && identityPosition == i) continue;
|
||||
sql.AppendFormat("{0},", columns[i]);
|
||||
}
|
||||
sql.Remove(sql.Length - 1, 1).Append(")");
|
||||
}
|
||||
if (query != null)
|
||||
{
|
||||
sql.AppendFormat(" {0}", query.ToString(dialect));
|
||||
return sql.ToString();
|
||||
}
|
||||
sql.Append(" values (");
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
{
|
||||
if (identityInsert && identityPosition == i)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sql.Append("?");
|
||||
if (i + 1 == values.Count)
|
||||
{
|
||||
sql.Append(")");
|
||||
}
|
||||
else if (0 < columns.Count && (i + 1) % columns.Count == 0)
|
||||
{
|
||||
sql.Append("),(");
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Append(",");
|
||||
}
|
||||
}
|
||||
|
||||
if (returnIdentity)
|
||||
{
|
||||
sql.AppendFormat("; select {0}", identityInsert ? dialect.IdentityQuery : "?");
|
||||
}
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public object[] GetParameters()
|
||||
{
|
||||
if (query != null)
|
||||
{
|
||||
return query.GetParameters();
|
||||
}
|
||||
var copy = new List<object>(values);
|
||||
if (IsIdentityInsert())
|
||||
{
|
||||
copy.RemoveAt(identityPosition);
|
||||
}
|
||||
else if (returnIdentity)
|
||||
{
|
||||
copy.Add(copy[identityPosition]);
|
||||
}
|
||||
return copy.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public SqlInsert InColumns(params string[] columns)
|
||||
{
|
||||
this.columns.AddRange(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert Values(params object[] values)
|
||||
{
|
||||
this.values.AddRange(values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert Values(SqlQuery query)
|
||||
{
|
||||
this.query = query;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert InColumnValue(string column, object value)
|
||||
{
|
||||
return InColumns(column).Values(value);
|
||||
}
|
||||
|
||||
public SqlInsert ReplaceExists(bool replaceExists)
|
||||
{
|
||||
this.replaceExists = replaceExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert IgnoreExists(bool ignoreExists)
|
||||
{
|
||||
this.ignoreExists = ignoreExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert Identity<TIdentity>(int position, TIdentity nullValue)
|
||||
{
|
||||
return Identity(position, nullValue, false);
|
||||
}
|
||||
|
||||
public SqlInsert Identity<TIdentity>(int position, TIdentity nullValue, bool returnIdentity)
|
||||
{
|
||||
identityPosition = position;
|
||||
this.nullValue = nullValue;
|
||||
this.returnIdentity = returnIdentity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
private bool IsIdentityInsert()
|
||||
{
|
||||
if (identityPosition < 0) return false;
|
||||
if (values[identityPosition] != null && nullValue != null &&
|
||||
values[identityPosition].GetType() != nullValue.GetType())
|
||||
{
|
||||
throw new InvalidCastException(string.Format("Identity null value must be {0} type.",
|
||||
values[identityPosition].GetType()));
|
||||
}
|
||||
return Equals(values[identityPosition], nullValue);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlInsert : ISqlInstruction
|
||||
{
|
||||
private readonly List<string> columns = new List<string>();
|
||||
private readonly string table;
|
||||
private readonly List<object> values = new List<object>();
|
||||
private int identityPosition = -1;
|
||||
private object nullValue;
|
||||
private SqlQuery query;
|
||||
private bool replaceExists;
|
||||
private bool ignoreExists;
|
||||
private bool returnIdentity;
|
||||
|
||||
|
||||
public SqlInsert(string table)
|
||||
: this(table, false)
|
||||
{
|
||||
}
|
||||
|
||||
public SqlInsert(string table, bool replaceExists)
|
||||
{
|
||||
this.table = table;
|
||||
ReplaceExists(replaceExists);
|
||||
}
|
||||
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
|
||||
if (ignoreExists)
|
||||
{
|
||||
sql.Append(dialect.InsertIgnore);
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Append(replaceExists ? "replace" : "insert");
|
||||
}
|
||||
sql.AppendFormat(" into {0}", table);
|
||||
bool identityInsert = IsIdentityInsert();
|
||||
if (0 < columns.Count)
|
||||
{
|
||||
sql.Append("(");
|
||||
for (int i = 0; i < columns.Count; i++)
|
||||
{
|
||||
if (identityInsert && identityPosition == i) continue;
|
||||
sql.AppendFormat("{0},", columns[i]);
|
||||
}
|
||||
sql.Remove(sql.Length - 1, 1).Append(")");
|
||||
}
|
||||
if (query != null)
|
||||
{
|
||||
sql.AppendFormat(" {0}", query.ToString(dialect));
|
||||
return sql.ToString();
|
||||
}
|
||||
sql.Append(" values (");
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
{
|
||||
if (identityInsert && identityPosition == i)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sql.Append("?");
|
||||
if (i + 1 == values.Count)
|
||||
{
|
||||
sql.Append(")");
|
||||
}
|
||||
else if (0 < columns.Count && (i + 1) % columns.Count == 0)
|
||||
{
|
||||
sql.Append("),(");
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Append(",");
|
||||
}
|
||||
}
|
||||
|
||||
if (returnIdentity)
|
||||
{
|
||||
sql.AppendFormat("; select {0}", identityInsert ? dialect.IdentityQuery : "?");
|
||||
}
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetParameters()
|
||||
{
|
||||
if (query != null)
|
||||
{
|
||||
return query.GetParameters();
|
||||
}
|
||||
var copy = new List<object>(values);
|
||||
if (IsIdentityInsert())
|
||||
{
|
||||
copy.RemoveAt(identityPosition);
|
||||
}
|
||||
else if (returnIdentity)
|
||||
{
|
||||
copy.Add(copy[identityPosition]);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
public SqlInsert InColumns(params string[] columns)
|
||||
{
|
||||
this.columns.AddRange(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert Values(params object[] values)
|
||||
{
|
||||
this.values.AddRange(values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert Values(SqlQuery query)
|
||||
{
|
||||
this.query = query;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert InColumnValue(string column, object value)
|
||||
{
|
||||
return InColumns(column).Values(value);
|
||||
}
|
||||
|
||||
public SqlInsert ReplaceExists(bool replaceExists)
|
||||
{
|
||||
this.replaceExists = replaceExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert IgnoreExists(bool ignoreExists)
|
||||
{
|
||||
this.ignoreExists = ignoreExists;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlInsert Identity<TIdentity>(int position, TIdentity nullValue)
|
||||
{
|
||||
return Identity(position, nullValue, false);
|
||||
}
|
||||
|
||||
public SqlInsert Identity<TIdentity>(int position, TIdentity nullValue, bool returnIdentity)
|
||||
{
|
||||
identityPosition = position;
|
||||
this.nullValue = nullValue;
|
||||
this.returnIdentity = returnIdentity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
private bool IsIdentityInsert()
|
||||
{
|
||||
if (identityPosition < 0) return false;
|
||||
if (values[identityPosition] != null && nullValue != null &&
|
||||
values[identityPosition].GetType() != nullValue.GetType())
|
||||
{
|
||||
throw new InvalidCastException(string.Format("Identity null value must be {0} type.",
|
||||
values[identityPosition].GetType()));
|
||||
}
|
||||
return Equals(values[identityPosition], nullValue);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +1,58 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
class SqlInstructionDebuggerDisplay
|
||||
{
|
||||
private readonly ISqlInstruction i;
|
||||
|
||||
|
||||
public SqlInstructionDebuggerDisplay(ISqlInstruction i)
|
||||
{
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (i == null) return null;
|
||||
|
||||
var parts = i.ToString().Split('?');
|
||||
var result = new StringBuilder(parts[0]);
|
||||
var counter = 0;
|
||||
foreach (var p in i.GetParameters())
|
||||
{
|
||||
counter++;
|
||||
if (p == null)
|
||||
{
|
||||
result.Append("null");
|
||||
}
|
||||
else
|
||||
{
|
||||
var format = "{0}";
|
||||
if (p is DateTime || p is Guid || p is string) format = "'{0}'";
|
||||
result.AppendFormat(format, p);
|
||||
}
|
||||
if (counter < parts.Length) result.Append(parts[counter]);
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
class SqlInstructionDebuggerDisplay
|
||||
{
|
||||
private readonly ISqlInstruction i;
|
||||
|
||||
|
||||
public SqlInstructionDebuggerDisplay(ISqlInstruction i)
|
||||
{
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (i == null) return null;
|
||||
|
||||
var parts = i.ToString().Split('?');
|
||||
var result = new StringBuilder(parts[0]);
|
||||
var counter = 0;
|
||||
foreach (var p in i.GetParameters())
|
||||
{
|
||||
counter++;
|
||||
if (p == null)
|
||||
{
|
||||
result.Append("null");
|
||||
}
|
||||
else
|
||||
{
|
||||
var format = "{0}";
|
||||
if (p is DateTime || p is Guid || p is string) format = "'{0}'";
|
||||
result.AppendFormat(format, p);
|
||||
}
|
||||
if (counter < parts.Length) result.Append(parts[counter]);
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,430 +1,430 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlQuery : ISqlInstruction
|
||||
{
|
||||
private readonly List<ISqlInstruction> columns = new List<ISqlInstruction>();
|
||||
private readonly ArrayList groups = new ArrayList();
|
||||
private readonly List<JoinInfo> joins = new List<JoinInfo>();
|
||||
private readonly List<ISqlInstruction> tables = new List<ISqlInstruction>();
|
||||
private readonly List<UnionInfo> unions = new List<UnionInfo>();
|
||||
private bool distinct;
|
||||
private int firstResult;
|
||||
private Exp having;
|
||||
private int maxResults;
|
||||
protected IDictionary<object, bool> orders = new Dictionary<object, bool>();
|
||||
private bool selectAll;
|
||||
protected Exp where;
|
||||
private bool forupdate;
|
||||
private string index;
|
||||
|
||||
|
||||
public SqlQuery()
|
||||
{
|
||||
}
|
||||
|
||||
public SqlQuery(string table)
|
||||
{
|
||||
From(table);
|
||||
}
|
||||
|
||||
#region ISqlInstruction Members
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
|
||||
sql.Append("select ");
|
||||
if (distinct) sql.Append("distinct ");
|
||||
if (selectAll)
|
||||
{
|
||||
sql.Append("*");
|
||||
}
|
||||
else
|
||||
{
|
||||
columns.ForEach(column => sql.AppendFormat("{0}, ", column.ToString(dialect)));
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (0 < tables.Count)
|
||||
{
|
||||
sql.Append(" from ");
|
||||
tables.ForEach(table => sql.AppendFormat("{0}, ", table.ToString(dialect)));
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(index))
|
||||
{
|
||||
sql.AppendFormat(" {0}", dialect.UseIndex(index));
|
||||
}
|
||||
|
||||
if (0 < joins.Count)
|
||||
{
|
||||
foreach (JoinInfo join in joins)
|
||||
{
|
||||
if (join.JoinType == SqlJoin.Inner) sql.Append(" inner join ");
|
||||
if (join.JoinType == SqlJoin.LeftOuter) sql.Append(" left outer join ");
|
||||
if (join.JoinType == SqlJoin.RightOuter) sql.Append(" right outer join ");
|
||||
sql.AppendFormat("{0} on {1}", join.With.ToString(dialect), join.On.ToString(dialect));
|
||||
}
|
||||
}
|
||||
|
||||
if (where != Exp.Empty) sql.AppendFormat(" where {0}", where.ToString(dialect));
|
||||
|
||||
if (0 < groups.Count)
|
||||
{
|
||||
sql.Append(" group by ");
|
||||
foreach (object group in groups)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", group.ToString());
|
||||
}
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (having != Exp.Empty) sql.AppendFormat(" having {0}", having.ToString(dialect));
|
||||
|
||||
if (0 < orders.Count)
|
||||
{
|
||||
sql.Append(" order by ");
|
||||
foreach (var order in orders)
|
||||
{
|
||||
sql.Append(order.Key.ToString());
|
||||
sql.AppendFormat(" {0}, ", order.Value ? "asc" : "desc");
|
||||
}
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (0 < maxResults)
|
||||
{
|
||||
sql.AppendFormat(" limit {0}", maxResults);
|
||||
if (0 < firstResult) sql.AppendFormat(" offset {0}", firstResult);
|
||||
}
|
||||
|
||||
if (forupdate)
|
||||
{
|
||||
sql.Append(" for update");
|
||||
}
|
||||
|
||||
unions.ForEach(u => sql.AppendFormat(" union {0}{1}", u.UnionAll ? "all " : string.Empty, u.Query.ToString(dialect)));
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public object[] GetParameters()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
columns.ForEach(column => parameters.AddRange(column.GetParameters()));
|
||||
tables.ForEach(table => parameters.AddRange(table.GetParameters()));
|
||||
foreach (JoinInfo join in joins)
|
||||
{
|
||||
parameters.AddRange(join.With.GetParameters());
|
||||
parameters.AddRange(join.On.GetParameters());
|
||||
}
|
||||
if (where != Exp.Empty) parameters.AddRange(where.GetParameters());
|
||||
if (having != Exp.Empty) parameters.AddRange(having.GetParameters());
|
||||
unions.ForEach(u => parameters.AddRange(u.Query.GetParameters()));
|
||||
return parameters.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public SqlQuery From(params string[] tables)
|
||||
{
|
||||
Array.ForEach(tables, table => this.tables.Add((SqlIdentifier)table));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery From(SqlQuery subQuery)
|
||||
{
|
||||
return From(subQuery, null);
|
||||
}
|
||||
|
||||
public SqlQuery From(SqlQuery subQuery, string alias)
|
||||
{
|
||||
tables.Add(new AsExp(subQuery, alias));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery UseIndex(string index)
|
||||
{
|
||||
this.index = index;
|
||||
return this;
|
||||
}
|
||||
|
||||
private SqlQuery Join(SqlJoin join, ISqlInstruction instruction, Exp on)
|
||||
{
|
||||
joins.Add(new JoinInfo(join, instruction, on));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery InnerJoin(string table, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.Inner, new SqlIdentifier(table), on);
|
||||
}
|
||||
|
||||
public SqlQuery LeftOuterJoin(string table, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.LeftOuter, new SqlIdentifier(table), on);
|
||||
}
|
||||
|
||||
public SqlQuery RightOuterJoin(string table, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.RightOuter, new SqlIdentifier(table), on);
|
||||
}
|
||||
|
||||
public SqlQuery InnerJoin(SqlQuery subQuery, Exp on)
|
||||
{
|
||||
return InnerJoin(subQuery, string.Empty, on);
|
||||
}
|
||||
|
||||
public SqlQuery LeftOuterJoin(SqlQuery subQuery, Exp on)
|
||||
{
|
||||
return LeftOuterJoin(subQuery, string.Empty, on);
|
||||
}
|
||||
|
||||
public SqlQuery RightOuterJoin(SqlQuery subQuery, Exp on)
|
||||
{
|
||||
return RightOuterJoin(subQuery, string.Empty, on);
|
||||
}
|
||||
|
||||
public SqlQuery InnerJoin(SqlQuery subQuery, string alias, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.Inner, new AsExp(subQuery, alias), on);
|
||||
}
|
||||
|
||||
public SqlQuery LeftOuterJoin(SqlQuery subQuery, string alias, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.LeftOuter, new AsExp(subQuery, alias), on);
|
||||
}
|
||||
|
||||
public SqlQuery RightOuterJoin(SqlQuery subQuery, string alias, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.RightOuter, new AsExp(subQuery, alias), on);
|
||||
}
|
||||
|
||||
public SqlQuery Select(string column)
|
||||
{
|
||||
columns.Add((SqlIdentifier)column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Select(params string[] columns)
|
||||
{
|
||||
this.columns.AddRange(columns.Select(r => (SqlIdentifier)r));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Select(SqlQuery subQuery, string alias = null)
|
||||
{
|
||||
columns.Add(new AsExp(subQuery, alias));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Select(ISqlInstruction instraction)
|
||||
{
|
||||
columns.Add(instraction);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectAll()
|
||||
{
|
||||
selectAll = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectCount()
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.count));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectCount(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.count, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectMin(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.min, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectMax(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.max, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectAvg(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.avg, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectSum(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.sum, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Distinct()
|
||||
{
|
||||
distinct = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Where(Exp exp)
|
||||
{
|
||||
where = where & exp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Where(string sql)
|
||||
{
|
||||
return Where(new SqlExp(sql));
|
||||
}
|
||||
|
||||
public SqlQuery Where(string column, object value)
|
||||
{
|
||||
return Where(new EqExp(column, value));
|
||||
}
|
||||
|
||||
public SqlQuery OrderBy(string column, bool asc)
|
||||
{
|
||||
orders.Add(column, asc);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery OrderBy(int positin, bool asc)
|
||||
{
|
||||
orders.Add(positin, asc);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery GroupBy(params string[] columns)
|
||||
{
|
||||
groups.AddRange(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery GroupBy(params int[] positins)
|
||||
{
|
||||
groups.AddRange(positins);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Having(Exp having)
|
||||
{
|
||||
this.having = having;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SetFirstResult(int firstResult)
|
||||
{
|
||||
this.firstResult = firstResult;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SetMaxResults(int maxResults)
|
||||
{
|
||||
this.maxResults = maxResults;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Union(params SqlQuery[] queries)
|
||||
{
|
||||
foreach (var q in queries)
|
||||
{
|
||||
unions.Add(new UnionInfo(q, false));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery UnionAll(params SqlQuery[] queries)
|
||||
{
|
||||
foreach (var q in queries)
|
||||
{
|
||||
unions.Add(new UnionInfo(q, true));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery ForUpdate(bool forupdate)
|
||||
{
|
||||
this.forupdate = forupdate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
|
||||
private class JoinInfo
|
||||
{
|
||||
public readonly SqlJoin JoinType;
|
||||
public readonly Exp On;
|
||||
public readonly ISqlInstruction With;
|
||||
|
||||
public JoinInfo(SqlJoin joinType, ISqlInstruction with, Exp on)
|
||||
{
|
||||
With = with;
|
||||
JoinType = joinType;
|
||||
On = on;
|
||||
}
|
||||
}
|
||||
|
||||
private enum SqlJoin
|
||||
{
|
||||
LeftOuter,
|
||||
RightOuter,
|
||||
Inner
|
||||
}
|
||||
|
||||
private class UnionInfo
|
||||
{
|
||||
public readonly SqlQuery Query;
|
||||
public readonly bool UnionAll;
|
||||
|
||||
public UnionInfo(SqlQuery query, bool unionAll)
|
||||
{
|
||||
Query = query;
|
||||
UnionAll = unionAll;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlQuery : ISqlInstruction
|
||||
{
|
||||
private readonly List<ISqlInstruction> columns = new List<ISqlInstruction>();
|
||||
private readonly ArrayList groups = new ArrayList();
|
||||
private readonly List<JoinInfo> joins = new List<JoinInfo>();
|
||||
private readonly List<ISqlInstruction> tables = new List<ISqlInstruction>();
|
||||
private readonly List<UnionInfo> unions = new List<UnionInfo>();
|
||||
private bool distinct;
|
||||
private int firstResult;
|
||||
private Exp having;
|
||||
private int maxResults;
|
||||
protected IDictionary<object, bool> orders = new Dictionary<object, bool>();
|
||||
private bool selectAll;
|
||||
protected Exp where;
|
||||
private bool forupdate;
|
||||
private string index;
|
||||
|
||||
|
||||
public SqlQuery()
|
||||
{
|
||||
}
|
||||
|
||||
public SqlQuery(string table)
|
||||
{
|
||||
From(table);
|
||||
}
|
||||
|
||||
#region ISqlInstruction Members
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
|
||||
sql.Append("select ");
|
||||
if (distinct) sql.Append("distinct ");
|
||||
if (selectAll)
|
||||
{
|
||||
sql.Append("*");
|
||||
}
|
||||
else
|
||||
{
|
||||
columns.ForEach(column => sql.AppendFormat("{0}, ", column.ToString(dialect)));
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (0 < tables.Count)
|
||||
{
|
||||
sql.Append(" from ");
|
||||
tables.ForEach(table => sql.AppendFormat("{0}, ", table.ToString(dialect)));
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(index))
|
||||
{
|
||||
sql.AppendFormat(" {0}", dialect.UseIndex(index));
|
||||
}
|
||||
|
||||
if (0 < joins.Count)
|
||||
{
|
||||
foreach (JoinInfo join in joins)
|
||||
{
|
||||
if (join.JoinType == SqlJoin.Inner) sql.Append(" inner join ");
|
||||
if (join.JoinType == SqlJoin.LeftOuter) sql.Append(" left outer join ");
|
||||
if (join.JoinType == SqlJoin.RightOuter) sql.Append(" right outer join ");
|
||||
sql.AppendFormat("{0} on {1}", join.With.ToString(dialect), join.On.ToString(dialect));
|
||||
}
|
||||
}
|
||||
|
||||
if (where != Exp.Empty) sql.AppendFormat(" where {0}", where.ToString(dialect));
|
||||
|
||||
if (0 < groups.Count)
|
||||
{
|
||||
sql.Append(" group by ");
|
||||
foreach (object group in groups)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", group.ToString());
|
||||
}
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (having != Exp.Empty) sql.AppendFormat(" having {0}", having.ToString(dialect));
|
||||
|
||||
if (0 < orders.Count)
|
||||
{
|
||||
sql.Append(" order by ");
|
||||
foreach (var order in orders)
|
||||
{
|
||||
sql.Append(order.Key.ToString());
|
||||
sql.AppendFormat(" {0}, ", order.Value ? "asc" : "desc");
|
||||
}
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
}
|
||||
|
||||
if (0 < maxResults)
|
||||
{
|
||||
sql.AppendFormat(" limit {0}", maxResults);
|
||||
if (0 < firstResult) sql.AppendFormat(" offset {0}", firstResult);
|
||||
}
|
||||
|
||||
if (forupdate)
|
||||
{
|
||||
sql.Append(" for update");
|
||||
}
|
||||
|
||||
unions.ForEach(u => sql.AppendFormat(" union {0}{1}", u.UnionAll ? "all " : string.Empty, u.Query.ToString(dialect)));
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetParameters()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
columns.ForEach(column => parameters.AddRange(column.GetParameters()));
|
||||
tables.ForEach(table => parameters.AddRange(table.GetParameters()));
|
||||
foreach (JoinInfo join in joins)
|
||||
{
|
||||
parameters.AddRange(join.With.GetParameters());
|
||||
parameters.AddRange(join.On.GetParameters());
|
||||
}
|
||||
if (where != Exp.Empty) parameters.AddRange(where.GetParameters());
|
||||
if (having != Exp.Empty) parameters.AddRange(having.GetParameters());
|
||||
unions.ForEach(u => parameters.AddRange(u.Query.GetParameters()));
|
||||
return parameters;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public SqlQuery From(params string[] tables)
|
||||
{
|
||||
Array.ForEach(tables, table => this.tables.Add((SqlIdentifier)table));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery From(SqlQuery subQuery)
|
||||
{
|
||||
return From(subQuery, null);
|
||||
}
|
||||
|
||||
public SqlQuery From(SqlQuery subQuery, string alias)
|
||||
{
|
||||
tables.Add(new AsExp(subQuery, alias));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery UseIndex(string index)
|
||||
{
|
||||
this.index = index;
|
||||
return this;
|
||||
}
|
||||
|
||||
private SqlQuery Join(SqlJoin join, ISqlInstruction instruction, Exp on)
|
||||
{
|
||||
joins.Add(new JoinInfo(join, instruction, on));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery InnerJoin(string table, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.Inner, new SqlIdentifier(table), on);
|
||||
}
|
||||
|
||||
public SqlQuery LeftOuterJoin(string table, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.LeftOuter, new SqlIdentifier(table), on);
|
||||
}
|
||||
|
||||
public SqlQuery RightOuterJoin(string table, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.RightOuter, new SqlIdentifier(table), on);
|
||||
}
|
||||
|
||||
public SqlQuery InnerJoin(SqlQuery subQuery, Exp on)
|
||||
{
|
||||
return InnerJoin(subQuery, string.Empty, on);
|
||||
}
|
||||
|
||||
public SqlQuery LeftOuterJoin(SqlQuery subQuery, Exp on)
|
||||
{
|
||||
return LeftOuterJoin(subQuery, string.Empty, on);
|
||||
}
|
||||
|
||||
public SqlQuery RightOuterJoin(SqlQuery subQuery, Exp on)
|
||||
{
|
||||
return RightOuterJoin(subQuery, string.Empty, on);
|
||||
}
|
||||
|
||||
public SqlQuery InnerJoin(SqlQuery subQuery, string alias, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.Inner, new AsExp(subQuery, alias), on);
|
||||
}
|
||||
|
||||
public SqlQuery LeftOuterJoin(SqlQuery subQuery, string alias, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.LeftOuter, new AsExp(subQuery, alias), on);
|
||||
}
|
||||
|
||||
public SqlQuery RightOuterJoin(SqlQuery subQuery, string alias, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.RightOuter, new AsExp(subQuery, alias), on);
|
||||
}
|
||||
|
||||
public SqlQuery Select(string column)
|
||||
{
|
||||
columns.Add((SqlIdentifier)column);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Select(params string[] columns)
|
||||
{
|
||||
this.columns.AddRange(columns.Select(r => (SqlIdentifier)r));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Select(SqlQuery subQuery, string alias = null)
|
||||
{
|
||||
columns.Add(new AsExp(subQuery, alias));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Select(ISqlInstruction instraction)
|
||||
{
|
||||
columns.Add(instraction);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectAll()
|
||||
{
|
||||
selectAll = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectCount()
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.count));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectCount(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.count, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectMin(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.min, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectMax(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.max, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectAvg(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.avg, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SelectSum(string column)
|
||||
{
|
||||
selectAll = false;
|
||||
columns.Add(new SelectAgregate(AgregateType.sum, column));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Distinct()
|
||||
{
|
||||
distinct = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Where(Exp exp)
|
||||
{
|
||||
where = where & exp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Where(string sql)
|
||||
{
|
||||
return Where(new SqlExp(sql));
|
||||
}
|
||||
|
||||
public SqlQuery Where(string column, object value)
|
||||
{
|
||||
return Where(new EqExp(column, value));
|
||||
}
|
||||
|
||||
public SqlQuery OrderBy(string column, bool asc)
|
||||
{
|
||||
orders.Add(column, asc);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery OrderBy(int positin, bool asc)
|
||||
{
|
||||
orders.Add(positin, asc);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery GroupBy(params string[] columns)
|
||||
{
|
||||
groups.AddRange(columns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery GroupBy(params int[] positins)
|
||||
{
|
||||
groups.AddRange(positins);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Having(Exp having)
|
||||
{
|
||||
this.having = having;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SetFirstResult(int firstResult)
|
||||
{
|
||||
this.firstResult = firstResult;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery SetMaxResults(int maxResults)
|
||||
{
|
||||
this.maxResults = maxResults;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery Union(params SqlQuery[] queries)
|
||||
{
|
||||
foreach (var q in queries)
|
||||
{
|
||||
unions.Add(new UnionInfo(q, false));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery UnionAll(params SqlQuery[] queries)
|
||||
{
|
||||
foreach (var q in queries)
|
||||
{
|
||||
unions.Add(new UnionInfo(q, true));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlQuery ForUpdate(bool forupdate)
|
||||
{
|
||||
this.forupdate = forupdate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
|
||||
private class JoinInfo
|
||||
{
|
||||
public readonly SqlJoin JoinType;
|
||||
public readonly Exp On;
|
||||
public readonly ISqlInstruction With;
|
||||
|
||||
public JoinInfo(SqlJoin joinType, ISqlInstruction with, Exp on)
|
||||
{
|
||||
With = with;
|
||||
JoinType = joinType;
|
||||
On = on;
|
||||
}
|
||||
}
|
||||
|
||||
private enum SqlJoin
|
||||
{
|
||||
LeftOuter,
|
||||
RightOuter,
|
||||
Inner
|
||||
}
|
||||
|
||||
private class UnionInfo
|
||||
{
|
||||
public readonly SqlQuery Query;
|
||||
public readonly bool UnionAll;
|
||||
|
||||
public UnionInfo(SqlQuery query, bool unionAll)
|
||||
{
|
||||
Query = query;
|
||||
UnionAll = unionAll;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,171 +1,171 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlUpdate : ISqlInstruction
|
||||
{
|
||||
private readonly List<string> expressions = new List<string>();
|
||||
private readonly List<JoinInfo> joins = new List<JoinInfo>();
|
||||
private readonly Dictionary<string, object> sets = new Dictionary<string, object>();
|
||||
private readonly SqlIdentifier table;
|
||||
private Exp where = Exp.Empty;
|
||||
|
||||
public SqlUpdate(string table)
|
||||
{
|
||||
this.table = (SqlIdentifier)table;
|
||||
}
|
||||
|
||||
#region ISqlInstruction Members
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
|
||||
if (0 < joins.Count)
|
||||
{
|
||||
sql.AppendFormat("update {0}", table.ToString(dialect));
|
||||
|
||||
foreach (var join in joins)
|
||||
{
|
||||
if (@join.JoinType == SqlJoin.Inner) sql.Append(" inner join ");
|
||||
if (@join.JoinType == SqlJoin.LeftOuter) sql.Append(" left outer join ");
|
||||
if (@join.JoinType == SqlJoin.RightOuter) sql.Append(" right outer join ");
|
||||
sql.AppendFormat("{0} on {1}", @join.With.ToString(dialect), @join.On.ToString(dialect));
|
||||
}
|
||||
|
||||
sql.Append(" set ");
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.AppendFormat("update {0} set ", table.ToString(dialect));
|
||||
}
|
||||
|
||||
foreach (var set in sets)
|
||||
{
|
||||
sql.AppendFormat("{0} = {1}, ", set.Key, set.Value is ISqlInstruction ? ((ISqlInstruction)set.Value).ToString(dialect) : "?");
|
||||
}
|
||||
expressions.ForEach(expression => sql.AppendFormat("{0}, ", expression));
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
if (where != Exp.Empty) sql.AppendFormat(" where {0}", where.ToString(dialect));
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public object[] GetParameters()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
foreach (var join in joins)
|
||||
{
|
||||
parameters.AddRange(@join.With.GetParameters());
|
||||
parameters.AddRange(@join.On.GetParameters());
|
||||
}
|
||||
|
||||
foreach (object parameter in sets.Values)
|
||||
{
|
||||
if (parameter is ISqlInstruction)
|
||||
{
|
||||
parameters.AddRange(((ISqlInstruction)parameter).GetParameters());
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
if (where != Exp.Empty) parameters.AddRange(where.GetParameters());
|
||||
return parameters.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private SqlUpdate Join(SqlJoin join, ISqlInstruction instruction, Exp on)
|
||||
{
|
||||
joins.Add(new JoinInfo(join, instruction, on));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate InnerJoin(string tableName, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.Inner, new SqlIdentifier(tableName), on);
|
||||
}
|
||||
|
||||
public SqlUpdate LeftOuterJoin(string tableName, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.LeftOuter, new SqlIdentifier(tableName), on);
|
||||
}
|
||||
|
||||
public SqlUpdate RightOuterJoin(string tableName, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.RightOuter, new SqlIdentifier(tableName), on);
|
||||
}
|
||||
|
||||
public SqlUpdate Set(string expression)
|
||||
{
|
||||
expressions.Add(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate Set(string column, object value)
|
||||
{
|
||||
sets[column] = value is SqlQuery ? new AsExp((SqlQuery)value) : value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate Where(Exp where)
|
||||
{
|
||||
this.where = this.where & where;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate Where(string column, object value)
|
||||
{
|
||||
return Where(Exp.Eq(column, value));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
private class JoinInfo
|
||||
{
|
||||
public SqlJoin JoinType { get; private set; }
|
||||
public Exp On { get; private set; }
|
||||
public ISqlInstruction With { get; private set; }
|
||||
|
||||
public JoinInfo(SqlJoin joinType, ISqlInstruction with, Exp on)
|
||||
{
|
||||
With = with;
|
||||
JoinType = joinType;
|
||||
On = on;
|
||||
}
|
||||
}
|
||||
|
||||
private enum SqlJoin
|
||||
{
|
||||
LeftOuter,
|
||||
RightOuter,
|
||||
Inner
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
|
||||
namespace ASC.Common.Data.Sql
|
||||
{
|
||||
[DebuggerTypeProxy(typeof(SqlDebugView))]
|
||||
public class SqlUpdate : ISqlInstruction
|
||||
{
|
||||
private readonly List<string> expressions = new List<string>();
|
||||
private readonly List<JoinInfo> joins = new List<JoinInfo>();
|
||||
private readonly Dictionary<string, object> sets = new Dictionary<string, object>();
|
||||
private readonly SqlIdentifier table;
|
||||
private Exp where = Exp.Empty;
|
||||
|
||||
public SqlUpdate(string table)
|
||||
{
|
||||
this.table = (SqlIdentifier)table;
|
||||
}
|
||||
|
||||
#region ISqlInstruction Members
|
||||
|
||||
public string ToString(ISqlDialect dialect)
|
||||
{
|
||||
var sql = new StringBuilder();
|
||||
|
||||
if (0 < joins.Count)
|
||||
{
|
||||
sql.AppendFormat("update {0}", table.ToString(dialect));
|
||||
|
||||
foreach (var join in joins)
|
||||
{
|
||||
if (@join.JoinType == SqlJoin.Inner) sql.Append(" inner join ");
|
||||
if (@join.JoinType == SqlJoin.LeftOuter) sql.Append(" left outer join ");
|
||||
if (@join.JoinType == SqlJoin.RightOuter) sql.Append(" right outer join ");
|
||||
sql.AppendFormat("{0} on {1}", @join.With.ToString(dialect), @join.On.ToString(dialect));
|
||||
}
|
||||
|
||||
sql.Append(" set ");
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.AppendFormat("update {0} set ", table.ToString(dialect));
|
||||
}
|
||||
|
||||
foreach (var set in sets)
|
||||
{
|
||||
sql.AppendFormat("{0} = {1}, ", set.Key, set.Value is ISqlInstruction ? ((ISqlInstruction)set.Value).ToString(dialect) : "?");
|
||||
}
|
||||
expressions.ForEach(expression => sql.AppendFormat("{0}, ", expression));
|
||||
sql.Remove(sql.Length - 2, 2);
|
||||
if (where != Exp.Empty) sql.AppendFormat(" where {0}", where.ToString(dialect));
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public IEnumerable<object> GetParameters()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
foreach (var join in joins)
|
||||
{
|
||||
parameters.AddRange(@join.With.GetParameters());
|
||||
parameters.AddRange(@join.On.GetParameters());
|
||||
}
|
||||
|
||||
foreach (object parameter in sets.Values)
|
||||
{
|
||||
if (parameter is ISqlInstruction)
|
||||
{
|
||||
parameters.AddRange(((ISqlInstruction)parameter).GetParameters());
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
if (where != Exp.Empty) parameters.AddRange(where.GetParameters());
|
||||
return parameters;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private SqlUpdate Join(SqlJoin join, ISqlInstruction instruction, Exp on)
|
||||
{
|
||||
joins.Add(new JoinInfo(join, instruction, on));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate InnerJoin(string tableName, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.Inner, new SqlIdentifier(tableName), on);
|
||||
}
|
||||
|
||||
public SqlUpdate LeftOuterJoin(string tableName, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.LeftOuter, new SqlIdentifier(tableName), on);
|
||||
}
|
||||
|
||||
public SqlUpdate RightOuterJoin(string tableName, Exp on)
|
||||
{
|
||||
return Join(SqlJoin.RightOuter, new SqlIdentifier(tableName), on);
|
||||
}
|
||||
|
||||
public SqlUpdate Set(string expression)
|
||||
{
|
||||
expressions.Add(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate Set(string column, object value)
|
||||
{
|
||||
sets[column] = value is SqlQuery ? new AsExp((SqlQuery)value) : value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate Where(Exp where)
|
||||
{
|
||||
this.where = this.where & where;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlUpdate Where(string column, object value)
|
||||
{
|
||||
return Where(Exp.Eq(column, value));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(SqlDialect.Default);
|
||||
}
|
||||
|
||||
private class JoinInfo
|
||||
{
|
||||
public SqlJoin JoinType { get; private set; }
|
||||
public Exp On { get; private set; }
|
||||
public ISqlInstruction With { get; private set; }
|
||||
|
||||
public JoinInfo(SqlJoin joinType, ISqlInstruction with, Exp on)
|
||||
{
|
||||
With = with;
|
||||
JoinType = joinType;
|
||||
On = on;
|
||||
}
|
||||
}
|
||||
|
||||
private enum SqlJoin
|
||||
{
|
||||
LeftOuter,
|
||||
RightOuter,
|
||||
Inner
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +1,39 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public static class StreamExtension
|
||||
{
|
||||
private const int BufferSize = 2048; //NOTE: set to 2048 to fit in minimum tcp window
|
||||
|
||||
public static void StreamCopyTo(this Stream srcStream, Stream dstStream, int length)
|
||||
{
|
||||
if (srcStream == null) throw new ArgumentNullException("srcStream");
|
||||
if (dstStream == null) throw new ArgumentNullException("dstStream");
|
||||
|
||||
var buffer = new byte[BufferSize];
|
||||
int totalRead = 0;
|
||||
int readed;
|
||||
while ((readed = srcStream.Read(buffer, 0, length - totalRead > BufferSize ? BufferSize : length - totalRead)) > 0 && totalRead < length)
|
||||
{
|
||||
dstStream.Write(buffer, 0, readed);
|
||||
totalRead += readed;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public static class StreamExtension
|
||||
{
|
||||
private const int BufferSize = 2048; //NOTE: set to 2048 to fit in minimum tcp window
|
||||
|
||||
public static void StreamCopyTo(this Stream srcStream, Stream dstStream, int length)
|
||||
{
|
||||
if (srcStream == null) throw new ArgumentNullException("srcStream");
|
||||
if (dstStream == null) throw new ArgumentNullException("dstStream");
|
||||
|
||||
var buffer = new byte[BufferSize];
|
||||
int totalRead = 0;
|
||||
int readed;
|
||||
while ((readed = srcStream.Read(buffer, 0, length - totalRead > BufferSize ? BufferSize : length - totalRead)) > 0 && totalRead < length)
|
||||
{
|
||||
dstStream.Write(buffer, 0, readed);
|
||||
totalRead += readed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,90 +1,90 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
public static class TempPath
|
||||
{
|
||||
static readonly string tempFolder;
|
||||
|
||||
static TempPath()
|
||||
{
|
||||
string rootFolder;
|
||||
|
||||
if (AppDomain.CurrentDomain != null)
|
||||
{
|
||||
rootFolder = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
rootFolder = Assembly.GetEntryAssembly().Location;
|
||||
}
|
||||
|
||||
tempFolder = ConfigurationManager.AppSettings["temp"] ?? Path.Combine("..", "Data", "temp");
|
||||
|
||||
if (!Path.IsPathRooted(tempFolder))
|
||||
{
|
||||
tempFolder = Path.GetFullPath(Path.Combine(rootFolder, tempFolder));
|
||||
}
|
||||
|
||||
if (!Directory.Exists(tempFolder))
|
||||
{
|
||||
Directory.CreateDirectory(tempFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTempPath()
|
||||
{
|
||||
return tempFolder;
|
||||
}
|
||||
|
||||
public static string GetTempFileName()
|
||||
{
|
||||
FileStream f = null;
|
||||
string path;
|
||||
var count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
path = Path.Combine(tempFolder, Path.GetRandomFileName());
|
||||
|
||||
try
|
||||
{
|
||||
using (f = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.Read))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ex.HResult != -2147024816 || count++ > 65536)
|
||||
throw;
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
if (count++ > 65536)
|
||||
throw new IOException(ex.Message, ex);
|
||||
}
|
||||
} while (f == null);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
public static class TempPath
|
||||
{
|
||||
static readonly string tempFolder;
|
||||
|
||||
static TempPath()
|
||||
{
|
||||
string rootFolder;
|
||||
|
||||
if (AppDomain.CurrentDomain != null)
|
||||
{
|
||||
rootFolder = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
rootFolder = Assembly.GetEntryAssembly().Location;
|
||||
}
|
||||
|
||||
tempFolder = ConfigurationManager.AppSettings["temp"] ?? Path.Combine("..", "Data", "temp");
|
||||
|
||||
if (!Path.IsPathRooted(tempFolder))
|
||||
{
|
||||
tempFolder = Path.GetFullPath(Path.Combine(rootFolder, tempFolder));
|
||||
}
|
||||
|
||||
if (!Directory.Exists(tempFolder))
|
||||
{
|
||||
Directory.CreateDirectory(tempFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTempPath()
|
||||
{
|
||||
return tempFolder;
|
||||
}
|
||||
|
||||
public static string GetTempFileName()
|
||||
{
|
||||
FileStream f = null;
|
||||
string path;
|
||||
var count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
path = Path.Combine(tempFolder, Path.GetRandomFileName());
|
||||
|
||||
try
|
||||
{
|
||||
using (f = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.Read))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ex.HResult != -2147024816 || count++ > 65536)
|
||||
throw;
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
if (count++ > 65536)
|
||||
throw new IOException(ex.Message, ex);
|
||||
}
|
||||
} while (f == null);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,44 +1,44 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ASC.Common
|
||||
{
|
||||
public static class TempStream
|
||||
{
|
||||
public static Stream GetBuffered(this Stream srcStream)
|
||||
{
|
||||
if (srcStream == null) throw new ArgumentNullException("srcStream");
|
||||
if (!srcStream.CanSeek || srcStream.CanTimeout)
|
||||
{
|
||||
//Buffer it
|
||||
var memStream = Create();
|
||||
srcStream.CopyTo(memStream);
|
||||
memStream.Position = 0;
|
||||
return memStream;
|
||||
}
|
||||
return srcStream;
|
||||
}
|
||||
|
||||
public static Stream Create()
|
||||
{
|
||||
return new FileStream(TempPath.GetTempFileName(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, 4096, FileOptions.DeleteOnClose);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ASC.Common
|
||||
{
|
||||
public static class TempStream
|
||||
{
|
||||
public static Stream GetBuffered(this Stream srcStream)
|
||||
{
|
||||
if (srcStream == null) throw new ArgumentNullException("srcStream");
|
||||
if (!srcStream.CanSeek || srcStream.CanTimeout)
|
||||
{
|
||||
//Buffer it
|
||||
var memStream = Create();
|
||||
srcStream.CopyTo(memStream);
|
||||
memStream.Position = 0;
|
||||
return memStream;
|
||||
}
|
||||
return srcStream;
|
||||
}
|
||||
|
||||
public static Stream Create()
|
||||
{
|
||||
return new FileStream(TempPath.GetTempFileName(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, 4096, FileOptions.DeleteOnClose);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,112 +1,112 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
using Autofac;
|
||||
|
||||
namespace ASC.Common.DependencyInjection
|
||||
{
|
||||
public class AutofacConfigLoader
|
||||
{
|
||||
public static ContainerBuilder Load(string containerName, string section = "autofac")
|
||||
{
|
||||
var container = new ContainerBuilder();
|
||||
|
||||
var autofacConfigurationSection = (AutofacConfigurationSection)ConfigurationManagerExtension.GetSection(section);
|
||||
|
||||
if (autofacConfigurationSection == null) return null;
|
||||
|
||||
foreach (var component in autofacConfigurationSection.GetComponents(containerName))
|
||||
{
|
||||
var componentType = Type.GetType(component.Type);
|
||||
if (componentType == null) continue;
|
||||
|
||||
var builder = container.RegisterType(componentType).AsSelf();
|
||||
|
||||
if (!string.IsNullOrEmpty(component.Service))
|
||||
{
|
||||
var serviceType = Type.GetType(component.Service);
|
||||
builder.As(serviceType);
|
||||
|
||||
if (!string.IsNullOrEmpty(component.Name))
|
||||
{
|
||||
builder.Named(component.Name, serviceType)
|
||||
.Named(component.Name.ToLower(), serviceType);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(component.Name))
|
||||
{
|
||||
builder.Named(component.Name, componentType)
|
||||
.Named(component.Name.ToLower(), componentType);
|
||||
}
|
||||
|
||||
if (component.Parameters != null && component.Parameters.Count > 0)
|
||||
{
|
||||
foreach (var parameter in component.Parameters)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(parameter.Type))
|
||||
{
|
||||
var parameterType = Type.GetType(parameter.Type);
|
||||
var parameterName = parameter.Name;
|
||||
if (parameterType == null) continue;
|
||||
|
||||
builder.WithParameter(
|
||||
(pi, ctx) => parameterType.IsSubclassOf(pi.ParameterType) && pi.Name == parameterName,
|
||||
(pi, ctx) => Activator.CreateInstance(parameterType));
|
||||
}
|
||||
else if (parameter.List != null && parameter.List.Any())
|
||||
{
|
||||
builder.WithParameter(new NamedParameter(parameter.Name, parameter.List.Select(r => r.Value).ToArray()));
|
||||
}
|
||||
else if (parameter.Dictionary != null && parameter.Dictionary.Any())
|
||||
{
|
||||
builder.WithParameter(new NamedParameter(parameter.Name, parameter.Dictionary.ToDictionary(r => r.Key, r => r.Value)));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.WithParameter(new NamedParameter(parameter.Name, parameter.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (component.InstanceScope)
|
||||
{
|
||||
case "single-instance":
|
||||
builder.SingleInstance();
|
||||
break;
|
||||
case "per-lifetime-scope":
|
||||
builder.InstancePerLifetimeScope();
|
||||
break;
|
||||
case "per-request":
|
||||
builder.InstancePerRequest();
|
||||
break;
|
||||
}
|
||||
|
||||
if (component.InjectProperties == "yes")
|
||||
{
|
||||
builder.PropertiesAutowired();
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
using Autofac;
|
||||
|
||||
namespace ASC.Common.DependencyInjection
|
||||
{
|
||||
public class AutofacConfigLoader
|
||||
{
|
||||
public static ContainerBuilder Load(string containerName, string section = "autofac")
|
||||
{
|
||||
var container = new ContainerBuilder();
|
||||
|
||||
var autofacConfigurationSection = (AutofacConfigurationSection)ConfigurationManagerExtension.GetSection(section);
|
||||
|
||||
if (autofacConfigurationSection == null) return null;
|
||||
|
||||
foreach (var component in autofacConfigurationSection.GetComponents(containerName))
|
||||
{
|
||||
var componentType = Type.GetType(component.Type);
|
||||
if (componentType == null) continue;
|
||||
|
||||
var builder = container.RegisterType(componentType).AsSelf();
|
||||
|
||||
if (!string.IsNullOrEmpty(component.Service))
|
||||
{
|
||||
var serviceType = Type.GetType(component.Service);
|
||||
builder.As(serviceType);
|
||||
|
||||
if (!string.IsNullOrEmpty(component.Name))
|
||||
{
|
||||
builder.Named(component.Name, serviceType)
|
||||
.Named(component.Name.ToLower(), serviceType);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(component.Name))
|
||||
{
|
||||
builder.Named(component.Name, componentType)
|
||||
.Named(component.Name.ToLower(), componentType);
|
||||
}
|
||||
|
||||
if (component.Parameters != null && component.Parameters.Count > 0)
|
||||
{
|
||||
foreach (var parameter in component.Parameters)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(parameter.Type))
|
||||
{
|
||||
var parameterType = Type.GetType(parameter.Type);
|
||||
var parameterName = parameter.Name;
|
||||
if (parameterType == null) continue;
|
||||
|
||||
builder.WithParameter(
|
||||
(pi, ctx) => parameterType.IsSubclassOf(pi.ParameterType) && pi.Name == parameterName,
|
||||
(pi, ctx) => Activator.CreateInstance(parameterType));
|
||||
}
|
||||
else if (parameter.List != null && parameter.List.Any())
|
||||
{
|
||||
builder.WithParameter(new NamedParameter(parameter.Name, parameter.List.Select(r => r.Value).ToArray()));
|
||||
}
|
||||
else if (parameter.Dictionary != null && parameter.Dictionary.Any())
|
||||
{
|
||||
builder.WithParameter(new NamedParameter(parameter.Name, parameter.Dictionary.ToDictionary(r => r.Key, r => r.Value)));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.WithParameter(new NamedParameter(parameter.Name, parameter.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (component.InstanceScope)
|
||||
{
|
||||
case "single-instance":
|
||||
builder.SingleInstance();
|
||||
break;
|
||||
case "per-lifetime-scope":
|
||||
builder.InstancePerLifetimeScope();
|
||||
break;
|
||||
case "per-request":
|
||||
builder.InstancePerRequest();
|
||||
break;
|
||||
}
|
||||
|
||||
if (component.InjectProperties == "yes")
|
||||
{
|
||||
builder.PropertiesAutowired();
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,126 +1,126 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
using ASC.Common.Data;
|
||||
using ASC.Common.Data.Sql;
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
using ASC.Common.Logging;
|
||||
|
||||
namespace ASC.Geolocation
|
||||
{
|
||||
public class GeolocationHelper
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger("ASC.Geo");
|
||||
|
||||
private readonly string dbid;
|
||||
|
||||
|
||||
public GeolocationHelper(string dbid)
|
||||
{
|
||||
this.dbid = dbid;
|
||||
}
|
||||
|
||||
|
||||
public IPGeolocationInfo GetIPGeolocation(string ip)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ipformatted = FormatIP(ip);
|
||||
using (var db = new DbManager(dbid))
|
||||
{
|
||||
var q = new SqlQuery("dbip_location")
|
||||
.Select("ip_start", "ip_end", "country", "city", "timezone_offset", "timezone_name")
|
||||
.Where(Exp.Le("ip_start", ipformatted))
|
||||
.OrderBy("ip_start", false)
|
||||
.SetMaxResults(1);
|
||||
return db
|
||||
.ExecuteList(q)
|
||||
.Select(r => new IPGeolocationInfo()
|
||||
{
|
||||
IPStart = Convert.ToString(r[0]),
|
||||
IPEnd = Convert.ToString(r[1]),
|
||||
Key = Convert.ToString(r[2]),
|
||||
City = Convert.ToString(r[3]),
|
||||
TimezoneOffset = Convert.ToDouble(r[4]),
|
||||
TimezoneName = Convert.ToString(r[5])
|
||||
})
|
||||
.SingleOrDefault(i => ipformatted.CompareTo(i.IPEnd) <= 0) ??
|
||||
IPGeolocationInfo.Default;
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
log.Error(error);
|
||||
}
|
||||
return IPGeolocationInfo.Default;
|
||||
}
|
||||
|
||||
public IPGeolocationInfo GetIPGeolocationFromHttpContext()
|
||||
{
|
||||
return GetIPGeolocationFromHttpContext(HttpContext.Current);
|
||||
}
|
||||
|
||||
public IPGeolocationInfo GetIPGeolocationFromHttpContext(HttpContext context)
|
||||
{
|
||||
if (context != null && context.Request != null)
|
||||
{
|
||||
var ip = context.Request.Headers["X-Forwarded-For"] ?? context.Request.ServerVariables["REMOTE_ADDR"];
|
||||
if (!string.IsNullOrWhiteSpace(ip))
|
||||
{
|
||||
return GetIPGeolocation(ip);
|
||||
}
|
||||
}
|
||||
return IPGeolocationInfo.Default;
|
||||
}
|
||||
|
||||
private static string FormatIP(string ip)
|
||||
{
|
||||
ip = (ip ?? "").Trim();
|
||||
if (ip.Contains('.'))
|
||||
{
|
||||
//ip v4
|
||||
if (ip.Length == 15)
|
||||
{
|
||||
return ip;
|
||||
}
|
||||
return string.Join(".", ip.Split(':')[0].Split('.').Select(s => ("00" + s).Substring(s.Length - 1)).ToArray());
|
||||
}
|
||||
else if (ip.Contains(':'))
|
||||
{
|
||||
//ip v6
|
||||
if (ip.Length == 39)
|
||||
{
|
||||
return ip;
|
||||
}
|
||||
var index = ip.IndexOf("::");
|
||||
if (0 <= index)
|
||||
{
|
||||
ip = ip.Insert(index + 2, new String(':', 8 - ip.Split(':').Length));
|
||||
}
|
||||
return string.Join(":", ip.Split(':').Select(s => ("0000" + s).Substring(s.Length)).ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Unknown ip " + ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
using ASC.Common.Data;
|
||||
using ASC.Common.Data.Sql;
|
||||
using ASC.Common.Data.Sql.Expressions;
|
||||
using ASC.Common.Logging;
|
||||
|
||||
namespace ASC.Geolocation
|
||||
{
|
||||
public class GeolocationHelper
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger("ASC.Geo");
|
||||
|
||||
private readonly string dbid;
|
||||
|
||||
|
||||
public GeolocationHelper(string dbid)
|
||||
{
|
||||
this.dbid = dbid;
|
||||
}
|
||||
|
||||
|
||||
public IPGeolocationInfo GetIPGeolocation(string ip)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ipformatted = FormatIP(ip);
|
||||
using (var db = DbManager.FromHttpContext(dbid))
|
||||
{
|
||||
var q = new SqlQuery("dbip_location")
|
||||
.Select("ip_start", "ip_end", "country", "city", "timezone_offset", "timezone_name")
|
||||
.Where(Exp.Le("ip_start", ipformatted))
|
||||
.OrderBy("ip_start", false)
|
||||
.SetMaxResults(1);
|
||||
return db
|
||||
.ExecuteList(q)
|
||||
.Select(r => new IPGeolocationInfo()
|
||||
{
|
||||
IPStart = Convert.ToString(r[0]),
|
||||
IPEnd = Convert.ToString(r[1]),
|
||||
Key = Convert.ToString(r[2]),
|
||||
City = Convert.ToString(r[3]),
|
||||
TimezoneOffset = Convert.ToDouble(r[4]),
|
||||
TimezoneName = Convert.ToString(r[5])
|
||||
})
|
||||
.SingleOrDefault(i => ipformatted.CompareTo(i.IPEnd) <= 0) ??
|
||||
IPGeolocationInfo.Default;
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
log.Error(error);
|
||||
}
|
||||
return IPGeolocationInfo.Default;
|
||||
}
|
||||
|
||||
public IPGeolocationInfo GetIPGeolocationFromHttpContext()
|
||||
{
|
||||
return GetIPGeolocationFromHttpContext(HttpContext.Current);
|
||||
}
|
||||
|
||||
public IPGeolocationInfo GetIPGeolocationFromHttpContext(HttpContext context)
|
||||
{
|
||||
if (context != null && context.Request != null)
|
||||
{
|
||||
var ip = context.Request.Headers["X-Forwarded-For"] ?? context.Request.ServerVariables["REMOTE_ADDR"];
|
||||
if (!string.IsNullOrWhiteSpace(ip))
|
||||
{
|
||||
return GetIPGeolocation(ip);
|
||||
}
|
||||
}
|
||||
return IPGeolocationInfo.Default;
|
||||
}
|
||||
|
||||
private static string FormatIP(string ip)
|
||||
{
|
||||
ip = (ip ?? "").Trim();
|
||||
if (ip.Contains('.'))
|
||||
{
|
||||
//ip v4
|
||||
if (ip.Length == 15)
|
||||
{
|
||||
return ip;
|
||||
}
|
||||
return string.Join(".", ip.Split(':')[0].Split('.').Select(s => ("00" + s).Substring(s.Length - 1)).ToArray());
|
||||
}
|
||||
else if (ip.Contains(':'))
|
||||
{
|
||||
//ip v6
|
||||
if (ip.Length == 39)
|
||||
{
|
||||
return ip;
|
||||
}
|
||||
var index = ip.IndexOf("::");
|
||||
if (0 <= index)
|
||||
{
|
||||
ip = ip.Insert(index + 2, new String(':', 8 - ip.Split(':').Length));
|
||||
}
|
||||
return string.Join(":", ip.Split(':').Select(s => ("0000" + s).Substring(s.Length)).ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Unknown ip " + ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +1,43 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.Geolocation
|
||||
{
|
||||
public class IPGeolocationInfo
|
||||
{
|
||||
public string Key { get; set; }
|
||||
|
||||
public string City { get; set; }
|
||||
|
||||
public double TimezoneOffset { get; set; }
|
||||
|
||||
public string TimezoneName { get; set; }
|
||||
|
||||
public string IPStart { get; set; }
|
||||
|
||||
public string IPEnd { get; set; }
|
||||
|
||||
|
||||
public readonly static IPGeolocationInfo Default = new IPGeolocationInfo
|
||||
{
|
||||
Key = string.Empty,
|
||||
IPStart = string.Empty,
|
||||
IPEnd = string.Empty,
|
||||
City = string.Empty,
|
||||
TimezoneName = string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ASC.Geolocation
|
||||
{
|
||||
public class IPGeolocationInfo
|
||||
{
|
||||
public string Key { get; set; }
|
||||
|
||||
public string City { get; set; }
|
||||
|
||||
public double TimezoneOffset { get; set; }
|
||||
|
||||
public string TimezoneName { get; set; }
|
||||
|
||||
public string IPStart { get; set; }
|
||||
|
||||
public string IPEnd { get; set; }
|
||||
|
||||
|
||||
public readonly static IPGeolocationInfo Default = new IPGeolocationInfo
|
||||
{
|
||||
Key = string.Empty,
|
||||
IPStart = string.Empty,
|
||||
IPEnd = string.Empty,
|
||||
City = string.Empty,
|
||||
TimezoneName = string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,91 +1,91 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using log4net.Util;
|
||||
|
||||
namespace ASC.Common.Logging
|
||||
{
|
||||
public class SpecialFolderPathConverter : PatternConverter
|
||||
{
|
||||
protected override void Convert(TextWriter writer, object state)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Option))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var result = string.Empty;
|
||||
const string CMD_LINE = "CommandLine:";
|
||||
if (Option.StartsWith(CMD_LINE))
|
||||
{
|
||||
var args = Environment.CommandLine.Split(' ');
|
||||
for (var i = 0; i < args.Length - 1; i++)
|
||||
{
|
||||
if (args[i].Equals(Option.Substring(CMD_LINE.Length), StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
result = args[i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var repo = log4net.LogManager.GetRepository();
|
||||
if (repo != null)
|
||||
{
|
||||
var realKey = Option;
|
||||
foreach (var key in repo.Properties.GetKeys())
|
||||
{
|
||||
if (Path.DirectorySeparatorChar == '/' && key == "UNIX:" + Option)
|
||||
{
|
||||
realKey = "UNIX:" + Option;
|
||||
}
|
||||
if (Path.DirectorySeparatorChar == '\\' && key == "WINDOWS:" + Option)
|
||||
{
|
||||
realKey = "WINDOWS:" + Option;
|
||||
}
|
||||
}
|
||||
|
||||
var val = repo.Properties[realKey];
|
||||
if (val is PatternString)
|
||||
{
|
||||
((PatternString)val).ActivateOptions();
|
||||
((PatternString)val).Format(writer);
|
||||
}
|
||||
else if (val != null)
|
||||
{
|
||||
result = val.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
result = result.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
|
||||
writer.Write(result);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LogLog.Error(GetType(), "Can not convert " + Option, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using log4net.Util;
|
||||
|
||||
namespace ASC.Common.Logging
|
||||
{
|
||||
public class SpecialFolderPathConverter : PatternConverter
|
||||
{
|
||||
protected override void Convert(TextWriter writer, object state)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Option))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var result = string.Empty;
|
||||
const string CMD_LINE = "CommandLine:";
|
||||
if (Option.StartsWith(CMD_LINE))
|
||||
{
|
||||
var args = Environment.CommandLine.Split(' ');
|
||||
for (var i = 0; i < args.Length - 1; i++)
|
||||
{
|
||||
if (args[i].Equals(Option.Substring(CMD_LINE.Length), StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
result = args[i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var repo = log4net.LogManager.GetRepository();
|
||||
if (repo != null)
|
||||
{
|
||||
var realKey = Option;
|
||||
foreach (var key in repo.Properties.GetKeys())
|
||||
{
|
||||
if (Path.DirectorySeparatorChar == '/' && key == "UNIX:" + Option)
|
||||
{
|
||||
realKey = "UNIX:" + Option;
|
||||
}
|
||||
if (Path.DirectorySeparatorChar == '\\' && key == "WINDOWS:" + Option)
|
||||
{
|
||||
realKey = "WINDOWS:" + Option;
|
||||
}
|
||||
}
|
||||
|
||||
var val = repo.Properties[realKey];
|
||||
if (val is PatternString)
|
||||
{
|
||||
((PatternString)val).ActivateOptions();
|
||||
((PatternString)val).Format(writer);
|
||||
}
|
||||
else if (val != null)
|
||||
{
|
||||
result = val.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
result = result.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
|
||||
writer.Write(result);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LogLog.Error(GetType(), "Can not convert " + Option, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,51 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.ServiceModel;
|
||||
|
||||
namespace ASC.Common.Module
|
||||
{
|
||||
public class BaseWcfClient<TService> : ClientBase<TService>, IDisposable where TService : class
|
||||
{
|
||||
public BaseWcfClient()
|
||||
{
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
// msdn recommendation to close wcf client
|
||||
try
|
||||
{
|
||||
Close();
|
||||
}
|
||||
catch (CommunicationException)
|
||||
{
|
||||
Abort();
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
Abort();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Abort();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.ServiceModel;
|
||||
|
||||
namespace ASC.Common.Module
|
||||
{
|
||||
public class BaseWcfClient<TService> : ClientBase<TService>, IDisposable where TService : class
|
||||
{
|
||||
public BaseWcfClient()
|
||||
{
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
// msdn recommendation to close wcf client
|
||||
try
|
||||
{
|
||||
Close();
|
||||
}
|
||||
catch (CommunicationException)
|
||||
{
|
||||
Abort();
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
Abort();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Abort();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Module
|
||||
{
|
||||
public interface IServiceController
|
||||
{
|
||||
void Start();
|
||||
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace ASC.Common.Module
|
||||
{
|
||||
public interface IServiceController
|
||||
{
|
||||
void Start();
|
||||
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
|
@ -1,183 +1,183 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using ASC.Common.Utils;
|
||||
using Amazon.SimpleEmail;
|
||||
using Amazon.SimpleEmail.Model;
|
||||
using log4net;
|
||||
|
||||
namespace ASC.Common.Notify
|
||||
{
|
||||
public class AWSEmail
|
||||
{
|
||||
public enum SendStatus
|
||||
{
|
||||
Ok,
|
||||
Failed,
|
||||
QuotaLimit
|
||||
}
|
||||
|
||||
private readonly AmazonSimpleEmailServiceClient _emailService;
|
||||
private readonly ILog _log = LogHolder.Log("ASC.Notify.AmazonSES");
|
||||
|
||||
//Static fields
|
||||
private static readonly TimeSpan RefreshTimeout;
|
||||
private static DateTime _lastRefresh;
|
||||
private static DateTime _lastSend;
|
||||
private static TimeSpan _sendWindow = TimeSpan.MinValue;
|
||||
private static GetSendQuotaResult _quota;
|
||||
private static readonly object SynchRoot = new object();
|
||||
|
||||
|
||||
static AWSEmail()
|
||||
{
|
||||
RefreshTimeout = TimeSpan.FromMinutes(30);
|
||||
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ses.refreshTimeout"]))
|
||||
{
|
||||
TimeSpan.TryParse(ConfigurationManager.AppSettings["ses.refreshTimeout"], out RefreshTimeout);
|
||||
}
|
||||
_lastRefresh = DateTime.UtcNow - RefreshTimeout;//Set to refresh on first send
|
||||
}
|
||||
|
||||
public AWSEmail()
|
||||
{
|
||||
var accessKey = ConfigurationManager.AppSettings["ses.accessKey"];
|
||||
var secretKey = ConfigurationManager.AppSettings["ses.secretKey"];
|
||||
|
||||
_emailService = new AmazonSimpleEmailServiceClient(accessKey, secretKey);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public SendStatus SendEmail(MailMessage mailMessage)
|
||||
{
|
||||
//Check if we need to query stats
|
||||
RefreshQuotaIfNeeded();
|
||||
if (_quota != null)
|
||||
{
|
||||
lock (SynchRoot)
|
||||
{
|
||||
if (_quota.Max24HourSend <= _quota.SentLast24Hours)
|
||||
{
|
||||
//Quota exceeded
|
||||
//Queu next refresh to +24 hours
|
||||
_lastRefresh = DateTime.UtcNow.AddHours(24);
|
||||
_log.WarnFormat("quota limit reached. setting next check to: {0}", _lastRefresh);
|
||||
return SendStatus.QuotaLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var destination = new Destination
|
||||
{
|
||||
ToAddresses = mailMessage.To.Select(adresses => adresses.Address).ToList(),
|
||||
BccAddresses = mailMessage.Bcc.Select(adresses => adresses.Address).ToList(),
|
||||
CcAddresses = mailMessage.CC.Select(adresses => adresses.Address).ToList(),
|
||||
|
||||
};
|
||||
|
||||
var body = new Body(new Content(mailMessage.Body) { Charset = Encoding.UTF8.WebName });
|
||||
|
||||
if (mailMessage.AlternateViews.Count > 0)
|
||||
{
|
||||
//Get html body
|
||||
foreach (var alternateView in mailMessage.AlternateViews)
|
||||
{
|
||||
if ("text/html".Equals(alternateView.ContentType.MediaType, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var stream = alternateView.ContentStream;
|
||||
var buf = new byte[stream.Length];
|
||||
stream.Read(buf, 0, buf.Length);
|
||||
stream.Seek(0, SeekOrigin.Begin);//NOTE:seek to begin to keep HTML body
|
||||
body.Html = new Content(Encoding.UTF8.GetString(buf)) { Charset = Encoding.UTF8.WebName };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var message = new Message(new Content(mailMessage.Subject), body);
|
||||
|
||||
var seRequest = new SendEmailRequest(mailMessage.From.ToEncodedStringEx(), destination, message);
|
||||
if (mailMessage.ReplyTo != null)
|
||||
seRequest.ReplyToAddresses.Add(mailMessage.ReplyTo.Address);
|
||||
|
||||
ThrottleIfNeeded();
|
||||
|
||||
var response = _emailService.SendEmail(seRequest);
|
||||
_lastSend = DateTime.UtcNow;
|
||||
return response != null ? SendStatus.Ok : SendStatus.Failed;
|
||||
}
|
||||
|
||||
private void ThrottleIfNeeded()
|
||||
{
|
||||
//Check last send and throttle if needed
|
||||
if (_sendWindow != TimeSpan.MinValue)
|
||||
{
|
||||
if (DateTime.UtcNow - _lastSend <= _sendWindow)
|
||||
//Possible BUG: at high frequncies maybe bug with to little differences
|
||||
{
|
||||
//This means that time passed from last send is less then message per second
|
||||
_log.DebugFormat("send rate doesn't fit in send window. sleeping for:{0}", _sendWindow);
|
||||
Thread.Sleep(_sendWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshQuotaIfNeeded()
|
||||
{
|
||||
if (!IsRefreshNeeded()) return;
|
||||
|
||||
lock (SynchRoot)
|
||||
{
|
||||
if (IsRefreshNeeded())//Double check
|
||||
{
|
||||
_log.DebugFormat("refreshing qouta. interval: {0} Last refresh was at: {1}", RefreshTimeout,
|
||||
_lastRefresh);
|
||||
|
||||
//Do quota refresh
|
||||
_lastRefresh = DateTime.UtcNow.AddMinutes(1);
|
||||
try
|
||||
{
|
||||
var quotaRequest = new GetSendQuotaRequest();
|
||||
_quota = _emailService.GetSendQuota(quotaRequest).GetSendQuotaResult;
|
||||
_sendWindow = TimeSpan.FromSeconds(1.0 / _quota.MaxSendRate);
|
||||
_log.DebugFormat("quota: {0}/{1} at {2} mps. send window:{3}", _quota.SentLast24Hours,
|
||||
_quota.Max24HourSend, _quota.MaxSendRate, _sendWindow);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error("error refreshing quota", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsRefreshNeeded()
|
||||
{
|
||||
return (DateTime.UtcNow - _lastRefresh) > RefreshTimeout || _quota == null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using ASC.Common.Utils;
|
||||
using Amazon.SimpleEmail;
|
||||
using Amazon.SimpleEmail.Model;
|
||||
using log4net;
|
||||
|
||||
namespace ASC.Common.Notify
|
||||
{
|
||||
public class AWSEmail
|
||||
{
|
||||
public enum SendStatus
|
||||
{
|
||||
Ok,
|
||||
Failed,
|
||||
QuotaLimit
|
||||
}
|
||||
|
||||
private readonly AmazonSimpleEmailServiceClient _emailService;
|
||||
private readonly ILog _log = LogHolder.Log("ASC.Notify.AmazonSES");
|
||||
|
||||
//Static fields
|
||||
private static readonly TimeSpan RefreshTimeout;
|
||||
private static DateTime _lastRefresh;
|
||||
private static DateTime _lastSend;
|
||||
private static TimeSpan _sendWindow = TimeSpan.MinValue;
|
||||
private static GetSendQuotaResult _quota;
|
||||
private static readonly object SynchRoot = new object();
|
||||
|
||||
|
||||
static AWSEmail()
|
||||
{
|
||||
RefreshTimeout = TimeSpan.FromMinutes(30);
|
||||
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ses.refreshTimeout"]))
|
||||
{
|
||||
TimeSpan.TryParse(ConfigurationManager.AppSettings["ses.refreshTimeout"], out RefreshTimeout);
|
||||
}
|
||||
_lastRefresh = DateTime.UtcNow - RefreshTimeout;//Set to refresh on first send
|
||||
}
|
||||
|
||||
public AWSEmail()
|
||||
{
|
||||
var accessKey = ConfigurationManager.AppSettings["ses.accessKey"];
|
||||
var secretKey = ConfigurationManager.AppSettings["ses.secretKey"];
|
||||
|
||||
_emailService = new AmazonSimpleEmailServiceClient(accessKey, secretKey);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public SendStatus SendEmail(MailMessage mailMessage)
|
||||
{
|
||||
//Check if we need to query stats
|
||||
RefreshQuotaIfNeeded();
|
||||
if (_quota != null)
|
||||
{
|
||||
lock (SynchRoot)
|
||||
{
|
||||
if (_quota.Max24HourSend <= _quota.SentLast24Hours)
|
||||
{
|
||||
//Quota exceeded
|
||||
//Queu next refresh to +24 hours
|
||||
_lastRefresh = DateTime.UtcNow.AddHours(24);
|
||||
_log.WarnFormat("quota limit reached. setting next check to: {0}", _lastRefresh);
|
||||
return SendStatus.QuotaLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var destination = new Destination
|
||||
{
|
||||
ToAddresses = mailMessage.To.Select(adresses => adresses.Address).ToList(),
|
||||
BccAddresses = mailMessage.Bcc.Select(adresses => adresses.Address).ToList(),
|
||||
CcAddresses = mailMessage.CC.Select(adresses => adresses.Address).ToList(),
|
||||
|
||||
};
|
||||
|
||||
var body = new Body(new Content(mailMessage.Body) { Charset = Encoding.UTF8.WebName });
|
||||
|
||||
if (mailMessage.AlternateViews.Count > 0)
|
||||
{
|
||||
//Get html body
|
||||
foreach (var alternateView in mailMessage.AlternateViews)
|
||||
{
|
||||
if ("text/html".Equals(alternateView.ContentType.MediaType, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var stream = alternateView.ContentStream;
|
||||
var buf = new byte[stream.Length];
|
||||
stream.Read(buf, 0, buf.Length);
|
||||
stream.Seek(0, SeekOrigin.Begin);//NOTE:seek to begin to keep HTML body
|
||||
body.Html = new Content(Encoding.UTF8.GetString(buf)) { Charset = Encoding.UTF8.WebName };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var message = new Message(new Content(mailMessage.Subject), body);
|
||||
|
||||
var seRequest = new SendEmailRequest(mailMessage.From.ToEncodedStringEx(), destination, message);
|
||||
if (mailMessage.ReplyTo != null)
|
||||
seRequest.ReplyToAddresses.Add(mailMessage.ReplyTo.Address);
|
||||
|
||||
ThrottleIfNeeded();
|
||||
|
||||
var response = _emailService.SendEmail(seRequest);
|
||||
_lastSend = DateTime.UtcNow;
|
||||
return response != null ? SendStatus.Ok : SendStatus.Failed;
|
||||
}
|
||||
|
||||
private void ThrottleIfNeeded()
|
||||
{
|
||||
//Check last send and throttle if needed
|
||||
if (_sendWindow != TimeSpan.MinValue)
|
||||
{
|
||||
if (DateTime.UtcNow - _lastSend <= _sendWindow)
|
||||
//Possible BUG: at high frequncies maybe bug with to little differences
|
||||
{
|
||||
//This means that time passed from last send is less then message per second
|
||||
_log.DebugFormat("send rate doesn't fit in send window. sleeping for:{0}", _sendWindow);
|
||||
Thread.Sleep(_sendWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshQuotaIfNeeded()
|
||||
{
|
||||
if (!IsRefreshNeeded()) return;
|
||||
|
||||
lock (SynchRoot)
|
||||
{
|
||||
if (IsRefreshNeeded())//Double check
|
||||
{
|
||||
_log.DebugFormat("refreshing qouta. interval: {0} Last refresh was at: {1}", RefreshTimeout,
|
||||
_lastRefresh);
|
||||
|
||||
//Do quota refresh
|
||||
_lastRefresh = DateTime.UtcNow.AddMinutes(1);
|
||||
try
|
||||
{
|
||||
var quotaRequest = new GetSendQuotaRequest();
|
||||
_quota = _emailService.GetSendQuota(quotaRequest).GetSendQuotaResult;
|
||||
_sendWindow = TimeSpan.FromSeconds(1.0 / _quota.MaxSendRate);
|
||||
_log.DebugFormat("quota: {0}/{1} at {2} mps. send window:{3}", _quota.SentLast24Hours,
|
||||
_quota.Max24HourSend, _quota.MaxSendRate, _sendWindow);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error("error refreshing quota", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsRefreshNeeded()
|
||||
{
|
||||
return (DateTime.UtcNow - _lastRefresh) > RefreshTimeout || _quota == null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,30 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using ASC.Notify.Messages;
|
||||
|
||||
namespace ASC.Notify.Channels
|
||||
{
|
||||
public interface ISenderChannel
|
||||
{
|
||||
string SenderName { get; }
|
||||
|
||||
void SendAsync(INoticeMessage message);
|
||||
|
||||
SendResponse DirectSend(INoticeMessage message);
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using ASC.Notify.Messages;
|
||||
|
||||
namespace ASC.Notify.Channels
|
||||
{
|
||||
public interface ISenderChannel
|
||||
{
|
||||
string SenderName { get; }
|
||||
|
||||
void SendAsync(INoticeMessage message);
|
||||
|
||||
SendResponse DirectSend(INoticeMessage message);
|
||||
}
|
||||
}
|
@ -1,81 +1,81 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
using ASC.Notify.Messages;
|
||||
using ASC.Notify.Sinks;
|
||||
|
||||
namespace ASC.Notify.Channels
|
||||
{
|
||||
public class SenderChannel : ISenderChannel
|
||||
{
|
||||
private readonly ISink firstSink;
|
||||
private readonly ISink senderSink;
|
||||
private readonly Context context;
|
||||
|
||||
|
||||
public string SenderName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
public SenderChannel(Context context, string senderName, ISink decorateSink, ISink senderSink)
|
||||
{
|
||||
if (senderName == null) throw new ArgumentNullException("senderName");
|
||||
if (context == null) throw new ArgumentNullException("context");
|
||||
if (senderSink == null) throw new ApplicationException(string.Format("channel with tag {0} not created sender sink", senderName));
|
||||
|
||||
this.context = context;
|
||||
this.SenderName = senderName;
|
||||
this.firstSink = decorateSink;
|
||||
this.senderSink = senderSink;
|
||||
|
||||
var dispatcherSink = new DispatchSink(SenderName, this.context.DispatchEngine);
|
||||
this.firstSink = AddSink(firstSink, dispatcherSink);
|
||||
}
|
||||
|
||||
public void SendAsync(INoticeMessage message)
|
||||
{
|
||||
if (message == null) throw new ArgumentNullException("message");
|
||||
|
||||
firstSink.ProcessMessageAsync(message);
|
||||
}
|
||||
|
||||
public SendResponse DirectSend(INoticeMessage message)
|
||||
{
|
||||
return senderSink.ProcessMessage(message);
|
||||
}
|
||||
|
||||
|
||||
private ISink AddSink(ISink firstSink, ISink addedSink)
|
||||
{
|
||||
if (firstSink == null) return addedSink;
|
||||
if (addedSink == null) return firstSink;
|
||||
|
||||
var current = firstSink;
|
||||
while (current.NextSink != null)
|
||||
{
|
||||
current = current.NextSink;
|
||||
}
|
||||
current.NextSink = addedSink;
|
||||
return firstSink;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
using ASC.Notify.Messages;
|
||||
using ASC.Notify.Sinks;
|
||||
|
||||
namespace ASC.Notify.Channels
|
||||
{
|
||||
public class SenderChannel : ISenderChannel
|
||||
{
|
||||
private readonly ISink firstSink;
|
||||
private readonly ISink senderSink;
|
||||
private readonly Context context;
|
||||
|
||||
|
||||
public string SenderName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
public SenderChannel(Context context, string senderName, ISink decorateSink, ISink senderSink)
|
||||
{
|
||||
if (senderName == null) throw new ArgumentNullException("senderName");
|
||||
if (context == null) throw new ArgumentNullException("context");
|
||||
if (senderSink == null) throw new ApplicationException(string.Format("channel with tag {0} not created sender sink", senderName));
|
||||
|
||||
this.context = context;
|
||||
this.SenderName = senderName;
|
||||
this.firstSink = decorateSink;
|
||||
this.senderSink = senderSink;
|
||||
|
||||
var dispatcherSink = new DispatchSink(SenderName, this.context.DispatchEngine);
|
||||
this.firstSink = AddSink(firstSink, dispatcherSink);
|
||||
}
|
||||
|
||||
public void SendAsync(INoticeMessage message)
|
||||
{
|
||||
if (message == null) throw new ArgumentNullException("message");
|
||||
|
||||
firstSink.ProcessMessageAsync(message);
|
||||
}
|
||||
|
||||
public SendResponse DirectSend(INoticeMessage message)
|
||||
{
|
||||
return senderSink.ProcessMessage(message);
|
||||
}
|
||||
|
||||
|
||||
private ISink AddSink(ISink firstSink, ISink addedSink)
|
||||
{
|
||||
if (firstSink == null) return addedSink;
|
||||
if (addedSink == null) return firstSink;
|
||||
|
||||
var current = firstSink;
|
||||
while (current.NextSink != null)
|
||||
{
|
||||
current = current.NextSink;
|
||||
}
|
||||
current.NextSink = addedSink;
|
||||
return firstSink;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user