Merge remote-tracking branch 'gitlab.seriate/DataLayer' into develop
This commit is contained in:
@@ -6,47 +6,47 @@ using EgtBEAMWALL.DataLayer.DatabaseModels;
|
||||
|
||||
namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
{
|
||||
public class ProjController : IDisposable
|
||||
{
|
||||
private DatabaseContext dbCtx;
|
||||
public class ProjController : IDisposable
|
||||
{
|
||||
private DatabaseContext dbCtx;
|
||||
|
||||
public ProjController()
|
||||
{
|
||||
// Initialize database context
|
||||
dbCtx = new DatabaseContext();
|
||||
}
|
||||
public ProjController()
|
||||
{
|
||||
// Initialize database context
|
||||
dbCtx = new DatabaseContext();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get record by ProjDbId
|
||||
/// </summary>
|
||||
/// <param name="ProjDbId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjDbId(int ProjDbId)
|
||||
{
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == ProjDbId)
|
||||
.SingleOrDefault();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get record by ProjId
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjId(int ProjId)
|
||||
{
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get record by ProjDbId
|
||||
/// </summary>
|
||||
/// <param name="ProjDbId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjDbId(int ProjDbId)
|
||||
{
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == ProjDbId)
|
||||
.SingleOrDefault();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get record by ProjId
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel FindByProjId(int ProjId)
|
||||
{
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
}
|
||||
|
||||
#if false
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Get paginated data from DB (ASC ordered)
|
||||
/// </summary>
|
||||
@@ -89,134 +89,146 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
.ToList();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get LAST paginated data from DB (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="PartDbIdStart"></param>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetLastPaginatedDesc(int numRecord)
|
||||
{
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if(numRecord == 0)
|
||||
/// <summary>
|
||||
/// Get LAST paginated data from DB (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="PartDbIdStart"></param>
|
||||
/// <param name="numRecord"></param>
|
||||
/// <returns></returns>
|
||||
protected List<ProjModel> GetLastDbModelDesc(int numRecord)
|
||||
{
|
||||
numRecord = dbCtx.ProjList.Count();
|
||||
// se numRecord = 0 --> passo tutti
|
||||
if (numRecord == 0)
|
||||
{
|
||||
numRecord = dbCtx.ProjList.Count();
|
||||
}
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjDbId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.OrderByDescending(x => x.ProjDbId)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get filtered data by ProjectId (ASC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdAsc(int ProdDbId)
|
||||
{
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderBy(x => x.ProdDbId)
|
||||
.ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get filtered data by ProjectId (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdDesc(int ProdDbId)
|
||||
{
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderByDescending(x => x.ProdDbId)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create record on DB
|
||||
/// </summary>
|
||||
/// <param name="newProjId"></param>
|
||||
/// <param name="newBTLFileName"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel Create(int newProjId, string newBTLFileName)
|
||||
{
|
||||
ProjModel newProj = new ProjModel() { ProjId=newProjId, BTLFileName=newBTLFileName };
|
||||
public List<Core.ProjectFile> GetLastDesc(int numRecord)
|
||||
{
|
||||
List<Core.ProjectFile> result = new List<Core.ProjectFile>();
|
||||
|
||||
var dbResult = GetLastDbModelDesc(numRecord);
|
||||
|
||||
// conversione
|
||||
result = dbResult.Select(x => new Core.ProjectFile(Core.ConstBeam.ProjectType.PROJ, x.ProjId, (int)x.ProdDbId, x.BTLFileName)).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get filtered data by ProjectId (ASC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdAsc(int ProdDbId)
|
||||
{
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderBy(x => x.ProdDbId)
|
||||
.ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Get filtered data by ProjectId (DESC ordered)
|
||||
/// </summary>
|
||||
/// <param name="ProdDbId"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProjModel> GetByProdDesc(int ProdDbId)
|
||||
{
|
||||
// retrieve
|
||||
return dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProdDbId == ProdDbId)
|
||||
.OrderByDescending(x => x.ProdDbId)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create record on DB
|
||||
/// </summary>
|
||||
/// <param name="newProjId"></param>
|
||||
/// <param name="newBTLFileName"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel Create(int newProjId, string newBTLFileName)
|
||||
{
|
||||
ProjModel newProj = new ProjModel() { ProjId = newProjId, BTLFileName = newBTLFileName };
|
||||
|
||||
try
|
||||
{
|
||||
// Add to database
|
||||
dbCtx.ProjList.Add(newProj);
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return newProj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lock records by ProjDbId (proj & prod)
|
||||
/// </summary>
|
||||
/// <param name="ProjDbId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel LockByProjDbId(int ProjDbId)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == ProjDbId)
|
||||
.SingleOrDefault();
|
||||
|
||||
// aggiorno stato
|
||||
currProj.Locked = true;
|
||||
|
||||
// seleziono il prod...
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == currProj.ProdDbId)
|
||||
.SingleOrDefault();
|
||||
currProd.Locked = true;
|
||||
|
||||
try
|
||||
{
|
||||
// Add to database
|
||||
dbCtx.ProjList.Add(newProj);
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return newProj;
|
||||
}
|
||||
return currProj;
|
||||
}
|
||||
/// <summary>
|
||||
/// Lock records by ProjId (proj & prod)
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel LockByProjId(int ProjId)
|
||||
{
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
|
||||
// aggiorno stato
|
||||
currProj.Locked = true;
|
||||
|
||||
/// <summary>
|
||||
/// Lock records by ProjDbId (proj & prod)
|
||||
/// </summary>
|
||||
/// <param name="ProjDbId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel LockByProjDbId(int ProjDbId)
|
||||
{
|
||||
var currProj= dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjDbId == ProjDbId)
|
||||
.SingleOrDefault();
|
||||
// seleziono il prod...
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == currProj.ProdDbId)
|
||||
.SingleOrDefault();
|
||||
currProd.Locked = true;
|
||||
|
||||
// aggiorno stato
|
||||
currProj.Locked = true;
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
// seleziono il prod...
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == currProj.ProdDbId)
|
||||
.SingleOrDefault();
|
||||
currProd.Locked = true;
|
||||
return currProj;
|
||||
}
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return currProj;
|
||||
}
|
||||
/// <summary>
|
||||
/// Lock records by ProjId (proj & prod)
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <returns></returns>
|
||||
public ProjModel LockByProjId(int ProjId)
|
||||
{
|
||||
var currProj= dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.SingleOrDefault();
|
||||
|
||||
// aggiorno stato
|
||||
currProj.Locked = true;
|
||||
|
||||
// seleziono il prod...
|
||||
var currProd = dbCtx
|
||||
.ProdList
|
||||
.Where(x => x.ProdDbId == currProj.ProdDbId)
|
||||
.SingleOrDefault();
|
||||
currProd.Locked = true;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return currProj;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +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>
|
||||
<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>
|
||||
<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>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="v13.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
</configuration>
|
||||
@@ -1,5 +1,4 @@
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -103,10 +102,10 @@
|
||||
<HintPath>..\..\..\EgtProg\DllD32\EgtWPFLib5.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net40\EntityFramework.dll</HintPath>
|
||||
<HintPath>..\packages\EntityFramework.6.0.0\lib\net40\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net40\EntityFramework.SqlServer.dll</HintPath>
|
||||
<HintPath>..\packages\EntityFramework.6.0.0\lib\net40\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -536,12 +535,4 @@ IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Debug" copy $(TargetPa
|
||||
IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.ViewerOptimizerR64.exe
|
||||
IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\ViewerOptimizer\EgtBEAMWALL.ViewerOptimizerD64.exe</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
|
||||
</Project>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net40" />
|
||||
<package id="EntityFramework" version="6.0.0" targetFramework="net40" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user