Esempio n. 1
0
        // Send command to Module Display to update job status
        private void ShowMessageJobFinishedOnDisplay(string jobNo, string stationName, string stationPost)
        {
            string message =
                Msg.DisplayShowInfo.Text +
                Msg.Separator + "REQ" +
                Msg.Separator + "Identifier" +
                Msg.Separator + stationPost +
                Msg.CompDelimiter + stationName +
                Msg.CompDelimiter + "Antrian no. " + jobNo + ", telah selesai diproses";

            QueueServer.SendMessageToQueueDisplay(message, stationPost);
        }
Esempio n. 2
0
        // Send message to Queue display, to update displayed finished job/antrian
        private void UpdateJobsStatusOnDisplay(string stationName, string stationPost)
        {
            string csvList = QueueRepository.GetFinishedJobInCsvList(stationPost);

            string message =
                Msg.DisplaySetFinished.Text +
                Msg.Separator + "REQ" +
                Msg.Separator + "Identifier" +
                Msg.Separator + stationPost +
                Msg.CompDelimiter + stationName +
                Msg.CompDelimiter + csvList;

            QueueServer.SendMessageToQueueDisplay(message, stationPost);
        }
Esempio n. 3
0
        public void Run()
        {
            if (Environment.UserInteractive)
            {
                Console.WriteLine("--------------------------------------------------------------------------------------");
                Console.WriteLine("\nStarting QueueServer...");
                Console.WriteLine("From " + Util.ProcessPath);
            }

            Logger.LogFile = "c:\\tmp\\QueueServer.log";
            Logger.Log("--------------------------------------------------------------------------------------");
            Logger.Log("Starting QueueServer...");
            Logger.Log("From " + Util.ProcessPath);

            mServer = new QueueServer();
            mServer.Start();
        }
