Пример #1
0
            public bool doCreatBlockZoneQueueByReqStatus(string car_id, string entry_sec_id, bool canPass, DateTime req_time)
            {
                bool   isSeccess        = true;
                string blockQueueStatus = string.Empty;
                Nullable <System.DateTime> block_time = null;

                if (canPass)
                {
                    block_time       = req_time;
                    blockQueueStatus = SCAppConstants.BlockQueueState.Blocking;
                }
                else
                {
                    blockQueueStatus = SCAppConstants.BlockQueueState.Request;
                }
                BLOCKZONEQUEUE blockObj = new BLOCKZONEQUEUE
                {
                    CAR_ID       = car_id,
                    ENTRY_SEC_ID = entry_sec_id,
                    REQ_TIME     = DateTime.Now,
                    BLOCK_TIME   = block_time,
                    STATUS       = blockQueueStatus
                };

                //   using (TransactionScope tx = new TransactionScope
                //(TransactionScopeOption.Suppress))
                //   {
                //using (DBConnection_EF con = new DBConnection_EF())
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    blockZoneQueueDao.add(con, blockObj);
                }
                //}
                return(isSeccess);
            }
Пример #2
0
            public (bool, BLOCKZONEQUEUE) CheckAndNoticeBlockVhPassByAdrID(string leave_adr_id)
            {
                List <ABLOCKZONEMASTER> lstBZM          = loadBZMByAdrID(leave_adr_id);
                BLOCKZONEQUEUE          waitblockZoneVH = null;

                if (lstBZM == null || lstBZM.Count == 0)
                {
                    return(false, null);
                }

                //foreach (ABLOCKZONEMASTER master in lstBZM)
                //{
                //switch (master.BLOCK_ZONE_TYPE)
                switch (lstBZM[0].BLOCK_ZONE_TYPE)
                {
                case E_BLOCK_ZONE_TYPE.Branch:
                    waitblockZoneVH = findNextBlockZonePassVh_Branch(lstBZM);
                    return(waitblockZoneVH != null, waitblockZoneVH);

                case E_BLOCK_ZONE_TYPE.Merge:
                    waitblockZoneVH = findNextBlockZonePassVh_Merge(lstBZM);
                    return(waitblockZoneVH != null, waitblockZoneVH);
                }

                return(false, null);
            }
