예제 #1
0
        /// <summary>
        /// 初始化上面的 Effect
        /// </summary>
        /// <param name="sysService"></param>
        public SysEffects(SysService sysService)
        {
            UnityIocService.AssertIsFirstInject(GetType());
            Logger = LoggerHelper.CreateLogger(GetType().ToString());
            //启动http解析服务
            StartHttpSystem = App.Store.asyncAction <SysActions.StartHttpSystem, bool>(
                async(dispatch, getState, instance) => {
                dispatch(instance);
                var isStarted = await sysService.StartHttpSystem(instance);
                if (isStarted)
                {
                    App.Store.Dispatch(new SysActions.StartHttpSystemSuccess());
                }
                else
                {
                    App.Store.Dispatch(new SysActions.StartHttpSystemFailed());
                }
                return(isStarted);
            });
            //启动关闭显示器定时器
            StartCloseScreenTimer = App.Store.asyncActionVoid <SysActions.StartCloseScreenTimer>(
                async(dispatch, getState, instance) => {
                dispatch(instance);
                await Task.Run(() => {
                    if (CloseScrrenTimer != null)
                    {
                        YUtil.RecoveryTimeout(CloseScrrenTimer);
                    }
                    else
                    {
                        CloseScrrenTimer = YUtil.SetInterval(instance.Interval, () => {
                            App.Store.Dispatch(new SysActions.CloseScreen());
                        });
                    }
                });
            });

            //停止关闭显示器定时器
            StopCloseScrenTimer = App.Store.asyncActionVoid <SysActions.StopCloseScreenTimer>(
                async(dispatch, getState, instance) => {
                dispatch(instance);
                await Task.Run(() => {
                    if (CloseScrrenTimer != null)
                    {
                        YUtil.ClearTimeout(CloseScrrenTimer);
                    }
                });
            });
        }