using System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Text; using System.Transactions; using System.Collections.ObjectModel; using Produmex.Foundation.Data.Sbo; using Produmex.Foundation.Data.Sbo.Attributes; using Produmex.Foundation.Data.Sbo.BusinessObjects; using Produmex.Foundation.Data.Sbo.BusinessObjects.Convertors; using Produmex.Foundation.Data.Sbo.BusinessObjects.Definitions.Tables; using Produmex.Foundation.Data.Sbo.Providers; using Produmex.Foundation.Data.Sbo.Utilities; using Produmex.Foundation.Data.SqlClient; using Produmex.Foundation.Diagnostics; using Produmex.Foundation.Reflection; using Produmex.Foundation.Resources; using Produmex.Foundation.SboGui; using Produmex.Sbo.Logex.Data.BusinessObjects; using Produmex.Sbo.Logex.Data.BusinessObjects.Definitions; using Produmex.Sbo.Logex.Data.BusinessObjects.Definitions.Tables; using Produmex.Sbo.Logex.Data.Providers; using Produmex.Sbo.Logex.Data.Devices; using Produmex.Foundation.Data.SqlClient; using Produmex.Foundation.Workflows.Parameters; using Produmex.Sbo.Logex.Data.DataObjects; namespace AddUpdateData { class Program { private static string CONNECTION_STRING = "BOY_PVC_THBR"; private static readonly ILog s_log = LogProvider.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType); static void Main(string[] args) { string ResoCode = ""; string[] Param = new string[] { "No parameter" }; if (args.Length > 0) { Param = args; } if (args.Length > 0) { ResoCode = args[0].Split('|')[0]; } try { DoSomething(ResoCode); } catch (Exception ex) { s_log.Error("", ex); Console.WriteLine(ex); Console.ReadLine(); } } public static void DoSomething(string ResoCode) { int ReportCode; string PrinterCode; int NbCopies; int LUID; int counter = 0; // creating a new transaction using (TransactionScope scope = PmxDbConnection.GetNewTransactionScope()) { // create the connection to the database using (PmxDbConnectionDirect conn = PmxDbConnectionMgr.GetDirectConnection(SboConnectionString.ParseStringToObject(CONNECTION_STRING))) { //open the connection conn.Open(); // creating a new PmxMoveProvider object PmxMoveProvider moveProv = new PmxMoveProvider(conn); // defining the query that is used as an input for the string query = @"SELECT * FROM PMX_WMS_INSPECT_CHANGE_QS WHERE ""ResoCode"" = '" + ResoCode + "'"; Console.WriteLine(query); s_log.Error("***** ***** Query Logs ***** *****: " + query ); // create a recordset from the result of the query using (ISboRecordset rs = SboRecordsetHelper.RunQuery(s_log, query, conn)) { // create a new PMXMove object using (PmxMove move = moveProv.GetNewBO()) { // read the rows from the recordset from the result of the query while (!rs.EoF) { // create a new PmxMoveLine object PmxMoveLine moveLine = moveProv.GetNewAddedLine(move); // set the parametersof the PmxMoveLine object from the moveLine.ItemCode = rs.GetTypedValue("ItemCode"); moveLine.Quantity = rs.GetTypedValue("Quantity"); moveLine.SourceQualityStatusCode = rs.GetTypedValue("QualityStatusCode"); moveLine.DestinationQualityStatusCode = "RELEASED"; moveLine.SourceStorageLocationCode = rs.GetTypedValue("StorLocCode"); moveLine.DestinationStorageLocationCode = rs.GetTypedValue("StorLocCode"); moveLine.ReasonFreeText = "Inspection Order : " + rs.GetTypedValue("U_DocNum"); if (rs.GetTypedValue("ItemTransactionalInfoKey") > 0) { moveLine.ItemTransactionalInfoKey = rs.GetTypedValue("ItemTransactionalInfoKey"); } if (rs.GetTypedValue("QuantityUom2") > 0) { moveLine.QuantityUom2 = rs.GetTypedValue("QuantityUom2"); } if (rs.GetTypedValue("LogunitIdentkey") > 0) { moveLine.SourceLogisticUnitIdentKey = rs.GetTypedValue("LogunitIdentkey"); moveLine.DestinationLogisticUnitIdentKey = rs.GetTypedValue("LogunitIdentkey"); ReportCode = rs.GetTypedValue("ReportCode"); PrinterCode = rs.GetTypedValue("PrinterCode"); NbCopies = rs.GetTypedValue("NbCopies"); LUID = rs.GetTypedValue("LogunitIdentkey"); s_log.Error("***** ***** Report / Printer / NbCopies ***** *****: " + ReportCode.ToString() + " / " + PrinterCode + " / " + NbCopies.ToString() ); // report PmxReportProvider reportProvider = new Produmex.Sbo.Logex.Data.Providers.PmxReportProvider(conn); PmxReport report = reportProvider.GetBO(ReportCode); // printer PmxOsePrinterProvider printerProvider = new PmxOsePrinterProvider(conn); PmxOsePrinter printer = printerProvider.GetNewBO(); printer = printerProvider.GetBO(PrinterCode); // device ReportPrinterDevice device = new ReportPrinterDevice(conn); // report parameter Collection reportParameters = new Collection(); reportParameters.Add(new ReportParameter("P_LUID", LUID)); reportParameters.Add(new ReportParameter("P_RESOCODE", ResoCode)); // print event: device.PrintReport(report, printer, null, NbCopies, null, reportParameters); } // read the next row from the recordset counter++; rs.MoveNext(); } if (counter > 0) { // add the move to Produmex WMS, this step will generate the move action moveProv.AddBO(move, true); } } } //Complete transaction scope.Complete(); } } } } }