Esempio n. 1
0
    public static MPSUser NewUser()
    {
        string name  = DateTime.Now.Ticks.ToString();
        string email = name + "@domain.com";

        AddObject(_Tabl, new string[] { _login, _pname, _pass, _isAdm, _ret, _birth, _lvl, _email }, new object[] { name, name, "", 0, 0, DateTime.Now, 3, email }, "");
        DefectUser.NewUser(name, "", email);
        ReferenceVersion.Updatekey();
        foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
        {
            return(new MPSUser(i));
        }
        return(null);
    }
Esempio n. 2
0
    public static MPSUser FindUser(string name, string pass)
    {
        bool domain = name.Contains("@");

        if (domain)
        {
            bool   valid        = false;
            string dispUserName = name;
            using (PrincipalContext context = new PrincipalContext(ContextType.Domain, Settings.CurrentSettings.COMPANYDOMAIN))
            {
                valid = context.ValidateCredentials(name, pass);
                if (valid)
                {
                    var usr = UserPrincipal.FindByIdentity(context, name);
                    if (usr != null)
                    {
                        dispUserName = usr.GivenName + " " + usr.Surname;
                    }
                }
            }
            if (!valid)
            {
                return(null);
            }
            foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
            {
                return(new MPSUser(i));
            }
            AddObject(_Tabl, new string[] { _login, _pname, _pass, _isAdm, _ret, _birth, _lvl, _email }, new object[] { name, dispUserName, "", 0, 0, DateTime.Now, 3, name }, "");
            DefectUser.NewUser(name, "", name);
            ReferenceVersion.Updatekey();
            foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
            {
                return(new MPSUser(i));
            }
            return(null);
        }
        foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login, _pass }, new object[] { name, pass }))
        {
            return(new MPSUser(i));
        }
        return(null);
    }
Esempio n. 3
0
    public static int New(string tabl, string desc)
    {
        string sql = $@"
			INSERT INTO {tabl}
			(
				{_ID}, 
				{_idPrj}, 
				{_idOrd}, 
				{_Desc}
			)
			values
			(
			   (SELECT MAX(T1.{_ID}) + 1 FROM {tabl} T1)
			 , 1
			 , (SELECT MAX(T2.{_idOrd}) + 1 FROM {tabl} T2)
			 , ?
			)"            ;

        SQLExecute(sql, new object[] { desc });
        ReferenceVersion.Updatekey();
        return(Convert.ToInt32(GetValue($"SELECT MAX({_ID}) FROM {tabl}")));
    }
Esempio n. 4
0
 protected override void PostStore()
 {
     ReferenceVersion.Updatekey();
 }