public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                ProductionLot lot = new ProductionLot();

                lot.LotId    = msg.Properties.ReadAsString("LotId");
                lot.Quantity = msg.Properties.ReadAsDouble("Qty");
                session.ProductionLots.Add(lot);
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Properties.Write("ErrorCode", ErrorInvalidEntry);
                responseMsg.Properties.Write("Message", ex.Message);
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("CustomerName", "");
            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                string languageCode = msg.Properties.ReadAsString("LanguageCode").Remove(2).ToUpper();

                string customerName = GetCachedAlarmText("VOICEPICK001", languageCode);

                responseMsg.Properties.Write("CustomerName", customerName);
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Properties.Write("ErrorCode", WarehouseAlarm);
                responseMsg.Properties.Write("Message", ex.Message);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            try
            {
                MessagePart part = CreateEmptyMessagePart(3);
                part.Properties.Write("ErrorCode", VocollectErrorCodeNoValidLots);
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(3);
                part.Properties.Write("ErrorCode", WarehouseAlarm);
                part.Properties.Write("Message", ex.Message);
                responseMsg.Parts.Add(part);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(3);
                part.Properties.Write("ErrorCode", (int)VocollectErrorCodeCritialError);
                part.Properties.Write("Message", GetCriticalErrorMessageText(msg));
                responseMsg.Parts.Add(part);

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            try
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "get_mt_pm", session);
                whMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                whMsg.Properties.Write("PM_Cur_O", new object());

                CorrelationContext context;

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                foreach (MessagePart part in context.ResponseMessages[0].Parts)
                {
                    int temp;

                    /* Packaging Type must be numeric in order to be valid */
                    if (!int.TryParse(part.Properties.ReadAsString("PMTYPID"), out temp))
                    {
                        continue;
                    }

                    VocollectMessagePart responsePart = new VocollectMessagePart();

                    responsePart.Properties.Write("PackNumber", part.Properties.Read("PMTYPID"));
                    responsePart.Properties.Write("PackDescription", part.Properties.Read("PMNAME"));

                    responsePart.Properties.Write("ErrorCode", (int)VocollectErrorCodeNoError);
                    responsePart.Properties.Write("Message", "");

                    responseMsg.Parts.Add(responsePart);
                }
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(2);
                part.Properties.Write("ErrorCode", WarehouseAlarm);
                part.Properties.Write("Message", ex.Message);
                responseMsg.Parts.Add(part);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(2);
                part.Properties.Write("ErrorCode", (int)VocollectErrorCodeCritialError);
                part.Properties.Write("Message", GetCriticalErrorMessageText(msg));
                responseMsg.Parts.Add(part);

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
        private static string GetCachedAlarmText(string alarmId, VocollectSession session, string languageCode)
        {
            if ((session == null) || (!session.Contains(alarmId)))
            {
                CorrelationContext context;

                if (session != null)
                {
                    languageCode = session.ReadAsString("NLANGCOD");
                }

                MultiPartMessage whMsg = CreateRequestMessage("wlsystem", "getalmtxt", null);
                whMsg.Properties.Write("ALMID_I", alarmId);
                whMsg.Properties.Write("NLANGCOD_I", languageCode);
                whMsg.Properties.Write("ALMTXT_O", "");

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                string alarmText = context.ResponseMessages[0].Properties.ReadAsString("ALMTXT_O");

                if (session != null)
                {
                    session.Write(alarmId, alarmText);
                }

                return(alarmText);
            }
            else
            {
                return(session.ReadAsString(alarmId));
            }
        }
