public IHttpActionResult GetActivityLog(JObject requestParams) { var data = ""; var identity = MyAuthorizationServerProvider.AuthenticateUser(); if (identity != null) { try { //Deserialize JSON data into calss object ActivityLog activityLog = requestParams.ToObject <ActivityLog>(); activityLog.p_CompID = identity.CompId; activityLog.p_UserId = Convert.ToInt32(identity.UserID); var ds = ActivityLogBL.LogCRUD(activityLog); data = Utility.ConvertDataSetToJSONString(ds); data = Utility.Successful(data); } catch (Exception ex) { data = Utility.Exception(ex);; } } else { data = Utility.AuthenticationError(); } return(new APIResult(Request, data)); }
public bool LogActivity(string activity, string message, string ex) { if (LoggedInUser != null) { tblActivityLog model = new tblActivityLog(); model.Activity = activity; model.ActivityDate = DateTime.Now; model.Exception = ex; model.IP = GetUserIP(); model.Message = message; model.SessionID = Session.SessionID; model.UserID = LoggedInUser.ID; model.UserName = LoggedInUser.Name; model.URL = Request.Url.AbsoluteUri; ActivityLogBL bl = new ActivityLogBL(); model = bl.AddActivityLog(model); return(true); } else { return(false); } }
public IHttpActionResult TaskUpdate(JObject requestParams) { var data = ""; var identity = MyAuthorizationServerProvider.AuthenticateUser(); if (identity != null) { try { UpdateTaskManagement task = requestParams.ToObject <UpdateTaskManagement>(); task.Param_CompID = identity.CompId; task.Param_UserID = Convert.ToInt32(identity.UserID); var ds = TaskBL.TaskUpdate(task); data = Utility.ConvertDataSetToJSONString(ds); data = Utility.Successful(data); #region Activity Log ActivityLog objlog = ActivityLogBL.ActivityLogMapper(Modules.Task.ToString(), 10, task.Param_CompID, task.Param_UserID , UserName, System.Reflection.MethodBase.GetCurrentMethod().Name, task.Param_TaskName, "", task.Param_ProjectName, task.Param_StatusName); var dsActivityLog = ActivityLogBL.LogCRUD(objlog); #endregion Activity Log } catch (Exception ex) { data = Utility.Exception(ex);; } } else { data = Utility.AuthenticationError(); } return(new APIResult(Request, data)); }
public void BindLogs() { ActivityLogBL bl = new ActivityLogBL(); grdLogs.DataSource = bl.GetTodayLogs(); grdLogs.DataBind(); //GeneratePDF(); }
public IHttpActionResult TaskCRUD(JObject requestParams) { var data = ""; var identity = MyAuthorizationServerProvider.AuthenticateUser(); if (identity != null) { try { //Deserialize JSON data into calss object TaskManagement task = requestParams.ToObject <TaskManagement>(); task.t_CompID = identity.CompId; task.t_UserId = Convert.ToInt32(identity.UserID); var ds = TaskBL.TaskCRUD(task); data = Utility.ConvertDataSetToJSONString(ds); data = Utility.Successful(data); #region Activity Log if (task.t_Action == 2 || task.t_Action == 3 || task.t_Action == 4) { ActivityLog objlog = ActivityLogBL.ActivityLogMapper(Modules.Task.ToString(), task.t_Action, task.t_CompID, task.t_UserId , UserName, System.Reflection.MethodBase.GetCurrentMethod().Name, task.t_TaskName); var dsActivityLog = ActivityLogBL.LogCRUD(objlog); if (!string.IsNullOrEmpty(task.t_FileName) && task.t_IsFileUploaded) { ActivityLog objlogfie = ActivityLogBL.ActivityLogMapper(Modules.Task.ToString(), (int)TaskAction.FILEADDED, task.t_CompID, task.t_UserId , UserName, System.Reflection.MethodBase.GetCurrentMethod().Name, task.t_TaskName, task.t_FileName); var dsActivityLogfile = ActivityLogBL.LogCRUD(objlogfie); } if (!string.IsNullOrEmpty(task.t_Comments)) { ActivityLog objlogcomments = ActivityLogBL.ActivityLogMapper(Modules.Task.ToString(), (int)TaskAction.COMMENTSADDED, task.t_CompID, task.t_UserId , UserName, System.Reflection.MethodBase.GetCurrentMethod().Name, task.t_TaskName, task.t_Comments); var dsActivityLogfile = ActivityLogBL.LogCRUD(objlogcomments); } } #endregion Activity Log } catch (Exception ex) { data = Utility.Exception(ex); } } else { data = Utility.AuthenticationError(); } return(new APIResult(Request, data)); }
public IHttpActionResult ProjectStatusCRUD(JObject requestParams) { var data = ""; var identity = MyAuthorizationServerProvider.AuthenticateUser(); if (identity != null) { try { //Deserialize JSON data into calss object TaskStatus taskStatus = requestParams.ToObject <TaskStatus>(); taskStatus.p_CompID = identity.CompId; taskStatus.p_UserId = Convert.ToInt32(identity.UserID); if (taskStatus.p_Action == 1)//View Action { if (identity.Role != "enduser") { taskStatus.p_UserId = 0; } } var ds = ProjectBL.ProjectStatusCRUD(taskStatus); data = Utility.ConvertDataSetToJSONString(ds); data = Utility.Successful(data); #region Activity Log if (taskStatus.p_Action == 2 || taskStatus.p_Action == 3 || taskStatus.p_Action == 5) { ActivityLog objlog = ActivityLogBL.ActivityLogMapper(Modules.Status.ToString(), taskStatus.p_Action, taskStatus.p_CompID, taskStatus.p_UserId , UserName, System.Reflection.MethodBase.GetCurrentMethod().Name, taskStatus.p_StatusName); var dsActivityLog = ActivityLogBL.LogCRUD(objlog); } #endregion Activity Log } catch (Exception ex) { data = Utility.Exception(ex);; } } else { data = Utility.AuthenticationError(); } return(new APIResult(Request, data)); }
private static string GenerateReport() { string path = ConfigurationManager.AppSettings["ReportPathOnServer"] + "Daily Activity" + DateTime.Now.ToShortDateString().Replace("/", "_") + ".pdf"; System.IO.File.WriteAllText(@"C:\Users\Public\TestFolder\WriteText.txt", " 1 " + path); Document doc = new Document(iTextSharp.text.PageSize.A4); System.IO.FileStream file = new System.IO.FileStream(path, System.IO.FileMode.OpenOrCreate); System.IO.File.WriteAllText(@"C:\Users\Public\TestFolder\WriteText.txt", " 1 " + file.ToString()); PdfWriter writer = PdfWriter.GetInstance(doc, file); doc.Open(); PdfPTable tab = new PdfPTable(5); PdfPCell cell = new PdfPCell(new Phrase("Header")); cell = ImageCell("~/images/logo.png", 30f, PdfPCell.ALIGN_LEFT); cell.Colspan = 5; cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right //Style cell.BorderColor = new BaseColor(System.Drawing.Color.Black); cell.Border = Rectangle.BOTTOM_BORDER; // | Rectangle.TOP_BORDER; cell.BorderWidthBottom = 1f; cell.PaddingBottom = 30f; tab.AddCell(cell); cell = new PdfPCell(new Phrase("DAILY ACTIVITY REPORT(" + DateTime.Now.ToShortDateString() + ")", new Font(Font.FontFamily.COURIER, 12F, 1, BaseColor.RED))); cell.Colspan = 5; cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right //Style // cell.BorderColor = new BaseColor(System.Drawing.Color.Black); cell.Border = Rectangle.BOTTOM_BORDER; // | Rectangle.TOP_BORDER; cell.BorderWidthBottom = 1f; cell.PaddingTop = 18f; cell.PaddingBottom = 18f; tab.AddCell(cell); //add header cells here tab.AddCell("Date & Time"); tab.AddCell("Username"); // tab.AddCell("Activity"); tab.AddCell("Message"); tab.AddCell("IP"); tab.AddCell("URL"); PdfPCell cellBottom = new PdfPCell(); cellBottom.Colspan = 5; cellBottom.HorizontalAlignment = 1; //Style cellBottom.BorderColor = new BaseColor(System.Drawing.Color.Black); cellBottom.Border = Rectangle.BOTTOM_BORDER; cellBottom.BorderWidthBottom = 1f; cellBottom.PaddingBottom = 5f; tab.AddCell(cellBottom); // put up the data now List <tblActivityLog> lst = new ActivityLogBL().GetTodayLogs(); foreach (var item in lst) { tab.AddCell(item.ActivityDate.ToShortDateString()); tab.AddCell(item.UserName); // tab.AddCell(item.Activity); tab.AddCell(item.Message); tab.AddCell(item.IP); tab.AddCell(item.URL); } doc.Add(tab); doc.Close(); file.Close(); return(path); }