public async Task <ResultObj <String> > userLogin(LogingDto inEnt)
        {
            ResultObj <String> reobj = new ResultObj <String>();

            var loginResult = await _login.UserLogin(inEnt);

            if (loginResult.success)
            {
                var client = new HttpClient();

                // var paras = new Dictionary<string, string>();
                // paras.Add("userObjJson", TypeChange.ObjectToStr(loginResult.data));
                // var tokeStr=Fun.HashEncrypt($"{DataTimeHelper.getDateLong(DateTime.Now)}|{loginResult.data.id}|{loginResult.data.loginName}|{loginResult.data.name}");
                var tokeStr = Helper.AuthHelper.GenerateToken(loginResult.data);
                reobj.success = true;
                reobj.code    = tokeStr;
                reobj.data    = TypeChange.ObjectToStr(loginResult.data);
            }
            else
            {
                reobj.success = false;
                reobj.msg     = loginResult.msg;
            }
            return(reobj);
        }
        public async Task <string> GetUserInfoAsync(string state, string code)
        {
            //Request.Headers.Select(x=>x.Key+"="+x.Value).ToArray()
            if (string.IsNullOrEmpty(code))
            {
                string ip = this.httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
                state = $"{state}|{ip}";
                var url = Helper.WeiChat.Utility.GetWebpageAuthorization(appConfig.WeiXin.Appid, $"http://{Request.Host.Host}{Request.Path}", state, false);
                Response.Redirect(url);
                return("");
            }
            else
            {
                var stateList = state.Split('|');
                state = stateList[0];
                var reStr = Helper.WeiChat.Utility.GetWebpageUserInfo(appConfig.WeiXin.Appid, appConfig.WeiXin.Secret, code);
                reStr.ip = stateList[1];
                var addressList = await httpClientFactory.CreateClient().GetAddressAsync(reStr.ip);

                reStr.address = string.Join("", addressList);
                await weiXin.saveUser(reStr, new List <string> {
                    "nickname", "headimgurl", "lastTime", "ip", "address", "subscribe"
                });

                return(TypeChange.ObjectToStr(reStr));
            }
        }
示例#3
0
        public async Task <ResultObj <int> > save(DtoSave <SysQueryEntity> inEnt)
        {
            ResultObj <int> reObj = new ResultObj <int>();

            try
            {
                if (string.IsNullOrEmpty(inEnt.data.queryCfgJson))
                {
                    inEnt.data.queryCfgJson = TypeChange.ObjectToStr((await _query.MakeQueryCfg(inEnt.data.code)).data);
                }
                if (string.IsNullOrEmpty(inEnt.data.rowsBtn))
                {
                    inEnt.data.rowsBtn = @"
[{
		""title"": ""修改"",
		""class"": ""nb-edit"",
		""readUrl"": ""user/*/singleByKey"",
		""apiUrl"": ""user/*/save""
	},
	{
		""title"": ""删除"",
		""class"": ""nb-trash"",
		""apiUrl"": ""user/*/delete"",
		""confirmTip"": ""确定要删除吗?""
	}
]";
                }
                if (string.IsNullOrEmpty(inEnt.data.heardBtn))
                {
                    inEnt.data.heardBtn = @"
[{
		""title"": ""添加"",
		""class"": ""nb-plus"",
		""click"": ""nowThis.Add('user/*/save')""
	},
	{
		""title"": ""批量删除"",
		""class"": ""ion-delete"",
		""click"": ""nowThis.Exec('user/*/delete','id','删除要删除吗?')""
	}
]                 
                    ";
                }
                if (inEnt.data.id == 0)
                {
                    reObj.data = await _query.Save(inEnt);
                }
                else
                {
                    reObj.data = await _query.Update(inEnt);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteErrorLog(typeof(QueryController), ex.ToString());
                reObj.msg     = ex.Message;
                reObj.success = false;
            }
            return(reObj);
        }
示例#4
0
        public Result Test(DtoKey inEnt)
        {
            Result reEnt = new Result();

            reEnt.success = true;
            reEnt.msg     = "接口测试成功:" + TypeChange.ObjectToStr(appConfig);
            return(reEnt);
        }
        public async Task <SysQueryEntity> Single(Expression <Func <SysQueryEntity, bool> > where)
        {
            var reEnt = await dal.Single(where);

            reEnt._DictStr         = TypeChange.ObjectToStr(new ModelHelper <SysQueryEntity>(reEnt).GetDisplayDirct());
            reEnt._dictQueryCfgStr = TypeChange.ObjectToStr(new ModelHelper <QueryCfg>(new QueryCfg()).GetDisplayDirct());
            return(reEnt);
        }
示例#6
0
        public Result TestUser(DtoKey inEnt)
        {
            Result reEnt = new Result();

            reEnt.success = true;
            reEnt.msg     = "User.Identity:" + TypeChange.ObjectToStr(User.Identity);
            reEnt.msg    += "User.Claims:" + TypeChange.ObjectToStr(from c in User.Claims select new { c.Type, c.Value });

            return(reEnt);
        }
        public Result MakeMenu()
        {
            String    token    = Utility.ReadAccessToken(appConfig.WeiXin.Appid, appConfig.WeiXin.Secret);
            MenuModel makeMenu = new MenuModel();

            makeMenu.button = new LinkedList <MenuNodeModel>();
            //makeMenu.button.AddLast(new MenuNodeModel()
            //{
            //    name = "ETC免费办理",
            //    sub_button = new LinkedList<MenuNodeModel>(new[] {
            //        new MenuNodeModel(){
            //            key=MessageUtil.CLICK_ETC_BIND,
            //            name="绑定申办ETC"
            //        },new MenuNodeModel(){
            //            key=MessageUtil.CLICK_ETC,
            //            name="申办ETC"
            //        },new MenuNodeModel(){
            //            key=MessageUtil.CLICK_ETC_INSTALL,
            //            name="ETC安装激活点"
            //        }
            //    })
            //});

            makeMenu.button.AddLast(new MenuNodeModel()
            {
                name = "ETC安装激活点",
                type = "click",
                key  = MessageUtil.CLICK_ETC_INSTALL,
            });
            makeMenu.button.AddLast(new MenuNodeModel()
            {
                name = "推广赚钱",
                type = "click",
                key  = MessageUtil.CLICK_GetMoney,
            });
            makeMenu.button.AddLast(new MenuNodeModel()
            {
                name = "获取物流帮手",
                type = "click",
                key  = MessageUtil.CLICK_DOWNURL,
            });
            Result result = new Result();

            result.msg = Utility.SetMenu(token, TypeChange.ObjectToStr(makeMenu));
            return(result);
        }