public bool doUpdatePortStatus(string portID, ProtocolFormat.OHTMessage.PortStationStatus 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 bool updatePortStatus(string portID, ProtocolFormat.OHTMessage.PortStationStatus 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 bool updatePortStatus(string portID, ProtocolFormat.OHTMessage.PortStationStatus 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);
            }
示例#4
0
 public static string portLoadStatusConvert(ProtocolFormat.OHTMessage.PortStationStatus portLoadStatus)
 {
     if (portLoadStatus == ProtocolFormat.OHTMessage.PortStationStatus.Down)
     {
         return(((int)PortLoadStatus.Port_Busy).ToString());
     }
     else if (portLoadStatus == ProtocolFormat.OHTMessage.PortStationStatus.Disabled)
     {
         return(((int)PortLoadStatus.Port_Busy).ToString());
     }
     else if (portLoadStatus == ProtocolFormat.OHTMessage.PortStationStatus.LoadRequest)
     {
         return(((int)PortLoadStatus.Port_Empty).ToString());
     }
     else if (portLoadStatus == ProtocolFormat.OHTMessage.PortStationStatus.UnloadRequest)
     {
         return(((int)PortLoadStatus.Port_Ready_To_Unload).ToString());
     }
     else if (portLoadStatus == ProtocolFormat.OHTMessage.PortStationStatus.Wait)
     {
         return(((int)PortLoadStatus.Port_Busy).ToString());
     }
     return(string.Empty);
 }
示例#5
0
        private void initPortStationDataChange()
        {
            var function =
                scApp.getFunBaseObj <PortStationReport>(PortStation.PORT_ID) as PortStationReport;

            try
            {
                //1.建立各個Function物件
                function.Read(bcfApp, SCAppConstants.EQPT_OBJECT_CATE_PORT, PortStation.PORT_ID);
                PortStation.PORT_SERVICE_STATUS = ProtocolFormat.OHTMessage.PortStationServiceStatus.InService;//暫時先寫死,以後要從資料庫讀
                //APORTSTATION port =  scApp.MapBLL.getPortByPortID(PortStation.PORT_ID);
                //PortStation.PORT_SERVICE_STATUS = port.PORT_SERVICE_STATUS;
                function.portServiceState = PortStation.PORT_SERVICE_STATUS;

                //2.read log
                function.Timestamp = DateTime.Now;
                LogManager.GetLogger("com.mirle.ibg3k0.sc.Common.LogHelper").Info(function.ToString());
                //LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(PortStationReport), Device: DEVICE_NAME,
                //    XID: PortStation.PORT_ID, Data: function.ToString());

                //3.logical (include db save)

                ProtocolFormat.OHTMessage.PortStationStatus status = default(ProtocolFormat.OHTMessage.PortStationStatus);
                if (function.portStationReady)
                {
                    switch (function.portStationLoadRequest)
                    {
                    case true:
                        //PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.LoadRequest;//LoadRequest
                        status = ProtocolFormat.OHTMessage.PortStationStatus.LoadRequest;    //LoadRequest
                        break;

                    case false:
                        //PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.UnloadRequest;//UnloadRequest
                        status = ProtocolFormat.OHTMessage.PortStationStatus.UnloadRequest;    //UnloadRequest
                        break;
                    }
                }
                else
                {
                    switch (function.portStationLoadRequest)
                    {
                    case true:
                        //PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.Down;//Down
                        status = ProtocolFormat.OHTMessage.PortStationStatus.Down;    //Down
                        break;

                    case false:
                        //PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.Wait;//Wait
                        status = ProtocolFormat.OHTMessage.PortStationStatus.Wait;    //Wait
                        break;
                    }
                }
                scApp.PortStationService.doUpdatePortStatus(PortStation.PORT_ID, status);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
            finally
            {
                scApp.putFunBaseObj <PortStationReport>(function);
            }
        }
示例#6
0
        private void PortStationDataChange(object sender, ValueChangedEventArgs e)
        {
            var function =
                scApp.getFunBaseObj <PortStationReport>(PortStation.PORT_ID) as PortStationReport;

            try
            {
                //1.建立各個Function物件
                function.Read(bcfApp, SCAppConstants.EQPT_OBJECT_CATE_PORT, PortStation.PORT_ID);
                function.portServiceState = PortStation.PORT_SERVICE_STATUS;
                //2.read log
                function.Timestamp = DateTime.Now;
                LogManager.GetLogger("com.mirle.ibg3k0.sc.Common.LogHelper").Info(function.ToString());
                //LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(PortStationReport), Device: DEVICE_NAME,
                //    XID: PortStation.PORT_ID, Data: function.ToString());

                //3.logical (include db save)
                ProtocolFormat.OHTMessage.PortStationStatus status = default(ProtocolFormat.OHTMessage.PortStationStatus);
                if (function.portStationReady)
                {
                    switch (function.portStationLoadRequest)
                    {
                    case true:
                        //PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.LoadRequest;//LoadRequest
                        status = ProtocolFormat.OHTMessage.PortStationStatus.LoadRequest;    //LoadRequest
                        break;

                    case false:
                        //PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.UnloadRequest;//UnloadRequest
                        status = ProtocolFormat.OHTMessage.PortStationStatus.UnloadRequest;    //UnloadRequest
                        break;
                    }
                }
                else
                {
                    switch (function.portStationLoadRequest)
                    {
                    case true:
                        PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.Down; //Down
                        status = ProtocolFormat.OHTMessage.PortStationStatus.Down;                  //Down
                        break;

                    case false:
                        PortStation.PORT_STATUS = ProtocolFormat.OHTMessage.PortStationStatus.Wait; //Wait
                        status = ProtocolFormat.OHTMessage.PortStationStatus.Wait;                  //Wait
                        break;
                    }
                }
                scApp.PortStationService.doUpdatePortStatus(PortStation.PORT_ID, status);

                AEQPT eqpt = scApp.getEQObjCacheManager().getEquipmentByEQPTID(PortStation.EQPT_ID);
                if (PortStation.PORT_SERVICE_STATUS != ProtocolFormat.OHTMessage.PortStationServiceStatus.OutOfService && !eqpt.EQ_Down)//如果Port沒有disable且所屬EQ並非Down,才需要上報MCS PortEventState
                {
                    mcsMapAction.sendS6F11_PortEventState(PortStation.PORT_ID, ((int)PortStation.PORT_STATUS).ToString());
                }
                else
                {
                    //do nothing
                }
                //如果port Down

                //scApp.getEQObjCacheManager().getPortStation

                //foreach(AUNIT portstation in eqpt.UnitList )
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
            finally
            {
                scApp.putFunBaseObj <PortStationReport>(function);
            }
        }