static void CopyBehaviour(MonoBehaviour behaviour, JSSerializer serizlizer) { lstAnalyze.Clear(); lstString.Clear(); lstObjs.Clear(); // GameObject go = behaviour.gameObject; //Type type = behaviour.GetType(); // 1) Fields FieldInfo[] fields = GetMonoBehaviourSerializedFields(behaviour); foreach (FieldInfo field in fields) { AddAnalyze(field.FieldType, field.Name, field.GetValue(behaviour)); } // 2) Properties PropertyInfo[] properties = GetTypeSerializedProperties(behaviour.GetType()); foreach (PropertyInfo pro in properties) { AddAnalyze(pro.PropertyType, "#" + pro.Name, pro.GetValue(behaviour, null)); } TraverseAnalyze(); for (var i = 0; i < lstAnalyze.Count; i++) { lstAnalyze[i].Alloc(serizlizer); } serizlizer.jsClassName = JSNameMgr.GetTypeFullName(behaviour.GetType()); serizlizer.arrString = lstString.ToArray(); serizlizer.arrObject = lstObjs.ToArray(); }
public async Task <int> GetUserBet(int userId, DateTime startTime, DateTime endTime, string gamePlatform, string sort, string order, int pageIndex, int pageSize) { int result = 0; NameValueCollection nvc = new NameValueCollection(); nvc.Add("userId", userId.ToString()); nvc.Add("startTime", startTime.ToString("yyyy-MM-dd 00:00:00")); nvc.Add("endTime", endTime.ToString("yyyy-MM-dd 00:00:00")); nvc.Add("gamePlatform", gamePlatform); nvc.Add("sort", sort); nvc.Add("order", order); nvc.Add("pageIndex", pageIndex.ToString()); nvc.Add("pageSize", pageSize.ToString()); String parms = UtilHelper.ConvertNameValueString(nvc); var request = CreateRequest("api/bet/GetUserBet", HttpMethod.Get); var response = await Client.SendAsync(request); if (response.StatusCode == HttpStatusCode.OK) { var responseText = await response.Content.ReadAsStringAsync(); result = JSSerializer.Deserialize <int>(responseText); } return(result); }
public void Index() { var context = HttpContext; string data = ""; using (StreamReader sr = new StreamReader(context.Request.InputStream)) { data = sr.ReadToEnd(); JObject jtoken = JObject.Parse(data); data = jtoken["data"].ToString(); } AppUtility.Engine.LogWriter.Write("CRM_To_H3接口风险点干预流程数据:" + data); JavaScriptSerializer json = new JavaScriptSerializer(); WorkFlowMethod.Return result = new WorkFlowMethod.Return(); try { //data = "D7756CA4CAD69B232FCBDD7F9DBE3AE965C8D1AC54FB50518BCDC1725CCA1CD88A5FD5BC64BACA0C393440E2940EE851E96781BF17513B4C265C3F2822F905DDD35C10E28677CEBA042CBB142ED38015B630FF9A787E5395E8C0EEDF61175D634644B3B9998378480001C2F6691A47F8351CD6F68D4E217995FE481F77494D004F52C83F29747F70B8E66148858F850A0A6BEEFF0706424E1C500CD3DA0BEAD5C66275A6796B5E3C36221262678A70A00E7986BAE12506D81A73A67089861153802A6A743C0224990584045AD1B7381F9DE91BE2A503E92E94A1E552AE9E0E405CDA65C9FB3984C07D3EB2D0FE29A948E94146B6E5BFF61EE895A9B2FAE7A8D1E40C25C0DCE11BBCF46BCC1A3C6B5709C19B238F5ABC124D83332E3B2A434EFE063579C371DA886DA58702315F9356C2850B91BFBE508973EE7A582BEC10AFBEBE0107A687F4A5C45ABCB7CDFDB461C685A23AE70E22CCF21E0024A7B9E0024657140D80566B172422D3E02DA2BE4B9C3D9A82759DF0729268E792246AC9ABAD1AE8CAF2685C6C981BD059D752B5AE7474A3EF64FAC6CBA09ABF2D084507F5925B29ED591C208DB79261A47DA7EDC48A3A8460C884CFC8A48B24C7566F67868669D0ADBDF7733F60F1ED356E7DFAC66005D4EA260FF3B882C6A475AB8A733286C56CD4C53668516B5A0B0FDBA04F2F1C82AFA1EB4C06EFE5D9A1665A4359CF487B996E42BD9D74579E3CC8661A0F30FCFA7AC56DF8AD5A13416F2C4472AD90A098C50FD07C3FF5EFB9E6CABD5383C801E61B68F767CEFD60F84136EA91280723930FB23D7192E11F8683F3DE2508E4B3558B572BD80A329834AC2380BC1483A80F72DD397B1242628BAAD174E7F46F61B2E690E1BD4C4908A1AE7D9EF66DED5469085E166DDBE4F49A7B2C735FEADECB"; List <DataItemParam> dataList = new List <DataItemParam>(); data = DESDecrypt(data, "B^@s(d)+"); AppUtility.Engine.LogWriter.Write("CRM_To_H3接口风险点干预解密数据:" + data); JObject jsonData = JObject.Parse(data); RiskPoint rp = new RiskPoint(); rp.DealerID = jsonData["third_system_no"].ToString(); rp.Originator = jsonData["originator"].ToString(); List <RiskPointForm> rpfList = new List <RiskPointForm>(); foreach (var item in jsonData["distributorlist"]) { RiskPointForm rpf = new RiskPointForm(); rpf.Dealer = item["distributor"].ToString(); rpf.Reason = item["message"].ToString(); rpf.DealerID = item["third_system_no"].ToString(); rpfList.Add(rpf); } rp.riskpointform = rpfList; string str = JSSerializer.Serialize(rp); BPMServiceResult bpmresult = startWorkflowByEntityTrinsJson("RiskPoint", jsonData["originator"].ToString(), false, str); //;jsonData["originator"].ToString() "*****@*****.**" "18f923a7-5a5e-426d-94ae-a55ad1a4b239" //BPMServiceResult bpmresult = StartWorkflow("RiskPoint", jsonData["originator"].ToString(), false, dataList); //"*****@*****.**" "18f923a7-5a5e-426d-94ae-a55ad1a4b239" if (bpmresult.Success) { result.Result = "0"; result.Message = result.Message; } else { result.Result = "-1"; result.Message = result.Message; } } catch (Exception e) { result.Result = "-1"; result.Message = e.Message; } context.Response.Write(json.Serialize(result)); }
public static string JsonSerialize(object o) { if (o == null) { return(null); } return(JSSerializer.Serialize(o)); }
/// <summary> /// 获取用户的待办任务总数 /// </summary> /// <param name="context"></param> /// <returns></returns> private string getAllWorkItemCount(HttpContextBase context) { string workitem = "{\"result\":[";//{"":"","":""} workitem += "{\"UnfinishedWorkItemCount\":" + getUnfinishedWorkItemCount(context) + "," + "\"WorkItem\":" + getUnfinishedWorkItem(context) + "},"; workitem += "{\"FinishedWorkItemCount\":" + getFinishedWorkItemCount(context) + "," + "\"WorkItem\":" + getFinishedWorkItem(context) + "},"; workitem += "{\"UserUnReadedWorkItemCount\":" + GetUserUnReadedWorkItemCount(context) + "," + "\"WorkItem\":" + GetUserUnReadedWorkItem(context) + "},"; workitem += "{\"UserReadedWorkItemCount\":" + GetUserReadedWorkItemCount(context) + "," + "\"WorkItem\":" + GetUserReadedWorkItem(context) + "}]}"; return(JSSerializer.Serialize(workitem)); }
/// <summary> /// 查询用户的待办 /// </summary> /// <param name="context"></param> /// <returns></returns> private string getUnfinishedWorkItem(HttpContextBase context) { string rtn = ""; string UserCode = context.Request["UserCode"]; WorkFlowFunction wf = new WorkFlowFunction(); int startIndex = 0, endIndex = 10; List <OThinker.H3.Controllers.ViewModels.WorkItemViewModel> lstModel = wf.GetUnFinishWorkItems(UserCode, null, null, startIndex, endIndex, "", ""); rtn = CommonFunction.Obj2Json(lstModel); return(JSSerializer.Serialize(rtn)); }
public Footer GetFooter(string key) { var request = GetRequest("api/News/GetNewsByKey?key=" + key); var response = Client.SendAsync(request).Result; if (response.StatusCode == HttpStatusCode.OK) { var responseText = response.Content.ReadAsStringAsync().Result; return(JSSerializer.Deserialize <Footer>(responseText)); } return(null); }
public PagerFrontViewModel <Ad> GetFooterImages() { var request = GetRequest("api/News/GetAds?type=yc_footer_image&pageSize=20&pageIndex=0"); var response = Client.SendAsync(request).Result; if (response.StatusCode == HttpStatusCode.OK) { var responseText = response.Content.ReadAsStringAsync().Result; return(JSSerializer.Deserialize <PagerFrontViewModel <Ad> >(responseText)); } return(null); }
private string Is_Mortgaged(HttpContextBase context) { string application_number = context.Request["applicationNo"]; WorkFlowFunction wf = new WorkFlowFunction(); int i = wf.Is_Mortgaged(application_number); object obj = new { value = i }; return(JSSerializer.Serialize(obj)); }
public Config Get() { Config config = null; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "api/config/items"); var response = Client.SendAsync(request).Result; if (response.StatusCode == HttpStatusCode.OK) { var responseText = response.Content.ReadAsStringAsync().Result;//.Replace("<", "").Replace(">k__BackingField", ""); // 替换序列化产生的k__BackingField,否则反序列化时会不成功 config = JSSerializer.Deserialize <Config>(responseText); } return(config); }
/// <summary> /// 获取用户的已阅任务总数 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetUserReadedWorkItemCount(HttpContextBase context) { string count = "0"; string UserCode = context.Request["UserCode"]; count = new WorkFlowFunction().GetUserReadWorkItemCountBySql(UserCode); object obj = new { Result = count }; return(JSSerializer.Serialize(obj)); }
public int GetUnreadMessagesCount(DateTime beginTime, DateTime endTime) { int result = 0; var request = GetRequest("api/user/GetUnreadMessageCount?startTime=" + beginTime + "&endTime=" + endTime); var response = Client.SendAsync(request).Result; if (response.StatusCode == HttpStatusCode.OK) { var responseText = response.Content.ReadAsStringAsync().Result; result = JSSerializer.Deserialize <int>(responseText); } return(result); }
/// <summary> /// 获取用户的待办任务总数 /// </summary> /// <param name="context"></param> /// <returns></returns> private string getUnfinishedWorkItemCount(HttpContextBase context) { int count = 0; string UserCode = context.Request["UserCode"]; count = new WorkFlowFunction().GetUserUnfinishedWorkItemCount(UserCode); object obj = new { Result = count }; return(JSSerializer.Serialize(obj)); }
public async Task <int> GetUserBankCount(string userName) { int result = 0; var request = CreateRequest("api/user/GetUserBankCount?userName=" + userName, HttpMethod.Get); var response = await Client.SendAsync(request); if (response.StatusCode == HttpStatusCode.OK) { var responseText = await response.Content.ReadAsStringAsync(); result = JSSerializer.Deserialize <int>(responseText); } return(result); }
public async Task <UserDeposit> GetLastDeposit() { UserDeposit result = null; var request = GetRequest("api/Deposit/GetLastDeposit"); var response = await Client.SendAsync(request); if (response.StatusCode == HttpStatusCode.OK) { var responseText = await response.Content.ReadAsStringAsync(); result = JSSerializer.Deserialize <UserDeposit>(responseText); } return(result); }
public async Task <int> GetMessageCount(DateTime?beginTime, DateTime?endTime) { int result = 0; var request = GetRequest("api/user/GetMessageCount?startTime=" + beginTime + "&endTime=" + endTime); var response = await Client.SendAsync(request); if (response.StatusCode == HttpStatusCode.OK) { var responseText = await response.Content.ReadAsStringAsync(); result = JSSerializer.Deserialize <int>(responseText); } return(result); }
private string getCinstenceid(HttpContextBase context) { string rtn = ""; string applicationno = context.Request["applicationno"]; WorkFlowFunction wf = new WorkFlowFunction(); rtn = wf.getCinstenceid(applicationno); object obj = new { Result = rtn }; return(JSSerializer.Serialize(obj)); }
private string RSRiskManagement(HttpContextBase context) { bool rtn = false; string instanceid = context.Request["instanceid"]; WorkFlowFunction wf = new WorkFlowFunction(); rtn = wf.SubmitWorkItemByInstanceID(instanceid, ""); object obj = new { Result = rtn }; return(JSSerializer.Serialize(obj)); }
private string indvidualHistoryFinancedAmount(HttpContextBase context) { string rtn = ""; string IdCardNo = context.Request["IdCardNo"]; string applicationno = context.Request["applicationno"]; string currentV = context.Request["currentV"]; WorkFlowFunction wf = new WorkFlowFunction(); rtn = wf.indvidualHistoryFinancedAmount(IdCardNo, applicationno, currentV); object obj = new { Result = rtn }; return(JSSerializer.Serialize(obj)); }
//private string getRejectWorkItem(HttpContextBase context) //{ // string rtn = ""; // string objectids = context.Request["objectids"]; // WorkFlowFunction wf = new WorkFlowFunction(); // rtn = wf.getRejectWorkItem(objectids); // return rtn; //} //[Xss] //public string getRejectWorkItem() //{ // return getRejectWorkItem(HttpContext); //} private string insertLYInfo(HttpContextBase context) { int rtn = 0; string instanceid = context.Request["instanceid"]; string userid = context.Request["userid"]; string ly = context.Request["ly"]; ly = System.Web.HttpUtility.HtmlEncode(ly);// 19.7.3 wangxg rtn = WorkFlowFunction.insertLYInfo(instanceid, userid, ly); object obj = new { Result = rtn }; return(JSSerializer.Serialize(obj)); }
public static T JsonDeserialize <T>(string jsonString) { try { if (string.IsNullOrEmpty(jsonString)) { return(default(T)); } T t = JSSerializer.Deserialize <T>(jsonString); return(t); } catch (Exception ex) { string errorMessage = ex.ToString(); return(default(T)); } }
//private string getssx(HttpContextBase context) //{ // string rtn = ""; // string pcode = context.Request["pcode"]; // string UserCode = context.Request["UserCode"]; // WorkFlowFunction wf = new WorkFlowFunction(); // rtn = wf.getssx(UserCode, pcode); // return rtn; //} //[Xss] //public string getssx() //{ // return getssx(HttpContext); //} //private string getdycs(HttpContextBase context) //{ // string rtn = ""; // string UserCode = context.Request["UserCode"]; // WorkFlowFunction wf = new WorkFlowFunction(); // rtn = wf.getdycs(UserCode); // return rtn; //} //[Xss] //public string getdycs() //{ // return getdycs(HttpContext); //} //private string searchdycs(HttpContextBase context) //{ // string rtn = ""; // string UserCode = context.Request["UserCode"]; // string ids = context.Request["ids"]; // WorkFlowFunction wf = new WorkFlowFunction(); // rtn = wf.searchdycs(ids, UserCode); // return rtn; //} //[Xss] //public string searchdycs() //{ // return searchdycs(HttpContext); //} //private string updatedycs(HttpContextBase context) //{ // string rtn = ""; // string UserCode = context.Request["UserCode"]; // string shen = context.Request["shen"]; // string shi = context.Request["shi"]; // string xian = context.Request["xian"]; // WorkFlowFunction wf = new WorkFlowFunction(); // rtn = wf.updatedycs(UserCode, shen, shi, xian); // return rtn; //} //[Xss] //public string updatedycs() //{ // return updatedycs(HttpContext); //} //private string downloaddycs(HttpContextBase context) //{ // string rtn = ""; // WorkFlowFunction wf = new WorkFlowFunction(); // rtn = wf.downloaddycs(); // return rtn; //} //[Xss] //public string downloaddycs() //{ // return downloaddycs(HttpContext); //} //private string deldycs(HttpContextBase context) //{ // string rtn = ""; // string UserCode = context.Request["UserCode"]; // string ids = context.Request["ids"]; // WorkFlowFunction wf = new WorkFlowFunction(); // rtn = wf.deldycs(ids, UserCode); // return rtn; //} //[Xss] //public string deldycs() //{ // return deldycs(HttpContext); //} private string ldaplogin(HttpContextBase context) { string UserCode = context.Request["UserCode"]; string ls_userid = ""; string ls_username = ""; string ls_password = ""; string cn = ""; try { string ldap_url = System.Configuration.ConfigurationManager.AppSettings["ldap_url"] + string.Empty; string sql = "select sn,dn,cn,userpassword from ldapuser where email='" + UserCode + "'"; DataTable dt = OThinker.H3.Controllers.AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { ls_userid = dt.Rows[0]["dn"].ToString(); ls_username = dt.Rows[0]["sn"].ToString(); ls_password = dt.Rows[0]["userpassword"].ToString(); cn = dt.Rows[0]["cn"].ToString(); jtLDAP a = new jtLDAP(); //a.LDAP_URL = "LDAP://oms2.zhengtongauto.net:3402/dc=zhengtongauto,dc=com"; //a.LDAP_USERID = "cn=" + ls_userid + ",dc=zhengtongauto,dc=com"; a.LDAP_URL = ldap_url; a.LDAP_USERID = ls_userid; a.LDAP_PASSWORD = ls_password; a.GetEntry(); string r = a.f_getPersonMes(cn, "description"); //记录日志信息 LogManager.logPath = AppDomain.CurrentDomain.BaseDirectory + @"bin\ldap-log\"; LogManager.WriteLog(LogFile.Trace, "账号验证成功:" + ls_username + ",返回信息:" + r); } } catch (Exception ex) { //记录日志信息 LogManager.logPath = AppDomain.CurrentDomain.BaseDirectory + @"bin\ldap-log\"; LogManager.WriteLog(LogFile.Trace, "账号验证失败:" + ls_username + ",返回信息:" + ex.Message); } object obj = new { Result = "true" }; return(JSSerializer.Serialize(obj)); }
public void Index() { var context = HttpContext; string Shop = context.Request["Shop"]; string Province = context.Request["Province"]; string City = context.Request["City"]; string SpName = context.Request["SpName"]; string DyName = context.Request["DyName"]; string Page = context.Request["Page"]; string Size = context.Request["Size"]; string method = context.Request["method"]; string pid = context.Request["id"]; string ObjectID = context.Request["ObjectID"] + string.Empty; Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject(); int total = 0; ret.Add("Data", new ReturnData() { Shop = Shop, Province = Province, City = City, SpName = SpName, DyName = DyName, ObjectID = ObjectID }.GetJson(Page, Size, out total)); ret.Add("Total", total); if (method == "GetProvince") { var result = GetArea(string.IsNullOrEmpty(pid) ? "" : pid); context.Response.Write(JSSerializer.Serialize(result)); } if (method == "GetCity" && !string.IsNullOrEmpty(pid)) { var result = GetArea(pid); context.Response.Write(JSSerializer.Serialize(result)); } if (method == "GetPeople") { var result = GetPeople(); context.Response.Write(JSSerializer.Serialize(result)); } if (method == "Data") { context.Response.Write(ret); } }
/// <summary> /// Replace MonoBehaviour with JSComponent, only when this MonoBehaviour has JsType attribute /// Will copy serialized data if needed /// </summary> /// <typeparam name="T"></typeparam> /// <param name="go">GameObject to replace MonoBehaviours.</param> /// <returns>return true if any MonoBehaviour of go has been replaced.</returns> public static bool CopyGameObject(GameObject go) { bool bReplaced = false; var behaviours = go.GetComponents <MonoBehaviour>(); for (var i = 0; i < behaviours.Length; i++) { var behav = behaviours[i]; // ignore JSSerializer here if (behav is JSSerializer) { continue; } if (behav == null) { // Debug.Log("00000000000"); Debug.LogWarning("There is null behaviour in gameObject \"" + go.name + "\""); continue; } if (WillTypeBeTranslatedToJavaScript(behav.GetType())) { // if this MonoBehaviour is going to be translated to JavaScript // replace this behaviour with JSComponent // copy the serialized data if needed //JSSerializer helper = (JSSerializer)go.AddComponent<T>(); JSSerializer helper = JSComponentGenerator.CreateJSComponentInstance(go, behav); if (helper == null) { continue; } CopyBehaviour(behav, helper); bReplaced = true; } } return(bReplaced); }
public static void CreateRule() { var serializer = new JSSerializer(); OrmLiteRepository<Rule> table = new OrmLiteRepository<Rule>(); Rule rule = new Rule(); rule.ActivateBonusInDays = 1; rule.ChargeAmount = 100; rule.BonusLifeTime = 30; rule.Production = true; rule.Sandbox = true; rule.ActivateInDate = DateTime.Now; rule.ActivateOnCharge = true; rule.ChargePercent = 50; rule.LifeTimeFrom = DateTime.Now; rule.LifeTimeTo = DateTime.Now.AddDays(40); rule.Priority = 2; rule.Name = "Rule 2"; ConditionGroup mainGroup = new ConditionGroup(); mainGroup.ExpressionType = ExpressionType.AND; Condition cond1 = new Condition(new BaseCondition()); Dictionary<string, object> cond1Settings = new Dictionary<string, object>(); cond1Settings.Add("Date", DateTime.Now.AddDays(-40)); cond1.ConditionItem.Settings = cond1Settings; cond1.ConditionItem.ConditionId = new Guid("2be12ef8-00b9-47c5-a0cb-d6f15fb02aa5"); mainGroup.Add(cond1); ConditionGroup subGroup1 = new ConditionGroup(); subGroup1.ExpressionType = ExpressionType.AND; Condition cond2 = new Condition(new BaseCondition()); Dictionary<string, object> cond2Settings = new Dictionary<string, object>(); cond2Settings.Add("Date", DateTime.Now.AddDays(-40)); cond2.ConditionItem.Settings = cond2Settings; cond2.ConditionItem.ConditionId = new Guid("2be12ef8-00b9-47c5-a0cb-d6f15fb02aa5"); subGroup1.Add(cond2); mainGroup.Add(subGroup1); var conditionJson = serializer.Serialize(mainGroup); rule.Conditions = conditionJson; LocalRestrictionBase localRestriction = new LocalRestrictionBase(); localRestriction.RestrictionId = new Guid("C6EB436E-1021-45A5-B937-30B6B7BE1970"); localRestriction.Name = "LocalRestriction от бога"; var restrictionSettings = new Dictionary<string, object>(); restrictionSettings.Add("Date", DateTime.Now); localRestriction.Settings = restrictionSettings; LocalActionBase localAction = new LocalActionBase(); localAction.ActionId = new Guid("EB54BD15-D953-4986-AC89-47A9F5E527C0"); localAction.Name = "LocalAction от бога"; var actionSettings = new Dictionary<string, object>(); actionSettings.Add("Date", DateTime.Now); localAction.Settings = actionSettings; List<LocalRestrictionBase> restrictionList = new List<LocalRestrictionBase>(); restrictionList.Add(localRestriction); List<LocalActionBase> actionList = new List<LocalActionBase>(); actionList.Add(localAction); rule.LocalActions = serializer.Serialize(actionList); rule.LocalRestrictions = serializer.Serialize(restrictionList); table.SafeAdd(rule); //Console.WriteLine(json); //Console.ReadKey(); }
public void Alloc(JSSerializer serializer) { eSerialize = SerializeType.String; switch (analyzeType) { case JSSerializer.AnalyzeType.ArrayBegin: AllocString("ArrayBegin/" + this.Name + "/"); break; case JSSerializer.AnalyzeType.ArrayEnd: AllocString("ArrayEnd/" + this.Name + "/"); break; case JSSerializer.AnalyzeType.StructBegin: AllocString("StructBegin/" + this.Name + "/" + JSNameMgr.GetTypeFullName(this.type)); break; case JSSerializer.AnalyzeType.StructEnd: AllocString("StructEnd/" + this.Name + "/" + JSNameMgr.GetTypeFullName(this.type)); break; case JSSerializer.AnalyzeType.ListBegin: AllocString("ListBegin/" + this.Name + "/" + JSNameMgr.GetTypeFullName(typeof(List<>))); break; case JSSerializer.AnalyzeType.ListEnd: AllocString("ListEnd/" + this.Name + "/" + JSNameMgr.GetTypeFullName(typeof(List<>))); break; case JSSerializer.AnalyzeType.Unit: { var sb = new StringBuilder(); // this.value could be null Type objectType = this.type; // this.value.GetType(); if (this.unitType == JSSerializer.UnitType.ST_JavaScriptMonoBehaviour || this.unitType == JSSerializer.UnitType.ST_UnityEngineObject) { eSerialize = SerializeType.Object; if (this.unitType == JSSerializer.UnitType.ST_JavaScriptMonoBehaviour) { if (!typeof(UnityEngine.MonoBehaviour).IsAssignableFrom(objectType) || !WillTypeBeTranslatedToJavaScript(objectType)) { Debug.LogError("unitType is ST_JavaScriptMonoBehaviour, but objectType is not MonoBehaviour or not having JsType attribute."); } // if a monobehaviour is referenced // and this monobehaviour will be translated to js later // ST_MonoBehaviour // add game object var index = AllocObject(((MonoBehaviour)this.value).gameObject); // UnitType / Name / object Index / MonoBehaviour Name sb.AppendFormat("{0}/{1}/{2}/{3}", (int)this.unitType, this.Name, index, JSNameMgr.GetTypeFullName(objectType)); AllocString(sb.ToString()); } else { // UnitType / Name / object Index sb.AppendFormat("{0}/{1}/{2}", (int)this.unitType, this.Name, AllocObject((UnityEngine.Object)this.value)); AllocString(sb.ToString()); } } else { sb.AppendFormat("{0}/{1}/{2}", (int)this.unitType, this.Name, ValueToString(this.value, this.type)); AllocString(sb.ToString()); } } break; } }
public AnalyzeStructInfo(JSSerializer.AnalyzeType at, string name, Type type, object v = null, JSSerializer.UnitType ut = JSSerializer.UnitType.ST_Unknown) { analyzeType = at; Name = name; this.type = type; value = v; unitType = ut; eSerialize = SerializeType.String; }
static void CopyBehaviour(MonoBehaviour behaviour, JSSerializer serizlizer) { lstAnalyze.Clear(); lstString.Clear(); lstObjs.Clear(); // GameObject go = behaviour.gameObject; //Type type = behaviour.GetType(); FieldInfo[] fields = GetMonoBehaviourSerializedFields(behaviour); foreach (FieldInfo field in fields) { AddAnalyze(field.FieldType, field.Name, field.GetValue(behaviour)); } TraverseAnalyze(); for (var i = 0; i < lstAnalyze.Count; i++) { lstAnalyze[i].Alloc(serizlizer); } serizlizer.jsClassName = JSNameMgr.GetTypeFullName(behaviour.GetType()); serizlizer.arrString = lstString.ToArray(); serizlizer.arrObject = lstObjs.ToArray(); }
public static void CreateTables() { var serializer = new JSSerializer(); OrmLiteRepository<LocalRestriction> table = new OrmLiteRepository<LocalRestriction>(); LocalRestriction ent = new LocalRestriction(); ent.LookupItemId = new Guid("c6eb436e-1021-45a5-b937-30b6b7be1970"); ent.Name = "LocalRestriction от бога"; ent.RuleId = new Guid("B999488A-9D27-4318-BE06-99DB84B25139"); ent.Production = true; ent.Sandbox = true; var settings = new Dictionary<string, object>(); settings.Add("Date", DateTime.Now); ent.Settings = serializer.Serialize(settings); ent.CreatedOn = DateTime.Now; table.SafeAdd(ent); }
public void Alloc(JSSerializer serializer) { eSerialize = SerializeType.String; switch (analyzeType) { case JSSerializer.AnalyzeType.ArrayBegin: AllocString("ArrayBegin/" + this.Name + "/"); break; case JSSerializer.AnalyzeType.ArrayEnd: AllocString("ArrayEnd/" + this.Name + "/"); break; case JSSerializer.AnalyzeType.StructBegin: AllocString("StructBegin/" + this.Name + "/" + JSNameMgr.GetTypeFullName(this.type)); break; case JSSerializer.AnalyzeType.StructEnd: AllocString("StructEnd/" + this.Name + "/" + JSNameMgr.GetTypeFullName(this.type)); break; case JSSerializer.AnalyzeType.ListBegin: AllocString("ListBegin/" + this.Name + "/" + JSNameMgr.GetTypeFullName(typeof(List <>))); break; case JSSerializer.AnalyzeType.ListEnd: AllocString("ListEnd/" + this.Name + "/" + JSNameMgr.GetTypeFullName(typeof(List <>))); break; case JSSerializer.AnalyzeType.Unit: { var sb = new StringBuilder(); // this.value could be null Type declaredType = this.type; Type valueType = (this.value != null ? this.value.GetType() : declaredType); if (this.unitType == JSSerializer.UnitType.ST_JavaScriptMonoBehaviour || this.unitType == JSSerializer.UnitType.ST_UnityEngineObject) { eSerialize = SerializeType.Object; if (this.unitType == JSSerializer.UnitType.ST_JavaScriptMonoBehaviour) { if (!typeof(UnityEngine.MonoBehaviour).IsAssignableFrom(valueType) || !WillTypeBeTranslatedToJavaScript(valueType)) { Debug.LogError("unitType is ST_JavaScriptMonoBehaviour, but valueType is not MonoBehaviour or doesn't JsType attribute."); } // if a monobehaviour is referenced // and this monobehaviour will be translated to js later // ST_MonoBehaviour // add game object // this.value can be null int index; if (this.value == null) { index = AllocObject(null); } else { index = AllocObject(((MonoBehaviour)this.value).gameObject); } // UnitType / Name / object Index / MonoBehaviour Name sb.AppendFormat("{0}/{1}/{2}/{3}", (int)this.unitType, this.Name, index, JSNameMgr.GetTypeFullName(valueType)); AllocString(sb.ToString()); } else { // UnitType / Name / object Index sb.AppendFormat("{0}/{1}/{2}", (int)this.unitType, this.Name, AllocObject((UnityEngine.Object) this.value)); AllocString(sb.ToString()); } } else { sb.AppendFormat("{0}/{1}/{2}", (int)this.unitType, this.Name, ValueToString(this.value, this.type)); AllocString(sb.ToString()); } } break; } }
/// <summary> /// 启动H3流程实例(包含子表) /// </summary> /// <typeparam name="T">实体类-泛型</typeparam> /// <param name="workflowCode">流程模板编码</param> /// <param name="userCode">启动流程的用户编码</param> /// <param name="finishStart">是否结束第一个活动</param> /// <param name="EntityParamValues">流程实例启动初始化数据项实体类集合</param> /// <returns></returns> private BPMServiceResult startWorkflowByEntityTrinsJson( string workflowCode, string userCode, bool finishStart, object EntityParamValues) { string workItemID, keyItem, errorMessage; workItemID = keyItem = errorMessage = string.Empty; BPMServiceResult result; try { // 获取模板 OThinker.H3.WorkflowTemplate.PublishedWorkflowTemplateHeader workflowTemplate = GetWorkflowTemplate(workflowCode); if (workflowTemplate == null) { result = new BPMServiceResult(false, "流程启动失败,流程模板不存在,模板编码:" + workflowCode + "。"); return(result); } // 查找流程发起人 //OThinker.Organization.User user = OThinker.H3.Controllers.AppUtility.Engine.Organization.GetUserByCode(userCode) as OThinker.Organization.User; string user = "******";// GetUserIDByCode(userCode); //"18f923a7-5a5e-426d-94ae-a55ad1a4b239"; // if (user == null) { result = new BPMServiceResult(false, "流程启动失败,用户{" + userCode + "}不存在。"); return(result); } OThinker.H3.DataModel.BizObjectSchema schema = OThinker.H3.Controllers.AppUtility.Engine.BizObjectManager.GetPublishedSchema(workflowTemplate.BizObjectSchemaCode); OThinker.H3.DataModel.BizObject bo = new OThinker.H3.DataModel.BizObject( OThinker.H3.Controllers.AppUtility.Engine.Organization, OThinker.H3.Controllers.AppUtility.Engine.MetadataRepository, OThinker.H3.Controllers.AppUtility.Engine.BizObjectManager, OThinker.H3.Controllers.AppUtility.Engine.BizBus, schema, OThinker.Organization.User.AdministratorID, OThinker.Organization.OrganizationUnit.DefaultRootID); if (EntityParamValues != null) { Newtonsoft.Json.Linq.JObject jObject = Newtonsoft.Json.Linq.JObject.Parse(EntityParamValues.ToString()); foreach (KeyValuePair <string, Newtonsoft.Json.Linq.JToken> jo in jObject) { //如果字段是GTAttachment则是附件 if (bo.Schema.ContainsField(jo.Key)) { if (bo.Schema.GetLogicType(jo.Key) == OThinker.H3.Data.DataLogicType.Comment) { continue; } //判断是否子表 else if (bo.Schema.GetLogicType(jo.Key) != OThinker.H3.Data.DataLogicType.BizObjectArray) { //给对象赋值 bo[jo.Key] = jo.Value; } else { List <object> list = JSSerializer.Deserialize <List <object> >(Newtonsoft.Json.JsonConvert.SerializeObject(jo.Value) as string); //获取子表的属性 BizObjectSchema childSchema = schema.GetProperty(jo.Key).ChildSchema; BizObject[] bizObjects = new BizObject[list.Count]; int i = 0; foreach (object objT in list) { bizObjects[i] = new BizObject(OThinker.H3.Controllers.AppUtility.Engine, childSchema, userCode); foreach (KeyValuePair <string, object> t in (dynamic)objT) { if (childSchema.ContainsField(t.Key)) { //给对象赋值 bizObjects[i][t.Key] = t.Value; continue; } } i++; } //子表回写给流程子表 bo[jo.Key] = bizObjects; } } } } bo.Create(); // 创建流程实例 string InstanceId = OThinker.H3.Controllers.AppUtility.Engine.InstanceManager.CreateInstance( bo.ObjectID, workflowTemplate.WorkflowCode, workflowTemplate.WorkflowVersion, null, null, user, null, false, OThinker.H3.Instance.InstanceContext.UnspecifiedID, null, OThinker.H3.Instance.Token.UnspecifiedID); // 设置紧急程度为普通 OThinker.H3.Messages.MessageEmergencyType emergency = OThinker.H3.Messages.MessageEmergencyType.Normal; // 这里也可以在启动流程的时候赋值 Dictionary <string, object> paramTables = new Dictionary <string, object>(); // 启动流程的消息 OThinker.H3.Messages.StartInstanceMessage startInstanceMessage = new OThinker.H3.Messages.StartInstanceMessage( emergency, InstanceId, workItemID, paramTables, OThinker.H3.Instance.PriorityType.Normal, true, null, false, OThinker.H3.Instance.Token.UnspecifiedID, null); OThinker.H3.Controllers.AppUtility.Engine.InstanceManager.SendMessage(startInstanceMessage); result = new BPMServiceResult(true, InstanceId, workItemID, "流程实例启动成功!", ""); } catch (Exception ex) { result = new BPMServiceResult(false, "流程实例启动失败!错误:" + ex + string.Empty); } return(result); }