public void FillFusionData(Fusion fusion)
        {
            string sql = "SELECT h.HEAT_ID,h.HEAT_NO,h.RPT_TSOLL,h.RPT_TIST,h.RPT_CSOLL,h.RPT_CIST,h.DT_BEGIN,h.DT_END,h.TEAM_NAME,";
            sql += "g.NAME_ENGLISH FROM HEATS h, GRADE_SPEC g WHERE h.DT_BEGIN BETWEEN " + OracleDate(fusion.StartDate.AddMinutes(-6)) + " AND ";
            sql += OracleDate(fusion.StartDate.AddMinutes(6)) + " AND h.CV_NO=" + fusion.ConverterNumber.ToString() + " AND h.GRADE_ID=g.GRADE_ID";

            OracleDataReader reader = Execute(sql);
            while (reader.Read())
            {
                fusion.Id = int.Parse(reader[0].ToString());
                fusion.Number = int.Parse(reader[1].ToString());
                fusion.PlannedTempereture = int.Parse(!string.IsNullOrEmpty(reader[2].ToString()) ? reader[2].ToString() : "0");
                fusion.FactTemperature = int.Parse(!string.IsNullOrEmpty(reader[3].ToString()) ? reader[3].ToString() : "0");
                fusion.PlannedC = double.Parse(!string.IsNullOrEmpty(reader[4].ToString()) ? reader[4].ToString() : "0.0");
                fusion.FactC = double.Parse(!string.IsNullOrEmpty(reader[5].ToString()) ? reader[5].ToString() : "0");
                fusion.StartDateDB = DateTime.Parse(reader[6].ToString());
                fusion.EndDate = DateTime.Parse(reader[7].ToString());
                fusion.TeamNumber = int.Parse(!string.IsNullOrEmpty(reader[8].ToString()) ? reader[8].ToString() : "0");
                fusion.Grade = reader[9].ToString();

            }
            // clean up
            reader.Close();
            FillDataByLance(fusion);
            FillDataByGasFlow(fusion);
        }
        public List<Fusion> GetTrendPoints(string fileName)
        {
            List<Fusion> result = new List<Fusion>();
            List<TrendPoint> points = new List<TrendPoint>();
            System.IO.StreamReader streamReader = new System.IO.StreamReader(fileName);
            System.IO.FileInfo file = new System.IO.FileInfo(fileName);
            m_NewType = file.Extension == ".pldx";

            int countFusion = 0;
            string startDate = "";
            Fusion fusion = null;
            while (!streamReader.EndOfStream)
            {
                string temp = streamReader.ReadLine();
                if (temp.StartsWith("V7") || temp.StartsWith("New"))
                {
                    continue;
                }
                if (temp.StartsWith(">"))
                {

                    countFusion++;
                    if (countFusion > 1)
                    {

                        if (!m_NewType)
                        {
                            string startDate1 = ParseDateFromFileName(fileName);
                            startDate1 = string.Format("{0} {1}:00", startDate1, temp.Substring(1, 5));
                            if (Convert.ToDateTime(startDate) != Convert.ToDateTime(startDate1))
                            {
                                fusion = new Fusion(countFusion, Convert.ToDateTime(startDate), points);
                                fusion.AggregateNumber = int.Parse(fileName.Substring(fileName.Length - 16, 1));
                            }
                            else
                            {
                                countFusion--;
                            }
                        }
                        else
                        {

                            string[] split = temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            fusion = new Fusion(int.Parse(split[1]), DateTime.Parse(split[2] + " " + split[3]), points);
                            fusion.AggregateNumber = int.Parse(fileName.Substring(fileName.Length - 17, 1));
                            fusion.ID = int.Parse(split[0].Substring(2));
                            fusion.StartDate = DateTime.Parse(split[4] + " " + split[5]);
                            fusion.TeamNumber = int.Parse(split[6]);
                            int offset = 0;
                            if (split.Length < 12) continue;
                            if (split.Length > 12)
                            {
                                offset = split.Length - 12;
                                for (int i = 7; i <= 7 + offset; i++)
                                {
                                    fusion.Grade += split[i];
                                }
                            }
                            else
                            {
                                fusion.Grade = split[7];
                            }

                            fusion.PlannedTemperature = int.Parse(split[8 + offset]);
                            fusion.FactTemperature = int.Parse(split[9 + offset]);
                            fusion.PlannedCarbon = double.Parse(split[10 + offset]);
                            fusion.FactCarbon = double.Parse(split[11 + offset]);

                        }
                        if (fusion != null)
                        {
                            result.Add(fusion);
                            points = new List<TrendPoint>();
                        }
                    }
                    if (!m_NewType)
                    {
                        startDate = ParseDateFromFileName(fileName);
                        startDate = string.Format("{0} {1}:00", startDate, temp.Substring(1, 5));
                    }
                    else
                    {
                        startDate = temp;
                    }
                    continue;
                }
                if (m_NewType)
                {
                    points.Add(ParseLineNew(temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)));
                }
                else
                {
                    points.Add(ParseLine(temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), startDate));
                }
            }

            return result;
        }
        public Fusion GetFusion(string heatNumber)
        {
            Fusion fusion = new Fusion();
            string sql = "SELECT h.HEAT_ID,h.HEAT_NO,h.RPT_TSOLL,h.RPT_TIST,h.RPT_CSOLL,h.RPT_CIST,to_char(h.DT_BEGIN,'dd.mm.yy HH24:mi:ss'),to_char(h.DT_END,'dd.mm.yy HH24:mi:ss'),h.TEAM_NAME,";
            sql += "g.NAME_ENGLISH,h.CHGD_HMWEIGHT,h.HM_TEMP,h.CONVERTER_LIFE FROM HEATS h, GRADE_SPEC g WHERE h.HEAT_NO='" + heatNumber + "' AND h.GRADE_ID=g.GRADE_ID";

            OracleDataReader reader = Execute(sql);
            while (reader.Read())
            {
                fusion.ID = int.Parse(reader[0].ToString());
                fusion.Number = int.Parse(reader[1].ToString());
                fusion.PlannedTemperature = int.Parse(!string.IsNullOrEmpty(reader[2].ToString()) ? reader[2].ToString() : "0");
                fusion.FactTemperature = int.Parse(!string.IsNullOrEmpty(reader[3].ToString()) ? reader[3].ToString() : "0");
                fusion.PlannedCarbon = double.Parse(!string.IsNullOrEmpty(reader[4].ToString()) ? reader[4].ToString() : "0");
                fusion.FactCarbon = double.Parse(!string.IsNullOrEmpty(reader[5].ToString()) ? reader[5].ToString() : "0");
                fusion.StartDate = DateTime.Parse(reader[6].ToString());
                fusion.EndDate = DateTime.Parse(!string.IsNullOrEmpty(reader[7].ToString()) ? reader[7].ToString() : "01.01.01");
                fusion.TeamNumber = int.Parse(!string.IsNullOrEmpty(reader[8].ToString()) ? reader[8].ToString() : "0");
                fusion.Grade = reader[9].ToString();
                fusion.CastIronWeight = int.Parse(CheckNubmerForNull(reader[10].ToString()));
                fusion.CastIronTemp = int.Parse(CheckNubmerForNull(reader[11].ToString()));
                fusion.AggregateLifeTime = int.Parse(CheckNubmerForNull(reader[12].ToString()));
                fusion.AggregateNumber = int.Parse(heatNumber.Substring(0, 1));
            }
            // clean up
            reader.Close();
            return fusion;
        }
        private void FillDataByLance(Fusion fusion)
        {
            string sql = "SELECT INSERTTIME, O2PRESSURE, LANCEHGT FROM HEAT_BLOWINGS where HEAT_ID=" + fusion.Id.ToString();
            OracleDataReader reader = Execute(sql);
            while (reader.Read())
            {

                TrendPoint trendPoint = fusion.Points.Find(p => p.Time == DateTime.Parse(reader[0].ToString()) - fusion.StartDateDB);
                if (trendPoint != null)
                {
                    trendPoint.O2Pressure = double.Parse(!string.IsNullOrEmpty(reader[1].ToString()) ? reader[1].ToString() : "0.0");
                    trendPoint.LanceHeight = int.Parse(!string.IsNullOrEmpty(reader[2].ToString()) ? reader[2].ToString() : "0");
                }
            }
            reader.Close();
        }
 private void FillDataByGasFlow(Fusion fusion)
 {
     string sql = "SELECT INSERTTIME, FLOW FROM HEAT_OFFGAS where HEAT_ID=" + fusion.Id.ToString();
     OracleDataReader reader = Execute(sql);
     while (reader.Read())
     {
         TrendPoint trendPoint = fusion.Points.Find(p => p.Time == DateTime.Parse(reader[0].ToString()) - fusion.StartDateDB);
         if (trendPoint != null)
             trendPoint.GasFlow = int.Parse(!string.IsNullOrEmpty(reader[1].ToString()) ? reader[1].ToString() : "0");
     }
     reader.Close();
 }
 public List<Fusion> GetFusionsData(DateTime dateBeg, DateTime dateEnd, int converterNumber,int GradeID)
 {
     List<Fusion> result = new List<Fusion>();
     string sql = "SELECT DISTINCT h.HEAT_ID,h.HEAT_NO,h.RPT_TSOLL,h.RPT_TIST,h.RPT_CSOLL,h.RPT_CIST,to_char(h.DT_BEGIN,'dd.mm.yy HH24:mi:ss'),to_char(h.DT_END,'dd.mm.yy HH24:mi:ss'),h.TEAM_NAME,";
     sql += "g.NAME_ENGLISH,h.CHGD_HMWEIGHT,h.HM_TEMP FROM HEATS h, GRADE_SPEC g, heat_offgas ho WHERE h.HEAT_ID = ho.HEAt_ID AND h.DT_BEGIN BETWEEN " + OracleDate(dateBeg) + " AND ";
     sql += OracleDate(dateEnd) + " AND h.CV_NO=" + converterNumber.ToString() + " AND h.GRADE_ID=g.GRADE_ID";
     if (GradeID != 0)
     {
         sql += " AND h.GRADE_ID=" + GradeID.ToString();
     }
     sql += " ORDER BY h.HEAT_NO";
     OracleDataReader reader = Execute(sql);
     while (reader.Read())
     {
         Fusion fusion = new Fusion();
         fusion.Id = int.Parse(reader[0].ToString());
         fusion.Number = int.Parse(reader[1].ToString());
         fusion.PlannedTempereture = int.Parse(!string.IsNullOrEmpty(reader[2].ToString()) ? reader[2].ToString() : "0");
         fusion.FactTemperature = int.Parse(!string.IsNullOrEmpty(reader[3].ToString()) ? reader[3].ToString() : "0");
         fusion.PlannedC = double.Parse(!string.IsNullOrEmpty(reader[4].ToString()) ? reader[4].ToString() : "0");
         fusion.FactC = double.Parse(!string.IsNullOrEmpty(reader[5].ToString()) ? reader[5].ToString() : "0");
         fusion.StartDateDB = DateTime.Parse(reader[6].ToString());
         fusion.EndDate = DateTime.Parse(!string.IsNullOrEmpty(reader[7].ToString()) ? reader[7].ToString() : "01.01.01");
         fusion.TeamNumber = int.Parse(!string.IsNullOrEmpty(reader[8].ToString()) ? reader[8].ToString() : "0");
         fusion.Grade = reader[9].ToString();
         fusion.CastIronWeight = int.Parse(CheckNubmerForNull(reader[10].ToString()));
         fusion.CastIronTemp = int.Parse(CheckNubmerForNull(reader[11].ToString()));
         fusion.ConverterNumber = converterNumber;
         result.Add(fusion);
     }
     // clean up
     reader.Close();
     return result;
 }
