Exemplo n.º 1
0
        public Com.LogonResult Logon(string TellNumber)
        {
            try
            {
                Com.User mUser = BLL.User.GetUserByTellNumber(TellNumber);
                if (mUser == null)
                {
                    mUser = new Com.User()
                    {
                        TellNumber  = TellNumber,
                        LastLogin   = DateTime.Now,
                        Active      = false,
                        Credit      = 500,
                        JoinDate    = DateTime.Now,
                        RewardState = 0,
                        ActiveCode  = CreateRandomCode()
                    };

                    mUser.UID = BLL.User.AddUser(mUser);
                    if (mUser.UID < 0)
                    {
                        return(new Com.LogonResult()
                        {
                            IsNew = true, HasError = true, NickName = "", UserID = mUser.UID
                        });
                    }
                    else
                    {
                        new System.Threading.Thread(delegate() { SendActivationCodeViaSMS(TellNumber, mUser.ActiveCode); }).Start();
                        return(new Com.LogonResult()
                        {
                            IsNew = true, HasError = false, NickName = "", UserID = mUser.UID
                        });
                    }
                }
                else
                {
                    string NewActiveCode = CreateRandomCode();
                    if (TellNumber == "989123456789")//mehr
                    {
                        NewActiveCode = "12345";
                    }
                    mUser.ActiveCode = NewActiveCode;
                    bool Res = BLL.User.UpdateUserCode(mUser);
                    new System.Threading.Thread(delegate() { SendActivationCodeViaSMS(TellNumber, NewActiveCode); }).Start();
                    return(new Com.LogonResult()
                    {
                        IsNew = false, HasError = false, NickName = mUser.NickName, UserID = mUser.UID
                    });
                }
            }
            catch (Exception e)
            {
                new System.Threading.Thread(delegate() { BLL.Log.DoLog(Com.Common.Action.Logon, TellNumber, -200, e.Message); }).Start();
                return(new Com.LogonResult()
                {
                    IsNew = false, HasError = true, NickName = e.Message, UserID = 0
                });
            }
        }
Exemplo n.º 2
0
        public ResLastUserInfo GetLastUserInfo(int UID)
        {
            ResLastUserInfo Res = new ResLastUserInfo();

            try
            {
                Com.User usr      = BLL.User.GetUser(UID);
                MiniUser miniUser = new MiniUser()
                {
                    CodeMeli    = usr.CodeMeli ?? "",
                    Credit      = usr.Credit,
                    Email       = usr.Email ?? "",
                    FamilyName  = usr.FamilyName ?? "",
                    JoinDate    = usr.JoinDate,
                    LastLogin   = usr.LastLogin,
                    Name        = usr.Name ?? "",
                    NickName    = usr.NickName ?? "",
                    RewardState = 1,
                    TellNumber  = usr.TellNumber,
                    UID         = usr.UID,
                    Address     = usr.Address ?? "",
                    CodePosti   = usr.CodePosti ?? "",
                    City        = usr.City ?? "",
                    Ostan       = usr.Ostan ?? "",
                };
                Res.MiniUser    = miniUser;
                Res.userBought  = BLL.User.GetAllUserBought(UID);
                Res.userMessage = BLL.User.GetAllUserMessage(UID);
            }
            catch (Exception e)
            {
                new System.Threading.Thread(delegate() { BLL.Log.DoLog(Common.Action.GetLastUserInfo, UID.ToString(), -400, e.Message); }).Start();
                new System.Threading.Thread(delegate() { BLL.Log.DoLog(Common.Action.GetLastUserInfo, UID.ToString(), -400, e.InnerException.Message); }).Start();
            }

            return(Res);
        }