WebFileServer
Changes
.gitignore 3(+3 -0)
FileServer/.vs/FileServer/v15/.suo 0(+0 -0)
FileServer/AppTests/App.config 17(+17 -0)
FileServer/AppTests/AppTests.csproj 89(+89 -0)
FileServer/AppTests/packages.config 6(+6 -0)
FileServer/AppTests/Test_DB.cs 34(+34 -0)
FileServer/AppTests/Test_UOW.cs 195(+195 -0)
FileServer/FileServer.sln 7(+7 -0)
FileServer/Model/App.config 19(+14 -5)
FileServer/Model/Model.csproj 3(+2 -1)
FileServer/Model/UnitsOfWork/Context.cs 28(+14 -14)
FileServer/Web/Config.xml 5(+3 -2)
Details
.gitignore 3(+3 -0)
diff --git a/.gitignore b/.gitignore
index 950a99f..648d56e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,6 @@ FileServer/SPA/Build
FileServer/SPA/node_modules
FileServer/SPA/package-lock.json
+
+FileServer/AppTests/bin
+FileServer/AppTests/obj
FileServer/.vs/FileServer/v15/.suo 0(+0 -0)
diff --git a/FileServer/.vs/FileServer/v15/.suo b/FileServer/.vs/FileServer/v15/.suo
index fd6f3ac..7316f1d 100644
Binary files a/FileServer/.vs/FileServer/v15/.suo and b/FileServer/.vs/FileServer/v15/.suo differ
FileServer/AppTests/App.config 17(+17 -0)
diff --git a/FileServer/AppTests/App.config b/FileServer/AppTests/App.config
new file mode 100644
index 0000000..7e1d79c
--- /dev/null
+++ b/FileServer/AppTests/App.config
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
+ <parameters>
+ <parameter value="mssqllocaldb" />
+ </parameters>
+ </defaultConnectionFactory>
+ <providers>
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ </providers>
+ </entityFramework>
+</configuration>
\ No newline at end of file
FileServer/AppTests/AppTests.csproj 89(+89 -0)
diff --git a/FileServer/AppTests/AppTests.csproj b/FileServer/AppTests/AppTests.csproj
new file mode 100644
index 0000000..e44e13d
--- /dev/null
+++ b/FileServer/AppTests/AppTests.csproj
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props')" />
+ <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>{C8B1D86B-A2D2-4021-B4CA-C242CED2E763}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>AppTests</RootNamespace>
+ <AssemblyName>AppTests</AssemblyName>
+ <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+ <IsCodedUITest>False</IsCodedUITest>
+ <TestProjectType>UnitTest</TestProjectType>
+ <NuGetPackageImportStamp>
+ </NuGetPackageImportStamp>
+ <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="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Test_UOW.cs" />
+ <Compile Include="Test_DB.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ <None Include="packages.config" />
+ <None Include="TestPlaylist\MainTest.playlist" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\BLL\BLL.csproj">
+ <Project>{b03d6843-e0cd-4526-990d-0300e8b148ec}</Project>
+ <Name>BLL</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Model\Model.csproj">
+ <Project>{156c9263-5079-445d-b579-3540ca1b54b1}</Project>
+ <Name>Model</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
+ </PropertyGroup>
+ <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props'))" />
+ <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets'))" />
+ </Target>
+ <Import Project="..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets')" />
+</Project>
\ No newline at end of file
diff --git a/FileServer/AppTests/AppTests.csproj.user b/FileServer/AppTests/AppTests.csproj.user
new file mode 100644
index 0000000..6cbe588
--- /dev/null
+++ b/FileServer/AppTests/AppTests.csproj.user
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectView>ProjectFiles</ProjectView>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
FileServer/AppTests/packages.config 6(+6 -0)
diff --git a/FileServer/AppTests/packages.config b/FileServer/AppTests/packages.config
new file mode 100644
index 0000000..6cd36fc
--- /dev/null
+++ b/FileServer/AppTests/packages.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="EntityFramework" version="6.2.0" targetFramework="net46" />
+ <package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net46" />
+ <package id="MSTest.TestFramework" version="1.4.0" targetFramework="net46" />
+</packages>
\ No newline at end of file
diff --git a/FileServer/AppTests/Properties/AssemblyInfo.cs b/FileServer/AppTests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b0b9c42
--- /dev/null
+++ b/FileServer/AppTests/Properties/AssemblyInfo.cs
@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("AppTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AppTests")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("c8b1d86b-a2d2-4021-b4ca-c242ced2e763")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
FileServer/AppTests/Test_DB.cs 34(+34 -0)
diff --git a/FileServer/AppTests/Test_DB.cs b/FileServer/AppTests/Test_DB.cs
new file mode 100644
index 0000000..ef124af
--- /dev/null
+++ b/FileServer/AppTests/Test_DB.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+using Model.UnitsOfWork;
+
+namespace AppTests
+{
+ [TestClass]
+ public class Test_DB
+ {
+
+ /// <summary>
+ /// Проверка установки соединения с базой
+ /// </summary>
+ [TestMethod]
+ public void TryConnect()
+ {
+ bool? exists;
+
+ using (Context context = new Context())
+ {
+ context.Database.CreateIfNotExists();
+ exists = context.Database.Exists();
+ }
+
+ Assert.IsTrue(exists.HasValue && exists.Value);
+ }
+ }
+}
FileServer/AppTests/Test_UOW.cs 195(+195 -0)
diff --git a/FileServer/AppTests/Test_UOW.cs b/FileServer/AppTests/Test_UOW.cs
new file mode 100644
index 0000000..47dbdaa
--- /dev/null
+++ b/FileServer/AppTests/Test_UOW.cs
@@ -0,0 +1,195 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using System.IO;
+using System.Reflection;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+using BLL.Services;
+using BLL.Services.System;
+using BLL.Services.FS;
+using Model.Tools;
+using Model.UnitsOfWork;
+using Model.Entities.Users;
+using Model.Entities.Files.FS_Entities;
+
+namespace AppTests
+{
+ [TestClass]
+ public class Test_UOW
+ {
+
+ protected DirectoryInfo GetProjectPath()
+ {
+ return new DirectoryInfo(Assembly.GetExecutingAssembly().Location)
+ .Parent
+ .Parent
+ .Parent;
+ }
+ protected DirectoryInfo GetSolutionPath()
+ {
+ return GetProjectPath().Parent;
+ }
+ protected DirectoryInfo GetWebProjectPath()
+ {
+ return new DirectoryInfo(GetSolutionPath().FullName + "\\Web");
+ }
+
+
+ protected User GetAdmin(UOW UOW)
+ {
+ return UOW.Repo_User
+ .All.FirstOrDefault(e => e.Login == "Admin");
+ }
+ protected SRootDirectory GetTestDir(UOW UOW)
+ {
+ string TestDirName = "ForTests";
+
+ return UOW.Repo_SRootDirectory
+ .All.FirstOrDefault(e => e.Name == TestDirName);
+ }
+
+
+ /// <summary>
+ /// Проверка установки соединения с базой
+ /// </summary>
+ [TestMethod]
+ public void DropAndInit()
+ {
+ var Config = ConfigTools.Get();
+ //Расположение конфигурации
+ Config.ConfigDirectory = GetWebProjectPath().FullName;//Server.MapPath("~/");
+ Config.Import();
+
+ //Очистить базу данных
+ //Проинициализирвоать базу
+ using (var UOW = Model.UnitsOfWork.UOW.InitRepo(true))
+ {
+ //Прочитать корневые папки
+ new ConfigurationServices(UOW, Config).ReadConfiguration();
+ //Просканировать все папки
+ Task.WaitAll(new ScanServices(UOW).ScanAllDirs());
+ }
+ }
+
+ /// <summary>
+ /// Проверка пользователя по умолчанию
+ /// </summary>
+ [TestMethod]
+ public void TestDefaultUsers()
+ {
+ using (var UOW = new UOW())
+ {
+ if (GetAdmin(UOW) == null)
+ throw new Exception("Admin user not found");
+ }
+ }
+
+
+ /// <summary>
+ /// Проверка групп по умолчанию
+ /// </summary>
+ [TestMethod]
+ public void TestDefaultGroups()
+ {
+ using (var UOW = new UOW())
+ {
+ var groups = UOW.Repo_Group.All_List;
+
+ Repo_Group.DefaultGroupsNames
+ .ToList().ForEach(e1 =>
+ {
+ if (groups.FirstOrDefault(e2 => e2.Name == e1) == null)
+ throw new Exception("Default group " + e1 + " not found");
+ });
+ }
+ }
+
+
+ /// <summary>
+ /// Проверка наличия в базе информации о папке для тестов
+ /// Также очищает все соержимое тестовой папки
+ /// </summary>
+ [TestMethod]
+ public void TestDirectory()
+ {
+
+ using (var UOW = new UOW())
+ {
+ var TestDir = GetTestDir(UOW);
+ if (TestDir == null)
+ throw new Exception("Test dir not found");
+
+ if (!TestDir.Info.Exists)
+ throw new Exception("Test Directory not exists");
+
+ //Очистка папки
+ var items = TestDir.Items.ToList();
+ items.ForEach(e => UOW.Delete(e));
+ }
+ }
+
+
+ /// <summary>
+ /// Тест имитирующий использование серсира для загрузки файла
+ /// В конце удаляет загруженный файл
+ /// </summary>
+ [TestMethod]
+ public void UploadTest()
+ {
+ //Данные файла
+ string Data = "DataToFile";
+
+ byte[] data_byte;
+
+ using (MemoryStream ms = new MemoryStream())
+ {
+ using (StreamWriter sw = new StreamWriter(ms))
+ {
+ sw.WriteLine(Data);
+ sw.Flush();
+
+ ms.Position = 0;
+ data_byte = ms.ToArray();
+ }
+ }
+
+ string FileName = "UploadTest.txt";
+
+ using (var UOW = new UOW())
+ {
+ var Admin = GetAdmin(UOW);
+ var TestDir = GetTestDir(UOW);
+
+
+ UploadServices uploadServices =
+ new UploadServices(UOW);
+
+ var upload_project = uploadServices
+ .StartUpload(TestDir, FileName, data_byte.Length, Admin);
+
+ int start = 0;
+ int stop = upload_project.NextChunkSize;
+ bool Uploaded = false;
+
+ while (!Uploaded)
+ {
+ var cur_block = data_byte.Skip(start).Take(stop - start)
+ .ToArray();
+
+ Uploaded = uploadServices.UploadChunk(upload_project, cur_block);
+ start = stop;
+ stop += upload_project.NextChunkSize;
+ }
+
+ //Удаление загруженного файла
+ UOW.Delete(TestDir
+ .Items.FirstOrDefault(e => e.Name == FileName));
+ }
+ }
+
+ }
+}
diff --git a/FileServer/AppTests/TestPlaylist/MainTest.playlist b/FileServer/AppTests/TestPlaylist/MainTest.playlist
new file mode 100644
index 0000000..c045e57
--- /dev/null
+++ b/FileServer/AppTests/TestPlaylist/MainTest.playlist
@@ -0,0 +1,8 @@
+<Playlist Version="1.0">
+ <Add Test="AppTests.Test_DB.TryConnect" />
+ <Add Test="AppTests.Test_UOW.DropAndInit" />
+ <Add Test="AppTests.Test_UOW.TestDefaultUsers" />
+ <Add Test="AppTests.Test_UOW.TestDefaultGroups" />
+ <Add Test="AppTests.Test_UOW.TestDirectory" />
+ <Add Test="AppTests.Test_UOW.UploadTest" />
+</Playlist>
\ No newline at end of file
diff --git a/FileServer/BLL/Services/FS/UploadServices.cs b/FileServer/BLL/Services/FS/UploadServices.cs
index dd8abf3..47f9b3b 100644
--- a/FileServer/BLL/Services/FS/UploadServices.cs
+++ b/FileServer/BLL/Services/FS/UploadServices.cs
@@ -19,7 +19,7 @@ namespace BLL.Services.FS
/// </summary>
public class UploadServices : BaseServices
{
- const int ChunkSize = 1048576;
+ public const int ChunkSize = 1048576;
protected readonly Repo_SFileUpload Repo_SFileUpload;
public UploadServices(UOW UOW) : base(UOW)
FileServer/FileServer.sln 7(+7 -0)
diff --git a/FileServer/FileServer.sln b/FileServer/FileServer.sln
index d1e9833..743b0de 100644
--- a/FileServer/FileServer.sln
+++ b/FileServer/FileServer.sln
@@ -23,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{1C6CAB7E-6
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeStarterTools", "NodeStarterTools\NodeStarterTools.csproj", "{63ED1EB7-BBC3-463B-A3BA-DA3CB6B33385}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppTests", "AppTests\AppTests.csproj", "{C8B1D86B-A2D2-4021-B4CA-C242CED2E763}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -53,6 +55,10 @@ Global
{63ED1EB7-BBC3-463B-A3BA-DA3CB6B33385}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63ED1EB7-BBC3-463B-A3BA-DA3CB6B33385}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63ED1EB7-BBC3-463B-A3BA-DA3CB6B33385}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C8B1D86B-A2D2-4021-B4CA-C242CED2E763}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C8B1D86B-A2D2-4021-B4CA-C242CED2E763}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C8B1D86B-A2D2-4021-B4CA-C242CED2E763}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C8B1D86B-A2D2-4021-B4CA-C242CED2E763}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -64,6 +70,7 @@ Global
{18878028-6360-4299-88FC-2A3B3A45E3A8} = {7F3E17AA-FA4A-43AC-8EA2-69F833002500}
{C405B0FD-9ADC-4C7A-9CC7-2D1723AABB0D} = {7F3E17AA-FA4A-43AC-8EA2-69F833002500}
{63ED1EB7-BBC3-463B-A3BA-DA3CB6B33385} = {650B5C6C-BCA3-4856-8D06-F06EA6E152F1}
+ {C8B1D86B-A2D2-4021-B4CA-C242CED2E763} = {1C6CAB7E-64E5-4F37-B6A5-1E03AF3E6C1B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3BDB4E41-3C9F-4326-B453-03CE5954033F}
FileServer/Model/App.config 19(+14 -5)
diff --git a/FileServer/Model/App.config b/FileServer/Model/App.config
index 13ecece..236f273 100644
--- a/FileServer/Model/App.config
+++ b/FileServer/Model/App.config
@@ -1,17 +1,26 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
- <parameter value="mssqllocaldb" />
+ <parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
- <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
-</configuration>
\ No newline at end of file
+
+ <connectionStrings>
+ <!--Sqllocaldb-->
+ <add name="DBConnection" connectionString="data source=(localdb)\MSSQLLocalDB;Initial Catalog=FS;Integrated Security=True; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
+ <!--MS SQL Express-->
+ <!-- .\ - WIN-2016-SERVER -->
+ <!--<add name="DBConnection" connectionString="data source=.\SQLEXPRESS;Initial Catalog=MSSQLLocalDB;User ID=SQL_User;Password=link; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />-->
+ </connectionStrings>
+
+ <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>
diff --git a/FileServer/Model/Entities/Files/Repo/Repo_SFileUpload.cs b/FileServer/Model/Entities/Files/Repo/Repo_SFileUpload.cs
index 121da22..62d8c2b 100644
--- a/FileServer/Model/Entities/Files/Repo/Repo_SFileUpload.cs
+++ b/FileServer/Model/Entities/Files/Repo/Repo_SFileUpload.cs
@@ -22,6 +22,9 @@ namespace Model.Entities.Files.Repo
if (string.IsNullOrEmpty(elem.Name))
throw Repo_Exception<SFileUpload>.Factory(this, elem, Repo_Exceptions.Name_is_null_or_empty);
+ if (elem.Size == 0)
+ throw new Repo_Exception<SFileUpload>(this, "upload file size is 0");
+
if (elem.Parent == null)
throw Repo_Exception<SFileUpload>.Factory(this, elem, Repo_Exceptions.Parent_is_null);
FileServer/Model/Model.csproj 3(+2 -1)
diff --git a/FileServer/Model/Model.csproj b/FileServer/Model/Model.csproj
index e018a99..2acae99 100644
--- a/FileServer/Model/Model.csproj
+++ b/FileServer/Model/Model.csproj
@@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Model</RootNamespace>
<AssemblyName>Model</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
+ <TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
FileServer/Model/UnitsOfWork/Context.cs 28(+14 -14)
diff --git a/FileServer/Model/UnitsOfWork/Context.cs b/FileServer/Model/UnitsOfWork/Context.cs
index 7dcdc3b..039c2c5 100644
--- a/FileServer/Model/UnitsOfWork/Context.cs
+++ b/FileServer/Model/UnitsOfWork/Context.cs
@@ -18,10 +18,10 @@ namespace Model.UnitsOfWork
{
static string log = "Context.log";
- static Context()
- {
- File.Delete(log);
- }
+ //static Context()
+ //{
+ // File.Delete(log);
+ //}
public DbSet<User> Users { set; get; }
public DbSet<Group> Groups { set; get; }
@@ -37,16 +37,16 @@ namespace Model.UnitsOfWork
public Context(bool Clear = false) : base("DBConnection")
{
- Database.Log = (s) =>
- {
- //using (FileStream stream = new FileStream(log, FileMode.Append))
- //{
- // using (StreamWriter wr = new StreamWriter(stream))
- // {
- // wr.WriteLine(s);
- // }
- //}
- };
+ //Database.Log = (s) =>
+ //{
+ // //using (FileStream stream = new FileStream(log, FileMode.Append))
+ // //{
+ // // using (StreamWriter wr = new StreamWriter(stream))
+ // // {
+ // // wr.WriteLine(s);
+ // // }
+ // //}
+ //};
if (Clear && Database.Exists())
{
FileServer/Web/Config.xml 5(+3 -2)
diff --git a/FileServer/Web/Config.xml b/FileServer/Web/Config.xml
index 8ff2593..df951a0 100644
--- a/FileServer/Web/Config.xml
+++ b/FileServer/Web/Config.xml
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<ConfigData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <LastExportDate>2019-08-11T09:42:33.5357866+04:00</LastExportDate>
+ <LastExportDate>2019-08-11T09:46:03.0389857+04:00</LastExportDate>
<WriteNewRootDir>true</WriteNewRootDir>
<RootDirs>
+ <string>D:\GIT\WebFileServer\FileServer\Web\App_Data\ForTests</string>
<string>D:\GIT\WebFileServer\FileServer\Console\bin\Debug\Dir1</string>
- <string>D:\GIT\WebFileServer\FileServer\Console\bin\Debug\Dir2</string>
+ <string>D:\GIT\WebFileServer\FileServer\Console\bin\Debug\Dir2</string>
<string>D:\GIT\WebFileServer\FileServer\Web\App_Data\NewRootDir-1</string>
<string>D:\GIT\WebFileServer\FileServer\Web\App_Data\NewRootDir-2</string>
</RootDirs>