Пример #7
0
 private void FindFusionMath(Fusion fusion)
 {
     m_Db.FillFusionData(fusion);
     listBox1.Items.Add(DateTime.Now.ToString() + ": Плавка №" + fusion.Number.ToString() + "(" + fusion.Id.ToString() + ") загружена.");
 }
        public bool DoCommon(Fusion fusion, List<OffGas> offgases, List<Lance> lances, List<Addition> additions, List<Sublance> sublances, List<SlagOutburstEvent> slagOutburst, List<IgnitionEvent> ignition)
        {
            if (!m_FileExist)
            {
                Microsoft.Office.Interop.Excel.Worksheet newWorksheet = ExcelWorkBook.Sheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                newWorksheet.Name = "Сводные данные";
            }
            int col = 2; int row = ExcelApp.Rows.Worksheet.UsedRange.Rows.Count + 2;

            ExcelApp.Cells[++row, col++] = "Плавка :";
            ExcelApp.Cells[row, col++] = "Марка: ";
            ExcelApp.Cells[row, col++] = "T задан.: ";
            ExcelApp.Cells[row, col++] = "T факт.: ";
            ExcelApp.Cells[row, col++] = "С задан.: ";
            ExcelApp.Cells[row, col++] = "С факт.: ";
            ExcelApp.Cells[row, col++] = "Дата начала: ";
            ExcelApp.Cells[row, col] = "Дата окончания: ";
            col = 2;
            ExcelApp.Cells[++row, col++] = fusion.Number.ToString();
            ExcelApp.Cells[row, col++] = fusion.Grade;
            ExcelApp.Cells[row, col++] = fusion.PlannedTemperature;
            ExcelApp.Cells[row, col++] = fusion.FactTemperature;
            ExcelApp.Cells[row, col++] = fusion.PlannedCarbon;
            ExcelApp.Cells[row, col++] = fusion.FactCarbon;
            ExcelApp.Cells[row, col++] = fusion.StartDate;
            ExcelApp.Cells[row, col] = fusion.EndDate;
            ExcelApp.Cells[++row, 1] = "Время";
            ExcelApp.Cells[row, 2] = "Положение фурмы";
            ExcelApp.Cells[row, 3] = "Интенсивность О2";
            ExcelApp.Cells[row, 4] = "H2";
            ExcelApp.Cells[row, 5] = "О2";
            ExcelApp.Cells[row, 6] = "CО";
            ExcelApp.Cells[row, 7] = "CО2";
            ExcelApp.Cells[row, 8] = "N2";
            ExcelApp.Cells[row, 9] = "Ar";
            ExcelApp.Cells[row, 10] = "Материал название";
            ExcelApp.Cells[row, 11] = "Материал вес";
            ExcelApp.Cells[row, 12] = "Зонд [T]";
            ExcelApp.Cells[row, 13] = "Зонд [C]";
            ExcelApp.Cells[row, 14] = "Зонд [Оксислен.]";
            ExcelApp.Cells[row, 15] = "Лев.фурма Q воды вход";
            ExcelApp.Cells[row, 16] = "Лев.фурма T воды вход";
            ExcelApp.Cells[row, 17] = "Лев.фурма Q воды слив";
            ExcelApp.Cells[row, 18] = "Лев.фурма T воды слив";
            ExcelApp.Cells[row, 19] = "Прав.фурма Q воды вход";
            ExcelApp.Cells[row, 20] = "Прав.фурма T воды вход";
            ExcelApp.Cells[row, 21] = "Прав.фурма Q воды слив";
            ExcelApp.Cells[row, 22] = "Прав.фурма T воды слив";
            ExcelApp.Cells[row, 23] = "V отх. газов";
            ExcelApp.Cells[row, 24] = "Т отх. газов";
            ExcelApp.Cells[row, 25] = "Т отх. газов на выходе";
            ExcelApp.Cells[row, 26] = "Т отх. газов охлаждение";
            ExcelApp.Cells[row, 27] = "Т отх. газов 1 ступень";
            ExcelApp.Cells[row, 28] = "Т отх. газов 2 ступень";
            ExcelApp.Cells[row, 29] = "Зажигание плавки";
            ExcelApp.Cells[row, 30] = "Выбросы шлака";

            row++;

            var minDate = DateTime.Now;
            var maxDate = new DateTime();

            if (offgases.Count != 0)
            {
                minDate = new[] { minDate, offgases.Min(p => p.Date) }.Min();
                maxDate = new[] { maxDate, offgases.Max(p => p.Date) }.Max();
            }

            if (lances.Count != 0)
            {
                minDate = new[] { minDate, lances.Min(p => p.Date) }.Min();
                maxDate = new[] { maxDate, lances.Max(p => p.Date) }.Max();
            }

            if (additions.Count != 0)
            {
                minDate = new[] { minDate, additions.Min(p => p.Date) }.Min();
                maxDate = new[] { maxDate, additions.Max(p => p.Date) }.Max();
            }

            DateTime curDate = minDate;
            Lance lastLanceInfo = null;
            OffGas lastOffgas = null;
            while (curDate <= maxDate)
            {
                bool findSomeThing = false;
                Lance lanceInfo = null;
                if (lances != null)
                {
                    lanceInfo = lances.Find(p =>p.Date.Date == curDate.Date && p.Date.Hour == curDate.Hour && p.Date.Minute == curDate.Minute && p.Date.Second == curDate.Second);
                    if (lanceInfo != null)
                    {
                        ExcelApp.Cells[row, 2] = lanceInfo.Height;
                        ExcelApp.Cells[row, 3] = lanceInfo.O2Flow;
                        ExcelApp.Cells[row, 15] = lanceInfo.O2LeftLanceWaterInput;
                        ExcelApp.Cells[row, 16] = lanceInfo.O2LeftLanceWaterTempInput;
                        ExcelApp.Cells[row, 17] = lanceInfo.O2LeftLanceWaterOutput;
                        ExcelApp.Cells[row, 18] = lanceInfo.O2LeftLanceWaterTempOutput;
                        ExcelApp.Cells[row, 19] = lanceInfo.O2RightLanceWaterInput;
                        ExcelApp.Cells[row, 20] = lanceInfo.O2RightLanceWaterTempInput;
                        ExcelApp.Cells[row, 21] = lanceInfo.O2RightLanceWaterOutput;
                        ExcelApp.Cells[row, 22] = lanceInfo.O2RightLanceWaterTempOutput;
                        lastLanceInfo = lanceInfo;
                        findSomeThing = true;
                    }
                }

                OffGas offgas = null;
                if (offgases != null)
                {

                    offgas = offgases.Find( p =>p.Date.Date == curDate.Date && p.Date.Hour == curDate.Hour && p.Date.Minute == curDate.Minute && p.Date.Second == curDate.Second);
                    if (offgas != null)
                    {
                        ExcelApp.Cells[row, 4] = offgas.H2;
                        ExcelApp.Cells[row, 5] = offgas.O2;
                        ExcelApp.Cells[row, 6] = offgas.CO;
                        ExcelApp.Cells[row, 7] = offgas.CO2;
                        ExcelApp.Cells[row, 8] = offgas.N2;
                        ExcelApp.Cells[row, 9] = offgas.Ar;
                        ExcelApp.Cells[row, 23] = offgas.Temperature;
                        ExcelApp.Cells[row, 24] = offgas.Flow;
                        ExcelApp.Cells[row, 25] = offgas.TemperatureOnExit;
                        ExcelApp.Cells[row, 26] = offgas.PrecollingTemperature;
                        ExcelApp.Cells[row, 27] = offgas.TemperatureAfter1Step;
                        ExcelApp.Cells[row, 28] = offgas.TemperatureAfter2Step;
                        lastOffgas = offgas;
                        findSomeThing = true;
                    }
                }

                if (additions != null)
                    {
                        Addition addition = additions.Find(p => p.Date.Date == curDate.Date && p.Date.Hour == curDate.Hour && p.Date.Minute == curDate.Minute
                                                                && p.Date.Second == curDate.Second);
                        if (addition != null)
                        {
                            ExcelApp.Cells[row, 10] = addition.MaterialName;
                            ExcelApp.Cells[row, 11] = addition.PortionWeight;
                            findSomeThing = true;
                        }
                    }

                    if (sublances != null)
                    {
                        Sublance sublance = sublances.Find(p => p.StartDate.Date == curDate.Date && p.StartDate.Hour == curDate.Hour && p.StartDate.Minute == curDate.Minute
                                                                && p.StartDate.Second == curDate.Second);
                        if (sublance != null)
                        {
                            ExcelApp.Cells[row, 12] = sublance.Temperature;
                            ExcelApp.Cells[row, 13] = sublance.C;
                            ExcelApp.Cells[row, 14] = sublance.Oxigen;
                            findSomeThing = true;
                        }
                    }

                    if (ignition != null)
                    {
                        IgnitionEvent ign = ignition.Find(p => p.Time.Date == curDate.Date && p.Time.Hour == curDate.Hour && p.Time.Minute == curDate.Minute
                                                               && p.Time.Second == curDate.Second);
                        if (ign != null)
                        {
                            ExcelApp.Cells[row, 29] = ign.FusionIgnition;
                            findSomeThing = true;
                        }
                    }

                    if (slagOutburst != null)
                    {
                        SlagOutburstEvent outburst = slagOutburst.Find(p => p.Time.Date == curDate.Date && p.Time.Hour == curDate.Hour && p.Time.Minute == curDate.Minute
                                                                            && p.Time.Second == curDate.Second);
                        if (outburst != null)
                        {
                            ExcelApp.Cells[row, 30] = outburst.Counter;
                            findSomeThing = true;
                        }
                    }

                    if (findSomeThing)
                    {
                        if (lanceInfo == null && lastLanceInfo != null)
                        {
                            ExcelApp.Cells[row, 2] = lastLanceInfo.Height;
                            ExcelApp.Cells[row, 3] = lastLanceInfo.O2Flow;
                        }

                        if (offgas == null && lastOffgas != null)
                        {
                            ExcelApp.Cells[row, 4] = lastOffgas.H2;
                            ExcelApp.Cells[row, 5] = lastOffgas.O2;
                            ExcelApp.Cells[row, 6] = lastOffgas.CO;
                            ExcelApp.Cells[row, 7] = lastOffgas.CO2;
                            ExcelApp.Cells[row, 8] = lastOffgas.N2;
                            ExcelApp.Cells[row, 9] = lastOffgas.Ar;
                        }
                        ExcelApp.Cells[row++, 1] = curDate;
                    }

                curDate = curDate.AddSeconds(1);
            }
            return true;
        }