Beispiel #1
0
        public JoapResonse Invoke(JoapRequest joapRequest, string sessionId)
        {
            try
            {
                object o = Umc.GetObject(joapRequest.ObjName, joapRequest.ObjCls);

                JoapResonse jr = new JoapResonse();
                if (!string.IsNullOrEmpty(joapRequest.Method))
                {
//                    jr.RetData.Data = Umc.InvokeMethod(o,joapRequest.ObjCls, joapRequest.Method, joapRequest.Paramates);
                    // jr.RetData.Data = Umc.InvokeMethod(o, joapRequest.Method, joapRequest.Paramates);
                    jr.ObjData.Data = o;
                }
                return(jr);
            }
            catch (Exception err)
            {
                string    msg = err.Message;
                Exception et  = err.InnerException;
                while (et != null)
                {
                    msg += ",\n" + et.Message;
                    et   = et.InnerException;
                }
                Exception newErr = new Exception("执行命令" + joapRequest.Method + "时,发生错误" + msg, err);
                throw newErr;
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                HttpRequest      hReq  = context.Request;
                HttpResponse     hResp = context.Response;
                HttpSessionState hSes  = context.Session;


                string objType = Path.GetFileNameWithoutExtension(hReq.Url.LocalPath);
                string name    = hReq.QueryString["name"];
                Umc    umc     = Umc.getInstance(context);
                object wbc     = umc.GetObject(name, objType);

                if (!(wbc is IVisualWbo))
                {
                    throw new XException("调用的对象不是可视化对象,不能在页面上展示");
                }
                hResp.Write((wbc as IVisualWbo).Render(""));
            }
            catch (Exception err)
            {
                context.Response.Write(JsonExceptionUtils.ThrowErr(err).Serialize());
            }
        }
Beispiel #3
0
        public static string GetValue(string varName, Umc umc)
        {
            string     name      = varName.Remove(0, 2);
            int        fid       = name.LastIndexOf('.');
            string     fieldName = name.Substring(fid + 1);
            string     tableName = name.Substring(0, fid);
            DataSource table     = umc.GetObject <DataSource>(tableName);

            if (table == null)
            {
                throw new ESchemaFileException("不能找到变量定义的字段值," + varName);
            }


            Dictionary <string, string> rec = new Dictionary <string, string>();// table.ActiveRecord;

            if (rec != null && rec.ContainsKey(fieldName))
            {
                string value = rec[fieldName];
                if (value == null)
                {
                    value = "NULL";
                }
                return(value);
            }
            else if (rec == null || rec.Count < 1)
            {
                return("NULL");
            }
            else
            {
                throw new ESchemaFileException("不能找到变量定义的字段值," + varName);
            }
        }
Beispiel #4
0
        public void ProcessRequest(HttpContext context)
        {
            Request  = context.Request;
            Server   = context.Server;
            Session  = context.Session;
            Response = context.Response;


            parseRequestPath(context.Request.Path);
            //   Dictionary<string, string> jsonNameValues = this.getRequestGetNameValueParams(context.Request);
            //  if (jsonNameValues == null)

            Dictionary <string, string> jsonNameValues = WboHandlerTools.getRequestPostNameValueParams(context.Request);
            Umc    umc = Umc.getInstance(context);
            object obj = umc.GetObject(objName, objType);
            // object resp = Umc.invoke(obj, objType, "getPageRows", jsonNameValues);
        }
Beispiel #5
0
        private void OpenDataSource()
        {
            dataSources.Clear();
            foreach (WbdlDataSchema dss in pageSchema.DataSources)
            {
                try
                {
                    object obj = Umc.GetObject(dss.Name, dss.DataType);

                    if (obj is ISessionWbo)
                    {
                        (obj as ISessionWbo).Session = this.session;
                    }

                    if (obj is ISecurityWbo)
                    {
                        (obj as ISecurityWbo).UserContext = this.security.user;
                    }

                    if (dss.Props != null)
                    {
                        SetObjPropertis(dss.Props, obj);
                        //    if (obj is IDataSource)
                        //        (obj as IDataSource).RefreshData();
                    }
                    dataSources.Add(dss.Id, obj);
                }
                catch (Exception e)
                {
                    string s = e.Message;
                    if (e.InnerException != null)
                    {
                        s = s += e.InnerException.Message;
                    }
                    throw new XException(s + "Page在打开数据源" + dss.Name + "是发生错误,数据Id:" + dss.Id);
                }
            }
        }
Beispiel #6
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                umc = Umc.getInstance(context);
                parseRequestPath(context.Request.Path);
                Dictionary <string, string> jsonNameValues = HandlerUtils.getPostParams(context);

                if (ext.Equals(".keep"))
                {
                    umc.keepWbo(
                        this.wboTypeId,
                        this.wboName,
                        jsonNameValues["wboJSON"],
                        jsonNameValues["newName"]
                        );

                    writeToJsonResponse(context.Response, null);
                    return;
                }

                if (ext.Equals(".free"))
                {
                    umc.freeWbo(wboName, wboTypeId);
                    writeToJsonResponse(context.Response, null);
                    return;
                }

                if (ext.Equals(".del"))
                {
                    umc.delWbo(wboName, wboTypeId);
                    writeToJsonResponse(context.Response, null);
                    return;
                }

                if (ext.Equals(".disp", StringComparison.OrdinalIgnoreCase))
                {
                    object ret = umc.GetObject(wboName, this.wboTypeId);
                    if (!(ret is IVisualWbo))
                    {
                        throw new XException(Lang.ObjectIsNotVisualWbo);
                    }
                    string elementName = "";
                    if (jsonNameValues.ContainsKey("elementName"))
                    {
                        elementName = jsonNameValues["elementName"];
                    }
                    string html = (ret as IVisualWbo).Render(elementName);
                    context.Response.Write(html);
                    return;
                }

                if (reqName.EndsWith(".post"))
                {
                    jsonNameValues = null;
                }

                object obj;
                if (ext.Equals(".dir"))
                {
                    obj = Umc.dir(wboTypeId);
                }
                else
                {
                    obj = umc.invoke(reqName, jsonNameValues);
                }

                writeToJsonResponse(context.Response, obj);

                //context.Response.End();
            }
            catch (System.Reflection.TargetInvocationException e1)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(e1.InnerException).Serialize();
                if (e1.InnerException is PermissionException)
                {
                    jsonErr = JsonExceptionUtils.ThrowErr(SecErrs.NotPemission, (e1.InnerException as PermissionException).LoginUrl).Serialize();
                }
                context.Response.Write(jsonErr);
            }
            catch (PermissionException e2)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(10, e2.Message, e2.LoginUrl).Serialize();
                context.Response.Write(jsonErr);
            }
            catch (Exception e)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(e).Serialize();
                context.Response.Write(jsonErr);
            }
        }