示例#1
0
        public void disconnect(ConnectionID connID, float timeout)
        {
            Console.WriteLine("WORKER OBJECT - disconnecting ...");

            WorkerConnectionID hpeconnID = (WorkerConnectionID)connID;

            string user_port_name     = connID.getUser().getInstanceName() + ":" + connID.getUserPortName();
            string provider_port_name = connID.getProvider().getInstanceName() + ":" + connID.getProviderPortName();

            if (!port_manager.isReleased(user_port_name))
            {
                Console.WriteLine(": DISCONNECT - EXCEPTION RELEASE PORT - " + user_port_name);
                throw new CCAExceptionImpl(CCAExceptionType.UsesPortNotReleased);
            }

            if (!connectionList.ContainsKey(connID.ToString()))
            {
                throw new CCAExceptionImpl(CCAExceptionType.PortNotConnected);
            }

            connectionList.Remove(connID.ToString());
            Console.WriteLine(": disconnecting " + user_port_name + " from " + provider_port_name);

            connByUserPort.Remove(user_port_name);
            connByProviderPort.Remove(provider_port_name);

            if (connectionProperties.ContainsKey(connID))
            {
                connectionProperties.Remove(connID);
            }
        }
示例#2
0
 private void OnConnect(uint connimeOut)
 {
     Connect.OnReceivedEx += Connect_OnReceivedEx;
     Connect.OnPublish    += Connect_OnPublish;
     Connect.Create(App.Current.GetType().ToString() + ConnectionID.ToString());
     if (Connect.Connect((int)connimeOut) == 0)
     {
         ConnectionStatus = true;
     }
 }
示例#3
0
        public override bool ToSQL(string tablename, Guid executionID, StringBuilder sb, bool firstItem)
        {
            try
            {
                Int64 elapsed = 0; // Convert.ToInt64(ResponseTimestamp.Subtract(RequestTimestamp).TotalMilliseconds);
                if (!firstItem)
                {
                    sb.Append(",");
                }

                //  (FDAExecutionID, connectionID, DeviceAddress, Attempt, TimestampUTC1, TimestampUTC2, ElapsedPeriod, TransCode, TransStatus, ApplicationMessage,DBRGUID,DBRGIdx,DBRGSize,Details01,TxSize,Details02,RxSize,ProtocolNote,Protocol) values ");

                sb.Append("('");
                sb.Append(executionID);
                sb.Append("','");
                sb.Append(ConnectionID.ToString());
                sb.Append("','");
                sb.Append(DeviceAddress);
                sb.Append("',");
                sb.Append(AttemptNum);
                sb.Append(",'");
                sb.Append(DateTimeHelpers.FormatDateTime(EventTime));
                sb.Append("','");
                sb.Append(DateTimeHelpers.FormatDateTime(EventTime));
                sb.Append("',");
                sb.Append(elapsed);
                sb.Append(",");
                sb.Append(EventType);
                sb.Append(",CAST(1 as bit),");
                sb.Append("'','"); // app message
                sb.Append(GroupID);
                sb.Append("','");
                sb.Append(GroupIdx);
                sb.Append("',");
                sb.Append(GroupSize);
                sb.Append(",'Tx: ");
                sb.Append(BitConverter.ToString(AckBytes));
                sb.Append("',");
                sb.Append(AckBytes.Length);
                sb.Append(",'N/A',0,'");
                sb.Append(ProtocolNote);
                sb.Append("','");
                sb.Append(Protocol);
                sb.Append("')");
            }
            catch (Exception ex)
            {
                Globals.SystemManager.LogApplicationError(Globals.FDANow(), ex, "Error occurred while adding a comms log comms transaction item to an SQL insert batch");
                return(false);
            }
            return(true);
        }
示例#4
0
        public override bool ToSQL(string tablename, Guid executionID, StringBuilder sb, bool firstItem)
        {
            //  (FDAExecutionID, connectionID, DeviceAddress, Attempt, TimestampUTC1, TimestampUTC2, ElapsedPeriod, TransCode, TransStatus, ApplicationMessage,DBRGUID,DBRGIdx,DBRGSize,Details01,TxSize,Details02,RxSize,ProtocolNote,Protocol) values ");
            try
            {
                DateTime endTime = StartTime.Add(Elapsed);
                if (!firstItem)
                {
                    sb.Append(",");
                }
                sb.Append("('");
                sb.Append(executionID);
                sb.Append("','");
                sb.Append(ConnectionID.ToString());
                sb.Append("','',");
                sb.Append(Attempt);
                sb.Append(",'");
                sb.Append(DateTimeHelpers.FormatDateTime(StartTime));
                sb.Append("','");
                sb.Append(DateTimeHelpers.FormatDateTime(endTime));
                sb.Append("',");
                sb.Append(Elapsed.TotalMilliseconds);
                sb.Append(",");
                sb.Append(EventType);
                sb.Append(",");
                sb.Append("cast(" + Status + " as bit)");
                sb.Append(",'");
                sb.Append(Message.Replace("'", "''"));
                sb.Append("','00000000-0000-0000-0000-000000000000','0',0,'N/A',0,'N/A',0,'N/A','N/A')");
            } catch (Exception ex)
            {
                Globals.SystemManager.LogApplicationError(Globals.FDANow(), ex, "Error occurred while adding a comms log connection event to an SQL insert batch");
                return(false);
            }

            return(true);
        }
