示例#1
0
        public static string GetEmailActivationCode()
        {
GenerateEmailActivationCode:

            string strGuid = string.Empty;

            try
            {
                //get new activation code
                strGuid = System.Guid.NewGuid().ToString();
                strGuid = strGuid.Replace("-", string.Empty);
                strGuid = strGuid.Substring(0, 10).ToString();
            }
            catch (Exception ex)
            {
                ErrorLog(ex.Message, "DALUtility.vb, GetEmailActivationCode");
            }

            //Declare Sql Parameter
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@ActivationCodeByEmail", EncryptDecrypt.Encrypt(strGuid));

            //Check This Activation Code Is Exists Then
            if ((DALCommon.DataExistsByQuery("SELECT UserAccountNo FROM dbo.UserAccount WHERE ActivationCodeByEmail LIKE @ActivationCodeByEmail", param)))
            {
                goto GenerateEmailActivationCode;
            }
            else
            {
                return(strGuid);
            }
        }
示例#2
0
        public static string GetMobileActivationCode()
        {
GenerateMobileActivationCode:

            string strGuid = string.Empty;
            string numbers                    = null;
            string singleNumberValue          = null;
            string strActivationCodeForMobile = string.Empty;

            try
            {
                //declare string builder to get random numbers for 6 digits
                StringBuilder builder = new StringBuilder();
                //declare an object for random
                Random Random = new Random();
                //declare all the numbers
                numbers = "1234567890";

                //Now go for 6 digit numbers
                for (int i = 0; i <= 5; i++)
                {
                    //get the single number
                    singleNumberValue = Convert.ToString(numbers[(Random.Next(0, numbers.Length))]);
                    //append with the previous one
                    builder.Append(singleNumberValue);
                }
                //concatenate all the values 1 String and 5 Digits
                strActivationCodeForMobile = builder.ToString();
            }
            catch (Exception ex)
            {
                ErrorLog(ex.Message, "DALUtility.vb, GetEmailActivationCode");
            }

            //Declare Sql Parameter
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@ActivationCodeByMobile", EncryptDecrypt.Encrypt(strActivationCodeForMobile));

            //Check This Activation Code Is Exists Then
            if ((DALCommon.DataExistsByQuery("SELECT UserAccountNo FROM dbo.UserAccount WHERE ActivationCodeByMobile LIKE @ActivationCodeByMobile", param)))
            {
                goto GenerateMobileActivationCode;
            }
            else
            {
                return(strActivationCodeForMobile);
            }
        }