public void Delete(Audit item) { using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository<Audit>(); rep.Delete(item); } }
protected void lbnOK_Click(object sender, EventArgs e) { try { //check file type first //if (fileUpload.HasFile) //{ // string strAllowedFiles = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("FileExtensions"); // string[] strSearchPatterns = strAllowedFiles.Split(','); // string uploadType = fileUpload.PostedFile.FileName.Substring(fileUpload.PostedFile.FileName.LastIndexOf('.')+1); // if (!strAllowedFiles.Contains(uploadType)) // { // DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "File type not allowed", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError); // return; // } //} //create file DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController(); DNNQuickApps.Modules.QuickDocsPro.File objFile = new DNNQuickApps.Modules.QuickDocsPro.File(); //if (!Convert.ToBoolean(Settings["IsSearchable"].ToString())) //{ // objFile.ModuleID = ModuleId; //} objFile.PortalID = PortalId; objFile.CreatedByUserID = UserId; objFile.CreatedDate = System.DateTime.Now; objFile.LastModifiedDate = System.DateTime.Now; objFile.LastModifiedByUserID = UserId; objFile.VersionsToKeep = -1; objFile.VersionNumber = 1; //check files type (shared, user, groups) String strFilesModuleType = Settings["FilesMode"].ToString(); if (strFilesModuleType == "UserFiles" || strFilesModuleType == "GroupFiles") { if (strFilesModuleType == "UserFiles") { //get UserID parameter if (this.Request.QueryString["UserID"] != null) { _userIDParameter = Convert.ToInt32(this.Request.QueryString["UserID"]); } objFile.HomeFolderUserID = _userIDParameter; } else //group files { //get UserID parameter if (this.Request.QueryString["GroupID"] != null) { _roleIDParameter = Convert.ToInt32(this.Request.QueryString["GroupID"]); } objFile.RoleID = _roleIDParameter; } } if (UserId != -1) { objFile.CreatedByUserName = UserInfo.DisplayName; objFile.LastModifiedByUserName = UserInfo.DisplayName; } else { objFile.CreatedByUserName = "******"; objFile.LastModifiedByUserName = "******"; } //create file or folder if (this.Request.QueryString["Type"] != null) { ItemType = Convert.ToInt32(this.Request.QueryString["Type"]); } if (ItemType == 1)//File { //check file exists if (asyncFileUpload.UploadedFiles.Count == 0) { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Please select a valid file to upload", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError); return; } objFile.Name = "File Upload"; objFile.ItemType = 1; } else if (ItemType == 0) //folder { objFile.Name = txtName.Text; objFile.ItemType = 0; objFile.IsFolder = true; } else if (ItemType == 2) //Hyperlink { objFile.Name = txtName.Text; objFile.ItemType = 2; objFile.LinkURL = txtHyperlink.Text; } else { Response.Redirect(Globals.NavigateURL(), true); } if (this.Request.QueryString["Parent"] != null) { ParentID = Int32.Parse(this.Request.QueryString["Parent"]); } objFile.ParentID = ParentID; objFile.Description = ""; //create file objQuickFiles.Create(objFile); if (ItemType == 1) //file { //create file version and copy attributes from current version DNNQuickApps.Modules.QuickDocsPro.File objVersionFile = new DNNQuickApps.Modules.QuickDocsPro.File(); //if (!Convert.ToBoolean(Settings["IsSearchable"].ToString())) //{ // objVersionFile.ModuleID = ModuleId; //} objVersionFile.PortalID = PortalId; objVersionFile.CreatedByUserID = objFile.CreatedByUserID; objVersionFile.CreatedDate = objFile.LastModifiedDate; objVersionFile.CreatedByUserName = objFile.CreatedByUserName; objVersionFile.LastModifiedDate = objFile.LastModifiedDate; objVersionFile.LastModifiedByUserID = objFile.LastModifiedByUserID; objVersionFile.LastModifiedByUserName = objFile.LastModifiedByUserName; objVersionFile.LinkURL = objFile.LinkURL; objVersionFile.ItemType = objFile.ItemType; objVersionFile.VersionsToKeep = -1; objVersionFile.VersionNumber = objFile.VersionNumber; objVersionFile.ParentID = objFile.ID; objVersionFile.Name = "Version Upload"; objVersionFile.Description = objFile.Description; objVersionFile.HomeFolderUserID = objFile.HomeFolderUserID; objVersionFile.RoleID = objFile.RoleID; objQuickFiles.Create(objVersionFile); //upload file version FileConfigurationController configCtrl = new FileConfigurationController(); List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>; if (configs[0].StorageType == "UNC") { objVersionFile.CreatePath(configs[0].FilesLocation); //fileUpload.SaveAs(configs[0].FilesLocation + objVersionFile.GetFullPath()); asyncFileUpload.UploadedFiles[0].SaveAs(configs[0].FilesLocation + objVersionFile.GetFullPath()); } else { objVersionFile.CreatePath(Server.MapPath(configs[0].FilesLocation)); //fileUpload.SaveAs(Server.MapPath(configs[0].FilesLocation) + objVersionFile.GetFullPath()); asyncFileUpload.UploadedFiles[0].SaveAs(Server.MapPath(configs[0].FilesLocation) + objVersionFile.GetFullPath()); } //List<string> fileNameAndExtension = objVersionFile.GetFileNameAndExtension(fileUpload.FileName); List<string> fileNameAndExtension = objVersionFile.GetFileNameAndExtension(asyncFileUpload.UploadedFiles[0].FileName); objVersionFile.AttachmentName = asyncFileUpload.UploadedFiles[0].FileName;// fileUpload.FileName; objVersionFile.AttachmentPath = objVersionFile.GetFullPath(); objVersionFile.FileType = asyncFileUpload.UploadedFiles[0].ContentType;// fileUpload.PostedFile.ContentType; objVersionFile.FileLength = (int)asyncFileUpload.UploadedFiles[0].ContentLength;// fileUpload.PostedFile.ContentLength; objVersionFile.Name = fileNameAndExtension[0]; objVersionFile.Extension = fileNameAndExtension[1]; objFile.AttachmentPath = objVersionFile.GetFullPath(); objFile.FileType = asyncFileUpload.UploadedFiles[0].ContentType;// fileUpload.PostedFile.ContentType; objFile.FileLength = (int)asyncFileUpload.UploadedFiles[0].ContentLength;// fileUpload.PostedFile.ContentLength; objFile.Name = fileNameAndExtension[0]; objFile.Extension = fileNameAndExtension[1]; objQuickFiles.Update(objVersionFile); objQuickFiles.Update(objFile); } //create permissions PermissionController objQuickPermissions = new PermissionController(); foreach (GridViewRow row in gridPermissions.Rows) { if ((((CheckBox)row.FindControl("chkCanSee")).Checked)) { Permission perm = new Permission(); perm.CanSee = true; perm.CanAddFiles = ((CheckBox)row.FindControl("chkCanAddFolders")).Checked; perm.CanAddFolders = ((CheckBox)row.FindControl("chkCanAddItems")).Checked; perm.CanModify = ((CheckBox)row.FindControl("chkCanModify")).Checked; perm.CanDelete = ((CheckBox)row.FindControl("chkCanDelete")).Checked; perm.CanModifyPermission = ((CheckBox)row.FindControl("chkCanModifyPermission")).Checked; perm.FileID = objFile.ID; int userID = Int32.Parse(row.Cells[8].Text); int roleID = Int32.Parse(row.Cells[10].Text); string userName = row.Cells[9].Text; string roleName = row.Cells[11].Text; if (userID > 0) { perm.UserID = userID; perm.UserName = userName; } if (roleID > 0) { perm.RoleID = roleID; perm.RoleName = roleName; } objQuickPermissions.Create(perm); } } //refresh cac SynchronizeModule(); //Redirect back to the parent folder page //Redirect back to the portal home page string strItemType = "Folder"; switch (ItemType) { case 0: strItemType = "Folder"; break; case 1: strItemType = "File"; break; case 2: strItemType = "Hyperlink"; break; } #region "Audit" //Audit: Create Item AuditController ctrlAudit = new AuditController(); Audit createAudit = new Audit() { EventDate = objFile.CreatedDate, EventDetails = "File name: " + objFile.Name, EventName = "Created", FileID = objFile.ID, UserID = UserId }; ctrlAudit.Create(createAudit); #endregion string successMessage = String.Format("Success=New {0} '{1}' created.", strItemType, objFile.Name); this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + objFile.ParentID, "ModuleID=" + ModuleId.ToString(), "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, successMessage), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private void OpenFile(int fileID, int versionNumber, string strMode) { FileController ctrl = new FileController(); File file; File requestedFile = ctrl.Get(fileID); if (versionNumber == -1) { if (requestedFile.ItemType == 1) //file, don't need version of link { file = ctrl.GetCurrentVersion(fileID); } else { file = requestedFile; //set open to requested file } } else { file = ctrl.GetVersion(fileID, versionNumber); } FileConfigurationController configCtrl = new FileConfigurationController(); List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>; if (file != null) { if (requestedFile.CanSee(UserId, PortalId, PortalSettings.AdministratorRoleId, true)) { if (file.ItemType == 2) //hyperlink { #region "Audit" //Audit: Create Item AuditController ctrlAudit = new AuditController(); Audit viewAudit = new Audit() { EventDate = System.DateTime.Now, EventDetails = "", EventName = "Opened Link", FileID = requestedFile.ID, UserID = UserId }; ctrlAudit.Create(viewAudit); #endregion Response.Redirect(file.LinkURL); } if (file.ItemType == 1) //file { #region "Audit" //Audit: Create Item AuditController ctrlAudit = new AuditController(); Audit viewAudit; if (versionNumber == -1) { viewAudit = new Audit() { EventDate = System.DateTime.Now, EventDetails = "", EventName = "Downloaded", FileID = requestedFile.ID, UserID = UserId }; } else { viewAudit = new Audit() { EventDate = System.DateTime.Now, EventDetails = "Version: " + file.VersionNumber, EventName = "Downloaded Version", FileID = requestedFile.ID, UserID = UserId }; } ctrlAudit.Create(viewAudit); #endregion bool canOpenFileType = false; switch (file.FileType.ToLower()) { case "text/plain": canOpenFileType = true; break; case "text/html": canOpenFileType = true; break; case "text/xml": canOpenFileType = true; break; case "image/gif": canOpenFileType = true; break; case "image/jpeg": canOpenFileType = true; break; case "image/tiff": canOpenFileType = true; break; case "image/bmp": canOpenFileType = true; break; case "image/png": canOpenFileType = true; break; } if (strMode == "Open" && canOpenFileType == true) { Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.ContentType = file.FileType; Response.AddHeader("Content-Length", file.FileLength.ToString()); //Response.Flush(); //Response.AppendHeader("content-disposition", String.Format("inline; filename={0}.{1}", requestedFile.Name, file.Extension)); //Set the appropriate ContentType. //Response.ContentType = file.FileType; //Get the physical path to the file. string FilePath = MapPath(configs[0].FilesLocation + file.AttachmentPath); //Write the file directly to the HTTP content output stream. Response.WriteFile(FilePath); } else { Response.Clear(); //Response.ClearHeaders(); //Response.ClearContent(); Response.ContentType = file.FileType; Response.AddHeader("Content-Length", file.FileLength.ToString()); //Response.Flush(); Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}.{1}", requestedFile.Name, file.Extension)); Response.Flush(); Response.TransmitFile(configs[0].FilesLocation + file.AttachmentPath); } //Response.Flush(); Response.End(); } } else { //Response.Redirect(Globals.NavigateURL("TabId", "", "WarningMessage=You do not have permission to the requested object.")); ShowUserErrorMessage("You do not have permission to the requested object.", ModuleId); } } else { //Response.Redirect(Globals.NavigateURL("TabId", "", "WarningMessage=The requested object does not exist.")); ShowUserErrorMessage("The requested object does not exist.", ModuleId); } }
private void DeleteChildren(File file) { //delete ALL children items where user has delete permission FileController fileCtrl = new FileController(); List<File> files = fileCtrl.GetItems(file.ID) as List<File>; foreach (File childFile in files) { if (file.ItemType == 0) { DeleteChildren(childFile); } } //send to trash if not folder if (file.ItemType != 0 && file.CanDelete(UserId, PortalId, PortalSettings.AdministratorRoleId, false)) { //send to trash if not there already if (!file.IsInTrash) { file.IsInTrash = true; fileCtrl.Update(file); #region "Audit" //Audit: Create Item AuditController ctrlAudit = new AuditController(); Audit deleteAudit = new Audit() { EventDate = file.LastModifiedDate, EventDetails = "", EventName = "Deleted", FileID = file.ID, UserID = UserId }; ctrlAudit.Create(deleteAudit); #endregion _deletedFilesCount++; return; } //if file is in trash, delete permissions and file if (file.IsInTrash) { PermissionController permCtrl = new PermissionController(); //delete versions and version permissions List<File> versions = fileCtrl.GetItems(file.ID) as List<File>; foreach (File version in versions) { List<Permission> versionPermissions = permCtrl.GetItems(version.ID) as List<Permission>; for (int i = 0; versionPermissions.Count - 1 > i; i++) { permCtrl.Delete(versionPermissions[i]); } fileCtrl.Delete(version); } //delete file permissions List<Permission> folderPermissions = permCtrl.GetItems(file.ID) as List<Permission>; for (int i = 0; folderPermissions.Count - 1 >= i; i++) { permCtrl.Delete(folderPermissions[i]); } //delete file instead of sending to trash _filesToDelete.Add(file); //fileCtrl.Delete(file); _permanentlyDeletedFilesCount++; return; } } //check if any items exist under folder and delete permission before deleting if (file.ItemType == 0 && file.CanDelete(UserId, PortalId, PortalSettings.AdministratorRoleId, false)) { //get current child count List<File> childFiles = fileCtrl.GetItems(file.ID) as List<File>; int childFilesCount = 0; //count child items not in trash foreach (File childFileCount in childFiles) { if (!childFileCount.IsInTrash) { childFilesCount++; } } //no child items, permanently delete folder if (childFilesCount == 0) { //delete folder permissions PermissionController permCtrl = new PermissionController(); List<Permission> folderPermissions = permCtrl.GetItems(file.ID) as List<Permission>; for (int i = 0; folderPermissions.Count - 1 >= i; i++) { permCtrl.Delete(folderPermissions[i]); } //delete folder instead of sending to trash _filesToDelete.Add(file); //fileCtrl.Delete(file); _deletedFilesCount++; return; } else { _notDeletedFilesCount++; return; } } _notDeletedFilesCount++; }
protected void lbnOK_Click(object sender, EventArgs e) { try { //check file exists if (asyncFileUpload.UploadedFiles.Count == 0) { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Please select a valid file to upload", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError); return; } //get parameters if (this.Request.QueryString["File"] != null) { FileID = Int32.Parse(this.Request.QueryString["File"]); } if (this.Request.QueryString["Parent"] != null) { ParentID = Int32.Parse(this.Request.QueryString["Parent"]); } //get current/root file DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController(); File objOriginalFile = objQuickFiles.Get(FileID); objOriginalFile.LastModifiedDate = System.DateTime.Now; objOriginalFile.LastModifiedByUserID = UserId; if (UserId != -1) { objOriginalFile.LastModifiedByUserName = UserInfo.DisplayName; } else { objOriginalFile.LastModifiedByUserName = "******"; } //increment version number objOriginalFile.VersionNumber = objOriginalFile.VersionNumber + 1; objOriginalFile.AttachmentName = asyncFileUpload.UploadedFiles[0].FileName;// fileUpload.FileName; //create file version and copy attributes from current version DNNQuickApps.Modules.QuickDocsPro.File objFile = new DNNQuickApps.Modules.QuickDocsPro.File(); //if (!Convert.ToBoolean(Settings["IsSearchable"].ToString())) //{ // objFile.ModuleID = ModuleId; //} objFile.PortalID = PortalId; objFile.Name = objOriginalFile.Name; objFile.CreatedByUserID = objOriginalFile.LastModifiedByUserID; objFile.CreatedDate = objOriginalFile.LastModifiedDate; objFile.CreatedByUserName = objOriginalFile.LastModifiedByUserName; objFile.LastModifiedDate = objOriginalFile.LastModifiedDate; objFile.LastModifiedByUserID = objOriginalFile.LastModifiedByUserID; objFile.LastModifiedByUserName = objOriginalFile.LastModifiedByUserName; objFile.VersionsToKeep = -1; objFile.VersionNumber = objOriginalFile.VersionNumber; objFile.ItemType = objOriginalFile.ItemType; objFile.HomeFolderUserID = objOriginalFile.HomeFolderUserID; objFile.RoleID = objOriginalFile.RoleID; //Set parent to root/current file objFile.ParentID = FileID; objQuickFiles.Update(objOriginalFile); objQuickFiles.Create(objFile); //upload file version FileConfigurationController configCtrl = new FileConfigurationController(); List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>; if (configs[0].StorageType == "UNC") { objFile.CreatePath(configs[0].FilesLocation); //fileUpload.SaveAs(configs[0].FilesLocation + objFile.GetFullPath()); asyncFileUpload.UploadedFiles[0].SaveAs(configs[0].FilesLocation + objFile.GetFullPath()); } else { objFile.CreatePath(Server.MapPath(configs[0].FilesLocation)); //fileUpload.SaveAs(Server.MapPath(configs[0].FilesLocation) + objFile.GetFullPath()); asyncFileUpload.UploadedFiles[0].SaveAs(Server.MapPath(configs[0].FilesLocation) + objFile.GetFullPath()); } //List<string> fileNameAndExtension = objFile.GetFileNameAndExtension(fileUpload.FileName); List<string> fileNameAndExtension = objFile.GetFileNameAndExtension(asyncFileUpload.UploadedFiles[0].FileName); objFile.AttachmentName = asyncFileUpload.UploadedFiles[0].FileName;// fileUpload.FileName; objFile.AttachmentPath = objFile.GetFullPath(); objFile.FileType = asyncFileUpload.UploadedFiles[0].ContentType;// fileUpload.PostedFile.ContentType; objFile.FileLength = (int)asyncFileUpload.UploadedFiles[0].ContentLength;// fileUpload.PostedFile.ContentLength; objFile.Name = fileNameAndExtension[0]; objFile.Extension = fileNameAndExtension[1]; objOriginalFile.AttachmentPath = objFile.GetFullPath(); objOriginalFile.FileType = asyncFileUpload.UploadedFiles[0].ContentType; //fileUpload.PostedFile.ContentType; objOriginalFile.FileLength = (int)asyncFileUpload.UploadedFiles[0].ContentLength; //fileUpload.PostedFile.ContentLength; //Don't change file name when uploading new version, only version gets new file name //objOriginalFile.Name = fileNameAndExtension[0]; objOriginalFile.Extension = fileNameAndExtension[1]; objQuickFiles.Update(objOriginalFile); objQuickFiles.Update(objFile); #region "Audit" //Audit: New Version Item AuditController ctrlAudit = new AuditController(); Audit versionAudit = new Audit() { EventDate = objOriginalFile.LastModifiedDate, EventDetails = "File name: " + objFile.Name, EventName = "Added Version", FileID = objOriginalFile.ID, UserID = UserId }; ctrlAudit.Create(versionAudit); #endregion //refresh cac SynchronizeModule(); //Redirect back to the portal home page this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + ParentID, "ModuleID=" + ModuleId.ToString(), "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, "Success=New version uploaded for file: " + objOriginalFile.Name), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void lbnOK_Click(object sender, EventArgs e) { try { ParentID = -1; if (this.Request.QueryString["Parent"] != null) { ParentID = Int32.Parse(this.Request.QueryString["Parent"]); } if (this.Request.QueryString["View"] != null) { _sourceView = this.Request.QueryString["View"]; } if (this.Request.QueryString["ID"] != null) { this.ItemID = Int32.Parse(this.Request.QueryString["ID"]); } else { this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + ParentID.ToString(), "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, "Warning=Could not save updates. File not found."), true); } //get file DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController(); DNNQuickApps.Modules.QuickDocsPro.File objFile = objQuickFiles.Get(ItemID); objFile.ModuleID = ModuleId; objFile.LastModifiedDate = System.DateTime.Now; objFile.Name = txtName.Text; objFile.Description = txtDescription.Text; objFile.LastModifiedByUserID = UserId; //update link url if (objFile.ItemType == 2) //link { objFile.LinkURL = txtHyperlink.Text; } if (UserId != -1) { objFile.LastModifiedByUserName = UserInfo.DisplayName; } else { objFile.LastModifiedByUserName = "******"; } try { objFile.VersionsToKeep = Int32.Parse(txtVersionsToKeep.Text); } catch { } if (objFile.CanEditPermissions(UserId, PortalId, PortalSettings.AdministratorRoleId, true)) { //delete existing permissions PermissionController permCtrl = new PermissionController(); List<Permission> permissionsToDelete = permCtrl.GetItems(objFile.ID) as List<Permission>; for (int i = 0; i < permissionsToDelete.Count; i++) { permCtrl.Delete(permissionsToDelete[i]); } //create updated permissions PermissionController objQuickPermissions = new PermissionController(); foreach (GridViewRow row in gridPermissions.Rows) { if ((((CheckBox)row.FindControl("chkCanSee")).Checked)) { Permission perm = new Permission(); perm.CanSee = true; perm.CanAddFiles = ((CheckBox)row.FindControl("chkCanAddItems")).Checked; perm.CanAddFolders = ((CheckBox)row.FindControl("chkCanAddFolders")).Checked; perm.CanModify = ((CheckBox)row.FindControl("chkCanModify")).Checked; perm.CanDelete = ((CheckBox)row.FindControl("chkCanDelete")).Checked; perm.CanModifyPermission = ((CheckBox)row.FindControl("chkCanModifyPermission")).Checked; perm.FileID = objFile.ID; int userID = Int32.Parse(row.Cells[8].Text); int roleID = Int32.Parse(row.Cells[10].Text); string userName = row.Cells[9].Text; string roleName = row.Cells[11].Text; if (userID > 0) { perm.UserID = userID; perm.UserName = userName; } if (roleID > 0) { perm.RoleID = roleID; perm.RoleName = roleName; } objQuickPermissions.Create(perm); } } } objQuickFiles.Update(objFile); #region "Audit" //Audit: Updated Item AuditController ctrlAudit = new AuditController(); Audit updatedAudit = new Audit() { EventDate = objFile.LastModifiedDate, EventDetails = "", EventName = "Updated", FileID = objFile.ID, UserID = UserId }; ctrlAudit.Create(updatedAudit); #endregion //refresh cache SynchronizeModule(); if (chkApplyToSubItems.Checked) { //apply permissions to sub-items ApplyPermissionsToSubItems(objFile); return; } //Redirect back to the portal home page this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + ParentID.ToString(), "View=" + _sourceView, "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, "Success=Changes saved."), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void lbnOK_Click(object sender, EventArgs e) { try { //check for trash view if (this.Request.QueryString["View"] != null) { _view = this.Request.QueryString["View"]; } //can not select portal root or no selection if (treeFolders.SelectedNode == null || Convert.ToInt32(treeFolders.SelectedNode.Value) == -1) { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Error: The item can not be moved to the selected location. Select a different folder.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError); return; } int intSelectedNodeValue = Convert.ToInt32(treeFolders.SelectedNode.Value); //get parameters if (this.Request.QueryString["Parent"] != null) { _ParentID = Int32.Parse(this.Request.QueryString["Parent"]); } if (this.Request.QueryString["File"] != null) { _FileID = Int32.Parse(this.Request.QueryString["File"]); } FileController fileCtrl = new FileController(); File targetFile = fileCtrl.Get(_FileID); File destinationFolder = fileCtrl.Get(intSelectedNodeValue); if (destinationFolder == null) { destinationFolder = new File(); destinationFolder.ID = -1; destinationFolder.Name = "Portal Root Folder"; } var orginalLocation = fileCtrl.Get(targetFile.ParentID); targetFile.ParentID = intSelectedNodeValue; string strEventType = "Moved"; if (targetFile.IsInTrash) { strEventType = "Restored"; } targetFile.IsInTrash = false; if (UserId != -1) { targetFile.LastModifiedByUserName = UserInfo.DisplayName; } else { targetFile.LastModifiedByUserName = "******"; } targetFile.LastModifiedByUserID = -1; targetFile.LastModifiedDate = System.DateTime.Now; fileCtrl.Update(targetFile); #region "Audit" //Audit: Create Item AuditController ctrlAudit = new AuditController(); Audit moveAudit; if (strEventType == "Moved") { moveAudit = new Audit() { EventDate = targetFile.LastModifiedDate, EventDetails = String.Format("From: {0}(ID:{1}) to: {2}(ID:{3})", orginalLocation.Name, orginalLocation.ID.ToString(), destinationFolder.Name, destinationFolder.ID.ToString()), EventName = strEventType, FileID = targetFile.ID, UserID = UserId }; } else { moveAudit = new Audit() { EventDate = targetFile.LastModifiedDate, EventDetails = String.Format("To: {0}(ID:{1})", destinationFolder.Name, destinationFolder.ID.ToString()), EventName = strEventType, FileID = targetFile.ID, UserID = UserId }; } ctrlAudit.Create(moveAudit); #endregion //refresh cac SynchronizeModule(); //Redirect back to the portal home page this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + _ParentID, "ModuleID=" + ModuleId, "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, String.Format("Success={0} moved to: {1}", targetFile.Name, destinationFolder.Name), "View=" + _view), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }