public JsonItemCollection GetFactorys(IDbConnection cn) { JsonItemCollection factorys = new JsonItemCollection(); using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cn as SqlConnection; cmd.CommandText = "SELECT * FROM iSYSFactory"; using (YZReader reader = new YZReader(cmd.ExecuteReader())) { while (reader.Read()) { JsonItem factory = new JsonItem(); factorys.Add(factory); factory.Attributes["ID"] = reader.ReadInt32("ID"); factory.Attributes["Name"] = reader.ReadString("Name"); factory.Attributes["MapX"] = reader.ReadInt32("MapX"); factory.Attributes["MapY"] = reader.ReadInt32("MapY"); } } } return factorys; }
private void BindDefaultResultConsumerConfig(string parentId) { var ji = new JsonItem(); ji.Id = Guid.NewGuid().ToString(); ji.IsObject = true; ji.Key = "Sample"; ji.ParentId = parentId; _defaultNormalERMSConfig.Add(ji); _defaultNormalERMSConfig.AddRange(NormalList2(ji.Id)); ji = new JsonItem(); ji.Id = Guid.NewGuid().ToString(); ji.IsObject = true; ji.Key = "Result"; ji.ParentId = parentId; _defaultNormalERMSConfig.Add(ji); _defaultNormalERMSConfig.AddRange(NormalList2(ji.Id)); ji = new JsonItem(); ji.Id = Guid.NewGuid().ToString(); ji.IsObject = true; ji.Key = "ResultNG42"; ji.ParentId = parentId; _defaultNormalERMSConfig.Add(ji); _defaultNormalERMSConfig.AddRange(NormalList2(ji.Id)); ji = new JsonItem(); ji.Id = Guid.NewGuid().ToString(); ji.IsObject = true; ji.Key = "SampleNG43"; ji.ParentId = parentId; _defaultNormalERMSConfig.Add(ji); _defaultNormalERMSConfig.AddRange(NormalList2(ji.Id)); ji = new JsonItem(); ji.Id = Guid.NewGuid().ToString(); ji.IsObject = true; ji.Key = "ResultNG43"; ji.ParentId = parentId; _defaultNormalERMSConfig.Add(ji); _defaultNormalERMSConfig.AddRange(NormalList2(ji.Id)); ji = new JsonItem(); ji.Id = Guid.NewGuid().ToString(); ji.IsObject = true; ji.Key = "AccountsConsumer"; ji.ParentId = parentId; _defaultNormalERMSConfig.Add(ji); _defaultNormalERMSConfig.AddRange(AccountConsumerList(ji.Id)); ji = new JsonItem(); ji.Id = Guid.NewGuid().ToString(); ji.IsObject = true; ji.Key = "StatusUpdateAlerts"; ji.ParentId = parentId; _defaultNormalERMSConfig.Add(ji); _defaultNormalERMSConfig.AddRange(StatusUpdateAlertList(ji.Id)); }
public static void AshxAuthCheck(bool checkLogin) { if (String.Compare(System.Web.Configuration.WebConfigurationManager.AppSettings["ShowMaintenancePage"], "true", true) == 0) { HttpContext.Current.Response.StatusCode = 500; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 100); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } else if (checkLogin && !YZAuthHelper.IsAuthenticated) { HttpContext.Current.Response.StatusCode = 200; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 101); rv.Attributes.Add("errorMessage", "登录超时"); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } }
public static void AshxAuthCheck(bool checkLogin) { if (String.Compare(System.Web.Configuration.WebConfigurationManager.AppSettings["ShowMaintenancePage"], "true", true) == 0) { HttpContext.Current.Response.StatusCode = 500; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 100); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } else if (checkLogin && !YZAuthHelper.IsAuthenticated) { HttpContext.Current.Response.StatusCode = 200; JsonItem rv = new JsonItem(); rv.Attributes.Add("success", false); rv.Attributes.Add("errorCode", 101); rv.Attributes.Add("errorMessage", Resources.YZStrings.Aspx_LoginTimeout); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rv.ToString()); HttpContext.Current.Response.End(); } }
/** AddFirst * * List。追加。 * */ public void AddFirst(ModeAddList a_mode, JsonItem a_from_listitem_json, System.Collections.IList a_to_list, System.Type a_to_listitem_type) { WorkPool_Item t_item = new WorkPool_Item(); { //モード。 t_item.mode = (int)a_mode; //設定元。 t_item.from_value_jsonitem = a_from_listitem_json; t_item.from_key_jsonitem = null; //設定先。 t_item.to_value_type = a_to_listitem_type; t_item.to_key_type = null; t_item.to_value_object = null; t_item.to_key_object = null; t_item.to_list = a_to_list; t_item.to_index = 0; t_item.to_dictionary = null; t_item.to_fieldinfo = null; t_item.to_parent_object = null; t_item.to_enumerable = null; t_item.to_methodinfo = null; } this.list.AddFirst(t_item); }
private async void RefreshViewer() { JsonItem item = new JsonItem(); string jsonString = _document.Text; var task = Task.Run(() => { try { JToken json = JToken.Parse(jsonString); item = new JsonItem(json, null, true); } catch (Exception ex) { Workspace.Instance.Report.AddReportWithIdentifier($"{ex.Message}\r\n{ex.StackTrace}", ReportType.Warning); } }); Workspace.Instance.SetStatus(TaskStatusType.Loading, $"Refresh a file... ({FilePath})"); _items.Clear(); await task; try { _items.Add(item); } catch (Exception ex) { Workspace.Instance.Report.AddReportWithIdentifier($"{ex.Message}\r\n{ex.StackTrace}", ReportType.Warning); } Workspace.Instance.Report.AddReportWithIdentifier($"JSON Viewer has been refreshed.", ReportType.Information); Workspace.Instance.SetStatus(TaskStatusType.Completed, $"Completed."); }
public JsonItemCollection GetFactorys(IDbConnection cn) { JsonItemCollection factorys = new JsonItemCollection(); using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cn as SqlConnection; cmd.CommandText = "SELECT * FROM iSYSFactory"; using (YZReader reader = new YZReader(cmd.ExecuteReader())) { while (reader.Read()) { JsonItem factory = new JsonItem(); factorys.Add(factory); factory.Attributes["ID"] = reader.ReadInt32("ID"); factory.Attributes["Name"] = reader.ReadString("Name"); factory.Attributes["MapX"] = reader.ReadInt32("MapX"); factory.Attributes["MapY"] = reader.ReadInt32("MapY"); } } } return(factorys); }
public static void ApplayRecordPermision(BPMConnection cn, JsonItemCollection items, string rsid, string tableName, string jsonitemKeyAttrName) { //获得资源上的记录级权限种类 UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, rsid); BPMObjectNameCollection permNames = new BPMObjectNameCollection(); foreach (UserResourcePermision resourcePerm in resourcePerms) { if (resourcePerm.PermType == UserResourcePermisionType.Record) { permNames.Add(resourcePerm.PermName); } } //应用权限 foreach (JsonItem item in items) { string key = Convert.ToString(item.Attributes[jsonitemKeyAttrName]); bool[] rv = RecordSecurityManager.CheckPermision(cn, tableName, key, permNames); JsonItem jsonPerm = new JsonItem(); item.Attributes["perm"] = jsonPerm; for (int i = 0; i < permNames.Count; i++) { jsonPerm.Attributes[permNames[i]] = rv[i]; } } }
/** AddFirst * * FieldInfo * */ public void AddFirst(ModeFieldInfo a_mode, JsonItem a_from_member_jsonitem, System.Reflection.FieldInfo a_to_fieldinfo, System.Object a_to_parent_object) { WorkPool_Item t_item = new WorkPool_Item(); { //モード。 t_item.mode = (int)a_mode; //設定元。 t_item.from_value_jsonitem = a_from_member_jsonitem; t_item.from_key_jsonitem = null; //設定先。 t_item.to_value_type = a_to_fieldinfo.FieldType; t_item.to_key_type = null; t_item.to_value_object = null; t_item.to_key_object = null; t_item.to_list = null; t_item.to_index = 0; t_item.to_dictionary = null; t_item.to_fieldinfo = a_to_fieldinfo; t_item.to_parent_object = a_to_parent_object; t_item.to_enumerable = null; t_item.to_methodinfo = null; } this.list.AddFirst(t_item); }
/** Add * * FieldInfo。 * */ public void Add(ModeFieldInfo a_mode, JsonItem a_to_jsonitem, System.Reflection.FieldInfo a_from_fieldinfo, System.Object a_from_parent_object, int a_nest) { WorkPool_Item t_item = new WorkPool_Item(); { //モード。 t_item.mode = (int)a_mode; //ネスト。 t_item.nest = a_nest; //コンバート元、インスタンス。 t_item.from_fieldinfo = a_from_fieldinfo; t_item.from_parent_object = a_from_parent_object; t_item.from_object = null; t_item.from_type = null; t_item.from_option = ConvertToJsonItemOption.None; //コンバート先。JSON。 t_item.to_jsonitem = a_to_jsonitem; t_item.to_index = 0; t_item.to_key_string = null; } this.list.Add(t_item); }
public override Type GetReversiveType(JsonItem item) { var d = item.Value as IDictionary <string, object>; if (d == null) { return(null); } if (d.ContainsKey("Vip")) { return(typeof(PersonInfo)); } else if (d.ContainsKey("Value")) { var v = d["Value"]; if (v is bool) { return(typeof(NamedClassA)); } // NOTE: keep in mind that there's no Int32 in primitive types if (v is long) { return(typeof(NamedClassB)); } } return(null); }
protected void Page_Load(object sender, EventArgs e) { userid = Request["uid"]; password = Request["PWD"]; JsonItem rv = new JsonItem(); string realAccount = null; try { if (BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, userid, password, out realAccount)) { YZAuthHelper.SetAuthCookie(realAccount); YZAuthHelper.ClearLogoutFlag(); rv.Attributes["success"] = true; rv.Attributes["text"] = "登陆成功"; } } catch (Exception ex) { rv.Attributes["success"] = true; rv.Attributes["text"] = ex.Message; } }
private JsonItem GetDeepNode(Person person) { if (_processed.ContainsKey(person)) { return(new JsonItem(_processed[person])); } var personNode = new JsonItem(Utils.GetPersonDescription(person)); _processed.Add(person, personNode); var marriages = _marriages .Where(x => x.husband_id == person.id || x.wife_id == person.id) .ToList(); foreach (var marriage in marriages) { var marriageNode = GetMarriageNode(person, marriage); var childrenNodes = GetChildrenNodes(marriage); if (childrenNodes != null) { marriageNode.AddChildren(childrenNodes.ToArray()); } personNode.AddChildren(marriageNode); } return(personNode); }
private string GetJsonStringValue(JsonItem item) { //var value = string.Empty; //item.TryGetValue(out value); //return value; throw new NotImplementedException(); }
/** * 打开JSON View */ private void showJSONItem_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.selectedJSONStr)) { return; } string hexStr = this.selectedJSONStr.Replace(Global.JSON_TAG, String.Empty); int index = decodeJSONIndex(hexStr.Trim()); JsonItem jsonItem = this.logFileItem.jsonList[index]; if (jsonItem == null) { return; } if (null == this.oJsonViewForm || this.oJsonViewForm.IsDisposed) { this.oJsonViewForm = new JsonViewForm(jsonItem.Content); } this.oJsonViewForm.showJSONView(jsonItem.Content); this.oJsonViewForm.StartPosition = FormStartPosition.CenterScreen; this.oJsonViewForm.Show(); }
private string GetJsonStringValue(JsonItem item) { var value = string.Empty; item.TryGetValue(out value); return(value); }
/** AddFirst * * Dictionary。追加。 * */ public void AddFirst(ModeAddStringDictionary a_mode, JsonItem a_from_listitem_jsonitem, string a_from_key_string, System.Collections.IDictionary a_to_dictionary, System.Type a_to_listitem_type) { JsonItemToObject_WorkPool_Item t_item = new JsonItemToObject_WorkPool_Item(); { //モード。 t_item.mode = (int)a_mode; //設定元。 t_item.from_value_jsonitem = a_from_listitem_jsonitem; t_item.from_key_jsonitem = null; //設定先。 t_item.to_value_type = a_to_listitem_type; t_item.to_key_type = null; t_item.to_value_object = null; t_item.to_key_object = a_from_key_string; t_item.to_list = null; t_item.to_index = 0; t_item.to_dictionary = a_to_dictionary; t_item.to_fieldinfo = null; t_item.to_parent_object = null; t_item.to_enumerable = null; t_item.to_methodinfo = null; } this.list.AddFirst(t_item); }
private void btnSelectKey_Click(object sender, EventArgs e) { try { var selectedTN = this.tvJsonMain.SelectedNode; if (selectedTN == null) { return; } var ids = selectedTN.Tag.ToString().Split('|'); var fileId = ids[0]; var elementId = ids[1]; var file = this.JsonFileList.FirstOrDefault(x => x.Id == fileId); var element = file.JsonItems.FirstOrDefault(x => x.Id == elementId && !x.IsDeleted); var parentElement = file.JsonItems.FirstOrDefault(x => x.Id == element.ParentId && !x.IsDeleted); element.ParentKey = parentElement == null ? "" : parentElement.Key; SelectedCurrentElement = element; } catch { MessageBox.Show("No element selected."); } }
JsonObject ParseObject() { JsonObject result = new JsonObject(); do { JsonItem propName = ParseNext(); if (!(propName is JsonValue) || string.IsNullOrEmpty(((JsonValue)propName).Value)) { throw new TranslationException("JSON parsing error. Not found property name at pos : " + (position).ToString() + " in string : " + data); } string propNameStr = ((JsonValue)propName).Value; if (result.ContainsKey(propNameStr)) { throw new TranslationException("JSON parsing error. The property " + propNameStr + "already exists. At pos : " + (position - 1).ToString() + " in string : " + data); } if (GetNextChar() != ":") { throw new TranslationException("JSON parsing error. Not found ':' at pos : " + (position - 1).ToString() + " in string : " + data); } JsonItem next = ParseNext(); result.Add(propNameStr, next); }while(GetNextChar() != "}"); return(result); }
/*extracts the name out of a json string*/ public string getDate(JsonItem item) { string date = item.Date.Split('T')[0]; string[] dateVals = date.Split('-'); return(dateVals[2] + "." + dateVals[1] + "." + dateVals[0][2] + dateVals[0][3]); }
public static JsonItem GetTaskStateJsonItem(BPMConnection cn, TaskState state, int taskid) { JsonItem rv = new JsonItem(); rv.Attributes.Add("State", state.ToString().ToLower()); if (state == TaskState.Running) { JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); foreach (BPMProcStep step in steps) { JsonItem item = new JsonItem(); item.Attributes.Add("StepName", step.StepDisplayName); item.Attributes.Add("Share", step.Share); item.Attributes.Add("RecipientAccount", step.RecipientAccount); item.Attributes.Add("RecipientDisplayName", step.RecipientFullName); children.Add(item); } } return(rv); }
/** Add * * IndexArray。追加。 * */ public void Add(ModeAddIndexArray a_mode, JsonItem a_to_jsonitem, System.Object a_from_listitem_object, System.Type a_from_listitem_type, ConvertToJsonItemOption a_from_option, int a_nest) { WorkPool_Item t_item = new WorkPool_Item(); { //mode t_item.mode = (int)a_mode; //nest t_item.nest = a_nest; //コンバート元、インスタンス。 t_item.from_fieldinfo = null; t_item.from_parent_object = null; t_item.from_object = a_from_listitem_object; t_item.from_type = a_from_listitem_type; t_item.from_option = a_from_option; //コンバート先。JSON。 t_item.to_jsonitem = a_to_jsonitem; t_item.to_index = 0; t_item.to_key_string = null; } this.list.Add(t_item); }
/** JsonItem => Json文字列。 */ public static void JsonItemToJsonString(JsonItem a_jsonitem, System.Text.StringBuilder a_stringbuilder, ConvertToJsonStringOption a_option) { if (a_jsonitem != null) { a_jsonitem.ConvertToJsonString(a_stringbuilder, a_option); } }
public static Item ToItem(JsonItem ji) { // TODO : Item Effect from ID/Name if (ji == null) { return(null); } else { Item res = new Item(SlotUtil.FromString(ji.Slot), new Attributes(ji.Stats), ji.Id, ji.Name, ClassicCraft.Enchantment.ToEnchantment(ji.Enchantment), null); if (res.Attributes != null) { res.Attributes.SetValue(Attribute.CritChance, res.Attributes.GetValue(Attribute.CritChance) / 100); res.Attributes.SetValue(Attribute.HitChance, res.Attributes.GetValue(Attribute.HitChance) / 100); res.Attributes.SetValue(Attribute.Haste, res.Attributes.GetValue(Attribute.Haste) / 100); res.Attributes.SetValue(Attribute.SpellHitChance, res.Attributes.GetValue(Attribute.SpellHitChance) / 100); res.Attributes.SetValue(Attribute.SpellCritChance, res.Attributes.GetValue(Attribute.SpellCritChance) / 100); } if (res.Enchantment != null) { res.Enchantment.Attributes.SetValue(Attribute.CritChance, res.Enchantment.Attributes.GetValue(Attribute.CritChance) / 100); res.Enchantment.Attributes.SetValue(Attribute.HitChance, res.Enchantment.Attributes.GetValue(Attribute.HitChance) / 100); res.Enchantment.Attributes.SetValue(Attribute.Haste, res.Enchantment.Attributes.GetValue(Attribute.Haste) / 100); res.Enchantment.Attributes.SetValue(Attribute.SpellHitChance, res.Enchantment.Attributes.GetValue(Attribute.SpellHitChance) / 100); res.Enchantment.Attributes.SetValue(Attribute.SpellCritChance, res.Enchantment.Attributes.GetValue(Attribute.SpellCritChance) / 100); } return(res); } }
private JsonItem GetMarriageNode(Person person, Marriage marriage) { var marriageStr = Utils.GetMarriageDescription(marriage); var partnerId = (marriage.husband_id == person.id) ? marriage.wife_id : marriage.husband_id; var partner = _persons.Where(x => x.id == partnerId).SingleOrDefault(); var partnerNode = default(JsonItem); if (partner != null) { if (_processed.ContainsKey(partner)) { partnerNode = new JsonItem(GetFullMarriageDescription(marriageStr, Utils.GetDuplicateStr(partner))); } else { partnerNode = new JsonItem(GetFullMarriageDescription(marriageStr, Utils.GetPersonDescription(partner))); } } else { partnerNode = new JsonItem(GetFullMarriageDescription(marriageStr, "(unknown)")); } return(partnerNode); }
private static string GetJsonStringValue(JsonItem item) { string value; item.TryGetValue(out value); return(value); }
private List <JsonItem> GetChildrenNodes(Marriage marriage) { var childrenNodes = default(List <JsonItem>); var sons = _sons.Where(x => x.marriage_id == marriage.id).ToList(); if (sons.Any()) { childrenNodes = new List <JsonItem>(); foreach (var son in sons) { var sonPerson = _persons.Where(x => x.id == son.person_id).Single(); var sonNode = default(JsonItem); if (_processed.ContainsKey(sonPerson)) { sonNode = new JsonItem(_processed[sonPerson]); } else { sonNode = GetDeepNode(sonPerson); } childrenNodes.Add(sonNode); } } return(childrenNodes); }
/** AddFirst * * Enumerable * */ public void AddFirst(ModeIEnumerable a_mode, JsonItem a_from_member_jsonitem, System.Collections.IEnumerable a_to_enumerable, System.Reflection.MethodInfo a_to_methodinfo, System.Type a_to_listitem_type) { JsonItemToObject_WorkPool_Item t_item = new JsonItemToObject_WorkPool_Item(); { //モード。 t_item.mode = (int)a_mode; //設定元。 t_item.from_value_jsonitem = a_from_member_jsonitem; t_item.from_key_jsonitem = null; //設定先。 t_item.to_value_type = a_to_listitem_type; t_item.to_key_type = null; t_item.to_value_object = null; t_item.to_key_object = null; t_item.to_list = null; t_item.to_index = 0; t_item.to_dictionary = null; t_item.to_fieldinfo = null; t_item.to_parent_object = null; t_item.to_enumerable = a_to_enumerable; t_item.to_methodinfo = a_to_methodinfo; } this.list.AddFirst(t_item); }
public static Dictionary <Player.Slot, Item> ToEquipment(JsonWeapon mh, JsonWeapon oh, JsonWeapon ranged, Dictionary <string, JsonItem> je) { Dictionary <Player.Slot, Item> res = new Dictionary <Player.Slot, Item>(); foreach (Player.Slot slot in (Player.Slot[])Enum.GetValues(typeof(Player.Slot))) { if (slot == Player.Slot.MH) { res.Add(slot, JsonWeapon.ToWeapon(mh)); } else if (slot == Player.Slot.OH) { res.Add(slot, JsonWeapon.ToWeapon(oh)); } else if (slot == Player.Slot.Ranged) { res.Add(slot, JsonWeapon.ToWeapon(ranged)); } else { Item i = null; string s = Player.FromSlot(slot); if (je.ContainsKey(s)) { i = JsonItem.ToItem(je[s]); } res.Add(slot, JsonItem.ToItem(je[Player.FromSlot(slot)])); } } return(res); }
private string GetJsonPropertyStringValue(JsonItem item, string property) { var value = string.Empty; var prop = item.GetProperty(property); prop.TryGetValue(out value); return(value); }
private string GetJsonPropertyStringValue(JsonItem item, string property) { //var value = string.Empty; //var prop = item.GetProperty(property); //prop.TryGetValue(out value); //return value; throw new NotImplementedException(); }
/** Fee。オブジェクト => Json文字列。 */ public static void ObjectToJsonString_Fee <Type>(Type a_instance, System.Text.StringBuilder a_stringbuilder, ConvertToJsonItemOption a_option_tojsonitem, ConvertToJsonStringOption a_option_tojsonstring) { if (a_instance != null) { JsonItem t_jsonitem = ConvertObjectToJsonItem.ConvertObjectToJsonItem.Convert(a_instance, a_instance.GetType(), a_option_tojsonitem, null, 0); t_jsonitem.ConvertToJsonString(a_stringbuilder, a_option_tojsonstring); } }
void IJsonConverter.SerializationConvert(JsonItem item) { if (UseTextualForm) { item._Value = (bool)item._Value ? "1" : "0"; } else { item._Value = (bool)item._Value ? 1 : 0; } }
public void Applay(JsonItem itm, string ignoreAttr) { foreach (string attr in itm.Attributes.Keys) { if (NameCompare.EquName(attr, ignoreAttr)) continue; this.Attributes[attr] = itm.Attributes[attr]; } }
void IJsonConverter.DeserializationConvert(JsonItem item) { throw new NotImplementedException (); //var d = new XmlDocument (); //var nl = item.Value as IList<object>; //if (nl != null) { // foreach (var node in nl) { // RevertNode (d, node); // } //} }
void IJsonConverter.SerializationConvert(JsonItem item) { var v = item.Value as XmlNode; if (v == null) return; var nt = v.NodeType; if (nt == XmlNodeType.Element) { item.Value = ConvertElement ((XmlElement)v); } else if (nt == XmlNodeType.Document || nt == XmlNodeType.DocumentFragment) { item.Value = ConvertNode (v); } }
void IJsonConverter.DeserializationConvert(JsonItem item) { var v = item._Value; if (v == null) { item._Value = false; } var s = v as string; if (s != null) { item._Value = s.Trim () != "0"; } if (v is long) { item._Value = (long)v != 0L; } }
public void Serialize(BPMConnection cn,JsonItem item) { User user = null; if (cn != null) user = User.TryGetUser(cn, this.uid); if (user == null) { user = new User(); user.Account = this.uid; } item.Attributes["id"] = this.id; item.Attributes["uid"] = user.Account; item.Attributes["uname"] = user.ShortName; item.Attributes["date"] = YZStringHelper.DateToStringM(this.date); item.Attributes["resType"] = this.resType.ToString(); item.Attributes["resId"] = this.resId; item.Attributes["message"] = this.message; }
public void WhenIParseTheContentAsAJsonString(string type) { this.buffer = new ParseBuffer(this.jsonContent); if (type == "string") { this.jsonItem = new JsonStringParser(buffer).ParseNext(); } else if (type == "number") { this.jsonItem = new JsonNumberParser(buffer).ParseNext(); } else if (type == "boolean") { this.jsonItem = new JsonBooleanParser(buffer).ParseNext(); } else if (type == "null") { this.jsonItem = new JsonNullParser(buffer).ParseNext(); } else { Assert.Fail("unknown parser type."); } }
public static JsonItem GetTaskStateJsonItem(BPMConnection cn, TaskState state, int taskid) { JsonItem rv = new JsonItem(); rv.Attributes.Add("State", state.ToString().ToLower()); if (state == TaskState.Running) { JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); foreach (BPMProcStep step in steps) { JsonItem item = new JsonItem(); item.Attributes.Add("StepName", step.StepDisplayName); item.Attributes.Add("Share", step.Share); item.Attributes.Add("RecipientAccount", step.RecipientAccount); item.Attributes.Add("RecipientDisplayName", step.RecipientFullName); children.Add(item); } } return rv; }
private long? GetJsonPropertyNullableLongValue(JsonItem item, string property) { //long value; //var prop = item.GetProperty(property); //if (prop.TryGetValue(out value)) //{ // return value; //} //return null; throw new NotImplementedException(); }
private JobStatusCode GetJobStatusCodeValue(JsonItem item, string property) { //var jobStatus = JobStatusCode.Unknown; //var value = string.Empty; //var prop = item.GetProperty(property); //prop.TryGetValue(out value); //if (value.IsNotNullOrEmpty()) //{ // if (!Enum.TryParse(value, true, out jobStatus)) // { // jobStatus = JobStatusCode.Unknown; // } //} //return jobStatus; throw new NotImplementedException(); }
private JsonObject GetJsonObject(JsonItem item, string property) { //var prop = item.GetProperty(property); //if (prop == null || !prop.IsValidObject()) //{ // return null; //} //return (JsonObject)prop; throw new NotImplementedException(); }
private IEnumerable<string> GetJsonArray(JsonItem item, string property) { var prop = item.GetProperty(property); if (prop == null || !prop.IsValidArray()) { return null; } var ret = new List<string>(); var array = (JsonArray)prop; for (var i = 0; i < array.Count(); i++) { var value = this.GetJsonStringValue(array.GetIndex(i)); if (!string.IsNullOrEmpty(value)) { ret.Add(value); } } return ret; }
public static void ApplayPermision(BPMConnection cn, JsonItemCollection items) { for(int moduleIndex = 0; moduleIndex < items.Count ; moduleIndex++) { JsonItem item = items[moduleIndex]; bool moduleExecute = true; if (item.Attributes.ContainsKey("modulePerm")) { YZModulePermision perm = item.Attributes["modulePerm"] as YZModulePermision; item.Attributes.Remove("modulePerm"); //检查模块权限 moduleExecute = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, "Execute"); if (moduleExecute) { //获得模块config配置项 JsonItem config = null; if (item.Attributes.ContainsKey("config")) config = item.Attributes["config"] as JsonItem; else { config = new JsonItem(); item.Attributes["config"] = config; } //在config配置项下建perm配置 JsonItem jsonPerm = new JsonItem(); config.Attributes["perm"] = jsonPerm; //记录模块rsid jsonPerm.Attributes["rsid"] = perm.RSID; //生成工具条上的访问权限 if (perm.GenToolbarPermision) { //获得工具条上的模块级权限种类 UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, perm.RSID); BPMObjectNameCollection permNames = new BPMObjectNameCollection(); foreach (UserResourcePermision resourcePerm in resourcePerms) { if (resourcePerm.PermType == UserResourcePermisionType.Module) permNames.Add(resourcePerm.PermName); } //记录工具条上的模块级权限许可情况 bool[] rv = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, permNames); for (int i = 0; i < permNames.Count; i++) jsonPerm.Attributes[permNames[i]] = rv[i]; } } else { items.RemoveAt(moduleIndex); moduleIndex--; } } //此模块可见则检查子级 if (moduleExecute) { if (item.Attributes.ContainsKey("children")) { JsonItemCollection children = item.Attributes["children"] as JsonItemCollection; if (children != null) { int allCount = children.Count; ApplayPermision(cn, children); if (allCount != 0 && children.Count == 0) { //item.Attributes["empty"] = true; items.RemoveAt(moduleIndex); moduleIndex--; continue; } } } if (item.Attributes.ContainsKey("tabs")) { JsonItemCollection tabs = item.Attributes["tabs"] as JsonItemCollection; if (tabs != null) { int allCount = tabs.Count; ApplayPermision(cn, tabs); if (allCount != 0 && tabs.Count == 0) { //item.Attributes["empty"] = true; items.RemoveAt(moduleIndex); moduleIndex--; continue; } } } } } }
Type IJsonConverter.GetReversiveType(JsonItem item) { return null; }
private JobStatusCode GetJobStatusCodeValue(JsonItem item, string property) { var jobStatus = JobStatusCode.Unknown; var value = string.Empty; var prop = item.GetProperty(property); prop.TryGetValue(out value); if (value.IsNotNullOrEmpty()) { if (!Enum.TryParse(value, true, out jobStatus)) { jobStatus = JobStatusCode.Unknown; } } return jobStatus; }
private string GetJsonPropertyStringValue(JsonItem item, string property) { var value = string.Empty; var prop = item.GetProperty(property); prop.TryGetValue(out value); return value; }
private IEnumerable<string> GetJsonArray(JsonItem item, string property) { //var prop = item.GetProperty(property); //if (prop == null || !prop.IsValidArray()) //{ // return null; //} //var ret = new List<string>(); //var array = (JsonArray)prop; //for (var i = 0; i < array.Count(); i++) //{ // var value = this.GetJsonStringValue(array.GetIndex(i)); // if (!string.IsNullOrEmpty(value)) // { // ret.Add(value); // } //} //return ret; throw new NotImplementedException(); }
private string GetJsonStringValue(JsonItem item) { var value = string.Empty; item.TryGetValue(out value); return value; }
private bool GetJobId(JsonItem details, out string jobId) { var jobIdJson = details.GetProperty(JobId); if (jobIdJson == null || jobIdJson.IsNullOrMissing || jobIdJson.IsError) { var id = details.GetProperty(ParentId); return id.TryGetValue(out jobId); } return jobIdJson.TryGetValue(out jobId); }
private long? GetJsonPropertyNullableLongValue(JsonItem item, string property) { long value; var prop = item.GetProperty(property); if (prop.TryGetValue(out value)) { return value; } return null; }
private bool GetJobId(JsonItem details, out string jobId) { //var jobIdJson = details.GetProperty(JobId); //if (jobIdJson == null || jobIdJson.IsNullOrMissing || jobIdJson.IsError) //{ // var id = details.GetProperty(ParentId); // return id.TryGetValue(out jobId); //} //return jobIdJson.TryGetValue(out jobId); throw new NotImplementedException(); }
private string GetJsonStringValue(JsonItem item) { string value; item.TryGetValue(out value); return value; }
internal string ConvertToJSON(object obj, ReflectionCache cache) { if (cache.CommonType == ComplexType.Dictionary || cache.CommonType == ComplexType.List) { _useGlobalTypes = false; } var cv = cache.Converter; if (cv != null) { var ji = new JsonItem (String.Empty, obj, false); cv.SerializationConvert (ji); if (ReferenceEquals (obj, ji._Value) == false) { obj = ji._Value; } cache = _manager.GetReflectionCache (obj.GetType ()); } var m = cache.SerializeMethod; if (m != null) { if (cache.CollectionName != null) { WriteObject (obj); } else { m (this, obj); } } else { WriteValue (obj); } if (_useGlobalTypes && _globalTypes != null && _globalTypes.Count > 0) { var sb = new StringBuilder (); sb.Append ("\"" + JsonDict.ExtTypes + "\":{"); var pendingSeparator = false; foreach (var kv in _globalTypes) { sb.Append (pendingSeparator ? ",\"" : "\""); sb.Append (kv.Key); sb.Append ("\":\""); sb.Append (ValueConverter.Int32ToString (kv.Value)); sb.Append ('\"'); pendingSeparator = true; } sb.Append ("},"); _output.Insert (_before, sb.ToString ()); } return _output.ToString (); }
private JsonObject GetJsonObject(JsonItem item, string property) { var prop = item.GetProperty(property); if (prop == null || !prop.IsValidObject()) { return null; } return (JsonObject)prop; }
// HACK: This is a very long function, individual parts in regions are made inline for better performance void WriteObject(object obj) { #region Detect Circular Reference var ci = 0; if (_cirobj.TryGetValue (obj, out ci) == false) _cirobj.Add (obj, _cirobj.Count + 1); else { if (_currentDepth > 0 && _useExtensions && _params.InlineCircularReferences == false) { //_circular = true; _output.Append ("{\"" + JsonDict.ExtRefIndex + "\":"); _output.Append (ValueConverter.Int32ToString (ci)); _output.Append ("}"); return; } } #endregion var def = _manager.GetReflectionCache (obj.GetType ()); var si = def.Interceptor; if (si != null && si.OnSerializing (obj) == false) { return; } #region Locate Extension Insertion Position if (_useGlobalTypes == false) _output.Append ('{'); else { if (_before == 0) { _output.Append ('{'); _before = _output.Length; } else _output.Append ('{'); } #endregion _currentDepth++; if (_currentDepth > _maxDepth) throw new JsonSerializationException ("Serializer encountered maximum depth of " + _maxDepth); //var map = new Dictionary<string, string> (); var append = false; #region Write Type Reference if (_useExtensions) { if (_useGlobalTypes == false) WritePairFast (JsonDict.ExtType, _useTypeAlias? _manager.ForwardLookupAlias(def.AssemblyName) : def.AssemblyName); else { var dt = 0; var ct = _useTypeAlias ? _manager.ForwardLookupAlias(def.AssemblyName) : def.AssemblyName; if (_globalTypes.TryGetValue (ct, out dt) == false) { dt = _globalTypes.Count + 1; _globalTypes.Add (ct, dt); } WritePairFast (JsonDict.ExtType, ValueConverter.Int32ToString (dt)); } append = true; } #endregion var g = def.Getters; var c = g.Length; for (int ii = 0; ii < c; ii++) { var p = g[ii]; var m = p.Member; #region Skip Members Not For Serialization if (p.Serializable == TriState.False) { continue; } if (p.Serializable == TriState.Default) { if (m.IsStatic && _params.SerializeStaticMembers == false || m.IsReadOnly && m.MemberTypeReflection.AppendItem == null && (m.IsProperty && _showReadOnlyProperties == false || m.IsProperty == false && _showReadOnlyFields == false)) { continue; } } #endregion var ji = new JsonItem (m.MemberName, m.Getter (obj), true); if (si != null && si.OnSerializing (obj, ji) == false) { continue; } var cv = p.Converter ?? m.MemberTypeReflection.Converter; if (cv != null) { cv.SerializationConvert (ji); } #region Convert Items if (p.ItemConverter != null) { var ev = ji._Value as IEnumerable; if (ev != null) { var ai = new JsonItem (ji.Name, null, false); var ol = new List<object> (); foreach (var item in ev) { ai.Value = item; p.ItemConverter.SerializationConvert (ai); ol.Add (ai.Value); } ji._Value = ol; } } #endregion #region Determine Serialized Field Name if (p.SpecificName) { if (ji._Value == null || p.TypedNames == null || p.TypedNames.TryGetValue (ji._Value.GetType (), out ji._Name) == false) { ji._Name = p.SerializedName; } } else { ji._Name = p.SerializedName; } #endregion #region Skip Null, Default Value or Empty Collection if (_params.SerializeNullValues == false && (ji._Value == null || ji._Value is DBNull)) { continue; } if (p.HasNonSerializedValue && Array.IndexOf (p.NonSerializedValues, ji._Value) != -1) { // ignore fields with default value continue; } if (m.IsCollection && _params.SerializeEmptyCollections == false) { var vc = ji._Value as ICollection; if (vc != null && vc.Count == 0) { continue; } } #endregion if (append) _output.Append (','); #region Write Name if (p.SpecificName) { WriteStringFast (ji._Name); _output.Append (':'); } else { _naming.WriteName (_output, ji._Name); } #endregion #region Write Value if (m.SerializeMethod != null && cv == null) { var v = ji._Value; if (v == null || v is DBNull) { _output.Append ("null"); } else if (m.MemberTypeReflection.CollectionName != null) { WriteObject (v); } else { m.SerializeMethod (this, v); } } else { WriteValue (ji._Value); } #endregion append = true; } #region Write Inherited Collection if (def.CollectionName != null && def.SerializeMethod != null) { if (append) _output.Append (','); WriteStringFast (def.CollectionName); _output.Append (':'); def.SerializeMethod (this, obj); append = true; } #endregion #region Write Extra Values if (si != null) { var ev = si.SerializeExtraValues (obj); if (ev != null) { foreach (var item in ev) { if (append) _output.Append (','); WritePair (item._Name, item._Value); append = true; } } si.OnSerialized (obj); } #endregion _currentDepth--; _output.Append ('}'); }
private long GetJsonPropertyLongValue(JsonItem item, string property) { long value; var prop = item.GetProperty(property); prop.TryGetValue(out value); return value; }