private void UserTrack() { BL_Employee objBL = new BL_Employee(); string hostAddress = string.Empty, serverIP = string.Empty; hostAddress = GetHostAddress(); serverIP = GetServerIPAddress(); objBL.SavePageHitsCount(UserSession.VZID, Convert.ToString(ConfigurationManager.AppSettings["ToolCode"]), Path.GetFileName(Request.Url.PathAndQuery), hostAddress, serverIP); }
//Set logged user session public static void SetUserSession(Int64 EmpEid) { #region Set User Session if (UserSession.EmpEID == null || UserSession.EmpID == null) { BL_Employee objBL = new BL_Employee(); PL_Employee MySession = objBL.GetLoggedInEmpDetails(EmpEid); if (MySession != null) { List<string> MyRoleID = new List<string>(); List<string> MyRoleName = new List<string>(); UserSession.EmpEID = Convert.ToString(MySession.EmpEid); UserSession.EmpID = Convert.ToString(MySession.EmpId); UserSession.VZID = MySession.VZID; UserSession.Gender = MySession.Gender; UserSession.EmpName = MySession.EmpName; UserSession.EmpFirstName = MySession.EmpFirstName; UserSession.Email = MySession.Email; } } #endregion }
public static void WriteToLog(string strClassMethod, string strMessage, string strEmpId) { try { StreamWriter w; string strApplicationName = HttpContext.Current.Request.ApplicationPath; string strFileName = GetFileName(); string strFilePath = GetLogFolderPath() + strFileName; //DeleteFiles(GetLogFolderPath()); if (!File.Exists(strFilePath)) { w = File.CreateText(strFilePath); w.Close(); } w = File.AppendText(strFilePath); w.Write("\r\n----------------------"); w.Write("Log Entry : "); w.Write("{0}", DateTime.Now.ToString()); w.Write("----------------------"); w.WriteLine("\r\nApplicationName : {0}", strApplicationName); w.WriteLine("Class.Method : {0}", strClassMethod); w.WriteLine("Error : {0}", strMessage); w.WriteLine("EmpId : {0}", strEmpId); w.WriteLine("----------------------------------------------------------------------------"); // Update the underlying file. string txtErrorMessage = "Error : {0}" + strMessage + "<br>" + "EmpId : {0}" + strEmpId; w.Flush(); w.Close(); try { #region Table Content Preparation StringBuilder sb = new StringBuilder(); sb.Append("<table style='border:0px solid #000000;border-collapse:collapse;font-family:Arial;font-size:x-small;'>"); sb.Append("<tr>"); sb.Append("<td align='left'><b>Employee ID</b>"); sb.Append("</td>"); sb.Append("<td width='10px'></td>"); sb.AppendFormat("<td align='left'>{0}", strEmpId); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("<tr>"); sb.Append("<td align='left'><b>Date</b>"); sb.Append("</td>"); sb.Append("<td width='10px'></td>"); sb.AppendFormat("<td align='left'>{0}", DateTime.Now.ToShortDateString()); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("<tr>"); sb.Append("<td align='left'><b>Time</b>"); sb.Append("</td>"); sb.Append("<td width='10px'></td>"); sb.AppendFormat("<td align='left'>{0}", DateTime.Now.ToLongTimeString()); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("<tr>"); sb.Append("<td align='left'><b>Page Location </b>"); sb.Append("</td>"); sb.Append("<td width='10px'></td>"); sb.AppendFormat("<td align='left'>{0}", strClassMethod); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("<tr>"); sb.Append("<td align='left'><b>Source</b>"); sb.Append("</td>"); sb.Append("<td width='10px'></td>"); sb.AppendFormat("<td align='left'>{0}", strMessage); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("</table>"); #endregion BL_Employee objBL = new BL_Employee(); //objBL.SaveErrorMessage(sb.ToString()); } catch { } } catch (Exception ex) { } }