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));
            }
        }
예제 #2
0
        public override void Invoke(EventRequest request)
        {
            bool outOfSync = false;

            lock (Session.SyncLock)
            {
                if (request.HashCode != Session.StateResponse.HashCode)
                {
                    outOfSync = true;
                }
            }

            if (!outOfSync)
            {
                using (MultiPartMessage eventMessage = new MultiPartMessage("", new MemoryStream(4096)))
                {
                    eventMessage.Metadata.Write("SendUri", new Uri("app://" + request.SessionId));

                    StreamWriter writer = new StreamWriter(eventMessage.Data, new UnicodeEncoding(false, false));
                    _requestSerializer.Serialize(writer, request);

                    MessageEngine.Instance.TransmitMessage(eventMessage);
                }
            }

            TransmitResponseMessage(new EventResponse());
        }
        /// <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);
                }
            }
        }
예제 #4
0
        public static void PostQueryAsMultipartMessage(string baseUri, string sparql, WebCredentials targetCredentials, WebProxyCredentials proxyCredentials)
        {
            try
            {
                string           result         = string.Empty;
                MultiPartMessage requestMessage = new MultiPartMessage
                {
                    name    = "update",
                    type    = MultipartMessageType.FormData,
                    message = sparql,
                };

                List <MultiPartMessage> requestMessages = new List <MultiPartMessage>
                {
                    requestMessage
                };

                WebHttpClient webClient = new WebHttpClient(baseUri, targetCredentials.GetNetworkCredential(), proxyCredentials.GetWebProxy());

                string response = String.Empty;
                webClient.PostMultipartMessage("", requestMessages, ref response);
            }
            catch (Exception exception)
            {
                _logger.Error("Error in PostQueryAsMultipartMessage: " + exception);
                throw exception;
            }
        }
        /// <summary>
        /// Called by the pipeline to invoke the component.
        /// </summary>
        /// <param name="msg">The message to process.</param>
        /// <returns>A collection of messages produced by this component.</returns>
        public override Collection <MultiPartMessage> Invoke(MultiPartMessage msg)
        {
            Collection <MultiPartMessage> resultCollection = new Collection <MultiPartMessage>();

            DateTime startTime = DateTime.Now;

            string stylesheet = null;

            try
            {
                stylesheet = Path.Combine(xsltPath, msg.Properties.ReadAsString("MessageType") + ".xslt");
            }
            catch (ArgumentException ex)
            {
                throw new ComponentException("Invalid characters in MessageType.", ex);
            }

            MultiPartMessage transformedMsg = Transform(msg, stylesheet);

            PromoteProperties(transformedMsg);

            resultCollection.Add(transformedMsg);

            TimeSpan transformationTime = DateTime.Now - startTime;

            if ((MessageEngine.Instance.Tracing.Switch.Level & SourceLevels.Verbose) == SourceLevels.Verbose)
            {
                MessageEngine.Instance.Tracing.TraceEvent(TraceEventType.Verbose, 0, "Message transformed in: {0}s {1}ms.", transformationTime.Seconds, transformationTime.Milliseconds);
            }

            return(resultCollection);
        }
        /// <summary>
        /// Called by the pipeline to invoke the component.
        /// </summary>
        /// <param name="msg">The message to process.</param>
        /// <returns>A collection of messages produced by this component.</returns>
        public override Collection <MultiPartMessage> Invoke(MultiPartMessage msg)
        {
            try
            {
                Collection <MultiPartMessage> resultCollection = new Collection <MultiPartMessage>();
                resultCollection.Add(msg);

                if (msg.Properties.ReadAsString("MessageType").Contains("ODR"))
                {
                    msg.Properties.Write("IsOutputDataRecord", true);

                    MultiPartMessage ackMsg = new MultiPartMessage("http://www.im.se/wms/voice/vocollect/ack", new MemoryStream());

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

                    TcpAdapter adapter = (TcpAdapter)MessageEngine.Instance.AdapterProxy.GetAdapterById("tcp");

                    //Transmit raw byte data
                    adapter.TransmitMessage(ackMsg);
                }
                else
                {
                    msg.Properties.Write("IsOutputDataRecord", false);
                }

                return(resultCollection);
            }
            catch (MessageEngineException ex)
            {
                throw new ComponentException("Failed to acknowledge message: \"" + msg.MessageType + "\"", ex);
            }
        }
예제 #7
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            TcpAdapterEndPoint endPoint = null;

            try
            {
                endPoint = (TcpAdapterEndPoint)ar.AsyncState;

                Socket clientSocket = endPoint.Socket;

                int byteCount = clientSocket.EndReceive(ar);

                if (byteCount > 0)
                {
                    MultiPartMessage msg = new MultiPartMessage("",
                                                                new MemoryStream(endPoint.buffer, 0, byteCount));

                    OnMessageReceived(msg, endPoint);

                    InitializeEndPoint(endPoint);
                }
                else
                {
                    Disconnect(endPoint);
                }
            }
            catch (Exception ex)
            {
                Disconnect(endPoint, ex);
            }
        }
