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); }
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"); } } } } } } }