コード例 #1
0
        public static WbapResponse Invoke(WbapRequest request, string sessionId)
        {
            PageController pageController = new PageController(request.PageName, sessionId);

            pageController.SetRequestData(request.ElementBinds);

            Wbap wbap = new Wbap(pageController);

            wbap.ISecHandler = _ISec;

            string pageName = request.PageName;
            string actionId = request.ActionId;


            WbapResponse wbapResponse = null;

            if (string.IsNullOrEmpty(actionId) || actionId.Equals("Initialize", StringComparison.OrdinalIgnoreCase))
            {
                wbapResponse = wbap.Initialize(pageName, sessionId);
            }
            else
            {
                wbapResponse = new WbapResponse();
                ActionBroker action = wbap.GetAction(request, ref wbapResponse, pageName, sessionId, _ISec);
                if (action != null)
                {
                    wbapResponse = action.Execute();
                }
            }
            return(wbapResponse);
        }
コード例 #2
0
        private WbapResponse _Execute()
        {
            WbapResponse response = new WbapResponse();

            response.PageName = this.request.PageName;
            return(__Execute(response));
        }
コード例 #3
0
        //private void UpdatePage(WbapRequest request)
        //{
        //    foreach (KeyValuePair<string, object> keyValue in request.ElementBinds)
        //    {
        //        string elementId = keyValue.Key;
        //        object obj = keyValue.Value;

        //        if (elementId[0].Equals('#')) throw new XException("非法的ElementId:" + elementId);
        //        if (elementId[0].Equals('$')) throw new XException("非法的ElementId:" + elementId);
        //        if (elementId[0].Equals('@')) throw new XException("非法的ElementId:" + elementId);

        //        if (obj is WbapList)
        //        {
        //            pageController.SetWbapList(elementId, (WbapList)obj);
        //        }
        //        else if (obj is string)
        //        {
        //            pageController.SetStringElement(elementId, (string)obj);
        //        }
        //    }

        //}

        private WbapResponse _ExecuteFar()
        {
            WbapResponse response = new WbapResponse();

            response.PageName = this.request.PageName;

            Dictionary <string, Object> namedParams = new Dictionary <string, object>();

            foreach (KeyValuePair <string, Object> elementItem in request.ElementBinds)
            {
                string retElement = null;
                if (elementItem.Key.Equals("ReturnValue"))
                {
                    retElement = elementItem.Value.ToString();
                }
                else
                {
                    namedParams.Add(elementItem.Key, GetParamVarValue(elementItem.Value.ToString()));
                }
            }

            //    Umc.InvokeFunction("sid", "msid", request.ActionId, namedParams);
            return(response);
        }
コード例 #4
0
 public static string SerializeResponse(WbapResponse response)
 {
     return(Wbap.SerializeResponse(response));
 }