예제 #8
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);
            }
        }
        /// <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);
            }
        }
        private static MultiPartMessage CreateMessage(Stream data)
        {
            var message = new MultiPartMessage(data);

            message.Data.Seek(0, SeekOrigin.Begin);

            XmlReader xml = XmlReader.Create(message.Data);

            while (xml.NodeType != XmlNodeType.Element)
            {
                xml.Read();
            }

            message.Metadata.Write("MessageType", "http://www.im.se/wms/mobile/" + xml.Name);

            if (xml.MoveToAttribute("SessionId"))
            {
                message.Metadata.Write("SessionId", xml.ReadContentAsString());
            }

            if (xml.MoveToAttribute("Sequence"))
            {
                message.Metadata.Write("Sequence", xml.ReadContentAsInt());
            }

            return(message);
        }
예제 #11
0
        /// <summary>
        /// Called by the pipeline to invoke the component.
        /// </summary>
        /// <param name="msg">The message to process.</param>
        /// <returns>A collection of messages produced by this component.</returns>
        public override Collection <MultiPartMessage> Invoke(MultiPartMessage msg)
        {
            Collection <MultiPartMessage> resultCollection = new Collection <MultiPartMessage>();

            Encoding encoding = Encoding.GetEncoding(Configuration.ReadAsString("CodePageName"));

            buffer.Append(encoding.GetString(((MemoryStream)msg.Data).ToArray()));

            if ((MessageEngine.Instance.Tracing.Switch.Level & SourceLevels.Verbose) == SourceLevels.Verbose)
            {
                MessageEngine.Instance.Tracing.TraceEvent(TraceEventType.Verbose, 0, "Stream buffer content: \"{0}\"", buffer.ToString().Trim());
            }

            string data = null;

            while ((data = ReadBuffer(buffer)) != null)
            {
                MultiPartMessage xmlMessage = CreateMessage(data);

                if (xmlMessage != null)
                {
                    resultCollection.Add(xmlMessage);
                }
            }

            return(resultCollection);
        }
예제 #12
0
        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);
            }
        }
예제 #13
0
        protected void TransmitResponseMessage(TResponse response)
        {
            if (!MessageEngine.Instance.IsRunning)
            {
                return;
            }

            CheckAndThrowException();

            MultiPartMessage temp = new MultiPartMessage(new MemoryStream(8192));

            _responseSerializer.Serialize(temp.Data, response);

            AppendEndOfFile(temp);

            TraceMessageData("Sending data: ", temp);

            SourceMessage.Metadata.Copy("ReceiveUri", temp.Metadata);
            temp.Metadata.Write("Loopback", true);

            if (Session != null)
            {
                Session.LastResponseMessage = temp;
            }

            try
            {
                MessageEngine.Instance.TransmitMessage(temp);
            }
            catch (AdapterException)
            {
            }
        }
예제 #14
0
        private void TransmitFaultMessage(ServerFault serverFault)
        {
            MultiPartMessage temp = new MultiPartMessage(new MemoryStream(4096));

            _exceptionSerializer.Serialize(temp.Data, serverFault);

            AppendEndOfFile(temp);

            TraceMessageData("Sending data: ", temp);

            SourceMessage.Metadata.Copy("ReceiveUri", temp.Metadata);
            temp.Metadata.Write("Loopback", true);

            if (Session != null)
            {
                Session.LastResponseMessage = temp;
            }

            try
            {
                MessageEngine.Instance.TransmitMessage(temp);
            }
            catch (AdapterException)
            {
            }
        }
예제 #15
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);
            }
        }
        /// <summary>
        /// Called by the pipeline to invoke the component.
        /// </summary>
        /// <param name="msg">The message to process.</param>
        /// <returns>A collection of messages produced by this component.</returns>
        public override Collection <MultiPartMessage> Invoke(MultiPartMessage msg)
        {
            Collection <MultiPartMessage> resultCollection = new Collection <MultiPartMessage>();

            resultCollection.Add(msg);

            if (MessageEngine.Instance.Tracing.Switch.Level != SourceLevels.Off)
            {
                ContextTraceListener contextListener = ((ContextTraceListener)MessageEngine.Instance.Tracing.Listeners["ContextTraceListener"]);

                if (contextListener != null)
                {
                    string sessionId = msg.Properties.ReadAsString("SerialNumber");

                    if ((MessageEngine.Instance.Tracing.Switch.Level & SourceLevels.Verbose) == SourceLevels.Verbose)
                    {
                        MessageEngine.Instance.Tracing.TraceData(TraceEventType.Verbose, 0, string.Format("TraceContextComponent: Switching context to: \"{0}\"", sessionId));
                    }

                    if (!contextListener.IsContextInitialized(sessionId))
                    {
                        contextListener.InitializeContext(sessionId,
                                                          new RollingFileTraceListener(Path.Combine(logPath, sessionId + ".log"), maxLogSize));
                    }

                    contextListener.Context = sessionId;
                }
            }

            return(resultCollection);
        }
