private static object InvokeMethod(object o, string wboId, string methodName, Dictionary <string, string> jsonNamedParams) { WboSchema wboSchema = WboSchemaContainer.Instance().GetItem(wboId); WboProxy wbop = WboProxyFactory.getWboProxy(wboSchema); return(wbop.invokeMethd(o, methodName, jsonNamedParams)); }
public void freeWbo(string wboName, string wboTypeId) { WboSchema objectSchema = WboSchemaContainer.Instance().GetItem(wboTypeId); WboProxy wboProxy = WboProxyFactory.getWboProxy(objectSchema); if (wboProxy.getWboType().IsSubclassOf(typeof(ISessionWbo))) { objectSchema.LifeCycle = LifeCycle.Session; } string objHashKey = getObjHashKey(objectSchema.Id, wboName); switch (objectSchema.LifeCycle) { case LifeCycle.Global: if (objects.ContainsKey(objHashKey)) { objects.Remove(objHashKey); } break; case LifeCycle.Session: string sesssionId = Session.SessionID; if (SessionObjects.ContainsKey(objHashKey)) { SessionObjects.Remove(objHashKey); } break; } }
private static object CreateObject(WboSchema objectSchema, string objectName) { WboProxy wboProxy = WboProxyFactory.getWboProxy(objectSchema); //从持久存档文件中获取对象 string file = getWboFileName(objectName, objectSchema.Id); if (File.Exists(file)) { XmlReader xmlReader = XmlReader.Create(file); try { if (xmlReader == null) { throw (new EContainerCanNotOpenSchameFile()); } XmlSerializer xmls = new XmlSerializer(wboProxy.getWboType()); return(xmls.Deserialize(xmlReader)); } catch (Exception e) { throw new Exception("打开文件" + file + "时发生错误." + e.Message, e); } finally { xmlReader.Close(); } } return(wboProxy.createObject(objectName)); }
public object invoke(string req, Dictionary <string, string> jsonNamedParams) { if (string.IsNullOrEmpty(req)) { throw new Exception(string.Format(Lang.RequestNameIsNull, req)); } string memberName = null; string objName = null; string[] names = req.Split('.'); string comId = names[0]; object obj; if (USER_COMID.Equals(comId, StringComparison.OrdinalIgnoreCase)) { obj = security.user; if (names.Length == 1) { return(obj); } PropertyInfo pi = obj.GetType().GetProperty(names[1]); return(pi.GetValue(obj, null)); } WboSchema wboSchema = WboSchemaContainer.Instance().GetItem(comId); WboProxy wbop = WboProxyFactory.getWboProxy(wboSchema); if (names.Length > 1) { memberName = names[names.Length - 1]; if (wbop.hasMember(memberName)) { objName = UmcTools.getObjName(names, 1, names.Length - 2); } else { // memberName = null; objName = UmcTools.getObjName(names, 1); if (!string.IsNullOrEmpty(objName)) { memberName = null; } } } checkPermission(comId, objName, memberName, wboSchema); obj = GetObject(objName, comId); if (string.IsNullOrEmpty(memberName)) { return(obj); } return(invoke(obj, comId, objName, memberName, jsonNamedParams)); }
/// <summary> /// 通过传入wboSchema对象构架,和wbo对象的方法名及命名参数列表,调用methodName指定的方法 /// </summary> /// <param name="wboSchema">要调用的对象的对象架构</param> /// <param name="memberName">要调用的方法名称</param> /// <param name="jsonNamedParams">json命名参数列表规范的参数</param> /// <returns>methodName指定的方法的返回结果</returns> public object Invoke(string wboId, string objectName, string memberName, Dictionary <string, string> jsonNamedParams) { WboSchema wboSchema = WboSchemaContainer.Instance().GetItem(wboId); object obj = GetObject(objectName, wboId); WboProxy wbop = WboProxyFactory.getWboProxy(wboSchema); checkPermission(wboId, objectName, memberName, wboSchema); return(wbop.invoke(obj, memberName, jsonNamedParams)); }
public static object invoke(object o, string comId, string objName, string memberName, Dictionary <string, string> jsonNamedParams) { //WboProxy wp = WboProxyFactory.getWboProxy(objectSchema); if (string.IsNullOrEmpty(memberName)) { return(o); } WboSchema objectSchema = WboSchemaContainer.Instance().GetItem(comId); WboProxy wp = WboProxyFactory.getWboProxy(objectSchema); return(wp.invoke(o, memberName, jsonNamedParams)); }
private object invoke(string comId, string memberName, Dictionary <string, string> jsonNamedParams) { WboSchema objectSchema = WboSchemaContainer.Instance().GetItem(comId); object obj = GetObject(null, objectSchema); if (string.IsNullOrEmpty(memberName)) { return(obj); } WboProxy wp = WboProxyFactory.getWboProxy(objectSchema); return(wp.invoke(obj, memberName, jsonNamedParams)); }
public static string getComId(Type type) { string[] typeIds = WboSchemaContainer.Instance().GetSchemaIds(); foreach (string comId in typeIds) { WboSchema schema = WboSchemaContainer.Instance().GetItem(comId); Type regType = WboProxyFactory.getWboProxy(schema).getWboType(); if (regType.Equals(type)) { return(comId); } } return(type.Name); }
public object setWbo(string comId, string wboName, string wboJSON) { WboSchema objectSchema = WboSchemaContainer.Instance().GetItem(comId); WboProxy wboProxy = WboProxyFactory.getWboProxy(objectSchema); object wbo; try { wbo = JsonConvert.DeserializeObject(wboJSON, wboProxy.getWboType()); } catch { throw new XException(string.Format(Lang.WboTypeNotMatchComId, comId)); } if (wboProxy.getWboType().IsSubclassOf(typeof(ISessionWbo))) { objectSchema.LifeCycle = LifeCycle.Session; } string objHashKey = getObjHashKey(objectSchema.Id, wboName); switch (objectSchema.LifeCycle) { case LifeCycle.Global: if (objects.ContainsKey(objHashKey)) { objects[objHashKey] = wbo; } else { objects.Add(objHashKey, wbo); } break; case LifeCycle.Session: string sesssionId = Session.SessionID; if (SessionObjects.ContainsKey(objHashKey)) { SessionObjects[objHashKey] = wbo; } else { SessionObjects.Add(objHashKey, wbo); } break; } return(wbo); }
private object GetObject(string objectName, WboSchema objectSchema) { string sessionId = context.Session.SessionID; object obj = null; // log.Debug("\n"); // log.Debug("start getObject,object is" + objectName); WboProxy wboProxy = WboProxyFactory.getWboProxy(objectSchema); if (wboProxy.getWboType().IsSubclassOf(typeof(ISessionWbo))) { obj = GetSessionObject(objectSchema, objectName); } else { switch (objectSchema.LifeCycle) { case LifeCycle.Global: log.Debug(" start getObject from globle "); obj = GetGlobalObject(objectSchema, objectName); break; case LifeCycle.Session: log.Debug("start getObject from session: " + sessionId + ", object:" + objectName); obj = GetSessionObject(objectSchema, objectName); break; default: obj = CreateObject(objectSchema, objectName); break; } } if (obj is IHttpHandler) { (obj as IHttpHandler).ProcessRequest(context); } if (obj is IHttpWbo) { (obj as IHttpWbo).setContext(this); } return(obj); }