Init, first working version - Only GetBestellungen implemented

This commit is contained in:
2025-09-09 12:12:43 +02:00
parent 38fafeec0f
commit f5cd3989aa
22 changed files with 1282 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<appSettings>
<add key="ThisWebApiServiceEndpoint" value="http://*:8901"/>
<add key="ActiveSapDestinationName" value="DG2"/>
<add key="SapDefaultUSER" value="XXX"/>
<add key="SapDefaultPASSWD" value="XXX"/>
<add key="SapCLIENT" value="100"/>
<add key="SapLanguage" value="DE"/>
<add key="SapASHOST" value="XXX"/>
<add key="SapSYSNR" value="00"/>
<add key="SapMaxPoolSize" value="10"/>
<add key="SapIdleTimeout" value="10"/>
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<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="sapnco" publicKeyToken="50436dca5c7f7d23" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.0.42" newVersion="3.1.0.42"/>
</dependentAssembly>
<dependentAssembly>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="sapnco_utils" publicKeyToken="50436dca5c7f7d23" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.0.42" newVersion="3.1.0.42"/>
</dependentAssembly>
</assemblyBinding>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.3.0" newVersion="4.2.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -0,0 +1,145 @@
<?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>{236F375E-DEA1-461E-A05D-5358DCD25D09}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>CompControl.SapFrameworkConnector</RootNamespace>
<AssemblyName>CompControl.SapFrameworkConnector</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CompControl">
<HintPath>ExternalDLLs\CompControl.dll</HintPath>
</Reference>
<Reference Include="CompControl.ErpConnector.Service">
<HintPath>ExternalDLLs\CompControl.ErpConnector.Service.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=3.2.0.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\log4net.3.2.0\lib\net462\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin, Version=4.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Owin.4.2.3\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=4.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Owin.Host.HttpListener.4.2.3\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Hosting, Version=4.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Owin.Hosting.4.2.3\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json.Bson, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll</HintPath>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="sapnco">
<HintPath>ExternalDLLs\sapnco.dll</HintPath>
</Reference>
<Reference Include="sapnco_utils">
<HintPath>ExternalDLLs\sapnco_utils.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.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<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.Http.Formatting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.AspNet.WebApi.Client.6.0.0\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=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\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.Web" />
<Reference Include="System.Web.Http, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.3.0\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http.Owin, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.AspNet.WebApi.Owin.5.3.0\lib\net45\System.Web.Http.Owin.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.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigHelper.cs" />
<Compile Include="GBS\GBSApiController.cs" />
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="ServiceController.cs" />
<Compile Include="Standard\SapStandardFunctions.cs" />
<Compile Include="Service.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Service.Designer.cs">
<DependentUpon>Service.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Standard\StandardApiController.cs" />
<Compile Include="Startup.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Service.resx">
<DependentUpon>Service.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35728.132 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompControl.SapFrameworkConnector", "CompControl.SapFrameworkConnector.csproj", "{236F375E-DEA1-461E-A05D-5358DCD25D09}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{236F375E-DEA1-461E-A05D-5358DCD25D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{236F375E-DEA1-461E-A05D-5358DCD25D09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{236F375E-DEA1-461E-A05D-5358DCD25D09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{236F375E-DEA1-461E-A05D-5358DCD25D09}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,19 @@
using System;
using System.Configuration;
namespace CompControl.SapFrameworkConnector
{
public class ConfigHelper
{
public static readonly string ThisWebApiServiceEndpoint = ConfigurationManager.AppSettings["ThisWebApiServiceEndpoint"];
public static readonly string ActiveSapDestinationName = ConfigurationManager.AppSettings["ActiveSapDestinationName"];
public static readonly string SapDefaultUSER = ConfigurationManager.AppSettings["SapDefaultUSER"];
public static readonly string SapDefaultPASSWD = ConfigurationManager.AppSettings["SapDefaultPASSWD"];
public static readonly string SapCLIENT = ConfigurationManager.AppSettings["SapCLIENT"];
public static readonly string SapLanguage = ConfigurationManager.AppSettings["SapLanguage"];
public static readonly string SapASHOST = ConfigurationManager.AppSettings["SapASHOST"];
public static readonly string SapSYSNR = ConfigurationManager.AppSettings["SapSYSNR"];
public static readonly string SapMaxPoolSize = ConfigurationManager.AppSettings["SapMaxPoolSize"];
public static readonly string SapIdleTimeout = ConfigurationManager.AppSettings["SapIdleTimeout"];
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
namespace CompControl.SapFrameworkConnector
{
[RoutePrefix("api/gbs")]
public class GBSApiController
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace CompControl.SapFrameworkConnector
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service()
};
ServiceBase.Run(ServicesToRun);
}
}
}

View File

@@ -0,0 +1,66 @@
using System.Configuration.Install;
namespace CompControl.SapFrameworkConnector
{
partial class ProjectInstaller
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
// serviceProcessInstaller1
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
// serviceInstaller1
this.serviceInstaller1.DelayedAutoStart = true;
this.serviceInstaller1.Description = "CompControl SapFrameworkConnector";
this.serviceInstaller1.ServiceName = "CompControl.SapFrameworkConnector";
this.serviceInstaller1.DisplayName = this.serviceInstaller1.ServiceName;
this.serviceInstaller1.ServicesDependedOn = new string[] { "" };
this.serviceInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_AfterInstall);
// ProjectInstaller
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
namespace CompControl.SapFrameworkConnector
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>227, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@@ -0,0 +1,33 @@
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("CompControl.SapFrameworkConnector")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CompControl.SapFrameworkConnector")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[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("236f375e-dea1-461e-a05d-5358dcd25d09")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,36 @@
namespace CompControl.SapFrameworkConnector
{
partial class Service
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ServiceName = "CompControl.SapFrameworkConnector";
}
#endregion
}
}

