wildcard search
This commit is contained in:
@@ -10,17 +10,17 @@
|
||||
|
||||
public static class PersonalizationExtensions
|
||||
{
|
||||
internal static IEnumerable<string> Intersect(this IEnumerable<string> source, Type enumType)
|
||||
=> Enum.GetNames(enumType).Intersect(source);
|
||||
|
||||
public static IServiceCollection AddAdministration(this IServiceCollection services, string sqlConnectionString)
|
||||
{
|
||||
ServiceProvider.RegisterServices(sqlConnectionString);
|
||||
ServiceProvider.RegisterInternalServices(sqlConnectionString);
|
||||
|
||||
return services
|
||||
.AddScoped<IAccountManager, AccountManager>()
|
||||
.AddScoped<IEmployeesManager, EmployeesManager>()
|
||||
.AddScoped<ISoftwareManager, SoftwareManager>();
|
||||
}
|
||||
|
||||
internal static IEnumerable<string> Intersect(this IEnumerable<string> source, Type enumType)
|
||||
=> Enum.GetNames(enumType).Intersect(source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,22 +9,20 @@
|
||||
|
||||
using System;
|
||||
|
||||
internal class ServiceProvider
|
||||
internal static class ServiceProvider
|
||||
{
|
||||
private static IServiceProvider serviceProvider;
|
||||
|
||||
internal static T GetService<T>()
|
||||
=> serviceProvider.GetService<T>();
|
||||
|
||||
internal static void RegisterServices(string sqlConnectionString)
|
||||
{
|
||||
serviceProvider = new ServiceCollection()
|
||||
internal static void RegisterInternalServices(string sqlConnectionString)
|
||||
=> serviceProvider = new ServiceCollection()
|
||||
.AddSingleton(_ => SQLConnection.CreateConnection(sqlConnectionString))
|
||||
.AddScoped<IEmployeesRepository, EmployeesRepository>()
|
||||
.AddScoped<IFunctionsRepository, FunctionsRepository>()
|
||||
.AddScoped<IRolesRepository, RolesRepository>()
|
||||
.AddScoped<ISoftwareRepository, SoftwareRepository>()
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace LaaProduction.Search.Data.Interfaces
|
||||
{
|
||||
using LaaProduction.Search.Models.Wildcard;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal interface IWildcardRepository
|
||||
{
|
||||
IEnumerable<string> Fields();
|
||||
|
||||
IEnumerable<WildcardResult> Find(string token, IEnumerable<string> fields);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
namespace LaaProduction.Search.Data
|
||||
{
|
||||
using LaaProduction.Search.Data.Interfaces;
|
||||
using LaaProduction.Search.Models.Wildcard;
|
||||
using LaaProductionSQL.Interfaces;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class WildcardRepository : IWildcardRepository
|
||||
{
|
||||
private readonly ISQLConnection sqlConnection;
|
||||
|
||||
public WildcardRepository(ISQLConnection sqlConnection)
|
||||
=> this.sqlConnection = sqlConnection;
|
||||
|
||||
public IEnumerable<string> Fields()
|
||||
=> new string[]
|
||||
{
|
||||
"CustomerNo",
|
||||
"Customer",
|
||||
"ProductionOrderNo",
|
||||
"CustomerOrderNo",
|
||||
"PosNo",
|
||||
"SerialNo",
|
||||
"CustomerSerialNo",
|
||||
"KurzBez",
|
||||
"Typ",
|
||||
"Nennweite",
|
||||
"Baulaenge",
|
||||
"Quantity",
|
||||
"FabricNo",
|
||||
"IdentNr",
|
||||
"PcbId",
|
||||
"ErRadioAddress",
|
||||
"GmRadioAddress",
|
||||
};
|
||||
|
||||
public IEnumerable<WildcardResult> Find(string token, IEnumerable<string> fields)
|
||||
=> sqlConnection
|
||||
.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(token)}
|
||||
OR REPLACE([APS].[KundeneigeneSerienNr], ' ', '') LIKE @{nameof(token)};
|
||||
-----------------------------------------------------------------------------
|
||||
-- 2. LOOK FOR PCB NUMBER ---------------------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
INSERT INTO @serienNr
|
||||
SELECT [PCBS].[MapPcbIdToSerialNumber_SerialNumber]
|
||||
FROM [MapPcbIdToSerialNumber] AS [PCBS]
|
||||
WHERE [PCBS].[MapPcbIdToSerialNumber_PcbId] LIKE @{nameof(token)};
|
||||
-----------------------------------------------------------------------------
|
||||
-- 3. LOOK FOR FUNK ADDRESS E-REGISTER --------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
INSERT INTO @serienNr
|
||||
SELECT [ER].[Seriennummer]
|
||||
FROM [eRegister] AS [ER]
|
||||
WHERE [ER].[Adresse] LIKE @{nameof(token)};
|
||||
-----------------------------------------------------------------------------
|
||||
-- 4. LOOK FOR FUNK ADDRESS GENESIS -----------------------------------------
|
||||
-----------------------------------------------------------------------------
|
||||
INSERT INTO @serienNr
|
||||
SELECT [GM].[Seriennummer]
|
||||
FROM [Genesis_Meter] AS [GM]
|
||||
WHERE [GM].[Adresse] LIKE @{nameof(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(token), $"%{token}%")
|
||||
.ExecuteReader(reader =>
|
||||
{
|
||||
var wildcardResult = new WildcardResult();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
wildcardResult[field] = reader.GetValue(field);
|
||||
}
|
||||
|
||||
return wildcardResult;
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace LaaProduction.Search
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface ISearchManager
|
||||
{
|
||||
IEnumerable<string> WildcardFields();
|
||||
|
||||
IEnumerable<IDictionary<string, object>> SearchWildcard(string token, IEnumerable<string> selectedFields);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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>{23C6F8CD-2A91-4444-A828-6A0B5B942520}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LaaProduction.Search</RootNamespace>
|
||||
<AssemblyName>LaaProduction.Search</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</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="LaaProductionSQL, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\LaaProductionSQL.1.0.0\lib\netstandard2.0\LaaProductionSQL.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>
|
||||
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<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.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.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\Interfaces\IWildcardRepository.cs" />
|
||||
<Compile Include="Data\WildcardRepository.cs" />
|
||||
<Compile Include="Interfaces\ISearchManager.cs" />
|
||||
<Compile Include="Models\Wildcard\WildcardInputModel.cs" />
|
||||
<Compile Include="Models\Wildcard\WildcardResult.cs" />
|
||||
<Compile Include="SearchExtensions.cs" />
|
||||
<Compile Include="SearchManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServiceProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace LaaProduction.Search.Models.Wildcard
|
||||
{
|
||||
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.FieldsArray);
|
||||
set => this.FieldsArray = $"{value}".Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
internal IEnumerable<string> FieldsArray { get; set; }
|
||||
|
||||
internal IEnumerable<string> GetRequiredFields(IEnumerable<string> allFields)
|
||||
{
|
||||
if (this.fields.Any())
|
||||
{
|
||||
return this.fields.Intersect(allFields, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
return allFields;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace LaaProduction.Search.Models.Wildcard
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class WildcardResult : Dictionary<string, object>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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("LaaProduction.Search")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LaaProduction.Search")]
|
||||
[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("23c6f8cd-2a91-4444-a828-6a0b5b942520")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace LaaProduction.Search
|
||||
{
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
public static class SearchExtensions
|
||||
{
|
||||
public static IServiceCollection AddSearching(this IServiceCollection services, string sqlConnectionString)
|
||||
{
|
||||
ServiceProvider.RegisterInternalServices(sqlConnectionString);
|
||||
|
||||
return services.AddScoped<ISearchManager, SearchManager>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace LaaProduction.Search
|
||||
{
|
||||
using LaaProduction.Search.Data.Interfaces;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class SearchManager : ISearchManager
|
||||
{
|
||||
private readonly IWildcardRepository wildcardRepository;
|
||||
|
||||
public SearchManager()
|
||||
=> this.wildcardRepository = ServiceProvider.GetService<IWildcardRepository>();
|
||||
|
||||
public IEnumerable<IDictionary<string, object>> SearchWildcard(string token, IEnumerable<string> selectedFields)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
return Array.Empty<IDictionary<string, object>>();
|
||||
}
|
||||
|
||||
token = token.Replace(" ", string.Empty).Trim();
|
||||
selectedFields = selectedFields ?? Array.Empty<string>();
|
||||
|
||||
if (selectedFields.Any())
|
||||
{
|
||||
selectedFields = this.wildcardRepository.Fields().Intersect(selectedFields);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedFields = this.wildcardRepository.Fields();
|
||||
}
|
||||
|
||||
return this.wildcardRepository.Find(token, selectedFields);
|
||||
}
|
||||
|
||||
public IEnumerable<string> WildcardFields()
|
||||
=> this.wildcardRepository.Fields();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace LaaProduction.Search
|
||||
{
|
||||
using LaaProduction.Search.Data;
|
||||
using LaaProduction.Search.Data.Interfaces;
|
||||
using LaaProductionSQL;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using System;
|
||||
|
||||
internal static class ServiceProvider
|
||||
{
|
||||
private static IServiceProvider serviceProvider;
|
||||
|
||||
internal static T GetService<T>()
|
||||
=> serviceProvider.GetService<T>();
|
||||
|
||||
internal static void RegisterInternalServices(string sqlConnectionString)
|
||||
=> serviceProvider = new ServiceCollection()
|
||||
.AddSingleton(_ => SQLConnection.CreateConnection(sqlConnectionString))
|
||||
.AddScoped<IWildcardRepository, WildcardRepository>()
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace LaaProduction.Shipment.Interfaces
|
||||
{
|
||||
public interface IShipmentManager
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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>{A487E02B-0E6C-4A98-84F6-4AF3E7B8E73B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LaaProduction.Shippment</RootNamespace>
|
||||
<AssemblyName>LaaProduction.Shippment</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</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="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Interfaces\IShipmentManager.cs" />
|
||||
<Compile Include="ShipmentManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
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("LaaProduction.Shippment")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LaaProduction.Shippment")]
|
||||
[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("a487e02b-0e6c-4a98-84f6-4af3e7b8e73b")]
|
||||
|
||||
// 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")]
|
||||
@@ -0,0 +1,6 @@
|
||||
Database table dependencies
|
||||
---
|
||||
[Auftrag].[dbo].[PalettenScan]
|
||||
...
|
||||
[Auftrag].[dbo].[AuftragPosition]
|
||||
[Auftrag].[dbo].[PalettenScan]
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace LaaProduction.Shipment
|
||||
{
|
||||
using LaaProduction.Shipment.Interfaces;
|
||||
|
||||
public class ShipmentManager : IShipmentManager
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -18,74 +18,74 @@
|
||||
var requiredFields = model.GetRequiredFields(this.Options());
|
||||
var ordersFound = sqlConnection
|
||||
.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 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)")
|
||||
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 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));
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProductionWeb", "LaaProd
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction.Personalization", "LaaProduction.Personalization\LaaProduction.Personalization.csproj", "{4C17FD42-7002-431A-8D6E-C57DD7D7C2D2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction.Shipment", "LaaProduction.Shipment\LaaProduction.Shipment.csproj", "{A487E02B-0E6C-4A98-84F6-4AF3E7B8E73B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction.Search", "LaaProduction.Search\LaaProduction.Search.csproj", "{23C6F8CD-2A91-4444-A828-6A0B5B942520}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -32,6 +36,14 @@ Global
|
||||
{4C17FD42-7002-431A-8D6E-C57DD7D7C2D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4C17FD42-7002-431A-8D6E-C57DD7D7C2D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4C17FD42-7002-431A-8D6E-C57DD7D7C2D2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A487E02B-0E6C-4A98-84F6-4AF3E7B8E73B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A487E02B-0E6C-4A98-84F6-4AF3E7B8E73B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A487E02B-0E6C-4A98-84F6-4AF3E7B8E73B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A487E02B-0E6C-4A98-84F6-4AF3E7B8E73B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{23C6F8CD-2A91-4444-A828-6A0B5B942520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{23C6F8CD-2A91-4444-A828-6A0B5B942520}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{23C6F8CD-2A91-4444-A828-6A0B5B942520}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{23C6F8CD-2A91-4444-A828-6A0B5B942520}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace LaaProductionWeb
|
||||
{
|
||||
using LaaProduction.Personalization;
|
||||
|
||||
using LaaProduction.Search;
|
||||
using LaaProductionHttp;
|
||||
using LaaProductionSQL;
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
@@ -33,6 +33,7 @@
|
||||
.AddScoped<IShipmentsService, ShipmentsService>()
|
||||
.AddScoped<ISoftwareService, SoftwareService>()
|
||||
.AddAdministration(Appsettings.ConnectionString)
|
||||
.AddSearching(Appsettings.ConnectionString)
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,16 @@
|
||||
routeTemplate: "api/Personalization/{controller}/{action}/{id}",
|
||||
defaults: new { action = "Get", id = RouteParameter.Optional });
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "SearchApi",
|
||||
routeTemplate: "api/Search/{controller}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional });
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "SearchActionApi",
|
||||
routeTemplate: "api/Search/{controller}/{action}/{id}",
|
||||
defaults: new { action = "Get", id = RouteParameter.Optional });
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
namespace LaaProductionWeb.Areas.Serach.Controllers
|
||||
{
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System.Web.Http;
|
||||
|
||||
public class WildcardController : ApiController
|
||||
{
|
||||
private readonly ISearchService searchService;
|
||||
|
||||
public WildcardController()
|
||||
=> this.searchService = ServiceProvider.GetService<ISearchService>();
|
||||
|
||||
[HttpOptions]
|
||||
public IHttpActionResult Options()
|
||||
=> this.Json(this.searchService.Options());
|
||||
|
||||
[HttpGet]
|
||||
public IHttpActionResult Get([FromUri] WildcardInputModel model)
|
||||
{
|
||||
if (this.ModelState.IsValid)
|
||||
{
|
||||
return this.Json(this.searchService.Find(model));
|
||||
}
|
||||
|
||||
return this.BadRequest(this.ModelState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace LaaProductionWeb.Controllers.API
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Http.ModelBinding;
|
||||
|
||||
internal static class APIExtensions
|
||||
{
|
||||
public static string Content(this ModelStateDictionary modelStateDictionary)
|
||||
{
|
||||
var errors = new Dictionary<string, string>();
|
||||
|
||||
foreach (var error in modelStateDictionary)
|
||||
{
|
||||
var errorKey = error
|
||||
.Key
|
||||
?.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
?.LastOrDefault();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(errorKey))
|
||||
{
|
||||
var errorMessage = error
|
||||
.Value
|
||||
.Errors
|
||||
.FirstOrDefault()
|
||||
.ErrorMessage;
|
||||
|
||||
errors[errorKey] = errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
return JsonConvert.SerializeObject(errors, Formatting.Indented);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
namespace LaaProductionWeb.Controllers.API.Search
|
||||
{
|
||||
using LaaProduction.Search;
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
[AuthorizeBearer]
|
||||
[RoutePrefix("api/Search/Wildcard")]
|
||||
public class WildcardController : ApiController
|
||||
{
|
||||
private readonly ISearchManager searchManager;
|
||||
|
||||
public WildcardController()
|
||||
=> this.searchManager = ServiceProvider.GetService<ISearchManager>();
|
||||
|
||||
[HttpGet]
|
||||
public IHttpActionResult Get()
|
||||
{
|
||||
var fields = this.searchManager.WildcardFields();
|
||||
|
||||
return this.Json(fields);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IHttpActionResult Post([FromBody] WildcardSearchModel model)
|
||||
{
|
||||
IEnumerable<IDictionary<string, object>> results = Array.Empty<IDictionary<string, object>>();
|
||||
|
||||
if (this.ModelState.IsValid)
|
||||
{
|
||||
results = this.searchManager.SearchWildcard(model.Token, model.SelectedFields);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.ResponseMessage(new HttpResponseMessage
|
||||
{
|
||||
Content = new StringContent(this.ModelState.Content()),
|
||||
RequestMessage = this.Request,
|
||||
StatusCode = HttpStatusCode.BadRequest,
|
||||
Version = this.Request.Version
|
||||
});
|
||||
}
|
||||
|
||||
return this.Json(results);
|
||||
}
|
||||
}
|
||||
|
||||
public class WildcardSearchModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(50, MinimumLength = 3)]
|
||||
[RegularExpression("^[0-9 a-z-A-Z]+$")]
|
||||
public string Token { get; set; }
|
||||
|
||||
public string Fields { get; set; }
|
||||
|
||||
internal IEnumerable<string> SelectedFields
|
||||
=> this.Fields
|
||||
?.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
?? Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
namespace LaaProductionWeb.Controllers
|
||||
{
|
||||
using LaaProduction.Personalization;
|
||||
|
||||
using LaaProductionHttp.Interfaces;
|
||||
using LaaProductionWeb.App_Infrastructure;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models.Search;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -15,12 +16,12 @@
|
||||
public class SearchController : Controller
|
||||
{
|
||||
private readonly IOrdersService ordersService;
|
||||
private readonly IHttpService httpService;
|
||||
private readonly IHttpClient httpClient;
|
||||
|
||||
public SearchController()
|
||||
{
|
||||
this.ordersService = ServiceProvider.GetService<IOrdersService>();
|
||||
this.httpService = ServiceProvider.GetService<IHttpService>();
|
||||
this.httpClient = ServiceProvider.GetService<IHttpClient>();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@@ -48,23 +49,33 @@
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[AllowedRoles(UsersRoles.WEB_Admin)]
|
||||
public async Task<ActionResult> Wildcard()
|
||||
{
|
||||
var httpOptions = await this.httpService.OptionsAsync("/Search/Wildcard");
|
||||
var fieldsResult = await this.httpClient
|
||||
.Get("/api/Search/Wildcard")
|
||||
.AuthorizeBearer(this.User.GetNameIdentifier())
|
||||
.SendAsync<IEnumerable<string>>();
|
||||
|
||||
var model = new SearchWildcardModel();
|
||||
|
||||
if (httpOptions.Succeeded)
|
||||
if (fieldsResult.Succeeded)
|
||||
{
|
||||
model.Fields = httpOptions
|
||||
.Deserialize<List<string>>()
|
||||
.ToDictionary(x => x, x => false);
|
||||
if (fieldsResult.Value != null)
|
||||
{
|
||||
model.Fields = fieldsResult.Value.ToDictionary(x => x, x => false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ModelState.AddModelErrors(fieldsResult);
|
||||
}
|
||||
|
||||
return this.View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[AllowedRoles(UsersRoles.WEB_API_Explorer)]
|
||||
[AllowedRoles(UsersRoles.WEB_Admin)]
|
||||
public async Task<ActionResult> Wildcard(SearchWildcardModel model)
|
||||
{
|
||||
var fields = string.Empty;
|
||||
@@ -74,20 +85,19 @@
|
||||
fields = WebUtility.UrlEncode(string.Join(",", model.Fields.Where(x => x.Value).Select(x => x.Key)));
|
||||
}
|
||||
|
||||
var httpResult = await this.httpService.GetAsync($"/Search/Wildcard?token={model.Token}&fields={fields}");
|
||||
var httpResult = await this.httpClient
|
||||
.Post($"/api/Search/Wildcard")
|
||||
.WhitJsonBody(new { model.Token, fields })
|
||||
.AuthorizeBearer(this.User.GetNameIdentifier())
|
||||
.SendAsync<IEnumerable<IDictionary<string, object>>>();
|
||||
|
||||
if (httpResult.Succeeded)
|
||||
{
|
||||
model.Results = httpResult.Deserialize<List<Dictionary<string, object>>>();
|
||||
model.Results = httpResult.Value ?? Array.Empty<IDictionary<string, object>>();
|
||||
}
|
||||
else
|
||||
{
|
||||
var errors = httpResult.Deserialize<Dictionary<string, string>>();
|
||||
|
||||
foreach (var errorKVP in errors)
|
||||
{
|
||||
this.ModelState.AddModelError(errorKVP.Key, errorKVP.Value.Replace("Token", "'Search text'"));
|
||||
}
|
||||
this.ModelState.AddModelErrors(httpResult);
|
||||
}
|
||||
|
||||
return this.View(model);
|
||||
|
||||
@@ -195,7 +195,6 @@
|
||||
<Compile Include="Areas\Personalization\Models\Software\UserFunctions.cs" />
|
||||
<Compile Include="Areas\Personalization\Models\Software\UsersFunctionsInputModel.cs" />
|
||||
<Compile Include="Areas\Personalization\Models\Software\UsersFunctionsModel.cs" />
|
||||
<Compile Include="Areas\Serach\Controllers\WildcardController.cs" />
|
||||
<Compile Include="Areas\Shipment\Controllers\ScannedController.cs" />
|
||||
<Compile Include="Areas\Shipment\Models\Interfaces\IScanModel.cs" />
|
||||
<Compile Include="Areas\Shipment\Models\ScanModel.cs" />
|
||||
@@ -203,10 +202,12 @@
|
||||
<Compile Include="Areas\Software\Controllers\FunctionsController.cs" />
|
||||
<Compile Include="Areas\Software\SoftwareAreaRegistration.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\API\APIExtensions.cs" />
|
||||
<Compile Include="Controllers\API\Personalization\EmployeesController.cs" />
|
||||
<Compile Include="Controllers\API\Personalization\SoftwareController.cs" />
|
||||
<Compile Include="Controllers\API\Personalization\LoginController.cs" />
|
||||
<Compile Include="Controllers\API\Personalization\RolesController.cs" />
|
||||
<Compile Include="Controllers\API\Search\WildcardController.cs" />
|
||||
<Compile Include="Controllers\ApprovalsController.cs" />
|
||||
<Compile Include="Controllers\EmailController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
@@ -299,6 +300,14 @@
|
||||
<Project>{4c17fd42-7002-431a-8d6e-c57dd7d7c2d2}</Project>
|
||||
<Name>LaaProduction.Personalization</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LaaProduction.Search\LaaProduction.Search.csproj">
|
||||
<Project>{23c6f8cd-2a91-4444-a828-6a0b5b942520}</Project>
|
||||
<Name>LaaProduction.Search</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LaaProduction.Shipment\LaaProduction.Shipment.csproj">
|
||||
<Project>{a487e02b-0e6c-4a98-84f6-4af3e7b8e73b}</Project>
|
||||
<Name>LaaProduction.Shipment</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LaaProductionWeb.Services\LaaProductionWeb.Services.csproj">
|
||||
<Project>{ff167011-431a-41a7-a7db-560e08860388}</Project>
|
||||
<Name>LaaProductionWeb.Services</Name>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="container-fluid">
|
||||
<form action="~/Search/Wildcard" method="post" autocomplete="off">
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-12 d-flex">
|
||||
<div class="col-md-12 d-flex mb-3">
|
||||
@this.Html.LabelFor(x => x.Fields, new { @for = "serial_nr", @class = "text-smallcaps fw-bold" })
|
||||
</div>
|
||||
@if (this.Model.Fields != null)
|
||||
@@ -24,6 +24,9 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="row mb-3 small text-danger">
|
||||
@this.Html.ValidationSummary()
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="input-group mt-3">
|
||||
@@ -40,30 +43,41 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="table-responsive rounded-1 mt-3">
|
||||
<table class="table table-warning table-bordered mb-0">
|
||||
@if (this.Model.Results != null)
|
||||
{
|
||||
@if (this.Model.Results != null)
|
||||
{
|
||||
var headers = this.Model.Results.FirstOrDefault()?.Keys ?? Array.Empty<string>();
|
||||
|
||||
<table class="table table-warning table-bordered mb-0">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
@foreach (var header in this.Model.Results.FirstOrDefault()?.Keys ?? Array.Empty<string>())
|
||||
@foreach (var header in headers)
|
||||
{
|
||||
<th class="py-3">@header</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
@foreach (var data in this.Model.Results)
|
||||
@if (this.Model.Results.Any())
|
||||
{
|
||||
foreach (var data in this.Model.Results)
|
||||
{
|
||||
<tr>
|
||||
@foreach (var value in data.Values)
|
||||
{
|
||||
<td class="py-3">@value</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
else if (this.IsPost)
|
||||
{
|
||||
<tr>
|
||||
@foreach (var value in data.Values)
|
||||
{
|
||||
<td class="py-3">@value</td>
|
||||
}
|
||||
<td colspan="@(this.Model.Fields?.Count ?? 1)" class="py-3">Keine ergebnisse gefunden for '@this.Model.Token'</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
}
|
||||
</table>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user