public static MyTimeSpan[] DesirialazeArray(string s) { string[] ss = s.Split(new string[] { "},", "}" }, StringSplitOptions.RemoveEmptyEntries); MyTimeSpan[] myTimes = new MyTimeSpan[ss.Length - 1]; for (int i = 0; i < ss.Length - 1; i++) { string[] sss = ss[i].Split(','); myTimes[i] = new MyTimeSpan(); string[] ssss = sss[0].Split(':'); myTimes[i].Day = Convert.ToInt32(ssss[ssss.Length - 1]); ssss = sss[1].Split(':'); myTimes[i].Hour = Convert.ToInt32(ssss[ssss.Length - 1]); ssss = sss[2].Split(':'); myTimes[i].Minute = Convert.ToInt32(ssss[ssss.Length - 1]); ssss = sss[3].Split(':'); myTimes[i].Second = Convert.ToInt32(ssss[ssss.Length - 1]); ssss = sss[4].Split(':'); myTimes[i].Milisecond = Convert.ToInt32(ssss[ssss.Length - 1]); } return(myTimes); }
private void ActivityGrafDraw() { label5.Text = ""; WebRequest req = WebRequest.CreateHttp("https://localhost:5001/api/Activity/Statistics/Activity/" + Periods[comboBox3.Text] + "/" + Chastota[comboBox4.Text] + "/" + comboBox2.Text); req.ContentType = "application/json"; req.Method = "GET"; req.Headers.Add("Authorization:Bearer " + token); WebResponse resp = req.GetResponse(); MyTimeSpan[] times; using (var streamWriter = new StreamReader(resp.GetResponseStream())) { string s = streamWriter.ReadToEnd(); times = MyTimeSpan.DesirialazeArray(s); for (int i = 0; i < times.Length; i++) { label5.Text += i + ": " + times[i].Day + " Дней, " + times[i].Hour + " Часов, " + times[i].Minute + " Минут, " + times[i].Second + " Секунд" + "\r\n"; } } myTimes = times; panel4.Refresh(); }