View File

@@ -0,0 +1,65 @@
using CompControl.SapFrameworkConnector;
using Microsoft.Owin;
using Microsoft.Owin.Hosting;
using SAP.Middleware.Connector;
using System;
using System.Configuration;
using System.ServiceProcess;
using System.Xml;
namespace CompControl.SapFrameworkConnector
{
public partial class Service : ServiceBase
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private IDisposable _server = null;
public Service()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
RfcTrace.DefaultTraceLevel = 3;
RfcTrace.TraceDirectory = @"C:\Temp\CC\NCoLogs"; // Log-Dateien in diesem Ordner speichern
_log.Debug("SAP NCo Logging aktiviert: " + RfcTrace.TraceDirectory);
var config = new ConfigFileDestination();
if (!RfcDestinationManager.IsDestinationConfigurationRegistered()) { RfcDestinationManager.RegisterDestinationConfiguration(config); }
var dest = RfcDestinationManager.GetDestination(ConfigHelper.ActiveSapDestinationName); // Jetzt kannst du die Destination abrufen
_log.Info("SAP Destination loaded: " + dest.Name);
_server = WebApp.Start<Startup>(url: ConfigHelper.ThisWebApiServiceEndpoint);
_log.Info($"Service started successfully at: {ConfigHelper.ThisWebApiServiceEndpoint}");
}
protected override void OnStop()
{
_log.Debug($"Service was stopped!");
}
}
}
public class ConfigFileDestination : IDestinationConfiguration
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public RfcConfigParameters GetParameters(string destinationName)
{
RfcConfigParameters parms = new RfcConfigParameters();
parms.Add(RfcConfigParameters.AppServerHost, ConfigHelper.SapASHOST);
parms.Add(RfcConfigParameters.SystemNumber, ConfigHelper.SapSYSNR);
parms.Add(RfcConfigParameters.Client, ConfigHelper.SapCLIENT);
parms.Add(RfcConfigParameters.User, ConfigHelper.SapDefaultUSER);
parms.Add(RfcConfigParameters.Password, ConfigHelper.SapDefaultPASSWD);
parms.Add(RfcConfigParameters.Language, ConfigHelper.SapLanguage);
_log.Debug($"Destination registered => ASHOST={ConfigHelper.SapASHOST} | SYSNR={ConfigHelper.SapSYSNR} | CLIENT={ConfigHelper.SapCLIENT} | USER={ConfigHelper.SapDefaultUSER} | LANG={ConfigHelper.SapLanguage}");
return parms;
}
public bool ChangeEventsSupported() => false;
public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged;
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@@ -0,0 +1,22 @@
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace CompControl.SapFrameworkConnector
{
[RoutePrefix("api/service")]
public class ServiceController : ApiController
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Ping
// GET api/service/ping
[Route("ping")]
[HttpGet]
public HttpResponseMessage Ping()
{
return Request.CreateResponse(HttpStatusCode.OK, true);
}
#endregion
}
}