Exemplo n.º 6
0
        private MessagePart CreateResponsePart(MessagePart part, VocollectSession session)
        {
            MessagePart responsePart = new VocollectMessagePart();

            responsePart.Properties.Write("SystemContainerId", part.Properties.ReadAsString("SEQNUM").PadLeft(session.ReadAsInt("VOICE_MIN_DIGITS_CARCODE"), '0'));
            responsePart.Properties.Write("ScannedContainerValidation", part.Properties.Read("CARCODE"));

            string carCode = part.Properties.ReadAsString("CARCODE");

            if (carCode.Length > session.ReadAsDecimal("VOICE_MIN_DIGITS_CARCODE"))
            {
                carCode = carCode.Substring(carCode.Length - session.ReadAsInt("VOICE_MIN_DIGITS_CARCODE"), session.ReadAsInt("VOICE_MIN_DIGITS_CARCODE"));
            }
            else if (carCode.Length < session.ReadAsInt("VOICE_MIN_DIGITS_CARCODE"))
            {
                carCode = carCode.PadLeft(session.ReadAsInt("VOICE_MIN_DIGITS_CARCODE"), '0');
            }

            responsePart.Properties.Write("SpokenContainerValidation", carCode);
            responsePart.Properties.Write("WorkId", "1");
            responsePart.Properties.Write("TargetContainer", "");
            responsePart.Properties.Write("ContainerStatus", "O");
            responsePart.Properties.Write("Printed", "1");
            responsePart.Properties.Write("ContainerType", part.Properties.Read("CARNAME"));
            responsePart.Properties.Write("Area", part.Properties.Read("WSID"));
            responsePart.Properties.Write("Location", part.Properties.Read("WPADR"));
            responsePart.Properties.Write("CustomerNumber", GetCotainerHashCode(part).ToString());
            responsePart.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responsePart.Properties.Write("Message", "");

            return(responsePart);
        }
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                if (session.Contains("CatchMeasureException"))
                {
                    Exception ex = (Exception)session["CatchMeasureException"];
                    responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                    responseMsg.Properties.Write("Message", ex.Message);
                }
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                try
                {
                    session.Remove("CatchMeasureException");
                }
                finally
                {
                    TransmitResponseMessage(responseMsg, session);
                }
            }
        }
