private void btnUpdateFolder_Click(object sender, EventArgs e) { SharedFileFolder folder = new SharedFileFolder(this.moduleId, this.itemId); if((folder.FolderId > 0)&&(folder.ModuleId == this.moduleId)) { folder.FolderName = this.txtFolderName.Text; folder.ParentId = int.Parse(this.ddFolderList.SelectedValue); folder.Save(); } CacheHelper.ClearModuleCache(moduleId); if (hdnReturnUrl.Value.Length > 0) { WebUtils.SetupRedirect(this, hdnReturnUrl.Value); return; } WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); }
protected void dgFile_RowUpdating(object sender, GridViewUpdateEventArgs e) { SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); if (siteUser == null) return; try { GridView grid = (GridView)sender; TextBox txtEditName = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtEditName"); if (txtEditName.Text.Trim().Length < 1) return; string keys = grid.DataKeys[e.RowIndex].Value.ToString(); char[] separator = { '~' }; string[] args = keys.Split(separator); string type = args[1]; if (type == "folder") { int folderID = int.Parse(args[0]); SharedFileFolder folder = new SharedFileFolder(this.ModuleId, folderID); folder.FolderName = Path.GetFileName(txtEditName.Text); folder.Save(); } if (type == "file") { int fileID = int.Parse(args[0]); SharedFile sharedFile = new SharedFile(this.ModuleId, fileID); sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged); sharedFile.FriendlyName = Path.GetFileName(txtEditName.Text); sharedFile.UploadUserId = siteUser.UserId; sharedFile.UploadDate = DateTime.UtcNow; //lastModDate sharedFile.Save(); } dgFile.EditIndex = -1; BindData(); } catch (Exception ex) { lblError.Text = ex.Message; } upFiles.Update(); }
protected void btnNewFolder_Click(object sender, EventArgs e) { try { if (txtNewDirectory.Text.Length > 0) { SharedFileFolder folder = new SharedFileFolder(); folder.ParentId = CurrentFolderId; folder.ModuleId = ModuleId; Module m = new Module(ModuleId); folder.ModuleGuid = m.ModuleGuid; folder.FolderName = Path.GetFileName(txtNewDirectory.Text); if (folder.Save()) { BindData(); } } } catch(Exception ex) { lblError.Text = ex.Message; } upFiles.Update(); }
public void InstallContent(Module module, string configInfo) { if (string.IsNullOrEmpty(configInfo)) { return; } SiteSettings siteSettings = new SiteSettings(module.SiteId); SiteUser admin = SiteUser.GetNewestUser(siteSettings); string upLoadPath = HostingEnvironment.MapPath("~/Data/Sites/" + module.SiteId.ToInvariantString() + "/SharedFiles/"); if (!Directory.Exists(upLoadPath)) { Directory.CreateDirectory(upLoadPath); } XmlDocument xml = new XmlDocument(); using (StreamReader stream = File.OpenText(HostingEnvironment.MapPath(configInfo))) { xml.LoadXml(stream.ReadToEnd()); } XmlAttributeCollection attributes = xml.DocumentElement.Attributes; if (attributes["filePath"].Value.Length > 0) { string destPath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/SharedFiles/"; if (!Directory.Exists(HostingEnvironment.MapPath(destPath))) { Directory.CreateDirectory(HostingEnvironment.MapPath(destPath)); } IOHelper.CopyFolderContents(HostingEnvironment.MapPath(attributes["filePath"].Value), HostingEnvironment.MapPath(destPath)); destPath = "~/Data/Sites/" + module.SiteId.ToInvariantString() + "/SharedFiles/History/"; if (!Directory.Exists(HostingEnvironment.MapPath(destPath))) { Directory.CreateDirectory(HostingEnvironment.MapPath(destPath)); } } foreach (XmlNode node in xml.DocumentElement.ChildNodes) { if (node.Name == "file") //root level files { CreateFile(module, null, admin, node); } } XmlNode foldersNode = null; foreach (XmlNode node in xml.DocumentElement.ChildNodes) { if (node.Name == "folders") { foldersNode = node; break; } } if (foldersNode != null) { foreach (XmlNode folderNode in foldersNode.ChildNodes) { if (folderNode.Name == "folder") { XmlAttributeCollection folderAttributes = folderNode.Attributes; if ((folderAttributes["folderName"] != null)&&(folderAttributes["folderName"].Value.Length > 0)) { //create folder SharedFileFolder folder = new SharedFileFolder(); folder.ModuleId = module.ModuleId; folder.ModuleGuid = module.ModuleGuid; folder.FolderName = folderAttributes["folderName"].Value; folder.Save(); foreach (XmlNode fileNode in folderNode.ChildNodes) { if (fileNode.Name == "file") { CreateFile(module, folder, admin, fileNode); } } } } } } }