Exemplo n.º 1
0
        public int GetIndentifyingCode(string openid, string number)
        {
            var code = (DateTime.Now.ToString() + openid).GetHashCode().ToString().Replace("-", "");

            code = code.PadLeft(6, '0').Substring(code.Length - 6, 6);

            var ic = new IdentifyingCode
            {
                OpenId      = openid,
                Content     = code,
                PhoneNumber = number,
            };

            var codeStirng = string.Format(System.Configuration.ConfigurationManager.AppSettings["identifyingcodebasestring"], code);
            var ret        = ShortMessageHelper.SendMsg(number, codeStirng);

            var db = new ModelContext();

            if (ret == "s")
            {
                ic.IsSendSuccess = true;
                db.IdentifyingCodeSet.Add(ic);
                db.SaveChanges();
                return(ic.IdentifyingCodeId);
            }
            else
            {
                ic.IsSendSuccess = false;
                ic.Remarks       = ret;
                db.IdentifyingCodeSet.Add(ic);
                db.SaveChanges();
                return(0);
            }
        }
Exemplo n.º 2
0
        private void Bind()
        {
            UserNameTextBox.Focus();
            IdentifyingCode ic = new IdentifyingCode();

            identifyingCode = ic.IdentifyingCodeStringGenerate();
            try
            {
                IdentifyingCodePictureBox.BackgroundImage = ic.IdentifyingCodeImageGenerate(identifyingCode);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            ToolTip.SetToolTip(IdentifyingCodePictureBox, "Click to change");
        }