//public int GetPendingTransferForProcessing()
        //{
        //    int queueId = 0;

        //    try
        //    {

        //        using (OracleConnection con = new DBConnection().getDBConnection())
        //        {

        //            using (OracleCommand command = con.CreateCommand())
        //            {

        //                command.CommandType = CommandType.StoredProcedure;
        //                command.CommandText = "GET_PENDING_REQUEST_IN_QUEUE";
        //                command.Parameters.Add("V_QUEUE_ID", OracleDbType.Int64, queueId, ParameterDirection.Output);
        //                command.ExecuteNonQuery();
        //                Int32.TryParse(Convert.ToString(command.Parameters["V_QUEUE_ID"].Value), out queueId);
        //            }
        //        }

        //    }
        //    catch (Exception errMsg)
        //    {
        //        Console.WriteLine(errMsg.Message);
        //    }

        //    return queueId;
        //}
        public Model.QueueData GetQueueData(int queueId)
        {
            Model.QueueData objQueueData = new Model.QueueData();

            try
            {
                string sql = "SELECT Q.ID,Q.EES_NAME,Q.KIOSK_ID,Q.CUSTOMER_PK_ID,Q.IS_ENTRY,Q.PRIORITY,Q.STATUS,Q.PROC_START_TIME,Q.PROC_END_TIME"
                             + " ,Q.ASSIGNED_THREAD_ID,Q.car_type,Q.GATE,cust.card_id,QUEUE_HANDLING_PACKAGE.get_machine_search_flag(Q.ID) machine_search_flag"
                             + " FROM L2_EES_QUEUE Q LEFT JOIN L2_CUSTOMERS CUST ON q.customer_pk_id=cust.customer_id   WHERE  ID=" + queueId;


                using (OracleConnection con = new DBConnection().getDBConnection())
                {
                    using (OracleCommand command = con.CreateCommand())
                    {
                        command.CommandText = sql;
                        using (OracleDataReader reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                while (reader.Read())
                                {
                                    objQueueData.queuePkId    = Int32.Parse(reader["ID"].ToString());
                                    objQueueData.eesCode      = reader["EES_NAME"].ToString();
                                    objQueueData.kioskId      = reader["KIOSK_ID"].ToString();
                                    objQueueData.customerPkId = Int32.Parse(reader["CUSTOMER_PK_ID"].ToString());
                                    objQueueData.customerId   = reader["card_id"].ToString();
                                    objQueueData.requestType  = Int32.Parse(reader["IS_ENTRY"].ToString());
                                    objQueueData.priority     = Int32.Parse(reader["PRIORITY"].ToString());

                                    objQueueData.status = Int32.Parse(reader["STATUS"].ToString());

                                    objQueueData.carType           = (ARCPMS_ENGINE.src.mrs.Global.GlobalValues.CAR_TYPE)Int32.Parse(reader["car_type"].ToString());
                                    objQueueData.gate              = reader["GATE"].ToString();
                                    objQueueData.isEntry           = objQueueData.requestType == 1 ? true : false;
                                    objQueueData.MachineSearchFlag = int.Parse(reader["machine_search_flag"].ToString());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception errMsg)
            {
                Console.WriteLine(errMsg);
            }
            return(objQueueData);
        }
        public Model.QueueData InsertQueue(Model.QueueData objQueueData)
        {
            var queueId = 0;

            try
            {
                lock (lockInserQueue)
                {
                    using (OracleConnection con = new DBConnection().getDBConnection())
                    {
                        using (OracleCommand command = con.CreateCommand())
                        {
                            command.CommandType = CommandType.StoredProcedure;
                            command.CommandText = "INSERT_QUEUE";
                            command.Parameters.Add("V_QUEUE_ID", OracleDbType.Int64, queueId, ParameterDirection.Output);
                            command.Parameters.Add("cust_id", OracleDbType.Varchar2, 50, objQueueData.customerId, ParameterDirection.Input);
                            command.Parameters.Add("ARG_EES_ID", OracleDbType.Int64, objQueueData.eesNumber, ParameterDirection.Input);
                            command.Parameters.Add("KIOSK_ID", OracleDbType.Varchar2, objQueueData.kioskId, ParameterDirection.Input);
                            command.Parameters.Add("CAR_ID", OracleDbType.Varchar2, objQueueData.plateNumber, ParameterDirection.Input);
                            command.Parameters.Add("ARG_REQUEST_TYPE", OracleDbType.Int64, objQueueData.requestType, ParameterDirection.Input);
                            command.Parameters.Add("PRIORITY", OracleDbType.Int64, 1, ParameterDirection.Input);
                            command.Parameters.Add("high_car", OracleDbType.Int64, objQueueData.carType, ParameterDirection.Input);
                            command.Parameters.Add("STAT", OracleDbType.Int64, 0, ParameterDirection.Input);
                            command.Parameters.Add("PATRON_NAME", OracleDbType.NVarchar2, 500, objQueueData.patronName, ParameterDirection.Input);
                            command.Parameters.Add("arg_need_wash", OracleDbType.Int64, (objQueueData.needWash ? 1 : 0), ParameterDirection.Input);
                            command.Parameters.Add("RETRIEVAL_TYPE", OracleDbType.Int64, objQueueData.retrievalType, ParameterDirection.Input);
                            command.Parameters.Add("arg_rot_staus", OracleDbType.Char, 0, ParameterDirection.Input);


                            command.ExecuteNonQuery();
                            Int32.TryParse(Convert.ToString(command.Parameters["V_QUEUE_ID"].Value), out queueId);
                            objQueueData.queuePkId = queueId;
                        }
                    }
                }
            }
            catch (Exception errMsg)
            {
                Console.WriteLine(errMsg.Message);
            }
            return(objQueueData);
        }
        public List <Model.QueueData> GetAllProcessingQId()
        {
            List <Model.QueueData> processingQList = new List <Model.QueueData>();

            try
            {
                string sql = "SELECT Q.ID FROM L2_EES_QUEUE Q    WHERE  STATUS =2";


                using (OracleConnection con = new DBConnection().getDBConnection())
                {
                    using (OracleCommand command = con.CreateCommand())
                    {
                        command.CommandText = sql;
                        using (OracleDataReader reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                while (reader.Read())
                                {
                                    Model.QueueData objQueueData = new Model.QueueData();
                                    objQueueData.queuePkId = Int32.Parse(reader["ID"].ToString());

                                    processingQList.Add(objQueueData);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception errMsg)
            {
                Console.WriteLine(errMsg);
            }
            return(processingQList);
        }
Ejemplo n.º 4
0
 public QueueService(Model.QueueData queueData, User user)
 {
     User      = user;
     QueueData = queueData;
     InitializeConnection();
 }
        public void ReadQueueEntryData()
        {
            if (objQueueDaoService == null)
            {
                objQueueDaoService = new QueueDaoImp();
            }
            if (objParkingControllerService == null)
            {
                objParkingControllerService = new ParkingControllerImp();
            }
            if (objClickTransferService == null)
            {
                objClickTransferService = new ClickTransferImp();
            }
            if (objCarWashControllerService == null)
            {
                objCarWashControllerService = new CarWashControllerImp();
            }
            int queueId = 0;

            try
            {
                queueEntryReader.Stop();
                queueId = objQueueDaoService.GetPendingQueueDataForProcessing();
                if (queueId != 0)
                {
                    Model.QueueData objQueueData = new Model.QueueData();
                    objQueueData = objQueueDaoService.GetQueueData(queueId);

                    CancellationTokenSource tokenSource = new CancellationTokenSource();


                    if (objQueueData.requestType == 1)
                    {
                        Task.Factory.StartNew(() => objParkingControllerService.EntryCarProcessing(objQueueData), tokenSource.Token);
                    }
                    else if (objQueueData.requestType == 0)
                    {
                        Task.Factory.StartNew(() => objParkingControllerService.ExitCarProcessing(objQueueData), tokenSource.Token);
                    }
                    else if (objQueueData.requestType == 3 || objQueueData.requestType == 4 ||
                             objQueueData.requestType == 5 || objQueueData.requestType == 6 ||
                             objQueueData.requestType == 7 || objQueueData.requestType == 8)
                    {
                        objParkingControllerService.AddRequestIntoQueue(objQueueData);
                    }

                    objQueueDaoService.SetQueueStatus(queueId, 2);
                }
            }
            catch (Exception errMsg)
            {
                Logger.WriteLogger(GlobalValues.PARKING_LOG, ":--Exception 'ReadQueueEntryData ':: " + errMsg.Message);
            }
            finally
            {
                removeFinishedThread();
                queueEntryReader.Interval = 3000;
                queueEntryReader.Start();
            }
        }