Example #1
0
        public static string ReplaceAllMessageToken(string messageTemplate, string username, Int32 PortalID)
        {
            string[] tokens = GetAllToken(messageTemplate);
            foreach (string token in tokens)
            {
                switch (token)
                {
                case "%UserFirstName%":
                    string fName = GetUserFirstName(username, PortalID);
                    messageTemplate = messageTemplate.Replace(token, fName);
                    break;

                case "%UserLastName%":
                    string lName = GetUserLastName(username, PortalID);
                    messageTemplate = messageTemplate.Replace(token, lName);
                    break;

                case "%UserEmail%":
                    string userEmail = GetUserEmail(username, PortalID);
                    messageTemplate = messageTemplate.Replace(token, userEmail);
                    break;

                case "%UserActivationCode%":
                    string act = GetUserActivationCode(username, PortalID);
                    act             = EncryptionMD5.Encrypt(act);
                    messageTemplate = messageTemplate.Replace(token, act);
                    break;

                case "%Username%":
                    messageTemplate.Replace(token, username);
                    break;
                }
            }
            return(messageTemplate);
        }
Example #2
0
        /// <summary>
        /// Replaces all the messagetoken in a messagetemple with  their respective values.
        /// </summary>
        /// <param name="messageTemplate">Message template.</param>
        /// <param name="username">User's name.</param>
        /// <param name="PortalID">portalID.</param>
        /// <returns>Replaced message template.</returns>
        public static string ReplaceAllMessageToken(string messageTemplate, string username, Int32 PortalID)
        {
            MessageManagementController objController = new MessageManagementController();
            MessageManagementInfo       objInfo       = objController.GetUserDetailsByUserName(username, PortalID);

            messageTemplate = messageTemplate.Replace("##Username##", username);
            messageTemplate = messageTemplate.Replace("##UserEmail##", objInfo.Email);
            messageTemplate = messageTemplate.Replace("##UserFirstName##", objInfo.FirstName);
            messageTemplate = messageTemplate.Replace("##UserLastName##", objInfo.LastName);
            messageTemplate = messageTemplate.Replace("##HostUrl##", GetCurrnetHostURL);
            messageTemplate = messageTemplate.Replace("##UserActivationCode##", EncryptionMD5.Encrypt(objInfo.UserID.ToString()));
            return(messageTemplate);
        }
Example #3
0
        public static string ReplaceAllMessageToken(string messageTemplate, DataTable messageTokenValueDT)
        {
            string messageToken      = string.Empty;
            string messateTokenValue = string.Empty;

            for (int i = 0; i < messageTokenValueDT.Columns.Count; i++)
            {
                messageToken      = messageTokenValueDT.Columns[i].ColumnName.ToString().Replace('_', '%');
                messateTokenValue = messageTokenValueDT.Rows[0][i].ToString();
                switch (messageToken)
                {
                case "%UserActivationCode%":
                    messateTokenValue = EncryptionMD5.Encrypt(messateTokenValue);
                    break;
                }
                messageTemplate = messageTemplate.Replace(messageToken, messateTokenValue);
            }
            return(messageTemplate);
        }