public clsFrom(clsJSON_block block) { foreach (string[] line in block.data) { if (line[0].CompareTo("url") == 0) { this.url = line[1]; } if (line[0].CompareTo("profile_id") == 0) { Int64 _i = 0; if (Int64.TryParse(line[1], out _i)) { this.profile_id = _i; } } if (line[0].CompareTo("fname") == 0) { this.fname = line[1]; } if (line[0].CompareTo("sname") == 0) { this.sname = line[1]; } if (line[0].CompareTo("login") == 0) { this.login = line[1]; } if (line[0].CompareTo("avatar") == 0) { this.avatar = line[1]; } ; } }
public clsFrom(clsJSON_block block) { foreach (string[] line in block.data) { if (line[0].CompareTo("url") == 0) this.url = line[1]; if (line[0].CompareTo("profile_id") == 0) { Int64 _i = 0; if (Int64.TryParse(line[1], out _i)) this.profile_id = _i; } if (line[0].CompareTo("fname") == 0) this.fname = line[1]; if (line[0].CompareTo("sname") == 0) this.sname = line[1]; if (line[0].CompareTo("login") == 0) this.login = line[1]; if (line[0].CompareTo("avatar") == 0) this.avatar = line[1]; ; } }
public clsMessDialog(clsJSON json) { string[] strFrom = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; string[] strTo = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; have_attach = false; url_Attachments = new List <string>(); #region обработка данных класса foreach (string[] line in json.data) { if (line[0].ToLower().CompareTo("message_html") == 0) { this.message_html = line[1]; } if (line[0].ToLower().CompareTo("message_text") == 0) { this.message_text = line[1]; } if (line[0].ToLower().CompareTo("post_time") == 0) { this.post_time = DateTime.Parse(line[1]);//clsTimeConvert.dtFrom8061(line[1]); } if (line[0].ToLower().CompareTo("attachments") == 0) { have_attach = true; } if (line[0].ToLower().CompareTo("url") == 0) { if (have_attach) { string turl = line[1]; string s = "//content.freelancehunt.com/message/"; if (turl.Remove(s.Length) == s) { turl = "https:" + turl; url_Attachments.Add(turl); } } else { this.url = line[1]; } } } #endregion #region приложения /* * if (json.block.attachments != null) * { * clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("attachments") == 0); * * if (block != null) * { * this.url_Attachments = new List<string>(); * foreach (string[] param in block.data) * { * if (param[0].ToLower().CompareTo("url") == 0) { this.url_Attachments.Add("https:" + param[1]); } * } * } * } */ #endregion #region от кого if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("from") == 0); if (block != null) { foreach (string[] line in block.data) { if (line[0].ToLower().CompareTo("profile_id") == 0) { strFrom[0] = line[1]; } if (line[0].ToLower().CompareTo("login") == 0) { strFrom[1] = line[1]; } if (line[0].ToLower().CompareTo("url") == 0) { strFrom[2] = line[1]; } if (line[0].ToLower().CompareTo("avatar") == 0) { strFrom[3] = line[1]; } if (line[0].ToLower().CompareTo("fname") == 0) { strFrom[4] = line[1]; } if (line[0].ToLower().CompareTo("sname") == 0) { strFrom[5] = line[1]; } } } } this.from = new clsFrom(strFrom); #endregion #region кому if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("to") == 0); if (block != null) { foreach (string[] line in block.data) { if (line[0].ToLower().CompareTo("profile_id") == 0) { strTo[0] = line[1]; } if (line[0].ToLower().CompareTo("login") == 0) { strTo[1] = line[1]; } if (line[0].ToLower().CompareTo("url") == 0) { strTo[2] = line[1]; } if (line[0].ToLower().CompareTo("avatar") == 0) { strTo[3] = line[1]; } if (line[0].ToLower().CompareTo("fname") == 0) { strFrom[4] = line[1]; } if (line[0].ToLower().CompareTo("sname") == 0) { strFrom[5] = line[1]; } } } } this.to = new clsFrom(strTo); #endregion }
public clsMessage(clsJSON json) { string[] strFrom = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; #region данные класса foreach (string[] line in json.data) { if (line[0].ToLower().CompareTo("url") == 0) { this.url = line[1]; } if (line[0].ToLower().CompareTo("url_api") == 0) { this.url_api = line[1]; } if (line[0].ToLower().CompareTo("subject") == 0) { this.subject = line[1]; } if (line[0].ToLower().CompareTo("has_attach") == 0) { int _i = 0; if (int.TryParse(line[1], out _i)) { this.attachCount = _i; } } if (line[0].ToLower().CompareTo("last_post_time") == 0) { this.last_post_time = DateTime.Parse(line[1]); //clsTimeConvert.dtFrom8061(line[1]); } if (line[0].ToLower().CompareTo("post_time") == 0) { this.post_time = DateTime.Parse(line[1]);//clsTimeConvert.dtFrom8061(line[1]); } if (line[0].ToLower().CompareTo("unread_count") == 0) { int _i = 0; if (int.TryParse(line[1], out _i)) { this.unread_count = _i; } } if (line[0].ToLower().CompareTo("is_unread") == 0) { string cs = "true"; if (line[1].Equals(cs)) { is_unread = true; } else { is_unread = false; } } } #endregion #region от кого if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("from") == 0); if (block != null) { foreach (string[] line in block.data) { if (line[0].ToLower().CompareTo("profile_id") == 0) { strFrom[0] = line[1]; } if (line[0].ToLower().CompareTo("login") == 0) { strFrom[1] = line[1]; } if (line[0].ToLower().CompareTo("url") == 0) { strFrom[2] = line[1]; } if (line[0].ToLower().CompareTo("avatar") == 0) { strFrom[3] = line[1]; } if (line[0].ToLower().CompareTo("fname") == 0) { strFrom[4] = line[1]; } if (line[0].ToLower().CompareTo("sname") == 0) { strFrom[5] = line[1]; } } } } this.from = new clsFrom(strFrom); #endregion }
public clsProject(clsJSON json) { string[] strFrom = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; #region обработка данных для этого класса foreach (string[] param in json.data) { if (param[0].ToLower().CompareTo("project_id") == 0) { Int64 _i = 0; if (Int64.TryParse(param[1], out _i)) { this.id = _i; } } if (param[0].ToLower().CompareTo("name") == 0) { this.name = param[1]; } if (param[0].ToLower().CompareTo("url") == 0) { this.url = param[1]; } if (param[0].ToLower().CompareTo("url_api") == 0) { this.url_api = param[1]; } if (param[0].ToLower().CompareTo("description") == 0) { //this.description = param[1].Replace("rn", "\r\n"); this.description = param[1].Replace("\r\n", "\n"); string n = "null"; if (this.description.Trim().Equals(n)) { this.description = ""; } } if (param[0].ToLower().CompareTo("description_html") == 0) { this.description_html = param[1].Replace("\r\n", "\n"); string n = "null"; if (this.description_html.Trim().Equals(n)) { this.description_html = ""; } } if (param[0].ToLower().CompareTo("description_text") == 0) { //this.description_text = param[1].Replace("rn", "\r\n"); this.description_text = param[1].Replace("\r\n", "\n"); string n = "null"; if (this.description_text.Trim().Equals(n)) { this.description_text = ""; } } if (param[0].ToLower().CompareTo("budget_amount") == 0) { this.budget_amount = param[1]; } if (param[0].ToLower().CompareTo("budget_currency_code") == 0) { this.budget_currency_code = param[1]; } if (param[0].ToLower().CompareTo("status_id") == 0) { int _i = 0; if (int.TryParse(param[1], out _i)) { this.status_id = _i; } } if (param[0].ToLower().CompareTo("status_name") == 0) { this.status_name = param[1]; } if (param[0].ToLower().CompareTo("bid_count") == 0) { int _i = 0; if (int.TryParse(param[1], out _i)) { this.bid_count = _i; } } if (param[0].ToLower().CompareTo("start_time") == 0) { this.start_time = param[1]; } if (param[0].ToLower().CompareTo("publication_time") == 0) { this.publication_time = param[1]; } if (param[0].ToLower().CompareTo("expire_time") == 0) { this.expire_time = param[1]; } if (param[0].ToLower().CompareTo("is_job") == 0) { this.is_job = param[1].CompareTo("1") == 0 || param[1].ToLower().CompareTo("true") == 0; } if (param[0].ToLower().CompareTo("is_featured") == 0) { this.is_featured = param[1].CompareTo("1") == 0 || param[1].ToLower().CompareTo("true") == 0; } if (param[0].ToLower().CompareTo("is_identity_verified") == 0) { this.is_identity_verified = param[1].CompareTo("1") == 0 || param[1].ToLower().CompareTo("true") == 0; } if (param[0].ToLower().CompareTo("is_safe_project") == 0) { this.is_safe_project = param[1].CompareTo("1") == 0 || param[1].ToLower().CompareTo("true") == 0; } if (param[0].ToLower().CompareTo("is_bid_added") == 0) { this.is_bid_added = param[1].CompareTo("1") == 0 || param[1].ToLower().CompareTo("true") == 0; } } #endregion #region skills if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("skills") == 0); if (block != null) { this.skills = new Dictionary <int, string>(); foreach (string[] param in block.data) { int _i = 0; if (!int.TryParse(param[0], out _i)) { continue; } this.skills.Add(_i, param[1]); } } } #endregion #region from if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("from") == 0); if (block != null) { foreach (string[] param in block.data) { if (param[0].ToLower().CompareTo("profile_id") == 0) { strFrom[0] = param[1]; } if (param[0].ToLower().CompareTo("login") == 0) { strFrom[1] = param[1]; } if (param[0].ToLower().CompareTo("url") == 0) { strFrom[2] = param[1]; } if (param[0].ToLower().CompareTo("avatar") == 0) { strFrom[3] = param[1]; } if (param[0].ToLower().CompareTo("fname") == 0) { strFrom[4] = param[1]; } if (param[0].ToLower().CompareTo("sname") == 0) { strFrom[5] = param[1]; } } } } #endregion this.from = new clsFrom(strFrom); }
public static List <clsJSON> parceProj(string text) { List <clsJSON> rezult = new List <clsJSON>(); //string text2 = text.Replace("[", "[\r\n"); //text2 = text2.Replace("{", "\r\n{\r\n"); //text2 = text2.Replace("}", "\r\n}\r\n"); string text2 = text.Replace("[", "[\n"); text2 = text2.Replace("{", "\n{\n"); text2 = text2.Replace("}", "\n}\n"); List <string[]> data = new List <string[]>(); List <clsJSON_block> bloks = null; clsJSON_block blok = null; bool inBlock = false; string blockName = string.Empty; int brckNum = 0; string[] lines = text2.Split(new char[] { '\r', '\n' }); int i = -1; foreach (string line in lines) { i++; if (string.IsNullOrEmpty(line)) { continue; } if (line.CompareTo("[") == 0) { continue; } if (line.CompareTo("]") == 0) { continue; } if (line.CompareTo("{") == 0) { brckNum++; continue; } if (line.CompareTo("}") == 0) { brckNum--; if (brckNum == 0) { // закончили JSON rezult.Add(new clsJSON(data, bloks)); data = new List <string[]>(); bloks = null; blok = null; inBlock = false; blockName = string.Empty; } else { // закончили блок if (blok != null) { bloks.Add(blok); } blok = null; inBlock = false; blockName = string.Empty; } continue; } string[] param = line.Split(':'); if (param.Count() == 1) { continue; } param[0] = param[0].Replace("\"", ""); #region название блока if (string.IsNullOrEmpty(param[1])) { inBlock = true; blok = new clsJSON_block(param[0]); if (bloks == null) { bloks = new List <clsJSON_block>(); } continue; } #endregion string tmpParam1 = line.Substring(line.IndexOf(":") + 1); //string tmpParam1 = line.Substring(line.IndexOf(":") + 1).Replace("\"", "").Replace(",", ""); #region если текст разделен, то его надо соединить if (param[0] == "name" || param[0] == "description_text" || param[0] == "description_html") { int n = 1; bool r = true; while (r) { while (lines[i + n].Trim().Length < 1) { n++; } if (!lines[i + n].Contains("\":\"")) { tmpParam1 = tmpParam1 + lines[i + n]; n++; } else { r = false; } } } #endregion param[1] = remЕxEndsStarts(tmpParam1);//.Replace("\"", "").Replace(",", ""); if (inBlock) { blok.addData(new string[] { param[0], param[1] }); } else { data.Add(new string[] { param[0], param[1] }); } } return(rezult); }
public static List <clsJSON> parce(string text) { List <clsJSON> rezult = new List <clsJSON>(); string text2 = text.Replace("[", "[\r\n"); text2 = text2.Replace("{", "\r\n{\r\n"); text2 = text2.Replace("}", "\r\n}\r\n"); List <string[]> data = new List <string[]>(); List <clsJSON_block> bloks = null; clsJSON_block blok = null; bool inBlock = false; string blockName = string.Empty; int brckNum = 0; string[] lines = text2.Split(new char[] { '\r', '\n' }); int i = -1; foreach (string line in lines) { i++; if (string.IsNullOrEmpty(line)) { continue; } if (line.CompareTo("[") == 0) { continue; } if (line.CompareTo("]") == 0) { continue; } if (line.CompareTo("{") == 0) { brckNum++; continue; } if (line.CompareTo("}") == 0) { brckNum--; if (brckNum == 0) { // закончили JSON rezult.Add(new clsJSON(data, bloks)); data = new List <string[]>(); bloks = null; blok = null; inBlock = false; blockName = string.Empty; } else { // закончили блок if (blok != null) { bloks.Add(blok); } blok = null; inBlock = false; blockName = string.Empty; } continue; } string[] param = line.Split(':'); if (param.Count() == 1) { continue; } param[0] = param[0].Replace("\"", ""); #region название блока if (string.IsNullOrEmpty(param[1])) { inBlock = true; blok = new clsJSON_block(param[0]); if (bloks == null) { bloks = new List <clsJSON_block>(); } continue; } #endregion param[1] = line.Substring(line.IndexOf(":") + 1).Replace("\"", "").Replace(",", ""); if (inBlock) { blok.addData(new string[] { param[0], param[1] }); } else { data.Add(new string[] { param[0], param[1] }); } } return(rezult); }
public static List<clsJSON> parce(string text) { List<clsJSON> rezult = new List<clsJSON>(); string text2 = text.Replace("[", "[\r\n"); text2 = text2.Replace("{", "\r\n{\r\n"); text2 = text2.Replace("}", "\r\n}\r\n"); List<string[]> data = new List<string[]>(); List<clsJSON_block> bloks = null; clsJSON_block blok = null; bool inBlock = false; string blockName = string.Empty; int brckNum = 0; string[] lines = text2.Split(new char[] { '\r', '\n' }); int i = -1; foreach (string line in lines) { i++; if (string.IsNullOrEmpty(line)) continue; if (line.CompareTo("[") == 0) continue; if (line.CompareTo("]") == 0) continue; if (line.CompareTo("{") == 0) { brckNum++; continue; } if (line.CompareTo("}") == 0) { brckNum--; if (brckNum == 0) { // закончили JSON rezult.Add(new clsJSON(data, bloks)); data = new List<string[]>(); bloks = null; blok = null; inBlock = false; blockName = string.Empty; } else { // закончили блок if (blok != null) bloks.Add(blok); blok = null; inBlock = false; blockName = string.Empty; } continue; } string[] param = line.Split(':'); if (param.Count() == 1) continue; param[0] = param[0].Replace("\"", ""); #region название блока if (string.IsNullOrEmpty(param[1])) { inBlock = true; blok = new clsJSON_block(param[0]); if (bloks == null) bloks = new List<clsJSON_block>(); continue; } #endregion param[1] = line.Substring(line.IndexOf(":") + 1).Replace("\"", "").Replace(",", ""); if (inBlock) blok.addData(new string[] { param[0], param[1] }); else data.Add(new string[] { param[0], param[1] }); } return rezult; }
public static List<clsJSON> parceProj(string text) { List<clsJSON> rezult = new List<clsJSON>(); //string text2 = text.Replace("[", "[\r\n"); //text2 = text2.Replace("{", "\r\n{\r\n"); //text2 = text2.Replace("}", "\r\n}\r\n"); string text2 = text.Replace("[", "[\n"); text2 = text2.Replace("{", "\n{\n"); text2 = text2.Replace("}", "\n}\n"); List<string[]> data = new List<string[]>(); List<clsJSON_block> bloks = null; clsJSON_block blok = null; bool inBlock = false; string blockName = string.Empty; int brckNum = 0; string[] lines = text2.Split(new char[] { '\r', '\n' }); int i = -1; foreach (string line in lines) { i++; if (string.IsNullOrEmpty(line)) continue; if (line.CompareTo("[") == 0) continue; if (line.CompareTo("]") == 0) continue; if (line.CompareTo("{") == 0) { brckNum++; continue; } if (line.CompareTo("}") == 0) { brckNum--; if (brckNum == 0) { // закончили JSON rezult.Add(new clsJSON(data, bloks)); data = new List<string[]>(); bloks = null; blok = null; inBlock = false; blockName = string.Empty; } else { // закончили блок if (blok != null) bloks.Add(blok); blok = null; inBlock = false; blockName = string.Empty; } continue; } string[] param = line.Split(':'); if (param.Count() == 1) continue; param[0] = param[0].Replace("\"", ""); #region название блока if (string.IsNullOrEmpty(param[1])) { inBlock = true; blok = new clsJSON_block(param[0]); if (bloks == null) bloks = new List<clsJSON_block>(); continue; } #endregion string tmpParam1 = line.Substring(line.IndexOf(":") + 1); //string tmpParam1 = line.Substring(line.IndexOf(":") + 1).Replace("\"", "").Replace(",", ""); #region если текст разделен, то его надо соединить if (param[0] == "name" || param[0] == "description_text" || param[0] == "description_html") { int n = 1; bool r = true; while (r) { while (lines[i + n].Trim().Length < 1) { n++; } if (!lines[i + n].Contains("\":\"")) { tmpParam1 = tmpParam1 + lines[i + n]; n++; } else { r = false; } } } #endregion param[1] = remЕxEndsStarts(tmpParam1);//.Replace("\"", "").Replace(",", ""); if (inBlock) blok.addData(new string[] { param[0], param[1] }); else data.Add(new string[] { param[0], param[1] }); } return rezult; }
public clsFeed(clsJSON json) { string[] strFrom = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; #region обработка данных для этого класса foreach (string[] line in json.data) { if (line[0].ToLower().CompareTo("time") == 0) { this.date = clsTimeConvert.dtFrom8061(line[1]); } if (line[0].ToLower().CompareTo("message") == 0) { this.message = line[1]; mesDivider(this.message); } if (line[0].ToLower().CompareTo("is_new") == 0) { this.is_new = line[1].ToLower().CompareTo("true") == 0; } if (line[0].ToLower().CompareTo("time_millis") == 0) { if (!line[1].Contains("message")) { Int64 date = 0; if (Int64.TryParse(line[1], out date)) { time_millis = date; } } else { Int64 date = 0; if (Int64.TryParse(line[1].Split('m')[0], out date)) { time_millis = date; } String ms = line[1].Split(':')[1]; if (String.IsNullOrEmpty(this.message)) { this.message = ms; mesDivider(this.message); } } } } #endregion #region от кого clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("from") == 0); if (block != null) { foreach (string[] line in block.data) { if (line[0].ToLower().CompareTo("profile_id") == 0) { strFrom[0] = line[1]; } if (line[0].ToLower().CompareTo("login") == 0) { strFrom[1] = line[1]; } if (line[0].ToLower().CompareTo("url") == 0) { strFrom[2] = line[1]; } if (line[0].ToLower().CompareTo("avatar") == 0) { strFrom[3] = line[1]; } if (line[0].ToLower().CompareTo("fname") == 0) { strFrom[4] = line[1]; } if (line[0].ToLower().CompareTo("sname") == 0) { strFrom[5] = line[1]; } } } this.from = new clsFrom(strFrom); #endregion }