protected CUserEntity CreateUser(CUserEntity newUser) { try { COrganizeEntity organize = new COrganizeEntity(_connString); List <COrganizeEntity> organizelst = new List <COrganizeEntity>(); organizelst = organize.GetObjectList("this.Org_Name ='" + _orgName + "'"); int orgRes = organizelst[0].Org_Resource; // create resource for user's folder CResourceEntity folderRes = new CResourceEntity(_connString); folderRes.Res_Name = ""; folderRes.Res_Parent = orgRes; folderRes.Res_Type = (int)RESOURCETYPE.FOLDERRESOURCE; folderRes.Res_Id = folderRes.Insert(); folderRes.Res_Name = folderRes.Res_Id.ToString() + newUser.Usr_Member; folderRes.Update(); // create user's folder //String userPath = folderRes.MakeFullPath(); String userPath = _rootPath + "\\" + folderRes.Res_Name; Directory.CreateDirectory(userPath); // create user newUser.Usr_Resource = folderRes.Res_Id; newUser.ConnString = _connString; newUser.Usr_Id = newUser.Insert(); return(newUser); } catch (Exception e) { throw e; } }
public COrganizeEntity CreateOrganize(String organizeName) { try { // create resource for this organize CResourceEntity res = new CResourceEntity(_connString); res.Res_Name = _orgName; res.Res_Parent = 0; res.Res_Type = (int)RESOURCETYPE.ORGANIZERESOURCE; res.Res_Id = res.Insert(); // create default storage folder named as organize resource id String organizePath = System.IO.Path.Combine(_path, res.Res_Id.ToString() + _orgName); Directory.CreateDirectory(organizePath); _rootPath = organizePath; CSearchDAL.AddSearchFolder(_rootPath); // create resource for default folder of organize CResourceEntity folderRes = new CResourceEntity(_connString); folderRes.Res_Name = res.Res_Id.ToString() + _orgName; folderRes.Res_Parent = 0; folderRes.Res_Type = (int)RESOURCETYPE.FOLDERRESOURCE; folderRes.Res_Id = folderRes.Insert(); // Create organize entity COrganizeEntity organize = new COrganizeEntity(_connString); organize.Org_Name = _orgName; organize.Org_Resource = folderRes.Res_Id; organize.Insert(); // create archive folder for organzie String archivePath = System.IO.Path.Combine(organizePath, "归档目录"); Directory.CreateDirectory(archivePath); // create resource for archive folder CResourceEntity archiveRes = new CResourceEntity(_connString); archiveRes.Res_Name = "归档目录"; archiveRes.Res_Parent = folderRes.Res_Id; archiveRes.Res_Type = (int)RESOURCETYPE.FOLDERRESOURCE; archiveRes.Res_Id = archiveRes.Insert(); organize.Org_ArchiveRes = archiveRes.Res_Id; organize.Update(); return(organize); } catch (Exception ex) { throw (ex); } }