Ejemplo n.º 1
0
        public void СreateCharts()
        {
            tests   = new List <string>();
            results = new List <List <string> >();
            dates   = new List <List <string> >();
            date    = new List <string>();
            MyDate myDate = new MyDate(a, b);


            Message response = JsonConvert.DeserializeObject <Message>(server.SendMsg("GetCharts", Data.ServiceSel, JsonConvert.SerializeObject(mess)));

            try
            {
                response.args.ForEach(elem =>
                {
                    Message test = JsonConvert.DeserializeObject <Message>(elem);
                    if (myDate.Compare(test.args[2]))
                    {
                        string d = test.args[2].Split('|')[0];
                        try
                        {
                            if (!dates[tests.IndexOf(test.args[4])].Contains(d))
                            {
                                if (tests.Contains(test.args[4]))
                                {
                                    results[tests.IndexOf(test.args[4])].Add(test.args[1]);
                                    dates[tests.IndexOf(test.args[4])].Add(d);
                                }
                                else
                                {
                                    tests.Add(test.args[4]);
                                    results.Add(new List <string>());
                                    results[tests.IndexOf(test.args[4])].Add(test.args[1]);
                                    dates.Add(new List <string>());
                                    dates[tests.IndexOf(test.args[4])].Add(d);
                                }
                            }
                        }
                        catch
                        {
                            if (tests.Contains(test.args[4]))
                            {
                                results[tests.IndexOf(test.args[4])].Add(test.args[1]);
                                dates[tests.IndexOf(test.args[4])].Add(d);
                            }
                            else
                            {
                                tests.Add(test.args[4]);
                                results.Add(new List <string>());
                                results[tests.IndexOf(test.args[4])].Add(test.args[1]);
                                dates.Add(new List <string>());
                                dates[tests.IndexOf(test.args[4])].Add(d);
                            }
                        }
                        if (date.Contains(d))
                        {
                        }
                        else
                        {
                            date.Add(d);
                        }
                    }
                });
            }
            catch { }
            for (int i = 0; i < dates.Count; i++)
            {
                if (dates[i].Count != date.Count)
                {
                    for (int j = 0; j < date.Count; j++)
                    {
                        if (!dates[i].Contains(date[j]))
                        {
                            dates[i].Insert(j, date[j]);
                            if (j != 0 && j != results[i].Count && results[i][j - 1] != "" && results[i][j] != "")
                            {
                                results[i].Insert(j, results[i][j - 1]);
                            }
                            else
                            {
                                results[i].Insert(j, "");
                            }
                        }
                    }
                }
            }
            string temp = "";

            for (int i = 0; i < date.Count; i++)
            {
                if (date[i] == temp)
                {
                    date[i] = "";
                }
                else
                {
                    temp = date[i];
                }
            }
        }