View File

@@ -0,0 +1,261 @@
using log4net;
using SAP.Middleware.Connector;
using System;
using System.Collections.Generic;
using static CompControl.ErpConnector.Service.Models.Cicor_SapModels;
using static CompControl.ErpConnector.Service.Models.SapDataTypes;
namespace CompControl.SapFrameworkConnector
{
public class SapStandardFunctions
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //Logger
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
public static DateTime ConvertSapDateToDateTime(string sapDate, bool delimitersUsed = true)
{
if (delimitersUsed) //Style: 2022-02-18, mostly gotten from SAP with GetString on DATS
{
int year = Convert.ToInt32(sapDate.Substring(0, 4));
int month = Convert.ToInt32(sapDate.Substring(5, 2));
int day = Convert.ToInt32(sapDate.Substring(8, 2));
return new DateTime(year, month, day);
}
else //Style: 20220218 (Like stored in SAP, needed for input)
{
int year = Convert.ToInt32(sapDate.Substring(0, 4));
int month = Convert.ToInt32(sapDate.Substring(4, 2));
int day = Convert.ToInt32(sapDate.Substring(6, 2));
return new DateTime(year, month, day);
}
}
public static string ConvertDateTimeToSapTime(DateTime date)
{
if (date == null) { return "00000000"; }
return date.ToString("yyyyMMdd");
}
public static string ConvertMslToSAPString(string matfeuchte)
{
if (matfeuchte == null || matfeuchte.Equals("")) { return "01"; }
switch (matfeuchte)
{
case "0":
return "01";
case "1":
return "01";
case "2":
return "02";
case "3":
return "03";
case "4":
return "04";
case "5":
return "05";
case "6":
return "06";
case "2a":
return "07";
case "5a":
return "08";
default:
return "01";
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
public static GetMATNRfromBMATN_EXPORT GetMATNRfromBMATN(GetMATNRfromBMATN_IMPORT import)
{
string errorMsg = "";
GetMATNRfromBMATN_EXPORT export = new GetMATNRfromBMATN_EXPORT();
try
{
RfcDestination dest = RfcDestinationManager.GetDestination(ConfigHelper.ActiveSapDestinationName);
IRfcFunction func = dest.Repository.CreateFunction("RFC_READ_TABLE"); //Create Function
IRfcTable t2 = func.GetTable("DATA");
t2.Clear();
IRfcTable options2 = func.GetTable("OPTIONS");
options2.Clear();
options2.Append();
options2.SetValue("TEXT", "BMATN = '" + import.BMATN?.Trim().PadLeft(18, '0') + "'");
IRfcTable fields2 = func.GetTable("FIELDS");
fields2.Append(1);
fields2.CurrentIndex = 0; fields2.SetValue(0, "EMATN");
func.SetValue("QUERY_TABLE", "AMPL"); //Set Value to function
func.SetValue("DELIMITER", ";"); //Set Value to function
func.SetValue("USE_ET_DATA_4_RETURN", "0");
func.Invoke(dest); //Invoke function at Sap destination
IRfcTable rfcTable2 = func.GetTable("DATA"); //Process return values
_log.Debug("Number rows DATA of MATNR found: " + rfcTable2.Count);
int rowCount2 = rfcTable2.Count;
foreach (IRfcStructure structure in rfcTable2)
{
export.MATNR = structure.GetString(0);
_log.Debug("MATNR received: " + export.MATNR);
}
}
catch (Exception ex) { errorMsg += "CI: SAP Other Exception: " + ex; }
if (!errorMsg.Equals("")) { _log.Error(errorMsg); }
return export;
}
public static GetMAKTXfromMATNR_EXPORT GetMAKTXfromMATNR(GetMAKTXfromMATNR_IMPORT import)
{
string errorMsg = "";
GetMAKTXfromMATNR_EXPORT export = new GetMAKTXfromMATNR_EXPORT();
try
{
RfcDestination dest = RfcDestinationManager.GetDestination(ConfigHelper.ActiveSapDestinationName);
IRfcFunction func3 = dest.Repository.CreateFunction("RFC_READ_TABLE"); //Create Function
IRfcTable t3 = func3.GetTable("DATA");
t3.Clear();
IRfcTable options3 = func3.GetTable("OPTIONS");
options3.Clear();
options3.Append();
options3.SetValue("TEXT", "MATNR = '" + import.MATNR?.Trim().PadLeft(18, '0') + "'");
options3.Append();
IRfcTable fields3 = func3.GetTable("FIELDS");
fields3.Append(1);
fields3.CurrentIndex = 0; fields3.SetValue(0, "MAKTX");
func3.SetValue("QUERY_TABLE", "MAKT");
func3.SetValue("DELIMITER", ";");
func3.SetValue("USE_ET_DATA_4_RETURN", "0");
func3.Invoke(dest); //Invoke function at Sap destination
IRfcTable rfcTable3 = func3.GetTable("DATA"); //Process return values
_log.Debug("Number rows DATA of MAKTX found: " + rfcTable3.Count);
int rowCount3 = rfcTable3.Count;
foreach (IRfcStructure structure in rfcTable3)
{
export.MAKTX = structure.GetString(0);
_log.Info("MAKTX received: " + export.MAKTX);
}
}
catch (Exception ex) { errorMsg += "CI: SAP Other Exception: " + ex; }
if (!errorMsg.Equals("")) { _log.Error(errorMsg); }
_log.Debug($"GetMAKTXforMATNR: Found MAKTX for MATNR {import.MATNR}: {export.MAKTX}");
return export;
}
public static BAPI_PO_GETDETAIL_EXPORT BAPI_PO_GETDETAILS(BAPI_PO_GETDETAIL_IMPORT import)
{
string errorMsg = "";
BAPI_PO_GETDETAIL_EXPORT export = new BAPI_PO_GETDETAIL_EXPORT();
List<BAPIEKPO> poItemBuffer = new List<BAPIEKPO>();
if (import != null)
{
try
{
RfcDestination dest = RfcDestinationManager.GetDestination(ConfigHelper.ActiveSapDestinationName);
IRfcFunction func = dest.Repository.CreateFunction("BAPI_PO_GETDETAIL"); //Create Function
func.SetValue("PURCHASEORDER", import.PURCHASEORDER?.Trim().PadLeft(10, '0')); //Set Value to function
func.SetValue("ITEMS", import.ITEMS); //Set Value to function
func.SetValue("HISTORY", "X");
func.SetValue("SCHEDULES", "X");
func.SetValue("ACCOUNT_ASSIGNMENT", "X");
func.SetValue("ITEM_TEXTS", "X");
func.SetValue("HEADER_TEXTS", "X");
func.SetValue("SERVICES", "X");
func.SetValue("CONFIRMATIONS", "X");
func.SetValue("SERVICE_TEXTS", "X");
func.SetValue("EXTENSIONS", "X");
func.Invoke(dest); //Invoke function at Sap destination
IRfcStructure po_header_struct = func.GetStructure("PO_HEADER");
export.PO_HEADER.PO_NUMBER = po_header_struct.GetString("PO_NUMBER");
export.PO_HEADER.CREATED_ON = po_header_struct.GetString("CREATED_ON");
export.PO_HEADER.CREATED_BY = po_header_struct.GetString("CREATED_BY");
export.PO_HEADER.DOC_TYPE = po_header_struct.GetString("DOC_TYPE");
export.PO_HEADER.VENDOR = po_header_struct.GetString("VENDOR");
export.PO_HEADER.VEND_NAME = po_header_struct.GetString("VEND_NAME");
if (!(export.PO_HEADER.DOC_TYPE.Equals("MP") || export.PO_HEADER.DOC_TYPE.Equals("MP") || export.PO_HEADER.DOC_TYPE.Equals("MP") || export.PO_HEADER.DOC_TYPE.Equals("ZBRO"))) { }
IRfcTable po_items_table = func.GetTable("PO_ITEMS");
foreach (IRfcStructure row in po_items_table)
{
BAPIEKPO temp = new BAPIEKPO();
temp.PO_NUMBER = row.GetString("PO_NUMBER").TrimStart('0') ?? "";
temp.PO_ITEM = row.GetString("PO_ITEM").TrimStart('0') ?? "";
temp.STATUS = row.GetString("STATUS") ?? "";
temp.CHANGED_ON = row.GetString("CHANGED_ON") ?? "";
temp.SHORT_TEXT = row.GetString("SHORT_TEXT") ?? "";
temp.MATERIAL = row.GetString("MATERIAL").TrimStart('0') ?? "";
temp.PUR_MAT = row.GetString("PUR_MAT").TrimStart('0') ?? "";
temp.QUANTITY = row.GetDecimal("QUANTITY");
temp.UNIT = row.GetString("UNIT") ?? "";
temp.PLANT = row.GetString("PLANT") ?? "";
temp.MAT_GRP = row.GetString("MAT_GRP") ?? "";
temp.ACCTASSCAT = row.GetString("ACCTASSCAT") ?? "";
temp.QUAL_INSP = row.GetString("QUAL_INSP") ?? "";
temp.MANU_MAT = row.GetString("MANU_MAT") ?? "";
temp.MFR_NO = row.GetString("MFR_NO") ?? "";
temp.VEND_MAT = row.GetString("VEND_MAT") ?? "";
temp.STOR_LOC = row.GetString("STORE_LOC") ?? "";
temp.DELETE_IND = row.GetString("DELETE_IND") ?? "";
poItemBuffer.Add(temp);
}
IRfcTable po_item_hist_total = func.GetTable("PO_ITEM_HISTORY_TOTALS");
foreach (IRfcStructure row in po_item_hist_total)
{
BAPIEKBES temp = new BAPIEKBES();
temp.BLOCKED_QY = row.GetDecimal("BLOCKED_QY");
temp.BL_QTY = row.GetDecimal("BL_QTY");
temp.BL_QTY_TOTAL = row.GetDecimal("BL_QTY_TOTAL");
temp.DELIV_QTY = row.GetDecimal("DELIV_QTY");
temp.DL_QTY_TOTAL = row.GetDecimal("DL_QTY_TOTAL");
temp.DL_QTY_TRSP = row.GetDecimal("DL_QTY_TRSP");
temp.IV_QTY = row.GetDecimal("IV_QTY");
temp.IV_QTY_TOTAL = row.GetDecimal("IV_QTY_TOTAL");
temp.PO_ITEM = row.GetString("PO_ITEM").TrimStart('0') ?? "";
temp.PO_PR_QNT = row.GetDecimal("PO_PR_QNT");
temp.SERIAL_NO = row.GetString("SERIAL_NO").TrimStart('0') ?? "";
temp.WITHDR_QTY = row.GetDecimal("WITHDR_QTY");
export.PO_ITEM_HISTORY_TOTAL.Add(temp);
}
IRfcTable po_item_hist = func.GetTable("PO_ITEM_HISTORY");
foreach (IRfcStructure row in po_item_hist)
{
BAPIEKBE temp = new BAPIEKBE();
temp.BATCH = row.GetString("BATCH") ?? "";
temp.DOC_YEAR = row.GetString("DOC_YEAR") ?? "";
temp.MATDOC_ITM = row.GetString("MATDOC_ITM") ?? "";
temp.MATERIAL = row.GetString("MATERIAL") ?? "";
temp.MAT_DOC = row.GetString("MAT_DOC") ?? "";
temp.MOVE_TYPE = row.GetString("MOVE_TYPE") ?? "";
temp.PO_ITEM = row.GetString("PO_ITEM") ?? "";
temp.PROCESS_ID = row.GetString("PROCESS_ID") ?? "";
temp.PSTNG_DATE = row.GetString("PSTNG_DATE") ?? "";
temp.PUR_MAT = row.GetString("PUR_MAT") ?? "";
temp.QUANTITY = row.GetDecimal("QUANTITY");
temp.REF_DOC_NO = row.GetString("REF_DOC_NO") ?? "";
temp.SERIAL_NO = row.GetString("SERIAL_NO") ?? "";
temp.DELIV_QTY = row.GetDecimal("DELIV_QTY");
temp.DELIV_UNIT = row.GetString("DELIV_UNIT") ?? "";
export.PO_ITEM_HISTORY.Add(temp);
}
}
catch (Exception ex) { errorMsg += "CI: SAP Other Exception: " + ex; }
}
else { _log.Debug("Error, IMPORT for BAPI_PO_GETDETAILS was NULL! "); }
if (!errorMsg.Equals("")) { _log.Debug(errorMsg); }
return export;
}
}
}

View File

@@ -0,0 +1,141 @@
using System;
using System.Net.Http;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using CompControl.ErpConnector.Service.Models;
using static CompControl.ErpConnector.Service.Models.Cicor_SapModels;
using static CompControl.ErpConnector.Service.Models.SapDataTypes;
namespace CompControl.SapFrameworkConnector
{
[RoutePrefix("api/we")]
public class StandardApiController: ApiController
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
[Route("getbestellungen")]
[HttpPut]
public async Task<HttpResponseMessage> GetBestellungen([FromBody] FilterBestellungen filterBestellungen, CancellationToken cancellationToken)
{
ApiResultBestellungen result = new ApiResultBestellungen(); //New ApiResult to return via Web
try
{
_log.Debug("GetBestellungen received for Filter: " + filterBestellungen.ToString());
BAPI_PO_GETDETAIL_IMPORT import = new BAPI_PO_GETDETAIL_IMPORT() { PURCHASEORDER = filterBestellungen.OrderNo };
BAPI_PO_GETDETAIL_EXPORT details = SapStandardFunctions.BAPI_PO_GETDETAILS(import);
int cnt = 0;
foreach (BAPIEKPO det in details.PO_ITEMS)
{
cnt++;
string inspect = "";
string inspectInfo = "";
string prioText = "";
string prioChar = "";
string ItemText1 = "";
bool posIsClosed = false;
DateTime expDeliverDate = DateTime.MaxValue;
if (det.QUAL_INSP.Equals("X"))
{
inspect = "Q";
if (ConfigHelper.SapLanguage.Equals("DE")) { inspectInfo = "Qualitaetspruefung erforderlich!"; }
else { inspectInfo = "Quality check mandatory!"; }
}
expDeliverDate = SapStandardFunctions.ConvertSapDateToDateTime(det.ExpectedDeliveryDate, false);
if (det.QUANTITY <= det.QUANTITYPROCESSED) { posIsClosed = true; }
GetMAKTXfromMATNR_IMPORT getMak = new GetMAKTXfromMATNR_IMPORT();
getMak.MATNR = det.MATERIAL.Trim();
GetMAKTXfromMATNR_EXPORT outMak = SapStandardFunctions.GetMAKTXfromMATNR(getMak);
ItemText1 = outMak.MAKTX;
GrDataItem gr = new GrDataItem();
gr.AcceptedManufacturesLink = cnt.ToString();
gr.Created = SapStandardFunctions.ConvertSapDateToDateTime(details.PO_HEADER.CREATED_ON);
gr.LastUpdate = SapStandardFunctions.ConvertSapDateToDateTime(det.CHANGED_ON);
gr.PosIsClosed = posIsClosed;
gr.OrderNo = det.PO_NUMBER;
gr.OrderPos = det.PO_ITEM;
gr.OrderQuantity = det.QUANTITY;
gr.ItemNo = det.MATERIAL.Trim();
gr.ItemText1 = ItemText1;
gr.ItemNoRef = gr.CustomValue05 = det.PUR_MAT;
gr.OrderPosInfoText = det.ACCTASSCAT;
gr.QuantityProcessed = det.QUANTITYPROCESSED;
gr.QuantityUnit = det.UNIT;
gr.Plant = det.PLANT;
gr.Inspection = inspect;
gr.InspectionInfo = inspectInfo;
gr.Priority = prioChar;
gr.PriorityInfoText = prioText;
gr.CustomValue01 = det.QUAL_INSP;
gr.ExpectedDeliveryDate = expDeliverDate;
gr.MPN = det.MANU_MAT.Trim();
gr.SupplierNo = details.PO_HEADER.VENDOR;
gr.SupplierName = details.PO_HEADER.VEND_NAME;
gr.SupplierItemNo = det.VEND_MAT;
gr.StorageLocation = det.STOR_LOC;
gr.Schedule = det.SCHEDULE.TrimStart('0');
gr.CustomValue08 = details.PO_HEADER.DOC_TYPE;
if (!det.DELETE_IND.Equals("L")) { result.GrDataItems.Add(gr); }
}
_log.Debug($"Result of GetBestellungen now consists of {result.GrDataItems.Count} GrDataItems and {result.ManufacturerDataItems.Count} ManufactuerDataItems...");
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
else { _log.Error(result); } //An error occurred
}
catch (Exception ex)
{
string sm = $"GetBestellungen: An unexpected error occured: " + ex;
_log.Error(sm);
result = new ApiResultBestellungen //ApiResult on Exception
{
ErrorNumber = 101,
MessageShort = sm,
MessageLong = sm,
MessageTechnical = $"{sm} [{filterBestellungen}] - {ex}"
};
}
return Request.CreateResponse(HttpStatusCode.OK, result);
}
[Route("getherstellerdaten")]
public async Task<HttpResponseMessage> GetHerstellerdaten([FromUri] string itemNo, CancellationToken cancellationToken)
{
ApiResultHerstellerdaten result = new ApiResultHerstellerdaten(); //New ApiResult to return via Web
_log.Debug("GetHerstellerdaten received for itemNo: " + itemNo);
try
{
if (result.IsSuccessful) { _log.Debug(result); } //Action was successful => log for debug
else { _log.Error(result); } //An error occurred
}
catch (Exception ex)
{
string sm = $"GetHerstellerDaten: An unexpected error occured for '{itemNo}' " + ex;
_log.Error(sm);
result = new ApiResultHerstellerdaten //Default ApiResult on error
{
ErrorNumber = 101,
MessageShort = sm,
MessageLong = sm,
MessageTechnical = $"{sm} [{itemNo}] - {ex}"
};
}
return Request.CreateResponse(HttpStatusCode.OK, result);
}
}
}