コード例 #5
0
        private WbapResponse __Execute(WbapResponse response)
        {
            //CheckPermissionRetrun ret = _ISec.CheckObjectPermission(sessionId, _ActionSchema.Id, 1);
            //if (ret != CheckPermissionRetrun.Yes)
            //{
            //    response.ErrorNo = Convert.ToInt32(ret);
            //    response.Message = "Access denied:" + ret.ToString();
            //    return response;
            //}


            for (int i = request.Step; i < _ActionSchema.Actions.Count; i++)
            {
                ActionSchema methodSchema = _ActionSchema.Actions[i];

                #region client action
                if (methodSchema.IsRunAtClient())
                {
                    BuildAction(_ActionSchema.Id, i, response.Action);
                    if (response.Action.Request.ActionId != null && response.Action.Request.ActionId != "")
                    {
                        return(response);
                    }
                    else
                    {
                        break;
                    }
                }
                #endregion

                string retVarName = methodSchema.ReturnValue;

                //#region Menu


                //if (methodSchema.MethodName.ToUpper() == GetMenu)
                //{
                //    if (methodSchema.Parameters[0].Value[0] == '$')
                //        methodSchema.Parameters[0].Value = (string)request.ElementBinds[methodSchema.Parameters[0].Value];
                //    XMenuObject xMenu = GetMenuBySession(this.sessionId, methodSchema.Parameters[0].Value);
                //    if (!response.ElementBinds.ContainsKey(retVarName))
                //        response.ElementBinds.Add(retVarName, xMenu);
                //    else
                //        response.ElementBinds[retVarName] = xMenu;
                //    continue;
                //}
                //#endregion

                #region preocess params
                Object[] parameters = new Object[methodSchema.Parameters.Count];
                for (int j = 0; j < methodSchema.Parameters.Count; j++)
                {
                    ParameterSchema paramSchema = methodSchema.Parameters[j];

                    object paramValue = null;
                    if (string.IsNullOrEmpty(paramSchema.Value))
                    {
                        parameters[j] = null;
                        continue;
                    }

                    if (paramSchema.Value[0] == '#')
                    {
                        paramValue = request.ElementBinds.GetTable(paramSchema.Value.Remove(0, 1), schema);
                    }
                    else if (paramSchema.Value[0] == '$')
                    {
                        paramValue = request.ElementBinds[paramSchema.Value];
                    }
                    else
                    {
                        paramValue = paramSchema.Value;
                    }
                    //paramValue = GetParamVarValue(paramSchema.Value);

                    if (paramValue == null)
                    {
                        //        BuildAction(_ActionSchema.Id, i, response.Action);
                        //       return response;
                    }

                    parameters[j] = paramValue;
                }

                #endregion

                #region flow control
                int idx = DetectFlowCtrlExec(methodSchema.MethodName, parameters);
                if (idx != -1)
                {
                    if (idx == BREAK)
                    {
                        return(response);
                    }
                    i = idx - 1;
                    continue;
                }

                #endregion

                #region Invoke
                Object invokeRet = null;

                //try
                //{
                invokeRet = Umc.InvokeFunction(sessionId, null, methodSchema.MethodName, parameters);
                //}
                //catch (Exception e)
                //{
                //    if (e.InnerException != null)
                //        throw e.InnerException;
                //    throw (e);
                //}

                #endregion

                ProcessMethodReturn(invokeRet, response.ElementBinds);
                if (!string.IsNullOrEmpty(retVarName))
                {
                    if (!response.ElementBinds.ContainsKey(retVarName))
                    {
                        response.ElementBinds.Add(retVarName, invokeRet);
                    }
                    else
                    {
                        response.ElementBinds[retVarName] = invokeRet;
                    }
                }

                //临时作废,考虑用GetType()分类型处理的方法
                #region process return value
                //if (retVarName != null && retVarName != "" && retVarName[0] == VAR_TYPES[(int)RealParamFlagType.Element])
                //{
                //    retVarName = retVarName.Remove(0, 1);
                //    if (methodReturnObj is CodeTable)
                //    {
                //        Dictionary<string, string> option = new Dictionary<string, string>();

                //        foreach (CodeTableData codeTableData in (methodReturnObj as CodeTable).Datas)
                //        {
                //            option.Add(codeTableData.Id, codeTableData.Text);
                //        }
                //        if (!response.ElementBinds.ContainsKey(retVarName))
                //            response.ElementBinds.Add(retVarName, option);
                //        else
                //            response.ElementBinds[retVarName] = option;

                //    }
                //    else
                //    {
                //        if (!request.ElementBinds.ContainsKey(retVarName))
                //        {
                //            request.ElementBinds.Add(retVarName, methodReturnObj);
                //        }
                //        else
                //        {
                //            request.ElementBinds[retVarName] = methodReturnObj;
                //        }
                //        if (!response.ElementBinds.ContainsKey(retVarName))
                //            response.ElementBinds.Add(retVarName, methodReturnObj);
                //        else
                //            response.ElementBinds[retVarName] = methodReturnObj;
                //    }
                //}

                //else if (retVarName != null && retVarName != "" && retVarName[0] == VAR_TYPES[(int)RealParamFlagType.Table])
                //{
                //    XTable table = (XTable)methodReturnObj;
                //    response.ElementBinds.ImportTable(table, pageController, retVarName.Remove(0, 1));
                //}
                //else if (retVarName != null && retVarName != "")
                //{
                //    if (methodReturnObj is MapTable)
                //    {
                //        WebLookupList lookupList = new WebLookupList();
                //        lookupList.ImportMapTable(methodReturnObj as MapTable, pageController);
                //        if (!response.ElementBinds.ContainsKey(retVarName))
                //            response.ElementBinds.Add(retVarName, lookupList);
                //        else
                //            response.ElementBinds[retVarName] = lookupList;
                //    }
                //    else
                //    {
                //        if (!response.ElementBinds.ContainsKey(retVarName))
                //            response.ElementBinds.Add(retVarName, methodReturnObj);
                //        else
                //            response.ElementBinds[retVarName] = methodReturnObj;
                //    }
                //}
                #endregion
            }
            //XData xData = Umc.FindObject<XData>(sessionId, null);
            //if (xData != null)
            //    xData.Commit();
            return(response);
        }