public bool doUpdatePortStatus(string portID, E_PORT_STATUS status)
        {
            bool   isSuccess = true;
            string result    = string.Empty;

            try
            {
                if (isSuccess)
                {
                    using (TransactionScope tx = SCUtility.getTransactionScope())
                    {
                        using (DBConnection_EF con = DBConnection_EF.GetUContext())
                        {
                            isSuccess = scApp.PortStationBLL.OperateDB.updatePortStatus(portID, status);
                            if (isSuccess)
                            {
                                tx.Complete();
                                scApp.PortStationBLL.OperateCatch.updatePortStatus(portID, status);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error(ex, "Execption:");
            }
            return(isSuccess);
        }
            public void updatePortStationStatus(string portID, E_PORT_STATUS portStatus)
            {
                APORTSTATION port_station = CacheManager.getPortStation(portID);

                if (port_station != null)
                {
                    port_station.PORT_STATUS = portStatus;
                }
            }
 public bool updatePortStatus(string portID, E_PORT_STATUS status)
 {
     try
     {
         APORTSTATION port_station = CacheManager.getPortStation(portID);
         port_station.PORT_STATUS = status;
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         return(false);
     }
     return(true);
 }
            public void updatePortStationStatus(string port_id, E_PORT_STATUS port_status)
            {
                APORTSTATION portTemp = null;

                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    portTemp = portStationDao.getByID(con, port_id);
                    if (portTemp != null)
                    {
                        portTemp.PORT_STATUS = port_status;
                        portStationDao.update(con, portTemp);
                    }
                }
            }
        private void RegisterSegmentEvent()
        {
            Post["Segment/StatusUpdate"] = (p) =>
            {
                var    scApp     = SCApplication.getInstance();
                bool   isSuccess = true;
                string result    = string.Empty;

                string seg_id = Request.Query.seg_id.Value ?? Request.Form.seg_id.Value ?? string.Empty;
                string type   = Request.Query.type.Value ?? Request.Form.type.Value ?? string.Empty;
                string satus  = Request.Query.satus.Value ?? Request.Form.satus.Value ?? string.Empty;
                try
                {
                    Enum.TryParse(type, out sc.ASEGMENT.DisableType disableType);
                    Enum.TryParse(satus, out sc.E_SEG_STATUS e_status);

                    E_PORT_STATUS port_status = e_status == E_SEG_STATUS.Active ?
                                                E_PORT_STATUS.InService : E_PORT_STATUS.OutOfService;
                    switch (disableType)
                    {
                    case ASEGMENT.DisableType.Safety:
                        var enable_result = scApp.RoadControlService.RecoverCVEnable(seg_id);
                        isSuccess = enable_result.isSuccess;
                        result    = enable_result.reason;
                        break;

                    default:
                        isSuccess = scApp.RoadControlService.doEnableDisableSegment(seg_id, port_status, disableType, Data.SECS.CSOT.SECSConst.LANECUTTYPE_LaneCutOnHMI);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    result    = "Execption happend!";
                    logger.Error(ex, "Execption:");
                }

                var response = (Response)result;
                response.ContentType = restfulContentType;
                return(response);
            };
        }
            public bool updatePortStatus(string portID, E_PORT_STATUS status)
            {
                try
                {
                    APORTSTATION port_statino = new APORTSTATION();
                    port_statino.PORT_ID = portID;
                    using (DBConnection_EF con = DBConnection_EF.GetUContext())
                    {
                        con.APORTSTATION.Attach(port_statino);
                        port_statino.PORT_STATUS = status;

                        con.Entry(port_statino).Property(p => p.PORT_STATUS).IsModified = true;

                        portStationDao.update(con, port_statino);
                        con.Entry(port_statino).State = EntityState.Detached;
                    }
                }
                catch
                {
                    return(false);
                }
                return(true);
            }
Example #7
0
        public void doEnableDisableSegment(string segment_id, E_PORT_STATUS port_status, string laneCutType)
        {
            ASEGMENT segment = null;

            try
            {
                List <APORTSTATION> port_stations = PortStationBLL.OperateCatch.loadAllPortBySegmentID(segment_id, SectionBLL);

                using (TransactionScope tx = SCUtility.getTransactionScope())
                {
                    using (DBConnection_EF con = DBConnection_EF.GetUContext())
                    {
                        switch (port_status)
                        {
                        case E_PORT_STATUS.InService:
                            segment = RouteGuide.OpenSegment(segment_id);
                            break;

                        case E_PORT_STATUS.OutOfService:
                            segment = RouteGuide.CloseSegment(segment_id);
                            break;
                        }
                        foreach (APORTSTATION port_station in port_stations)
                        {
                            PortStationBLL.OperateDB.updatePortStationStatus(port_station.PORT_ID, port_status);
                            PortStationBLL.OperateCatch.updatePortStationStatus(port_station.PORT_ID, port_status);
                        }
                        tx.Complete();
                    }
                }
                List <AMCSREPORTQUEUE> reportqueues = new List <AMCSREPORTQUEUE>();
                List <ASECTION>        sections     = SectionBLL.cache.loadSectionsBySegmentID(segment_id);
                string segment_start_adr            = sections.First().FROM_ADR_ID;
                string segment_end_adr = sections.Last().TO_ADR_ID;
                switch (port_status)
                {
                case E_PORT_STATUS.InService:
                    ReportBLL.newReportLaneInService(segment_start_adr, segment_end_adr, laneCutType, reportqueues);
                    break;

                case E_PORT_STATUS.OutOfService:
                    ReportBLL.newReportLaneOutOfService(segment_start_adr, segment_end_adr, laneCutType, reportqueues);
                    break;
                }
                foreach (APORTSTATION port_station in port_stations)
                {
                    switch (port_status)
                    {
                    case E_PORT_STATUS.InService:
                        ReportBLL.newReportPortInServeice(port_station.PORT_ID, reportqueues);
                        break;

                    case E_PORT_STATUS.OutOfService:
                        ReportBLL.newReportPortOutOfService(port_station.PORT_ID, reportqueues);
                        break;
                    }
                }
                ReportBLL.newSendMCSMessage(reportqueues);
            }
            catch (Exception ex)
            {
                segment = null;
                logger.Error(ex, "Exception:");
            }
            //return segment;
        }
Example #8
0
        public bool doEnableDisableSegment(string segment_id, E_PORT_STATUS status, ASEGMENT.DisableType disableType, string laneCutType)
        {
            bool     is_success = true;
            ASEGMENT seg_do     = null;

            try
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(RoadControlService), Device: "OHxC",
                              Data: $"Start process segment:{segment_id} excute:{status} ,disable type:{disableType} ,lane cut type:{laneCutType}");

                bool     is_status_change = false;
                ASEGMENT seg_vo           = SegmentBLL.cache.GetSegment(segment_id);
                lock (seg_vo)
                {
                    List <APORTSTATION> port_stations = PortStationBLL.OperateCatch.loadAllPortBySegmentID(segment_id, SectionBLL);
                    using (TransactionScope tx = SCUtility.getTransactionScope())
                    {
                        using (DBConnection_EF con = DBConnection_EF.GetUContext())
                        {
                            switch (status)
                            {
                            case E_PORT_STATUS.InService:
                                seg_do = RouteGuide.OpenSegment(segment_id, disableType);
                                break;

                            case E_PORT_STATUS.OutOfService:
                                seg_do = RouteGuide.CloseSegment(segment_id, disableType);
                                break;
                            }
                            is_status_change = seg_vo.STATUS != seg_do.STATUS;
                            if (is_status_change)
                            {
                                foreach (APORTSTATION port_station in port_stations)
                                {
                                    PortStationBLL.OperateDB.updatePortStationStatus(port_station.PORT_ID, status);
                                    PortStationBLL.OperateCatch.updatePortStationStatus(port_station.PORT_ID, status);
                                }
                            }
                            tx.Complete();
                        }
                    }
                    seg_vo.put(seg_do);
                    segmentListChanged?.Invoke(this, seg_vo);

                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(RoadControlService), Device: "OHxC",
                                  Data: $"end process segment:{segment_id} excute:{status} ,disable type:{disableType} ,lane cut type:{laneCutType}" +
                                  $"finial status:{seg_vo.STATUS},DISABLE_FLAG_USER:{seg_vo.DISABLE_FLAG_USER},DISABLE_FLAG_SAFETY:{seg_vo.DISABLE_FLAG_SAFETY}" +
                                  $",DISABLE_FLAG_HID:{seg_vo.DISABLE_FLAG_HID},DISABLE_FLAG_SYSTEM:{seg_vo.DISABLE_FLAG_SYSTEM}");

                    if (is_status_change)
                    {
                        List <AMCSREPORTQUEUE> reportqueues = new List <AMCSREPORTQUEUE>();
                        List <ASECTION>        sections     = SectionBLL.cache.loadSectionsBySegmentID(segment_id);
                        string segment_start_adr            = sections.First().FROM_ADR_ID;
                        string segment_end_adr = sections.Last().TO_ADR_ID;
                        switch (seg_vo.STATUS)
                        {
                        case E_SEG_STATUS.Active:
                            ReportBLL.newReportLaneInService(segment_start_adr, segment_end_adr, laneCutType, reportqueues);
                            break;

                        case E_SEG_STATUS.Closed:
                            ReportBLL.newReportLaneOutOfService(segment_start_adr, segment_end_adr, laneCutType, reportqueues);
                            break;
                        }
                        foreach (APORTSTATION port_station in port_stations)
                        {
                            switch (seg_vo.STATUS)
                            {
                            case E_SEG_STATUS.Active:
                                ReportBLL.newReportPortInServeice(port_station.PORT_ID, reportqueues);
                                break;

                            case E_SEG_STATUS.Closed:
                                ReportBLL.newReportPortOutOfService(port_station.PORT_ID, reportqueues);
                                break;
                            }
                        }
                        ReportBLL.newSendMCSMessage(reportqueues);
                    }
                }
            }
            catch (Exception ex)
            {
                seg_do = null;
                logger.Error(ex, "Exception:");
                is_success = false;
            }
            return(is_success);
            //return seg_do;
        }