public static async Task<User> CreateAsync( string name, string password, string mandant, DataAccessLayer.NetworkState state, bool offline)
        {

            DataAccessLayer.DAL_Session dal_Session = new DataAccessLayer.DAL_Session ();
            var session = BusinessLayer.Session.Create ();

            // First the Name and Password have to be authiticated
            session = await dal_Session.GetSessionAsync (name, password, mandant, offline); 
            //DataAccessLayer.SOAResult result = await dal_Session.GetSessionAsync (session, name, password, mandant, state);
            if (session.Success == DataAccessLayer.SOAResult.Disconnected)
            {
                // Then there is a connection failure
                return null;
            }

            var user = new User ();

            if (session.Success == DataAccessLayer.SOAResult.FALSE)
            {
                // Username and Password were wrong, return an empty object
                return user;    
            }


            DataAccessLayer.DAL_User dal_User = new DataAccessLayer.DAL_User ();

            user.IdSession = session.ID;
            user.ID = session.UserID;
            user.Name = name;
            user.Password = password;
            user.Mandant = mandant;
            if (offline == true)
                user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;
            else
                user.NetworkStatus = state;


            if (state != DataAccessLayer.NetworkState.Disconnected && offline == false)
                await dal_User.SetUserPermissionsAsync ( user);

            return user;


        }
Exemple #2
0
        public static async Task<User> CreateAsync( string name, string password, string mandant, DataAccessLayer.NetworkState state, bool offline)
        {

            DataAccessLayer.DAL_Session dal_Session = new DataAccessLayer.DAL_Session ();
            var session = BusinessLayer.Session.Create ();

            // First the Name and Password have to be authiticated
            session = await dal_Session.GetSessionAsync (name, password, mandant, offline); 
            //DataAccessLayer.SOAResult result = await dal_Session.GetSessionAsync (session, name, password, mandant, state);
            if (session.Success == DataAccessLayer.SOAResult.Disconnected)
            {
                // Then there is a connection failure
                return null;
            }

            var user = new User ();

            if (session.Success == DataAccessLayer.SOAResult.FALSE)
            {
                // Username and Password were wrong, return an empty object
                return user;    
            }


            DataAccessLayer.DAL_User dal_User = new DataAccessLayer.DAL_User ();

            user.IdSession = session.ID;
            user.ID = session.UserID;

            if (state != DataAccessLayer.NetworkState.Disconnected && offline == false)
            {
                user = await dal_User.SetUserPermissionsAsync(user);

                // set if the user is able to create tasks in the offline modus
                DataAccessLayer.DAL_User.SetOfflineInsertTask(
                    user.HasPermission(DAC_Object.Kunde_Task, BusinessLayer.DAC_Permission.CREATE),
                    user.HasPermission(DAC_Object.Lieferant_Task, BusinessLayer.DAC_Permission.CREATE),
                    user.HasPermission(DAC_Object.Interessent_Task, BusinessLayer.DAC_Permission.CREATE));                 
            }
            user.ID = session.UserID;
            user.Name = name;
            user.Password = password;
            user.Mandant = mandant;
            user.Abteilung = session.Abteilung;
            user.Adr_Vertr = session.Adr_Vertr;
            user.Adr_KeyAccount = session.Adr_KeyAccount;
            if (offline == true)
                user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;
            else
                user.NetworkStatus = state;



            return user;


        }