예제 #17
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>
        /// Returns the critical error message text defined in the app.config file.
        /// </summary>
        /// <param name="msg">Message for session reference.</param>
        /// <returns>Critical error message text from app.config file.</returns>
        protected string GetCriticalErrorMessageText(MultiPartMessage msg)
        {
            VocollectSection configSection = ConfigurationManager.GetSection(VocollectSection.SectionKey) as VocollectSection;

            MessageElement message = configSection.MessageCollection["CriticalError"];

            return(string.Format(message.Text, this.GetType().Name));
        }
        /// <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);
            }
        }
예제 #20
0
 private static void TraceMessageData(string text, MultiPartMessage temp)
 {
     if ((MessageEngine.Instance.Tracing.Switch.Level & SourceLevels.Verbose) == SourceLevels.Verbose)
     {
         temp.Data.Seek(0, SeekOrigin.Begin);
         string data = Encoding.UTF8.GetString(((MemoryStream)temp.Data).ToArray(), 0, (int)temp.Data.Length).Replace('\0', '0');
         MessageEngine.Instance.Tracing.TraceEvent(TraceEventType.Verbose, 0, "{0}\"{1}\"", text, data);
     }
 }
예제 #21
0
        private static void AppendEndOfFile(MultiPartMessage msg)
        {
            msg.Data.Seek(0, SeekOrigin.End);

            for (int i = 0; i < EndOfFileLength; i++)
            {
                msg.Data.WriteByte(0);
            }
        }
        /// <summary>
        /// Checks if the component supports processing of a specified message.
        /// </summary>
        /// <param name="msg">The message to process.</param>
        /// <returns>True if the message is supported, othwerwise false.</returns>
        public override bool Supports(MultiPartMessage msg)
        {
            if (msg.MessageType == "http://www.im.se/wms/voice/vocollect/xml_param_base")
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Creates a response message ready to be transmitted back to the terminal.
        /// </summary>
        /// <param name="sourceMsg">The source message containing the receive Uri.</param>
        /// <returns>A <see cref="VocollectMessage"/> object.</returns>
        protected static MultiPartMessage CreateResponseMessage(MultiPartMessage sourceMsg)
        {
            MultiPartMessage msg = new VocollectMessage();

            sourceMsg.Metadata.Copy("ReceiveUri", msg.Metadata);
            msg.Metadata.Write("Loopback", true);

            return(msg);
        }
예제 #24
0
        /// <summary>
        /// Invokes the subscriber for processing of the message.
        /// </summary>
        /// <param name="msg">A reference to the subscribed message.</param>
        public override void Invoke(MultiPartMessage msg)
        {
            ContextTraceListener contextListener = ((ContextTraceListener)MessageEngine.Instance.Tracing.Listeners["ContextTraceListener"]);

            if (contextListener != null)
            {
                contextListener.ResetContext();
            }
        }
예제 #25
0
        /// <summary>
        /// Transmits a message over the adapter protocol
        /// </summary>
        /// <param name="msg">The message to transmit</param>
        public override void TransmitMessage(MultiPartMessage msg)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }

            TransmitMessage(msg, null);
        }
 /// <summary>
 /// Checks if the component supports processing of a specified message.
 /// </summary>
 /// <param name="msg">The message to process.</param>
 /// <returns>True if the message is supported, othwerwise false.</returns>
 public override bool Supports(MultiPartMessage msg)
 {
     if (msg.MessageType.StartsWith("http://www.im.se/wms/mobile/"))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <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);
        }
 /// <summary>
 /// Checks if the component supports processing of a specified message.
 /// </summary>
 /// <param name="msg">The message to process.</param>
 /// <returns>True if the message is supported, othwerwise false.</returns>
 public override bool Supports(MultiPartMessage msg)
 {
     if (msg.MessageType.StartsWith("http://www.im.se/wms/voice/vocollect/voicedirect"))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// Checks if the component supports processing of a specified message.
 /// </summary>
 /// <param name="msg">The message to process.</param>
 /// <returns>True if the message is supported, othwerwise false.</returns>
 public override bool Supports(MultiPartMessage msg)
 {
     if (msg.Metadata.ReadAsString("ReceiveAdapterId") == "tcp")
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #30
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);
            }
        }