Exemple #1
0
        /*
         * POPULATE THE USER OBJECT WITH THE ATTRIBUTES OF THE USER
         */
        private void generateUser(string username, string password)
        {
            DataClassesDataContext dc = new DataClassesDataContext();

            //
            // Get the app id and the app name
            //
            UNI_APP _app     = new UNI_APP();
            string  _appName = "";

            //
            // Get the app name from the web config and use it to get the app id from the database
            // If an error occurred retrieving it from the database then set it to the default name
            //
            try
            { _appName = System.Configuration.ConfigurationManager.AppSettings["DefaultAppName"].ToString(); }
            catch
            { _app.app_nm = "EDW REPORTS"; }

            // Get the app id from the database.
            // If an error occurred then try get the app id from the web config file. If an error occured again then assign a default id of 1
            try
            { _app = (from _ap in dc.UNI_APPs where _ap.app_nm.ToUpper() == _appName select _ap).Single(); }
            catch
            {
                try
                { _app.app_id = int.Parse(System.Configuration.ConfigurationManager.AppSettings["DefaultAppId"].ToString()); }
                catch
                { _app.app_id = 4; }
            }

            try
            {
                string pwd = password;
                System.Collections.Generic.List <sp_electionwatch_helper_loginResult> _users = (dc.sp_electionwatch_helper_login(username.ToUpper(), pwd)).ToList();

                if (_users[0].usr_nm != null)
                {
                    CurrentUser _currentUser = new CurrentUser();

                    sp_electionwatch_helper_loginResult _user = (from u in _users where u.app_id == _app.app_id select u).Single();

                    if (_user.app_id == _app.app_id)
                    {
                        _currentUser.UserId           = _user.usr_id;
                        _currentUser.Username         = _user.usr_nm;
                        _currentUser.FirstName        = _user.frst_nm.ToUpper();
                        _currentUser.LastName         = _user.last_nm.ToUpper();
                        _currentUser.WorkLocationId   = _user.wloc_id;
                        _currentUser.WorkLocationName = _user.wloc_nm;
                        _currentUser.ActiveElection   = _user.elctn_nm.ToUpper();

                        try
                        { _currentUser.LastLoginDate = (DateTime)_user.last_login_dt; }
                        catch { }

                        // Get the user's constituencies
                        try
                        {
                            System.Collections.Generic.List <SP_GET_LOCATIONSResult> locations = (dc.SP_GET_LOCATIONS(_user.usr_nm, _user.app_id)).ToList();

                            foreach (SP_GET_LOCATIONSResult location in locations)
                            {
                                try
                                {
                                    if (_currentUser.WorkLocations.ContainsKey(location.wloc_id))
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        _currentUser.WorkLocations.Add((int)location.wloc_id, location.wloc_nm);
                                    }
                                }
                                catch
                                { }

                                try
                                {
                                    if (_currentUser.Constituencies.ContainsKey(location.cnstncy_nbr))
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        _currentUser.Constituencies.Add((int)location.cnstncy_nbr, location.cnstncy_nm);
                                    }
                                }
                                catch
                                { }
                            }

                            _currentUser.UserRoles.Add("cur", getUserRole(_currentUser.UserId, _app.app_id));//tks
                        }
                        catch { }

                        Session.Add("CurrentUser", _currentUser);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
 partial void UpdateUNI_APP(UNI_APP instance);
Exemple #3
0
 partial void DeleteUNI_APP(UNI_APP instance);
Exemple #4
0
 partial void InsertUNI_APP(UNI_APP instance);