adding nuget package from gitlab
This commit is contained in:
parent
8eb09bdabf
commit
65261c8ade
@ -1,116 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
public class FluentSQL : IFluentSQL
|
||||
{
|
||||
private readonly string connectionString;
|
||||
|
||||
public FluentSQL(string connectionString)
|
||||
{
|
||||
connectionString.ThrowIfNullOrWhiteSpace(nameof(connectionString));
|
||||
|
||||
var connectionStringBuilder = new SqlConnectionStringBuilder(connectionString);
|
||||
|
||||
this.connectionString = connectionStringBuilder.ToString();
|
||||
}
|
||||
|
||||
public FluentSQLCommand CreateCommand(string commandText)
|
||||
=> new FluentSQLCommand(this, commandText);
|
||||
|
||||
internal int ExecuteNonQuery(FluentSQLCommand command)
|
||||
{
|
||||
command.ThrowIfNull(nameof(command));
|
||||
|
||||
var rowsAffected = 0;
|
||||
|
||||
using (var sqlConnection = new SqlConnection(this.connectionString))
|
||||
{
|
||||
sqlConnection.OpenWithErrorHandling();
|
||||
|
||||
using (var sqlCommand = sqlConnection.CreateCommand())
|
||||
{
|
||||
sqlCommand.CommandText = command.CommandText;
|
||||
|
||||
sqlCommand.Parameters.AddRange(command.Parameters);
|
||||
|
||||
rowsAffected = sqlCommand.ExecuteNonQuery();
|
||||
|
||||
sqlCommand.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
return rowsAffected;
|
||||
}
|
||||
|
||||
internal IEnumerable<T> ExecuteReader<T>(FluentSQLCommand command, Func<IFluentSQLReader, T> expression)
|
||||
{
|
||||
command.ThrowIfNull(nameof(command));
|
||||
expression.ThrowIfNull(nameof(expression));
|
||||
|
||||
using (var sqlConnection = new SqlConnection(this.connectionString))
|
||||
{
|
||||
sqlConnection.OpenWithErrorHandling();
|
||||
|
||||
using (var sqlCommand = sqlConnection.CreateCommand())
|
||||
{
|
||||
sqlCommand.CommandText = command.CommandText;
|
||||
|
||||
sqlCommand.Parameters.AddRange(command.Parameters);
|
||||
|
||||
using (FluentSQLReader sqlReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess))
|
||||
{
|
||||
sqlCommand.Parameters.Clear();
|
||||
|
||||
while (sqlReader.Read())
|
||||
{
|
||||
yield return expression(sqlReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal T ExecuteScalar<T>(FluentSQLCommand command, Func<IFluentSQLReader, T> expression)
|
||||
{
|
||||
command.ThrowIfNull(nameof(command));
|
||||
expression.ThrowIfNull(nameof(expression));
|
||||
|
||||
var scalarResult = default(T);
|
||||
|
||||
using (var sqlConnection = new SqlConnection(this.connectionString))
|
||||
{
|
||||
sqlConnection.OpenWithErrorHandling();
|
||||
|
||||
using (var sqlCommand = sqlConnection.CreateCommand())
|
||||
{
|
||||
sqlCommand.CommandText = command.CommandText;
|
||||
|
||||
sqlCommand.Parameters.AddRange(command.Parameters);
|
||||
|
||||
var scalarObject = sqlCommand.ExecuteScalar();
|
||||
|
||||
sqlCommand.Parameters.Clear();
|
||||
|
||||
if (scalarObject is T scalarValue)
|
||||
{
|
||||
scalarResult = scalarValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scalarResult;
|
||||
}
|
||||
|
||||
internal T FirstOrDefault<T>(FluentSQLCommand command, Func<IFluentSQLReader, T> expression)
|
||||
=> this
|
||||
.ExecuteReader(command, expression)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,65 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
public class FluentSQLCommand : IFluentSQLCommand
|
||||
{
|
||||
private readonly FluentSQL fluentSql;
|
||||
private readonly IDictionary<string, SqlParameter> parameters;
|
||||
|
||||
public FluentSQLCommand(FluentSQL fluentSql, string commandText)
|
||||
{
|
||||
this.fluentSql = fluentSql.EnsureNotNull(nameof(fluentSql));
|
||||
this.CommandText = commandText.EnsureNotNullOrWhiteSpace(nameof(commandText));
|
||||
this.parameters = new Dictionary<string, SqlParameter>();
|
||||
}
|
||||
|
||||
internal string CommandText { get; }
|
||||
|
||||
internal SqlParameter[] Parameters
|
||||
=> this.parameters.Values.ToArray();
|
||||
|
||||
public int ExecuteNonQuery()
|
||||
=> this.fluentSql.ExecuteNonQuery(this);
|
||||
|
||||
public IEnumerable<T> ExecuteReader<T>(Func<IFluentSQLReader, T> expression)
|
||||
=> this.fluentSql.ExecuteReader(this, expression);
|
||||
|
||||
public T ExecuteScalar<T>(Func<IFluentSQLReader, T> expression)
|
||||
=> this.fluentSql.ExecuteScalar(this, expression);
|
||||
|
||||
public T FirstOrDefault<T>(Func<IFluentSQLReader, T> expression)
|
||||
=> this.fluentSql.FirstOrDefault(this, expression);
|
||||
|
||||
public IFluentSQLCommand SetParameter(string name, object value)
|
||||
{
|
||||
name.ThrowIfNullOrWhiteSpace(nameof(name));
|
||||
|
||||
if (value is null)
|
||||
{
|
||||
value = DBNull.Value;
|
||||
}
|
||||
|
||||
var parameter = new SqlParameter(name, value);
|
||||
|
||||
this.parameters[name] = parameter;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IFluentSQLCommand SetParameters(IEnumerable<KeyValuePair<string, object>> parameters)
|
||||
{
|
||||
foreach (var kvp in parameters)
|
||||
{
|
||||
this.SetParameter(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
internal static class FluentSQLExtensions
|
||||
{
|
||||
public static T EnsureNotNull<T>(this T value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
value.ThrowIfNull(memberName);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string EnsureNotNullOrWhiteSpace(this string value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
value.ThrowIfNullOrWhiteSpace(memberName);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void ThrowIfNull<T>(this T value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentException($"{memberName} should not be null.", memberName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ThrowIfNullOrWhiteSpace(this string value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentException($"{memberName} should not be null or white space.", memberName);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void OpenWithErrorHandling(this SqlConnection sqlConnection)
|
||||
{
|
||||
sqlConnection.ThrowIfNull(nameof(sqlConnection));
|
||||
|
||||
sqlConnection.FireInfoMessageEventOnUserErrors = true;
|
||||
sqlConnection.InfoMessage += SqlConnectionInfoMessage;
|
||||
|
||||
sqlConnection.Open();
|
||||
}
|
||||
|
||||
internal static void SqlConnectionInfoMessage(object sender, SqlInfoMessageEventArgs e)
|
||||
{
|
||||
// TODO: Log error message to the caller or elsewhere.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,151 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
public class FluentSQLReader : IFluentSQLReader, IDisposable
|
||||
{
|
||||
private readonly SqlDataReader sqlDataReader;
|
||||
|
||||
private int index;
|
||||
|
||||
private FluentSQLReader(SqlDataReader sqlDataReader)
|
||||
=> this.sqlDataReader = sqlDataReader.EnsureNotNull(nameof(sqlDataReader));
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.sqlDataReader.Close();
|
||||
this.sqlDataReader.Dispose();
|
||||
}
|
||||
|
||||
public bool GetBool()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetBoolean(this.index);
|
||||
}
|
||||
|
||||
return default(bool);
|
||||
}
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
var bytes = default(byte[]);
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
bytes = this.sqlDataReader.GetFieldValue<byte[]>(0);
|
||||
}
|
||||
|
||||
return bytes ?? Array.Empty<byte>();
|
||||
}
|
||||
|
||||
public DateTime GetDate()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetDateTime(this.index);
|
||||
}
|
||||
|
||||
return default(DateTime);
|
||||
}
|
||||
|
||||
public int GetInt()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetInt32(this.index);
|
||||
}
|
||||
|
||||
return default(int);
|
||||
}
|
||||
|
||||
public long GetLong()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetInt64(this.index);
|
||||
}
|
||||
|
||||
return default(long);
|
||||
}
|
||||
|
||||
public short GetSmallint()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetInt16(this.index);
|
||||
}
|
||||
|
||||
return default(short);
|
||||
}
|
||||
|
||||
public string GetString()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return $"{this.sqlDataReader.GetValue(this.index)}";
|
||||
}
|
||||
|
||||
return default(string);
|
||||
}
|
||||
|
||||
public T GetValue<T>()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
if (this.sqlDataReader.GetValue(this.index) is T value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public object GetValue(string column)
|
||||
{
|
||||
column.EnsureNotNullOrWhiteSpace(nameof(column));
|
||||
|
||||
var colIndex = this.sqlDataReader.GetOrdinal(column);
|
||||
|
||||
if (colIndex >= 0 && colIndex < this.sqlDataReader.FieldCount)
|
||||
{
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetValue(this.index);
|
||||
}
|
||||
}
|
||||
|
||||
return default(object);
|
||||
}
|
||||
|
||||
internal bool Read()
|
||||
{
|
||||
this.index = -1;
|
||||
|
||||
return this.sqlDataReader.Read();
|
||||
}
|
||||
|
||||
public static implicit operator FluentSQLReader(SqlDataReader sqlDataReader)
|
||||
=> new FluentSQLReader(sqlDataReader);
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
namespace LaaProductionWeb.Data.Interfaces
|
||||
{
|
||||
public interface IFluentSQL
|
||||
{
|
||||
FluentSQLCommand CreateCommand(string commandText);
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
namespace LaaProductionWeb.Data.Interfaces
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface IFluentSQLCommand
|
||||
{
|
||||
int ExecuteNonQuery();
|
||||
|
||||
IEnumerable<T> ExecuteReader<T>(Func<IFluentSQLReader, T> expression);
|
||||
|
||||
T ExecuteScalar<T>(Func<IFluentSQLReader, T> expression);
|
||||
|
||||
T FirstOrDefault<T>(Func<IFluentSQLReader, T> expression);
|
||||
|
||||
IFluentSQLCommand SetParameter(string name, object value);
|
||||
|
||||
IFluentSQLCommand SetParameters(IEnumerable<KeyValuePair<string, object>> parameters);
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
namespace LaaProductionWeb.Data.Interfaces
|
||||
{
|
||||
using System;
|
||||
|
||||
public interface IFluentSQLReader
|
||||
{
|
||||
bool GetBool();
|
||||
|
||||
byte[] GetBytes();
|
||||
|
||||
DateTime GetDate();
|
||||
|
||||
int GetInt();
|
||||
|
||||
long GetLong();
|
||||
|
||||
short GetSmallint();
|
||||
|
||||
string GetString();
|
||||
|
||||
T GetValue<T>();
|
||||
|
||||
object GetValue(string column);
|
||||
}
|
||||
}
|
||||
@ -1,116 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
public class FluentSQL : IFluentSQL
|
||||
{
|
||||
private readonly string connectionString;
|
||||
|
||||
public FluentSQL(string connectionString)
|
||||
{
|
||||
connectionString.ThrowIfNullOrWhiteSpace(nameof(connectionString));
|
||||
|
||||
var connectionStringBuilder = new SqlConnectionStringBuilder(connectionString);
|
||||
|
||||
this.connectionString = connectionStringBuilder.ToString();
|
||||
}
|
||||
|
||||
public FluentSQLCommand CreateCommand(string commandText)
|
||||
=> new FluentSQLCommand(this, commandText);
|
||||
|
||||
internal int ExecuteNonQuery(FluentSQLCommand command)
|
||||
{
|
||||
command.ThrowIfNull(nameof(command));
|
||||
|
||||
var rowsAffected = 0;
|
||||
|
||||
using (var sqlConnection = new SqlConnection(this.connectionString))
|
||||
{
|
||||
sqlConnection.OpenWithErrorHandling();
|
||||
|
||||
using (var sqlCommand = sqlConnection.CreateCommand())
|
||||
{
|
||||
sqlCommand.CommandText = command.CommandText;
|
||||
|
||||
sqlCommand.Parameters.AddRange(command.Parameters);
|
||||
|
||||
rowsAffected = sqlCommand.ExecuteNonQuery();
|
||||
|
||||
sqlCommand.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
return rowsAffected;
|
||||
}
|
||||
|
||||
internal IEnumerable<T> ExecuteReader<T>(FluentSQLCommand command, Func<IFluentSQLReader, T> expression)
|
||||
{
|
||||
command.ThrowIfNull(nameof(command));
|
||||
expression.ThrowIfNull(nameof(expression));
|
||||
|
||||
using (var sqlConnection = new SqlConnection(this.connectionString))
|
||||
{
|
||||
sqlConnection.OpenWithErrorHandling();
|
||||
|
||||
using (var sqlCommand = sqlConnection.CreateCommand())
|
||||
{
|
||||
sqlCommand.CommandText = command.CommandText;
|
||||
|
||||
sqlCommand.Parameters.AddRange(command.Parameters);
|
||||
|
||||
using (FluentSQLReader sqlReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess))
|
||||
{
|
||||
sqlCommand.Parameters.Clear();
|
||||
|
||||
while (sqlReader.Read())
|
||||
{
|
||||
yield return expression(sqlReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal T ExecuteScalar<T>(FluentSQLCommand command, Func<IFluentSQLReader, T> expression)
|
||||
{
|
||||
command.ThrowIfNull(nameof(command));
|
||||
expression.ThrowIfNull(nameof(expression));
|
||||
|
||||
var scalarResult = default(T);
|
||||
|
||||
using (var sqlConnection = new SqlConnection(this.connectionString))
|
||||
{
|
||||
sqlConnection.OpenWithErrorHandling();
|
||||
|
||||
using (var sqlCommand = sqlConnection.CreateCommand())
|
||||
{
|
||||
sqlCommand.CommandText = command.CommandText;
|
||||
|
||||
sqlCommand.Parameters.AddRange(command.Parameters);
|
||||
|
||||
var scalarObject = sqlCommand.ExecuteScalar();
|
||||
|
||||
sqlCommand.Parameters.Clear();
|
||||
|
||||
if (scalarObject is T scalarValue)
|
||||
{
|
||||
scalarResult = scalarValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scalarResult;
|
||||
}
|
||||
|
||||
internal T FirstOrDefault<T>(FluentSQLCommand command, Func<IFluentSQLReader, T> expression)
|
||||
=> this
|
||||
.ExecuteReader(command, expression)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
public class FluentSQLCommand : IFluentSQLCommand
|
||||
{
|
||||
private readonly FluentSQL fluentSql;
|
||||
private readonly IDictionary<string, SqlParameter> parameters;
|
||||
|
||||
public FluentSQLCommand(FluentSQL fluentSql, string commandText)
|
||||
{
|
||||
this.fluentSql = fluentSql.EnsureNotNull(nameof(fluentSql));
|
||||
this.CommandText = commandText.EnsureNotNullOrWhiteSpace(nameof(commandText));
|
||||
this.parameters = new Dictionary<string, SqlParameter>();
|
||||
}
|
||||
|
||||
internal string CommandText { get; }
|
||||
|
||||
internal SqlParameter[] Parameters
|
||||
=> this.parameters.Values.ToArray();
|
||||
|
||||
public int ExecuteNonQuery()
|
||||
=> this.fluentSql.ExecuteNonQuery(this);
|
||||
|
||||
public IEnumerable<T> ExecuteReader<T>(Func<IFluentSQLReader, T> expression)
|
||||
=> this.fluentSql.ExecuteReader(this, expression);
|
||||
|
||||
public T ExecuteScalar<T>(Func<IFluentSQLReader, T> expression)
|
||||
=> this.fluentSql.ExecuteScalar(this, expression);
|
||||
|
||||
public T FirstOrDefault<T>(Func<IFluentSQLReader, T> expression)
|
||||
=> this.fluentSql.FirstOrDefault(this, expression);
|
||||
|
||||
public IFluentSQLCommand SetParameter(string name, object value)
|
||||
{
|
||||
name.ThrowIfNullOrWhiteSpace(nameof(name));
|
||||
|
||||
if (value is null)
|
||||
{
|
||||
value = DBNull.Value;
|
||||
}
|
||||
|
||||
var parameter = new SqlParameter(name, value);
|
||||
|
||||
this.parameters[name] = parameter;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IFluentSQLCommand SetParameters(IEnumerable<KeyValuePair<string, object>> parameters)
|
||||
{
|
||||
foreach (var kvp in parameters)
|
||||
{
|
||||
this.SetParameter(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
internal static class FluentSQLExtensions
|
||||
{
|
||||
public static T EnsureNotNull<T>(this T value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
value.ThrowIfNull(memberName);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string EnsureNotNullOrWhiteSpace(this string value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
value.ThrowIfNullOrWhiteSpace(memberName);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void ThrowIfNull<T>(this T value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentException($"{memberName} should not be null.", memberName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ThrowIfNullOrWhiteSpace(this string value, [CallerMemberName] string memberName = "")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentException($"{memberName} should not be null or white space.", memberName);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void OpenWithErrorHandling(this SqlConnection sqlConnection)
|
||||
{
|
||||
sqlConnection.ThrowIfNull(nameof(sqlConnection));
|
||||
|
||||
sqlConnection.FireInfoMessageEventOnUserErrors = true;
|
||||
sqlConnection.InfoMessage += SqlConnectionInfoMessage;
|
||||
|
||||
sqlConnection.Open();
|
||||
}
|
||||
|
||||
internal static void SqlConnectionInfoMessage(object sender, SqlInfoMessageEventArgs e)
|
||||
{
|
||||
// TODO: Log error message to the caller or elsewhere.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,151 +0,0 @@
|
||||
namespace LaaProductionWeb.Data
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
public class FluentSQLReader : IFluentSQLReader, IDisposable
|
||||
{
|
||||
private readonly SqlDataReader sqlDataReader;
|
||||
|
||||
private int index;
|
||||
|
||||
private FluentSQLReader(SqlDataReader sqlDataReader)
|
||||
=> this.sqlDataReader = sqlDataReader.EnsureNotNull(nameof(sqlDataReader));
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.sqlDataReader.Close();
|
||||
this.sqlDataReader.Dispose();
|
||||
}
|
||||
|
||||
public bool GetBool()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetBoolean(this.index);
|
||||
}
|
||||
|
||||
return default(bool);
|
||||
}
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
var bytes = default(byte[]);
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
bytes = this.sqlDataReader.GetFieldValue<byte[]>(0);
|
||||
}
|
||||
|
||||
return bytes ?? Array.Empty<byte>();
|
||||
}
|
||||
|
||||
public DateTime GetDate()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetDateTime(this.index);
|
||||
}
|
||||
|
||||
return default(DateTime);
|
||||
}
|
||||
|
||||
public int GetInt()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetInt32(this.index);
|
||||
}
|
||||
|
||||
return default(int);
|
||||
}
|
||||
|
||||
public long GetLong()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetInt64(this.index);
|
||||
}
|
||||
|
||||
return default(long);
|
||||
}
|
||||
|
||||
public short GetSmallint()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetInt16(this.index);
|
||||
}
|
||||
|
||||
return default(short);
|
||||
}
|
||||
|
||||
public string GetString()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return $"{this.sqlDataReader.GetValue(this.index)}";
|
||||
}
|
||||
|
||||
return default(string);
|
||||
}
|
||||
|
||||
public T GetValue<T>()
|
||||
{
|
||||
this.index++;
|
||||
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
if (this.sqlDataReader.GetValue(this.index) is T value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public object GetValue(string column)
|
||||
{
|
||||
column.EnsureNotNullOrWhiteSpace(nameof(column));
|
||||
|
||||
var colIndex = this.sqlDataReader.GetOrdinal(column);
|
||||
|
||||
if (colIndex >= 0 && colIndex < this.sqlDataReader.FieldCount)
|
||||
{
|
||||
if (!this.sqlDataReader.IsDBNull(this.index))
|
||||
{
|
||||
return this.sqlDataReader.GetValue(this.index);
|
||||
}
|
||||
}
|
||||
|
||||
return default(object);
|
||||
}
|
||||
|
||||
internal bool Read()
|
||||
{
|
||||
this.index = -1;
|
||||
|
||||
return this.sqlDataReader.Read();
|
||||
}
|
||||
|
||||
public static implicit operator FluentSQLReader(SqlDataReader sqlDataReader)
|
||||
=> new FluentSQLReader(sqlDataReader);
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
namespace LaaProductionWeb.Data.Interfaces
|
||||
{
|
||||
public interface IFluentSQL
|
||||
{
|
||||
FluentSQLCommand CreateCommand(string commandText);
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
namespace LaaProductionWeb.Data.Interfaces
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface IFluentSQLCommand
|
||||
{
|
||||
int ExecuteNonQuery();
|
||||
|
||||
IEnumerable<T> ExecuteReader<T>(Func<IFluentSQLReader, T> expression);
|
||||
|
||||
T ExecuteScalar<T>(Func<IFluentSQLReader, T> expression);
|
||||
|
||||
T FirstOrDefault<T>(Func<IFluentSQLReader, T> expression);
|
||||
|
||||
IFluentSQLCommand SetParameter(string name, object value);
|
||||
|
||||
IFluentSQLCommand SetParameters(IEnumerable<KeyValuePair<string, object>> parameters);
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
namespace LaaProductionWeb.Data.Interfaces
|
||||
{
|
||||
using System;
|
||||
|
||||
public interface IFluentSQLReader
|
||||
{
|
||||
bool GetBool();
|
||||
|
||||
byte[] GetBytes();
|
||||
|
||||
DateTime GetDate();
|
||||
|
||||
int GetInt();
|
||||
|
||||
long GetLong();
|
||||
|
||||
short GetSmallint();
|
||||
|
||||
string GetString();
|
||||
|
||||
T GetValue<T>();
|
||||
|
||||
object GetValue(string column);
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LaaProductionWeb.Data</RootNamespace>
|
||||
<AssemblyName>LaaProductionWeb.Data</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<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="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FluentSQL.cs" />
|
||||
<Compile Include="FluentSQLExtensions.cs" />
|
||||
<Compile Include="Interfaces\IFluentSQL.cs" />
|
||||
<Compile Include="Interfaces\IFluentSQLCommand.cs" />
|
||||
<Compile Include="Interfaces\IFluentSQLReader.cs" />
|
||||
<Compile Include="FluentSQLCommand.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="FluentSQLReader.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
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("LaaProductionWeb.Data")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LaaProductionWeb.Data")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[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("4b5bf112-d3be-4e84-9a8e-74a0e314bba7")]
|
||||
|
||||
// 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,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
@ -12,9 +12,9 @@
|
||||
|
||||
public class AccountService : IAccountService
|
||||
{
|
||||
private readonly IFluentSQL sqlClient;
|
||||
private readonly IFluentSQLConnection sqlClient;
|
||||
|
||||
public AccountService(IFluentSQL sqlClient)
|
||||
public AccountService(IFluentSQLConnection sqlClient)
|
||||
=> this.sqlClient = sqlClient;
|
||||
|
||||
public Employee FindEmployee(short userId)
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
|
||||
public class ApprovalsService : IApprovalsService
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
|
||||
public ApprovalsService(IFluentSQL fluentSQL)
|
||||
public ApprovalsService(IFluentSQLConnection fluentSQL)
|
||||
=> this.fluentSQL = fluentSQL;
|
||||
|
||||
public Result Add(ProductionApproval approval)
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
namespace LaaProductionWeb.Services.Interfaces
|
||||
{
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface ISearchService
|
||||
{
|
||||
IEnumerable<WildcardResult> Find(WildcardInputModel model);
|
||||
|
||||
IEnumerable<string> Options();
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,8 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -32,8 +34,8 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentSQL, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentSQL.1.0.0\lib\netstandard2.0\FluentSQL.dll</HintPath>
|
||||
<Reference Include="FluentSQLClient, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentSQLClient.1.0.0\lib\netstandard2.0\FluentSQLClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
@ -42,17 +44,11 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.SqlClient, Version=4.6.1.5, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SqlClient.4.8.5\lib\net461\System.Data.SqlClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
@ -67,6 +63,7 @@
|
||||
<Compile Include="Interfaces\IOrdersService.cs" />
|
||||
<Compile Include="Interfaces\IProtocolService.cs" />
|
||||
<Compile Include="Interfaces\IReportService.cs" />
|
||||
<Compile Include="Interfaces\ISearchService.cs" />
|
||||
<Compile Include="Interfaces\IShipmentsService.cs" />
|
||||
<Compile Include="Interfaces\ISoftwareService.cs" />
|
||||
<Compile Include="LoggerService.cs" />
|
||||
@ -101,6 +98,8 @@
|
||||
<Compile Include="Models\Reports\ReportFilter.cs" />
|
||||
<Compile Include="Models\Result.cs" />
|
||||
<Compile Include="Models\Search\SearchWildcardModel.cs" />
|
||||
<Compile Include="Models\Search\WildcardInputModel.cs" />
|
||||
<Compile Include="Models\Search\WildcardResult.cs" />
|
||||
<Compile Include="Models\SerialNr.cs" />
|
||||
<Compile Include="Models\ShipmentModel.cs" />
|
||||
<Compile Include="Models\Reports\SqlExpression.cs" />
|
||||
@ -115,6 +114,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ProtocolService.cs" />
|
||||
<Compile Include="ReportService.cs" />
|
||||
<Compile Include="SearchService.cs" />
|
||||
<Compile Include="ShipmentsService.cs" />
|
||||
<Compile Include="SoftwareService.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
|
||||
public class LoggerService : ILoggerService
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
|
||||
public LoggerService(IFluentSQL fluentSQL)
|
||||
public LoggerService(IFluentSQLConnection fluentSQL)
|
||||
=> this.fluentSQL = fluentSQL;
|
||||
|
||||
public class Actions
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
|
||||
public class WildcardInputModel
|
||||
{
|
||||
private string token;
|
||||
private IEnumerable<string> fields = Array.Empty<string>();
|
||||
|
||||
[Required]
|
||||
[StringLength(50, MinimumLength = 1)]
|
||||
[RegularExpression("^[0-9 a-z-A-Z]+$")]
|
||||
public string Token
|
||||
{
|
||||
get => this.token;
|
||||
set => this.token = value?.Replace(" ", "")?.Trim();
|
||||
}
|
||||
|
||||
public string Fields
|
||||
{
|
||||
get => string.Join(",", this.fields);
|
||||
set => this.fields = $"{value}".Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
internal IEnumerable<string> GetRequiredFields(IEnumerable<string> allFields)
|
||||
{
|
||||
if (this.fields.Any())
|
||||
{
|
||||
return allFields.Where(x => this.fields.Contains(x, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
return allFields;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
namespace LaaProductionWeb.Services.Models
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class WildcardResult : Dictionary<string, object>
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -7,9 +7,9 @@
|
||||
|
||||
public class OrdersService : IOrdersService
|
||||
{
|
||||
private readonly IFluentSQL sqlClient;
|
||||
private readonly IFluentSQLConnection sqlClient;
|
||||
|
||||
public OrdersService(IFluentSQL sqlClient)
|
||||
public OrdersService(IFluentSQLConnection sqlClient)
|
||||
=> this.sqlClient = sqlClient;
|
||||
|
||||
public OrdersFoundModel FindOrders(string search)
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
|
||||
public class ProtocolService : IProtocolService
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
|
||||
public ProtocolService(IFluentSQL fluentSQL)
|
||||
public ProtocolService(IFluentSQLConnection fluentSQL)
|
||||
=> this.fluentSQL = fluentSQL;
|
||||
|
||||
public bool DeleteFile(int fileId)
|
||||
|
||||
@ -12,9 +12,9 @@
|
||||
|
||||
public partial class ReportService : IReportService
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
|
||||
public ReportService(IFluentSQL fluentSQL)
|
||||
public ReportService(IFluentSQLConnection fluentSQL)
|
||||
=> this.fluentSQL = fluentSQL;
|
||||
|
||||
public CordonelPressureSensorModel LoadCordonelPressureSensorReport(CordonelPressureSensorModel model = null)
|
||||
|
||||
131
LaaProductionWeb/LaaProductionWeb.Services/SearchService.cs
Normal file
131
LaaProductionWeb/LaaProductionWeb.Services/SearchService.cs
Normal file
@ -0,0 +1,131 @@
|
||||
namespace LaaProductionWeb.Services
|
||||
{
|
||||
using FluentSQLClient.Interfaces;
|
||||
|
||||
using LaaProductionWeb.Services.Models;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class SearchService : ISearchService
|
||||
{
|
||||
private readonly IFluentSQLConnection fluentSQLClient;
|
||||
|
||||
public SearchService(IFluentSQLConnection fluentSQLClient)
|
||||
=> this.fluentSQLClient = fluentSQLClient;
|
||||
|
||||
public IEnumerable<WildcardResult> Find(WildcardInputModel model)
|
||||
{
|
||||
var requiredFields = model.GetRequiredFields(this.Options());
|
||||
var ordersFound = fluentSQLClient
|
||||
.CreateCommand($@"
|
||||
DECLARE @serienNr TABLE([Nr] VARCHAR(50));
|
||||
-----------------------------------------------------------------------------
|
||||
-- 1. LOOK FOR SERIAL NUMBER ------------------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
INSERT INTO @serienNr
|
||||
SELECT [APS].[SerienNr]
|
||||
FROM [AuftragPositionSerienNr] AS [APS]
|
||||
WHERE [APS].[SerienNr] LIKE @{nameof(model.Token)}
|
||||
OR [APS].[KundeneigeneSerienNr] LIKE @{nameof(model.Token)}
|
||||
OR REPLACE([APS].[KundeneigeneSerienNr], ' ', '') LIKE @{nameof(model.Token)};
|
||||
-----------------------------------------------------------------------------
|
||||
-- 2. LOOK FOR PCB NUMBER ---------------------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
INSERT INTO @serienNr
|
||||
SELECT [PCBS].[MapPcbIdToSerialNumber_SerialNumber]
|
||||
FROM [MapPcbIdToSerialNumber] AS [PCBS]
|
||||
WHERE [PCBS].[MapPcbIdToSerialNumber_PcbId] LIKE @{nameof(model.Token)};
|
||||
-----------------------------------------------------------------------------
|
||||
-- 3. LOOK FOR FUNK ADDRESS E-REGISTER --------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
INSERT INTO @serienNr
|
||||
SELECT [ER].[Seriennummer]
|
||||
FROM [eRegister] AS [ER]
|
||||
WHERE [ER].[Adresse] LIKE @{nameof(model.Token)};
|
||||
-----------------------------------------------------------------------------
|
||||
-- 4. LOOK FOR FUNK ADDRESS GENESIS -----------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
INSERT INTO @serienNr
|
||||
SELECT [GM].[Seriennummer]
|
||||
FROM [Genesis_Meter] AS [GM]
|
||||
WHERE [GM].[Adresse] LIKE @{nameof(model.Token)};
|
||||
-----------------------------------------------------------------------------
|
||||
-- 5. TAKE ORDERS INFO ------------------------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
SELECT DISTINCT
|
||||
[KN].[KundenNr] AS [CustomerNo]
|
||||
, [KN].[Name] AS [Customer]
|
||||
, [AP].[FertigungsauftragNr] AS [ProductionOrderNo]
|
||||
, [APS].[AuftragNr] AS [CustomerOrderNo]
|
||||
, [APS].[PositionNr] AS [PosNo]
|
||||
, [APS].[SerienNr] AS [SerialNo]
|
||||
, [APS].[KundeneigeneSerienNr] AS [CustomerSerialNo]
|
||||
, [IDN].[KurzBez] AS [KurzBez]
|
||||
, [IDN].[Typ] AS [Typ]
|
||||
, [IDN].[Nennweite] AS [Nennweite]
|
||||
, [IDN].[Baulaenge] AS [Baulaenge]
|
||||
, [AP].[Menge] AS [Quantity]
|
||||
, [APS].[FabNr] AS [FabricNo]
|
||||
, [IDN].[IdentNr] AS [IdentNr]
|
||||
, [PCBS].[MapPcbIdToSerialNumber_PcbId] AS [PcbId]
|
||||
, [ER].[Adresse] AS [ErRadioAddress]
|
||||
, [GM].[Adresse] AS [GmRadioAddress]
|
||||
FROM [AuftragPositionSerienNr] AS [APS]
|
||||
LEFT JOIN [AuftragPosition_Gesamt] AS [AP]
|
||||
ON [AP].[AuftragNr] = [APS].[AuftragNr]
|
||||
AND [AP].[PositionNr] = [APS].[PositionNr]
|
||||
LEFT JOIN [Auftrag_Gesamt] AS [AG]
|
||||
ON [AG].[AuftragNr] = [APS].[AuftragNr]
|
||||
LEFT JOIN [Kunde] AS [KN]
|
||||
ON [KN].[KundenNr] = [AG].[KundenNr]
|
||||
LEFT JOIN [Identnr] AS [IDN]
|
||||
ON [IDN].[IdentNr] = [AP].[Identnr]
|
||||
LEFT JOIN [MapPcbIdToSerialNumber] AS [PCBS]
|
||||
ON [PCBS].[MapPcbIdToSerialNumber_SerialNumber] = [APS].[SerienNr]
|
||||
LEFT JOIN [eRegister] AS [ER]
|
||||
ON [ER].[Seriennummer] = [APS].[SerienNr]
|
||||
LEFT JOIN [Genesis_Meter] AS [GM]
|
||||
ON [GM].[Seriennummer] = [APS].[SerienNr]
|
||||
WHERE [APS].[SerienNr] IN (SELECT [Nr] FROM @serienNr)")
|
||||
.SetParameter(nameof(model.Token), model.Token)
|
||||
.ExecuteReader(reader => this.ToWildcardResult(reader, requiredFields));
|
||||
|
||||
return ordersFound;
|
||||
}
|
||||
|
||||
public IEnumerable<string> Options()
|
||||
=> new string[]
|
||||
{
|
||||
"CustomerNo",
|
||||
"Customer",
|
||||
"ProductionOrderNo",
|
||||
"CustomerOrderNo",
|
||||
"PosNo",
|
||||
"SerialNo",
|
||||
"CustomerSerialNo",
|
||||
"KurzBez",
|
||||
"Typ",
|
||||
"Nennweite",
|
||||
"Baulaenge",
|
||||
"Quantity",
|
||||
"FabricNo",
|
||||
"IdentNr",
|
||||
"PcbId",
|
||||
"ErRadioAddress",
|
||||
"GmRadioAddress",
|
||||
};
|
||||
|
||||
internal WildcardResult ToWildcardResult(IFluentSQLReader reader, IEnumerable<string> fields)
|
||||
{
|
||||
var wildcardResult = new WildcardResult();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
wildcardResult[field] = reader.GetValue(field);
|
||||
}
|
||||
|
||||
return wildcardResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,9 +12,9 @@
|
||||
|
||||
public class ShipmentsService : IShipmentsService
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
|
||||
public ShipmentsService(IFluentSQL fluentSQL)
|
||||
public ShipmentsService(IFluentSQLConnection fluentSQL)
|
||||
=> this.fluentSQL = fluentSQL;
|
||||
|
||||
public OrderScanModel DeletePalletEntry(int id)
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
|
||||
public class SoftwareService : ISoftwareService
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
|
||||
public SoftwareService(IFluentSQL fluentSQL)
|
||||
public SoftwareService(IFluentSQLConnection fluentSQL)
|
||||
=> this.fluentSQL = fluentSQL;
|
||||
|
||||
public void AddFunction(short appId, string name)
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
namespace LaaProductionWeb.UnitTests.Data
|
||||
{
|
||||
using LaaProductionWeb.Data;
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[TestClass]
|
||||
public class FluentSQLTestClass
|
||||
{
|
||||
[TestMethod]
|
||||
public void Constructor_ShouldThrow_ConnectionString_IsNull()
|
||||
=> Assert.ThrowsException<ArgumentException>(() => new FluentSQL(null));
|
||||
|
||||
[TestMethod]
|
||||
public void Constructor_ShouldThrow_ConnectionString_IsWhiteSpace()
|
||||
=> Assert.ThrowsException<ArgumentException>(() => new FluentSQL(string.Empty));
|
||||
|
||||
[TestMethod]
|
||||
public void Constructor_ShouldThrow_ConnectionString_KeyNotFound()
|
||||
=> Assert.ThrowsException<ArgumentException>(() => new FluentSQL("invalid connection string"));
|
||||
|
||||
[TestMethod]
|
||||
public void Constructor_ShouldThrow_ConnectionString_NotWellFormed()
|
||||
=> Assert.ThrowsException<ArgumentException>(() => new FluentSQL("Invalid Key=123"));
|
||||
}
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
<?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.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\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>{A14581DD-E1AC-4AB0-9329-B723D24A2F3A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LaaProductionWeb.UnitTests.Data</RootNamespace>
|
||||
<AssemblyName>LaaProductionWeb.UnitTests.Data</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</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>
|
||||
</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="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.1.3.2\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.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FluentSQLTestClass.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LaaProductionWeb.Data\LaaProductionWeb.Data.csproj">
|
||||
<Project>{4b5bf112-d3be-4e84-9a8e-74a0e314bba7}</Project>
|
||||
<Name>LaaProductionWeb.Data</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>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\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" />
|
||||
</Project>
|
||||
@ -1,20 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("LaaProductionWeb.UnitTests.Data")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LaaProductionWeb.UnitTests.Data")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("a14581dd-e1ac-4ab0-9329-b723d24a2f3a")]
|
||||
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.33423.255
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProductionWeb.Data", "LaaProductionWeb.Data\LaaProductionWeb.Data.csproj", "{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProductionWeb.Services", "LaaProductionWeb.Services\LaaProductionWeb.Services.csproj", "{FF167011-431A-41A7-A7DB-560E08860388}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documents", "Documents", "{59875741-02AA-4D9A-9B3C-683CA6DDBE7B}"
|
||||
@ -14,22 +12,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documents", "Documents", "{
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProductionWeb", "LaaProductionWeb\LaaProductionWeb.csproj", "{D1AD077B-00E3-4663-AB9F-23FF65D98D2F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{C01BB59F-25A6-4AC1-ADB5-C453EA57C35B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProductionWeb.UnitTests.Data", "LaaProductionWeb.UnitTests.Data\LaaProductionWeb.UnitTests.Data.csproj", "{A14581DD-E1AC-4AB0-9329-B723D24A2F3A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentSQL", "FluentSQL\FluentSQL.csproj", "{68986A99-0DBA-407C-90BE-D5ED63C41BD4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FF167011-431A-41A7-A7DB-560E08860388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FF167011-431A-41A7-A7DB-560E08860388}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FF167011-431A-41A7-A7DB-560E08860388}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -38,21 +26,10 @@ Global
|
||||
{D1AD077B-00E3-4663-AB9F-23FF65D98D2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D1AD077B-00E3-4663-AB9F-23FF65D98D2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D1AD077B-00E3-4663-AB9F-23FF65D98D2F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A14581DD-E1AC-4AB0-9329-B723D24A2F3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A14581DD-E1AC-4AB0-9329-B723D24A2F3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A14581DD-E1AC-4AB0-9329-B723D24A2F3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A14581DD-E1AC-4AB0-9329-B723D24A2F3A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{68986A99-0DBA-407C-90BE-D5ED63C41BD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{68986A99-0DBA-407C-90BE-D5ED63C41BD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{68986A99-0DBA-407C-90BE-D5ED63C41BD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{68986A99-0DBA-407C-90BE-D5ED63C41BD4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{A14581DD-E1AC-4AB0-9329-B723D24A2F3A} = {C01BB59F-25A6-4AC1-ADB5-C453EA57C35B}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9D3C9EBA-FB4B-4BF4-8158-4A9FE47D3E88}
|
||||
EndGlobalSection
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
namespace LaaProductionWeb.App_Infrastructure
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using System.Web.Mvc;
|
||||
|
||||
using ClaimsPrincipal = System.Security.Claims.ClaimsPrincipal;
|
||||
|
||||
public class AllowedRolesAttribute : AuthorizeAttribute
|
||||
{
|
||||
public AllowedRolesAttribute(params string[] roles)
|
||||
|
||||
@ -4,7 +4,9 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Web.Mvc;
|
||||
|
||||
using IAuthorizationFilter = System.Web.Mvc.IAuthorizationFilter;
|
||||
using AuthorizationContext = System.Web.Mvc.AuthorizationContext;
|
||||
|
||||
public class AuthorizationFilter : IAuthorizationFilter
|
||||
{
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
namespace LaaProductionWeb.App_Infrastructure
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using WebAPIModelState = System.Web.Http.ModelBinding.ModelStateDictionary;
|
||||
|
||||
|
||||
public class HttpErrorModel : Dictionary<string, object>
|
||||
{
|
||||
private HttpErrorModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static implicit operator HttpErrorModel(WebAPIModelState modelStateDictionary)
|
||||
{
|
||||
var badRequestErrors = new HttpErrorModel();
|
||||
|
||||
foreach (var kvp in modelStateDictionary)
|
||||
{
|
||||
var errorKey = kvp.Key ?? string.Empty;
|
||||
var errorValue = kvp.Value.Errors?.FirstOrDefault()?.ErrorMessage;
|
||||
|
||||
if (errorKey is null || errorValue is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
badRequestErrors[errorKey] = errorValue;
|
||||
}
|
||||
|
||||
return badRequestErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
namespace LaaProductionWeb
|
||||
{
|
||||
using FluentSQLClient;
|
||||
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Data;
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
using LaaProductionWeb.Services;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddSingleton<IFluentSQL>(_ => new FluentSQL(Appsettings.ConnectionString));
|
||||
services.AddSingleton(_ => FluentSQLConnection.CreateClient(Appsettings.ConnectionString));
|
||||
services.AddSingleton<IHttpService>(_ => new HttpService(Appsettings.APIURL));
|
||||
|
||||
services.AddScoped<IAccountService, AccountService>();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
namespace LaaProductionWeb.Areas.Serach.Models
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
using FluentSQLClient.Interfaces;
|
||||
|
||||
using LaaProductionWeb.Areas.Serach.Models.Interfaces;
|
||||
using LaaProductionWeb.Models;
|
||||
|
||||
@ -10,9 +11,9 @@
|
||||
|
||||
public class WildcardModel : IWildcardModel
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
|
||||
public WildcardModel(IFluentSQL fluentSQL)
|
||||
public WildcardModel(IFluentSQLConnection fluentSQL)
|
||||
=> this.fluentSQL = fluentSQL;
|
||||
|
||||
public ModelResult<IEnumerable<WildcardResult>> Find(ModelStateDictionary validationState, WildcardInputModel model)
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
namespace LaaProductionWeb.Areas.Shipment.Models
|
||||
{
|
||||
using FluentSQLClient.Interfaces;
|
||||
|
||||
using LaaProductionWeb.Areas.Shipment.Models.Interfaces;
|
||||
using LaaProductionWeb.Models;
|
||||
using LaaProductionWeb.Models.SMTP;
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class ScanModel : IScanModel
|
||||
{
|
||||
private readonly IFluentSQL fluentSQL;
|
||||
private readonly IFluentSQLConnection fluentSQL;
|
||||
private readonly SMTPClient smtpClient;
|
||||
|
||||
public ScanModel(IFluentSQL fluentSQL, SMTPClient smtpClient)
|
||||
public ScanModel(IFluentSQLConnection fluentSQL, SMTPClient smtpClient)
|
||||
{
|
||||
this.fluentSQL = fluentSQL;
|
||||
this.smtpClient = smtpClient;
|
||||
|
||||
@ -45,6 +45,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentSQLClient, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentSQLClient.1.0.0\lib\netstandard2.0\FluentSQLClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
@ -65,18 +68,36 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data.OracleClient" />
|
||||
<Reference Include="System.Data.SqlClient, Version=4.6.1.5, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SqlClient.4.8.5\lib\net461\System.Data.SqlClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IdentityModel" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
@ -114,6 +135,9 @@
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="WebGrease">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
|
||||
@ -122,6 +146,7 @@
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Infrastructure\AllowedRolesAttribute.cs" />
|
||||
@ -211,7 +236,6 @@
|
||||
<Content Include="Areas\Administration\Views\Software\Users.cshtml" />
|
||||
<Content Include="Areas\Administration\Views\Software\UsersFunctions.cshtml" />
|
||||
<Content Include="Areas\Administration\Views\web.config" />
|
||||
<None Include="packages.config" />
|
||||
<Content Include="Views\_ViewStart.cshtml" />
|
||||
<Content Include="Views\Admin\Index.cshtml" />
|
||||
<Content Include="Views\Approvals\Add.cshtml" />
|
||||
@ -242,14 +266,11 @@
|
||||
<Content Include="Views\Shipments\Print.cshtml" />
|
||||
<Content Include="Views\Shipments\Scan.cshtml" />
|
||||
<Content Include="Views\Web.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
|
||||
<Content Include="Views\Home\Session.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LaaProductionWeb.Data\LaaProductionWeb.Data.csproj">
|
||||
<Project>{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}</Project>
|
||||
<Name>LaaProductionWeb.Data</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LaaProductionWeb.Services\LaaProductionWeb.Services.csproj">
|
||||
<Project>{ff167011-431a-41a7-a7db-560e08860388}</Project>
|
||||
<Name>LaaProductionWeb.Services</Name>
|
||||
|
||||
@ -14,18 +14,11 @@
|
||||
<add key="ConnectionString" value="Data Source=SLASQL01.emea.sensus.net;Initial Catalog=Auftrag;Password=ServiceParingfile;Persist Security Info=True;User ID=ServiceParingfile;" />
|
||||
<add key="APIURL" value="https://localhost:44346/" />
|
||||
</appSettings>
|
||||
<!--
|
||||
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
|
||||
|
||||
The following attributes can be set on the <httpRuntime> tag.
|
||||
<system.Web>
|
||||
<httpRuntime targetFramework="4.8.1" />
|
||||
</system.Web>
|
||||
-->
|
||||
|
||||
<system.web>
|
||||
<customErrors mode="Off" />
|
||||
<compilation debug="true" targetFramework="4.6.2" />
|
||||
<httpRuntime targetFramework="4.6.2" />
|
||||
<compilation debug="true" targetFramework="4.8.1" />
|
||||
<httpRuntime targetFramework="4.8.1" />
|
||||
<authentication mode="None" />
|
||||
<anonymousIdentification enabled="true" />
|
||||
<authorization>
|
||||
@ -35,30 +28,30 @@
|
||||
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="ADB9793829DDAE60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Web.Infrastructure" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="ADB9793829DDAE60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Web.Infrastructure" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
@ -75,6 +68,42 @@
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.9.0" newVersion="5.2.9.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.2" newVersion="7.0.0.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.ProtectedData" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.1" newVersion="7.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.2" newVersion="7.0.0.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.5.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.codedom>
|
||||
|
||||
@ -1,22 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net462" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net481" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.9" targetFramework="net481" />
|
||||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net462" />
|
||||
<package id="Microsoft.AspNet.WebApi" version="5.2.9" targetFramework="net481" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.9" targetFramework="net481" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.9" targetFramework="net481" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.9" targetFramework="net481" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.9" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net481" />
|
||||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0" targetFramework="net481" />
|
||||
<package id="Microsoft.Extensions.DependencyInjection" version="7.0.0" targetFramework="net481" />
|
||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="7.0.0" targetFramework="net481" />
|
||||
<package id="FluentSQLClient" version="1.0.0" targetFramework="net481" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net481" />
|
||||
<package id="Modernizr" version="2.8.3" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net481" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net481" />
|
||||
<package id="System.Data.SqlClient" version="4.8.5" targetFramework="net481" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net481" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net481" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net481" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net462" />
|
||||
</packages>
|
||||
11
nuget.config
11
nuget.config
@ -1,13 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="gitlab" value="https://slm.sms-esaap.com/api/v4/projects/1011/packages/nuget/index.json" />
|
||||
<add key="nuget.laa" value="https://slm.sms-esaap.com/api/v4/projects/1149/packages/nuget/index.json" />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<packageSourceCredentials>
|
||||
<gitlab>
|
||||
<add key="Username" value="%GITLAB_PACKAGE_REGISTRY_USERNAME%" />
|
||||
<add key="ClearTextPassword" value="%GITLAB_PACKAGE_REGISTRY_PASSWORD%" />
|
||||
</gitlab>
|
||||
</packageSourceCredentials>
|
||||
</configuration>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user