public ActionResult RenameFolder(string currentName, string memberId, PersonalFolderIdFormats format) { string result = "ok"; try { DirectoryInfo d = new DirectoryInfo(currentName); DirectoryMember m = _contextManager.DirectoryContext.DirectoryMembers.GetByID(memberId); string newName = LdapUserConfig.FormatFolderName(m, format); string thisPath = Path.GetDirectoryName(d.FullName); string newPath = Path.Combine(thisPath, newName); d.MoveTo(newPath); } catch(Exception ex) { ExceptionCollector ec = new ExceptionCollector(ex); result = ec.ToUL(); } return Content(result); }
public ActionResult Submit(string p, long s, Guid id, PersonalFolderIdFormats nf) { string result = "ok"; try { PersonalFolder f = null; if(id.Equals(Guid.Empty)) { f = new PersonalFolder() { PersonalFolderKey = Guid.NewGuid(), FolderPath = p, NameFormat = nf, MembershipScope = s }; cm.LdapContext.PersonalFolders.Insert(f); } else { f = cm.LdapContext.PersonalFolders.GetByID(id); f.MembershipScope = s; f.FolderPath = p; f.NameFormat = nf; cm.LdapContext.PersonalFolders.Update(f); } } catch(Exception ex) { ExceptionCollector ec = new ExceptionCollector(ex); result = ec.ToUL(); } return Content(result); }
public static string FormatFolderName(IDirectoryMember member, PersonalFolderIdFormats format) { if (format == PersonalFolderIdFormats.Fullname) { string name = DirectoryMemberRepository.GetName(member, DirectoryMemberNameFormats.Full | DirectoryMemberNameFormats.Sort) + " - " + member.UserName; return name; } else { return member.UserName; } }