}//END updateTokenUser method

        // =====================================================================================
        /// <summary>
        /// This method add an organisation for token generated users.
        /// </summary>
        /// <param name="UserProfile">Evado.Digital.Model.EdUserProfile object</param>
        /// <returns>EvEventCodes: an event code for saving items</returns>
        // -------------------------------------------------------------------------------------
        public EvEventCodes AddTokenOrganisation(
            EdUserProfile UserProfile)
        {
            this.LogMethod("AddTokenOrganisation");
            //
            // Initialise the methods variables and objects.
            //
            EvEventCodes result = EvEventCodes.Ok;

            Evado.Digital.Model.EdOrganisation organisation      = new EdOrganisation( );
            Evado.Digital.Dal.EdOrganisations  dal_Organisations =
                new  Evado.Digital.Dal.EdOrganisations(this.ClassParameters);

            //
            // Create the org identifier.
            //
            int orgCount = dal_Organisations.getOrganisationCount(String.Empty);

            String orgId = "T" + orgCount.ToString("0000");

            organisation.OrgId = orgId;
            UserProfile.OrgId  = orgId;

            //
            // Add organisation object
            //
            result = dal_Organisations.addItem(organisation);

            this.LogDebug(dal_Organisations.Log);

            this.LogMethodEnd("AddTokenOrganisation");
            return(result);
        }
 public EvReportHtml(
     EvReport report,
     EdUserProfile userProfile)
 {
     this.writeDebugLogMethod("EvReportHtml initialisation method.");
     this._report      = report;
     this._UserProfile = userProfile;
 }
        }//END UserCount method

        // =====================================================================================
        /// <summary>
        /// This class retrieves a user profile with a specific connection String.
        /// </summary>
        /// <param name="ConnectionStringKey">string: the database connection string config key</param>
        /// <param name="UserId">string: a user identifier</param>
        /// <returns>Evado.Digital.Model.EdUserProfile: a user profile object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method to retrieve a userProfile object based on UserId
        ///
        /// 2. Return the UserProfile object
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EdUserProfile getItem(string ConnectionStringKey, string UserId)
        {
            this.FlushLog( );
            this.LogMethod("getItem");
            Evado.Digital.Bll.EvStaticSetting.ConnectionStringKey = ConnectionStringKey;

            EdUserProfile userProfile = getItem(UserId);

            Evado.Digital.Bll.EvStaticSetting.ResetConnectionString( );
            return(userProfile);
        }
示例#4
0
        // ==================================================================================
        /// <summary>
        /// This methods performs a MarkDown text substitution in the Content text passed into the
        /// method and returns text with the relevant text substitutions.
        /// </summary>
        /// <param name="Content">String: MarkDown text containing the values to be substituted</param>
        /// <param name="SubjectMilestone">EvMilestone: the subject milestone</param>
        /// <returns>Markdown String</returns>
        //  ---------------------------------------------------------------------------------
        public String substituteDataValue(
            String Content,
            EdUserProfile PatientUseProfile)
        {
            String content = Content;

            //
            // substitute the user ID into the content.
            //
            if (PatientUseProfile.UserId != String.Empty)
            {
                content = content.Replace(
                    EvcStatics.TEXT_SUBSITUTION_USER_ID,
                    PatientUseProfile.UserId.Trim( ));
            }
            else
            {
                content = content.Replace(
                    EvcStatics.TEXT_SUBSITUTION_USER_ID, String.Empty);
            }

            //
            // substitute the user ID into the content.
            //
            if (PatientUseProfile.Password != String.Empty)
            {
                content = content.Replace(
                    EvcStatics.TEXT_SUBSITUTION_PASSWORD,
                    PatientUseProfile.Password.Trim( ));
            }
            else
            {
                content = content.Replace(
                    EvcStatics.TEXT_SUBSITUTION_PASSWORD, String.Empty);
            }

            //
            // Return the substituted text content.
            //
            return(content);
        }
