protected bool CloseBroker() { // *** Close and cleanup an rpc broker *** bool returnVal = false; // *** First get it from the store *** GetBrokerFromStore(); // *** If we have one *** if (this.rpcBroker != null) { // *** Delete from store *** BrokerStore.Delete(this.BrokerKey); // *** Close the broker ** RpcBrokerUtility.CloseBroker(this.rpcBroker); // *** Remove reference *** this.rpcBroker = null; // *** Indicate success *** returnVal = true; } // *** Remove unneeded key name *** if (Session != null) { Session[RpcBrokerUtility.BrokerKeyName] = ""; } return(returnVal); }
public BrokerOperationResult TestServerConnection(string serverName, string serverPort) { BrokerOperationResult returnResult = new BrokerOperationResult(); int port = 0; if (int.TryParse(serverPort, out port)) { //using (RpcBroker broker = new RpcBroker(serverName, port)) ServerConfig config = new ServerConfig() { ServerName = serverName, ListenerPort = port }; IRpcBroker broker = RpcBrokerUtility.GetNewConnectedRpcBroker(config); if (broker != null) { returnResult.SetResult(true, ""); broker.Disconnect(); } } return(returnResult); }
protected bool CreateBroker() { // *** Create the broker to use for data calls *** bool returnVal = false; if (this.rpcBroker == null) { // *** Get server settings *** ServerConfigResult opResult = this.DashboardRepository.Settings.GetServerData(); if (opResult.Success) { // *** Get connected broker *** this.rpcBroker = RpcBrokerUtility.GetNewConnectedRpcBroker(opResult.ServerConfig); // *** Check for broker *** if (this.rpcBroker != null) { // *** Add broker to store *** this.BrokerKey = BrokerStore.Add(this.rpcBroker); returnVal = true; } else { ErrorLogger.Log("Could not get a connected broker"); } } } else // *** We already have a broker *** { returnVal = true; } // *** Add Prenatal Lab File Name to repository *** this.DashboardRepository.PrenatalLabFileName = this.Request.MapPath("~/Content/PrenatalLabs.csv"); // *** Add Content Path to Checklist Repository *** if (this.DashboardRepository.Checklist != null) { this.DashboardRepository.Checklist.ContentPath = this.Request.MapPath("~/Content/"); } // *** Add broker to DashboardBroker *** if (this.rpcBroker != null) { this.DashboardRepository.SetRpcBroker(this.rpcBroker); } return(returnVal); }
protected void Session_OnEnd() { string brokerKey = (string)this.Session[RpcBrokerUtility.BrokerKeyName]; if (!string.IsNullOrWhiteSpace(brokerKey)) { IRpcBroker broker = BrokerStore.Get(brokerKey); if (broker != null) { RpcBrokerUtility.CloseBroker(broker); BrokerStore.Delete(brokerKey); } Session[RpcBrokerUtility.BrokerKeyName] = ""; TraceLogger.Log(string.Format(" -- Broker connection with key [{0}] has been closed -- ", brokerKey)); } if (Session["OutgoingCdaDocs"] != null) { List <string> docList = (List <string>)Session["OutgoingCdaDocs"]; foreach (string doc in docList) { try { TraceLogger.Log(string.Format("Deleting CDA temporary file, {0}.", doc)); System.IO.File.Delete(doc); } catch (Exception genericException) { string message = string.Format("Could not delete temporary CDA file {0}", doc); ErrorLogger.Log(genericException, message); } } } if (Session["CdaExportFolder"] != null) { string exportFolder = Session["CdaExportFolder"].ToString(); if (Directory.Exists(exportFolder)) { string[] files = System.IO.Directory.GetFiles(exportFolder); foreach (string file in files) { string tempUpper = System.IO.Path.GetFileName(file).ToUpper(); if ((tempUpper != "CDA.XSL") && (tempUpper != "WARNING READ THIS.TXT")) { DateTime fileDateTime = System.IO.File.GetLastWriteTime(file); DateTime expiredDateTime = DateTime.Now.AddDays(-1); if (expiredDateTime > fileDateTime) { try { System.IO.File.Delete(file); } catch (Exception ex) { ErrorLogger.Log(ex, "Could not delete temporary CDA file"); } } } } } } }