Beispiel #1
0
    public static MvcHtmlString GetBasicInfo(this HtmlHelper html, bool currentUser = false, bool buttonAuth = false, bool distributeFile = false, bool flow = false)
    {
        StringBuilder sb = new StringBuilder();

        #region 当前用户

        if (currentUser == true && HttpContext.Current.Items["hasCurrentUser"] == null)
        {
            UserInfo user = FormulaHelper.GetUserInfo();
            sb.AppendFormat("var user = {0};\n", JsonHelper.ToJson(user));
            HttpContext.Current.Items["hasCurrentUser"] = true;
        }

        #endregion

        #region  钮权限

        if (HttpContext.Current.Items["hasBtnAuth"] == null)
        {
            IResService resService = FormulaHelper.GetService <IResService>();

            var        listRes      = resService.GetRes(HttpContext.Current.Request.Url.PathAndQuery, "Button,Field,FieldEdit");
            List <Res> noneAuthList = new List <Res>();
            List <Res> readonlyList = new List <Res>();
            if (listRes.Count > 0)
            {
                UserInfo user        = FormulaHelper.GetUserInfo();
                var      userListRes = resService.GetRes(HttpContext.Current.Request.Url.PathAndQuery, "Button,Field,FieldEdit", user.UserID);
                noneAuthList = listRes.Where(c => c.Type == "Button" || c.Type == "Field").Where(c => userListRes.Where(d => d.ID == c.ID).Count() == 0).ToList();
                readonlyList = listRes.Where(c => c.Type == "FieldEdit").Where(c => userListRes.Where(d => d.ID == c.ID).Count() == 0).ToList();
            }

            sb.AppendFormat("var noneAuthControl='{0}';\n", string.Join(",", noneAuthList.Select(c => c.ButtonID).ToArray()));
            sb.AppendFormat("var readonlyControl='{0}';\n", string.Join(",", readonlyList.Select(c => c.ButtonID).ToArray()));

            HttpContext.Current.Items["hasBtnAuth"] = true;
        }

        #endregion

        #region 流程当前环节

        if (flow == true && HttpContext.Current.Items["hasFlowStepCode"] == null)
        {
            sb.AppendFormat("\n var FlowCurrentStepCode = '{0}';", FormulaHelper.GetService <IWorkflowService>().GetFlowCurrentStepCode());
            HttpContext.Current.Items["hasFlowStepCode"] = true;
        }

        #endregion

        return(MvcHtmlString.Create(sb.ToString()));
    }
 public virtual void InitReference(IServiceContainer serviceContainer, IManagerContainer mgrContainer)
 {
     _serviceContainer = serviceContainer;
     //通用Service
     _ecsFacadeService     = serviceContainer.GetService <IECSFacadeService>();
     _randomService        = serviceContainer.GetService <IRandomService>();
     _timeMachineService   = serviceContainer.GetService <ITimeMachineService>();
     _constStateService    = serviceContainer.GetService <IConstStateService>();
     _inputService         = serviceContainer.GetService <IInputService>();
     _viewService          = serviceContainer.GetService <IViewService>();
     _audioService         = serviceContainer.GetService <IAudioService>();
     _map2DService         = serviceContainer.GetService <IMap2DService>();
     _resService           = serviceContainer.GetService <IResService>();
     _effectService        = serviceContainer.GetService <IEffectService>();
     _eventRegisterService = serviceContainer.GetService <IEventRegisterService>();
 }
 public virtual void InitReference(IServiceContainer serviceContainer, IManagerContainer mgrContainer = null)
 {
     this._serviceContainer     = serviceContainer;
     this._ecsFactoryService    = serviceContainer.GetService <IECSFactoryService>();
     this._randomService        = serviceContainer.GetService <IRandomService>();
     this._timeMachineService   = serviceContainer.GetService <ITimeMachineService>();
     this._globalStateService   = serviceContainer.GetService <IGlobalStateService>();
     this._inputService         = serviceContainer.GetService <IInputService>();
     this._viewService          = serviceContainer.GetService <IViewService>();
     this._audioService         = serviceContainer.GetService <IAudioService>();
     this._map2DService         = serviceContainer.GetService <IMap2DService>();
     this._resService           = serviceContainer.GetService <IResService>();
     this._effectService        = serviceContainer.GetService <IEffectService>();
     this._eventRegisterService = serviceContainer.GetService <IEventRegisterService>();
     this._idService            = serviceContainer.GetService <IIdService>();
     this._debugService         = serviceContainer.GetService <IDebugService>();
 }
Beispiel #4
0
 protected override void OnInit(BaseContext context, IServiceContainer services)
 {
     _context = (Context)context;
     //BuildInServices
     _randomService        = services.GetService <IRandomService>();
     _timeMachineService   = services.GetService <ITimeMachineService>();
     _globalStateService   = services.GetService <IGlobalStateService>();
     _viewService          = services.GetService <IViewService>();
     _audioService         = services.GetService <IAudioService>();
     _inputService         = services.GetService <IInputService>();
     _map2DService         = services.GetService <IMap2DService>();
     _resService           = services.GetService <IResService>();
     _effectService        = services.GetService <IEffectService>();
     _eventRegisterService = services.GetService <IEventRegisterService>();
     _idService            = services.GetService <IIdService>();
     _debugService         = services.GetService <IDebugService>();
     //GameServices
     _gameStateService  = services.GetService <IGameStateService>();
     _gameConfigService = services.GetService <IGameConfigService>();
     _gameEventService  = services.GetService <IGameEventService>();
 }