List <IdAndName> GetFileResource(DbHelper.ActAndRes helper, string fileName) { var list = new List <IdAndName>(); switch (fileName) { case "DownloadingPage.aspx": break; case "FileResourceCreate.aspx": list.Add(new IdAndName() { Name = "File-Resource edit" }); break; case "FileResourceView.aspx": var fileId = Request.QueryString["arId"]; var file = helper.GetFileResource(Convert.ToInt32(fileId)); list.Add(new IdAndName() { Name = file.Name }); break; } return(list); }
private void LoadFileResource() { using (var helper = new DbHelper.ActAndRes()) { var files = new List <FileResourceEventArgs>(); var fileR = helper.GetFileResource(FileResourceId); if (fileR != null) { txtName.Text = fileR.Name; CKEditor1.Text = fileR.Description; chkDisplayDescription.Checked = fileR.ShowDescriptionOnCoursePage; chkShowSize.Checked = fileR.ShowSize; chkShowType.Checked = fileR.ShowType; chkShowUploadModifiedDate.Checked = fileR.ShowUploadModifiedDate; ddlDisplay.SelectedIndex = fileR.Display; var i = 1; foreach (var f in fileR.FileResourceFiles) { files.Add(new FileResourceEventArgs() { Id = f.SubFileId, Visible = true, FileType = f.SubFile.FileType, IconPath = f.SubFile.IconPath, FilePath = f.SubFile.FileDirectory + "/" + f.SubFile.FileName, FileDisplayName = f.SubFile.DisplayName, FileSizeInBytes = f.SubFile.FileSizeInBytes , LocalId = i.ToString() }); i++; } FilesDisplay1.SetInitialValues(files); RestrictionUC.SetActivityResource(false, ((int)Enums.Resources.File) + 1, fileR.Id); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //var SubId=19&arId=2&secId=2&edit=1 var subId = Request.QueryString["SubId"]; var arId = Request.QueryString["arId"]; var secId = Request.QueryString["secId"]; var edit = Request.QueryString["edit"]; try { if (arId != null) { #region File Resource FileResourceId = Convert.ToInt32(arId); using (var helper = new DbHelper.ActAndRes()) { var fileRes = helper.GetFileResource(FileResourceId); if (fileRes != null) { lblHeading.Text = fileRes.Name; lblTitle.Text = fileRes.Name; var file = helper.GetFileOfFileResource(fileRes.MainFileId ?? 0); if (file != null) { var fullPath = file.SubFile.FileDirectory + file.SubFile.FileName; if (fullPath == "") { pnlError.Visible = true; } pnlError.Visible = true; //ProcessRequest(Context, fullPath); switch (fileRes.Display) { case 0: frame.Src = fullPath; break; case 1: //embed//iframe frame.Src = fullPath; break; case 2: //force donload ProcessRequest(Context, fullPath); break; case 3: //open//only file in same window break; case 4: //popup if (subId != null && edit != null && secId != null) { OpenWindow(fullPath); Response.Redirect( "~/Views/Course/Section/Master/CourseSectionListing.aspx" + "?SubId" + subId + "&edit=" + edit); } break; } } else { pnlError.Visible = true; } } else { pnlError.Visible = true; } } #endregion } } catch { } } }