private void menuUpload_Click(object sender, EventArgs e) { /* int selectedResource = GetSelectedTreeResource(); * if (selectedResource <= 0) * { * MessageBox.Show("请选择一个目录", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } */ try { int selectedResource = GetSelectedTreeResource(); CACLEntity acl = new CACLEntity(MidLayerSettings.ConnectionString); acl.Acl_Resource = selectedResource; acl.Acl_Operation = (int)ACLOPERATION.WRITE; if (!_currentUser.CheckPrivilege(acl)) { MessageBox.Show("没有写权限!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } OpenFileDialog objFile = new OpenFileDialog(); objFile.FileOk += new CancelEventHandler(objFile_FileOk); objFile.MaxFileSize = 1000000; //objFile.Filter = "Image files(*.bmp;*.gif;*.jpg)|*.bmp;*.gif;*.jpg"; objFile.Multiselect = true; objFile.ShowDialog(); } catch (Exception ex) { MessageBox.Show("警告:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
public virtual void CreateFolder(CUserEntity user, int parentResource, String folderName) { CACLEntity acl = new CACLEntity(user.ConnString); acl.Acl_Resource = parentResource; acl.Acl_Operation = (int)ACLOPERATION.WRITE; if (!user.CheckPrivilege(acl)) { throw new Exception("没有写权限!"); } user.CreateFolder(parentResource, folderName); }
/// <summary> /// 更新文件——赵英武 /// </summary> /// <param name="user"></param> /// <param name="resId"></param> /// <param name="objFileDialog"></param> public virtual void Update(CUserEntity user, int resId, OpenFileDialog objFileDialog) { CACLEntity acl = new CACLEntity(user.ConnString); acl.Acl_Resource = resId; acl.Acl_Operation = (int)ACLOPERATION.WRITE; if (!user.CheckPrivilege(acl)) { throw new Exception("没有写权限!"); } String filePath; HttpPostedFileHandle hfh = (HttpPostedFileHandle)objFileDialog.Files[0]; CResourceEntity res = new CResourceEntity().Load(resId); user.UpdateFile(resId, hfh.PostedFileName, out filePath); hfh.SaveAs(filePath); }
public virtual void DeleteFolder(CUserEntity user, int resource) { CACLEntity acl = new CACLEntity(user.ConnString); acl.Acl_Resource = resource; acl.Acl_Operation = (int)ACLOPERATION.WRITE; if (!user.CheckPrivilege(acl)) { throw new Exception("没有写权限!"); } CResourceEntity res = new CResourceEntity(user.ConnString).Load(resource); String dirPath = res.MakeFullPath(); user.DeleteResource(resource); System.IO.Directory.Delete(dirPath, true); }
public virtual void UploadFile(CUserEntity user, int parentResource, OpenFileDialog objFileDialog) { CACLEntity acl = new CACLEntity(user.ConnString); acl.Acl_Resource = parentResource; acl.Acl_Operation = (int)ACLOPERATION.WRITE; if (!user.CheckPrivilege(acl)) { throw new Exception("没有写权限!"); } for (int i = 0; i < objFileDialog.Files.Count; i++) { String filePath; HttpPostedFileHandle hfh = (HttpPostedFileHandle)objFileDialog.Files[i];; user.CreateFile(parentResource, hfh.PostedFileName, out filePath); hfh.SaveAs(filePath); } }
private void AddResource(int resourceId) { CACLEntity acl = new CACLEntity(); acl.Acl_Resource = resourceId; acl.Acl_Operation = (int)ACLOPERATION.WRITE; if (!_currentUser.CheckPrivilege(acl)) { throw new Exception("没有写权限!"); } foreach (int res in _resources) { if (res == resourceId) { return; } } _resources.Add(resourceId); }
IGatewayHandler IGatewayControl.GetGatewayHandler(IContext objContext, string strAction) { if (strAction == "Download") { //objContext.HttpContext.Response.ContentType = "image/jpeg"; int res = (int)fileListView.SelectedItems[0].Tag; CACLEntity acl = new CACLEntity(_currentUser.ConnString); acl.Acl_Operation = (int)ACLOPERATION.READ; acl.Acl_Resource = res; acl.Acl_Role = _currentUser.Usr_Id; acl.Acl_RType = (int)ACLROLETYPE.USERROLE; if (!_currentUser.CheckPrivilege(acl)) { return(null); } CResourceEntity resource = new CResourceEntity(_currentUser.ConnString).Load(res); String fileName = "attachment; filename=\"" + resource.Res_Name + "\""; String fullPath = resource.MakeFullPath(); objContext.HttpContext.Response.AddHeader("content-disposition", fileName); objContext.HttpContext.Response.WriteFile(fullPath); } return(null); }
private void MainForm_Load(object sender, EventArgs e) { //this.Menu = mainMenu1; _currentUser = (CUserEntity)Context.Session["CurrentUser"]; try { myDirTree.CurrentUser = _currentUser; myDirTree.RootResourceId = _currentUser.Usr_Resource; archiveDirTree.CurrentUser = _currentUser; archiveDirTree.RootResourceId = _currentUser.GetUserOrganize().Org_ArchiveRes; _myFileList.CurrentUser = _currentUser; _archiveFileLst.CurrentUser = _currentUser; shareDirTree.CurrentUser = _currentUser; shareDirTree.Helper = new ShareHelpClass(); _shareFileList.CurrentUser = _currentUser; _userList.CurrentUser = _currentUser; _groupList.CurrentUser = _currentUser; _userUpdate.CurrentUser = _currentUser; _myApply.CurrentUser = _currentUser; _auditeApply.CurrentUser = _currentUser; orgMgerDirTree.CurrentUser = _currentUser; orgMgerDirTree.RootResourceId = _currentUser.GetUserOrganize().Org_Resource; _orgMgerList.CurrentUser = _currentUser; _orgMemo.CurrentUser = _currentUser; _mailSet.CurrentUser = _currentUser; // Create resource clipboard and save in session ResourceClip clipBoard = new ResourceClip(); Context.Session["ResourceClipBoard"] = clipBoard; //系统管理 List <CFunction> systemFunctions = new List <CFunction>(); CFunction function = new CFunction(); function.Name = "备份"; function.Ui = _orgMemo; function.Image = new IconResourceHandle("save.gif"); systemFunctions.Add(function); function = new CFunction(); function.Name = "用户管理"; function.Image = new IconResourceHandle("member.png"); function.Ui = _userList; systemFunctions.Add(function); function = new CFunction(); function.Name = "用户组管理"; function.Image = new IconResourceHandle("member.png"); function.Ui = _groupList; systemFunctions.Add(function); function = new CFunction(); function.Name = "系统配置"; function.Image = new IconResourceHandle("properties.gif"); function.Ui = _mailSet; systemFunctions.Add(function); this.sysFunctionTree.FunctionList = systemFunctions; this.sysFunctionTree.TreeEvent += FunctionTreeEventHandler; //我的信息 List <CFunction> myinfoFunctions = new List <CFunction>(); // function = new CFunction(); // function.Name = "安全信息"; // function.Image = new IconResourceHandle("importantmail.gif"); // myinfoFunctions.Add(function); // function = new CFunction(); // function.Name = "其它信息"; // function.Image = new IconResourceHandle("member.gif"); // myinfoFunctions.Add(function); function = new CFunction(); function.Name = "修改个人资料"; function.Image = new IconResourceHandle("member.gif"); function.Ui = _userUpdate; myinfoFunctions.Add(function); function = new CFunction(); function.Name = "审核归档申请"; function.Image = new IconResourceHandle("member.gif"); function.Ui = _auditeApply; CACLEntity acl = new CACLEntity(); acl.Acl_Operation = (int)ACLOPERATION.AUDITAPPLY; acl.Acl_Resource = _currentUser.Usr_Organize; if (_currentUser.CheckPrivilege(acl) == true) { myinfoFunctions.Add(function); } function = new CFunction(); function.Name = "我的归档申请"; function.Image = new IconResourceHandle("member.gif"); function.Ui = _myApply; myinfoFunctions.Add(function); this.myinfofunctionTree.FunctionList = myinfoFunctions; this.myinfofunctionTree.TreeEvent += FunctionTreeEventHandler; //我的文档 // myDirTree.RootDir = Context.Server.MapPath("~/App_Data"); //myDirTree.RootDir = Context.Server.MapPath("~/"+ConfigurationManager.AppSettings["Userdata"]); myDirTree.RootDir = ConfigurationManager.AppSettings["UserData"]; myDirTree.Init(); myDirTree.FileListUI = _myFileList; myDirTree.TreeEvent += DirTreeEventHandler; myDirTree.SearchEvent += DirTreeSearchEventHandler; //共享空间 /* * List<CFunction> shareSpaceFunctionList = new List<CFunction>(); * function = new CFunction(); * function.Name = "我共享给他人的文档"; * function.Image = new IconResourceHandle("folders.gif"); * shareSpaceFunctionList.Add(function); * function = new CFunction(); * function.Name = "他人共享给我的文档"; * function.Image = new IconResourceHandle("folders.gif"); * shareSpaceFunctionList.Add(function); * shareSpacefunctionTree.FunctionList = shareSpaceFunctionList; */ shareDirTree.Init(); shareDirTree.FileListUI = _shareFileList; shareDirTree.TreeEvent += DirTreeEventHandler; shareDirTree.SearchEvent += DirTreeSearchEventHandler; //归档区 //archiveDirTree.RootDir = Context.Server.MapPath("~/App_Data"); archiveDirTree.RootDir = ConfigurationManager.AppSettings["UserData"]; archiveDirTree.Init(); archiveDirTree.FileListUI = _archiveFileLst; archiveDirTree.TreeEvent += DirTreeEventHandler; archiveDirTree.SearchEvent += DirTreeSearchEventHandler; //组织管理——赵英武 // orgMgerDirTree.RootDir = Context.Server.MapPath("~/App_Data"); orgMgerDirTree.RootDir = ConfigurationManager.AppSettings["UserData"]; orgMgerDirTree.Init(); orgMgerDirTree.FileListUI = _orgMgerList; orgMgerDirTree.TreeEvent += DirTreeEventHandler; orgMgerDirTree.SearchEvent += DirTreeSearchEventHandler; systemPage.Image = new IconResourceHandle("24X24.applications.gif"); myInfoPage.Image = new IconResourceHandle("24X24.behaviors.gif"); myDocPage.Image = new IconResourceHandle("24X24.controls.gif"); shareSpaceTab.Image = new IconResourceHandle("24X24.sharedspace.gif"); archiveTab.Image = new IconResourceHandle("24X24.folders.gif"); orgManageTab.Image = new IconResourceHandle("24X24.orgAdmin.gif"); // only administrator can see system admin page if (_currentUser.Usr_Type != (int)USERTYPE.ORGANIZEADMIN && _currentUser.Usr_Type != (int)USERTYPE.SYSTEMADMIN) { leftNavigationTabs.Controls.Remove(systemPage); } //only orgnizeAdministrator can see orgnize admin page if (_currentUser.Usr_Type != (int)USERTYPE.ORGANIZEADMIN) { leftNavigationTabs.Controls.Remove(orgManageTab); } } catch (Exception ex) { MessageBox.Show("系统错误:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OKBtn_Click(object sender, EventArgs e) { String targetText = targetBox.Text; if (targetText.Length <= 0) { MessageBox.Show("请填写检索内容!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <String> searchScopes = new List <string>(); if (currentDirBox.Checked) { CResourceEntity res = new CResourceEntity().Load(_resource); String curDir = res.MakeFullPath(); searchScopes.Add(curDir); } if (myDirBox.Checked) { int myDirId = _currentUser.Usr_Resource; CResourceEntity res = new CResourceEntity().Load(myDirId); String myDir = res.MakeFullPath(); searchScopes.Add(myDir); } if (archiveDirBox.Checked) { int archiveId = _currentUser.GetUserOrganize().Org_ArchiveRes; CACLEntity acl1 = new CACLEntity(); acl1.Acl_Resource = archiveId; acl1.Acl_Operation = (int)ACLOPERATION.READ; if (_currentUser.CheckPrivilege(acl1)) { CResourceEntity res = new CResourceEntity().Load(archiveId); String archiveDir = res.MakeFullPath(); searchScopes.Add(archiveDir); } else { List <CResourceEntity> ress = _currentUser.ListDescendants(archiveId); foreach (CResourceEntity res in ress) { searchScopes.Add(res.MakeFullPath()); } } } if (shareDirBox.Checked) { List <CResourceEntity> ress = _currentUser.ListShareResources(); foreach (CResourceEntity res in ress) { searchScopes.Add(res.MakeFullPath()); } } _result.Clear(); foreach (String s in searchScopes) { SearchFullText(targetText, s); } this.DialogResult = DialogResult.OK; Close(); }