Ejemplo n.º 1
0
        /// <summary>
        /// 取得动作
        /// </summary>
        /// <param name="wbapRequest"></param>
        /// <param name="response"></param>
        /// <param name="pageName"></param>
        /// <param name="sessionId"></param>
        /// <returns></returns>
        public ActionBroker GetAction(WbapRequest wbapRequest, ref WbapResponse response, string pageName, string sessionId, ISecurity secHandler)
        {
            SetSessionInfo(wbapRequest);
            ActionBroker action = null;

            SaveRequestData(wbapRequest);
            if (response == null)
            {
                response = new WbapResponse();
            }
            response.PageName = pageName;

            //if (pageCtr == null || pageCtr.BuzObject.Id != pageName)
            //    pageCtr = new PageController(pageName,sessionId);

            this.sessionId = sessionId;

            ActionFlowSchema actionSchema = null;

            if (pageCtr.Schame.Actions.FindItem(wbapRequest.ActionId) == null)
            {
                if (wbapRequest.ActionId.Equals("onLoad", StringComparison.OrdinalIgnoreCase))
                {
                    return(null);
                }
                else
                {
                    action   = new ActionBroker(wbapRequest, actionSchema, pageCtr, sessionId, WbdlSchema, secHandler);
                    response = action.ExecuteFar();
                    return(null);
                }
            }

            try
            {
                actionSchema = pageCtr.Schame.Actions.GetItem(wbapRequest.ActionId);
            }
            catch (Exception)
            {
                throw (new E_CanNotFindActionSchema(wbapRequest.ActionId));
            }

            if (actionSchema == null)
            {
                throw (new E_CanNotFindActionSchema(wbapRequest.ActionId));
            }
            action = new ActionBroker(wbapRequest, actionSchema, pageCtr, sessionId, WbdlSchema, _ISec);
            return(action);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        private void InitualElement(WbapResponse resp, FieldBindSchema fieldBindSchema)
        {
            string tableName = fieldBindSchema.TableId;

            if (tableName == null)
            {
                throw (new E_WbdlPageFieldBindSchemaNotAssignedFieldId(fieldBindSchema.Id));
            }

            XTableSchema tableSchema = this.pageCtr.GetTableSchema(tableName);

//            XTableAdapter tableAdapter = new XTableAdapter(tableSchema);

            if (tableSchema == null)
            {
                return;
            }

            FieldSchema fieldSchame = tableSchema.Fields.FindItem(fieldBindSchema.FieldId);

            if (fieldSchame == null)
            {
                return;
                //throw (new E_CannotGetFieldSchame(fieldBindSchema.TableId + "." + fieldBindSchema.FieldId));
            }
            //fieldSchame.DisplayName = fieldBindSchema.DisplayName;
            //捆绑初始值
            //if (fieldSchame.DefaultValue != null && fieldSchame.DefaultValue != "")
            //{
            //    if (!resp.ElementBinds.ContainsKey(fieldBindSchema.Id))
            //        resp.ElementBinds.Add(fieldBindSchema.Id, fieldSchame.DefaultValue);
            //}

            //捆绑下拉列表
            string codeTableName = fieldSchame.CodeTableName;

            if (codeTableName != null && codeTableName != "")
            {
                //     XData xData = new XData();
                //try
                //{
                //    CodeTable codeTable = xData.GetCodeTable(codeTableName);
                //    Dictionary<string, string> option = new Dictionary<string, string>();

                //    foreach (CodeTableData codeTableData in codeTable.Datas)
                //    {
                //        option.Add(codeTableData.Id, codeTableData.Text);
                //    }
                //    resp.ElementBinds.AddOption(fieldBindSchema.Id, option);
                //}
                //catch (Exception e)
                //{
                //    throw (new Exception("Bind Element CodeTable Error Element Id is'" + fieldBindSchema.Id + "'  CodeTable is '" + codeTableName + "'," + e.Message));
                //}
            }


            //捆绑Lookup

            LookupFieldSchema lookupField = tableSchema.LookupFields.FindItem(fieldBindSchema.FieldId);

            if (lookupField != null)
            {
                //WbapEvent wbapEvent = new WbapEvent();
                //wbapEvent.EventName = "onpropertychange";
                //string  actionId= "GetLookup("
                //                  + fieldBindSchema.TableId
                //                  + "," + fieldBindSchema.FieldId
                //                  + ","+field;
                //wbapEvent.Action.Request.ActionId =actionId;
                //wbapEvent.Action.Request.PageName = schema.Id;
                //wbapEvent.Action.Request.ElementBinds.Add("fieldName", fieldBindSchema.TableId);
                //wbapEvent.Action.Request.ElementBinds.Add("fieldName", fieldBindSchema.FieldId);
                //wbapEvent.Action.Request.ElementBinds.Add("fieldValue", "@" + fieldBindSchema.Id);
                //wbapEvent.Action.Request.ElementBinds.Add("ReturnValue", "@" + fieldBindSchema.Id + "_Lookup");

                //fieldBindSchema.

                //resp.ElementBinds.AddEvent(fieldBindSchema.Id, wbapEvent);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 序列化WbapResponse
        /// </summary>
        /// <param name="wbapResponse"></param>
        /// <returns></returns>
        public static string SerializeResponse(WbapResponse wbapResponse)
        {
            string respText = JsonConvert.SerializeObject(wbapResponse);

            return(respText);
        }