Beispiel #1
0
 // TODO access values from Lang.resx
 public static string Title(Person person, string culture = null)
 {
     if (string.IsNullOrEmpty(culture)) culture = person.Culture ?? "de-CH";
     Resources.Lang.Culture = new CultureInfo(culture);
     switch (person.Gender) {
         default:
         case Person.Genders.None: return "";
         case Person.Genders.Male: return Resources.Lang.MaleTitle;
         case Person.Genders.Female: return Resources.Lang.FemaleTitle;
         case Person.Genders.Miss: return Resources.Lang.MissTitle;
         case Person.Genders.Group: return Resources.Lang.GroupTitle;
         case Person.Genders.Company: return Resources.Lang.CompanyTitle;
     }
 }
Beispiel #2
0
 public static string Salutation(Person person, string culture = null)
 {
     if (string.IsNullOrEmpty(culture)) culture = person.Culture ?? "de-CH";
     Resources.Lang.Culture = new CultureInfo(culture);
     switch (person.Gender) {
         default:
         case Person.Genders.None: return Resources.Lang.GroupSalutation;
         case Person.Genders.Male: return Resources.Lang.MaleSalutation + " " + person.LastName;
         case Person.Genders.Female: return Resources.Lang.FemaleSalutation + " " + person.LastName;
         case Person.Genders.Miss: return Resources.Lang.MissSalutation + " " + person.LastName;
         case Person.Genders.Group: return Resources.Lang.GroupSalutation;
         case Person.Genders.Company: return Resources.Lang.CompanySalutation;
     }
 }
Beispiel #3
0
        /// <summary>
        /// True if the the person is allowed to edit the document.
        /// </summary>
        /// <param name="doc">A document.</param>
        /// <param name="p">A person.</param>
        /// <returns>True if the the person is allowed to edit the document.</returns>
        public static bool IsEditable(IDocumentInfo doc, Person p)
        {
            if (doc == null) return true;
            var cats = (doc.Categories ?? string.Empty).SplitList(',', ';').ToList();
            if (cats.Contains("*")) return true;
            if (p == null) return false;
            if (cats.Contains("?")) return true;

            if (p.EditorSettings.EditableDocuments == null) {	// build the editable documents cache for this person.
                var edocs = p.EditorSettings.EditableDocuments = new List<EditRight>();
                using (var db = new Silversite.Context()) {
                    // first find the rights for this user
                    var rights = db.EditRights.Find(p.UserName);
                    if (rights != null) {
                        edocs.AddRange(rights.DocumentCategories.SplitList(s => new EditRight(s), ',',';'));
                    }
                    // and then for the users roles
                    foreach (var role in p.Roles) {
                        rights = db.EditRights.Find(role);
                        if (rights != null) {
                            edocs.AddRange(rights.DocumentCategories.SplitList(s => new EditRight(s), ',',';'));
                        }
                    }
                }
            }

            foreach (var right in p.EditorSettings.EditableDocuments) {
                foreach (var cat in cats) {
                    if (Paths.Match(right.DocumentCategory, cat)) {
                        return right.Permission == Permission.Allowed;
                    }
                }
            }
            return false;
        }
Beispiel #4
0
 internal static void Load(Person person)
 {
     if (person.customData == null) person.Custom.Clear();
     else {
         using (var m = new System.IO.MemoryStream(person.customData)) {
             var f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
             var data = f.Deserialize(m) as CustomDataClass;
             data.Person = person;
             person.Custom = data;
         }
     }
 }
Beispiel #5
0
 public CustomDataClass(Person person)
 {
     Person = person; Update();
 }