private void FillFileInfo(string virtualPathAndFile, ref DotNetNuke.Services.FileSystem.FileInfo fileInfo) { fileInfo.FileName = Path.GetFileName(virtualPathAndFile); fileInfo.Extension = Path.GetExtension(virtualPathAndFile); if (fileInfo.Extension.StartsWith(".")) { fileInfo.Extension = fileInfo.Extension.Remove(0, 1); } fileInfo.ContentType = FileSystemUtils.GetContentType(fileInfo.Extension); FileStream fileStream = null; try { fileStream = File.OpenRead(HttpContext.Current.Request.MapPath(virtualPathAndFile)); FillImageInfo(fileStream, ref fileInfo); } finally { if (fileStream != null) { fileStream.Close(); fileStream.Dispose(); } } }
public override byte[] GetFileContent(FileInfo objFileInfo) { using (Stream objStream = FileManager.Instance.GetFileContent(objFileInfo)) { return(Common.ReadStream(objStream)); } }
private void FillImageInfo(Stream fileStream, ref DotNetNuke.Services.FileSystem.FileInfo fileInfo) { var imageExtensions = new FileExtensionWhitelist(Common.Globals.glbImageFileTypes); if (imageExtensions.IsAllowedExtension(fileInfo.Extension)) { System.Drawing.Image img = null; try { img = System.Drawing.Image.FromStream(fileStream); if (fileStream.Length > int.MaxValue) { fileInfo.Size = int.MaxValue; } else { fileInfo.Size = int.Parse(fileStream.Length.ToString()); } fileInfo.Width = img.Width; fileInfo.Height = img.Height; } catch { // error loading image file fileInfo.ContentType = "application/octet-stream"; } finally { if (img != null) { img.Dispose(); } } } }
public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments) { try { string virtualPath = FileSystemValidation.ToVirtualPath(path); string returnValue = DNNValidator.OnCreateFile(FileSystemValidation.CombineVirtualPath(virtualPath, name), file.ContentLength); if (!(string.IsNullOrEmpty(returnValue))) { return(returnValue); } var folder = DNNValidator.GetUserFolder(virtualPath); var fileInfo = new DotNetNuke.Services.FileSystem.FileInfo(); FillFileInfo(file, ref fileInfo); //Add or update file FileManager.Instance.AddFile(folder, name, file.InputStream); return(returnValue); } catch (Exception ex) { return(DNNValidator.LogUnknownError(ex, path, name)); } }
public string SaveFile(string Folder, out string FullFileName) { FullFileName = ""; string returnFileName = ""; string CurrentTime = DateTime.Now.ToString("_yyyy_MM_dd_HH_mm_ss"); string ParentFolderName; ParentFolderName = PortalSettings.HomeDirectoryMapPath; ParentFolderName += Folder; string strExtension = Path.GetExtension(txtFile.PostedFile.FileName).Replace(".", ""); string fullFileFilter = ",png,gif,cad,ps,jpg,jpeg"; if (!fullFileFilter.Contains("," + strExtension.ToLower())) { lblMessage.Text = "File có phần mở rộng không hợp lệ."; } else { lblMessage.Text = FileSystemUtils.UploadFileWithTime(CurrentTime, ParentFolderName.Replace("/", "\\"), txtFile.PostedFile, false); } if (lblMessage.Text == String.Empty) { FullFileName = txtFile.PostedFile.FileName.Substring(txtFile.PostedFile.FileName.LastIndexOf("\\") + 1); int dotIndex = FullFileName.LastIndexOf("."); returnFileName = FullFileName.Substring(0, dotIndex); FullFileName = returnFileName + CurrentTime + FullFileName.Substring(dotIndex); FileController fileCont = new FileController(); FileInfo file = fileCont.GetFile(FullFileName, PortalId, Folder); hdImage.Value = file.FileId.ToString(); } return(returnFileName); }
public override string CopyFile(string path, string newPath) { try { string virtualPathAndFile = (string)(string)FileSystemValidation.ToVirtualPath(path); string virtualNewPathAndFile = (string)(string)FileSystemValidation.ToVirtualPath(newPath); string returnValue = DNNValidator.OnCopyFile(virtualPathAndFile, virtualNewPathAndFile); if (!(string.IsNullOrEmpty(returnValue))) { return(returnValue); } //Returns errors or empty string when successful (ie: NewFileAlreadyExists) returnValue = TelerikContent.CopyFile(virtualPathAndFile, virtualNewPathAndFile); if (string.IsNullOrEmpty(returnValue)) { string virtualNewPath = (string)(string)FileSystemValidation.RemoveFileName(virtualNewPathAndFile); FolderInfo dnnFolder = DNNValidator.GetUserFolder(virtualNewPath); DotNetNuke.Services.FileSystem.FileInfo dnnFileInfo = new DotNetNuke.Services.FileSystem.FileInfo(); FillFileInfo(virtualNewPathAndFile, ref dnnFileInfo); DNNFileCtrl.AddFile(PortalSettings.PortalId, dnnFileInfo.FileName, dnnFileInfo.Extension, dnnFileInfo.Size, dnnFileInfo.Width, dnnFileInfo.Height, dnnFileInfo.ContentType, dnnFolder.FolderPath, dnnFolder.FolderID, true); } return(returnValue); } catch (Exception ex) { return(DNNValidator.LogUnknownError(ex, path, newPath)); } }
public override DateTime GetFileLastModificationDate(FileInfo objFile) { if (objFile != null) { return(objFile.LastModificationTime); } return(DateTime.MinValue); }
public void ExistsFile_Returns_False_When_File_Does_Not_Exist() { this._folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId); this._folderInfo.Setup(fi => fi.FolderID).Returns(Constants.FOLDER_ValidFolderId); FileInfo file = null; this._fileManager.Setup(fm => fm.GetFile(this._folderInfo.Object, Constants.FOLDER_ValidFileName)).Returns(file); var result = this._dfp.FileExists(this._folderInfo.Object, Constants.FOLDER_ValidFileName); Assert.IsFalse(result); }
public static string GetFilePath(string strFile, int portalId) { if (strFile != "") { FileController objFileController = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objXSLFile = objFileController.GetFileById(int.Parse(strFile.Replace("FileID=", "")), portalId); return(string.Format("{0}{1}", objXSLFile.Folder, objXSLFile.FileName)); } else { return(""); } }
public override int AddOrUpdateFile(FileInfo objFile, byte[] content, bool contentOnly) { var objFolder = FolderManager.Instance.GetFolder(objFile.FolderId); if (objFolder != null) { if (content != null && content.Length > 0) { using (var objStream = new MemoryStream(content)) { if (objFile.FileId > 0) { var toReturn = objFile.FileId; if (!contentOnly) { toReturn = FileManager.Instance.UpdateFile(objFile, objStream).FileId; } //Todo: seems the updatefile does not have the proper call to that function. Should be registered as a bug. FolderProvider folderProvider = FolderProvider.Instance( ComponentBase <IFolderMappingController, FolderMappingController> .Instance .GetFolderMapping(objFolder.PortalID, objFolder.FolderMappingID) .FolderProviderType); folderProvider.UpdateFile(objFolder, objFile.FileName, objStream); return(toReturn); } else { return(FileManager.Instance.AddFile(objFolder, objFile.FileName, objStream).FileId); } } } else { if (objFile.FileId > 0) { var toReturn = objFile.FileId; if (!contentOnly) { toReturn = FileManager.Instance.UpdateFile(objFile).FileId; } return(toReturn); } else { return(FileManager.Instance.AddFile(objFolder, objFile.FileName, null).FileId); } } } return(-1); }
private void FillFileInfo(Telerik.Web.UI.UploadedFile file, ref DotNetNuke.Services.FileSystem.FileInfo fileInfo) { //The core API expects the path to be stripped off the filename fileInfo.FileName = ((file.FileName.Contains("\\")) ? System.IO.Path.GetFileName(file.FileName) : file.FileName); fileInfo.Extension = file.GetExtension(); if (fileInfo.Extension.StartsWith(".")) { fileInfo.Extension = fileInfo.Extension.Remove(0, 1); } fileInfo.ContentType = FileSystemUtils.GetContentType(fileInfo.Extension); FillImageInfo(file.InputStream, ref fileInfo); }
public void ShowControls() { if (_Url != string.Empty) { string FileID; FileID = _Url.Substring(7); if (FileID != "0") { FileController fileCont = new FileController(); FileInfo file = fileCont.GetFileById(int.Parse(FileID), _objPortal.PortalID); lblFileID.Text = file.FileId.ToString(); lblFileName.Text = file.FileName; } } }
protected void cmdSave_Click(object sender, EventArgs e) { string CurrentTime = DateTime.Now.ToString("_yyyy_MM_dd_HH_mm_ss"); // if no file is selected exit if (txtFile.PostedFile.FileName == "") { return; } string ParentFolderName; if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId) { ParentFolderName = Globals.HostMapPath; } else { ParentFolderName = PortalSettings.HomeDirectoryMapPath; } ParentFolderName += Folder; string strExtension = Path.GetExtension(txtFile.PostedFile.FileName).Replace(".", ""); string fullFileFilter = "," + FileFilter.ToLower(); if (!String.IsNullOrEmpty(FileFilter) && !fullFileFilter.Contains("," + strExtension.ToLower())) { // trying to upload a file not allowed for current filter lblMessage.Text = string.Format(Localization.GetString("UploadError", this.LocalResourceFile), FileFilter, strExtension); } else { lblMessage.Text = FileSystemUtils.UploadFileWithTime(CurrentTime, ParentFolderName.Replace("/", "\\"), txtFile.PostedFile, false); } if (lblMessage.Text == String.Empty) { lblFileName.Text = txtFile.PostedFile.FileName.Substring(txtFile.PostedFile.FileName.LastIndexOf("\\") + 1); int dotIndex = lblFileName.Text.LastIndexOf("."); lblFileName.Text = lblFileName.Text.Substring(0, dotIndex) + CurrentTime + lblFileName.Text.Substring(dotIndex); FileController fileCont = new FileController(); FileInfo file = fileCont.GetFile(lblFileName.Text, _objPortal.PortalID, Folder); lblFileID.Text = file.FileId.ToString(); } }
public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments) { try { // TODO: Create entries in .resx for these messages Uri uri; if (!Uri.TryCreate(name, UriKind.Relative, out uri)) { ShowMessage(string.Format("The file {0} cannot be uplodaded because it would create an invalid URL. Please, rename the file before upload.", name)); return(""); } var invalidChars = new[] { '<', '>', '*', '%', '&', ':', '\\', '?', '+' }; if (invalidChars.Any(uri.ToString().Contains)) { ShowMessage(string.Format("The file {0} contains some invalid characters. The file name cannot contain any of the following characters: {1}", name, new String(invalidChars))); return(""); } string virtualPath = FileSystemValidation.ToVirtualPath(path); string returnValue = DNNValidator.OnCreateFile(FileSystemValidation.CombineVirtualPath(virtualPath, name), file.ContentLength); if (!string.IsNullOrEmpty(returnValue)) { return(returnValue); } var folder = DNNValidator.GetUserFolder(virtualPath); var fileInfo = new DotNetNuke.Services.FileSystem.FileInfo(); FillFileInfo(file, ref fileInfo); //Add or update file FileManager.Instance.AddFile(folder, name, file.InputStream); return(returnValue); } catch (Exception ex) { return(DNNValidator.LogUnknownError(ex, path, name)); } }
protected void btnAddAttachment_Click(object sender, EventArgs e) { string url = UserInfo.IsInRole(PortalSettings.AdministratorRoleName) ? ctlAttachment.Url : ctlUserAttachment.Url; if (url == "")//当前没有选择任何文件,直接返回 { return; } FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); AttachmentInfo ai = new AttachmentInfo(); if (url.StartsWith("FileID=")) { fi = GetFileInfoById(url); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { ai.FilePath = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; } } List <AttachmentInfo> list = AttachmentList; if (list == null) { list = new List <AttachmentInfo>(); } ai.Id = list.Count;//累加Id list.Add(ai); AttachmentList = list; gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }
/// <summary>process import of multi-instance records.</summary> /// <param name="xml">The xml.</param> /// <param name="prefix">The prefix (image, or link)</param> /// <param name="slide">The slide.</param> private static void ProcessImport(XmlNode xml, string prefix, Slide slide) { var ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings(); var contentTypeXml = xml.SelectSingleNode(prefix + "contenttype"); var contentFileNameXml = xml.SelectSingleNode(prefix + "filename"); var contentFileExtensionXml = xml.SelectSingleNode(prefix + "fileextension"); var contentFolderPathXml = xml.SelectSingleNode(prefix + "folderpath"); var contentBase64Xml = xml.SelectSingleNode(prefix + "filedata"); var contentTabPathXml = xml.SelectSingleNode(prefix + "tabpath"); // this item appears to be an encoded tabpath.... lets continue if (contentTabPathXml != null) { // todo, when upgrading DNN reference, switch this to GetTabByTabPath on the TabController var tabInfo = ps.DesktopTabs.Cast<TabInfo>().SingleOrDefault(desktopTab => desktopTab.TabPath == contentTabPathXml.InnerText); if (tabInfo != null) { switch (prefix) { case "image": slide.ImageLink = "TabID=" + tabInfo.TabID.ToString(CultureInfo.InvariantCulture); break; default: slide.Link = "TabID=" + tabInfo.TabID.ToString(CultureInfo.InvariantCulture); break; } } } // this item appears to be an encoded image... lets continue if (contentTypeXml != null && contentBase64Xml != null && contentFolderPathXml != null && contentFileNameXml != null && contentFileExtensionXml != null) { var folderController = new FolderController(); var fileController = new FileController(); // for now, just put imported images into the root folder... var folder = folderController.GetFolder(ps.PortalId, contentFolderPathXml.InnerText, true); if (folder == null) { folderController.AddFolder(ps.PortalId, contentFolderPathXml.InnerText); folder = folderController.GetFolder(ps.PortalId, contentFolderPathXml.InnerText, true); } var file = fileController.GetFile(contentFileNameXml.InnerText, ps.PortalId, folder.FolderID); if (file == null) { var content = Convert.FromBase64String(contentBase64Xml.InnerText); file = new DotNetNuke.Services.FileSystem.FileInfo { PortalId = ps.PortalId, ContentType = contentTypeXml.InnerText, FileName = contentFileNameXml.InnerText, Extension = contentFileExtensionXml.InnerText, FolderId = folder.FolderID, Size = content.Length, }; // save the file the dnn filesystem File.WriteAllBytes(ps.HomeDirectoryMapPath + file.FileName, content); // add the file to the dnn database file.FileId = fileController.AddFile(file); } // update the files content.... just incase, it never hurts.... right? ////fileController.UpdateFileContent(file.FileId, content); switch (prefix) { case "image": slide.ImageLink = "FileID=" + file.FileId.ToString(CultureInfo.InvariantCulture); break; default: slide.Link = "FileID=" + file.FileId.ToString(CultureInfo.InvariantCulture); break; } } }
public void MoveFile_Calls_DeleteFile_When_A_File_With_The_Same_Name_Exists_On_The_Destination_Folder() { _fileInfo.Setup(fi => fi.FileName).Returns(Constants.FOLDER_ValidFileName); _fileInfo.Setup(fi => fi.PortalId).Returns(Constants.CONTENT_ValidPortalId); _fileInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID); _fileInfo.Setup(fi => fi.FolderId).Returns(Constants.FOLDER_ValidFolderId); _fileInfo.Setup(fi => fi.StartDate).Returns(DateTime.Parse(Constants.FOLDER_FileStartDate)); _folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID); _folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId); _folderInfo.Setup(fi => fi.FolderID).Returns(Constants.FOLDER_OtherValidFolderId); var folderMapping = new FolderMappingInfo { FolderProviderType = Constants.FOLDER_ValidFolderProviderType }; _folderMappingController.Setup(fmc => fmc.GetFolderMapping(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping); var fileContent = new MemoryStream(); _mockFileManager.Setup(mfm => mfm.GetFileContent(_fileInfo.Object)).Returns(fileContent); string someString; _mockFileLockingController.Setup(mflc => mflc.IsFileLocked(_fileInfo.Object, out someString)).Returns(false); _mockFileManager.Setup(mfm => mfm.MoveVersions(_fileInfo.Object, It.IsAny<IFolderInfo>(), It.IsAny<FolderProvider>(), It.IsAny<FolderProvider>())); var existingFile = new FileInfo(); _mockFileManager.Setup(mfm => mfm.GetFile(_folderInfo.Object, Constants.FOLDER_ValidFileName, It.IsAny<bool>())).Returns(existingFile); _mockFileManager.Setup(mfm => mfm.DeleteFile(existingFile)).Verifiable(); _mockFileManager.Object.MoveFile(_fileInfo.Object, _folderInfo.Object); _mockFileManager.Verify(); }
/// ----------------------------------------------------------------------------- /// <summary> /// Adds a File to the DataTable used for the File List grid /// </summary> /// <param name="tblFiles">The DataTable</param> /// <param name="objFile">The FileInfo object to add</param> /// <remarks> /// </remarks> /// <history> /// [cnurse] 12/3/2004 documented /// [cnurse] 04/24/2006 Updated to use new Secure Storage /// </history> /// ----------------------------------------------------------------------------- private void AddFileToTable(DataTable tblFiles, FileInfo objFile) { DataRow dRow = tblFiles.NewRow(); dRow["FileType"] = "File"; dRow["FileId"] = objFile.FileId; dRow["FileName"] = objFile.FileName; dRow["FileSize"] = objFile.Size.ToString("##,##0"); dRow["IntFileSize"] = objFile.Size; if (!String.IsNullOrEmpty(objFile.Extension) || objFile.Extension != null) { dRow["Extension"] = objFile.Extension; } else { dRow["Extension"] = "none"; } if (objFile.SupportsFileAttributes) { dRow["SupportsFileAttributes"] = true; if (objFile.FileAttributes.HasValue) { dRow["DateModified"] = objFile.LastModificationTime; dRow["Archive"] = objFile.FileAttributes.Value & FileAttributes.Archive; dRow["ReadOnly"] = objFile.FileAttributes.Value & FileAttributes.ReadOnly; dRow["Hidden"] = objFile.FileAttributes.Value & FileAttributes.Hidden; dRow["System"] = objFile.FileAttributes.Value & FileAttributes.System; dRow["AttributeString"] = GetAttributeString(objFile.FileAttributes.Value); } } else { dRow["SupportsFileAttributes"] = false; dRow["Archive"] = false; dRow["ReadOnly"] = false; dRow["Hidden"] = false; dRow["System"] = false; dRow["AttributeString"] = ""; } tblFiles.Rows.Add(dRow); }
protected void btnAddAttachment_Click(object sender, EventArgs e) { string url = UserInfo.IsInRole(PortalSettings.AdministratorRoleName) ? ctlAttachment.Url : ctlUserAttachment.Url; if (url == "")//当前没有选择任何文件,直接返回 { return; } FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); AttachmentInfo ai = new AttachmentInfo(); if (url.StartsWith("FileID=")) { fi = GetFileInfoById(url); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { ai.FilePath = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; } } List<AttachmentInfo> list = AttachmentList; if (list == null) { list = new List<AttachmentInfo>(); } ai.Id = list.Count;//累加Id list.Add(ai); AttachmentList = list; gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }
private void UpdateArticle() { ArticleInfo objArticle = new ArticleInfo(); objArticle.Id = ArticleId; objArticle.PortalId = PortalId; //Normal objArticle.Title = txtTitle.Text; objArticle.Author = txtAuthor.Text; objArticle.Source = txtSource.Text; objArticle.Quote = chkQuote.Checked; objArticle.Draft = chkDraft.Checked; objArticle.LinkUrl = ctlLinkUrl.Url; objArticle.PinOrder = Convert.ToInt32(txtPinOrder.Text); //other if (ArticlePortalSettings.General.Portal_ArticleRequireApproval == true) { objArticle.Authed = chkAuthed.Checked; } else { objArticle.Authed = true; } objArticle.Featured = chkFeatured.Checked; objArticle.Active = chkActive.Checked; objArticle.Thumbnail = ""; objArticle.Image = UserInfo.IsInRole(PortalSettings.AdministratorRoleName)?ctlImage.Url : ctlUserImage.Url; objArticle.ImageDescription = txtImageDescription.Text; if (objArticle.Image.StartsWith("FileID=")) { FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); fi = GetFileInfoById(objArticle.Image); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; System.IO.FileInfo physicalFile = new System.IO.FileInfo(fi.PhysicalPath); if (!fi.FileName.ToLower().StartsWith("thumb_")) //文件没有以"thumb_"开头,则先查找是否存在以thumb_ 开头的同名图片 { if (System.IO.File.Exists(physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name)) //存在该文件,则自动指向 { objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } else//不存在,则生成该文件,然后指向 { if (ArticlePortalSettings.General.Portal_ArticleGenerateThumb) { Utils.ResizeImage(fi.PhysicalPath, ArticlePortalSettings.General.Portal_ArticleThumbnailSize, physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name); objArticle.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } } } } } //Add Categories objArticle.Categories = RecursiveHelper.GetAspNetTreeCheckList(tvCategory); //Add Tags objArticle.Tags = ""; TagInfo objTag = new TagInfo(); List <int> tagList = new List <int>(); if (txtTag1.Text.Trim() != "") { objTag = TagController.GetByTag(txtTag1.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag1.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag2.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 1) { objTag = TagController.GetByTag(txtTag2.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag2.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag3.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 2) { objTag = TagController.GetByTag(txtTag3.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag3.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag4.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 3) { objTag = TagController.GetByTag(txtTag4.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag4.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag5.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 4) { objTag = TagController.GetByTag(txtTag5.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag5.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag6.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 5) { objTag = TagController.GetByTag(txtTag6.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag6.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag7.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 6) { objTag = TagController.GetByTag(txtTag7.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag7.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag8.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 7) { objTag = TagController.GetByTag(txtTag8.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag8.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag9.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 8) { objTag = TagController.GetByTag(txtTag9.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag9.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag10.Text.Trim() != "" && ArticlePortalSettings.General.Portal_ArticleTagSelectCount > 9) { objTag = TagController.GetByTag(txtTag10.Text.Trim()); if (objTag == null) { objTag = new TagInfo(); objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag10.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } var newTaglist = (from p in tagList select p).Distinct();//remove the repeated tag item. foreach (int item in newTaglist) { objArticle.Tags += item.ToString() + ","; } objArticle.Tags = Utils.RemoveSeperator(objArticle.Tags, ","); //Tags end //date if ((txtPublishDate.Text != null) && (txtPublishDate.Text != "")) { objArticle.PublishDate = Convert.ToDateTime(txtPublishDate.Text); } else { objArticle.PublishDate = DateTime.Now; } if (txtExpireDate.Text != "") { objArticle.ExpireDate = Convert.ToDateTime(txtExpireDate.Text); } objArticle.ViewRoles = Utils.GetCheckedItems(cblViewRoles, PortalSettings.AdministratorRoleId); //Rating objArticle.AllowRating = chkAllowRating.Checked; objArticle.RatingRoles = Utils.GetCheckedItems(cblRatingRoles, PortalSettings.AdministratorRoleId); //Recommend objArticle.AllowRecommend = chkAllowRecommend.Checked; objArticle.RecommendRoles = Utils.GetCheckedItems(cblRecommendRoles, PortalSettings.AdministratorRoleId); //Comment objArticle.AllowComment = chkAllowComment.Checked; objArticle.CommentRoles = Utils.GetCheckedItems(cblCommentRoles, PortalSettings.AdministratorRoleId); objArticle.AutoAuthComment = chkAutoAuthComment.Checked; //Download roles objArticle.DownloadRoles = Utils.GetCheckedItems(cblDownloadRoles, PortalSettings.AdministratorRoleId); objArticle.Summary = LocalUtils.RemoveAllHtmlTags(txtSummary.Text); objArticle.Article = txtDetail.Text; objArticle.UserId = UserId; //Now processing attachment int newArticleId = -1; if (ArticleId == -1) { newArticleId = ArticleController.Add(objArticle); } else { ArticleController.Update(objArticle); newArticleId = ArticleId; AttachmentController.DeleteByArticle(ArticleId); //delete attachment first. } AttachmentInfo ai = new AttachmentInfo(); foreach (AttachmentInfo item in AttachmentList) { ai.ArticleId = newArticleId; ai.FilePath = item.FilePath; AttachmentController.Add(ai); } //Reset all ArticleId = -1; AttachmentList = new List <AttachmentInfo>(); gvAttachment.DataSource = AttachmentList; gvAttachment.DataBind(); }
public void OverwriteFolder_Calls_MoveFile_For_Each_File_In_Source_Folder() { _folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId); _folderInfo.Setup(fi => fi.FolderPath).Returns(Constants.FOLDER_ValidFolderRelativePath); _folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID); var destinationFolder = new FolderInfo(); var file1 = new FileInfo(); var file2 = new FileInfo(); var file3 = new FileInfo(); var files = new List<IFileInfo> { file1, file2, file3 }; _mockFolderManager.Setup(mfm => mfm.GetFiles(_folderInfo.Object, It.IsAny<bool>(), It.IsAny<bool>())).Returns(files); var fileManager = new Mock<IFileManager>(); FileManager.RegisterInstance(fileManager.Object); fileManager.Setup(fm => fm.MoveFile(It.IsAny<IFileInfo>(), destinationFolder)); _mockFolderManager.Setup(mfm => mfm.DeleteFolder(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderRelativePath)); var folderMapping = new FolderMappingInfo(); _mockFolderManager.Setup(mfm => mfm.GetFolderMapping(It.IsAny<Dictionary<int, FolderMappingInfo>>(), Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping); _mockFolderManager.Setup(mfm => mfm.IsFolderMappingEditable(folderMapping)).Returns(false); _mockFolderManager.Object.OverwriteFolder(_folderInfo.Object, destinationFolder, new Dictionary<int, FolderMappingInfo>(), new SortedList<string, IFolderInfo>()); fileManager.Verify(fm => fm.MoveFile(It.IsAny<IFileInfo>(), destinationFolder), Times.Exactly(3)); }
public static byte[] GetFileContent(FileInfo file) { return null; }
public override void ClearFileContent(FileInfo objFileInfo) { DatabaseFolderProvider.ClearFileContent(objFileInfo.FileId); }
private string GetImageThumbnail(int fileId) { string thumbnail = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (File.Exists(objPhysical.DirectoryName + "\\" + "thumb_" + objPhysical.Name))//Find if exist thumbnail image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + "thumb_" + objFile.FileName; } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName).A3Url; } } } return thumbnail; }
//Checks if the Storage location is secured then post append the protected extension to the file name. private string GetActualFileName(FileInfo objFile) { return((objFile.StorageLocation == (int)FolderController.StorageLocationTypes.SecureFileSystem) ? objFile.FileName + ProtectedExtension : objFile.FileName); }
public string CopyHyperlink(String objPath) { return String.Format("{0} || {1}", Request.Url, FileExplorer1.CurrentFolder); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); }
private void UpdateVideo() { VideoInfo objVideo = new VideoInfo(); if (VideoId!=-1) { objVideo = VideoController.Get(VideoId); } objVideo.Id = VideoId; objVideo.PortalId = PortalId; objVideo.TypeId = TypeId; //Normal objVideo.Title = txtTitle.Text; objVideo.VideoFile = ctlVideoFile.Url; objVideo.VideoPath = ctlVideoFile.FullUrl; objVideo.UrlMode = ctlVideoFile.UrlMode; objVideo.Duration = txtVideoDuration.Text.Trim(); if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); if (txtVideoDuration.Text.Trim() == "") { objVideo.Duration = GetVideoDuration(fileId); } } //if (CurrentType.MediaType==Convert.ToInt32(MediaType.Video)) //{ objVideo.HttpType = ddlHttpType.SelectedValue; //} //else //{ // objVideo.HttpType = "Audio"; //} objVideo.Author = txtAuthor.Text; objVideo.Source = txtSource.Text; objVideo.Quote = chkQuote.Checked; // objVideo.Private = chkPrivate.Checked; // objVideo.Protected=chkProtected.Checked; objVideo.ShareType=Convert.ToInt16(ddlShareType.SelectedValue); objVideo.Private = ddlShareType.SelectedValue == "1"; objVideo.Protected = ddlShareType.SelectedValue == "2"; objVideo.ProtectPassword = txtProtectPassword.Text; objVideo.Friends = chkFriends.Checked; objVideo.Followers = chkFollowers.Checked; if (cblGroups.Items.Count>0) { objVideo.Groups = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblGroups); } else { objVideo.Groups = string.Empty; } objVideo.LinkUrl = ctlLinkUrl.Url; if (HasManagePermission) { objVideo.DisplayOrder = Convert.ToInt32(txtDisplayOrder.Text); //other if (Settings_Portal.General.VideoRequireApproval == true) { objVideo.Authed = chkAuthed.Checked; } else { objVideo.Authed = true; } objVideo.Featured = chkFeatured.Checked; } else { objVideo.DisplayOrder = 100; objVideo.Authed = !Settings_Portal.General.VideoRequireApproval; objVideo.Featured = false; } objVideo.Active = chkActive.Checked; if (CurrentType.FieldEnable_Image) { //Image and thumbnail objVideo.Image = ctlImage.Url; objVideo.Thumbnail = ""; } else { objVideo.Image = string.Empty; objVideo.Thumbnail = string.Empty; } //File if (objVideo.Image.StartsWith("FileID=")) { //local file if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); fi = GetFileInfoById(objVideo.Image); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; System.IO.FileInfo physicalFile = new System.IO.FileInfo(fi.PhysicalPath); if (!fi.FileName.ToLower().StartsWith("thumb_"))//文件没有以"thumb_"开头,则先查找是否存在以thumb_ 开头的同名图片 { if (System.IO.File.Exists(physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name))//存在该文件,则自动指向 { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } else//不存在,则生成该文件,然后指向 { if (Settings_Portal.General.GenerateThumb) { Cross.DNN.Common.Utility.Utils.ResizeImage(fi.PhysicalPath, Settings_Portal.General.ThumbnailSize, physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name); objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } } } } } //a3 if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { int a3FileId = Convert.ToInt32(objVideo.Image.Replace("FileID=", "")); A3FileInfo objA3File = A3FileController.Get(a3FileId); if (objA3File != null && A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName) != null) { objVideo.Thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName).A3Url; } } } //External images if (objVideo.Image.ToLower().StartsWith("http")) { objVideo.Thumbnail = objVideo.Image; } if (string.IsNullOrEmpty(objVideo.Image))//没有设置任何图片,因此试图自动获取 { if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration,thunmnail { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); objVideo.Image = GetVideoThumbnail(fileId); objVideo.Thumbnail = objVideo.Image; } //自动获取youtube video 的image if (ctlVideoFile.Url.ToLower().IndexOf("youtu")>0) { if (!string.IsNullOrEmpty(LocalUtils.GetYouTubeVideoId(ctlVideoFile.Url))) { objVideo.Image = LocalUtils.GetYouTubeVideoImage_FullSize(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); objVideo.Thumbnail = LocalUtils.GetYouTubeVideoImage_Thumbnail(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); } } } //Add Categories objVideo.Categories = RecursiveHelper.GetAspNetTreeCheckList(tvCategory); objVideo.Field1 = GetHtmlEditorText(txtField1.Text); objVideo.Field2 = GetHtmlEditorText(txtField2.Text); objVideo.Field3 = GetHtmlEditorText(txtField3.Text); objVideo.Field4 = GetHtmlEditorText(txtField4.Text); objVideo.Field5 = GetHtmlEditorText(txtField5.Text); objVideo.Latitude=txtLatitude.Text.Trim(); objVideo.Longitude = txtLongitude.Text.Trim(); objVideo.MapTitle = txtMapTitle.Text.Trim(); //Add Tags objVideo.Tags = ""; TagInfo objTag = new TagInfo(); List<int> tagList = new List<int>(); if (txtTag1.Text.Trim() != "") { objTag = TagController.GetByTag(txtTag1.Text.Trim(),TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag1.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag2.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 1) { objTag = TagController.GetByTag(txtTag2.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag2.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag3.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 2) { objTag = TagController.GetByTag(txtTag3.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag3.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag4.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 3) { objTag = TagController.GetByTag(txtTag4.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag4.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag5.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 4) { objTag = TagController.GetByTag(txtTag5.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag5.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag6.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 5) { objTag = TagController.GetByTag(txtTag6.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag6.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag7.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 6) { objTag = TagController.GetByTag(txtTag7.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag7.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag8.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 7) { objTag = TagController.GetByTag(txtTag8.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag8.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag9.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 8) { objTag = TagController.GetByTag(txtTag9.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag9.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } if (txtTag10.Text.Trim() != "" && Settings_Portal.General.TagSelectCount > 9) { objTag = TagController.GetByTag(txtTag10.Text.Trim(), TypeId); if (objTag == null) { objTag = new TagInfo(); objTag.TypeId = TypeId; objTag.PortalId = PortalId; objTag.UserId = UserId; objTag.Tag = txtTag10.Text.Trim(); objTag.Id = TagController.Add(objTag); } tagList.Add(objTag.Id); } var newTaglist = (from p in tagList select p).Distinct();//remove the repeated tag item. foreach (int item in newTaglist) { objVideo.Tags += item.ToString() + ","; } objVideo.Tags = Cross.DNN.Common.Utility.Utils.RemoveSeperator(objVideo.Tags, ","); //Tags end //date if ((txtPublishDate.Text != null) && (txtPublishDate.Text != "")) { objVideo.PublishDate = Convert.ToDateTime(txtPublishDate.Text); } else { objVideo.PublishDate = DateTime.Now; } if (txtExpireDate.Text != "") { objVideo.ExpireDate = Convert.ToDateTime(txtExpireDate.Text); } if (HasManagePermission) { objVideo.ViewRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblViewRoles, PortalSettings.AdministratorRoleId); //Rating objVideo.AllowRating = chkAllowRating.Checked; objVideo.RatingRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblRatingRoles, PortalSettings.AdministratorRoleId); //Recommend objVideo.AllowRecommend = chkAllowRecommend.Checked; objVideo.RecommendRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblRecommendRoles, PortalSettings.AdministratorRoleId); //Comment objVideo.AllowComment = chkAllowComment.Checked; objVideo.CommentRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblCommentRoles, PortalSettings.AdministratorRoleId); objVideo.AutoAuthComment = chkAutoAuthComment.Checked; //Download roles objVideo.DownloadRoles = Cross.DNN.Common.Utility.Utils.GetCheckedItems(cblDownloadRoles, PortalSettings.AdministratorRoleId); } else { objVideo.ViewRoles = Settings_Portal.General.VideoViewRoles; objVideo.AllowRating = Settings_Portal.Rating.AllowRating; objVideo.RatingRoles = Settings_Portal.Rating.RatingRoles; objVideo.AllowRecommend = Settings_Portal.Recommend.AllowRecommend; objVideo.RecommendRoles = Settings_Portal.Recommend.RecommendRoles; objVideo.AllowComment = Settings_Portal.Comment.AllowComment; objVideo.CommentRoles = Settings_Portal.Comment.CommentRoles; objVideo.AutoAuthComment = Settings_Portal.Comment.AutoAuthComment; objVideo.DownloadRoles = Settings_Portal.Download.DownloadRoles; } objVideo.Summary = Cross.DNN.Common.Utility.Utils.RemoveAllHtmlTags(txtSummary.Text); objVideo.Description = GetHtmlEditorText(txtDetail.Text); objVideo.UserId = UserId; objVideo.UserName = UserInfo.DisplayName; objVideo.MediaType = CurrentType.MediaType; objVideo.VideoType = Convert.ToInt32(VideoType.Single);//Single video objVideo.HasVideo = true; //Now processing attachment int newVideoId = -1; if (VideoId == -1) { newVideoId = VideoController.Add(objVideo); } else { VideoController.Update(objVideo,true); newVideoId = VideoId; } UpdateUserDefinedData(newVideoId); //Reset all VideoId = -1; }
public void UploadEvent(object sender, MobileEventArgs args) { DateTime tokenTime = getTimeFromToken(args.token); int rmbNo = getRmbNoFromToken(args.token); if (tokenTime.AddMinutes(EXPIRE_MINUTES) <= DateTime.Now) { _view.Expire(); int RID = _rmbs.Where(a => a.RMBNo==rmbNo).SingleOrDefault().RID; LogThis(RID, 0, "Attempt to upload receipt with expired token: "+args.token + " to rmb #"+getRmbNoFromToken(args.token)+", line #"+getLineNoFromToken(args.token)+", time: "+getTimeFromToken(args.token).ToShortTimeString()); return; } int lineNo = getLineNoFromToken(args.token); AP_Staff_Rmb rmb = null; AP_Staff_RmbLine line = null; try { rmb = _rmbs.Where(a => a.SpareField4==args.token).Single(); if (rmb.RMBNo != rmbNo) throw new Exception(); line = _lines.Where(a => a.RmbLineNo == lineNo && a.RmbNo == rmbNo).Single(); } catch { } try // Upload { // initialize folder/permissions int recnum; try { recnum = _images.Where(a => a.RmbLineNo == lineNo && a.RMBNo == rmbNo).Select(a => a.RecNum).Max() + 1; } catch { // The above will fail for new lines. This statement should catch those try { recnum = _images.Where(a => a.RmbLineNo == null && a.RMBNo == rmbNo).Select(a => a.RecNum).Max() + 1; } catch { recnum = 1; } } IFileInfo file; string strUrl = ""; if (_testing) { file = new DotNetNuke.Services.FileSystem.FileInfo() { FileId = -1 }; } else { PortalSettings PS = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; Filesystem.ensureFolderExists(PS.PortalId); IFolderInfo imageFolder = Filesystem.getImageFolder(rmb.UserId, PS.PortalId); Filesystem.checkFolderPermissions(PS.PortalId, imageFolder, rmb.UserId, null); //no approvers list sent because it is an async function string filename = "R" + rmbNo.ToString()+"L"+(lineNo<0?"New":lineNo.ToString()) + "Rec" + recnum.ToString() + ".png"; // save file to DNN database string base64Data = Regex.Match(_view.ImageData, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value; byte[] image_data = Convert.FromBase64String(base64Data); //byte[] image_data = _view.ImageFile; //_view.ImageUrl= "data:image/png;base64," + Convert.ToBase64String(image_data); if (image_data == null || image_data.Length == 0) return; MemoryStream image_stream = resizeImage(image_data); file = FileManager.Instance.AddFile(imageFolder, filename, image_stream, false); //true is for overwrite string URL = FileManager.Instance.GetUrl(file); string strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery; strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, URL); } // link file to image AP_Staff_RmbLine_File image = new AP_Staff_RmbLine_File() { RMBNo = rmbNo, RecNum = recnum, FileId = file.FileId }; if (lineNo >= 0) image.RmbLineNo = lineNo; //A null RmbLineNo indicates that the line hasn't been saved yet image.URL = strUrl; StaffRmbDataContext d = new StaffRmbDataContext(); d.AP_Staff_RmbLine_Files.InsertOnSubmit(image); d.SubmitChanges(); LogThis(rmb.RID, 2, "Receipt image uploaded via mobile page"); _view.Message = "Image uploaded."; } catch (Exception ex) { LogThis(rmb.RID, 4, "Error saving receipt image via mobile page " + ex.Message + ex.StackTrace); _view.Message = "Image Upload Failed"; } }
public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments) { try { string virtualPath = FileSystemValidation.ToVirtualPath(path); string returnValue = DNNValidator.OnCreateFile(FileSystemValidation.CombineVirtualPath(virtualPath, name), file.ContentLength); if (! (string.IsNullOrEmpty(returnValue))) { return returnValue; } var folder = DNNValidator.GetUserFolder(virtualPath); var fileInfo = new DotNetNuke.Services.FileSystem.FileInfo(); FillFileInfo(file, ref fileInfo); //Add or update file FileManager.Instance.AddFile(folder, name, file.InputStream); return returnValue; } catch (Exception ex) { return DNNValidator.LogUnknownError(ex, path, name); } }
public static byte[] GetFileContent(FileInfo file, int PortalId, string HomeDirectory) { return GetFileContent(file); }
public static void AddFile(string FileName, int PortalId, string Folder, string HomeDirectoryMapPath, string contentType) { var fileManager = FileManager.Instance; var folder = FolderManager.Instance.GetFolder(PortalId, Folder); var file = fileManager.GetFile(folder, FileName); if (file == null) { file = new FileInfo { PortalId = PortalId, FolderId = folder.FolderID, FileName = FileName }; using (var fileContent = fileManager.GetFileContent(file)) { fileManager.AddFile(folder, FileName, fileContent, false); } } else { using (var fileContent = fileManager.GetFileContent(file)) { fileManager.UpdateFile(file, fileContent); } } }
private string GetVideoThumbnail(int fileId) { string thumbnail = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (File.Exists(objPhysical.DirectoryName + "\\" + "thumb_" + objPhysical.Name.Replace(objPhysical.Extension, ".jpg")))//Find if exist thumbnail image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + "thumb_" + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } if (File.Exists(objPhysical.DirectoryName + "\\" + objPhysical.Name.Replace(objPhysical.Extension, ".jpg")))//Find if exist same name image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } if (Settings_Portal.Video.VideoConvert && Settings_Portal.Video.PassPermissionCheck)// 如果同名的jpg文件不存在,则试图生成一个 { Cross.DNN.Common.VideoManage.VideoManageOption option = new Cross.DNN.Common.VideoManage.VideoManageOption(); option.General.FFMPEGPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\ffmpeg.exe"; option.General.FLVToolPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\flvtool2.exe"; option.General.MencoderPath = VideoConvert_ExecuteFolder + "\\mencoder\\mencoder.exe"; option.General.MencoderDirectory = VideoConvert_ExecuteFolder + "\\mencoder"; option.General.InputPath = objPhysical.Directory.FullName; option.General.OutputPath = objPhysical.Directory.FullName; option.Video.ExitProcess = Settings_Portal.Video.ProcessExitTime; option.General.FileName = objPhysical.Name; Cross.DNN.Common.VideoManage.VideoController ctlVideo = new Cross.DNN.Common.VideoManage.VideoController(option); if (File.Exists(option.General.FFMPEGPath))//First we need check if execute package available { ctlVideo.CaptureSingleImage(); thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName.Replace(objA3File.Extension, ".jpg")) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName.Replace(objA3File.Extension, ".jpg")).A3Url; } else { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + objA3File.FileName.Replace(objA3File.Extension, ".jpg")) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + objA3File.FileName.Replace(objA3File.Extension, ".jpg")).A3Url; } } } } return thumbnail; }
public override string CopyFile(string path, string newPath) { try { string virtualPathAndFile = (string)(string)FileSystemValidation.ToVirtualPath(path); string virtualNewPathAndFile = (string)(string)FileSystemValidation.ToVirtualPath(newPath); string returnValue = DNNValidator.OnCopyFile(virtualPathAndFile, virtualNewPathAndFile); if (! (string.IsNullOrEmpty(returnValue))) { return returnValue; } //Returns errors or empty string when successful (ie: NewFileAlreadyExists) returnValue = TelerikContent.CopyFile(virtualPathAndFile, virtualNewPathAndFile); if (string.IsNullOrEmpty(returnValue)) { string virtualNewPath = (string)(string)FileSystemValidation.RemoveFileName(virtualNewPathAndFile); FolderInfo dnnFolder = DNNValidator.GetUserFolder(virtualNewPath); DotNetNuke.Services.FileSystem.FileInfo dnnFileInfo = new DotNetNuke.Services.FileSystem.FileInfo(); FillFileInfo(virtualNewPathAndFile, ref dnnFileInfo); DNNFileCtrl.AddFile(PortalSettings.PortalId, dnnFileInfo.FileName, dnnFileInfo.Extension, dnnFileInfo.Size, dnnFileInfo.Width, dnnFileInfo.Height, dnnFileInfo.ContentType, dnnFolder.FolderPath, dnnFolder.FolderID, true); } return returnValue; } catch (Exception ex) { return DNNValidator.LogUnknownError(ex, path, newPath); } }
private string GetVideoDuration(int fileId) { string duration = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && System.IO.File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (Settings_Portal.Video.VideoConvert && Settings_Portal.Video.PassPermissionCheck) { Cross.DNN.Common.VideoManage.VideoManageOption option = new Cross.DNN.Common.VideoManage.VideoManageOption(); option.General.FFMPEGPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\ffmpeg.exe"; option.General.FLVToolPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\flvtool2.exe"; option.General.MencoderPath = VideoConvert_ExecuteFolder + "\\mencoder\\mencoder.exe"; option.General.MencoderDirectory = VideoConvert_ExecuteFolder + "\\mencoder"; option.General.InputPath = objPhysical.Directory.FullName; option.General.OutputPath = objPhysical.Directory.FullName; option.Video.ExitProcess = Settings_Portal.Video.ProcessExitTime; option.General.FileName = objPhysical.Name; Cross.DNN.Common.VideoManage.VideoController ctlVideo = new Cross.DNN.Common.VideoManage.VideoController(option); duration = ctlVideo.Get_Info().Duration; } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { duration = objA3File.Duration; } } return duration.Trim(); }
protected void Save_OnClick(object sender, EventArgs e) { try { if (FolderList.Items.Count == 0) { return; } DotNetNuke.Entities.Portals.PortalSettings portalSettings = DotNetNuke.Entities.Portals.PortalSettings.Current; string fileContents = htmlText2.Text.Trim(); string newFileName = FileName.Text; if (!(newFileName.EndsWith(".html"))) { newFileName = newFileName + ".html"; } string rootFolder = portalSettings.HomeDirectoryMapPath; string dbFolderPath = FolderList.SelectedValue; string virtualFolder = (string)(string)FileSystemValidation.ToVirtualPath(dbFolderPath); rootFolder = rootFolder + FolderList.SelectedValue; rootFolder = rootFolder.Replace("/", "\\"); string errorMessage = string.Empty; FolderController folderCtrl = new FolderController(); FolderInfo folder = folderCtrl.GetFolder(portalSettings.PortalId, dbFolderPath, false); if ((folder == null)) { ShowSaveTemplateMessage(GetString("msgFolderDoesNotExist.Text")); return; } // Check file name is valid FileSystemValidation dnnValidator = new FileSystemValidation(); errorMessage = dnnValidator.OnCreateFile(virtualFolder + newFileName, fileContents.Length); if (!(string.IsNullOrEmpty(errorMessage))) { ShowSaveTemplateMessage(errorMessage); return; } FileController fileCtrl = new FileController(); DotNetNuke.Services.FileSystem.FileInfo existingFile = fileCtrl.GetFile(newFileName, portalSettings.PortalId, folder.FolderID); // error if file exists if (!Overwrite.Checked && existingFile != null) { ShowSaveTemplateMessage(GetString("msgFileExists.Text")); return; } FileInfo newFile = existingFile; if ((newFile == null)) { newFile = new FileInfo(); } newFile.FileName = newFileName; newFile.ContentType = "text/plain"; newFile.Extension = "html"; newFile.Size = fileContents.Length; newFile.FolderId = folder.FolderID; errorMessage = FileSystemUtils.CreateFileFromString(rootFolder, newFile.FileName, fileContents, newFile.ContentType, string.Empty, false); if (!(string.IsNullOrEmpty(errorMessage))) { ShowSaveTemplateMessage(errorMessage); return; } existingFile = fileCtrl.GetFile(newFileName, portalSettings.PortalId, folder.FolderID); if (newFile.FileId != existingFile.FileId) { newFile.FileId = existingFile.FileId; } if (newFile.FileId != Null.NullInteger) { fileCtrl.UpdateFile(newFile.FileId, newFile.FileName, newFile.Extension, newFile.Size, newFile.Width, newFile.Height, newFile.ContentType, folder.FolderPath, folder.FolderID); } else { fileCtrl.AddFile(portalSettings.PortalId, newFile.FileName, newFile.Extension, newFile.Size, newFile.Width, newFile.Height, newFile.ContentType, folder.FolderPath, folder.FolderID, true); } ShowSaveTemplateMessage(string.Empty); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); throw ex; } }
private static void ParseFiles(XmlNodeList nodeFiles, int portalId, FolderInfo objFolder) { var fileManager = FileManager.Instance; foreach (XmlNode node in nodeFiles) { var fileName = XmlUtils.GetNodeValue(node.CreateNavigator(), "filename"); //First check if the file exists var objInfo = fileManager.GetFile(objFolder, fileName); if (objInfo != null) continue; objInfo = new FileInfo { PortalId = portalId, FileName = fileName, Extension = XmlUtils.GetNodeValue(node.CreateNavigator(), "extension"), Size = XmlUtils.GetNodeValueInt(node, "size"), Width = XmlUtils.GetNodeValueInt(node, "width"), Height = XmlUtils.GetNodeValueInt(node, "height"), ContentType = XmlUtils.GetNodeValue(node.CreateNavigator(), "contenttype"), SHA1Hash = XmlUtils.GetNodeValue(node.CreateNavigator(), "sha1hash"), FolderId = objFolder.FolderID, Folder = objFolder.FolderPath, Title = "", StartDate = DateTime.Now, EndDate = Null.NullDate, EnablePublishPeriod = false, ContentItemID = Null.NullInteger }; //Save new File try { using (var fileContent = fileManager.GetFileContent(objInfo)) { objInfo.FileId = fileManager.AddFile(objFolder, fileName, fileContent, false).FileId; } fileManager.UpdateFile(objInfo); } catch (InvalidFileExtensionException ex) //when the file is not allowed, we should not break parse process, but just log the error. { Logger.Error(ex.Message); } } }
private static void RemoveOrphanedFile(FileInfo objFile, int PortalId) { FileManager.Instance.DeleteFile(objFile); }
/// <summary>process import of multi-instance records.</summary> /// <param name="xml">The xml.</param> /// <param name="prefix">The prefix (image, or link)</param> /// <param name="slide">The slide.</param> private static void ProcessImport(XmlNode xml, string prefix, Slide slide) { var ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings(); var contentTypeXml = xml.SelectSingleNode(prefix + "contenttype"); var contentFileNameXml = xml.SelectSingleNode(prefix + "filename"); var contentFileExtensionXml = xml.SelectSingleNode(prefix + "fileextension"); var contentFolderPathXml = xml.SelectSingleNode(prefix + "folderpath"); var contentBase64Xml = xml.SelectSingleNode(prefix + "filedata"); var contentTabPathXml = xml.SelectSingleNode(prefix + "tabpath"); // this item appears to be an encoded tabpath.... lets continue if (contentTabPathXml != null) { // todo, when upgrading DNN reference, switch this to GetTabByTabPath on the TabController var tabInfo = ps.DesktopTabs.Cast <TabInfo>().SingleOrDefault(desktopTab => desktopTab.TabPath == contentTabPathXml.InnerText); if (tabInfo != null) { switch (prefix) { case "image": slide.ImageLink = "TabID=" + tabInfo.TabID.ToString(CultureInfo.InvariantCulture); break; default: slide.Link = "TabID=" + tabInfo.TabID.ToString(CultureInfo.InvariantCulture); break; } } } // this item appears to be an encoded image... lets continue if (contentTypeXml != null && contentBase64Xml != null && contentFolderPathXml != null && contentFileNameXml != null && contentFileExtensionXml != null) { var folderController = new FolderController(); var fileController = new FileController(); // for now, just put imported images into the root folder... var folder = folderController.GetFolder(ps.PortalId, contentFolderPathXml.InnerText, true); if (folder == null) { folderController.AddFolder(ps.PortalId, contentFolderPathXml.InnerText); folder = folderController.GetFolder(ps.PortalId, contentFolderPathXml.InnerText, true); } var file = fileController.GetFile(contentFileNameXml.InnerText, ps.PortalId, folder.FolderID); if (file == null) { var content = Convert.FromBase64String(contentBase64Xml.InnerText); file = new DotNetNuke.Services.FileSystem.FileInfo { PortalId = ps.PortalId, ContentType = contentTypeXml.InnerText, FileName = contentFileNameXml.InnerText, Extension = contentFileExtensionXml.InnerText, FolderId = folder.FolderID, Size = content.Length, }; // save the file the dnn filesystem File.WriteAllBytes(ps.HomeDirectoryMapPath + file.FileName, content); // add the file to the dnn database file.FileId = fileController.AddFile(file); } // update the files content.... just incase, it never hurts.... right? ////fileController.UpdateFileContent(file.FileId, content); switch (prefix) { case "image": slide.ImageLink = "FileID=" + file.FileId.ToString(CultureInfo.InvariantCulture); break; default: slide.Link = "FileID=" + file.FileId.ToString(CultureInfo.InvariantCulture); break; } } }
public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments) { try { // TODO: Create entries in .resx for these messages Uri uri; if (!Uri.TryCreate(name, UriKind.Relative, out uri)) { ShowMessage(string.Format("The file {0} cannot be uplodaded because it would create an invalid URL. Please, rename the file before upload.", name)); return ""; } var invalidChars = new[] {'<', '>', '*', '%', '&', ':', '\\', '?', '+'}; if (invalidChars.Any(uri.ToString().Contains)) { ShowMessage(string.Format("The file {0} contains some invalid characters. The file name cannot contain any of the following characters: {1}", name, new String(invalidChars))); return ""; } string virtualPath = FileSystemValidation.ToVirtualPath(path); string returnValue = DNNValidator.OnCreateFile(FileSystemValidation.CombineVirtualPath(virtualPath, name), file.ContentLength); if (!string.IsNullOrEmpty(returnValue)) { return returnValue; } var folder = DNNValidator.GetUserFolder(virtualPath); var fileInfo = new DotNetNuke.Services.FileSystem.FileInfo(); FillFileInfo(file, ref fileInfo); //Add or update file FileManager.Instance.AddFile(folder, name, file.InputStream); return returnValue; } catch (Exception ex) { return DNNValidator.LogUnknownError(ex, path, name); } }
private string GetFileFullUrl(int fileId) { string url = ""; if (Settings_Portal.General.FileStorage.ToLower() == "local") { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalSettings.PortalId); objFile = ctlFile.GetFileById(fileId, PortalSettings.PortalId); if (objFile != null) { url = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName; } } if (Settings_Portal.General.FileStorage.ToLower() == "a3") { if (A3FileController.Get(fileId) != null) { url = A3FileController.Get(fileId).A3Url; } } return url; }
protected void Save_OnClick(object sender, EventArgs e) { try { if (FolderList.Items.Count == 0) { return; } DotNetNuke.Entities.Portals.PortalSettings portalSettings = DotNetNuke.Entities.Portals.PortalSettings.Current; string fileContents = htmlText2.Text.Trim(); string newFileName = FileName.Text; if (! (newFileName.EndsWith(".html"))) { newFileName = newFileName + ".html"; } string rootFolder = portalSettings.HomeDirectoryMapPath; string dbFolderPath = FolderList.SelectedValue; string virtualFolder = (string)(string)FileSystemValidation.ToVirtualPath(dbFolderPath); rootFolder = rootFolder + FolderList.SelectedValue; rootFolder = rootFolder.Replace("/", "\\"); string errorMessage = string.Empty; FolderController folderCtrl = new FolderController(); FolderInfo folder = folderCtrl.GetFolder(portalSettings.PortalId, dbFolderPath, false); if ((folder == null)) { ShowSaveTemplateMessage(GetString("msgFolderDoesNotExist.Text")); return; } // Check file name is valid FileSystemValidation dnnValidator = new FileSystemValidation(); errorMessage = dnnValidator.OnCreateFile(virtualFolder + newFileName, fileContents.Length); if (! (string.IsNullOrEmpty(errorMessage))) { ShowSaveTemplateMessage(errorMessage); return; } FileController fileCtrl = new FileController(); DotNetNuke.Services.FileSystem.FileInfo existingFile = fileCtrl.GetFile(newFileName, portalSettings.PortalId, folder.FolderID); // error if file exists if (! Overwrite.Checked && existingFile != null) { ShowSaveTemplateMessage(GetString("msgFileExists.Text")); return; } FileInfo newFile = existingFile; if ((newFile == null)) { newFile = new FileInfo(); } newFile.FileName = newFileName; newFile.ContentType = "text/plain"; newFile.Extension = "html"; newFile.Size = fileContents.Length; newFile.FolderId = folder.FolderID; errorMessage = FileSystemUtils.CreateFileFromString(rootFolder, newFile.FileName, fileContents, newFile.ContentType, string.Empty, false); if (! (string.IsNullOrEmpty(errorMessage))) { ShowSaveTemplateMessage(errorMessage); return; } existingFile = fileCtrl.GetFile(newFileName, portalSettings.PortalId, folder.FolderID); if (newFile.FileId != existingFile.FileId) { newFile.FileId = existingFile.FileId; } if (newFile.FileId != Null.NullInteger) { fileCtrl.UpdateFile(newFile.FileId, newFile.FileName, newFile.Extension, newFile.Size, newFile.Width, newFile.Height, newFile.ContentType, folder.FolderPath, folder.FolderID); } else { fileCtrl.AddFile(portalSettings.PortalId, newFile.FileName, newFile.Extension, newFile.Size, newFile.Width, newFile.Height, newFile.ContentType, folder.FolderPath, folder.FolderID, true); } ShowSaveTemplateMessage(string.Empty); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); throw ex; } }
private void UpdateVideo() { VideoInfo objVideo = new VideoInfo(); if (VideoId != -1) { objVideo = VideoController.Get(VideoId); } objVideo.Id = VideoId; objVideo.PortalId = PortalId; objVideo.TypeId = TypeId; //Normal objVideo.Title = txtVideoTitle.Text; objVideo.VideoFile = ctlVideoFile.Url; objVideo.VideoPath = ctlVideoFile.FullUrl; objVideo.UrlMode = ctlVideoFile.UrlMode; objVideo.Duration = txtVideoDuration.Text.Trim(); if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); if (txtVideoDuration.Text.Trim() == "") { objVideo.Duration = GetVideoDuration(fileId); } } //if (CurrentType.MediaType == Convert.ToInt32(MediaType.Video)) //{ objVideo.HttpType = ddlHttpType.SelectedValue; //} //else //{ // objVideo.HttpType = "Audio"; //} if (CurrentType.FieldEnable_Image) { //Image and thumbnail objVideo.Image = ctlVideoImage.Url; objVideo.Thumbnail = ""; } else { objVideo.Image = string.Empty; objVideo.Thumbnail = string.Empty; } //File if (objVideo.Image.StartsWith("FileID=")) { //local file if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController fc = new FileController(); DotNetNuke.Services.FileSystem.FileInfo fi = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); fi = GetFileInfoById(objVideo.Image); if (fi != null && System.IO.File.Exists(fi.PhysicalPath)) { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + fi.FileName; System.IO.FileInfo physicalFile = new System.IO.FileInfo(fi.PhysicalPath); if (!fi.FileName.ToLower().StartsWith("thumb_"))//文件没有以"thumb_"开头,则先查找是否存在以thumb_ 开头的同名图片 { if (System.IO.File.Exists(physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name))//存在该文件,则自动指向 { objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } else//不存在,则生成该文件,然后指向 { if (Settings_Portal.General.GenerateThumb) { Cross.DNN.Common.Utility.Utils.ResizeImage(fi.PhysicalPath, Settings_Portal.General.ThumbnailSize, physicalFile.DirectoryName + "\\" + "thumb_" + physicalFile.Name); objVideo.Thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + fi.Folder + "thumb_" + fi.FileName; } } } } } //a3 if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { int a3FileId = Convert.ToInt32(objVideo.Image.Replace("FileID=", "")); A3FileInfo objA3File = A3FileController.Get(a3FileId); if (objA3File != null && A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName) != null) { objVideo.Thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName).A3Url; } } } //External images if (objVideo.Image.ToLower().StartsWith("http")) { objVideo.Thumbnail = objVideo.Image; } if (string.IsNullOrEmpty(objVideo.Image))//没有设置任何图片,因此试图自动获取 { if (ctlVideoFile.Url.StartsWith("FileID="))// 当前选择为文件,因此试图获取其duration,thunmnail { int fileId = Convert.ToInt32(ctlVideoFile.Url.Replace("FileID=", "")); objVideo.Image = GetVideoThumbnail(fileId); objVideo.Thumbnail = objVideo.Image; } //自动获取youtube video 的image if (ctlVideoFile.Url.ToLower().IndexOf("youtu") > 0) { if (!string.IsNullOrEmpty(LocalUtils.GetYouTubeVideoId(ctlVideoFile.Url))) { objVideo.Image = LocalUtils.GetYouTubeVideoImage_FullSize(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); objVideo.Thumbnail = LocalUtils.GetYouTubeVideoImage_Thumbnail(ctlVideoFile.Url, System.Web.HttpContext.Current.Request.IsSecureConnection); } } } objVideo.UserId = UserId; objVideo.UserName = UserInfo.DisplayName; objVideo.MediaType = CurrentType.MediaType; objVideo.VideoType = Convert.ToInt32(VideoType.SerialSlave);//Single video objVideo.SerialOrder = Convert.ToInt32(txtSerialOrder.Text); objVideo.MasterVideoId = SerialId; //Now processing attachment int newVideoId = -1; if (VideoId == -1) { newVideoId = VideoController.Add(objVideo); VideoInfo objSerial = VideoController.Get(SerialId); if (objSerial.HasVideo==false)//如果是第一次增加,则需要修改其 master video 的has video 属性 { objSerial.HasVideo = true; VideoController.Update(objSerial,false); } } else { VideoController.Update(objVideo,false); newVideoId = VideoId; } //Reset all VideoId = -1; }
protected void Page_Load(object sender, System.EventArgs e) { try { string renderUrl = Request.QueryString["rurl"]; if (!(string.IsNullOrEmpty(renderUrl))) { string fileContents = string.Empty; FileController fileCtrl = new FileController(); FileInfo fileInfo = null; int portalID = PortalController.Instance.GetCurrentPortalSettings().PortalId; if (renderUrl.ToLower().Contains("linkclick.aspx") && renderUrl.ToLower().Contains("fileticket")) { //File Ticket int fileID = GetFileIDFromURL(renderUrl); if (fileID > -1) { fileInfo = fileCtrl.GetFileById(fileID, portalID); } } else { if (renderUrl.Contains("?")) { renderUrl = renderUrl.Substring(0, renderUrl.IndexOf("?")); } //File URL string dbPath = (string)(string)FileSystemValidation.ToDBPath(renderUrl); string fileName = System.IO.Path.GetFileName(renderUrl); if (!string.IsNullOrEmpty(fileName)) { FolderInfo dnnFolder = GetDNNFolder(dbPath); if (dnnFolder != null) { fileInfo = fileCtrl.GetFile(fileName, portalID, dnnFolder.FolderID); } } } if (fileInfo != null) { if (CanViewFile(fileInfo.Folder)) { using (var streamReader = new StreamReader(FileManager.Instance.GetFileContent(fileInfo))) { fileContents = streamReader.ReadToEnd(); } } } if (!(string.IsNullOrEmpty(fileContents))) { Content.Text = Server.HtmlEncode(fileContents); } } } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); Content.Text = string.Empty; } }
private void Page_Load(object sender, EventArgs e) { //PortalSettings ps = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; PortalSettings ps = Utility.GetPortalSettings(PortalId); Response.ContentType = "text/xml"; Response.ContentEncoding = Encoding.UTF8; var sw = new StringWriter(CultureInfo.InvariantCulture); var wr = new XmlTextWriter(sw); wr.WriteStartElement("rss"); wr.WriteAttributeString("version", "2.0"); wr.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/"); wr.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/"); wr.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/"); wr.WriteAttributeString("xmlns:trackback", "http://madskills.com/public/xml/rss/module/trackback/"); wr.WriteStartElement("channel"); wr.WriteElementString("title", ps.PortalName); if (ps.PortalAlias.HTTPAlias.IndexOf("http://", StringComparison.OrdinalIgnoreCase) == -1) { wr.WriteElementString("link", "http://" + ps.PortalAlias.HTTPAlias); } else { wr.WriteElementString("link", ps.PortalAlias.HTTPAlias); } wr.WriteElementString("description", "RSS Feed for " + ps.PortalName); wr.WriteElementString("ttl", "120"); //TODO: look into options for how to display the "Title" of the RSS feed var dt = new DataTable { Locale = CultureInfo.InvariantCulture }; if (DisplayType == "ItemListing" || DisplayType == null) { dt = ItemId == -1 ? DataProvider.Instance().GetMostRecent(ItemTypeId, NumberOfItems, PortalId) : DataProvider.Instance().GetMostRecentByCategoryId(ItemId, ItemTypeId, NumberOfItems, PortalId); } else if (DisplayType == "CategoryFeature") { DataSet ds = DataProvider.Instance().GetParentItems(ItemId, PortalId, RelationshipTypeId); dt = ds.Tables[0]; } else if (DisplayType == "TagFeed") { if (AllowTags && _tagQuery != null && _tagQuery.Count > 0) { string tagCacheKey = Utility.CacheKeyPublishTag + PortalId + ItemTypeId.ToString(CultureInfo.InvariantCulture) + _qsTags; // +"PageId"; dt = DataCache.GetCache(tagCacheKey) as DataTable; if (dt == null) { //ToDo: we need to make getitemsfromtags use the numberofitems value dt = Tag.GetItemsFromTags(PortalId, _tagQuery); //TODO: we should sort the tags //TODO: should we set a 5 minute cache on RSS? DataCache.SetCache(tagCacheKey, dt, DateTime.Now.AddMinutes(5)); Utility.AddCacheKey(tagCacheKey, PortalId); } } } if (dt != null) { DataView dv = dt.DefaultView; if (dv.Table.Columns.IndexOf("dateColumn") > 0) { dv.Table.Columns.Add("dateColumn", typeof(DateTime)); foreach (DataRowView dr in dv) { dr["dateColumn"] = Convert.ToDateTime(dr["startdate"]); } dv.Sort = " dateColumn desc "; } for (int i = 0; i < dv.Count; i++) { //DataRow r = dt.Rows[i]; DataRow r = dv[i].Row; wr.WriteStartElement("item"); // wr.WriteElementString("slash:comments", objArticle.CommentCount.ToString()); // wr.WriteElementString("wfw:commentRss", "http://" & Request.Url.Host & Me.ResolveUrl("RssComments.aspx?TabID=" & m_tabID & "&ModuleID=" & m_moduleID & "&ArticleID=" & objArticle.ArticleID.ToString()).Replace(" ", "%20")); // wr.WriteElementString("trackback:ping", "http://" & Request.Url.Host & Me.ResolveUrl("Tracking/Trackback.aspx?ArticleID=" & objArticle.ArticleID.ToString() & "&PortalID=" & _portalSettings.PortalId.ToString() & "&TabID=" & _portalSettings.ActiveTab.TabID.ToString()).Replace(" ", "%20")); string title = String.Empty, description = String.Empty, childItemId = String.Empty, thumbnail = String.Empty, guid = String.Empty, author = string.Empty; DateTime startDate = DateTime.MinValue; if (DisplayType == null || string.Equals(DisplayType, "ItemListing", StringComparison.OrdinalIgnoreCase) || string.Equals(DisplayType, "TagFeed", StringComparison.OrdinalIgnoreCase)) { title = r["ChildName"].ToString(); description = r["ChildDescription"].ToString(); childItemId = r["ChilditemId"].ToString(); guid = r["itemVersionIdentifier"].ToString(); startDate = (DateTime)r["StartDate"]; thumbnail = r["Thumbnail"].ToString(); author = r["Author"].ToString(); //UserController uc = new UserController(); //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString())); //if(ui!=null) //author = ui.DisplayName; } else if (string.Equals(DisplayType, "CategoryFeature", StringComparison.OrdinalIgnoreCase)) { title = r["Name"].ToString(); description = r["Description"].ToString(); childItemId = r["itemId"].ToString(); guid = r["itemVersionIdentifier"].ToString(); startDate = (DateTime)r["StartDate"]; thumbnail = r["Thumbnail"].ToString(); author = r["Author"].ToString(); //UserController uc = new UserController(); //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString())); //if (ui != null) //author = ui.DisplayName; } if (!Uri.IsWellFormedUriString(thumbnail, UriKind.Absolute) && thumbnail != string.Empty) { var thumnailLink = new Uri(Request.Url, ps.HomeDirectory + thumbnail); thumbnail = thumnailLink.ToString(); } wr.WriteElementString("title", title); //if the item isn't disabled add the link if (!Utility.IsDisabled(Convert.ToInt32(childItemId, CultureInfo.InvariantCulture), PortalId)) { wr.WriteElementString("link", Utility.GetItemLinkUrl(childItemId, PortalId)); } //wr.WriteElementString("description", Utility.StripTags(this.Server.HtmlDecode(description))); description = Utility.ReplaceTokens(description); wr.WriteElementString("description", Server.HtmlDecode(description)); //wr.WriteElementString("author", Utility.StripTags(this.Server.HtmlDecode(author))); wr.WriteElementString("thumbnail", thumbnail); wr.WriteElementString("dc:creator", author); wr.WriteElementString("pubDate", startDate.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture)); //file attachment enclosure ItemVersionSetting attachmentSetting = ItemVersionSetting.GetItemVersionSetting(Convert.ToInt32(r["ItemVersionId"].ToString()), "ArticleSettings", "ArticleAttachment", PortalId); if (attachmentSetting != null) { if (attachmentSetting.PropertyValue.Length > 7) { var fileController = new FileController(); int fileId = Convert.ToInt32(attachmentSetting.PropertyValue.Substring(7)); DotNetNuke.Services.FileSystem.FileInfo fi = fileController.GetFileById(fileId, PortalId); string fileurl = "http://" + PortalSettings.PortalAlias.HTTPAlias + PortalSettings.HomeDirectory + fi.Folder + fi.FileName; wr.WriteStartElement("enclosure"); wr.WriteAttributeString("url", fileurl); wr.WriteAttributeString("length", fi.Size.ToString()); wr.WriteAttributeString("type", fi.ContentType); wr.WriteEndElement(); } } wr.WriteStartElement("guid"); wr.WriteAttributeString("isPermaLink", "false"); wr.WriteString(guid); //wr.WriteString(itemVersionId); wr.WriteEndElement(); wr.WriteEndElement(); } } wr.WriteEndElement(); wr.WriteEndElement(); Response.Write(sw.ToString()); }
public static void AddFile(string strFileName, string strExtension, string FolderPath, string strContentType, int Length, int imageWidth, int imageHeight) { #pragma warning disable 612,618 // Obtain PortalSettings from Current Context PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings(); int PortalId = FileSystemUtils.GetFolderPortalId(_portalSettings); var objFiles = new FileController(); var objFolders = new FolderController(); FolderInfo objFolder = objFolders.GetFolder(PortalId, FolderPath, false); if ((objFolder != null)) { var objFile = new FileInfo(PortalId, strFileName, strExtension, Length, imageWidth, imageHeight, strContentType, FolderPath, objFolder.FolderID, objFolder.StorageLocation, true); objFiles.AddFile(objFile); } #pragma warning restore 612,618 }
public static Stream GetFileStream(FileInfo objFile, int PortalId, string HomeDirectory) { return GetFileStream(objFile); }
/// <summary> /// Processes all Files from the template /// </summary> /// <param name="nodeFiles">Template file node for the Files</param> /// <param name="PortalId">PortalId of the new portal</param> /// <history> /// [cnurse] 11/09/2004 Created /// </history> private void ParseFiles( XmlNodeList nodeFiles, int PortalId, FolderInfo objFolder ) { int FileId = 0; FileController objController = new FileController(); FileInfo objInfo = null; string fileName = null; foreach( XmlNode node in nodeFiles ) { fileName = XmlUtils.GetNodeValue( node, "filename", "" ); //First check if the file exists objInfo = objController.GetFile( fileName, PortalId, objFolder.FolderID ); if( objInfo == null ) { objInfo = new FileInfo(); objInfo.PortalId = PortalId; objInfo.FileName = fileName; objInfo.Extension = XmlUtils.GetNodeValue( node, "extension", "" ); objInfo.Size = XmlUtils.GetNodeValueInt( node, "size", 0 ); objInfo.Width = XmlUtils.GetNodeValueInt( node, "width", 0 ); objInfo.Height = XmlUtils.GetNodeValueInt( node, "height", 0 ); objInfo.ContentType = XmlUtils.GetNodeValue( node, "contenttype", "" ); objInfo.FolderId = objFolder.FolderID; objInfo.Folder = objFolder.FolderPath; //Save new File FileId = objController.AddFile( objInfo ); } else { //Get Id from File FileId = objInfo.FileId; } } }
public static string AddFile(string strFile, int PortalId, bool ClearCache, FolderInfo folder) { var fileManager = FileManager.Instance; var fileName = GetFileName(strFile); var file = (FileInfo)fileManager.GetFile(folder, fileName); if (file == null) { file = new FileInfo { PortalId = PortalId, FolderId = folder.FolderID, FileName = fileName }; using (var fileContent = fileManager.GetFileContent(file)) { fileManager.AddFile(folder, GetFileName(strFile), fileContent, false); } } else { using (var fileContent = fileManager.GetFileContent(file)) { fileManager.UpdateFile(file, fileContent); } } return ""; }
public static void AddFile(string strFileName, string strExtension, string FolderPath, string strContentType, int Length, int imageWidth, int imageHeight) { // Obtain PortalSettings from Current Context PortalSettings portalSettings = PortalController.GetCurrentPortalSettings(); int portalId = IsHostTab(portalSettings.ActiveTab.TabID) ? Null.NullInteger : portalSettings.PortalId; var objFiles = new FileController(); var objFolders = new FolderController(); FolderInfo objFolder = objFolders.GetFolder(portalId, FolderPath, false); if ((objFolder != null)) { var objFile = new FileInfo(portalId, strFileName, strExtension, Length, imageWidth, imageHeight, strContentType, FolderPath, objFolder.FolderID, objFolder.StorageLocation, true); objFiles.AddFile(objFile); } }
public static Stream GetFileStream(FileInfo objFile) { return FileManager.Instance.GetFileContent(objFile); }
private static void ParseFiles(XmlNodeList nodeFiles, int portalId, FolderInfo objFolder) { var fileManager = FileManager.Instance; foreach (XmlNode node in nodeFiles) { var fileName = XmlUtils.GetNodeValue(node.CreateNavigator(), "filename"); //First check if the file exists var objInfo = fileManager.GetFile(objFolder, fileName); if (objInfo != null) continue; objInfo = new FileInfo { PortalId = portalId, FileName = fileName, Extension = XmlUtils.GetNodeValue(node.CreateNavigator(), "extension"), Size = XmlUtils.GetNodeValueInt(node, "size"), Width = XmlUtils.GetNodeValueInt(node, "width"), Height = XmlUtils.GetNodeValueInt(node, "height"), ContentType = XmlUtils.GetNodeValue(node.CreateNavigator(), "contenttype"), SHA1Hash = XmlUtils.GetNodeValue(node.CreateNavigator(), "sha1hash"), FolderId = objFolder.FolderID, Folder = objFolder.FolderPath }; //Save new File using (var fileContent = fileManager.GetFileContent(objInfo)) { objInfo.FileId = fileManager.AddFile(objFolder, fileName, fileContent, false).FileId; } fileManager.UpdateFile(objInfo); } }
/// ----------------------------------------------------------------------------- /// <summary> /// ParseFiles parses the Host Template's Files node /// </summary> /// <remarks> /// </remarks> /// <param name="node">The Files node</param> /// <param name="portalId">The PortalId (-1 for Host Files)</param> /// <history> /// [cnurse] 11/08/2004 created /// </history> /// ----------------------------------------------------------------------------- private static void ParseFiles(XmlNode node, int portalId) { //Parse the File nodes if (node != null) { XmlNodeList nodes = node.SelectNodes("file"); if (nodes != null) { var folderManager = FolderManager.Instance; var fileManager = FileManager.Instance; foreach (XmlNode fileNode in nodes) { string fileName = XmlUtils.GetNodeValue(fileNode.CreateNavigator(), "filename"); string extension = XmlUtils.GetNodeValue(fileNode.CreateNavigator(), "extension"); long size = long.Parse(XmlUtils.GetNodeValue(fileNode.CreateNavigator(), "size")); int width = XmlUtils.GetNodeValueInt(fileNode, "width"); int height = XmlUtils.GetNodeValueInt(fileNode, "height"); string contentType = XmlUtils.GetNodeValue(fileNode.CreateNavigator(), "contentType"); string folder = XmlUtils.GetNodeValue(fileNode.CreateNavigator(), "folder"); var folderInfo = folderManager.GetFolder(portalId, folder); var file = new FileInfo(portalId, fileName, extension, (int)size, width, height, contentType, folder, folderInfo.FolderID, folderInfo.StorageLocation, true); using (var fileContent = fileManager.GetFileContent(file)) { var addedFile = fileManager.AddFile(folderInfo, file.FileName, fileContent, false); file.FileId = addedFile.FileId; file.EnablePublishPeriod = addedFile.EnablePublishPeriod; file.EndDate = addedFile.EndDate; file.StartDate = addedFile.StartDate; } fileManager.UpdateFile(file); } } } }
private void ShowControls() { UrlController objUrls = new UrlController(); // set url type if (optType.SelectedItem == null) { if (!String.IsNullOrEmpty(_Url)) { string TrackingUrl = _Url; _UrlType = Globals.GetURLType(_Url).ToString("g").Substring(0, 1); if (_UrlType == "F") { FileController objFiles = new FileController(); if (_Url.ToLower().StartsWith("fileid=")) { TrackingUrl = _Url; FileInfo objFile = objFiles.GetFileById(int.Parse(_Url.Substring(7)), _objPortal.PortalID); if (objFile != null) { _Url = objFile.Folder + objFile.FileName; } } else { // to handle legacy scenarios before the introduction of the FileServerHandler TrackingUrl = "FileID=" + objFiles.ConvertFilePathToFileId(_Url, _objPortal.PortalID); } } if (_UrlType == "M") { if (_Url.ToLower().StartsWith("userid=")) { UserInfo objUser = UserController.GetUser(_objPortal.PortalID, int.Parse(_Url.Substring(7)), false); if (objUser != null) { _Url = objUser.Username; } } } UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(_objPortal.PortalID, TrackingUrl, ModuleID); if (objUrlTracking != null) { optType.Items.FindByValue(objUrlTracking.UrlType).Selected = true; chkNewWindow.Checked = objUrlTracking.NewWindow; chkTrack.Checked = objUrlTracking.TrackClicks; chkLog.Checked = objUrlTracking.LogActivity; } else // the url does not exist in the tracking table { optType.Items.FindByValue(_UrlType).Selected = true; chkNewWindow.Checked = false; chkTrack.Checked = true; chkLog.Checked = false; } } else { if (!String.IsNullOrEmpty(_UrlType)) { if (optType.Items.FindByValue(_UrlType) != null) { optType.Items.FindByValue(_UrlType).Selected = true; } else { optType.Items[0].Selected = true; } } else { optType.Items[0].Selected = true; } chkNewWindow.Checked = false; chkTrack.Checked = true; chkLog.Checked = false; } } // load listitems switch (optType.SelectedItem.Value) { case "N": // None URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = false; break; case "U": // Url URLRow.Visible = true; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = false; if (txtUrl.Text == "") { txtUrl.Text = _Url; } if (txtUrl.Text == "") { txtUrl.Text = "http://"; } txtUrl.Visible = true; cmdSelect.Visible = true; cboUrls.Items.Clear(); cboUrls.DataSource = objUrls.GetUrls(_objPortal.PortalID); cboUrls.DataBind(); if (cboUrls.Items.FindByValue(_Url) != null) { cboUrls.Items.FindByValue(_Url).Selected = true; } cboUrls.Visible = false; cmdAdd.Visible = false; cmdDelete.Visible = false; break; case "T": // tab URLRow.Visible = false; TabRow.Visible = true; FileRow.Visible = false; UserRow.Visible = false; cboTabs.Items.Clear(); cboTabs.DataSource = Globals.GetPortalTabs(_objPortal.PortalID, !_Required, true, false, false, false); cboTabs.DataBind(); if (cboTabs.Items.FindByValue(_Url) != null) { cboTabs.Items.FindByValue(_Url).Selected = true; } break; case "F": // file URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = true; UserRow.Visible = false; LoadFolders(); if (cboFolders.Items.Count == 0) { lblMessage.Text = Localization.GetString("NoPermission", this.LocalResourceFile); FileRow.Visible = false; return; } // select folder string FileName; string FolderPath; if (_Url != string.Empty) { FileName = _Url.Substring(_Url.LastIndexOf("/") + 1); FolderPath = _Url.Replace(FileName, ""); } else { FileName = _Url; FolderPath = string.Empty; } if (cboFolders.Items.FindByValue(FolderPath) != null) { cboFolders.Items.FindByValue(FolderPath).Selected = true; } else { cboFolders.Items[0].Selected = true; FolderPath = cboFolders.SelectedValue; } //cboFiles.DataSource = GetFileList(FileFilter, !_Required, cboFolders.SelectedItem.Value); cboFiles.DataSource = GetFileList(!_Required); cboFiles.DataBind(); if (cboFiles.Items.FindByText(FileName) != null) { cboFiles.Items.FindByText(FileName).Selected = true; } cboFiles.Visible = true; txtFile.Visible = false; string strWriteRoles = GetWriteRoles(FolderPath); cmdUpload.Visible = PortalSecurity.IsInRoles(strWriteRoles) && _ShowUpLoad; SetStorageLocationType(); txtUrl.Visible = false; cmdSave.Visible = false; cmdCancel.Visible = false; break; case "M": // membership users URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = true; if (txtUser.Text == "") { txtUser.Text = _Url; } break; } }