public async Task <bool> SetLocation(LocationDto model)
        {
            MobMemberHelper helper = new MobMemberHelper();
            Member          member = _Db.Members.Where(o => o.OpenId == model.FromUserName).FirstOrDefault();

            if (member == null)
            {
                member = new Member
                {
                    OpenId = model.FromUserName
                };
            }

            member.Latitude  = model.Latitude;
            member.Longitude = model.Longitude;
            member.Precision = model.Precision;

            if (!(await helper.SaveAsync(member)))
            {
                return(false);
            }
            SetSession(member);
            return(true);
        }
        public async Task <bool> Login(string strOwinConfigName, string strOwinState, string strOwinCode, string strSessionName = "Mob")
        {
            MobMemberHelper helper = new MobMemberHelper();

            Member member = null;

            if (!SystemConfigModel.Instance.IsUseWechatLogin)
            {
                member = new Member();
                if (!(await helper.SaveAsync(member)))
                {
                    return(false);
                }

                return(true);
            }

            if (!SessionHelper.Owin.IsValid(strOwinState))
            {
                return(false);
            }

            OwinConfig   config       = GetByName(strOwinConfigName);
            OwinTokenDto owinTokenDto = GetTokenDto(config, strOwinCode);

            if (!owinTokenDto.ErrCode.HasValue)
            {
                member = helper.GetDbSet <Member>().Where(o => o.OpenId == owinTokenDto.OpenId).FirstOrDefault();
                if (member != null)
                {
                    member.Name = "";
                    SetSession(member);
                    return(true);
                }
            }

            OwinUserDto owinDto = GetUserDto(config, owinTokenDto);

            if (owinDto.ErrCode.HasValue)
            {
                LogHelper.Error(owinDto.ErrCode + ":" + owinDto.ErrMsg);
                return(false);
            }

            if (member == null)
            {
                member = helper.GetDbSet <Member>().Where(o => o.OpenId == owinTokenDto.OpenId).FirstOrDefault();
            }

            if (member == null)
            {
                member = new Member
                {
                    OpenId = owinDto.OpenId,
                };
            }

            member.NickName  = owinDto.NickName;
            member.Avatar    = owinDto.HeadImgUrl;
            member.Sex       = owinDto.Sex == "1" ? Sex.Male : Sex.Male;
            member.ShareCode = await GetShareCodeAsync();

            if (!(await helper.SaveAsync(member)))
            {
                return(false);
            }

            string strShareCode = SessionHelper.ShareCode.GetSession <string>();

            if (!string.IsNullOrEmpty(strShareCode))
            {
                await helper.SetMemberReferee(member, strShareCode);
            }

            return(true);
        }