public JsonResult DeleteTemplate(String virtualPath) { bool retJsonBool = false; DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFileByVirtualPath(virtualPath) != null) { DCEOperations dceOps = new DCEOperations(); Guid fileID = dceOps.GetFileIDFromTemplateByVirtualPath(virtualPath); if (fileID != Guid.Empty) { dceOps.DeleteUploadedTemplateKeywords(fileID); dceOps.DeleteUploadedTemplates(virtualPath); docOps.DeleteFile(virtualPath); String physicalPath = UtilityOperations.GetServerMapPath(virtualPath); physicalPath = DecodePath(physicalPath); if (System.IO.File.Exists(physicalPath)) { System.IO.File.Delete(physicalPath); } retJsonBool = true; } } return(new JsonResult() { Data = retJsonBool }); }
public ActionResult EditUser(String userName) { MembershipUser user = Membership.GetUser(userName, true); UserEditModel userEditModel = new UserEditModel(); userEditModel.UserName = user.UserName; userEditModel.LastPasswordChangedDate = user.LastPasswordChangedDate; userEditModel.LastLoginDate = user.LastLoginDate; userEditModel.IsLockedOut = user.IsLockedOut; userEditModel.LastLockoutDate = user.LastLockoutDate; userEditModel.IsApproved = user.IsApproved; userEditModel.Email = user.Email; userEditModel.CreationDate = user.CreationDate; userEditModel.GetRolesForUser = Roles.GetRolesForUser(userName); userEditModel.Comment = user.Comment; AuthenticationsAndAuthorizationsOperations anaOPs = new AuthenticationsAndAuthorizationsOperations(); userEditModel.ExpiredDate = anaOPs.GetExpiryDate(userName); userEditModel.PhonePIN = anaOPs.getMobilPINByUserName(userName); DocumentsOperations documentsOperations = new DocumentsOperations(); userEditModel.PhoneAlias = anaOPs.GetMobileAliasByUserName(userName); return(View(userEditModel)); }
public void RecordFileDownload(String virtualPath, String userName) { DocumentsOperations docOps = new DocumentsOperations(); (new AuditTrailOperations()).InsertFilesDownloadAuditTrails(docOps.GetFileIDByVirtualPath(virtualPath), (new AuthenticationsAndAuthorizationsOperations()).GetUserIDByUserName(userName)); }
public ActionResult EditCommonFolder(CommonFolderAssignment cfa, String submit, String editCommonFolderKey, String editCommonFolderVal) { DocumentsOperations docOps = new DocumentsOperations(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); switch (submit) { case "Add": if (String.Equals(editCommonFolderKey.ToUpper(), "USER")) { docOps.InsertUsersFilesAuthorizations(aNaOps.GetUserIDByUserName(editCommonFolderVal), docOps.GetFileIDByVirtualPath(cfa.VirtualPath)); } else if (String.Equals(editCommonFolderKey.ToUpper(), "ROLE")) { docOps.InsertRolesFilesAuthorizations(aNaOps.GetRoleIDByRoleName(editCommonFolderVal), docOps.GetFileIDByVirtualPath(cfa.VirtualPath)); } break; case "Remove": if (String.Equals(editCommonFolderKey.ToUpper(), "USER")) { docOps.RemoveUsersFilesAuthorizations(aNaOps.GetUserIDByUserName(editCommonFolderVal), docOps.GetFileIDByVirtualPath(cfa.VirtualPath)); } else if (String.Equals(editCommonFolderKey.ToUpper(), "ROLE")) { docOps.RemoveRolesFilesAuthorizations(aNaOps.GetRoleIDByRoleName(editCommonFolderVal), docOps.GetFileIDByVirtualPath(cfa.VirtualPath)); } break; } return(RedirectToAction("EditCommonFolder", new { virtualPath = cfa.VirtualPath })); }
public JsonResult Upload(String virtualPath) { String jsonRet = ""; if (String.IsNullOrEmpty(virtualPath) || virtualPath == "/") { virtualPath = UtilityOperations.GetDockerRootPath(Server); } String userName = HttpContext.User.Identity.Name; foreach (String file in Request.Files) { var fileContent = Request.Files[file]; var fileNiceName = Request.Form["fileNiceName"]; var fileDesc = Request.Form["fileDesc"]; if (fileContent != null && fileContent.ContentLength > 0) { String filePath = Path.Combine(UtilityOperations.GetServerMapPath(virtualPath), Path.GetFileName(fileContent.FileName)); DocumentsOperations docOps = new DocumentsOperations(); //docOps.InsertFile(fileContent.FileName, virtualPath, fileNiceName, fileDesc); docOps.InsertFileEncodeFileName(fileContent.FileName, virtualPath + "/" + fileContent.FileName, fileNiceName, fileDesc, userName, false); fileContent.SaveAs(filePath); jsonRet = "Uploaded"; } } return(new JsonResult() { Data = jsonRet }); }
public ActionResult GetDocumentsDownloadedReportBySpecificUser(string userName) { if (!String.IsNullOrEmpty(userName)) { DocumentsOperations documentsOperations = new DocumentsOperations(); List<FilesDownloadAuditTrail> filesDownloadAuditTrails = documentsOperations.GetFilesDownloadedAuditTrailsBySpecificUser(userName); List<FilesDownloadAuditTrailViewModel> filesDownloadAuditTrailViewModeldata = new List<FilesDownloadAuditTrailViewModel>(); foreach (FilesDownloadAuditTrail item in filesDownloadAuditTrails) { FilesDownloadAuditTrailViewModel filesDownloadAuditTrailViewModel = new FilesDownloadAuditTrailViewModel(); filesDownloadAuditTrailViewModel.FileID = item.FileID; filesDownloadAuditTrailViewModel.NiceNameOrAreaName = item.File.NiceNameOrAreaName; filesDownloadAuditTrailViewModel.DateTimeDownloaded = item.DateTimeDownloaded; filesDownloadAuditTrailViewModeldata.Add(filesDownloadAuditTrailViewModel); } return View(new GridModel<FilesDownloadAuditTrailViewModel> { Total = filesDownloadAuditTrailViewModeldata.Count, Data = filesDownloadAuditTrailViewModeldata }); } else { List<FilesDownloadAuditTrailViewModel> filesDownloadAuditTrails = new List<FilesDownloadAuditTrailViewModel>(); return View(new GridModel<FilesDownloadAuditTrailViewModel> { Total = filesDownloadAuditTrails.Count, Data = filesDownloadAuditTrails }); } }
public ActionResult EditCommonFolder(String virtualPath) { DocumentsOperations docOps = new DocumentsOperations(); var file = docOps.GetFileByVirtualPath(virtualPath); CommonFolderAssignment cfa = new CommonFolderAssignment { FolderName = file.Name, CreatedAt = file.DateTimeUploaded.ToString(), VirtualPath = file.VirtualPath, UsersName = docOps.GetUsersNameByFileID(file.ID), RolesName = docOps.GetRolesNameByFileID(file.ID) }; MembershipUserCollection allUsers = Membership.GetAllUsers(); List <String> excludedUsers = new List <String>(); foreach (MembershipUser user in allUsers) { if (!cfa.UsersName.Contains(user.UserName)) { excludedUsers.Add(user.UserName); } } cfa.ExcludedUsers = excludedUsers; cfa.ExcludedRoles = Roles.GetAllRoles().Except(cfa.RolesName).ToList(); return(View(cfa)); }
public ActionResult GetTotalDocumentsDownloadedReport(string isLoad) { if (isLoad == "True") { DocumentsOperations documentsOperations = new DocumentsOperations(); List<FilesDownloadAuditTrail> filesDownloadAuditTrails = documentsOperations.GetTotalFilesDownloadedAuditTrails(); List<FilesDownloadAuditTrailViewModel> filesDownloadAuditTrailViewModeldata = new List<FilesDownloadAuditTrailViewModel>(); foreach (FilesDownloadAuditTrail item in filesDownloadAuditTrails) { FilesDownloadAuditTrailViewModel filesDownloadAuditTrailViewModel = new FilesDownloadAuditTrailViewModel(); filesDownloadAuditTrailViewModel.FileID = item.FileID; filesDownloadAuditTrailViewModel.NiceNameOrAreaName = item.File.NiceNameOrAreaName; filesDownloadAuditTrailViewModel.DateTimeDownloaded = item.DateTimeDownloaded; filesDownloadAuditTrailViewModeldata.Add(filesDownloadAuditTrailViewModel); } return View(new GridModel<FilesDownloadAuditTrailViewModel> { Total = filesDownloadAuditTrailViewModeldata.Count, Data = filesDownloadAuditTrailViewModeldata }); } else { List<FilesDownloadAuditTrailViewModel> filesDownloadAuditTrails = new List<FilesDownloadAuditTrailViewModel>(); return View(new GridModel<FilesDownloadAuditTrailViewModel> { Total = filesDownloadAuditTrails.Count, Data = filesDownloadAuditTrails }); } }
public ActionResult Review() { DocumentsOperations dops = new DocumentsOperations(); var myList = dops.GetReviewDocuments(User.Identity.Name); return(View(myList)); }
public ActionResult AllocateReviewer(string reviewer, int documentId, string permissionType) { DocumentsOperations dops = new DocumentsOperations(); try { if (permissionType == "Add") { dops.AllocateReviewerToDocument(documentId, reviewer); TempData["success_message"] = "Reviewer has been allocated to the document"; } else { dops.DeAllocateReviewerFromDocument(documentId, reviewer); TempData["success_message"] = "Reviewer was deallocated from the document"; } } catch (Exception ex) { TempData["error_message"] = ex.Message; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = reviewer + "Faliure allocating reviewer" } ); } return(RedirectToAction("Index", "Documents")); }
public JsonResult OCRThisFile(String virtualPath) { String physicalPath = UtilityOperations.DecodePath(UtilityOperations.GetServerMapPath(virtualPath), Server); SingleFileOCR singleFileOCR = new SingleFileOCR(physicalPath); String retVal = singleFileOCR.StartOCR(); if (!retVal.StartsWith("ERROR")) { DocumentsOperations docOps = new DocumentsOperations(); var file = docOps.GetFileByVirtualPath(virtualPath); String oriFileExt = (new System.IO.FileInfo(physicalPath)).Extension; String retFileExt = (new System.IO.FileInfo(retVal)).Extension; retFileExt = retVal.Substring(retVal.Length - (retFileExt.Length + 4)); docOps.InsertFileEncodeFileName(file.Name.Replace(oriFileExt, retFileExt), file.VirtualPath.Replace(oriFileExt, retFileExt), "", "OCR Performed @ " + DateTime.Now, HttpContext.User.Identity.Name, false); docOps.InsertFileBeenOCR(docOps.GetFileIDByVirtualPath(file.VirtualPath.Replace(oriFileExt, retFileExt)), docOps.IdentifyDocumentType(retVal)); return(new JsonResult() { Data = "" }); } return(new JsonResult() { Data = retVal }); }
public void DeleteFiles(string jlist) { System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); List<string> list = serializer.Deserialize<List<string>>(jlist); List<string> archives = new List<string>(); foreach (string path in list) { FileAttributes attr = System.IO.File.GetAttributes(path); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if (Directory.Exists(path)) { Directory.Delete(path, true); //delete folder and all subdirectories // return RedirectToAction("Repository", "Repository"); } } else { if (System.IO.File.Exists(path)) { string previousVirtualPath = UtilityOperations.GetVirtualPath(path);//.Replace("~/", "~//"); DocumentsOperations documentsOperations = new DocumentsOperations(); documentsOperations.DeleteFile(previousVirtualPath); System.IO.File.Delete(path); // return RedirectToAction("Repository", "Repository"); } } } //return View(); }
public static void LogDocumentsDownloaded(List<string> virtualPaths) { string userID = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); DocumentsOperations documentsOperations = new DocumentsOperations(); foreach (string path in virtualPaths) { Guid fileID = documentsOperations.GetFileIDByVirtualPath(path); documentsOperations.InsertFilesDownloadAuditTrails(fileID,new Guid(userID)); } }
public ActionResult DeleteUser_Controller(String userName) { DocumentsOperations docOps = new DocumentsOperations(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); docOps.RemoveUsersFilesAuthorizationsByUserName(aNaOps.GetUserIDByUserName(userName)); bool delUserStatus = Membership.DeleteUser(userName, true); return(RedirectToAction("ListUsers")); }
public JsonResult UploadTemplate() { String retJsonMsg = String.Empty; foreach (String file in Request.Files) { var fileContent = Request.Files[file]; var docType = Request.Form["DocType"]; var docDesc = Request.Form["DocDesc"]; var skipPages = Request.Form["SkipPages"]; List <int> pagesToSkill = new List <int>(); if (skipPages.Length > 0) { List <String> skippages = skipPages.Split(',').ToList(); foreach (String skip in skippages) { int number; bool retInt = int.TryParse(skip, out number); if (retInt) { pagesToSkill.Add(number); } else { retJsonMsg = "ERROR - Skip page value [" + skip + "] is not a number!"; break; } } } if (fileContent != null && fileContent.ContentLength > 0 && String.IsNullOrEmpty(retJsonMsg)) { String virtualPath = UtilityOperations.GetDCEDockerRootPath(); String physicalPath = DecodePath(Path.Combine(UtilityOperations.GetServerMapPath(virtualPath), Path.GetFileName(fileContent.FileName))); String userName = HttpContext.User.Identity.Name; DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFileByVirtualPath(virtualPath + "/" + fileContent.FileName) == null) { System.IO.Directory.CreateDirectory(UtilityOperations.GetServerMapPath(virtualPath)); fileContent.SaveAs(physicalPath); docOps.InsertFileEncodeFileName(fileContent.FileName, virtualPath + "/" + fileContent.FileName, "_DCEDockerFile", docDesc, userName, false); DCEOperations dceOps = new DCEOperations(); dceOps.InsertTemplate(virtualPath + "/" + fileContent.FileName, docType, docDesc, userName); List <String> retStrArr = GetPDFContents(physicalPath, pagesToSkill); dceOps.InsertOCRContents(fileContent.FileName, retStrArr[0], retStrArr[1]); } else { retJsonMsg = "ERROR - The file already eixsts."; } } } return(new JsonResult() { Data = retJsonMsg }); }
public JsonResult GetFileTags(String virtualPath) { DocumentsOperations docOps = new DocumentsOperations(); List <TagsOnFile> tags = docOps.GetTagsByFileID(docOps.GetFileIDByVirtualPath(virtualPath)); List <TagsMetadata> jsonTags = new List <TagsMetadata>(); foreach (TagsOnFile tag in tags) { jsonTags.Add(new TagsMetadata { TagName = tag.TagName, LastModified = tag.LastModifiedDateTime.ToString() }); } return(Json(new { Total = jsonTags.Count, Data = jsonTags })); }
public ActionResult DeleteRole(String roleName) { String[] usersInRole = Roles.GetUsersInRole(roleName); if (usersInRole.Count() > 0) { Roles.RemoveUsersFromRole(usersInRole, roleName); } DocumentsOperations docOps = new DocumentsOperations(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); docOps.RemoveRolesFilesAuthorizationsByRoleID(aNaOps.GetRoleIDByRoleName(roleName)); var delRoleStatus = Roles.DeleteRole(roleName, false); return(RedirectToAction("ListRoles")); }
public JsonResult CreateNewFolder(string path, String foldername) { string decodedPath = DecodePath(path); String folderPath = Path.Combine(decodedPath, foldername); if (folderPath != "\\") if (!Directory.Exists(folderPath)) { DocumentsOperations documentsOperations = new DocumentsOperations(); string virtualPath = UtilityOperations.GetVirtualPath(folderPath); documentsOperations.InsertFile(foldername, virtualPath, "", ""); Directory.CreateDirectory(folderPath); } else folderPath = ""; return new JsonResult() { Data = decodedPath }; }
public ActionResult GenerateKeywords(TemplateKeywords templateKeywords, String virtualPath, String inputKeyword, String templateDocType, String submit) { DCEOperations dceOps = new DCEOperations(); DCE_Templates template = dceOps.GetTemplateByVirtualPath(virtualPath); if (template != null) { templateKeywords.Template = GenerateUploadedTemplates(template); templateKeywords.SkipPages = template.SkipPages; } templateKeywords.TemplateOCRContent = template.DocumentOCRContent; switch (submit) { case "System Generation": templateKeywords.GeneratedBySystem = true; List <InputtedKeyword> arr = dceOps.GetKeywordsGeneratedBySystem(templateKeywords.Template); templateKeywords.Keywords = dceOps.GetKeywordsGeneratedBySystem(templateKeywords.Template); break; case "Keyword Checking": if (inputKeyword.Trim() == "") { ViewData["GenerateKeywordsReturnMsg"] = "Input Keyword is empty ..."; } else { templateKeywords.GeneratedBySystem = true; templateKeywords.Keywords = dceOps.GetKeywordByInput(templateKeywords.Template, inputKeyword); } break; case "Added Keywords": return(RedirectToAction("GenerateKeywords", new { virtualPath = virtualPath })); case "Update": DocumentsOperations docOps = new DocumentsOperations(); docOps.RenameDocumentTypeByVirtualPath(templateKeywords.Template.VirtualPath, templateDocType); templateKeywords.Template.DocumentType = templateDocType; break; default: templateKeywords.GeneratedBySystem = false; templateKeywords.Keywords = GetKeywordsByVirtualPath(virtualPath); break; } return(View(templateKeywords)); }
public ActionResult SearchFile(String searchValue, String virtualPath) { FileModel fileModel = new FileModel(virtualPath, ""); fileModel.IsRootDir = true; fileModel.IsSearchResult = true; String userName = HttpContext.User.Identity.Name; DocumentsOperations docOps = new DocumentsOperations(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); if (aNaOps.IsSystemAdministratorUser(userName) || aNaOps.IsDMSAdministratorUser(userName)) { userName = null; } String[] usersPath = docOps.GetAllUsersFolderInArray(UtilityOperations.GetDockerRootPath() + "/"); List <FileModel> searchCurrentResult = new List <FileModel>(); List <FileModel> searchCommonResult = new List <FileModel>(); foreach (String vPath in docOps.GetVirtualPathsBySearchValue(searchValue, userName)) { FileModel file = null; if (vPath.StartsWith(UtilityOperations.GetDockerCommonFolderPath())) { file = (new FileModel()).GetFolderOrFile(vPath); file.IsCommonFolder = true; if (usersPath.Contains(file.VirtualPath)) { file.IsUserFolder = true; } searchCommonResult.Add(file); } else if (vPath.StartsWith(virtualPath) && !String.Equals(vPath, virtualPath)) { file = (new FileModel()).GetFolderOrFile(vPath); if (usersPath.Contains(file.VirtualPath)) { file.IsUserFolder = true; } searchCurrentResult.Add(file); } } fileModel.CurrentFolderFiles = searchCurrentResult; fileModel.CommonFolderFiles = searchCommonResult; fileModel.Tags = new List <String>(); return(View(fileModel)); }
public JsonResult InsertFileTags(IEnumerable <String> tags, String virtualPath) { DocumentsOperations docOps = new DocumentsOperations(); if (tags != null && tags.Count() > 0) { docOps.InsertTagsByFileID(docOps.GetFileIDByVirtualPath(virtualPath), tags); } else { docOps.DeleteTagsByFileID(docOps.GetFileIDByVirtualPath(virtualPath)); } return(new JsonResult() { Data = "" }); }
public ActionResult CommonFolderMgt(CommonFolderManagement cfm, String submit, String tableSelectedFolder) { DocumentsOperations docOps = new DocumentsOperations(); String virtualPath = "", physicalPath = "", folderPath = ""; switch (submit) { case "Create": virtualPath = UtilityOperations.GetDockerCommonFolderPath(); physicalPath = UtilityOperations.GetServerMapPath(virtualPath); folderPath = Path.Combine(UtilityOperations.DecodePath(physicalPath, Server), cfm.FolderName); if (folderPath != "\\") { if (!Directory.Exists(folderPath)) { docOps.InsertNewFolder(virtualPath, folderPath, HttpContext.User.Identity.Name, cfm.FolderName); } else { TempData["CommonFolderMgtErrorMsg"] = "Warning - Folder already existed."; } } break; case "Edit": return(RedirectToAction("EditCommonFolder", new { virtualPath = tableSelectedFolder })); case "Delete": physicalPath = UtilityOperations.DecodePath(UtilityOperations.GetServerMapPath(tableSelectedFolder), Server); FileAttributes attr = System.IO.File.GetAttributes(physicalPath); if (Directory.Exists(physicalPath)) { if (docOps.GetFilesStartsWithVirtualPath(tableSelectedFolder) != null) { docOps.DeleteFile(tableSelectedFolder); } Directory.Delete(physicalPath, true); } else { TempData["CommonFolderMgtErrorMsg"] = "Warning - Folder not exist in the system."; } break; } return(RedirectToAction("CommonFolderMgt")); }
public ActionResult Index() { DashboardViewModel dvModel = new DashboardViewModel(); DCEOperations dceOps = new DCEOperations(); dvModel.CountTotalTemplates = dceOps.GetTotalTemplatesCount(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); dvModel.CountTotalWorkers = aNaOps.GetTotalUsersCount(); dvModel.CountTotalRoles = aNaOps.GetTotalRolesCount(); DocumentsOperations docOps = new DocumentsOperations(); dvModel.CountTotalDocuments = docOps.GetTotalFilesAndFolders(); return(View(dvModel)); }
private FileModel FilterAccessibleFolderAndFiles(String virtualPath, String userName) { FileModel fileModel = null; AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); DocumentsOperations docOps = new DocumentsOperations(); FileModel commonFileModel = new FileModel(UtilityOperations.GetDockerCommonFolderPath(), ""); if (!aNaOps.IsSystemAdministratorUser(userName) && !aNaOps.IsDMSAdministratorUser(userName)) { fileModel = new FileModel(virtualPath, "/" + userName); List <String> dbFilesVPath = docOps.GetFilesByUserName(userName).Select(file => file.VirtualPath).ToList(); if (fileModel.IsRootDir) { fileModel.CommonFolderFiles = commonFileModel.CurrentFolderFiles.Where(file => dbFilesVPath.Contains(file.VirtualPath)).ToList(); } else { fileModel.CommonFolderFiles = new List <FileModel>(); } fileModel.Tags = docOps.GetAllTagsByUserId(aNaOps.GetUserIDByUserName(userName)); } else { fileModel = new FileModel(virtualPath, ""); String[] usersPath = docOps.GetAllUsersFolderInArray(UtilityOperations.GetDockerRootPath() + "/"); foreach (FileModel file in fileModel.CurrentFolderFiles) { if (usersPath.Contains(file.VirtualPath)) { file.IsUserFolder = true; } } if (fileModel.IsRootDir) { fileModel.CommonFolderFiles = commonFileModel.CurrentFolderFiles; } else { fileModel.CommonFolderFiles = new List <FileModel>(); } fileModel.Tags = docOps.GetAllTagsByUserId(aNaOps.GetUserIDByUserName(userName)); } return(fileModel); }
public JsonResult ListUsers(String userName) { MembershipUserCollection users = Membership.GetAllUsers(); List <ListUsersViewModel> listRoles = new List <ListUsersViewModel>(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); DocumentsOperations documentsOperations = new DocumentsOperations(); foreach (MembershipUser user in users) { listRoles.Add(new ListUsersViewModel { UserName = user.UserName, MobileAlias = aNaOps.GetMobileAliasByUserName(user.UserName), Email = user.Email, LastActivityDate = (user.LastActivityDate).ToString(dateTimeFormat), ExpiredDate = (aNaOps.GetExpiryDate(user.UserName)).ToString(dateTimeFormat) }); } return(Json(new { Total = listRoles.Count, Data = listRoles })); }
public ActionResult Register(RegisterModel registerModel) { if (ModelState.IsValid) { MembershipCreateStatus createStatus; Membership.CreateUser(registerModel.UserName, registerModel.Password, registerModel.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { DocumentsOperations docOps = new DocumentsOperations(); docOps.InsertNewUserFolder(Server, registerModel.UserName); TempData["RegisterSuccess"] = "Created user successful!"; } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } return(View(registerModel)); }
public ActionResult CommonFolderMgt() { CommonFolderManagement cfm = new CommonFolderManagement(); List <CommonFolderAssignment> cfaList = new List <CommonFolderAssignment>(); DocumentsOperations docOps = new DocumentsOperations(); foreach (var item in docOps.GetFilesStartsWithVirtualPath(UtilityOperations.GetDockerCommonFolderPath())) { cfaList.Add(new CommonFolderAssignment { FolderName = item.Name, CreatedAt = item.DateTimeUploaded.ToString(), VirtualPath = item.VirtualPath, UsersName = docOps.GetUsersNameByFileID(item.ID), RolesName = docOps.GetRolesNameByFileID(item.ID) }); } cfm.CommonFolderAssignment = cfaList; return(View(cfm)); }
public JsonResult DeleteFile(String virtualPath) { bool retJsonBool = false; if (virtualPath.Length > 1) { String physicalPath = UtilityOperations.GetServerMapPath(virtualPath); physicalPath = UtilityOperations.DecodePath(physicalPath, Server); FileAttributes attr = System.IO.File.GetAttributes(physicalPath); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if (Directory.Exists(physicalPath)) { DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFilesStartsWithVirtualPath(virtualPath) != null) { docOps.DeleteFile(virtualPath); } Directory.Delete(physicalPath, true); retJsonBool = true; } } else { if (System.IO.File.Exists(physicalPath)) { DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFileByVirtualPath(virtualPath) != null) { docOps.DeleteFile(virtualPath); } System.IO.File.Delete(physicalPath); retJsonBool = true; } } } return(new JsonResult() { Data = retJsonBool }); }
public ActionResult SearchTags(String virtualPath, String tagName) { FileModel fileModel = new FileModel(virtualPath, ""); fileModel.IsRootDir = true; fileModel.IsSearchResult = true; DocumentsOperations docOps = new DocumentsOperations(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); String[] usersPath = docOps.GetAllUsersFolderInArray(UtilityOperations.GetDockerRootPath() + "/"); List <FileModel> searchCurrentResult = new List <FileModel>(); List <FileModel> searchCommonResult = new List <FileModel>(); foreach (String vPath in docOps.GetVirtualPathsByTagName(aNaOps.GetUserIDByUserName(HttpContext.User.Identity.Name), tagName)) { FileModel file = null; if (vPath.StartsWith(UtilityOperations.GetDockerCommonFolderPath())) { file = (new FileModel()).GetFolderOrFile(vPath); file.IsCommonFolder = true; if (usersPath.Contains(file.VirtualPath)) { file.IsUserFolder = true; } searchCommonResult.Add(file); } else { file = (new FileModel()).GetFolderOrFile(vPath); if (usersPath.Contains(file.VirtualPath)) { file.IsUserFolder = true; } searchCurrentResult.Add(file); } } fileModel.CurrentFolderFiles = searchCurrentResult; fileModel.CommonFolderFiles = searchCommonResult; fileModel.Tags = new List <String>(); return(View(fileModel)); }
public ActionResult SelectFiles(string filePath) { string userName = Membership.GetUser().UserName; DocumentsOperations documentsOperations = new DocumentsOperations(); IList<OOTS.Models.File> databasefiles = documentsOperations.GetFilesByUserName(userName); //return View(new GridModel<OOTS.Models.File> //{ // Total = files.Count, // Data = files //}); string rootpath = UtilityOperations.GetOOTSRootPath(Server); IList<FileModel> files = FileModel.GetFiles(filePath == "" || filePath == "/" ? rootpath : filePath); IList<FileModel> authorizedFiles = documentsOperations.FilterBasedOnAuthorizationsAndPopulateNiceNameAndDescription(files, databasefiles); return View(new GridModel<FileModel> { Total = authorizedFiles.Count, Data = authorizedFiles }); }
public JsonResult Rename() { var virtualPath = Request.Form["virtualPath"]; var newName = Request.Form["newName"]; var oldName = Request.Form["oldName"]; String decodePath = UtilityOperations.DecodePath(UtilityOperations.GetServerMapPath(virtualPath), Server); String newDecodePath = decodePath.Replace(oldName, newName); String retJsonMsg = ""; FileAttributes attr = System.IO.File.GetAttributes(decodePath); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if (System.IO.Directory.Exists(decodePath)) { System.IO.Directory.Move(decodePath, decodePath.Replace(oldName, newName)); retJsonMsg += " DirRenamed"; } } else { if (System.IO.File.Exists(decodePath)) { System.IO.File.Move(decodePath, decodePath.Replace(oldName, newName)); retJsonMsg += " FileRenamed"; } } DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFileByVirtualPath(virtualPath) != null) { docOps.RenameFile(newName, virtualPath, virtualPath.Replace(oldName, newName)); retJsonMsg += " DBRenamed"; } return(new JsonResult() { Data = retJsonMsg }); }
public JsonResult CreateNewFolder(String virtualPath, String userName, String folderName) { String physicalPath = UtilityOperations.GetServerMapPath(virtualPath); String decodePath = UtilityOperations.DecodePath(physicalPath, Server); String folderPath = Path.Combine(decodePath, folderName); String retJsonMsg = ""; if (folderPath != "\\") { if (!Directory.Exists(folderPath)) { DocumentsOperations docOps = new DocumentsOperations(); docOps.InsertNewFolder(virtualPath, folderPath, userName, folderName); } else { retJsonMsg += "Folder name already exists. Please enter a different folder name"; } } return(new JsonResult() { Data = retJsonMsg }); }
private void AssignRoleAccessToFileOrFolder(string roleID, string path) { DocumentsOperations documentsOperations = new DocumentsOperations(); string virtualPath = UtilityOperations.GetVirtualPath(path); Guid fileID = documentsOperations.GetFileIDByVirtualPath(virtualPath); documentsOperations.InsertRolesFilesAuthorizations(new Guid(roleID), fileID); }
public ActionResult Upload(string path, FormCollection collection) { if (string.IsNullOrEmpty(path) || path == "/") path = UtilityOperations.GetOOTSRootPath(Server); string niceName = collection["txtNiceName"]; string description = collection["txtDescription"]; foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[inputTagName]; if (file.ContentLength > 0) { string filePath = Path.Combine(path , Path.GetFileName(file.FileName)); DocumentsOperations documentsOperations = new DocumentsOperations(); string virtualPath = UtilityOperations.GetVirtualPath(filePath); documentsOperations.InsertFile(file.FileName, virtualPath, niceName, description); file.SaveAs(filePath); return RedirectToAction("Repository", "Repository"); } } return View(); }
public void Rename(string jlist, string path, string newname) { string decodedPath = DecodePath(path); System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); List<string> list = serializer.Deserialize<List<string>>(jlist); string itempath = list[0]; FileAttributes attr = System.IO.File.GetAttributes(itempath); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if (Directory.Exists(itempath)) { Directory.Move(itempath, Path.Combine( decodedPath , newname)); } } else { if (System.IO.File.Exists(itempath)) { string newItemPath = Path.Combine(decodedPath, newname); string previousVirtualPath = UtilityOperations.GetVirtualPath(itempath);//.Replace("~/", "~//"); ; string newVirtualPath = UtilityOperations.GetVirtualPath(newItemPath); DocumentsOperations documentsOperations = new DocumentsOperations(); documentsOperations.RenameFile(newname, previousVirtualPath, newVirtualPath); System.IO.File.Move(itempath, newItemPath); } } }
public ActionResult SelectFiles(string filePath) { string rootpath = UtilityOperations.GetOOTSRootPath(Server); IList<FileModel> files = FileModel.GetFiles(filePath == "" || filePath == "/" ? rootpath : filePath); DocumentsOperations documentsOperations = new DocumentsOperations(); documentsOperations.PopulateNiceNameAndDescription(files); return View(new GridModel<FileModel> { Total = files.Count, Data = files }); }
public ActionResult Comment(string document, Comment c) { if (document != null) { if (c.Comment1 != null) { int documentIdToFind = 0; try { documentIdToFind = Convert.ToInt32(new Encryption().DecryptString(document, User.Identity.Name)); } catch (FormatException fe) { TempData["error_message"] = "Document does not exist"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = fe.Message, Time = DateTime.Now, Message = "User tried to manually search for a document in the address bar" } ); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["error_message"] = "Document unavailable"; new LogsOperations().AddLog( new Log() { Controller = "Comment", Exception = ex.Message, Time = DateTime.Now, Message = "documentId decryption error" } ); return(RedirectToAction("Index")); } DocumentsOperations dops = new DocumentsOperations(); if (dops.DoesDocumentExist(documentIdToFind)) { try { Document d = dops.GetDocument(documentIdToFind); if (dops.IsReviewerAllocatedToDocument(User.Identity.Name, documentIdToFind)) { ViewData["document_id"] = new Encryption().EncryptString(d.Id.ToString(), User.Identity.Name); try { dops.AddComment(d, c, User.Identity.Name); ModelState.Clear(); } catch (Exception ex) { ViewData["error_message"] = ex.Message; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = "Adding comment exception" } ); return(RedirectToAction("Review")); } return(View()); } else { TempData["error_message"] = "You are not a reviewer of this document"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "User is not document's reviewer", Time = DateTime.Now, Message = "User is not document's reviewer" } ); return(RedirectToAction("Review")); } } catch (DocumentExistsException ex) { TempData["error_message"] = ex.Message; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = ex.Message } ); return(RedirectToAction("Review")); } catch (Exception ex) { TempData["error_message"] = ex.Message; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = "Error checking reviewing permissions" } ); return(RedirectToAction("Review")); } } else { TempData["error_message"] = "Document does not exist"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Document does not exist", Time = DateTime.Now, Message = "Document does not exist" } ); return(RedirectToAction("Review")); } } else { TempData["error_message"] = "Comment cannot be empty"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "No comment entered", Time = DateTime.Now, Message = "No comment entered" } ); return(RedirectToAction("Review")); } } else { TempData["error_message"] = "No document selected"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "No document selected", Time = DateTime.Now, Message = "No document selected" } ); return(RedirectToAction("Review")); } //DocumentsOperations dops = new DocumentsOperations(); //Document d = dops.GetDocument(document); //ViewData["document_id"] = d.Id; //try //{ // dops.AddComment(d, c, User.Identity.Name); // ModelState.Clear(); //} //catch (Exception ex) //{ // ViewData["error_message"] = ex.Message; // new LogsOperations().AddLog( // new Log() // { // Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), // Exception = ex.Message, // Time = DateTime.Now, // Message = "Adding comment exception" // } // ); //} //return View(); }
public void AssignTheSelectedFilesToTheSelectedRole(string jlist, string roleName) { List<string> list = null; list = UtilityOperations.StringToList(jlist, list); DocumentsOperations documentsOperations = new DocumentsOperations(); Guid roleID = documentsOperations.GetRoleIDByRoleName(roleName); foreach (string path in list) { AssignRoleAccessToFileOrFolder(roleID.ToString(), path); AssignRoleAccessToParentFolders(roleID.ToString(), path); AssignRoleAccessToChildFilesorFolders(roleID.ToString(), path); } }
public ActionResult Comment(string documentId) { if (documentId != null) { int documentIdToFind = 0; try { documentIdToFind = Convert.ToInt32(new Encryption().DecryptString(documentId, User.Identity.Name)); } catch (FormatException fe) { TempData["error_message"] = "Document does not exist"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = fe.Message, Time = DateTime.Now, Message = "User tried to manually search for a document in the address bar" } ); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["error_message"] = "Document unavailable"; new LogsOperations().AddLog( new Log() { Controller = "Comment", Exception = ex.Message, Time = DateTime.Now, Message = "documentId decryption error" } ); return(RedirectToAction("Index")); } DocumentsOperations dops = new DocumentsOperations(); if (dops.DoesDocumentExist(documentIdToFind)) { try { Document d = dops.GetDocument(documentIdToFind); if (dops.IsReviewerAllocatedToDocument(User.Identity.Name, documentIdToFind) || d.Username_fk == User.Identity.Name) { ViewData["document_title"] = d.Title; ViewData["document_id"] = new Encryption().EncryptString(d.Id.ToString(), User.Identity.Name); return(View()); } else { TempData["error_message"] = "You are not a reviewer of this document"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "User is not document's reviewer", Time = DateTime.Now, Message = "User is not document's reviewer" } ); return(RedirectToAction("Index")); } } catch (DocumentExistsException ex) { TempData["error_message"] = ex.Message; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = ex.Message } ); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["error_message"] = ex.Message; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = "Error checking reviewing permissions" } ); return(RedirectToAction("Index")); } } else { TempData["error_message"] = "Document does not exist"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Document does not exist", Time = DateTime.Now, Message = "Document does not exist" } ); return(RedirectToAction("Index")); } } else { TempData["error_message"] = "No document selected"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "No document selected", Time = DateTime.Now, Message = "No document selected" } ); return(RedirectToAction("Index")); } }
public ActionResult Add(Document d, HttpPostedFileBase filePath) { DocumentsOperations dops = new DocumentsOperations(); try { if (filePath != null) { if (Path.GetExtension(filePath.FileName).ToLower().Equals(".docx")) { if (filePath.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") { byte[] whitelist = new byte[] { 80, 75, 3, 4, 20, 0, 6, 0 }; byte[] inputRead = new byte[8]; filePath.InputStream.Read(inputRead, 0, 8); bool flag = true; for (int i = 0; i < 8; i++) { if (whitelist[i] != inputRead[i]) { flag = false; break; } } if (flag == true) { if (filePath.ContentLength <= (1048576 * 5)) { string absolutePath = Server.MapPath("\\UploadedDocuments\\"); string relativePath = "\\UploadedDocuments\\"; string fileName = Guid.NewGuid().ToString() + Path.GetExtension(filePath.FileName); d.FilePath = relativePath + fileName; // saves path to the image in the database filePath.InputStream.Position = 0; Stream s = new Encryption().HybridEncryptFile(filePath.InputStream, User.Identity.Name, new UsersOperations().GetUser(User.Identity.Name).PublicKey); s.Position = 0; FileStream fs = new FileStream(absolutePath + fileName, FileMode.CreateNew, FileAccess.Write); s.CopyTo(fs); fs.Close(); s.Position = 0; d.Signature = new Encryption().DigitalSign(s, new UsersOperations().GetUser(User.Identity.Name).PrivateKey); dops.AddDocument(User.Identity.Name, d); ViewData["success_message"] = "Document uploaded successfully"; ModelState.Clear(); } else { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Very large document", Time = DateTime.Now, Message = "Very large document" } ); ViewData["message"] = "The document must be smaller than 5MB"; } } else { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "The header values were not of a Word Document", Time = DateTime.Now, Message = "Not a word document" } ); ViewData["message"] = "This is not a valid .docx file"; } } else { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Content Type was not of a Word Document", Time = DateTime.Now, Message = "Not a word document" } ); ViewData["message"] = "This is not a valid .docx file"; } } else { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "File did not end with .docx", Time = DateTime.Now, Message = "Not a .docx file" } ); ViewData["message"] = "This file is not a document"; } } else { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "No document was selected to be uploaded", Time = DateTime.Now, Message = "No document" } ); ViewData["message"] = "Please select a document"; } } catch (DocumentExistsException de) { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = de.Message, Time = DateTime.Now, Message = de.Message } ); ViewData["error_message"] = de.Message; }catch (Exception ex) { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = "Unable to add document" } ); ViewData["error_message"] = "Unable to add document"; } return(View()); }
public ActionResult LogUserLogin(string returnUrl) { string userID = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); DocumentsOperations documentsOperations = new DocumentsOperations(); documentsOperations.InsertUserLoginAuditTrails(new Guid(userID)); return RedirectUserAfterLogin(returnUrl); }
public ActionResult GetUserActivityReportForASpecificUser(String userName) { if (!String.IsNullOrEmpty(userName)) { DocumentsOperations documentsOperations = new DocumentsOperations(); List<UserLoginAuditTrail> userActivityAuditTrails = documentsOperations.GetUserActivityAuditTrailsBySpecificUser(userName); List<UserLoginAuditTrailViewModel> UserLoginAuditTrailViewModeldata = new List<UserLoginAuditTrailViewModel>(); foreach (UserLoginAuditTrail item in userActivityAuditTrails) { UserLoginAuditTrailViewModel userLoginAuditTrailViewModelentry = new UserLoginAuditTrailViewModel(); userLoginAuditTrailViewModelentry.UserName = item.aspnet_Users.UserName; userLoginAuditTrailViewModelentry.DateTimeLogged = item.DateTimeLogged; UserLoginAuditTrailViewModeldata.Add(userLoginAuditTrailViewModelentry); } return View(new GridModel<UserLoginAuditTrailViewModel> { Total = UserLoginAuditTrailViewModeldata.Count, Data = UserLoginAuditTrailViewModeldata }); } else { List<UserLoginAuditTrailViewModel> UserLoginAuditTrailViewModeldata = new List<UserLoginAuditTrailViewModel>(); return View(new GridModel<UserLoginAuditTrailViewModel> { Total = UserLoginAuditTrailViewModeldata.Count, Data = UserLoginAuditTrailViewModeldata }); } }
public ActionResult DownloadFile(string documentId) { if (documentId != null) { int decryptedDocumentId = 0; try { decryptedDocumentId = Convert.ToInt32(new Encryption().DecryptString(documentId, User.Identity.Name)); } catch (FormatException fe) { TempData["error_message"] = "Document does not exist"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = fe.Message, Time = DateTime.Now, Message = "User tried to manually search for a document in the address bar" } ); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["error_message"] = "Document unavailable"; new LogsOperations().AddLog( new Log() { Controller = "Comment", Exception = ex.Message, Time = DateTime.Now, Message = "documentId decryption error" } ); return(RedirectToAction("Index")); } DocumentsOperations dops = new DocumentsOperations(); if (dops.DoesDocumentExist(decryptedDocumentId)) { try { Document d = dops.GetDocument(decryptedDocumentId); if (dops.IsReviewerAllocatedToDocument(User.Identity.Name, decryptedDocumentId)) { string absolutePath = Server.MapPath(d.FilePath); if (System.IO.File.Exists(absolutePath) == true) { FileStream fs = System.IO.File.OpenRead(absolutePath); MemoryStream ms = new MemoryStream(); fs.CopyTo(ms); ms.Position = 0; try { if (new Encryption().DigitalVerify(ms, new UsersOperations().GetUser(d.Username_fk).PublicKey, new DocumentsOperations().GetDocument(decryptedDocumentId).Signature)) { MemoryStream msOut = new MemoryStream(new Encryption().HybridDecryptFile(ms, new UsersOperations().GetUser(d.Username_fk).PrivateKey)); msOut.Position = 0; return(File(msOut.ToArray(), System.Net.Mime.MediaTypeNames.Application.Octet, d.FilePath)); } else { TempData["error_message"] = "Unable to verify document"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Unable to verify document", Time = DateTime.Now, Message = "Unable to verify document" } ); return(RedirectToAction("Index")); } } catch (Exception ex) { TempData["error_message"] = "Unable to verify document"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Unable to verify document", Time = DateTime.Now, Message = "Unable to verify document" } ); return(RedirectToAction("Index")); } } else { TempData["error_message"] = "Document does not exist"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Document does not exist", Time = DateTime.Now, Message = "Document does not exist" } ); return(RedirectToAction("Index")); } } else { TempData["error_message"] = "You are not a reviewer of this document"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "User is not document's reviewer", Time = DateTime.Now, Message = "User is not document's reviewer" } ); return(RedirectToAction("Index")); } } catch (DocumentExistsException ex) { TempData["error_message"] = ex.Message; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = ex.Message } ); return(RedirectToAction("Index")); } catch (Exception ex) { TempData["error_message"] = "Unable to download document"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = ex.Message, Time = DateTime.Now, Message = "Unable to download document" } ); return(RedirectToAction("Index")); } } else { new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "Document does not exist", Time = DateTime.Now, Message = "Document does not exist" } ); return(RedirectToAction("Index")); } } else { TempData["error_message"] = "No document selected"; new LogsOperations().AddLog( new Log() { Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(), Exception = "No document selected", Time = DateTime.Now, Message = "No document selected" } ); return(RedirectToAction("Index")); } }