Exemplo n.º 8
0
        public static void Print(string printerNumber, string containerId, VocollectSession session, bool isReprint)
        {
            if ((string.IsNullOrEmpty(printerNumber)) || (printerNumber == "1"))
            {
                printerNumber = "";
            }

            CorrelationContext context;

            /* Save printer number in session for use when finish pick to print PS */
            session.Write("PRINTERNUMBER", printerNumber);

            if (string.IsNullOrEmpty(containerId) && isReprint)
            {
                MultiPartMessage reprintMsg = CreateRequestMessage("wlvoicepick", "print_allloadcarriers", session);
                reprintMsg.Properties.Write("PBHEADID_I", session.ReadAsString("PBHEADID"));
                reprintMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                reprintMsg.Properties.Write("EMPID_I", session.ReadAsString("EMPID"));
                reprintMsg.Properties.Write("PRTID_I", printerNumber);

                reprintMsg.Properties.Write("ALMID_O", "");

                MessageEngine.Instance.TransmitRequestMessage(reprintMsg, reprintMsg.MessageId, out context);
            }
            else if (string.IsNullOrEmpty(containerId))
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "print", session);
                whMsg.Properties.Write("PBHEADID_I", session.ReadAsString("PBHEADID"));
                whMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                whMsg.Properties.Write("EMPID_I", session.ReadAsString("EMPID"));
                whMsg.Properties.Write("PRTID_I", printerNumber);

                if (string.IsNullOrEmpty(session.ReadAsString("PBROWID")) && (session.ReadAsInt("PBROW_COUNT") > 0))
                {
                    whMsg.Properties.Write("PRINTCOD_I", "BP");
                }
                else
                {
                    whMsg.Properties.Write("PRINTCOD_I", "AP");
                }

                whMsg.Properties.Write("ALMID_O", "");

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);
            }
            else
            {
                MultiPartMessage reprintMsg = CreateRequestMessage("wlvoicepick", "print_singleloadcarrier", session);
                reprintMsg.Properties.Write("PBHEADID_I", session.ReadAsString("PBHEADID"));
                reprintMsg.Properties.Write("SEQNUM_I", TrimContainerId(containerId));
                reprintMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                reprintMsg.Properties.Write("EMPID_I", session.ReadAsString("EMPID"));
                reprintMsg.Properties.Write("PRTID_I", printerNumber);

                reprintMsg.Properties.Write("ALMID_O", "");

                MessageEngine.Instance.TransmitRequestMessage(reprintMsg, reprintMsg.MessageId, out context);
            }
        }
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("DeliveryLocation", "");
            responseMsg.Properties.Write("DeliveryLocationCheckDigits", "");
            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "verify_loc", session);
                whMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                whMsg.Properties.Write("WSID_IO", msg.Properties.ReadAsString("AlternateDeliveryArea"));
                whMsg.Properties.Write("WPADR_I", msg.Properties.ReadAsString("AlternateDeliveryLocation"));
                whMsg.Properties.Write("WHID_I", session.ReadAsString("WHID"));
                whMsg.Properties.Write("ALMID_O", "");

                CorrelationContext context;

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                PropertyCollection properties = context.ResponseMessages[0].Properties;

                responseMsg.Properties.Write("DeliveryLocation", properties.Read("WSID_IO") + " " + msg.Properties.ReadAsString("AlternateDeliveryLocation"));

                DropLoadCarrier(TrimContainerId(msg.Properties.ReadAsString("ContainerId")), properties.ReadAsString("WSID_IO"), msg.Properties.ReadAsString("AlternateDeliveryLocation"), session);

                /* Clear drop variables so the container won't be dropped in next call to PrTaskGetDeliveryLocations */
                session.Write("DROPSEQNUM", "");
                session.Write("DROPWSID", "");
                session.Write("DROPWPADR", "");
            }
            catch (WarehouseAdapterException ex)
            {
                if (ex.AlarmId == "WS001")
                {
                    responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeAddressNotUnique);
                }
                else
                {
                    responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeInvalidLocation);
                }

                responseMsg.Properties.Write("Message", ex.Message);
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
        /// <summary>
        /// Returns the <see cref="VocollectSession"/> object associated with the terminal Id in the specified message.
        /// </summary>
        /// <param name="msg">A message containing the Terminal Id.</param>
        /// <returns>A <see cref="VocollectSession"/> object.</returns>
        /// <exception cref="SessionNotFoundException">
        /// </exception>
        private VocollectSession GetCurrentSession(MultiPartMessage msg)
        {
            VocollectSession session = SessionManager.Instance[msg.Properties.ReadAsString("SerialNumber")];

            if ((session == null) && (sessionPolicy == SessionPolicy.Required))
            {
                throw new SessionNotFoundException(string.Format("Session object not found for Endpoint: \"{1}\" ({0}).", msg.Metadata.Read("ReceiveUri").ToString(), msg.Properties.ReadAsString("SerialNumber")));
            }

            return(session);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                /* Do not direct operator to collect containers when continuing a temporarily stopped assignment
                 * or when print request is sent at the end of an assignment */
                if ((string.IsNullOrEmpty(session.ReadAsString("HOLD_TYPE")) ||
                     (session.ReadAsString("HOLD_TYPE") == HOLD_TYPE_Definitely)) &&
                    string.IsNullOrEmpty(session.ReadAsString("PBROWID")))
                {
                    responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCollectContainers);
                }

                if ((msg.Properties.ReadAsInt("PrinterNumber") > 0) && (msg.Properties.ReadAsInt("Operation") < 2))
                {
                    if ((session.ReadAsString("PRINTED") == "1") &&
                        (string.IsNullOrEmpty(TrimContainerId(msg.Properties.ReadAsString("SystemContainerId")))) &&
                        (msg.Properties.ReadAsInt("Operation") == 1))
                    {
                        Print(msg.Properties.ReadAsString("PrinterNumber"), TrimContainerId(msg.Properties.ReadAsString("SystemContainerId")), session, true);
                    }
                    else
                    {
                        Print(msg.Properties.ReadAsString("PrinterNumber"), TrimContainerId(msg.Properties.ReadAsString("SystemContainerId")), session, false);
                    }
                }

                session.Write("PRINTED", "1");
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Properties.Write("ErrorCode", WarehouseAlarm);
                responseMsg.Properties.Write("Message", ex.Message);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            try
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "get_user_languagecode", session);
                whMsg.Properties.Write("EMPID_I", msg.Properties.ReadAsString("Operator"));
                whMsg.Properties.Write("NLANGCOD_O", "");

                CorrelationContext context;

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                string languageCode = context.ResponseMessages[0].Properties.ReadAsString("NLANGCOD_O");

                VocollectMessagePart part = new VocollectMessagePart();
                part.Properties.Write("BreakType", 1);
                part.Properties.Write("BreakDescription", GetCachedAlarmText("VOICEPICK014", languageCode));
                part.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
                part.Properties.Write("Message", "");

                responseMsg.Parts.Add(part);
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(4);
                part.Properties.Write("ErrorCode", WarehouseAlarm);
                part.Properties.Write("Message", ex.Message);
                responseMsg.Parts.Add(part);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(4);
                part.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                part.Properties.Write("Message", GetCriticalErrorMessageText(msg));
                responseMsg.Parts.Add(part);

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
Exemplo n.º 13
0
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            /* Ignore ODR stored in flash output queue after terminal reset */
            if (session == null)
            {
                return;
            }

            using (TransactionScope transactionScope = new TransactionScope())
            {
                PrTaskLUTGetAssignment.RequestPickOrder(PickOrderHoldType.Temporarily, session);

                transactionScope.Complete();
            }
        }
        protected static void TransmitResponseMessage(MultiPartMessage msg, VocollectSession session)
        {
            if (session != null)
            {
                session.LastResponseMessage = msg;
            }

            try
            {
                MessageEngine.Instance.TransmitMessage(msg);
            }
            catch (AdapterException)
            {
                //Ignore any transmission errors, these will be logged by the TransmissionControlComponent
            }
        }