Пример #3
0
            //public bool updateBlockZoneQueue_ThrouTime(string car_id, string current_sec_id, out BLOCKZONEQUEUE throu_block_queue)
            public bool updateBlockZoneQueue_ThrouTime(string car_id, out BLOCKZONEQUEUE throu_block_queue)
            {
                bool isSeccess = true;

                //DBConnection_EF con = DBConnection_EF.GetContext();
                try
                {
                    //using (DBConnection_EF con = new DBConnection_EF())
                    using (DBConnection_EF con = DBConnection_EF.GetUContext())
                    {
                        //BLOCKZONEQUEUE blockObj = blockZoneQueueDao.getUsingBlockQueueByCarIDSecID(con, car_id, current_sec_id);
                        //throu_block_queue = blockZoneQueueDao.getThrouTimeNullBlockQueueByCarIDSecID(con, car_id, current_sec_id);

                        throu_block_queue = blockZoneQueueDao.getThrouTimeNullBlockQueueByCarID(con, car_id);
                        if (throu_block_queue != null)
                        {
                            throu_block_queue.THROU_TIME = DateTime.Now;
                            throu_block_queue.STATUS     = SCAppConstants.BlockQueueState.Through;
                            con.Entry(throu_block_queue).Property(p => p.THROU_TIME).IsModified = true;
                            con.Entry(throu_block_queue).Property(p => p.STATUS).IsModified     = true;

                            //bool isDetached = con.Entry(blockObj).State == EntityState.Modified;
                            //if (isDetached)
                            blockZoneQueueDao.Update(con, throu_block_queue);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Exception");
                    isSeccess         = false;
                    throu_block_queue = null;
                }
                return(isSeccess);
            }
Пример #4
0
            public bool updateBlockZoneQueue_AbnormalEnd(BLOCKZONEQUEUE blockZoneQueue, string status)
            {
                bool isSeccess = true;

                //DBConnection_EF con = DBConnection_EF.GetContext(out isNwe);
                if (blockZoneQueue != null)
                {
                    //DBConnection_EF con = DBConnection_EF.GetContext();
                    using (DBConnection_EF con = DBConnection_EF.GetUContext())
                    {
                        con.BLOCKZONEQUEUE.Attach(blockZoneQueue);
                        blockZoneQueue.RELEASE_TIME = DateTime.Now;
                        blockZoneQueue.STATUS       = status;
                        con.Entry(blockZoneQueue).Property(p => p.RELEASE_TIME).IsModified = true;
                        con.Entry(blockZoneQueue).Property(p => p.STATUS).IsModified       = true;

                        //con.Entry(blockZoneQueue).State = EntityState.Modified;
                        blockZoneQueueDao.Update(con, blockZoneQueue);
                        //con.Commit();
                    }
                }
                else
                {
                    isSeccess = false;
                }

                return(isSeccess);
            }
        public bool CheckAndNoticeBlockVhPassByAdrID(string leave_adr_id)
        {
            bool isSuccess = true;
            List <ABLOCKZONEMASTER> lstBZM          = scApp.MapBLL.loadBZMByAdrID(leave_adr_id);
            BLOCKZONEQUEUE          waitblockZoneVH = null;

            if (lstBZM == null || lstBZM.Count == 0)
            {
                return(true);
            }
            //foreach (ABLOCKZONEMASTER master in lstBZM)
            //{
            //switch (master.BLOCK_ZONE_TYPE)
            switch (lstBZM[0].BLOCK_ZONE_TYPE)
            {
            case E_BLOCK_ZONE_TYPE.Branch:
                waitblockZoneVH = scApp.MapBLL.findNextBlockZonePassVh_Branch(lstBZM);
                break;

            case E_BLOCK_ZONE_TYPE.Merge:
                waitblockZoneVH = scApp.MapBLL.findNextBlockZonePassVh_Merge(lstBZM);
                break;
            }
            if (waitblockZoneVH != null)
            {
                isSuccess = scApp.VehicleBLL.noticeVhPass(waitblockZoneVH);
            }
            else
            {
                isSuccess = false;
            }
            //}
            return(isSuccess);
        }
Пример #6
0
            public BLOCKZONEQUEUE getReqBlockQueueBySecID(string sec_id)
            {
                BLOCKZONEQUEUE blockZoneQueue = null;

                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    blockZoneQueue = blockZoneQueueDao.getReqBlockQueueBySecID(con, sec_id);
                }
                return(blockZoneQueue);
            }
        public (bool isBlocking, BLOCKZONEQUEUE blockZoneQueue) IsBlocking(string entrySecID)
        {
            BLOCKZONEQUEUE blockZoneQueue = null;

            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                blockZoneQueue = blockZoneQueueDao.getCountBlockingQueueBySecID(con, entrySecID);
            }
            return(blockZoneQueue != null, blockZoneQueue);
        }
        public BLOCKZONEQUEUE getUsingBlockZoneQueueByVhID(string vh_id)
        {
            BLOCKZONEQUEUE blockZoneQueue = null;

            //DBConnection_EF con = DBConnection_EF.GetContext();
            //using (DBConnection_EF con = new DBConnection_EF())
            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                blockZoneQueue = blockZoneQueueDao.getUsingBlockQueueByCarID(con, vh_id);
            }
            return(blockZoneQueue);
        }
Пример #9
0
        public BLOCKZONEQUEUE getCountBlockingQueueBySecID(DBConnection_EF con, String entry_sec_id)
        {
            BLOCKZONEQUEUE bLOCKZONEQUEUE = null;
            var            query          = from block in con.BLOCKZONEQUEUE
                                            where block.ENTRY_SEC_ID == entry_sec_id.Trim() &&
                                            (block.STATUS == SCAppConstants.BlockQueueState.Blocking ||
                                             block.STATUS == SCAppConstants.BlockQueueState.Through)
                                            orderby block.REQ_TIME
                                            select block;

            bLOCKZONEQUEUE = query.FirstOrDefault();
            return(bLOCKZONEQUEUE);
        }
Пример #10
0
            public bool updateBlockZoneQueue_BlockTime(string car_id, string current_sec_id)
            {
                bool isSeccess = true;

                //DBConnection_EF con = DBConnection_EF.GetContext(out isNew);
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    BLOCKZONEQUEUE blockObj = blockZoneQueueDao.getUsingBlockQueueByCarIDSecID(con, car_id, current_sec_id);
                    blockObj.BLOCK_TIME = DateTime.Now;
                    blockObj.STATUS     = SCAppConstants.BlockQueueState.Blocking;
                    blockZoneQueueDao.Update(con, blockObj);
                    con.Release();
                }

                return(isSeccess);
            }
