Пример #1
0
        public void createScript(string Username, string NameOfScript)
        {
            if (Scripts.ExistsBo(CanvasScriptKey.Create(Username, NameOfScript)))
            {
                // vorhandenes Script zurückgeben
                Scripts.GetBo(CanvasScriptKey.Create(Username, NameOfScript));
            }
            else
            {
                if (Users.ExistsBo(Username))
                {
                    var e = ScriptsSet.Create();
                    ScriptsSet.Add(e);
                    e.Name         = NameOfScript;
                    e.User         = UserNamesSet.Find(Username).User;
                    e.Created      = DateTime.Now;
                    e.Modified     = e.Created;
                    e.ScriptAsJson = "[]";

                    ScriptsSet.Add(e);
                }
                else
                {
                    throw new ArgumentException("Der Benutzer mit dem Namen " + Username + " existiert nicht.", "Username");
                }
            }
        }
Пример #2
0
 public void deleteUser(string username)
 {
     try{
         var nameRec = UserNamesSet.Find(username);
         if (nameRec != null)
         {
             if (nameRec.User.Scripts.Any())
             {
                 throw new Exception(mko.TraceHlp.FormatErrMsg(this, "deleteUser", "Name=", username, "Dem Benutzer sind noch Scripte zugeordnet"));
             }
             var user = nameRec.User;
             UserNamesSet.Remove(nameRec);
             UsersSet.Remove(user);
         }
         else
         {
             throw new System.Data.RowNotInTableException("Der zu löschende Benutzer " + username + " existiert nicht");
         }
     } catch (Exception ex) {
         throw new Exception(mko.TraceHlp.FormatErrMsg(this, "deleteUser"), ex);
     }
 }