Exemplo n.º 1
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        public WbapResponse Initialize(string pageName, string sessionId)
        {
            WbapResponse resp = null;

            //CheckPermissionRetrun ret = _ISec.CheckObjectPermission(sessionId, pageName, 1);
            //if (ret != CheckPermissionRetrun.Yes)
            //{
            //    resp = new WbapResponse();
            //    resp.ErrorNo = (int)(ret);
            //    // Convert.ToInt32
            //    resp.Message = "Access denied: " + ret.ToString();
            //    resp.PageName = pageName;
            //    return resp;
            //}

            //pageCtr = new PageController(pageName,sessionId);

            this.sessionId = sessionId;
            // this.schema = pageCtr.Schame;
            pageCtr.Initialize();

            WbapRequest request = new WbapRequest();

            request.ActionId = "OnLoad";
            request.Step     = 0;
            request.PageName = pageName;

            #region 权限管理
            //ret =_ISec.CheckObjectPermission(sessionId, streamRequest.ActionId, 2);
            //if (ret != CheckPermissionRetrun.Yes)
            //{
            //    resp = new WbapResponse();
            //    resp.ErrorNo = Convert.ToInt32(ret);
            //    resp.Message = "Access denied:" + ret.ToString();
            //    resp.PageName = pageName;
            //    return resp;
            //}
            #endregion

            ActionBroker action = GetAction(request, ref resp, pageName, sessionId, _ISec);

            if (action != null)
            {
                resp = action.Execute();
            }



            //元素捆绑
            foreach (FieldBindSchema fieldBindSchema in WbdlSchema.FieldBinds)
            {
                //ret = _ISec.CheckObjectPermission(sessionId, fieldBindSchema.Id, 2);
                //if (ret == CheckPermissionRetrun.Yes)
                this.InitualElement(resp, fieldBindSchema);
            }

            //捆绑列表列属性
            foreach (DataListBindSchema listBindSchema in WbdlSchema.DataListBinds)
            {
                //ret = _ISec.CheckObjectPermission(sessionId, listBindSchema.Id, 2);
                //if (ret == CheckPermissionRetrun.Yes)
                //{
                foreach (FieldBindSchema fieldBindSchema in listBindSchema.Columns)
                {
                    //ret = _ISec.CheckObjectPermission(sessionId, fieldBindSchema.Id, 2);
                    //if (ret == CheckPermissionRetrun.Yes)
                    this.InitualElement(resp, fieldBindSchema);
                }
                //}
            }

            //控件捆绑
            foreach (WbdlControl wbdlControl in WbdlSchema.Controls)
            {
                ActionSchema ms = wbdlControl.DataFunction;
                MethodBroker mb = new MethodBroker(ms);

                object invokeRet = mb.Invoke(sessionId, WbdlSchema, request);

                WbapControl wbapControl = new WbapControl();
                wbapControl.Data         = invokeRet;
                wbapControl.VenderObject = wbdlControl.VenderObject;
                wbapControl.VenderUrl    = wbdlControl.VerderUrl;
                resp.Controls.Add(wbdlControl.Id, wbapControl);
            }



            //捆绑数据;
            pageCtr.FillDataBodyWithDataSet(resp.ElementBinds);
            //捆绑列表

            //foreach (PageDataList pageList in pageCtr.Page.PageLists.Values)
            //{
            //    string listId = pageList.ElementId;
            //    if (!resp.ElementBinds.ContainsKey(listId + WbapList.TypeMarker))
            //    {
            //        WbapList wbapList = pageCtr.GetWbapList(listId);
            //        resp.ElementBinds.Add(listId + WbapList.TypeMarker, wbapList);
            //    }

            //}



            //捆绑事件
            foreach (EventSchema eventBindSchema in WbdlSchema.EventBinds)
            {
                string    actionId  = eventBindSchema.ActionFlow;
                WbapEvent wbapEvent = new WbapEvent();
                wbapEvent.EventName = eventBindSchema.EventName;
                BuildAction(actionId, 0, wbapEvent.Action, request);
                resp.ElementBinds.AddEvent(eventBindSchema.Id, wbapEvent);
            }

            //替换全局变量

            foreach (string elementKey in resp.ElementBinds.Keys)
            {
                if (elementKey.Length > 0 && elementKey[0] == '$')
                {
                    resp.ElementBinds[elementKey] = request.ElementBinds[elementKey];
                }
            }

            return(resp);
        }
Exemplo n.º 2
0
        internal void AddEvent(string elementId, WbapEvent wbapEvent)
        {
            string elementTypedId = GetTypedElementId(elementId, WbapDataType._Event);

            this.Add(elementTypedId, wbapEvent);
        }