private static string GoogleImageOutput(string input) { using (var client = new WebClient()) { string URL = "error"; string urlVar = "url"; int urlCheck = 0; string content = client.DownloadString(input); JsonTextParser parser = new JsonTextParser(); string output = parser.Parse(content).ToString(); char[] delimiters = new char[] { '\r', '\n' }; string[] parts = output.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { if (parts[i].Contains(urlVar) && urlCheck == 0) { parts[i] = parts[i].Replace("url", " "); parts[i] = parts[i].Replace('"', ' '); parts[i] = parts[i].Replace(',', ' '); parts[i] = parts[i].Trim(); URL = parts[i]; urlCheck = 1; } } return URL.Remove(0, 3); } }
public static Dictionary<string, SyncItem> GetHashList() { Dictionary<string,SyncItem> Hashlist = new Dictionary<string,SyncItem> (); //get remote hash data string HashJSON = getHashData (); //read JSON JsonTextParser parser = new JsonTextParser (); JsonObject hashes = parser.Parse(HashJSON); foreach (JsonObject field in hashes as JsonObjectCollection) { if(field.GetValue().GetType().Name !="String" ){ List<JsonObject> obj = (List<JsonObject>)field.GetValue(); SyncFile sf =new SyncFile(field.Name.ToString(), obj); Hashlist.Add (field.Name, sf); } else{ //Console.WriteLine(field.Name, field.GetValue().ToString()); } } return Hashlist; }
public bool getKey(string key) { try { JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(JsonValue); foreach (JsonObject field in obj as JsonObjectCollection) { string name = field.Name; string value = (string)field.GetValue(); if (name == key) { return Boolean.Parse(value); } } return true; } catch (Exception ex) { return true; } }
public static string GoogleOutput(string input) { using (var client = new WebClient()) { string output = ""; string URL = ""; string title = ""; string urlVar = "url"; int urlCheck = 0; string titleVar = "titleNoFormatting"; int titleCheck = 0; string content = client.DownloadString(input); JsonTextParser parser = new JsonTextParser(); output = parser.Parse(content).ToString(); char[] delimiters = new char[] { '\r', '\n' }; try { string[] parts = output.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { if (parts[i].Contains(titleVar) && titleCheck == 0) { parts[i] = parts[i].Replace("titleNoFormatting", " "); parts[i] = parts[i].Replace('"', ' '); parts[i] = parts[i].Replace(':', ' '); parts[i] = parts[i].Replace(',', ' '); parts[i] = parts[i].Trim(); title = parts[i]; titleCheck = 1; } if (parts[i].Contains(urlVar) && urlCheck == 0) { parts[i] = parts[i].Replace("url", " "); parts[i] = parts[i].Replace('"', ' '); parts[i] = parts[i].Replace(',', ' '); parts[i] = parts[i].Trim(); URL = parts[i]; urlCheck = 1; } } string finalOutput = URL.Remove(0, 3) + " - " + Botler.Utilities.TextFormatting.Bold(title); return finalOutput; } catch { } return "No results found sir"; } }
public static Object ParseJson(string jsonText) { if (jsonText == "{}") return new Hashtable(); if (!string.IsNullOrEmpty(jsonText)) { JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(jsonText); return ParseJson(obj); } else { return null; } }
public Object parse(String json) { BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance; var instance = Activator.CreateInstance (c); JsonTextParser parser = new JsonTextParser (); JsonObjectCollection jObject = (JsonObjectCollection)parser.Parse (json); foreach (FieldInfo field in c.GetFields(bindingFlags)) { String fieldName = removeTag (field.ToString ()); object value = null; var oValue = jObject [field.Name].GetValue (); switch (fieldName) { case "System.String": value = Convert.ToString (oValue); break; case "System.Double": value = Convert.ToDouble (oValue); break; case "Int32": value = Convert.ToInt32 (oValue); break; case "Int64": value = Convert.ToInt64 (oValue); break; case "System.Boolean": value = Convert.ToInt64 (oValue); break; case "System.Collections.Generic.List": value = oValue; break; default: //value = parse (varToList(oValue)[0].ToString()); break; } field.SetValue (instance, value); Console.WriteLine(field.Name+","+field.ToString()+","+jObject [field.Name].GetValue()); } return instance; }
public void ShowData(string jsonStr) { JsonTextParser parser = new JsonTextParser(); JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(jsonStr); if (((JsonNumericValue)jsonData["ok"]).Value == 1) { JsonObjectCollection data = (JsonObjectCollection)jsonData["data"]; string imgBase64Str = ((JsonStringValue)data["img_base64str"]).Value; byte[] imageBytes = Convert.FromBase64String(imgBase64Str); this.BigImgMemoryStream = new MemoryStream(imageBytes, 0, imageBytes.Length); this.BigImgMemoryStream.Write(imageBytes, 0, imageBytes.Length); this.BigImg = Image.FromStream(this.BigImgMemoryStream); BigImagePictureBox.Image = this.BigImg; } }
public void ShowData(string jsonStr) { this.ReportList.Items.Clear(); JsonTextParser parser = new JsonTextParser(); JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(jsonStr); JsonArrayCollection data = (JsonArrayCollection)jsonData["data"]; for (int i = 0; i < data.Count; i++) { JsonObjectCollection itemData = (JsonObjectCollection)data[i]; if (itemData["total_price"].GetValue() == null) continue; ListViewItem item = new ListViewItem(new string[] { "", Commons.UnixTimeFrom((long)((JsonNumericValue)itemData["time"]).Value).ToString("yyyy-MM-dd"), ((int)((JsonNumericValue)itemData["total"]).Value).ToString(), ((int)((JsonNumericValue)itemData["total_quantity"]).Value).ToString(), ((float)((JsonNumericValue)itemData["total_price"]).Value).ToString("f1") }); this.ReportList.Items.Add(item); } }
public void getPPL(int mode, string programName, string programEntry) { string address = "http://kdspykim2.cafe24.com:8080/get_ppl_data?"; if (mode == INQUIRY) { programName = d_program_name.Text.ToString(); programEntry = d_program_entry.Text.ToString(); } string programKey = programName + "_" + programEntry; string query = address + "drama_code=" + programKey; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(query); request.Method = "GET"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(stream, Encoding.UTF8); string result = streamReader.ReadToEnd(); JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(result); JsonArrayCollection items = (JsonArrayCollection)obj; pplDataList.clearList(); foreach (JsonObjectCollection item in items) { string productCode = item["product_code"].GetValue().ToString(); string programCode = item["drama_code"].GetValue().ToString(); string productName = item["product_name"].GetValue().ToString(); string brandName = item["brand_name"].GetValue().ToString(); string productImage = item["product_image"].GetValue().ToString(); string price = item["price"].GetValue().ToString(); string storeLink = item["store_link"].GetValue().ToString(); int startTime = Convert.ToInt32(item["start_time"].GetValue()); int endTime = Convert.ToInt32(item["end_time"].GetValue()); PPLData pplData = new PPLData(productCode, programCode, productName, brandName, productImage, price, storeLink, startTime, endTime); pplDataList.insertPPLData(pplData); } }
public void ShowData(string jsonStr) { JsonTextParser parser = new JsonTextParser(); JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(jsonStr); if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU_CLASS)) { this.MenuClassData = (JsonArrayCollection)jsonData["data"]; this.MenuClassList.Items.Clear(); this.MenuClassList.Items.Add(Strings.MenuFormListFirst); this.MenuClassList.SelectedIndex = 0; this.MenuIDList = new List<int>(); this.MenuIDList.Add(0); for (int i = 0; i < this.MenuClassData.Count; i++) { JsonObjectCollection itemData = (JsonObjectCollection)this.MenuClassData[i]; this.MenuClassList.Items.Add(((JsonStringValue)itemData["name"]).Value); this.MenuIDList.Add((int)((JsonNumericValue)itemData["id"]).Value); } //选定上一次所选定的索引 //this.MenuClassList.SelectedIndex = this.PrevSelectedIndex; } else if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU)) { this.MenuData = (JsonArrayCollection)jsonData["data"]; this.MenuDataList.Items.Clear(); for (int i = 0; i < this.MenuData.Count; i++) { JsonObjectCollection itemData = (JsonObjectCollection)this.MenuData[i]; ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonNumericValue)itemData["price"]).Value.ToString("f1"), ((JsonStringValue)itemData["mc_name"]).Value, Commons.UnixTimeFrom((long)((JsonNumericValue)itemData["add_time"]).Value).ToString("yyyy-MM-dd") }); this.MenuDataList.Items.Add(item); } } }
private void btnConvert_Click(object sender, EventArgs e) { try { JsonTextParser parser = new JsonTextParser(); JsonArrayCollection arrayAllMyFriends = parser.Parse(txtSourceCode.Text) as JsonArrayCollection; txtJsonCode.Text = arrayAllMyFriends.ToString(); //foreach (JsonObjectCollection item in arrayAllMyFriends) //{ // FriendInfo friend = new FriendInfo(); // friend.Id = JsonHelper.GetIntegerValue(item["uid"]); // friend.Name = JsonHelper.GetStringValue(item["real_name"]); // this._allMyFriendsList.Add(friend); // if (printMessage) // SetMessageLn(friend.Name + "(" + friend.Id.ToString() + ")"); //} } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ShowData(string jsonStr) { this.ClientList.Items.Clear(); this.ClientIDList = new List<int>(); JsonTextParser parser = new JsonTextParser(); JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(jsonStr); JsonArrayCollection data = (JsonArrayCollection)jsonData["data"]; for (int i = 0; i < data.Count; i++) { JsonObjectCollection itemData = (JsonObjectCollection)data[i]; string isAdmin = Strings.CommonsClientIsAdmin0; if (((JsonNumericValue)itemData["is_admin"]).Value == 1) isAdmin = Strings.CommonsClientIsAdmin1; ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonStringValue)itemData["ip"]).Value, isAdmin }); this.ClientList.Items.Add(item); this.ClientIDList.Add((int)((JsonNumericValue)itemData["id"]).Value); } }
public void ShowData(string jsonStr) { this.MenuClassList.Items.Clear(); this.MenuClassList.Items.Add(Strings.MenuClassFormListFirst); this.MenuClassList.SelectedIndex = 0; this.MenuClassIDList = new List<int>(); this.MenuClassIDList.Add(0); JsonTextParser parser = new JsonTextParser(); JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(jsonStr); JsonArrayCollection data = (JsonArrayCollection)jsonData["data"]; for (int i = 0; i < data.Count; i++) { JsonObjectCollection itemData = (JsonObjectCollection)data[i]; this.MenuClassList.Items.Add(((JsonStringValue)itemData["name"]).Value); this.MenuClassIDList.Add((int)((JsonNumericValue)itemData["id"]).Value); } //选定上一次所选定的索引 this.MenuClassList.SelectedIndex = this.PrevSelectedIndex; }
private void ReadMessage() { while (bConnected) { try { string readMessage = myNetwork.ReadMessage(); JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(readMessage); JsonObjectCollection col = (JsonObjectCollection)obj; string cmd = (string)col["cmd"].GetValue(); if (cmd == "chat") { this.Invoke(new UpdateLogCallback(this.UpdateLog), new object[] { (string)col["msg"].GetValue() }); } } catch (Exception e) { Console.WriteLine("{0}", e.ToString()); //MessageBox.Show("Error in receiving..."); break; } Thread.Sleep(100); } }
public void ReadAllMyFriends(string content, bool printMessage) { if (printMessage) SetMessageLn("读取我的所有朋友信息..."); this._allMyFriendsList.Clear(); //我的所有好友 JsonTextParser parser = new JsonTextParser(); JsonArrayCollection arrayAllMyFriends = parser.Parse(content) as JsonArrayCollection; foreach (JsonObjectCollection item in arrayAllMyFriends) { FriendInfo friend = new FriendInfo(); friend.Id = JsonHelper.GetIntegerValue(item["uid"]); friend.Name = JsonHelper.GetStringValue(item["real_name"]); this._allMyFriendsList.Add(friend); if (printMessage) SetMessageLn(friend.Name + "(" + friend.Id.ToString() + ")"); } if (printMessage) SetMessageLn(string.Format("您有{0}个朋友", new object[] { this._allMyFriendsList.Count })); }
private void InitializeConnection() { try { // clientSocket.Connect(ipEndPoint); myNetwork.GetConnect(txtIp.Text.Trim(), Convert.ToInt32(txtPort.Text.Trim()) ); Send_Login_Message(); string readMessage = myNetwork.ReadMessage(); JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(readMessage); JsonObjectCollection col = (JsonObjectCollection)obj; string cmd = (string)col["cmd"].GetValue(); if (cmd == "login") { string rt = (string)col["result"].GetValue(); if (rt == "fail") { MsgBox.Show((string)col["reason"].GetValue() , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } catch ( Exception e ) { Console.WriteLine("{0}", e.ToString() ); MsgBox.Show("in connecting...","Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ConnectOn(); GetThread(); }
public void LoadJsonFile(ListBox JsonList, TreeView VariableList, Button StartBtn) { if (JsonList.SelectedIndices.Count > 0) { string fileName = JsonList.SelectedItem.ToString(); StreamReader sr = new StreamReader(m_jsonFilePath + fileName); // 파일에서 다 읽는다 string jsonText = sr.ReadToEnd(); // 빈 파일이면? if (jsonText.Length == 0) { // 파싱 없이 리턴 MessageBox.Show("Empty File!"); return; } // 파싱한 다음 JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(jsonText); // JSON 멤버 변수로 전달한다 m_JsonCollection = (JsonObjectCollection)obj; // TreeVIew에 계층별로 집어넣는다 ShowJsonData(VariableList); MessageBox.Show("Load Json Success!"); // 스트림 리더를 닫는다. sr.Close(); // 시작 버튼을 선택 가능하게 StartBtn.Enabled = true; } }
public void ReadMatureFriends(string content, bool printMessage) { try { if (printMessage) SetMessageLn("读取[花园中有成熟果实的好友]信息..."); //this._mySharedFriendsList.Clear(); //this._matureFriendsList.Clear(); this._myGardenFriendsList.Clear(); //[{"uid":"10752908","real_name":"\u5173\u4ec1","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","share":1},{"uid":"10752309","real_name":"\u5b8b\u6c5f","icon20":"http:\/\/pic1.kaixin001.com\/logo\/75\/23\/20_10752309_1.jpg","share":1},{"uid":10752657,"real_name":"\u6b66\u5c0f\u6d6a","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","harvest":1},{"uid":10755959,"real_name":"\u5218\u6210\u540d","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_1_0.gif","harvest":1}] //[{"uid":"5629041","real_name":"\u5f20\u52e4","icon20":"http:\/\/pic1.kaixin001.com\/logo\/62\/90\/20_5629041_5.jpg","share":1},{"uid":13285985,"real_name":"\u66f9\u519b","icon20":"http:\/\/pic1.kaixin001.com\/logo\/28\/59\/20_13285985_23.jpg","harvest":1},{"uid":2176837,"real_name":"\u9676\u51b6\uff08\u82b1\u843d\u65e0\u98ce\uff09","icon20":"http:\/\/pic1.kaixin001.com\/logo\/17\/68\/20_2176837_2.jpg","harvest":1},{"uid":2287096,"real_name":"\u5510\u6167","icon20":"http:\/\/pic.kaixin001.com\/logo\/28\/70\/20_2287096_1.jpg","harvest":1,"antiharvest":1},{"uid":2395406,"real_name":"\u6731\u8273\u96ef","icon20":"http:\/\/pic.kaixin001.com\/logo\/39\/54\/20_2395406_3.jpg","harvest":1,"fee":1},{"uid":27353139,"real_name":"\u9648\u6b63\u4e1c","icon20":"http:\/\/pic1.kaixin001.com\/logo\/35\/31\/20_27353139_1.jpg","harvest":1},{"uid":2803054,"real_name":"\u8f66\u79be\u5409","icon20":"http:\/\/pic.kaixin001.com\/logo\/80\/30\/20_2803054_1.jpg","harvest":1},{"uid":3125472,"real_name":"\u738b\u535a\u667a","icon20":"http:\/\/pic.kaixin001.com\/logo\/12\/54\/20_3125472_9.jpg","harvest":1},{"uid":3172993,"real_name":"\u5f90\u632f\u4e9a","icon20":"http:\/\/pic1.kaixin001.com\/logo\/17\/29\/20_3172993_2.jpg","harvest":1},{"uid":330818,"real_name":"\u8881\u4f73\u534e","icon20":"http:\/\/pic.kaixin001.com\/logo\/33\/8\/20_330818_22.jpg","harvest":1},{"uid":3352378,"real_name":"\u5f90\u9e4f\u52c7","icon20":"http:\/\/pic.kaixin001.com\/logo\/35\/23\/20_3352378_2.jpg","harvest":1},{"uid":35926680,"real_name":"\u65bd\u6625\u534e","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","harvest":1},{"uid":3612627,"real_name":"\u5468\u6797","icon20":"http:\/\/pic1.kaixin001.com\/logo\/61\/26\/20_3612627_4.jpg","harvest":1},{"uid":4026057,"real_name":"\u8521\u632f\u534e","icon20":"http:\/\/pic1.kaixin001.com\/logo\/2\/60\/20_4026057_2.jpg","harvest":1},{"uid":4343401,"real_name":"\u9648\u9e4f","icon20":"http:\/\/pic1.kaixin001.com\/logo\/34\/34\/20_4343401_5.jpg","harvest":1},{"uid":5350880,"real_name":"\u5434\u6653\u6e05","icon20":"http:\/\/pic.kaixin001.com\/logo\/35\/8\/20_5350880_1.jpg","harvest":1},{"uid":6265093,"real_name":"\u987e\u73fa\u96ef","icon20":"http:\/\/pic1.kaixin001.com\/logo\/26\/50\/20_6265093_3.jpg","harvest":1},{"uid":7969758,"real_name":"\u9ad8\u5927\u519b","icon20":"http:\/\/pic.kaixin001.com\/logo\/96\/97\/20_7969758_8.jpg","harvest":1},{"uid":8288802,"real_name":"\u738b\u5ca9","icon20":"http:\/\/pic.kaixin001.com\/logo\/28\/88\/20_8288802_8.jpg","harvest":1},{"uid":9637731,"real_name":"\u66f9\u840d","icon20":"http:\/\/pic1.kaixin001.com\/logo\/63\/77\/20_9637731_2.jpg","harvest":1}] //[{"uid":"6752990","real_name":"\u5434\u5b50\u725b","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","share":1},{"uid":"6752812","real_name":"\u6c88\u81f4\u51b0","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","share":1},{"uid":"6904295","real_name":"\u5218\u7684\u8bdd","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","share":1},{"uid":"6903449","real_name":"\u9676\u5b9d","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_1_0.gif","share":1},{"uid":6194153,"real_name":"\u5e84\u5b50","icon20":"http:\/\/pic1.kaixin001.com\/logo\/19\/41\/20_6194153_1.jpg","harvest":1},{"uid":6733320,"real_name":"\u9676\u9187","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","harvest":1,"grass":1},{"uid":6209710,"real_name":"\u9648\u5fd7","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","grass":1},{"uid":6985380,"real_name":"\u9648\u89c2\u897f","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","grass":1},{"uid":7995480,"real_name":"\u9648\u6c5f\u94f8","icon20":"http:\/\/img.kaixin001.com.cn\/i\/20_0_0.gif","grass":1}] JsonTextParser parser = new JsonTextParser(); JsonArrayCollection arraySharedFriends = parser.Parse(content) as JsonArrayCollection; if (arraySharedFriends != null) { foreach (JsonObjectCollection item in arraySharedFriends) { FriendInfo friend = new FriendInfo(); friend.Id = JsonHelper.GetIntegerValue(item["uid"]); friend.Name = JsonHelper.GetStringValue(item["real_name"]); friend.GardenShare = item["share"] != null ? true : false; friend.GardenHarvest = item["harvest"] != null ? true : false; friend.GardenFee = item["fee"] != null ? true : false; friend.GardenGrass = item["grass"] != null ? true : false; friend.GardenVermin = item["vermin"] != null ? true : false; this._myGardenFriendsList.Add(friend); //if (friend.GardenShare) // this._mySharedFriendsList.Add(friend); //if (friend.GardenHarvest) // this._matureFriendsList.Add(friend); } } } catch (ThreadAbortException) { throw; } catch (ThreadInterruptedException) { throw; } catch (Exception ex) { LogHelper.Write("GameGarden.ReadMatureFriends", content, ex, LogSeverity.Error); SetMessage(" 读取[花园中有成熟果实的好友]信息失败!" + ex.Message); } }
public void WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e) { JsonTextParser parser = new JsonTextParser(); JsonObjectCollection jsonData = (JsonObjectCollection)parser.Parse(e.Message); if (((JsonNumericValue)jsonData["ok"]).Value == 1) { //子窗口相关 if (this.SubForm != null) { if (this.SubForm is OrderDayReportForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_REPORT_DAY)) ((OrderDayReportForm)this.SubForm).ShowData(e.Message); //订单日报表 else if (this.SubForm is OrderMonthReportForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_REPORT_MONTH)) ((OrderMonthReportForm)this.SubForm).ShowData(e.Message); //订单月报表 else if (this.SubForm is ClientForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_CLIENT_LIST)) ((ClientForm)this.SubForm).ShowData(e.Message); //客户端管理 else if (this.SubForm is MenuClassForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU_CLASS)) ((MenuClassForm)this.SubForm).ShowData(e.Message); //菜单分类 else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU_CLASS)) ((MenuForm)this.SubForm).ShowData(e.Message); //菜单列表的分类部分 else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_MENU)) ((MenuForm)this.SubForm).ShowData(e.Message); //菜单列表的数据部分 else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_BIG_IMAGE)) { if (((MenuForm)this.SubForm).SubForm != null && ((MenuAddForm)((MenuForm)this.SubForm).SubForm).SubForm != null) ((MenuBigImgViewForm)((MenuAddForm)((MenuForm)this.SubForm).SubForm).SubForm).ShowData(e.Message); //菜单显示图片 } else if (this.SubForm is MenuForm && ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_SELECTED_MENU_CLASS)) ((MenuForm)this.SubForm).MenuClassListSelectedWithID((int)((JsonNumericValue)jsonData["data"]).Value); //添加修改删除菜单数据后更新菜单数据列表 } if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_TOMAIN) || ((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_GET_ONLINE_LIST)) { { //发送获取在线列表的请求 jsonData = new JsonObjectCollection(); jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ONLINE_LIST)); ConnHelper.SendString(jsonData.ToString()); } { //获取下单明细列表 jsonData = new JsonObjectCollection(); jsonData.Add(new JsonStringValue("cmd", AppConfig.SERV_ORDER_DETAIL)); ConnHelper.SendString(jsonData.ToString()); } } else if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_ONLINE_LIST)) { //显示在线列表 this.InformationDeskIndices = new List<int>(); this.ClientOrderStatusList = new Dictionary<int, int>(); this.ClientStatusList = new Dictionary<int, int>(); this.ClientNameList = new Dictionary<int, string>(); this.OnlineList.Items.Clear(); JsonArrayCollection data = (JsonArrayCollection)jsonData["data"]; for (int i = 0; i < data.Count; i++) { JsonObjectCollection itemData = (JsonObjectCollection)data[i]; if (((JsonNumericValue)itemData["is_admin"]).Value == 1) { //服务台 ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonStringValue)itemData["ip"]).Value, Strings.MainFormInformationDeskName, Strings.MainFormInformationDeskStatus }); this.OnlineList.Items.Add(item); this.InformationDeskIndices.Add(i); } else { //一般 string status = Strings.MainFormClientStatus; if (itemData["o_status"].GetValue() != null) { float totalPrice = 0.0f; if (itemData["total_price"].GetValue() != null) totalPrice = (float)((JsonNumericValue)itemData["total_price"]).Value; if (((JsonNumericValue)itemData["o_status"]).Value == 0) status = string.Format(Strings.MainFormClientStatus0, totalPrice.ToString("f1")); else if (((JsonNumericValue)itemData["o_status"]).Value == 1) status = string.Format(Strings.MainFormClientStatus1, totalPrice.ToString("f1")); this.ClientOrderStatusList.Add(i, (int)((JsonNumericValue)itemData["o_status"]).Value); } this.ClientNameList.Add(i, ((JsonStringValue)itemData["name"]).Value); this.ClientStatusList.Add(i, (int)((JsonNumericValue)itemData["status"]).Value); ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["name"]).Value, ((JsonStringValue)itemData["ip"]).Value, Strings.MainFormClientClassName, status }); this.OnlineList.Items.Add(item); } } if (this.ClientListSelectedIndex > -1) this.OnlineList.Items[this.ClientListSelectedIndex].Selected = true; } else if (((JsonStringValue)jsonData["cmd"]).Value.Equals(AppConfig.CLIENT_WANT_ORDER_DETAIL)) { //下单明细列表 this.OrderDetailIDList = new List<int>(); this.OrderDetailStatusList = new List<int>(); this.OrderDetailNameList = new List<string>(); this.OrderDetailList.Items.Clear(); JsonArrayCollection data = (JsonArrayCollection)jsonData["data"]; for (int i = 0; i < data.Count; i++) { JsonObjectCollection itemData = (JsonObjectCollection)data[i]; string status = Strings.MainFormOrderDetailStatus0; if((int)((JsonNumericValue)itemData["status"]).Value == 1) status = Strings.MainFormOrderDetailStatus1; this.OrderDetailIDList.Add((int)((JsonNumericValue)itemData["id"]).Value); this.OrderDetailStatusList.Add((int)((JsonNumericValue)itemData["status"]).Value); this.OrderDetailNameList.Add(((JsonStringValue)itemData["menu_name"]).Value); ListViewItem item = new ListViewItem(new string[] { "", ((JsonStringValue)itemData["c_name"]).Value, ((JsonStringValue)itemData["menu_name"]).Value, ((float)((JsonNumericValue)itemData["price"]).Value).ToString("f1"), ((int)((JsonNumericValue)itemData["quantity"]).Value).ToString(), Commons.UnixTimeFrom((long)((JsonNumericValue)itemData["add_time"]).Value).ToString("HH:mm:ss"), status }); this.OrderDetailList.Items.Add(item); } if (this.OrderDetailListSelectedIndex > -1) this.OrderDetailList.Items[this.OrderDetailListSelectedIndex].Selected = true; } } else MessageBox.Show(((JsonStringValue)jsonData["message"]).Value); }
void OnGUI() { if (m_Text == null) { return; } if (GUI.Button(new Rect(100, 100, 150, 50), "测试LitJson")) { string str = m_Text.text; LitJson.JsonMapper.ToObject <Dictionary <string, List <TaskTalkCfg> > >(str); } if (GUI.Button(new Rect(250, 100, 150, 50), "测试FastJson")) { string str = m_Text.text; fastJSON.JSON.ToObject <Dictionary <string, List <TaskTalkCfg> > >(str); } if (GUI.Button(new Rect(400, 100, 150, 50), "测试System.Net.Json")) { string str = m_Text.text; System.Net.Json.JsonTextParser parser = new System.Net.Json.JsonTextParser(); parser.Parse(str); } if (GUI.Button(new Rect(550, 100, 150, 50), "测试Newtonsoft.Json")) { string str = m_Text.text; Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, List <TaskTalkCfg> > >(str); } if (m_Binary != null) { if (GUI.Button(new Rect(100, 150, 150, 50), "测试二进制首次不全读取")) { m_Stream = new MemoryStream(m_Binary.bytes); var dict = ConfigWrap.ToObjectList <string, TaskTalkCfg>(m_Stream); List <TaskTalkCfg> list; if (dict.ConfigTryGetValue("5", out list)) { } } if (GUI.Button(new Rect(250, 150, 150, 50), "二进制全部读取")) { m_Stream = new MemoryStream(m_Binary.bytes); ConfigWrap.ToObjectList <string, TaskTalkCfg>(m_Stream, true); } if (GUI.Button(new Rect(400, 150, 150, 50), "二进制全部读取携程")) { m_Stream = new MemoryStream(m_Binary.bytes); ConfigWrap.ToObjectList <string, TaskTalkCfg>(m_Stream, true, this); } if (GUI.Button(new Rect(550, 150, 150, 50), "二进制异步全读取")) { m_Stream = new MemoryStream(m_Binary.bytes); m_StartTime = Time.realtimeSinceStartup; ConfigWrap.ToObjectListAsync <string, TaskTalkCfg>(m_Stream, m_TaskDict, this, true, OnReadEnd); } if (GUI.Button(new Rect(700, 150, 150, 50), "二进制异步非全读取")) { m_Stream = new MemoryStream(m_Binary.bytes); m_StartTime = Time.realtimeSinceStartup; ConfigWrap.ToObjectListAsync <string, TaskTalkCfg>(m_Stream, m_TaskDict, this, false, OnReadEnd); } if (GUI.Button(new Rect(850, 150, 150, 50), "多线程异步全读取")) { m_Stream = new MemoryStream(m_Binary.bytes); m_StartTime = Time.realtimeSinceStartup; m_ThreadDone = false; m_StartTime = Time.realtimeSinceStartup; Loom.RunAsync( () => { m_ThreadDone = ConfigWrap.ToObjectListThreadAsyncc <string, TaskTalkCfg>(m_Stream, m_TaskDict, true, null); }); } } }
static void Main(string[] args) { // 1. parse sample Console.WriteLine(); Console.WriteLine("Source data:"); Console.WriteLine(jsonText); Console.WriteLine(); JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(jsonText); Console.WriteLine(); Console.WriteLine("Parsed data with indentation in JSON data format:"); Console.WriteLine(obj.ToString()); Console.WriteLine(); JsonUtility.GenerateIndentedJsonText = false; Console.WriteLine(); Console.WriteLine("Parsed data without indentation in JSON data format:"); Console.WriteLine(obj.ToString()); Console.WriteLine(); // enumerate values in json object Console.WriteLine(); Console.WriteLine("Parsed object contains these nested fields:"); foreach (JsonObject field in obj as JsonObjectCollection) { string name = field.Name; string value = string.Empty; string type = field.GetValue().GetType().Name; // try to get value. switch(type) { case "String": value = (string)field.GetValue(); break; case "Double": value = field.GetValue().ToString(); break; case "Boolean": value = field.GetValue().ToString(); break; default: // in this sample we'll not parse nested arrays or objects. throw new NotSupportedException(); } Console.WriteLine("{0} {1} {2}", name.PadLeft(15), type.PadLeft(10), value.PadLeft(15)); } Console.WriteLine(); // 2. generate sample Console.WriteLine(); // root object JsonObjectCollection collection = new JsonObjectCollection(); // nested values collection.Add(new JsonStringValue("FirstName", "Pavel")); collection.Add(new JsonStringValue("LastName", "Lazureykis")); collection.Add(new JsonNumericValue("Age", 23)); collection.Add(new JsonStringValue("Email", "*****@*****.**")); collection.Add(new JsonBooleanValue("HideEmail", true)); Console.WriteLine("Generated object:"); JsonUtility.GenerateIndentedJsonText = true; Console.WriteLine(collection); Console.WriteLine(); }
public static JsonArrayCollection CreateContentsPlayListBySector() { try { string scheduleText = GetLatestScheuleFileText(); var parser = new JsonTextParser(); var jsonObj = parser.Parse(@scheduleText); // abstract cmd var colArry = (JsonArrayCollection)jsonObj; foreach (var o in colArry) { int fldKeyId = 0; int fldParent = 0; int fldOrder = 0; var oneJsonSchdObj = (JsonObjectCollection) o; var vtotSector = oneJsonSchdObj[JsonColName.JsonSchdTotSec].GetValue(); //총구간 int totSector = int.Parse(vtotSector.ToString()); // create Json object array of play contents list by sector order if (totSector > 0) { //var jsonPlayContentsListObj = new JsonObjectCollection(); var arrColPlayContentsList = new JsonArrayCollection(); for (int idx = 0; idx < totSector; ++idx) { var jsonContentsObj = new JsonObjectCollection(); #region create parent sector ++fldKeyId; jsonContentsObj.Add(new JsonNumericValue("fldKeyId", fldKeyId)); // Key ID // 구간 Added for displaying Sector field that parent tab in tree list jsonContentsObj.Add(new JsonNumericValue("fldSector", idx + 1)); jsonContentsObj.Add(new JsonNumericValue("fldParentKey", 0)); fldParent = fldKeyId; arrColPlayContentsList.Add(jsonContentsObj); #endregion //jsonPlayContentsListObj.Add(arrColPlayContentsList); // abstract contents list to Json array collections var colArrayContentsList = (JsonArrayCollection) oneJsonSchdObj[JsonColName.JsonContentsList]; foreach (var oc in colArrayContentsList) { var oneJsonContentsObj = (JsonObjectCollection)oc; string cntsSectors = oneJsonContentsObj["cntsSectors"].GetValue().ToString(); var arrSectors = cntsSectors.Split(','); if (arrSectors.Contains((idx + 1).ToString())) // if this content is included this sector then create play content list { //var arrColPlayContentsList2 = new JsonArrayCollection(); var jsonContentsObj2 = new JsonObjectCollection(); ++fldKeyId; ++fldOrder; jsonContentsObj2.Add(new JsonNumericValue("fldKeyId", fldKeyId)); // Key ID jsonContentsObj2.Add(new JsonNumericValue("fldOrder", fldOrder)); // 순서 jsonContentsObj2.Add(new JsonNumericValue("fldParentKey", fldParent)); // ParentKey // 구간 Added for displaying Sector field that parent tab in tree list jsonContentsObj2.Add(new JsonNumericValue("fldSector", idx + 1)); jsonContentsObj2.Add(oneJsonContentsObj["cntsKey"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsName"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsUpdateDt"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsPlayTime"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsStartDt"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsEndDt"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsStartTime"]); jsonContentsObj2.Add(oneJsonContentsObj["scheCntsEndTime"]); jsonContentsObj2.Add(oneJsonContentsObj["fileName"]); jsonContentsObj2.Add(oneJsonContentsObj["mute"]); arrColPlayContentsList.Add(jsonContentsObj2); //jsonPlayContentsListObj.Add(arrColPlayContentsList2); } } } return arrColPlayContentsList; } else { return null; } } } catch (Exception) { LogFile.ThreadWriteLog("[JSON-ERR]" + Current.SchdName.Name + " 구간별 상영 리스트 생성 오류", LogType.LOG_ERROR); return null; } return null; }
private void ActAfterReceivingJson(string jsonText) { try { var parser = new JsonTextParser(); var jsonObj = parser.Parse(jsonText); // abstract cmd var col = (JsonObjectCollection) jsonObj; var cmdValue = (string)col[JsonColName.JsonCmd].GetValue(); switch (cmdValue) { case JsonCmd.ServerConnected: AppInfoStrc.TextHandlerId = (string) col[JsonColName.JsonTxtHndId].GetValue(); SendPlayerStatusInfo(); // send player system status info : CPU, HDD, MEM SendRequestScheduleSending(); // sending request to server for releasing schedule break; case JsonCmd.NewScheduele: SendRequestScheduleSending(); break; case JsonCmd.SchedueleDown: JsonArrayCollection sheduleListColl = (JsonArrayCollection) col[JsonColName.JsonschdList]; // abstract only schedule JSON text string scheduleColItem = ""; for (int idx = 0; idx < sheduleListColl.Count; idx++) { if (scheduleColItem != "") scheduleColItem += ","; scheduleColItem = scheduleColItem + sheduleListColl[idx]; } scheduleColItem = "[" + scheduleColItem + "]"; string oldScheduleFileText = GetLatestScheuleFileText(); if (scheduleColItem != oldScheduleFileText.TrimEnd() ) // create new schedule file if any differences. // if received schedule json is differ from latest schedule file { // Schedule file will be created with filename consist with timestamp for unique naming. double unixTimeStamp = (double) col[JsonColName.JsonTimestamp].GetValue(); DateTime datetimeTimestamp = CommonFunctions.UnixTimeStampToDateTime(unixTimeStamp); string timeStamp = string.Format("{0:yyyyMMdd_HHmmss}", datetimeTimestamp); JsonToTextFile(scheduleColItem, timeStamp); } var beDownloadContentsListJson = CreateNotDownlodedContents(); // for Downloading.... if (beDownloadContentsListJson != null) { // Web client download info DoDownloadContents(beDownloadContentsListJson); // begin Downloading.... } break; } } catch (Exception) { // Write error log - Received JSON text. var outText = jsonText.Replace("\"", "'"); LogFile.ThreadWriteLog("[RECV-ERR]" + outText, LogType.LOG_ERROR); } }
private static JsonArrayCollection CreateNotDownlodedContents() { try { string scheduleText = GetLatestScheuleFileText(); var parser = new JsonTextParser(); var jsonObj = parser.Parse(@scheduleText); // abstract cmd var colArry = (JsonArrayCollection) jsonObj; //var col = (JsonObjectCollection)jsonObj; var arrColPlayContentsList = new JsonArrayCollection(); foreach (var o in colArry) { var oneJsonSchdObj = (JsonObjectCollection) o; var col = (JsonObjectCollection) o; AppInfoStrc.UrlDownloadWebServer = col[JsonColName.UrlDownloadWebServer].GetValue().ToString(); AppInfoStrc.ExtDownloadWebServer = col[JsonColName.ExtDownloadWebServer].GetValue().ToString(); AppInfoStrc.BridgePath = col[JsonColName.BridgePath].GetValue().ToString(); AppInfoStrc.CurrentScheduleKey = col[JsonColName.JsonSchdKey].GetValue().ToString(); var colArrayContentsList = (JsonArrayCollection)oneJsonSchdObj[JsonColName.JsonContentsList]; if (colArrayContentsList != null) { foreach (var oc in colArrayContentsList) { var oneJsonContentsObj = (JsonObjectCollection) oc; var jsonContentsObj2 = new JsonObjectCollection(); if (!isAreadyExist(arrColPlayContentsList, oneJsonContentsObj["cntsKey"])) { jsonContentsObj2.Add(oneJsonContentsObj["cntsKey"]); jsonContentsObj2.Add(oneJsonContentsObj["cntsUpdateDt"]); jsonContentsObj2.Add(oneJsonContentsObj["fileName"]); arrColPlayContentsList.Add(jsonContentsObj2); } } } } return arrColPlayContentsList; } catch (Exception) { LogFile.ThreadWriteLog("[JSON-ERR]" + Current.SchdName.Name + " 다운받을 콘텐츠 리스트 생성 오류", LogType.LOG_ERROR); return null; } }
// // for subscription // public void fromJSON(string msg) { string json; using (XmlReader xmlrd = XmlReader.Create(new StringReader(msg))) { xmlrd.ReadToFollowing(JSON); json = xmlrd.ReadElementString(); // Debug.WriteLine("json string after parsing xml data : " + json); JsonTextParser parser = new JsonTextParser(); m_jsonObj = parser.Parse(json); } }
private object HandleGetSummaryStats(string res) { if (res.Contains("error_str") || res.Contains("error_code")) { AddError(DateTime.Now, "GetSummaryStats", res); return null; } string[] results = res.Split(new string[1] { "{[(SEP)]}" }, StringSplitOptions.None); for (int j = 0; j < results.Length; j++) { if (results[j] == "{\"data\":[]}") continue; Hashtable values = new Hashtable(); JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(results[j]); JsonUtility.GenerateIndentedJsonText = false; JsonObjectCollection col = (JsonObjectCollection)obj; JsonArrayCollection ar = col[0] as JsonArrayCollection; for (int i = 0; i < ar.Count; i++) { JsonObjectCollection oc = ar[i] as JsonObjectCollection; APIServiceProviderNamespace.main.campaignsDataTable dt = DBModule.GetCampaignByCID(oc["CampaignID"].GetValue().ToString()); if (dt.Rows.Count > 0) { string data = "<fields>"; data += "<sumsearch>" + oc["SumSearch"].GetValue().ToString() + "</sumsearch>"; data += "<sumcontext>" + oc["SumContext"].GetValue().ToString() + "</sumcontext>"; data += "<showssearch>" + oc["ShowsSearch"].GetValue().ToString() + "</showssearch>"; data += "<showscontext>" + oc["ShowsContext"].GetValue().ToString() + "</showscontext>"; data += "<clickssearch>" + oc["ClicksSearch"].GetValue().ToString() + "</clickssearch>"; data += "<clickscontext>" + oc["ClicksContext"].GetValue().ToString() + "</clickscontext>"; data += "</fields>"; string df = "yyyy-MM-dd"; if (ServiceProvider.Formats["datetime"] != null) df = ServiceProvider.Formats["datetime"].ToString(); DateTime statdate = DateTime.ParseExact(oc["StatDate"].GetValue().ToString(), df, null); // DBModule.AddStatisticsRecord(Convert.ToInt32(dt.Rows[0]["id"]), statdate, Convert.ToInt32(oc["ShowsSearch"].GetValue()), Convert.ToInt32(oc["ClicksSearch"].GetValue()), data); } } } return new object(); }
private string[] HandleGetCampaignsList(string res, string subclient, bool activesonly) { if (res.Contains("error_str") || res.Contains("error_code")) { AddError(DateTime.Now, "GetCampaignList", res); return null; } if (res == "{\"data\":[]}") return null; Hashtable values = new Hashtable(); JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(res); JsonUtility.GenerateIndentedJsonText = false; JsonObjectCollection col = (JsonObjectCollection)obj; JsonArrayCollection ar = col[0] as JsonArrayCollection; string[] compaignids = new string[ar.Count]; for (int i = 0; i < ar.Count; i++) { JsonObject isactive = (ar[i] as JsonObjectCollection)["IsActive"]; JsonObject name = (ar[i] as JsonObjectCollection)["Name"]; JsonObject id = (ar[i] as JsonObjectCollection)["CampaignID"]; JsonObject login = (ar[i] as JsonObjectCollection)["Login"]; if (name != null && name.GetValue() != null)// && isactive != null && isactive.GetValue() != null) { if (id != null && id.GetValue() != null && isactive != null && isactive.GetValue() != null && login != null && login.GetValue() != null) { if (!activesonly) { if (subclient.Length > 0 && subclient != login.GetValue().ToString()) continue; compaignids[i] = id.GetValue().ToString(); int cid = DBModule.AddCompaign(name.GetValue().ToString(), id.GetValue().ToString(), SyncManager.CurExecProject.DbId, ServiceProvider.Name, login.GetValue().ToString()); compaignids[i] += "=" + cid.ToString(); } else if (isactive.GetValue().ToString().ToLower() == "yes" ) { if (subclient.Length > 0 && subclient != login.GetValue().ToString()) continue; compaignids[i] = id.GetValue().ToString(); int cid = DBModule.AddCompaign(name.GetValue().ToString(), id.GetValue().ToString(), SyncManager.CurExecProject.DbId, ServiceProvider.Name, login.GetValue().ToString()); compaignids[i] += "=" + cid.ToString(); } } } } return compaignids; }
public void getPosts() { html = ""; File.Delete("C:\\NetPosterText.html"); status.Text = "Getting Posts..."; HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://net12.co.tv/api2/get.json?username="******"&password="******"<style type='text/css'>"; html += "body {"; html += "font-family: 'Calibri';"; html += "font-size: 12px;"; html += "}"; html += ".update {"; html += "background-color: #EDFFFB;"; html += "border: thin #000 solid; padding: 5px;"; html += "}"; html += ".update2 {"; html += "background-color: #EDFFFB;"; html += "border: thin #000 solid; padding: 5px;"; html += "}"; html += ".buttonClass {"; html += "background-color: #EDFFFB;"; html += "border: thin #000 solid; padding: 5px;"; html += "}"; html += ".buttonClass:hover {"; html += "background-color: #000;"; html += "border: thin #000 solid; padding: 5px; color: #FFF;"; html += "}"; html += "a {"; html += "text-decoration:none;"; html += "color: #555;"; html += "}"; html += "a:hover {"; html += "text-decoration:underline;"; html += "}"; html += "</style>"; html += "</head>"; html += "<body>"; // Managing the Updates foreach (JsonObject mainVar in obj as JsonObjectCollection) { switch (mainVar.Name) { case "error_code": if (mainVar.GetValue().ToString() != "100") success = false; break; case "updates": List<JsonObject> updates = (List<JsonObject>)mainVar.GetValue(); // Beginning the foreach loop, looping through each update. foreach (JsonObject update in updates) { // Instantiating the variables for the update. string update_id = ""; string replying_to_username = ""; string replying_to_id = ""; string updateStatus = ""; string time = ""; string source = ""; List<JsonObject> user = new List<JsonObject>(); string imageURL = ""; string updateUserName = ""; // Extracting the variables from the update. foreach (JsonObject var in update as JsonObjectCollection) { switch (var.Name) { case "update_id": update_id = var.GetValue().ToString(); break; case "replying_to_username": replying_to_username = var.GetValue().ToString(); break; case "replying_to_id": replying_to_id = var.GetValue().ToString(); break; case "status": updateStatus = parseBoldText(ResolveLinks(var.GetValue().ToString())); break; case "time": time = var.GetValue().ToString(); break; case "source": source = var.GetValue().ToString(); break; case "user": user = (List<JsonObject>)var.GetValue(); break; } } // Getting the user's ImageURL foreach (JsonObject var in user) { if (var.Name == "avatar") { imageURL = var.GetValue().ToString(); } else if (var.Name == "username") { updateUserName = var.GetValue().ToString(); } } // Generating the HTML code for the variables. html += "<br /><div class='update'>"; html += "<table>"; html += "<tr>"; html += "<td>"; html += "<img src='" + imageURL + "' style='width: 50px; height: 50px;' />"; html += "</td>"; html += "<td>"; html += "<b>" + updateUserName + "</b> - " + updateStatus; html += "<br />"; //Figuring out the Date string date = findDate(time); if (replying_to_id != "0" || replying_to_username != "") html += "Posted " + date + " from " + source + " in reply to " + replying_to_username + "."; else html += "Posted " + date + " from " + source + "."; html += "</td></tr></table>"; html += "</div><br />"; if (updateUserName != username) { html += "<div id='taskPanel' class='update2' name='" + updateUserName + "'>"; html += "<button id='reply' name='" + update_id + "'>Reply</button>"; html += "</div><br />"; } if (updateUserName == username) { html += "<div id='taskPanel' class='update2' name='" + updateUserName + "'>"; html += "<button id='delete' name='" + update_id + "'>Delete</button>"; html += "</div><br />"; } } break; } } if (success) { // Finishing off the HTML html += "</body></html>"; // Creating the temp file File.WriteAllText("C:\\NetPosterText.html", html); System.Threading.Thread.Sleep(0); viewer.Navigate("C:\\NetPosterText.html"); } status.Text = "Ready"; minutes = Properties.Settings.Default.waitTime; updateTimerText(); startTimer(); }
private string[] HandleGetSubClients(string res) { if (res.Contains("error_str") || res.Contains("error_code")) { AddError(DateTime.Now, "GetSubClients", res); return null; } if (res == "{\"data\":[]}") return null; JsonTextParser parser = new JsonTextParser(); JsonObject obj = parser.Parse(res); JsonUtility.GenerateIndentedJsonText = false; JsonObjectCollection col = (JsonObjectCollection)obj; //JsonArrayCollection ar = (JsonArrayCollection)col[0]; //col = (JsonObjectCollection)ar[0]; int i = 0; JsonArrayCollection ar = col[0] as JsonArrayCollection; string[] logins = new string[ar.Count]; for (int j = 0; j < ar.Count; j++) { JsonObject el = (ar[j] as JsonObjectCollection)["Login"]; if (el == null) continue; string name = el.Name; object o = el.GetValue(); string value = ""; if (o != null) value = o.ToString(); //string type = field.GetValue().GetType().Name; logins[j] = value; i++; } return logins; }
private void drawSubFrame() { int noFrame = arrSchedule.Count; for (int i = 0; i < noFrame; i++) { JsonTextParser parser = new JsonTextParser(); JsonObject jsonSchedule = parser.Parse(arrSchedule[i]); OpenSubframe(jsonSchedule); } }
private void button1_Click(object sender, EventArgs e) { picbMainLogo.Visible = false; #region 테스트 코딩 strInSchdl.Add( "{" + " \"xPos\": 100," + " \"yPos\": 0," + " \"hLen\": 360," + " \"vLen\": 200," + " \"fileName\": \"d:/Projects/NDS/Contents/A.avi\"," + " \"volume\": 0 " + "}" ); strInSchdl.Add( "{" + " \"xPos\": 400," + " \"yPos\": 100," + " \"hLen\": 500," + " \"vLen\": 280," + " \"fileName\": \"d:/Projects/NDS/Contents/A.tp\"," + " \"volume\": 0 " + "}" ); strInSchdl.Add( "{" + " \"xPos\": 200," + " \"yPos\": 300," + " \"hLen\": 500," + " \"vLen\": 350," + " \"fileName\": \"d:/Projects/NDS/Contents/A.wmv\"," + " \"volume\": 100 " + "}" ); JsonTextParser parser = new JsonTextParser(); JsonObject jsonShdlObj = parser.Parse(strInSchdl[0]); #endregion movieFrames.Add(new SubFrame(jsonShdlObj)); idxSubFrame = movieFrames.Count - 1; this.Controls.Add(movieFrames[idxSubFrame]); jsonShdlObj = parser.Parse(strInSchdl[1]); movieFrames.Add(new SubFrame(jsonShdlObj)); idxSubFrame = movieFrames.Count - 1; this.Controls.Add(movieFrames[idxSubFrame]); jsonShdlObj = parser.Parse(strInSchdl[2]); movieFrames.Add(new SubFrame(jsonShdlObj)); idxSubFrame = movieFrames.Count - 1; this.Controls.Add(movieFrames[idxSubFrame]); // movieFrames[idxSubFrame].Play(); //movieFrames[1].SetVolume(0); //movieFrames[2].SetVolume(0); movieFrames[1].Audio.ToggleMute(); movieFrames[2].Audio.ToggleMute(); movieFrames[0].Play(); movieFrames[1].Play(); movieFrames[2].Play(); //MessageBox.Show(subFrame.getMessage(" OK")); //movieFrames[0].Audio.Volume = 0; //movieFrames[1].Audio.Volume = 0; //movieFrames[2].Audio.Volume = 0; }