public ActionResult Download(int id) { var data = FileBLL.Get(id); string filePath = Server.MapPath("~/upload/" + data.FILEURL); return(File(filePath, "application/vnd.android", data.FILENAME)); }
public ActionResult DeleteRows(JArray selectedRows, JArray FileManageGrid_fields, string fileName, int FileManageGrid_pageIndex, int FileManageGrid_pageSize) { var ids = new List <int>(); foreach (var id in selectedRows) { ids.Add(Convert.ToInt32(id)); } var isSuccess = FileBLL.Delete(ids.ToArray()); if (isSuccess) { ShowNotify("数据删除成功!"); } else { ShowNotify("数据删除失败!"); } var grid1 = UIHelper.Grid("FileManageGrid"); var recordCount = 0; var data = FileBLL.GetList(fileName, FileManageGrid_pageIndex + 1, FileManageGrid_pageSize, out recordCount); grid1.RecordCount(recordCount); grid1.DataSource(data, FileManageGrid_fields); return(UIHelper.Result()); }
private void toolStripButton2_Click(object sender, EventArgs e) { frmUpload frm = new frmUpload(); DialogResult dlg = frm.ShowDialog(); if (dlg == System.Windows.Forms.DialogResult.OK) { SetPermission(frm); //刷新网格 string str = frm.Status; if (str == "personal") { DataTable dt = new FileBLL().GetFileByUser(LoginUser.UserId, Convert.ToInt32(frm.SelectFid)); this.skinDataGridView1.DataSource = dt; if (dt != null && dt.Rows.Count > 0) { skinDataGridView1.Rows[0].Selected = false; } this.skinGroupBox1.Text = "[" + frm.Fname + "]" + "共" + dt.Rows.Count + "份文档(下列文档点击右键可以进行操作)"; } else { DataTable dt = new FileBLL().GetFileByDepartment(frm.Depid); this.skinDataGridView1.DataSource = dt; if (dt != null && dt.Rows.Count > 0) { skinDataGridView1.Rows[0].Selected = false; } this.skinGroupBox1.Text = "[" + frm.Fname + "]" + "共" + dt.Rows.Count + "份文档(下列文档点击右键可以进行操作)"; } } }
public static IList <FolderRelation> ResourceFolderTree(IList <FolderRelation> movedFolders) { var user = UserService.CurrentUser; //用户所有的课程 IList <OC> ocs = UserService.User_OC_List(user); IList <FolderRelation> roots = new List <FolderRelation>(); FolderRelation fr = new FolderRelation(); fr.Id = 0; fr.Name = "个人资料"; fr.ParentID = 0; fr.RelationType = FileType.None; roots.Add(fr); foreach (var item in ocs) { fr = new FolderRelation(); fr.Id = item.OCID; fr.Name = item.Name; fr.ParentID = 0; fr.OCID = item.OCID; fr.RelationType = FileType.None; roots.Add(fr); } IList <FolderRelation> relationFolders = new List <FolderRelation>(); IList <Folder> folders = new FileBLL().Folder_ALL_Tree(user.UserID); foreach (var item in folders) { var exists = from v in movedFolders where item.FolderID == v.Id && v.RelationType == FileType.Folder select v; if (exists.Any()) { continue; } fr = new FolderRelation(); fr.Id = item.FolderID; fr.Name = item.FolderName; //fr.ParentID = item.ParentID == 0 ? item.OCID : item.ParentID; fr.ParentID = item.ParentID; fr.RelationType = FileType.Folder; fr.OCID = item.OCID; relationFolders.Add(fr); } var rootFolders = from v in relationFolders where v.ParentID == 0 select v; foreach (var rootFolder in rootFolders) { BuildRelationFolder(relationFolders, rootFolder); var root = from v in roots where v.OCID == rootFolder.OCID select v; if (root.Any()) { root.First().Children.Add(rootFolder); } } return(roots); }
/// <summary> /// 费彬彬2017-05-12编写岗位树 /// </summary> /// <param name="node"></param> private void CreatePositionTree() { try { TreeNode node = new TreeNode(); node.Name = "-1"; node.Text = "岗位文件"; skinTreeViewGW.Nodes.Add(node); cPositionTree(node); skinTreeViewGW.NodeMouseClick += (s, e) => { if (e.Button == MouseButtons.Left) { User u = e.Node.Tag as User; if (u != null) { DataTable dt = new FileBLL().GetFileByUserId(u.UserID); this.skinDataGridView1.DataSource = dt; if (dt != null && dt.Rows.Count > 0) { skinDataGridView1.Rows[0].Selected = false; } this.skinGroupBox1.Text = "[" + e.Node.Text + "]" + "共" + dt.Rows.Count + "份文档(下列文档点击右键可以进行操作)"; } } }; skinTreeViewGW.ExpandAll(); } catch (Exception b) { throw new Exception(b.Message.ToString()); } }
protected void btnSearchPlanReplace_Click(object sender, EventArgs e) { Position position = currentPosition; File searchPlan = FileBLL.SavePDF(fileSearchPlanReplace, SearchPlanFileType); if (searchPlan != null) { //Delete the old file FileBLL.DeletePDF(position.SearchPlanFile); //Save the new reference using (var ts = new TransactionScope()) { position.SearchPlanFile = searchPlan; PositionBLL.EnsurePersistent(position); ts.CommitTransaction(); } } else { lblInvalidSearchPlanFileType.Text = " *Job Description Must Be a PDF File"; } }
private string[] LoadData(string fileid) { var lst = new FileBLL().GetOne(Convert.ToInt32(fileid)); ; if (lst != null && lst.Count > 0) { try { var fpath = string.Format("{0}\\temp", Application.StartupPath); if (!Directory.Exists(fpath)) { Directory.CreateDirectory(fpath); } //生成本地文件 var Files = (Byte[])lst[0].FileData; var name = GenerateCheckCode(20); var ext = lst[0].FileExt.ToLower(); var path = string.Format("{0}\\temp\\{1}.{2}", Application.StartupPath, name, ext); var bw = new BinaryWriter(System.IO.File.Open(path, FileMode.OpenOrCreate)); bw.Write(Files, 0, Files.Length); bw.Flush(); bw.Close(); return(new string[] { name, ext, path, lst[0].FileName }); } catch { //奇葩文件不报错 } } return(null); }
private void 归档ToolStripMenuItem_Click(object sender, EventArgs e) { string fileid = skinDataGridView1.CurrentRow.Cells["FileId"].Value.ToString(); bool check = AuthPermission.Auth(LoginUser.UserId, Convert.ToInt32(fileid), FilePermission.Archive); if (check) { DialogResult dlg = MessageBox.Show("是否归档该文件", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlg == System.Windows.Forms.DialogResult.Yes) { bool c = new FileBLL().UpdateFileArchive(Convert.ToInt32(fileid), true); if (c) { MessageBox.Show("归档该文件成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("归档该文件失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } else { MessageBox.Show("您没有权限归档该文件", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void UploadPublications() { FileType publicationsFileType = FileTypeBLL.GetByName(STR_Publication); Application application = selectedApplication; File file = FileBLL.SavePDF(fileUpload, publicationsFileType); using (var ts = new TransactionScope()) { if (file != null) { application.Files.Add(file); ApplicationBLL.EnsurePersistent(application); lblStatus.Text = "File Uploaded Successfully"; } else { lblStatus.Text = "File Upload Did Not Succeed: Ensure That File Is A PDF File"; } ts.CommitTransaction(); } rptPublications.DataSource = GetFilesOfType(STR_Publication); rptPublications.DataBind(); }
protected void ibtnPublicationsRemoveFile_Click(object sender, EventArgs e) { int FileID = 0; bool success = false; success = int.TryParse(((ImageButton)sender).CommandArgument, out FileID); if (success) { File fileToDelete = FileBLL.GetByID(FileID); using (var ts = new TransactionScope()) { FileBLL.DeletePDF(fileToDelete); //Update the current application Application application = selectedApplication; application.Files.Remove(fileToDelete); ApplicationBLL.EnsurePersistent(application); ts.CommitTransaction(); } } rptPublications.DataSource = GetFilesOfType(STR_Publication); rptPublications.DataBind(); }
public static List <File> File_Search(File file, int PageSize, int PageIndex) { IFileBLL filebll = new FileBLL(); List <File> File_List = filebll.File_Search(file, PageSize, PageIndex); return(File_List); }
private void UploadFiles() { FileType selectedFileType = FileTypeBLL.GetByID(int.Parse(dlistFileTypes.SelectedValue)); //For all fileTypes except for Publications we should remove existing files if (selectedFileType.FileTypeName != STR_Publication && selectedFileType.FileTypeName != STR_LetterOfRec) { RemoveAllFilesOfType(selectedFileType.FileTypeName); } File file = FileBLL.SavePDF(fileUpload, selectedFileType); using (var ts = new TransactionScope()) { if (file != null) { Application application = selectedApplication; application.Files.Add(file); ApplicationBLL.EnsurePersistent(application); lblStatus.Text = "File Uploaded Successfully"; } else { lblStatus.Text = "File Upload Did Not Succeed: Ensure That File Is A PDF File"; } ts.CommitTransaction(); } }
public ActionResult Delete(List <IdList> IdList) { if (IdList != null && IdList.Count > 0) { foreach (IdList value in IdList) { if (value.Type.Equals("Folder")) { if (FolderBLL.DeleteById(value.Id) == false) { ResponseHelper.WriteFalse(Response); return(null); } } else { if (FileBLL.DeleteById(value.Id) == false) { ResponseHelper.WriteFalse(Response); return(null); } } } ResponseHelper.WriteTrue(Response); } return(null); }
/// <summary> /// Close the position and upload the final recruitment report /// </summary> protected void ClosePosition(object sender, EventArgs e) { Position position = CurrentPosition; File finalRecruitmentReport = FileBLL.SavePDF(fileFinalRecruitmentReport, FinalRecruitmentReportFileType); if (finalRecruitmentReport != null) { //Delete the old file if (position.FinalRecruitmentReportFile != null) { FileBLL.DeletePDF(position.FinalRecruitmentReportFile); } //Save the new reference using (var ts = new TransactionScope()) { position.FinalRecruitmentReportFile = finalRecruitmentReport; position.Closed = true; PositionBLL.EnsurePersistent(position); ts.CommitTransaction(); } Response.Redirect("ClosePositionSuccess.aspx"); } else { lblFileError.Text = "Uploaded File Must Be In PDF Format"; } }
/// <summary> /// Generates a list of all files associated with this application /// </summary> private void DataBindFiles() { List <File> fileList = new List <File>(currentApplication.Files); gviewFiles.DataSource = FileBLL.Sort(fileList, SortDirection.Ascending); gviewFiles.DataBind(); }
private void jddy() { List <MovieInfoModel> list = new FileBLL().SelectMovieInfo(1, 2); var jsondata = JsonConvert.SerializeObject(list); Response.Write(jsondata); Response.End(); }
private void LoadData() { var recordCount = 0; var data = FileBLL.GetList("", 1, 20, out recordCount); ViewBag.Grid1RecordCount = recordCount; ViewBag.Grid1DataSource = data; }
public ActionResult Get(String FolderId) { User user = Session["User"] as User; int folderId = 1; if (FolderId != null) { folderId = Convert.ToInt32(FolderId); } if (user == null) { ResponseHelper.WriteNull(Response); } else { if (folderId == 1) { var fileList = FileBLL.GetRootByUserId(user.Id); var folderList = FolderBLL.GetRootByUserId(user.Id); var dataList = new List <DataList>(); foreach (var v in fileList) { dataList.Add(new DataList { Id = v.Id, Type = v.Type, Size = v.Size, UpdateTime = v.UpdateTime, Name = v.Name }); } foreach (var v in folderList) { dataList.Add(new DataList { Id = v.Id, Type = "Folder", Size = "-", UpdateTime = v.UpdateTime, Name = v.Name }); } ResponseHelper.WriteObject(Response, new { DataList = dataList }); } else { var fileList = FileBLL.GetByFolderId(folderId); var folderList = FolderBLL.GetByFolderId(folderId); var dataList = new List <DataList>(); foreach (var v in fileList) { dataList.Add(new DataList { Id = v.Id, Type = v.Type, Size = v.Size, UpdateTime = v.UpdateTime, Name = v.Name }); } foreach (var v in folderList) { dataList.Add(new DataList { Id = v.Id, Type = "Folder", Size = "-", UpdateTime = v.UpdateTime, Name = v.Name }); } ResponseHelper.WriteObject(Response, new { DataList = dataList }); } } return(null); }
protected void btnDownloadAllPlusReferences_Click(object sender, EventArgs e) { bool success = FileBLL.DownloadByApplication(currentApplication, true); //Include references if (!success) { lblDownloadAllStatus.Text = "Files could not be combined successfully."; } }
public ActionResult FileManageGrid_PageIndexChanged(JArray FileManageGrid_fields, string fileName, int FileManageGrid_pageIndex, int FileManageGrid_pageSize) { var grid1 = UIHelper.Grid("FileManageGrid"); var recordCount = 0; var data = FileBLL.GetList(fileName, FileManageGrid_pageIndex + 1, FileManageGrid_pageSize, out recordCount); grid1.RecordCount(recordCount); grid1.DataSource(data, FileManageGrid_fields); return(UIHelper.Result()); }
public static IList <Folder> Folder_List(Folder folder) { if (!IES.Service.UserService.OC_IsRole(folder.OCID)) { return(null); } folder.CreateUserID = IES.Service.UserService.CurrentUser.UserID; IList <Folder> allFolders = new FileBLL().Folder_List(folder); return(allFolders); }
/// <summary> /// 顾挺2017-05-11编写加载跟人树示例 /// </summary> /// <param name="node"></param> private void CreatePersonlTree() { try { TreeNode node = new TreeNode(); //定义根节点 node.Name = "-1"; //将类Model的各个属性赋值给根节点 node.Text = "个人文件"; TreeNode node1 = new TreeNode(); node1.Name = "-1"; node1.Text = "我的借阅"; skinTreeViewPersonl.Nodes.Add(node); skinTreeViewPersonl.Nodes.Add(node1); cFilePersonlTree(node, node.Name); //调用另一个方法为根节点添加其他子节点 skinTreeViewPersonl.NodeMouseClick += (s, e) => { if (e.Button == MouseButtons.Left) { if (!string.IsNullOrEmpty(e.Node.Name)) { if (e.Node.Text == "我的借阅") { DataTable dt = new File_ShareBLL().GetFile_Share(LoginUser.UserId); this.skinDataGridView1.DataSource = dt; if (dt != null && dt.Rows.Count > 0) { skinDataGridView1.Rows[0].Selected = false; } this.skinGroupBox1.Text = "[" + e.Node.Text + "]" + "共" + dt.Rows.Count + "份文档(下列文档点击右键可以进行操作)"; } else { DataTable dt = new FileBLL().GetFileByUser(LoginUser.UserId, Convert.ToInt32(e.Node.Name)); this.skinDataGridView1.DataSource = dt; if (dt != null && dt.Rows.Count > 0) { skinDataGridView1.Rows[0].Selected = false; } this.skinGroupBox1.Text = "[" + e.Node.Text + "]" + "共" + dt.Rows.Count + "份文档(下列文档点击右键可以进行操作)"; } } } }; skinTreeViewPersonl.ExpandAll(); //展开所有节点 } catch (Exception e) { throw new Exception(e.Message.ToString()); } }
public ActionResult Delete() { if (Request["Id"] != null && Request["id"] != "") { int id = Convert.ToInt32(Request["Id"]); if (FileBLL.DeleteById(id)) { ResponseHelper.WriteTrue(Response); } } ResponseHelper.WriteFalse(Response); return(null); }
/// <summary> /// Downloads the file given by FileID /// </summary> /// <param name="FileID">FileID of the File to Download</param> /// <returns>true if file is found successfully</returns> private bool DownloadFile(int FileID) { File fileToDownload = FileBLL.GetNullableByID(FileID); if (fileToDownload == null) { return(false); } else { return(FileBLL.Transmit(fileToDownload.ID, fileToDownload.FileName)); } }
public ActionResult UpdateName() { if (Request["Id"] != null && Request["Name"] != null && Request["Id"] != "" && Request["Name"] != "") { int id = Convert.ToInt32(Request["Id"]); string name = Request["Name"]; if (FileBLL.UpdateNameById(id, name)) { ResponseHelper.WriteTrue(Response); } } ResponseHelper.WriteFalse(Response); return(null); }
//部门上传 private void button5_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBox2.Text)) { MessageBox.Show("请选择上传文件!", "系统提示"); return; } //获得目录编号,其子文件,都在父编号添加数据 var t = comboBox2.SelectedItem as Department; if (t != null) { if (comboBox2.SelectedItem as Department == null) { return; } _depid = (comboBox2.SelectedItem as Department).DepartmentID; var fname = comboBox2.Text.Trim(); _fname = fname; string aFirstName = this.textBox2.Text.Substring(this.textBox2.Text.LastIndexOf("\\") + 1, (this.textBox2.Text.LastIndexOf(".") - this.textBox2.Text.LastIndexOf("\\") - 1)); //文件名 string aLastName = this.textBox2.Text.Substring(this.textBox2.Text.LastIndexOf(".") + 1, (this.textBox2.Text.Length - this.textBox2.Text.LastIndexOf(".") - 1)); //扩展名 byte[] tmpfile = FileKit.GetFileData(this.textBox2.Text); File file = new File { FileName = aFirstName, FileCreateTime = DateTime.Now, FileExt = aLastName, FileData = tmpfile, FilePID = -1, FileSize = tmpfile.Length, UserID = LoginUser.UserId }; NewFileId = new FileBLL().AddFileDep(file, _depid); if (NewFileId > 0) { _status = "department"; this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("文件添加失败!", "系统提示"); } } else { MessageBox.Show("请选择对应目录!", "系统提示"); } }
private void loadMovieInfo() { PageNum = 0; //记录返回的电影数量 int Count; List <MovieInfoModel> list = new FileBLL().SelectPageMovieType(PageSize, PageNum, out Count, Request["MovieType"], Request["MovieArea"], Request["MovieYears"]); PageNow = list.Count > 0 ? 1 : 0; PageCount = (Count % PageSize) > 0 ? (Count / PageSize) + 1 : (Count / PageSize); var jsondata = JsonConvert.SerializeObject(list); Response.Write(jsondata); Response.End(); }
/// <summary> /// Downloads the current position description /// </summary> protected void lbtnDownloadPD_Click(object sender, EventArgs e) { File descriptionFile = currentPosition.DescriptionFile; if (descriptionFile == null) { throw new NullReferenceException(string.Format("Description File Not Found For Position {0}", currentPosition.ID)); } bool transmitSuccess = FileBLL.Transmit(descriptionFile.ID, descriptionFile.FileName); if (transmitSuccess == false) { throw new NullReferenceException(string.Format("Description File Not Found For Position {0}", currentPosition.ID)); } }
private void skinButton3_Click(object sender, EventArgs e) { _key = this.skinTextBox1.SkinTxt.Text.Trim(); if (!string.IsNullOrEmpty(_key) || !string.IsNullOrEmpty(this.comboBox1.Text) || !string.IsNullOrEmpty(this.skinTextBox2.SkinTxt.Text) || !string.IsNullOrEmpty(this.dateTimePicker1.Text) || !string.IsNullOrEmpty(this.dateTimePicker2.Text)) { Segment segment = new Segment(); ICollection <WordInfo> words = segment.DoSegment(_key); DataTable dt = new FileBLL().SeniorFindFile(words, this.comboBox1.Text, this.skinTextBox2.SkinTxt.Text, Convert.ToDateTime(this.dateTimePicker1.Value), Convert.ToDateTime(this.dateTimePicker2.Value)); _dresult = dt; DialogResult = DialogResult.OK; } else { MessageBox.Show("请输入查询的关键词!", "系统提示"); } }
public ActionResult GetContent(String Id, String fileName) { int id = Convert.ToInt32(Id); File file = FileBLL.GetById(id); if (file != null) { var fileContent = FileContentBLL.GetById(file.FileContentId); Response.ContentType = file.Type; FileResult result = File(fileContent.Data, file.Type, fileName); return(result); } return(RedirectToAction("Index", "Error")); }
public static List<File> File_Search(File file, int PageSize, int PageIndex) { IFileBLL filebll = new FileBLL(); List<File> File_List = filebll.File_Search(file, PageSize, PageIndex); return File_List; }