View File

@@ -0,0 +1,95 @@
using Owin;
using System.Web.Http.ExceptionHandling;
using System.Web.Http;
using Microsoft.Owin;
using System.Net.Http;
using System.Net;
using System.Threading.Tasks;
using System.Threading;
using System;
[assembly: OwinStartup(typeof(CompControl.SapFrameworkConnector.Startup))]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
namespace CompControl.SapFrameworkConnector
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
config.Services.Replace(typeof(IExceptionLogger), new UnhandledExceptionLogger());
config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler());
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });
app.UseWebApi(config);
}
}
class UnhandledExceptionLogger : ExceptionLogger
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public override void Log(ExceptionLoggerContext context) { _log.Error("Web API - Unhandled Exception", context.Exception); }
}
class GlobalExceptionHandler : ExceptionHandler
{
public override void Handle(ExceptionHandlerContext context)
{
if (context.Exception is ArgumentNullException)
{
var result = new HttpResponseMessage(HttpStatusCode.BadRequest)
{
Content = new StringContent(context.Exception.Message),
ReasonPhrase = "ArgumentNullException"
};
context.Result = new ArgumentNullResult(context.Request, result);
}
else
{
// Handle other exceptions
context.Result = new TextPlainErrorResult
{
Request = context.ExceptionContext.Request,
Content = context.Exception.Message,
ReasonPhrase = "Unhandled Web API Exception"
};
}
}
private class TextPlainErrorResult : IHttpActionResult
{
public HttpRequestMessage Request { get; set; }
public string Content { get; set; }
public string ReasonPhrase { get; set; }
public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
{
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
response.Content = new StringContent(Content);
response.RequestMessage = Request;
response.ReasonPhrase = ReasonPhrase;
return Task.FromResult(response);
}
}
private class ArgumentNullResult : IHttpActionResult
{
private HttpRequestMessage _request;
private HttpResponseMessage _httpResponseMessage;
public ArgumentNullResult(HttpRequestMessage request, HttpResponseMessage httpResponseMessage)
{
_request = request;
_httpResponseMessage = httpResponseMessage;
}
public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
{
return Task.FromResult(_httpResponseMessage);
}
}
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="3.2.0" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Client" version="6.0.0" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.3.0" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.3.0" targetFramework="net48" />
<package id="Microsoft.Owin" version="4.2.3" targetFramework="net48" />
<package id="Microsoft.Owin.Host.HttpListener" version="4.2.3" targetFramework="net48" />
<package id="Microsoft.Owin.Hosting" version="4.2.3" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="Newtonsoft.Json.Bson" version="1.0.2" targetFramework="net48" />
<package id="Owin" version="1.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
</packages>