示例#5
0
        public override bool ToSQL(string tablename, Guid executionID, StringBuilder sb, bool firstItem)
        {
            // generate the SQL for inserting this log item into the database (will be appended to a larger query for inserting several records in a single query)

            // the entire insert query looks like this:
            // Insert into CommsLog (FDAExecutionID, connectionID, DeviceAddress, Attempt, TimestampUTC1, TimestampUTC2, ElapsedPeriod, TransCode, TransStatus, ApplicationMessage,DBRGUID,DBRGIdx,DBRGSize,Details01,TxSize,Details02,RxSize,ProtocolNote,Protocol) values ")
            // values (log item 1),(log item 2), etc...

            try
            {
                string timestampStr = DateTimeHelpers.FormatDateTime(Timestamp);

                if (!firstItem)
                {
                    sb.Append(",");
                }
                sb.Append("('");
                sb.Append(executionID);
                sb.Append("','");
                sb.Append(ConnectionID.ToString());
                sb.Append("','',0,'");
                sb.Append(timestampStr);
                sb.Append("','");
                sb.Append(timestampStr);
                sb.Append("',0,");
                sb.Append(EventType);
                sb.Append(",cast(1 as bit),'");
                sb.Append(Message.Replace("'", "''"));
                sb.Append("','00000000-0000-0000-0000-000000000000','0',0,'N/A',0,'N/A',0,'N/A','N/A')");
            } catch (Exception ex)
            {
                Globals.SystemManager.LogApplicationError(Globals.FDANow(), ex, "Error occurred while adding a comms log comms event item to an SQL insert batch");
                return(false);
            }
            return(true);
        }
示例#6
0
        private void FTP_Welcome()
        {
            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }

            fileLog = new BinaryWriter(File.Open(logDir + ((System.Net.IPEndPoint)base.ClientEndPoint).Address.ToString() + "_" + ConnectionID.ToString() + ".txt", FileMode.Create));

            buffWriter.Clear();
            buffWriter.WriteString("220 " + _serverName + "\r\n", RawServer.BuffConverter.StringEncoding.ASCII);

            base.Send(buffWriter.ToByteArray());
        }
示例#7
0
        public override bool ToSQL(string tablename, Guid executionID, StringBuilder sb, bool firstItem)
        {
            // generate the SQL for inserting this log item into the database (will be appended to a larger query for inserting several records in a single query)
            // the entire insert query looks like this:
            // Insert into CommsLog (FDAExecutionID, connectionID, DeviceAddress, Attempt, TimestampUTC1, TimestampUTC2, ElapsedPeriod, TransCode, TransStatus, ApplicationMessage,DBRGUID,DBRGIdx,DBRGSize,Details01,TxSize,Details02,RxSize,ProtocolNote,Protocol)
            // values (log item 1),(log item 2), etc...

            try
            {
                Int64 elapsed = Convert.ToInt64(ResponseTimestamp.Subtract(RequestTimestamp).TotalMilliseconds);
                if (!firstItem)
                {
                    sb.Append(",");
                }


                sb.Append("('");
                sb.Append(executionID);
                sb.Append("','");
                sb.Append(ConnectionID.ToString());
                sb.Append("','");
                sb.Append(DeviceAddress);
                sb.Append("',");
                sb.Append(AttemptNum);
                sb.Append(",'");
                sb.Append(DateTimeHelpers.FormatDateTime(RequestTimestamp));
                sb.Append("','");
                sb.Append(DateTimeHelpers.FormatDateTime(ResponseTimestamp));
                sb.Append("',");
                sb.Append(elapsed);
                sb.Append(",");
                sb.Append(EventType);
                sb.Append(",");
                if (ResultStatus == DataRequest.RequestStatus.Success)
                {
                    sb.Append("cast(1 as bit),");
                }
                else
                {
                    sb.Append("cast(0 as bit),");
                }
                sb.Append("'");
                sb.Append(ApplicationMessage);
                sb.Append("','");
                sb.Append(GroupID);
                sb.Append("','");
                sb.Append(GroupIdx);
                sb.Append("',");
                sb.Append(GroupSize);
                sb.Append(",'Tx: ");
                sb.Append(BitConverter.ToString(RequestBytes));
                sb.Append("',");
                sb.Append(RequestBytes.Length);
                if (ResponseBytes != null)
                {
                    sb.Append(",'Rx: ");
                    sb.Append(BitConverter.ToString(ResponseBytes));
                    sb.Append("',");
                    sb.Append(ResponseBytes.Length);
                    sb.Append(",'");
                }
                else
                {
                    sb.Append(",'N/A',0,'");
                }
                sb.Append(Details.Replace("'", "''"));
                sb.Append("','");
                sb.Append(Protocol);
                sb.Append("')");
            } catch (Exception ex)
            {
                Globals.SystemManager.LogApplicationError(Globals.FDANow(), ex, "Error occurred while adding a comms log comms transaction item to an SQL insert batch");
                return(false);
            }
            return(true);
        }