コード例 #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);
            }
        }
コード例 #3
0
        public static int InsertUserLog(string CodeBlock, string ActivityOnPage, decimal UserAccountNo)
        {
            SqlDecimal sqlDecimal = SqlDecimal.Null;

            SqlParameter[] param = new SqlParameter[5];

            if ((UserAccountNo > 0))
            {
                param[0] = new SqlParameter("@UserAccountNo", Convert.ToDecimal(UserAccountNo));
            }
            else
            {
                param[0] = new SqlParameter("@UserAccountNo", sqlDecimal);
            }

            param[1] = new SqlParameter("@UserActivityOnSite", ActivityOnPage);
            // param[2] = new SqlParameter("@SitePageName", HttpContext.Current.Request.Url.AbsoluteUri);
            param[2] = new SqlParameter("@SitePageName", "");
            param[3] = new SqlParameter("@BlockName", CodeBlock);
            param[4] = new SqlParameter("@UserLogByIP", GetIP());

            return(DALCommon.ExecuteNonQuery("sp_User_InsertUserLog", param));
        }