Esempio n. 1
0
        /// <summary>
        /// Retrieves a data table filled with users under the specified account id.
        /// </summary>
        /// <param name="acctId">long: Account id.</param>
        /// <returns>iCampaign.TACS.Data.UserDs.UsersDataTable</returns>
        internal iCampaign.TACS.Data.UserDs.UsersDataTable GetUsers(long acctId)
        {
            //  Instantiate the data objects
            iCampaign.TACS.Data.UserDs.UsersDataTable dataTable = new UserDs.UsersDataTable();
            iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);

            //  Try to get the records from the database
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.FillByAcctId(dataTable, acctId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            return dataTable;
        }
Esempio n. 2
0
        /// <summary>
        /// Publishes list of user profiles for account id specified in Credentials.
        /// </summary>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>System.Collections.Generic.List T:iCampaign.TACS.UserProfile</returns>
        public List<UserProfile> GetUserProfiles(Credentials credentials)
        {
            List<UserProfile> userProfiles = new List<UserProfile>();

            //  Check to see if user has sufficient access
            if (!credentials.AccountOwner)
            {
                throw new SystemException(TacsSession.MSG_INSUFPRIV);
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                throw new SystemException(TacsSession.MSG_INVALSESS);
            }

            //  Go and retrieve the list of user profiles
            Data.UserDs.UsersDataTable dataTable = new UserDs.UsersDataTable();
            Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.FillByAcctId(dataTable, credentials.AccountId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            //  Now populate the list collection from the data table
            foreach (Data.UserDs.UsersRow row in dataTable)
            {
                UserProfile profile = new UserProfile();
                profile.AccountExpirey = row.ExpireOn;
                profile.AccountId = row.AcctId;
                profile.AccountName = credentials.AccountName;
                profile.AccountOwner = row.AccountOwner;
                profile.Disable = row.UserDisabled;
                profile.Email = row.Email;
                profile.FullName = row.FullName;
                profile.Password = row.Password;
                profile.SuperAdministrator = row.SuperAdministrator;
                userProfiles.Add(profile);
            }

            return userProfiles;
        }