示例#5
0
 public EvReportCsv(EvReport report, string separator, EdUserProfile userProfile)
 {
     _report    = report;
     _separator = separator;
 }
        }//END saveItem method

        #endregion

        #region Class  update  methods

        // =====================================================================================
        /// <summary>
        /// This method updates user profile for token authentication process.
        /// </summary>
        /// <param name="TokenUser">Evado.Model.EusTokenUserProfile object</param>
        /// <param name="UserTypeList">EdSelectionList object containing the user category options.</param>
        /// <returns>EvEventCodes: an event code for saving items</returns>
        // -------------------------------------------------------------------------------------
        public EvEventCodes updateTokenUser(
            Evado.Model.EusTokenUserProfile TokenUser,
            EvSelectionList UserTypeList)
        {
            this.FlushLog( );
            this.LogMethod("updateTokenUser");
            this.LogDebug("TokenUser.UserId {0}", TokenUser.UserId);
            this.LogDebug("UserTypeList.Items Title: {0}, items {1}",
                          UserTypeList.Title, UserTypeList.Items.Count);
            //
            // Initialise the methods variables and objects.
            //
            EvEventCodes result = EvEventCodes.Ok;

            Evado.Digital.Model.EdUserProfile userProfile         = new EdUserProfile( );
            Evado.Digital.Model.EdUserProfile existingUserProfile = new EdUserProfile( );

            //
            // Import the user token data.
            //
            userProfile.ImportTokenProfile(TokenUser);

            //
            // Check that the user id is valid
            //
            if (userProfile.UserId == String.Empty)
            {
                this.LogEvent("UserId is empty");
                return(EvEventCodes.Token_User_Profile_UserId_Empty);
            }

            //
            // validate that the user does not already exist.
            //
            existingUserProfile = this._Dal_UserProfiles.GetItem(userProfile.Guid);

            this.LogDebug(" userProfile.Guid: '{0}', UserId '{1}'", userProfile.Guid, userProfile.UserId);
            this.LogDebug(" existingUserProfile.Guid: '{0}', UserId '{1}'", existingUserProfile.Guid, existingUserProfile.UserId);

            if (existingUserProfile.UserId != userProfile.UserId &&
                existingUserProfile.Guid != Guid.Empty)
            {
                this.LogDebug("UserId does NOT match the Token value.");
                this.LogMethodEnd("updateTokenUser");
                return(EvEventCodes.Token_User_Profile_UserId_Error);
            }

            //
            // If a new user exists the update their details as a subscribed user.
            //
            if (existingUserProfile.UserId == userProfile.UserId &&
                TokenUser.UserStatus == EusTokenUserProfile.UserStatusCodes.New_User)
            {
                this.LogDebug("Existing User to update details as a subscribed user.");
                TokenUser.UserStatus = EusTokenUserProfile.UserStatusCodes.Subscribed_User;
            }

            //
            // if the user does not have an organisation create one for them.
            //
            if (userProfile.OrgId == String.Empty)
            {
                userProfile.OrgId = existingUserProfile.OrgId;

                this.LogDebug("No Organisation so create one for the user.");
                this.AddTokenOrganisation(userProfile);
            }

            //
            // match the user category with the user type.
            //
            if (UserTypeList.Items.Count > 0)
            {
                this.LogDebug("Updating the use category");
                this.LogDebug("UserType {0}.", userProfile.UserType);
                foreach (EvSelectionList.Item item in UserTypeList.Items)
                {
                    this.LogDebug("Item C: {0}, V: {1}, D: {2}", item.Category, item.Value, item.Description);
                    if (userProfile.UserType == item.Value)
                    {
                        userProfile.UserCategory = item.Category;
                        break;
                    }
                }
            }
            this.LogDebug("UserCatetory {0}.", userProfile.UserCategory);

            //
            // if the role is empty set to the category as a default.
            //
            if (userProfile.Roles == String.Empty)
            {
                userProfile.Roles = userProfile.UserCategory;
            }

            //
            // based on the user status select the method of user update.
            //
            this.LogDebug("UserStatus {0}.", TokenUser.UserStatus);
            switch (TokenUser.UserStatus)
            {
            case EusTokenUserProfile.UserStatusCodes.New_User:
            {
                this.LogValue("Add User");
                result = this._Dal_UserProfiles.AddItem(userProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                this.LogMethodEnd("updateTokenUser");
                return(result);
            }

            case EusTokenUserProfile.UserStatusCodes.Subscribed_User:
            {
                this.LogValue("update User");
                result = this._Dal_UserProfiles.UpdateItem(userProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                this.LogMethodEnd("updateTokenUser");
                return(result);
            }

            default:
            {
                this.LogValue("Disable user access");

                userProfile.Roles        = String.Empty;
                userProfile.UserCategory = String.Empty;
                userProfile.UserType     = String.Empty;

                result = this._Dal_UserProfiles.UpdateItem(userProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                this.LogMethodEnd("updateTokenUser");
                return(result);
            }
            }
        }//END updateTokenUser method