Show/Hide Toolbars

How to Implement Server Scripting and Logging With FVTerm

Use this to clean-up any static resources or allocation tables related to a user session.

 

         /// <summary>

         /// Disconnecting is used for managing assigned LUnames or other details on a user

         /// </summary>

         /// <param name="context">Active HTTP Context</param>

         /// <param name="hostName">Host name connected to</param>

         /// <param name="luName">LUName being disconnected</param>

         /// <returns></returns>

         static public bool Disconnecting(HttpContext context, string luName, string hostName)

         {

                 TimeSpan span = TimeSpan.MinValue;

                 DateTime startTime = DateTime.Now;

                 try

                 {

                         using (System.IO.StreamWriter sw = new System.IO.StreamWriter(Path.Combine(FVTermFolder, "Disconnecting.txt"), true))

                         {

                                 sw.WriteLine(String.Format("User:{0}/{1}, HostName:{2}, luName:{3}", context.User.Identity.Name,

                                                         context.Request.LogonUserIdentity.Name,

                                                         hostName, luName));

                         }

                 }

                 catch (System.Exception)

                 {        }

                 return true;

         }

 

The above sample demonstrates logging each user session disconnect.