Exemplo n.º 15
0
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            /* Ignore ODRs stored in flash output queue after terminal reset */
            if (session == null)
            {
                return;
            }

            CatchMeasure measure = new CatchMeasure();

            measure.Measurement = msg.Properties.ReadAsDouble("VariableWeight");
            session.CatchMeasureEntries.Add(measure);

            if (msg.Properties.ReadAsString("TransmissionStatus") == "1")
            {
                /* Final variable weight message */

                try
                {
                    MultiPartMessage pickedMsg = new MultiPartMessage();
                    pickedMsg.Properties.Write("AssignmentId", session.ReadAsString("PBHEADID"));
                    pickedMsg.Properties.Write("WorkId", "1");
                    pickedMsg.Properties.Write("LocationId", msg.Properties.ReadAsString("LocationId"));
                    pickedMsg.Properties.Write("QuantityPicked", (double)session.CatchMeasureEntries.Count);
                    pickedMsg.Properties.Write("PickedStatus", "1");
                    pickedMsg.Properties.Write("ContainerId", TrimContainerId(msg.Properties.ReadAsString("ContainerId")));
                    pickedMsg.Properties.Write("Sequence", msg.Properties.ReadAsString("Sequence"));
                    pickedMsg.Properties.Write("DiscrepancyCode", session.ReadAsString("RESTCOD"));
                    pickedMsg.Properties.Write("SplitExchange", "0");

                    try
                    {
                        PrTaskLUTPicked.ProcessPickedMessage(pickedMsg, session);
                    }
                    catch (Exception ex)
                    {
                        session.Write("CatchMeasureException", ex);
                        throw;
                    }
                }
                finally
                {
                    session.CatchMeasureEntries.Clear();
                }
            }
        }
        /// <summary>
        /// Verifies and connects the pick truck of a definitely stopped pick order.
        /// </summary>
        /// <param name="session">The current session.</param>
        /// <param name="verifyVehicleId">The vehicle id to verify.</param>
        public static void VerifyAndConnectPickTruck(VocollectSession session, string assignmentId, string vehicleId, string verifyVehicleId)
        {
            MultiPartMessage tuMsg = CreateRequestMessage("wlvoicepick", "verify_and_connect_tu", session);

            tuMsg.Properties.Write("PBHEADID_I", assignmentId);
            tuMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
            tuMsg.Properties.Write("TUID_I", vehicleId);
            tuMsg.Properties.Write("VERIFY_TUID_I", verifyVehicleId);
            tuMsg.Properties.Write("VERIFY_TUID_O", "");
            tuMsg.Properties.Write("ALMID_O", "");

            CorrelationContext context;

            MessageEngine.Instance.TransmitRequestMessage(tuMsg, tuMsg.MessageId, out context);

            //Update session with new vehicle id
            session.Write("TUID", context.ResponseMessages[0].Properties.ReadAsString("VERIFY_TUID_O"));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("Replenished", "1");
            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "verify_pp_balance", session);
                whMsg.Properties.Write("TERID_I", msg.Properties.ReadAsString("SerialNumber"));
                whMsg.Properties.Write("PPKEY_I", ExtractPickPlaceKey(msg.Properties.ReadAsString("LocationId")));
                whMsg.Properties.Write("STORQTY_O", 0d);
                whMsg.Properties.Write("ALMID_O", "");

                CorrelationContext context;

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                if ((decimal)context.ResponseMessages[0].Properties.Read("STORQTY_O") <= 0)
                {
                    responseMsg.Properties.Write("Replenished", "0");
                }
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Properties.Write("ErrorCode", WarehouseAlarm);
                responseMsg.Properties.Write("Message", ex.Message);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
