Exemple #1
0
        public devCommit getCritData(string login, string password)
        {
            request  = WebRequest.Create("http://nogy.onlinehacktomsk.ru/getcrit.php");
            postData = "login="******"&password="******"application/x-www-form-urlencoded";
            request.Method        = "POST";
            devCommit def = new devCommit();

            try
            {
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                WebResponse response = request.GetResponse();
                using (dataStream = response.GetResponseStream())
                {
                    StreamReader reader             = new StreamReader(dataStream);
                    string       responseFromServer = reader.ReadToEnd();
                    response.Close();
                    reader.Close();
                    if (responseFromServer == "0")
                    {
                        return(def);
                    }
                    List <devCommit> result = JsonConvert.DeserializeObject <List <devCommit> >(responseFromServer);
                    return(result[0]);
                }
            }
            catch (System.Net.WebException e)
            {
                return(def);
            };
        }
Exemple #2
0
        void update()
        {
            WebRequests client = new WebRequests();

            dataList = client.getDevData(curuser.login, curuser.password);
            devListUpdate();
            for (int i = 0; i < dataList.Count; i++)
            {
                devCommit tempCom = dataList[i]; tempCom.getDate(); dataList[i] = tempCom;
            }
            dPicker1.MaxDate = dataList[dataList.Count - 1].dattim;
            dPicker1.MinDate = dataList[0].dattim;
            dPicker2.MaxDate = dataList[dataList.Count - 1].dattim;
            dPicker2.MinDate = dataList[0].dattim;
            draw();
        }