Esempio n. 4
0
        public void OnMessage(DataReceivedEventArgs arg, Client client)
        {
            Exception exp = null;

            try
            {
                Message qmessage = new Message(arg);

                Logger.Log("[CallerHandler] Processing " + qmessage.MessageType.Text + " from " + client.RemoteInfo);

                // Handle CallerGetInfo
                if (qmessage.MessageType == Msg.CallerGetInfo && qmessage.Direction == MessageDirection.REQUEST)
                {
                    MessageHandler <Dictionary <string, string> > handler = new MessageHandler <Dictionary <string, string> >(qmessage)
                    {
                        ReceiveHandler  = new Func <Dictionary <string, string>, Dictionary <string, string> >(QueueRepository.GetLastProcessedNumberAndPostSummary),
                        ResponseHandler = (session, result) =>
                        {
                            // Send response to client
                            if (result != null && result.Count == 4)
                            {
                                string postPrefix = result["postPrefix"];
                                string numberS    = result["number"];
                                string numberLeft = result["numberLeft"];

                                // Send response to client(caller)
                                string messageC =
                                    Msg.CallerGetInfo.Text +
                                    Msg.Separator + "RES" +
                                    Msg.Separator + "Identifier" +
                                    Msg.Separator + postPrefix +
                                    Msg.CompDelimiter + numberS +
                                    Msg.CompDelimiter + numberLeft;

                                session.Send(messageC);
                            }
                        }
                    };

                    handler.Process();
                }
                // Handle CallerGetNext
                else if (qmessage.MessageType == Msg.CallerGetNext && qmessage.Direction == MessageDirection.REQUEST)
                {
                    string post     = qmessage.PayloadValues["post"];
                    string callerId = client.Name;

                    MessageHandler <Dictionary <string, string> > handler = new MessageHandler <Dictionary <string, string> >(qmessage)
                    {
                        ReceiveHandler  = new Func <Dictionary <string, string>, Dictionary <string, string> >(QueueRepository.GetWaitingNumberAndPostSummary),
                        ResponseHandler = (session, result) =>
                        {
                            if (result != null && result.Count == 4)
                            {
                                string postPrefix = result["postPrefix"];
                                string numberS    = result["number"];
                                string numberLeft = result["numberLeft"];

                                // Send response to client(caller)
                                string messageC =
                                    Msg.CallerGetNext.Text +
                                    Msg.Separator + "RES" +
                                    Msg.Separator + "Identifier" +
                                    Msg.Separator + postPrefix +
                                    Msg.CompDelimiter + numberS +
                                    Msg.CompDelimiter + numberLeft;

                                session.Send(messageC);


                                // on a valid number, send message to Display
                                if (!string.IsNullOrWhiteSpace(numberS))
                                {
                                    // Send message to Queue display, to update displayed number, and total queue
                                    string messageD =
                                        Msg.DisplayCall.Text +
                                        Msg.Separator + "REQ" +
                                        Msg.Separator + "Identifier" +
                                        Msg.Separator + postPrefix +
                                        Msg.CompDelimiter + numberS +
                                        Msg.CompDelimiter + numberLeft +
                                        Msg.CompDelimiter + post +
                                        Msg.CompDelimiter + callerId;

                                    QueueServer.SendMessageToQueueDisplay(messageD, post);

                                    // Now we want to delete processed number
                                    int numberI = Convert.ToInt32(numberS);
                                    QueueRepository.DeleteProcessedNumberFromQueue(numberI, callerId, post);
                                }
                            }
                            else
                            {
                                /*
                                 * string messageC =
                                 *  Msg.CallerGetNext.Text +
                                 *  Msg.Separator + "RES" +
                                 *  Msg.Separator + "Identifier" +
                                 *  Msg.Separator + "" +
                                 *  Msg.Separator + "" +
                                 *  Msg.CompDelimiter + "" +
                                 *  Msg.CompDelimiter + "";
                                 *
                                 * session.Send(messageC);
                                 */
                            }
                        }
                    };

                    handler.Process();
                }
                // Handle CallerRecall
                else if (qmessage.MessageType == Msg.CallerRecall && qmessage.Direction == MessageDirection.REQUEST)
                {
                    string number    = qmessage.PayloadValues["number"];
                    string post      = qmessage.PayloadValues["post"];
                    string caller    = qmessage.PayloadValues["station"];
                    string postrefix = QueueRepository.GetPostNumberPrefix(post);

                    // Send message to Queue display, to update displayed number
                    // XXX is sent to replace total waiting queue
                    string messageD =
                        Msg.DisplayRecall.Text +
                        Msg.Separator + "REQ" +
                        Msg.Separator + "Identifier" +
                        Msg.Separator + postrefix +
                        Msg.CompDelimiter + number +
                        Msg.CompDelimiter + "XXX" +
                        Msg.CompDelimiter + post +
                        Msg.CompDelimiter + caller;

                    QueueServer.SendMessageToQueueDisplay(messageD, post);
                }
            }
            catch (AppException ex)
            {
                exp = ex;
            }
            catch (Exception ex)
            {
                exp = ex;
            }

            if (exp != null)
            {
                Logger.Log("CallerHandler", exp);

                // SYS|NOTIFY|[Type!Message]
                string message =
                    Msg.SysNotify.Text +
                    Msg.Separator + "ERROR" +
                    Msg.CompDelimiter + exp.Message;

                client.Session.Send(message);
            }
        }
        public void OnMessage(DataReceivedEventArgs arg, Client client)
        {
            Exception exp = null;

            try
            {
                Message qmessage = new Message(arg);

                Logger.Log("[DisplayHandler] Processing " + qmessage.MessageType.Text + " from " + client.RemoteInfo);

                // Handle DisplayGetRunText message from QueueDisplay
                if (qmessage.MessageType == Msg.DisplayGetRunText && qmessage.Direction == MessageDirection.REQUEST)
                {
                    string post    = qmessage.PayloadValues["post"];
                    string station = qmessage.PayloadValues["station"];

                    MessageHandler <List <string> > handler = new MessageHandler <List <string> >(qmessage)
                    {
                        ReceiveHandler  = new Func <Dictionary <string, string>, List <string> >(QueueRepository.GetStationRunningText),
                        ResponseHandler = (session, result) =>
                        {
                            if (result != null && result.Count > 0)
                            {
                                foreach (string text in result)
                                {
                                    string message =
                                        Msg.DisplayGetRunText.Text +
                                        Msg.Separator + "RES" +
                                        Msg.Separator + "Identifier" +
                                        Msg.Separator + text;

                                    client.Session.Send(message);
                                }
                            }
                        }
                    };

                    handler.Process();
                }
                // DisplayResetRunText
                else if (qmessage.MessageType == Msg.DisplayResetRunText && qmessage.Direction == MessageDirection.REQUEST)
                {
                    string post    = qmessage.PayloadValues["post"];
                    string station = qmessage.PayloadValues["station"];

                    string message =
                        Msg.DisplayResetRunText.Text +
                        Msg.Separator + "REQ" +
                        Msg.Separator + "Identifier" +
                        Msg.Separator + post +
                        Msg.CompDelimiter + station;
                    // Forward message to Display
                    QueueServer.SendMessageToQueueDisplay(message, post);
                }
                // DisplayDelRunText
                else if (qmessage.MessageType == Msg.DisplayDelRunText && qmessage.Direction == MessageDirection.REQUEST)
                {
                    string post    = qmessage.PayloadValues["post"];
                    string station = qmessage.PayloadValues["station"];
                    string text    = qmessage.PayloadValues["text"];

                    string message =
                        Msg.DisplayDelRunText.Text +
                        Msg.Separator + "REQ" +
                        Msg.Separator + "Identifier" +
                        Msg.Separator + post +
                        Msg.CompDelimiter + station +
                        Msg.CompDelimiter + text;
                    // Forward message to Display
                    QueueServer.SendMessageToQueueDisplay(message, post);
                }
                // DisplayResetValues
                else if (qmessage.MessageType == Msg.DisplayResetValues && qmessage.Direction == MessageDirection.REQUEST)
                {
                    string post    = qmessage.PayloadValues["post"];
                    string station = qmessage.PayloadValues["station"];

                    string message =
                        Msg.DisplayResetValues.Text +
                        Msg.Separator + "REQ" +
                        Msg.Separator + "Identifier" +
                        Msg.Separator + post +
                        Msg.CompDelimiter + station;
                    // Forward to Display
                    QueueServer.SendMessageToQueueDisplay(message, post);
                }
            }
            catch (AppException ex)
            {
                exp = ex;
            }
            catch (Exception ex)
            {
                exp = ex;
            }

            if (exp != null)
            {
                Logger.Log("DisplayHandler", exp);

                // SYS|NOTIFY|[Type!Message]
                string message =
                    Msg.SysNotify.Text +
                    Msg.Separator + "ERROR" +
                    Msg.CompDelimiter + exp.Message;

                client.Session.Send(message);
            }
        }