Exemple #1
0
        //private bool isSendFinish = false;
        public void SendSocket(string action, string counterID, List <string> counterMove, List <string> serviceMove, string cNum, int point)
        {
            Ticket        tk        = null;
            string        message   = null;
            List <Ticket> lstObject = null;

            switch (action)
            {
            case ActionTicket.ACTION_ALL_RESTORE:
                var lstService = dicAllCounters[counterID].Services;
                lstObject = dicCancelled.Values.Where(m => lstService.Contains(m.Service_Id)).OrderByDescending(m => m.PriorityTicket).ThenBy(m => m.MTime).Take(18).ToList();
                EventSocket eventData = null;
                if (lstObject == null || lstObject.Count() == 0)
                {
                    message   = MessageError.ERROR_05;
                    eventData = new EventSocket(action, counterID, message);
                }
                else
                {
                    eventData = new EventSocket(action, counterID, lstObject);
                }

                DataReceived(eventData);
                return;

            case ActionTicket.CALL_LIST_WATTING:
                var counter = dicAllCounters[counterID];
                lstObject = dicWaitting.Values.Where(m => (m.Counter_Id == counterID) || ((m.Counter_Id == null || m.Counter_Id == "") && counter.Services.Contains(m.Services[0]))).OrderByDescending(m => m.PriorityTicket).ThenBy(m => m.MTime).Take(18).ToList();
                EventSocket eventListW = null;
                if (lstObject == null || lstObject.Count() == 0)
                {
                    eventListW = new EventSocket(action, counterID, MessageError.ERROR_01);
                }
                else
                {
                    eventListW = new EventSocket(action, counterID, lstObject);
                }
                DataReceived(eventListW);
                return;

            case ActionTicket.ACTION_CONNECT_COUNTER:
                var         objSendConnect = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                EventSocket evConnect      = new EventSocket(action, objSendConnect, counterID);
                DataReceived(evConnect);
                return;

            case ActionTicket.ACTION_CALL:
                var tkServing = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                tk = socController.GetTicketSendSocket(action, counterID, dicAllCounters, dicWaitting);
                if (tkServing != null)
                {
                    if (dicAllCounters.ContainsKey(tkServing.Counter_Id) && tk != null)
                    {
                        var cou = dicAllCounters[tkServing.Counter_Id];
                        cou.isNext = true;
                    }
                    convertObjectAndSend(ActionTicket.ACTION_FINISH, tkServing, serviceMove, counterMove);
                    return;
                }
                break;

            case ActionTicket.ACTION_RECALL:
                tk = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                break;

            case ActionTicket.ACTION_RESTORE:
                tk = dicCancelled.Values.FirstOrDefault(m => m.CNum == cNum);
                if (tk != null)
                {
                    tk.Counter_Id = counterID;
                }
                break;

            case ActionTicket.ACTION_CANCEL:
                Console.WriteLine("COUNTER: " + counterID);
                tk = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                break;

            case ActionTicket.ACTION_FINISH:
                tk = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                break;

            case ActionTicket.ACTION_CREATE:
                break;

            case ActionTicket.CALL_PRIORITY:
                var tkSer = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                if (tkSer != null)
                {
                    if (dicAllCounters.ContainsKey(tkSer.Counter_Id))
                    {
                        var cou = dicAllCounters[tkSer.Counter_Id];
                        cou.isNext = true;
                    }
                    convertObjectAndSend(ActionTicket.ACTION_FINISH, tkSer, serviceMove, counterMove);
                }
                tk = dicWaitting.Values.FirstOrDefault(m => m.CNum == cNum);
                if (tk != null)
                {
                    tk.Counter_Id = counterID;
                    action        = ActionTicket.ACTION_CALL;
                }
                break;

            case ActionTicket.ACTION_MOVE_SERVICE:
                tk = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                if (tk != null && GetService(tk).Equals(serviceMove[0]))
                {
                    sendNotiAction(ActionTicket.ACTION_MOVE_SERVICE, counterID);
                    return;
                }
                action = ActionTicket.ACTION_MOVE;
                break;

            case ActionTicket.ACTION_MOVE_COUNTER:
                tk = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                if (tk != null)
                {
                    var cou = (dicAllCounters.ContainsKey(counterMove[0])) ? dicAllCounters[counterMove[0]] : null;
                    if (cou != null)
                    {
                        var isCheckSer = cou.Services.Any(m => m == tk.Services[0]);
                        if (!isCheckSer)
                        {
                            sendNotiAction(ActionTicket.ACTION_MOVE_COUNTER, counterID);
                            return;
                        }
                    }
                }
                action = ActionTicket.ACTION_MOVE;
                break;

            case ActionTicket.RATING_ONCE:
                tk = dicServing.Values.FirstOrDefault(m => m.Counter_Id == counterID);
                convertRating(tk.Id, point);
                return;

            case ActionTicket.ACTION_PING:
                sendPingSocket();
                EventSocket eSocketRe = new EventSocket(ActionTicket.ACTION_PING);
                DataReceived(eSocketRe);
                return;

            default:
                break;
            }
            if (tk == null)
            {
                sendNotiAction(action, counterID);
                return;
            }
            convertObjectAndSend(action, tk, serviceMove, counterMove);
        }