public void AddDocumentAnalytic(DocumentAnalyticEntity documentAnalyticEntity) { using (uow = new UnitOfWork.UnitOfWork()) { DocumentAnalytic loginAnalytic = new DocumentAnalytic(); loginAnalytic.Date = DateTime.Now.ToString(); loginAnalytic.IPAddress = documentAnalyticEntity.IPAddress; loginAnalytic.OS = documentAnalyticEntity.OS; loginAnalytic.Platform = documentAnalyticEntity.Platform; loginAnalytic.Username = documentAnalyticEntity.Username; loginAnalytic.Browser = documentAnalyticEntity.Browser; loginAnalytic.DocumentName = documentAnalyticEntity.DocumentName; uow.DocumentAnalyticRepository.Insert(loginAnalytic); uow.Save(); } }
protected void lstDocuments_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "DownloadDoc") { string filename = e.CommandArgument.ToString().Replace("Uploads/", ""); DocumentAnalyticEntity docEntity = new DocumentAnalyticEntity(); docEntity.IPAddress = GetLocalIPAddress(); docEntity.Username = Request.Cookies["Email"].Value; docEntity.OS = getOS(); System.Web.HttpBrowserCapabilities browser = Request.Browser; docEntity.Platform = browser.Platform; docEntity.Browser = browser.Browser; docEntity.DocumentName = filename; userDal.AddDocumentAnalytic(docEntity); Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename); Response.TransmitFile(Server.MapPath("~/" + e.CommandArgument)); Response.End(); } }