Exemple #3
0
        private void draw()
        {
            int posY = 0;

            //ПОИСК КРАЙНИХ ИНДЕКСОВ СПИСКА ПО ДАТЕ
            foreach (devCommit tempCom in dataList)
            {
                if (tempCom.dattim.CompareTo(dPicker1.Value) >= 0)
                {
                    a = dataList.IndexOf(tempCom);
                    break;
                }
            }
            foreach (devCommit tempCom in dataList)
            {
                if (tempCom.dattim.CompareTo(dPicker2.Value) == 0)
                {
                    b = dataList.IndexOf(tempCom);
                    break;
                }
                else if (tempCom.dattim.CompareTo(dPicker2.Value) > 0)
                {
                    b = dataList.IndexOf(tempCom) - 1;
                }
            }
            infoBox.Controls.Clear();

            //ВЫВОД В ЗАВИСИМОСТИ ОТ ВЫБРАННОГО ТИПА
            //ВЫВОД ГРАФИКОВ/ДИАГРАММ
            if (typeCombo.SelectedIndex == 0 || typeCombo.SelectedIndex == 1)
            {
                foreach (ToolStripMenuItem curpar in par.DropDownItems)
                {
                    if (!curpar.Checked || curpar.Text == "Отметить все")
                    {
                        continue;
                    }

                    Chart     tempChart  = new Chart();
                    ChartArea chartArea1 = new ChartArea();
                    Legend    Legend1    = new Legend();
                    Title     title      = new Title();

                    title.Text      = curpar.Text;
                    title.Font      = new System.Drawing.Font("Century Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
                    chartArea1.Name = "chartArea_" + curpar.Name;
                    Legend1.Name    = "legend_" + curpar.Name;
                    tempChart.Name  = "chart_" + curpar.Name;
                    tempChart.Text  = curpar.Text;

                    chartArea1.CursorX.IsUserEnabled              = true;
                    chartArea1.CursorX.IsUserSelectionEnabled     = true;
                    chartArea1.AxisX.ScaleView.Zoomable           = true;
                    chartArea1.AxisX.ScrollBar.IsPositionedInside = false;

                    tempChart.Size     = new System.Drawing.Size(infoBox.Width - 30, 320);
                    tempChart.Location = new System.Drawing.Point(0, posY); posY += 350;
                    tempChart.Legends.Add(Legend1);
                    tempChart.Titles.Add(title);
                    tempChart.ChartAreas.Add(chartArea1);

                    infoBox.Controls.Add(tempChart);

                    foreach (ToolStripMenuItem id in id_dev.DropDownItems)
                    {
                        if (!id.Checked || id.Text == "Отметить все")
                        {
                            continue;
                        }
                        Series ser = new Series();
                        ser.Legend      = "legend_" + curpar.Name;
                        ser.BorderWidth = 3;
                        ser.LegendText  = id.Text;
                        ser.Name        = "ser_" + curpar.Name + id.Text;
                        ser.ChartArea   = "chartArea_" + curpar.Name;
                        if (typeCombo.SelectedIndex == 0)
                        {
                            ser.ChartType = SeriesChartType.Line;
                        }
                        else
                        {
                            ser.ChartType = SeriesChartType.Column;
                        }
                        tempChart.Series.Add(ser);
                    }
                }
                for (int i = a, count = 0; i < b + 1; i++)
                {
                    devCommit tempCom = dataList[i]; bool flag = false;
                    foreach (ToolStripMenuItem s  in id_dev.DropDown.Items)
                    {
                        if (s.Checked && s.Text == tempCom.dev_id.ToString())
                        {
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        continue;
                    }
                    count++;
                    foreach (ToolStripMenuItem tempItem in par.DropDownItems)
                    {
                        if (tempItem.Checked && tempItem.Text != "Отметить все")
                        {
                            Chart  ch = (infoBox.Controls["chart_" + tempItem.Name] as Chart);
                            Series s  = (infoBox.Controls["chart_" + tempItem.Name] as Chart).Series["ser_" + tempItem.Name + tempCom.dev_id.ToString()];
                            s.Points.AddXY(tempCom.date, Convert.ToDouble(tempCom.GetField(tempItem.Name)));
                            if (tempItem.Name == "temp")
                            {
                                Console.WriteLine(tempCom.temp);
                            }
                            if (s.Points.Count == 1)
                            {
                                //ch.ChartAreas["chartArea_" + tempItem.Name].AxisX.ScaleView.Zoom(0, 4);
                                ch.ChartAreas["chartArea_" + tempItem.Name].AxisY.Maximum = Convert.ToDouble(tempCom.GetField(tempItem.Name));
                                ch.ChartAreas["chartArea_" + tempItem.Name].AxisY.Minimum = Convert.ToDouble(tempCom.GetField(tempItem.Name));
                            }
                            if (ch.ChartAreas["chartArea_" + tempItem.Name].AxisY.Maximum < Convert.ToDouble(tempCom.GetField(tempItem.Name)))
                            {
                                ch.ChartAreas["chartArea_" + tempItem.Name].AxisY.Maximum = Convert.ToDouble(tempCom.GetField(tempItem.Name));
                            }
                            else if (ch.ChartAreas["chartArea_" + tempItem.Name].AxisY.Minimum > Convert.ToDouble(tempCom.GetField(tempItem.Name)))
                            {
                                ch.ChartAreas["chartArea_" + tempItem.Name].AxisY.Minimum = Convert.ToDouble(tempCom.GetField(tempItem.Name));
                            }
                        }
                    }
                }
            }

            //ВЫВОД ТАБЛИЦЫ С ИНФОРМЦИЕЙ

            if (typeCombo.SelectedIndex == 2)
            {
                DataGridView data = new DataGridView();
                data.Size        = infoBox.Size;
                data.ColumnCount = 8;
                //data.RowCount = 1;
                data.AutoSizeColumnsMode   = DataGridViewAutoSizeColumnsMode.Fill;
                data.Columns[0].HeaderText = "ID"; data.Columns[0].Name = "dev_id";
                data.Columns[1].HeaderText = "Дата"; data.Columns[0].Name = "date";
                data.Columns[2].HeaderText = "Время"; data.Columns[0].Name = "time";
                data.ColumnHeadersHeight   = 80;
                int count = 3;
                foreach (ToolStripMenuItem curpar in par.DropDownItems)
                {
                    if (!curpar.Checked || curpar.Text == "Отметить все")
                    {
                        continue;
                    }
                    data.Columns[count].HeaderText = curpar.Text;
                    data.Columns[count].Name       = curpar.Name;
                    count++;
                }
                data.ColumnCount = count;
                int rowCount = 0;
                for (int i = a; i < b + 1; i++)
                {
                    devCommit tempCom = dataList[i]; bool flag = false;
                    foreach (ToolStripMenuItem s in id_dev.DropDown.Items)
                    {
                        if (s.Checked && s.Text == tempCom.dev_id.ToString())
                        {
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        continue;
                    }
                    data.RowCount++;
                    int colCount = 3;
                    data.Rows[rowCount].Cells[0].Value = tempCom.dev_id;
                    data.Rows[rowCount].Cells[1].Value = tempCom.date;
                    data.Rows[rowCount].Cells[2].Value = tempCom.time;
                    foreach (ToolStripMenuItem tempItem in par.DropDownItems)
                    {
                        if (tempItem.Checked && tempItem.Text != "Отметить все")
                        {
                            data.Rows[rowCount].Cells[colCount].Value = tempCom.GetField(tempItem.Name);
                            colCount++;
                        }
                    }
                    rowCount++;
                }
                //data.RowCount--;
                infoBox.Controls.Add(data);
            }
        }
        private void reptForm_Load(object sender, EventArgs e)
        {
            data.Rows.Clear();
            data.ColumnCount = 5;
            data.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            data.Columns[0].HeaderText     = "ID"; data.Columns[1].HeaderText = "Дата";
            data.Columns[2].HeaderText     = "Время"; data.Columns[3].HeaderText = "Событие";
            data.Columns[4].HeaderText     = "Значение - Крит. значение";
            data.Columns[0].Width          = 40; data.Columns[3].Width = 300;
            int rowCount = 0;

            for (int i = a; i < b + 1; i++)
            {
                devCommit tempCom = dataList[i]; bool flag = false;
                foreach (ToolStripMenuItem s in id_dev.DropDown.Items)
                {
                    if (s.Checked && s.Text == tempCom.dev_id.ToString())
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    continue;
                }
                foreach (ToolStripMenuItem tempItem in par.DropDownItems)
                {
                    if (tempItem.Checked && tempItem.Text != "Отметить все")
                    {
                        int whatHappened = 0;
                        switch (tempItem.Name)
                        {
                        case "temp":
                            if (tempCom.temp >= 0.95 * critParam.temp && tempCom.temp < critParam.temp)
                            {
                                whatHappened = 1;
                            }
                            else if (tempCom.temp >= critParam.temp)
                            {
                                whatHappened = 2;
                            }
                            break;

                        case "vibr":
                            if (tempCom.vibr >= 0.95 * critParam.vibr && tempCom.vibr < critParam.vibr)
                            {
                                whatHappened = 1;
                            }
                            else if (tempCom.vibr >= critParam.vibr)
                            {
                                whatHappened = 2;
                            }
                            break;

                        case "loading":
                            if (tempCom.loading >= 0.80 * critParam.loading && tempCom.loading < 0.95 * critParam.loading)
                            {
                                whatHappened = 1;
                            }
                            else if (tempCom.loading >= 0.95 * critParam.loading)
                            {
                                whatHappened = 2;
                            }
                            break;

                        case "power":
                            if (tempCom.power >= 0.95 * critParam.power && tempCom.power < critParam.power)
                            {
                                whatHappened = 1;
                            }
                            else if (tempCom.power >= critParam.power)
                            {
                                whatHappened = 2;
                            }
                            break;

                        case "work_time":
                            if (tempCom.work_time >= 0.85 * critParam.work_time && tempCom.work_time < critParam.work_time)
                            {
                                whatHappened = 1;
                            }
                            else if (tempCom.work_time >= critParam.work_time)
                            {
                                whatHappened = 2;
                            }
                            break;
                        }
                        if (whatHappened > 0)
                        {
                            data.RowCount++;
                            data.Rows[rowCount].Height         = 60;
                            data.Rows[rowCount].Cells[0].Value = tempCom.dev_id;
                            data.Rows[rowCount].Cells[1].Value = tempCom.date;
                            data.Rows[rowCount].Cells[2].Value = tempCom.time;
                            data.Rows[rowCount].Cells[3].Value = "Значение параметра \"" + tempItem.Text + "\" ";
                            if (whatHappened == 1)
                            {
                                data.Rows[rowCount].Cells[3].Value += "приближается к критическому";
                            }
                            else
                            {
                                data.Rows[rowCount].Cells[3].Value          += "превысило критическое";
                                data.Rows[rowCount].Cells[3].Style.BackColor = Color.Red;
                            }
                            data.Rows[rowCount].Cells[4].Value = tempCom.GetField(tempItem.Name) + " - " + critParam.GetField(tempItem.Name);
                            rowCount++;
                        }
                    }
                }
            }
        }