diff --git a/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs b/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs index 5872981a..e7b2b6e3 100644 --- a/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs +++ b/LaaProductionWeb/Data/LaaProduction.Data.Omni/OmniDbContext.cs @@ -59,21 +59,7 @@ var inspectionOrder = default(InspectionOrder); var inspectionOrderRows = this.sql .CreateCommand($@" - DECLARE @search INT = @{nameof(identorpono)}; DECLARE @identnr INT; - DECLARE @fertnr INT; - - SELECT @identnr = [aap].[IdentNr] - , @fertnr = [aap].[FertigungsauftragNr] - FROM [AlleAuftragPositionen] AS [aap] - WHERE [aap].[FertigungsauftragNr] = @search - - IF @identnr IS NULL - BEGIN - SELECT @identnr = [idn].[IdentNr] - FROM [Identnr] AS [idn] - WHERE [idn].[IdentNr] = @search - END SELECT [d].[Id] , [aap].[AuftragNr] diff --git a/LaaProductionWeb/LaaProduction.Console/LaaProduction.Console.csproj b/LaaProductionWeb/LaaProduction.Console/LaaProduction.Console.csproj new file mode 100644 index 00000000..7a8fd8ca --- /dev/null +++ b/LaaProductionWeb/LaaProduction.Console/LaaProduction.Console.csproj @@ -0,0 +1,85 @@ + + + + + Debug + AnyCPU + {E8FCD0A3-714D-4436-9A20-B098E6A5537D} + Exe + LaaProduction.Console + LaaProduction.Console + v4.0 + 512 + true + + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net40\System.Net.Http.dll + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net40\System.Net.Http.Extensions.dll + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net40\System.Net.Http.Primitives.dll + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net40\System.Net.Http.WebRequest.dll + + + ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Runtime.dll + + + ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/LaaProductionWeb/LaaProduction.Console/Program.cs b/LaaProductionWeb/LaaProduction.Console/Program.cs new file mode 100644 index 00000000..8ed53421 --- /dev/null +++ b/LaaProductionWeb/LaaProduction.Console/Program.cs @@ -0,0 +1,28 @@ +namespace LaaProduction.Console +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + + public class Program + { + public static void Main(string[] args) + { + Console.ReadKey(); + + using (var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:57680/api.aspx?action=getlabel")) + { + request.Content = new FormUrlEncodedContent(new Dictionary + { + { "BUILD_INFO", "816232411982" } + }); + + using (var response = new HttpClient().SendAsync(request).Result) + { + Console.WriteLine(response.Content.ReadAsStringAsync().Result); + } + } + + } + } +} diff --git a/LaaProductionWeb/LaaProduction.Console/Properties/AssemblyInfo.cs b/LaaProductionWeb/LaaProduction.Console/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..c1435e1c --- /dev/null +++ b/LaaProductionWeb/LaaProduction.Console/Properties/AssemblyInfo.cs @@ -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.Console")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LaaProduction.Console")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[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("e8fcd0a3-714d-4436-9a20-b098e6a5537d")] + +// 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")] diff --git a/LaaProductionWeb/LaaProduction.Console/app.config b/LaaProductionWeb/LaaProduction.Console/app.config new file mode 100644 index 00000000..3f26b599 --- /dev/null +++ b/LaaProductionWeb/LaaProduction.Console/app.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/LaaProductionWeb/LaaProduction.Console/packages.config b/LaaProductionWeb/LaaProduction.Console/packages.config new file mode 100644 index 00000000..0694948c --- /dev/null +++ b/LaaProductionWeb/LaaProduction.Console/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionVFM/API.aspx b/LaaProductionWeb/LaaProductionVFM/API.aspx new file mode 100644 index 00000000..b95952de --- /dev/null +++ b/LaaProductionWeb/LaaProductionVFM/API.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="API.aspx.cs" Inherits="LaaProductionVFM.API" %> diff --git a/LaaProductionWeb/LaaProductionVFM/API.aspx.cs b/LaaProductionWeb/LaaProductionVFM/API.aspx.cs new file mode 100644 index 00000000..3575ae26 --- /dev/null +++ b/LaaProductionWeb/LaaProductionVFM/API.aspx.cs @@ -0,0 +1,288 @@ +namespace LaaProductionVFM +{ + using System; + using System.Collections.Specialized; + using System.Configuration; + using System.IO; + using System.Linq; + using System.Net; + using System.Reflection; + using System.Text; + using System.Web.UI; + + public partial class API : Page + { + protected void Page_Load(object sender, EventArgs e) + { + var actionString = this.Request.QueryString.Get("action"); + + if (!string.IsNullOrWhiteSpace(actionString)) + { + var action = this.GetType() + .GetMethods(BindingFlags.Instance | BindingFlags.NonPublic) + .Where(method => method.Name.Equals(actionString, StringComparison.OrdinalIgnoreCase)) + .FirstOrDefault(); + + if (action != null) + { + this.Response.Clear(); + this.Response.ContentType = "application/json"; + + action.Invoke(this, null); + + this.Response.Flush(); + } + } + } + + /***************************************************************************************** + * + * A new control variable @IMAGE_MODE allows you to dynamically change the configuration + * of the sentinel for the next print job. + * If set to 0, the sentinel prints a label. - + * If set to 1, the sentinel generates a preview image of the label but does not print it. + * If set to 2, the sentinel prints the label and generates a preview image of the label. + * + *****************************************************************************************/ + protected void PrintTestLabel() + { + try + { + var form = this.FormData(); + var builder = new StringBuilder(); + + builder.AppendLine(string.Format("@JOB_NAME = \"testlabel_{0}\"", form.PcbId)); + builder.AppendLine(string.Format("@PRINTER_NAME = \"{0}\"", Appsettings.TestLabelPrinter)); + builder.AppendLine(string.Format("@LABEL_NAME = \"{0}\"", Appsettings.TestLabel)); + builder.AppendLine(string.Format("@IMAGE_MODE = \"{0}\"", 0)); + builder.AppendLine(string.Format("ORDERNO = \"{0}\"", form.Orderno)); + builder.AppendLine(string.Format("POSNO = \"{0}\"", form.Posno)); + builder.AppendLine(string.Format("TESTDATE = \"{0}\"", form.TestDate)); + builder.AppendLine(string.Format("PARTNO = \"{0}\"", form.Partno)); + builder.AppendLine(string.Format("DESCL1 = \"{0}\"", form.DescriptionL1)); + builder.AppendLine(string.Format("DESCL2 = \"{0}\"", form.DescriptionL2)); + builder.AppendLine(string.Format("CUSTSN = \"{0}\"", form.CustId)); + builder.AppendLine(string.Format("REGSN = \"{0}\"", form.FactId)); + builder.AppendLine(string.Format("QMAXGPM = \"{0}\"", form.QmaxGPM)); + builder.AppendLine(string.Format("QMIDGPM = \"{0}\"", form.QmidGPM)); + builder.AppendLine(string.Format("QMINGPM = \"{0}\"", form.QminGPM)); + builder.AppendLine(string.Format("QMAXACC = \"{0}\"", form.QmaxACC)); + builder.AppendLine(string.Format("QMIDACC = \"{0}\"", form.QmidACC)); + builder.AppendLine(string.Format("QMINACC = \"{0}\"", form.QminACC)); + + if (!string.IsNullOrWhiteSpace(Appsettings.TestLabelTxt)) + { + var testDataTxt = string.Format(Appsettings.TestLabelTxt, form.PcbId); + var testLabelContent = builder.ToString(); + + File.WriteAllText(testDataTxt, testLabelContent); + + this.Response.StatusCode = (int)HttpStatusCode.OK; + } + else + { + this.Response.StatusCode = (int)HttpStatusCode.BadRequest; + } + } + catch (Exception e) + { + this.Response.StatusCode = (int)HttpStatusCode.InternalServerError; + this.Response.Write(e.ToString()); + } + } + + /***************************************************************************************** + * + * A new control variable @IMAGE_MODE allows you to dynamically change the configuration + * of the sentinel for the next print job. + * If set to 0, the sentinel prints a label. - + * If set to 1, the sentinel generates a preview image of the label but does not print it. + * If set to 2, the sentinel prints the label and generates a preview image of the label. + * + *****************************************************************************************/ + protected void PrintBoxLabel() + { + try + { + var form = this.FormData(); + var builder = new StringBuilder(); + + builder.AppendLine(string.Format("@JOB_NAME = \"boxlabel_{0}\"", form.CustId)); + builder.AppendLine(string.Format("@PRINTER_NAME = \"{0}\"", Appsettings.BoxLabelPrinter)); + builder.AppendLine(string.Format("@LABEL_NAME = \"{0}\"", Appsettings.BoxLabel)); + builder.AppendLine(string.Format("@IMAGE_MODE = \"{0}\"", 0)); + builder.AppendLine(string.Format("TITLE = \"{0}\"", form.Title)); + builder.AppendLine(string.Format("DESCL1 = \"{0}\"", form.DescriptionL1)); + builder.AppendLine(string.Format("DESCL2 = \"{0}\"", form.DescriptionL2)); + builder.AppendLine(string.Format("PARTNO = \"{0}\"", form.Partno)); + builder.AppendLine(string.Format("ORDERNO = \"{0}\"", form.Orderno)); + builder.AppendLine(string.Format("CUSTSN = \"{0}\"", form.CustId)); + builder.AppendLine(string.Format("BOXDATE = \"{0}\"", form.BoxDate)); + builder.AppendLine(string.Format("BOXNO = \"{0}\"", form.Boxno)); + builder.AppendLine(string.Format("QUANTITY = \"{0}\"", form.Quantity)); + + if (!string.IsNullOrWhiteSpace(Appsettings.BoxLabelTxt)) + { + var boxDataTxt = string.Format(Appsettings.BoxLabelTxt, form.CustId); + var boxLabelContent = builder.ToString(); + + File.WriteAllText(boxDataTxt, boxLabelContent); + + this.Response.StatusCode = (int)HttpStatusCode.OK; + } + else + { + this.Response.StatusCode = (int)HttpStatusCode.BadRequest; + } + } + catch (Exception e) + { + this.Response.StatusCode = (int)HttpStatusCode.InternalServerError; + this.Response.Write(e.ToString()); + } + } + + private T FormData() where T : new() + { + var expectedResult = new T(); + var properties = expectedResult + .GetType() + .GetProperties(BindingFlags.Public | BindingFlags.Instance) + .ToDictionary(x => x.Name.ToLower(), x => (Action)x.SetValue); + + var buffer = new Byte[this.Request.InputStream.Length]; + var dataLength = this.Request.InputStream.Read(buffer, 0, buffer.Length); + var data = new Byte[dataLength]; + + Array.Copy(buffer, 0, data, 0, dataLength); + + var content = Encoding.UTF8.GetString(data); + + if (string.IsNullOrWhiteSpace(content)) + { + return expectedResult; + } + + content = content.Trim('"'); + + var parts = content.Split(new[] { ';', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); + + foreach (var part in parts) + { + if (string.IsNullOrWhiteSpace(part)) + { + continue; + } + + var tokens = part.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries); + + if (tokens.Length != 2) + { + continue; + } + + var key = tokens[0]; + var value = tokens[1]; + + if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value)) + { + continue; + } + + key = key.ToLower().Trim(); + value = value.Trim(); + + if (properties.ContainsKey(key)) + { + properties[key](expectedResult, value); + } + } + + return expectedResult; + } + + public class TestLabel + { + public string PcbId { get; set; } + + public string Orderno { get; set; } + + public string Posno { get; set; } + + public string TestDate { get; set; } + + public string Partno { get; set; } + + public string DescriptionL1 { get; set; } + + public string DescriptionL2 { get; set; } + + public string CustId { get; set; } + + public string FactId { get; set; } + + public string QmaxGPM { get; set; } + + public string QmidGPM { get; set; } + + public string QminGPM { get; set; } + + public string QmaxACC { get; set; } + + public string QmidACC { get; set; } + + public string QminACC { get; set; } + } + + public class BoxLabel + { + public string CustId { get; set; } + + public string Title { get; set; } + + public string DescriptionL1 { get; set; } + + public string DescriptionL2 { get; set; } + + public string Partno { get; set; } + + public string Orderno { get; set; } + + public string BoxDate { get; set; } + + public string Boxno { get; set; } + + public string Quantity { get; set; } + } + + public class Appsettings + { + public const string ERROR_MSG = "ERROR_MSG"; + + private static readonly NameValueCollection appsettings + = ConfigurationManager.AppSettings; + + public static readonly string SQLServer = ConfigurationManager + .ConnectionStrings["DefaultConnection"] + .ConnectionString; + + public static readonly string BoxLabel = appsettings["BoxLabel"]; + + public static readonly string BoxLabelPrinter = appsettings["BoxLabelPrinter"]; + + public static readonly string BoxLabelTxt = appsettings["BoxLabelTxt"]; + + public static readonly string BoxLabelJpg = appsettings["BoxLabelJpg"]; + + public static readonly string TestLabel = appsettings["TestLabel"]; + + public static readonly string TestLabelPrinter = appsettings["TestLabelPrinter"]; + + public static readonly string TestLabelTxt = appsettings["TestLabelTxt"]; + + public static readonly string TestLabelJpg = appsettings["TestLabelJpg"]; + + public static readonly string CurrentDirectory = appsettings["CurrentDirectory"]; + } + } +} \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionVFM/Index.aspx.cs b/LaaProductionWeb/LaaProductionVFM/Index.aspx.cs index 4c478e29..d9a56682 100644 --- a/LaaProductionWeb/LaaProductionVFM/Index.aspx.cs +++ b/LaaProductionWeb/LaaProductionVFM/Index.aspx.cs @@ -7,6 +7,7 @@ { protected void Page_Load(object sender, EventArgs e) { + } } } \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionVFM/Web.config b/LaaProductionWeb/LaaProductionVFM/Web.config index a7880dbd..38ec396b 100644 --- a/LaaProductionWeb/LaaProductionVFM/Web.config +++ b/LaaProductionWeb/LaaProductionVFM/Web.config @@ -24,6 +24,12 @@ + + + + + + diff --git a/LaaProductionWeb/LaaProductionWeb.sln b/LaaProductionWeb/LaaProductionWeb.sln index d72ea3f3..60b217a2 100644 --- a/LaaProductionWeb/LaaProductionWeb.sln +++ b/LaaProductionWeb/LaaProductionWeb.sln @@ -54,6 +54,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction.Data.Omni", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction.Data.Inspection", "Data\LaaProduction.Data.Inspection\LaaProduction.Data.Inspection.csproj", "{25BACE1B-1961-411A-8AC0-1375A1898F8F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction.Console", "LaaProduction.Console\LaaProduction.Console.csproj", "{E8FCD0A3-714D-4436-9A20-B098E6A5537D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -116,6 +118,10 @@ Global {25BACE1B-1961-411A-8AC0-1375A1898F8F}.Debug|Any CPU.Build.0 = Debug|Any CPU {25BACE1B-1961-411A-8AC0-1375A1898F8F}.Release|Any CPU.ActiveCfg = Release|Any CPU {25BACE1B-1961-411A-8AC0-1375A1898F8F}.Release|Any CPU.Build.0 = Release|Any CPU + {E8FCD0A3-714D-4436-9A20-B098E6A5537D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E8FCD0A3-714D-4436-9A20-B098E6A5537D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E8FCD0A3-714D-4436-9A20-B098E6A5537D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E8FCD0A3-714D-4436-9A20-B098E6A5537D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE