//using System.Web.Mvc; //using System; //using System.Collections.Generic; //using System.Configuration; //using System.Data; //using System.Reflection; //using System.Web.Mvc; //using GODATA.Models.AuditLog; //using Kendo.Mvc.Extensions; //using Kendo.Mvc.UI; ////using CsvHelper; ////using ExportToExcel; //namespace GODATA.Controllers //{ // public class AuditLogController : Controller // { // #region Global References // /// // /// Global variable for Audit log repository // /// // private AuditLogRepository oAuditlog = null; // /// // /// Global variable for connection string. // /// // private static string _connString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString; // /// // /// Default page size for reports grid. // /// // private static int _pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]); // /// // /// Absolute Path on server in which csv files are saved. // /// // private static string _csvExportPathOnServer = ConfigurationManager.AppSettings["csvExportPathOnServer"].ToString(); // //private static string _csvExportLocation = ConfigurationManager.AppSettings["csvExportPath"].ToString(); // /// // /// Absolute Path on local in which csv files are saved. // /// // private static string _exportLocation = ConfigurationManager.AppSettings["csvExportPath"].ToString(); // #endregion // /// // /// Show Audit log page with filter (Date). // /// GET: /AuditLog/ // /// // /// Audit Log View // [AuditRepository] // public ActionResult AuditLog() // { // return View(); // } // /// // /// This function fetch Audit Log Data from repository. // /// POST :// AuditLog/showAuditLog // /// // /// Start date e.g. 01 Jan 2014 // /// End date e.g. 31 Mar 2014 // /// Action result. // [HttpPost] // [AuditRepository] // public ActionResult ShowAuditLog(string startDate, string endDate) // { // try // { // oAuditlog = new AuditLogRepository(); // List model = oAuditlog.GetAuditDetailDateWise(Convert.ToDateTime(startDate), Convert.ToDateTime(endDate), _pageSize, 0); // // Stored data in viewbag for paging. // ViewBag.StartDate = startDate; // ViewBag.EndDate = endDate; // ViewBag.total = oAuditlog.GetCountAuditDetail(Convert.ToDateTime(startDate), Convert.ToDateTime(endDate)); // ViewBag.pageSize = _pageSize; // return PartialView(model); // } // catch (Exception ex) // { // throw ex; // } // } // /// // /// Returns page wise data to grid. // /// // /// Datasource // /// selected date // /// end date // /// Total numbers of records // /// Action Result // public ActionResult ShowAuditLogPager([DataSourceRequest]DataSourceRequest request, string startDate, string endDate, int total) // { // try // { // oAuditlog = new AuditLogRepository(); // List model = oAuditlog.GetAuditDetailDateWise(Convert.ToDateTime(startDate), Convert.ToDateTime(endDate), request.PageSize, request.PageSize * (request.Page - 1)); // DataSourceResult result = model.ToDataSourceResult(request); // result.Total = total; // result.Data = model; // return Json(result); // } // catch (Exception ex) // { // throw ex; // } // } // /// // /// Export Audit log report to Excel with dynamic column generation // /// // /// selected date // /// end date // /// true if excel exported, else false // [HttpPost] // [AuditRepository] // public string ExportXlsAuditLog(string startDate, string endDate) // { // try // { // oAuditlog = new AuditLogRepository(); // DataSet ds = oAuditlog.GetAuditDetailDataset(Convert.ToDateTime(startDate), Convert.ToDateTime(endDate)); // // Remove columns which are not required // ds.Tables[0].Columns.Remove("auditid"); // ds.Tables[0].Columns.Remove("sessionid"); // ds.Tables[0].Columns[0].ColumnName = "User Name"; // ds.Tables[0].Columns[1].ColumnName = "IP-Address"; // ds.Tables[0].Columns[2].ColumnName = "Url Accessed"; // ds.Tables[0].Columns[3].ColumnName = "Time Accessed"; // ds.Tables[0].Columns[4].ColumnName = "Controller Name"; // ds.Tables[0].Columns[5].ColumnName = "Method Name"; // ds.Tables[0].Columns[6].ColumnName = "Input Parameters"; // //==========================Excel Section==========================// // string fileName = "AuditLog_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xlsx"; // string SaveCsvAs = Server.MapPath(_csvExportPathOnServer + fileName); // bool isCreated = CreateExcelFile.CreateExcelDocument(ds, SaveCsvAs); // if (isCreated == true) { return _exportLocation + fileName; } // else { return "error"; } // //========================Excel Section end========================// // } // catch (Exception ex) // { // return "error"; // } // } // } //}