public static void TestUpdate() { BrokerDAO.UpdateAppBrokerProperty(new Broker() { id = 2, interfaceStatusId = 3 }, BrokerDAO.Property.Status); }
// // GET: /BrokerMessage/ public ActionResult Index() { ViewBag.otherTitle = "Active Connections"; // interface related titles // incoming interface should always show if it's connected or not ViewBag.incomingTitleInterface = "Incoming from Interface to Broker Service"; ViewBag.outgoingTitleInterface = "Outgoing Interface from Broker Service (PASS THROUGH)"; // database related titles // this should always show the database connection status? ViewBag.outgoingTitleDatabase = "Outgoing from Service to Broker Database"; ViewBag.incomingTitleDatabase = "Incoming from External Database"; // web service titles // this is going to show what needs to be processed ViewBag.incomingTitleWebService = "Incoming from Broker Database to External Webservice"; List <Broker> interfaceList = new List <Broker>(); interfaceList = BrokerDAO.GetBrokerWorklist(); interfaceList.RemoveAll(b => b.communicationTypeName == "DATABASE" || b.communicationTypeName == "WEBSERVICE"); ViewBag.interfaceList = interfaceList; return(View()); }
private void startWaiting() { // update broker status to connected this.broker.interfaceStatusId = BrokerDAO.WAITING; // set worklist to waiting BrokerDAO.UpdateAppBrokerProperty(this.broker, BrokerDAO.Property.Status); }
public static Broker GetBrokerByApplicationAndCommunication(Communication communication, Broker broker) { List <Broker> brokers = BrokerDAO.Get(); broker = brokers.Find(b => b.communicationId == communication.id); return(broker); }
public static void handleBrokerStatUpdate(Message message, Communication communication) { Broker myBrokerUpdate = new Broker(); myBrokerUpdate = ConfigurationUtility.GetBrokerByApplicationAndCommunication(communication, myBrokerUpdate); myBrokerUpdate.lastMessageId = message.id; myBrokerUpdate.lastMessageDTTM = DateTime.Now; BrokerDAO.UpdateAppBrokerProperty(myBrokerUpdate, BrokerDAO.Property.Stats); // update the inbound one because it won't for some reason work on the inbound service myBrokerUpdate.id = 2; BrokerDAO.UpdateAppBrokerProperty(myBrokerUpdate, BrokerDAO.Property.Stats); }
private void stopListener() { // end the thread this.tcpListener.Stop(); // turn off the listener this.alreadyListening = false; // update broker status to connected this.broker.interfaceStatusId = BrokerDAO.STOPPED; // set worklist to waiting BrokerDAO.UpdateAppBrokerProperty(this.broker, BrokerDAO.Property.Status); }
private void startListener() { // start the interface this.tcpListener = new TcpListener(this.ipAddress, this.portNo); // start the interface this.tcpListener.Start(); // set the listening to true this.alreadyListening = true; // update broker status to connected this.broker.interfaceStatusId = BrokerDAO.WAITING; // set worklist to waiting BrokerDAO.UpdateAppBrokerProperty(this.broker, BrokerDAO.Property.Status); }
private void setBroker() { // init new broker to use for future updates this.broker = new Broker(); // set the correct broker for this interface for use across class List <Broker> brokers = BrokerDAO.Get(); // get a temp broker object Broker tempBroker = brokers.Find(b => b.communicationId == this.incomingCommunication.id); // do a shallow copy to get a new copy that I can work w/ later this.broker = tempBroker.ShallowCopy(); // get the current process id of the thread this.broker.processId = GenericUtility.GetCurrentManagedThreadId(); BrokerDAO.UpdateAppBrokerProperty(this.broker, BrokerDAO.Property.Process); BrokerDAO.UpdateAppBrokerProperty(this.broker, BrokerDAO.Property.Stats); }
public static void handleUpdateBrokerStats(int messageIdentity, HL7Broker.Model.Socket socket) { socket.broker.lastMessageDTTM = DateTime.Now; socket.broker.lastMessageId = messageIdentity; BrokerDAO.UpdateAppBrokerProperty(socket.broker, BrokerDAO.Property.Stats); }
private void run() { // create bye buffer the size of the input Byte[] buffer = new Byte[MAX_MESSAGE_SIZE]; // set connected here TcpClient tcpClient = this.tcpListener.AcceptTcpClient(); if (tcpClient.Connected) { if (this.broker.interfaceStatusId != BrokerDAO.CONNECTED) { // update interface broker status to connected since we are connected this.broker.interfaceStatusId = BrokerDAO.CONNECTED; // set worklist to waiting BrokerDAO.UpdateAppBrokerProperty(this.broker, BrokerDAO.Property.Status); } } else { startWaiting(); } // get the data String data = null; // get the network stream this.networkStream = tcpClient.GetStream(); // define stream byte index int byteIndex = 0; try { // define stream byte index // Loop to receive all the data sent by the client. while ((byteIndex = this.networkStream.Read(buffer, 0, buffer.Length)) != 0) { // Translate data bytes to a ASCII string. data = System.Text.Encoding.UTF8.GetString(buffer, 0, byteIndex); // if for some reason we can't process the message, we'll reject it (hopefully) try { // pass it over to inbound delegate delegate this.incomingHandler(data.ToString(), this.incomingCommunication, this); } catch (Exception e) { // this means we had trouble parsing the message when it came in. string ackRejected = HL7MessageUtility.getAck(AcknowledgementDAO.AcknowledgementType.AR.ToString(), ERROR_CONTROL_ID, DateTime.Now.ToString(), MESSAGE_HEADER_APPLICATION_NAME, MESSAGE_HEADER_FACILITY_NAME, ERROR_MESSAGE_REJECTED); // build ack response AcknowledgementDAO.insertIntoAcknowledgement(new Acknowledgement() { id = NEG_ONE, acknowledgementTypeId = (int)AcknowledgementDAO.AcknowledgementType.AE, messageId = 0, raw = ERROR_MESSAGE_REJECTED, createdDttm = DateTime.Now }); // pad the hl7 msesage for transfer ackRejected = HL7MessageUtility.padHL7MessageForTransfer(ackRejected); // write back this.networkStream.Write(Encoding.UTF8.GetBytes(ackRejected), 0, ackRejected.Length); // move on, don't stop continue; } // pass it over to the outbound delegate this.outgoingdHandler(data.ToString(), this.outgoingCommunication, this); } } catch (Exception ex) { ErrorLogger.LogError(ex, "run()"); } finally { // Shutdown and end connection tcpClient.Close(); // if the user is disconnected - set to waiting startWaiting(); } // Shutdown and end connection tcpClient.Close(); }