Пример #1
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            try
            {
                TempData["Messager"] = TempData["Messager"];
                var fullSystemConfigCache = SenparcDI.GetService <FullSystemConfigCache>();
                _fullSystemConfig = fullSystemConfigCache.Data;

                var fullAccountCache = SenparcDI.GetService <FullAccountCache>();
                if (this.UserName != null)
                {
                    FullAccount = fullAccountCache.GetObject(this.UserName);
                    if (FullAccount != null)
                    {
                        //...
                    }
                    else
                    {
                        //用户不存在,发生严重异常
                        LogUtility.Account.Error($"发生严重错误,用户已登录,但缓存及数据库中不存在:{this.UserName}");
                    }
                }

                FullAccount = FullAccount ?? new FullAccount();
                FullAccount.LastActiveTime = DateTime.Now;

                base.OnActionExecuting(context);
            }
            catch (Exception ex)
            {
                context.Result = RenderError(ex.Message, ex);
            }
        }
Пример #2
0
        /// <summary>
        /// 编辑 SystemConfig 信息
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostEditAsync([FromBody] FullSystemConfig fullSystemConfig)
        {
            var val = this.Validator(fullSystemConfig.SystemName, "系统名称", "SystemName", false);

            if (!ModelState.IsValid)
            {
                return(Ok(false, string.Join(",", val.ModelState.Values)));
            }

            var systemConfig = await _systemConfigService.GetObjectAsync(z => true);

            //暂时只允许修改 SystemName
            systemConfig.Update(fullSystemConfig.SystemName, systemConfig.MchId, systemConfig.MchKey, systemConfig.TenPayAppId, systemConfig.HideModuleManager);
            await _systemConfigService.SaveObjectAsync(systemConfig);

            base.SetMessager(MessageType.success, $"修改成功!");
            return(Ok(new { systemName = systemConfig.SystemName }));
        }
Пример #3
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            try
            {
                TempData["Messager"] = TempData["Messager"];


                var result = context.HttpContext.Session.GetString("userName");

                if (!string.IsNullOrEmpty(result))
                {
                    //var  _adminUserInfoService = CO2NET.SenparcDI.GetService<AdminUserInfoService>();
                    //  this.AdminUser = _adminUserInfoService.GetUserInfo(result);
                }

                //var ctoken = context.HttpContext.Session.GetString("session");

                //if (!string.IsNullOrEmpty(ctoken))
                //{
                //   var er = _encryptionService.CommonDecrypt(ctoken);
                //    var arr = result.Split("-");
                //    if (arr.Length == 3)
                //    {

                //        long ticks = 0;
                //        Int64.TryParse(arr[1], out ticks);
                //        this.Session = new SessionInfo
                //        {
                //            ClientKey = arr[2],
                //             ExpireTime =new DateTime(ticks),
                //              UserName = arr[0]
                //        };

                //    }
                //}

                var fullSystemConfigCache = SenparcDI.GetService <FullSystemConfigCache>();

                _fullSystemConfig = fullSystemConfigCache.Data;
                var fullAccountCache = SenparcDI.GetService <FullAccountCache>();
                if (this.UserName != null)
                {
                    FullAccount = fullAccountCache.GetObject(this.UserName);
                    if (FullAccount != null)
                    {
                        //...
                    }
                    else
                    {
                        //用户不存在,发生严重异常
                        LogUtility.Account.Error($"发生严重错误,用户已登录,但缓存及数据库中不存在:{this.UserName}");
                    }
                }

                FullAccount = FullAccount ?? new FullAccount();
                FullAccount.LastActiveTime = DateTime.Now;

                base.OnActionExecuting(context);
            }
            catch (Exception ex)
            {
                context.Result = RenderError(ex.Message, ex);
            }
        }