Exemplo n.º 18
0
        private void EndPointDestroyedEventHandler(object sender, AdapterEndPointEventArgs e)
        {
            TcpAdapterEndPoint endPoint = (TcpAdapterEndPoint)e.EndPoint;

            VocollectSession session = null;

            lock (endPointDictionary)
            {
                if (endPointDictionary.ContainsKey(endPoint))
                {
                    session = endPointDictionary[endPoint];
                    endPointDictionary.Remove(endPoint);
                }
            }

            if (session != null)
            {
                try
                {
                    if (endPoint.Exception != null)
                    {
                        session.ReleaseLock(false);

                        /* Do not log ObjectDisposedException since this indicates we got a timeout */
                        if (!(endPoint.Exception is ObjectDisposedException))
                        {
                            if ((MessageEngine.Instance.Tracing.Switch.Level & SourceLevels.Error) == SourceLevels.Error)
                            {
                                MessageEngine.Instance.Tracing.TraceData(TraceEventType.Error, 0, endPoint.Exception);
                            }
                        }
                    }
                    else
                    {
                        session.ReleaseLock(true);
                    }
                }
                catch (ObjectDisposedException)
                {
                    //Session has been disposed
                }
            }
        }
Exemplo n.º 19
0
        private bool IsDuplicate(MultiPartMessage msg, VocollectSession session, TcpAdapterEndPoint endPoint)
        {
            int hashCode = msg.Properties.ReadAsInt("HashCode");
            int sequence = msg.Properties.ReadAsInt("Sequence");

            DateTime timeStamp = (DateTime)msg.Properties.Read("TimeStamp");

            if (msg.Properties.ReadAsString("MessageType").Contains("ODR"))
            {
                if ((timeStamp <= session.LastTimeStamp) &&
                    (session.LastRequestMessage != null) &&
                    (session.LastResponseMessage != null) &&
                    (session.LastRequestMessage.Properties.ReadAsInt("HashCode") == hashCode) &&
                    (sequence <= session.LastRequestMessage.Properties.ReadAsInt("Sequence")))
                {
                    /* Duplicate ODR message */
                    return(true);
                }

                /* Message is valid update timestamp */
                session.LastTimeStamp = timeStamp;
            }
            else
            {
                /* Removed due to time synchronization issues, timestamp from terminal not accurate enough to be useful */
                //((TcpAdapter)endPoint.Adapter).SetEndPointTimeout(endPoint, timeStamp.AddMilliseconds(Configuration.ReadAsInt("PendingOperationsTimeout")));

                /* Always update timestamp for LUT messages */
                session.LastTimeStamp = timeStamp;

                if ((!session.LastOperationSuccessful) &&
                    (session.LastRequestMessage != null) &&
                    (session.LastResponseMessage != null) &&
                    (session.LastRequestMessage.Properties.ReadAsInt("HashCode") == hashCode))
                {
                    /* Duplicate LUT message */
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 20
0
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeInformationalError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "replenish_loc", session);
                whMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                whMsg.Properties.Write("PBROWID_I", msg.Properties.ReadAsString("Sequence"));
                whMsg.Properties.Write("EMPID_I", session.ReadAsString("EMPID"));
                whMsg.Properties.Write("NLANGCOD_I", session.ReadAsString("NLANGCOD"));
                whMsg.Properties.Write("ALMID_O", "");
                whMsg.Properties.Write("RESULT_O", "");

                CorrelationContext context;

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                responseMsg.Properties.Write("Message", context.ResponseMessages[0].Properties.ReadAsString("RESULT_O").ToLower());
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeInformationalError);
                responseMsg.Properties.Write("Message", ex.Message);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            try
            {
                VocollectMessagePart part = new VocollectMessagePart();
                part.Properties.Write("LocationId", msg.Properties.ReadAsString("LocationId"));
                part.Properties.Write("PreAisleDirection", "");
                part.Properties.Write("Aisle", ((string)part.Properties.Read("WSID")).PadRight(3, ' '));
                part.Properties.Write("PostAisleDirection", "");
                part.Properties.Write("Slot", "");
                part.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
                part.Properties.Write("Message", "");

                responseMsg.Parts.Add(part);
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(15);
                part.Properties.Write("ErrorCode", WarehouseAlarm);
                part.Properties.Write("Message", ex.Message);
                responseMsg.Parts.Add(part);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(15);
                part.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                part.Properties.Write("Message", GetCriticalErrorMessageText(msg));
                responseMsg.Parts.Add(part);

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Returns the session given its session Id.
        /// </summary>
        /// <param name="sessionId">The session Id string.</param>
        /// <returns>The corresponding session object.</returns>
        public VocollectSession this[string sessionId]
        {
            get
            {
                syncLock.AcquireReaderLock(Timeout.Infinite);

                VocollectSession session = null;

                try
                {
                    sessionDictionary.TryGetValue(sessionId, out session);
                }
                finally
                {
                    syncLock.ReleaseReaderLock();
                }

                return(session);
            }
        }
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeInformationalError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "check_repl_status", session);
                whMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                whMsg.Properties.Write("PPKEY_I", ExtractPickPlaceKey(msg.Properties.ReadAsString("LocationId")));
                whMsg.Properties.Write("NLANGCOD_I", session.ReadAsString("NLANGCOD"));
                whMsg.Properties.Write("RESULT_O", "");

                CorrelationContext context;

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                responseMsg.Properties.Write("Message", context.ResponseMessages[0].Properties.ReadAsString("RESULT_O"));
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Properties.Write("ErrorCode", WarehouseAlarm);
                responseMsg.Properties.Write("Message", ex.Message);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
        /// <summary>
        /// Internal invokation method.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        protected override void InternalInvoke(MultiPartMessage msg)
        {
            VocollectSession session = GetCurrentSession(msg);

            try
            {
                Invoke(msg, session);
            }
            finally
            {
                if (msg.MessageType.Contains("ODR"))
                {
                    /* Auto acknowledge ODR messages */
                    MultiPartMessage ackMsg = new MultiPartMessage("http://www.im.se/wms/voice/vocollect/voicedirect/ack", new MemoryStream());

                    ackMsg.Data.WriteByte(ackByte);
                    ackMsg.Metadata.Write("SendUri", msg.Metadata.Read("ReceiveUri"));

                    TransmitResponseMessage(ackMsg, session);
                }
            }
        }
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                /* Set a value for PBROWID so we know that picking has started even if user skipped a location */
                session.Write("PBROWID", "X");
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
 protected static string GetCachedAlarmText(string alarmId, VocollectSession session)
 {
     return(GetCachedAlarmText(alarmId, session, null));
 }
        /// <summary>
        /// Creates a request message ready to be transmitted to the WMS.
        /// </summary>
        /// <param name="packageName">Package name.</param>
        /// <param name="procedureName">Name of stored procedure to call.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <returns>A <see cref="MultiPartMessage"/> that can be sent to the WMS.</returns>
        protected static MultiPartMessage CreateRequestMessage(string packageName, string procedureName, VocollectSession session)
        {
            MultiPartMessage msg = new VocollectMessage();

            VocollectSection configSection = ConfigurationManager.GetSection(VocollectSection.SectionKey) as VocollectSection;

            msg.Metadata.Write("SendUri", new Uri(string.Format("warehouse://{2}/{0}/{1}", packageName, procedureName, configSection.Database)));

            if (session != null)
            {
                msg.Metadata.Write("LanguageCode", session.ReadAsString("NLANGCOD"));
            }

            return(msg);
        }
 /// <summary>
 /// Invokes the subscriber.
 /// </summary>
 /// <param name="msg">A reference to the subscribed message.</param>
 /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
 public abstract void Invoke(MultiPartMessage msg, VocollectSession session);
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            responseMsg.Properties.Write("Interleave", 0);
            responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
            responseMsg.Properties.Write("Message", "");

            try
            {
                using (TransactionScope transactionScope = new TransactionScope())
                {
                    /* Fetch user's language code */
                    MultiPartMessage langMsg = CreateRequestMessage("wlvoicepick", "get_user_languagecode", session);
                    langMsg.Properties.Write("EMPID_I", msg.Properties.ReadAsString("Operator"));
                    langMsg.Properties.Write("NLANGCOD_O", "");

                    CorrelationContext context;

                    MessageEngine.Instance.TransmitRequestMessage(langMsg, langMsg.MessageId, out context);

                    string languageCode = context.ResponseMessages[0].Properties.ReadAsString("NLANGCOD_O");

                    AuthenticationProvider provider = new AuthenticationProvider();
                    provider.Initialize(msg.Properties.ReadAsString("Password"));

                    MultiPartMessage authMsg = CreateRequestMessage("wlvoicepick", "authenticate", session);
                    authMsg.Properties.Write("EMPID_I", msg.Properties.ReadAsString("Operator"));
                    authMsg.Properties.Write("SALT_I", provider.Salt);
                    authMsg.Properties.Write("DATA_I", provider.SessionData);
                    authMsg.Properties.Write("WHID_I", "");
                    authMsg.Properties.Write("COMPANY_ID_I", "");
                    authMsg.Properties.Write("PRODUCT_I", "VOICE");
                    authMsg.Properties.Write("TERID_I", msg.Properties.ReadAsString("SerialNumber"));
                    authMsg.Properties.Write("SESSION_DATA_O", "");
                    authMsg.Properties.Write("ALMID_O", "");
                    authMsg.Properties.Write("ALMTXT1_O", "");
                    authMsg.Properties.Write("ALMTXT2_O", "");
                    authMsg.Properties.Write("ALMTXT3_O", "");

                    /* Set language code since we do not yet have a session */
                    authMsg.Metadata.Write("LanguageCode", languageCode);

                    MessageEngine.Instance.TransmitRequestMessage(authMsg, authMsg.MessageId, out context);

                    string sessionData = context.ResponseMessages[0].Properties.ReadAsString("SESSION_DATA_O");

                    AuthenticationSession authenticationSession = provider.DecryptSession(sessionData);

                    MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "logon", session);
                    whMsg.Properties.Write("TERID_I", msg.Properties.ReadAsString("SerialNumber"));
                    whMsg.Properties.Write("EMPID_I", msg.Properties.ReadAsString("Operator"));
                    whMsg.Properties.Write("SESSIONID_I", authenticationSession.SessionId);
                    whMsg.Properties.Write("WHID_O", "");
                    whMsg.Properties.Write("NLANGCOD_O", "");
                    whMsg.Properties.Write("ALMID_O", "");

                    /* Set language code since we do not yet have a session */
                    whMsg.Metadata.Write("LanguageCode", languageCode);

                    MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                    //Create session object
                    session = SessionManager.Instance.CreateSession(msg.Properties.ReadAsString("SerialNumber"));

                    /* Clear session if already exists */
                    session.Clear();

                    //Set session variables
                    session.Write("TERID", msg.Properties.ReadAsString("SerialNumber"));
                    session.Write("WHID", context.ResponseMessages[0].Properties.Read("WHID_O"));
                    session.Write("NLANGCOD", context.ResponseMessages[0].Properties.Read("NLANGCOD_O"));
                    session.Write("EMPID", msg.Properties.ReadAsString("Operator"));
                    session.Write("TUID", "");
                    session.Write("PBHEADID", "");
                    session.Write("PZID", "");
                    session.Write("PZGRPID", "");
                    session.Write("ITEID", "");

                    try
                    {
                        //Check if there is a temporarily stopped pick order available
                        PrTaskLUTGetAssignment.RequestPickOrder(PickOrderHoldType.Temporarily, session);

                        responseMsg.Properties.Write("ErrorCode", ErrorTempInterruptedPickOrderFound);
                    }
                    catch (WarehouseAdapterException ex)
                    {
                        if (ex.AlarmId != "PBHEAD030" && ex.AlarmId != "PBHEAD057")
                        {
                            throw;
                        }
                    }

                    transactionScope.Complete();
                }
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Properties.Write("ErrorCode", WarehouseAlarm);
                responseMsg.Properties.Write("Message", ex.Message);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                responseMsg.Properties.Write("Message", GetCriticalErrorMessageText(msg));

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }
        /// <summary>
        /// Invokes the subscriber.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        /// <param name="session">The current <see cref="VocollectSession"/> object.</param>
        /// <exception cref="WarehouseAdapterException">
        /// </exception>
        /// <exception cref="MessageEngineException">
        /// </exception>
        public override void Invoke(MultiPartMessage msg, VocollectSession session)
        {
            MultiPartMessage responseMsg = CreateResponseMessage(msg);

            try
            {
                MultiPartMessage whMsg = CreateRequestMessage("wlvoicepick", "get_mt_pbcar_pbrow", session);
                whMsg.Properties.Write("TERID_I", session.ReadAsString("TERID"));
                whMsg.Properties.Write("PBHEADID_I", session.ReadAsString("PBHEADID"));
                whMsg.Properties.Write("SEQNUM_I", TrimContainerId(msg.Properties.ReadAsString("ContainerId")));
                whMsg.Properties.Write("PBROW_Cur_O", new object());
                whMsg.Properties.Write("ALMID_O", "");

                CorrelationContext context;

                MessageEngine.Instance.TransmitRequestMessage(whMsg, whMsg.MessageId, out context);

                if (context.ResponseMessages[0].Parts.Count > 0)
                {
                    foreach (MessagePart part in context.ResponseMessages[0].Parts)
                    {
                        MessagePart responsePart = new VocollectMessagePart();

                        responsePart.Properties.Write("ContainerId", msg.Properties.Read("ContainerId"));
                        responsePart.Properties.Write("Description", part.Properties.Read("ARTNAME1"));
                        responsePart.Properties.Write("Quantity", part.Properties.Read("PICKQTY"));
                        responsePart.Properties.Write("Location", "");
                        responsePart.Properties.Write("PickTime", "");
                        responsePart.Properties.Write("ErrorCode", VocollectErrorCodeNoError);
                        responsePart.Properties.Write("Message", "");

                        responseMsg.Parts.Add(responsePart);
                    }
                }
                else
                {
                    MessagePart part = CreateEmptyMessagePart(7);
                    responseMsg.Parts.Add(part);
                }
            }
            catch (WarehouseAdapterException ex)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(7);
                part.Properties.Write("ErrorCode", WarehouseAlarm);
                part.Properties.Write("Message", ex.Message);
                responseMsg.Parts.Add(part);

                throw;
            }
            catch (Exception)
            {
                responseMsg.Parts.Clear();
                MessagePart part = CreateEmptyMessagePart(7);
                part.Properties.Write("ErrorCode", VocollectErrorCodeCritialError);
                part.Properties.Write("Message", GetCriticalErrorMessageText(msg));
                responseMsg.Parts.Add(part);

                throw;
            }
            finally
            {
                TransmitResponseMessage(responseMsg, session);
            }
        }