Пример #11
0
            public bool addBlockZoneQueue(string car_id, string entry_sec_id)
            {
                bool           isSeccess = true;
                BLOCKZONEQUEUE blockObj  = new BLOCKZONEQUEUE
                {
                    CAR_ID       = car_id,
                    ENTRY_SEC_ID = entry_sec_id,
                    REQ_TIME     = DateTime.Now,
                    STATUS       = SCAppConstants.BlockQueueState.Request
                };

                using (DBConnection_EF con = new DBConnection_EF())
                {
                    blockZoneQueueDao.add(con, blockObj);
                }
                return(isSeccess);
            }
Пример #12
0
            public BLOCKZONEQUEUE findNextBlockZonePassVh_Branch(List <ABLOCKZONEMASTER> bzms)
            {
                BLOCKZONEQUEUE lstBZQ = null;

                //由於有發生deadlock的問題所以改用獨立的connection。
                //DBConnection_EF con = DBConnection_EF.GetContext();
                //using (TransactionScope tx = new TransactionScope
                //    (TransactionScopeOption.Suppress))
                //{
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    //con.Configuration.AutoDetectChangesEnabled = false;
                    lstBZQ = blockZoneQueueDao.getFirstReqBlockQueueBySecIds(con, bzms.Select(bzm => bzm.ENTRY_SEC_ID.Trim()).ToList());
                    con.Release();
                }
                //}
                //}
                return(lstBZQ);
            }
        public bool updateBlockZoneQueue_ForceRelease(string car_id, string current_sec_id)
        {
            bool isSeccess = true;

            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                BLOCKZONEQUEUE blockObj = blockZoneQueueDao.getUsingBlockQueueByCarIDSecID(con, car_id, current_sec_id);
                if (blockObj != null)
                {
                    blockObj.RELEASE_TIME = DateTime.Now;
                    blockObj.STATUS       = SCAppConstants.BlockQueueState.Abnormal_Release_ForceRelease;
                    con.Entry(blockObj).Property(p => p.RELEASE_TIME).IsModified = true;
                    con.Entry(blockObj).Property(p => p.STATUS).IsModified       = true;

                    blockZoneQueueDao.Update(con, blockObj);
                }
            }
            return(isSeccess);
        }
        public bool updateBlockZoneQueue_ThrouTime(string car_id)
        {
            bool isSeccess = true;

            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                BLOCKZONEQUEUE throu_block_queue = blockZoneQueueDao.getThrouTimeNullBlockQueueByCarID(con, car_id);
                if (throu_block_queue != null)
                {
                    throu_block_queue.THROU_TIME = DateTime.Now;
                    throu_block_queue.STATUS     = SCAppConstants.BlockQueueState.Through;
                    con.Entry(throu_block_queue).Property(p => p.THROU_TIME).IsModified = true;
                    con.Entry(throu_block_queue).Property(p => p.STATUS).IsModified     = true;

                    blockZoneQueueDao.Update(con, throu_block_queue);
                }
            }
            return(isSeccess);
        }
Пример #15
0
            public BLOCKZONEQUEUE findNextBlockZonePassVh_Merge(List <ABLOCKZONEMASTER> bzms)
            {
                //1.找出BlockZoneMaster所有正在等待通過的Queue
                BLOCKZONEQUEUE BZQ = null;

                //由於有發生deadlock的問題所以改用獨立的connection。
                //DBConnection_EF con = DBConnection_EF.GetContext();
                //using (TransactionScope tx = new TransactionScope
                //        (TransactionScopeOption.Suppress))
                //{
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    //con.Configuration.AutoDetectChangesEnabled = false;
                    BZQ = blockZoneQueueDao.getFirstReqBlockQueueBySecIds(con, bzms.Select(bzm => bzm.ENTRY_SEC_ID.Trim()).ToList());
                    con.Release();
                }
                //}
                //2.ToDo按照這些車輛是否有貨做排序

                //3.ToDo按照MSC所給的命令優先順序做排序

                return(BZQ);
            }
Пример #16
0
 public void Update(DBConnection_EF con, BLOCKZONEQUEUE block)
 {
     //bool isDetached = con.Entry(block).State == EntityState.Modified;
     //if (isDetached)
     con.SaveChanges();
 }
Пример #17
0
 public void add(DBConnection_EF con, BLOCKZONEQUEUE block)
 {
     con.BLOCKZONEQUEUE.Add(block);
     con.SaveChanges();
 }