Пример #1
0
 public void Init()
 {
     var mainConf = System.Configuration.ConfigurationManager.OpenExeConfiguration("");
     ConverterNumber = int.Parse(mainConf.AppSettings.Settings["ConverterNumber"].Value);
     _eventsHandler = new ConverterEventsHandler(this);
     Instance = this;
     APIType = typeof(API.ConverterAPI);
     _Heat = new Heat {AggregateNumber = ConverterNumber};
 }
 public Heat GetHeatInfo(string heatNumber)
 {
     var heat = new Heat();
     var sql = "SELECT H.HEAT_ID, H.HEAT_NO, H.RPT_TSOLL, H.RPT_TIST, H.RPT_CSOLL, H.RPT_CIST, ";
     sql += "to_char(h.DT_BEGIN,'dd.mm.yy HH24:mi:ss'),to_char(h.DT_END,'dd.mm.yy HH24:mi:ss'), ";
     sql += "H.TEAM_NAME, G.NAME_ENGLISH, H.CHGD_HMWEIGHT, H.HM_TEMP, H.CONVERTER_LIFE ";
     sql += "FROM SMK.HEATS H, SMK.GRADE_SPEC G WHERE H.HEAT_NO = '" + heatNumber + "' AND H.GRADE_ID = G.GRADE_ID";
     var reader = Execute(sql);
     if (reader.Read())
     {
         heat.ID = int.Parse(reader[0].ToString());
         heat.Number = int.Parse(reader[1].ToString());
         heat.Planned.Temperature = int.Parse(!string.IsNullOrEmpty(reader[2].ToString()) ? reader[2].ToString() : "0");
         heat.Actual.Temperature = int.Parse(!string.IsNullOrEmpty(reader[3].ToString()) ? reader[3].ToString() : "0");
         heat.Planned.Carbon = double.Parse(!string.IsNullOrEmpty(reader[4].ToString()) ? reader[4].ToString() : "0");
         heat.Actual.Carbon = double.Parse(!string.IsNullOrEmpty(reader[5].ToString()) ? reader[5].ToString() : "0");
         heat.StartDate = DateTime.Parse(reader[6].ToString());
         heat.EndDate = DateTime.Parse(!string.IsNullOrEmpty(reader[7].ToString()) ? reader[7].ToString() : "01.01.01");
         heat.TeamNumber = int.Parse(!string.IsNullOrEmpty(reader[8].ToString()) ? reader[8].ToString() : "0");
         heat.Grade = reader[9].ToString();
         heat.HotMetalAttributes.Weight = int.Parse(CheckNubmerForNull(reader[10].ToString()));
         heat.HotMetalAttributes.Temperature = int.Parse(CheckNubmerForNull(reader[11].ToString()));
         heat.AggregateLifeTime = int.Parse(CheckNubmerForNull(reader[12].ToString()));
         heat.AggregateNumber = int.Parse(heatNumber.Substring(0, 1));
     }
     reader.Close();
     return heat;
 }
 private void SaveToFile(Heat heat)
 {
     FileInfo file;
     var binaryFormatter = new BinaryFormatter();
     if (string.IsNullOrEmpty(TextBoxDownLoadPath.Text))
     {
         if (!Directory.Exists(Application.StartupPath + "\\dat"))
             Directory.CreateDirectory(Application.StartupPath + "\\dat");
         file = new FileInfo("dat\\" + heat.Number.ToString() + ".dat");
     }
     else
     {
         if (!Directory.Exists(TextBoxDownLoadPath.Text))
             Directory.CreateDirectory(TextBoxDownLoadPath.Text);
         file = new FileInfo(TextBoxDownLoadPath.Text + "\\" + heat.Number.ToString() + ".dat");
     }
     var fileStream = file.Create();
     binaryFormatter.Serialize(fileStream, heat);
     fileStream.Close();
 }
        public void LoadFusionFromFile(string fileName)
        {
            try
            {
                BinaryFormatter bf = new BinaryFormatter();
                FileInfo file = new FileInfo(fileName);
                FileStream fs = file.OpenRead();

                string heatNumber = file.Name.Replace(".dat", "");
                var deserializedObject = new object();
                try
                {
                    deserializedObject = bf.Deserialize(fs);
                }
                catch
                {
                }
                finally
                {
                    fs.Close();
                    fs.Dispose();
                }

                _heat = new Heat {Number = int.Parse(heatNumber)};
                if (deserializedObject is Heat)
                {
                    _heat = deserializedObject as Heat;
                }
                if (deserializedObject is Dictionary<DateTime, BaseEvent>)
                {
                    _heat.LanceHistory.Clear();
                    _heat.OffGasAnalysisHistory.Clear();
                    _heat.OffGasHistory.Clear();
                    _heat.BoilerWaterCoolingHistory.Clear();
                    _heat.IgnitionHistory.Clear();
                    _heat.SlagOutburstHistory.Clear();
                    Dictionary<DateTime, BaseEvent> events = deserializedObject as Dictionary<DateTime, BaseEvent>;
                    foreach (DateTime key in events.Keys)
                    {

                        switch (events[key].GetType().ToString())
                        {
                            case "Converter.LanceEvent":
                                _heat.LanceHistory.Add((LanceEvent)events[key]);
                                break;
                            case "Converter.OffGasAnalysisEvent":
                                _heat.OffGasAnalysisHistory.Add((OffGasAnalysisEvent)events[key]);
                                break;
                            case "Converter.OffGasEvent":
                                _heat.OffGasHistory.Add((OffGasEvent)events[key]);
                                break;
                            case "Converter.BoilerWaterCoolingEvent":
                                _heat.BoilerWaterCoolingHistory.Add((BoilerWaterCoolingEvent)events[key]);
                                break;
                            case "Converter.IgnitionEvent":
                                _heat.IgnitionHistory.Add((IgnitionEvent)events[key]);
                                break;
                            case "Converter.SlagOutburstEvent":
                                _heat.SlagOutburstHistory.Add((SlagOutburstEvent)events[key]);
                                break;
                        }
                    }
                }
                else if ((deserializedObject is List<BaseEvent>))
                {
                    _heat.LanceHistory.Clear();
                    _heat.OffGasAnalysisHistory.Clear();
                    _heat.OffGasHistory.Clear();
                    _heat.BoilerWaterCoolingHistory.Clear();
                    _heat.IgnitionHistory.Clear();
                    _heat.SlagOutburstHistory.Clear();
                    List<BaseEvent> events = deserializedObject as List<BaseEvent>;
                    foreach (BaseEvent e in events)
                    {

                        switch (e.GetType().ToString())
                        {
                            case "Converter.LanceEvent":
                                _heat.LanceHistory.Add((LanceEvent)e);
                                break;
                            case "Converter.OffGasAnalysisEvent":
                                _heat.OffGasAnalysisHistory.Add((OffGasAnalysisEvent)e);
                                break;
                            case "Converter.OffGasEvent":
                                _heat.OffGasHistory.Add((OffGasEvent)e);
                                break;
                            case "Converter.BoilerWaterCoolingEvent":
                                _heat.BoilerWaterCoolingHistory.Add((BoilerWaterCoolingEvent)e);
                                break;
                            case "Converter.IgnitionEvent":
                                _heat.IgnitionHistory.Add((IgnitionEvent)e);
                                break;
                            case "Converter.SlagOutburstEvent":
                                _heat.SlagOutburstHistory.Add((SlagOutburstEvent)e);
                                break;
                        }
                    }

                }

                CurrentFussion = m_Db.GetFusion(_heat.Number.ToString().Insert(2, "0"));
                CurrentListOfGas.Clear();

                //if (false)
                //{
                //    CurrentListOfGas.Clear();
                //    DateTime? lastEventTime = null;
                //    double ArSum = 0;
                //    double COSum = 0;
                //    double CO2Sum = 0;
                //    double N2Sum = 0;
                //    double H2Sum = 0;
                //    double O2Sum = 0;
                //    int counter = 0;
                //    foreach (OffGasAnalysisEvent ogaEvent in _heat.OffGasAnalysisHistory)
                //    {
                //        ArSum += ogaEvent.Ar;
                //        COSum += ogaEvent.CO;
                //        CO2Sum += ogaEvent.CO2;
                //        H2Sum += ogaEvent.H2;
                //        N2Sum += ogaEvent.N2;
                //        O2Sum += ogaEvent.O2;
                //        counter++;
                //        if (lastEventTime == null || lastEventTime.Value.AddSeconds(1) < key)
                //        {
                //            OffGas og = new OffGas();
                //            og.Ar = ArSum / counter;
                //            og.CO = COSum / counter;
                //            og.CO2 = CO2Sum / counter;
                //            og.H2 = H2Sum / counter;
                //            og.N2 = N2Sum / counter;
                //            og.O2 = O2Sum / counter;
                //            og.Date = key;
                //            foreach (DateTime offGasHistoryKey in _heat.OffGasHistory.Keys)
                //            {
                //                if (offGasHistoryKey.Hour == key.Hour &&
                //                   offGasHistoryKey.Minute == key.Minute &&
                //                   offGasHistoryKey.Second == key.Second)
                //                {
                //                    og.Temp = _heat.OffGasHistory[offGasHistoryKey].OffGasTemp;
                //                    og.Flow = (int)_heat.OffGasHistory[offGasHistoryKey].OffGasFlow;
                //                    break;
                //                }
                //            }
                //            if (og.Flow != 0)
                //            {
                //                CurrentListOfGas.Add(og);
                //            }
                //            lastEventTime = key;
                //            ArSum = 0;
                //            COSum = 0;
                //            CO2Sum = 0;
                //            N2Sum = 0;
                //            H2Sum = 0;
                //            O2Sum = 0;
                //            counter = 0;
                //        }
                //    }

                //    lastEventTime = null;
                //    CurrentListLance.Clear();
                //    # region Объявление переменных
                //    int HeightSum = 0;
                //    double O2FlowSum = 0;
                //    double O2PressureSum = 0;
                //    double O2VolSum = 0;
                //    double O2LeftLanceGewBaerSum = 0;
                //    double O2LeftLanceGewWeightSum = 0;
                //    int O2LeftLanceLeckSum = 0;
                //    double O2LeftLanceWaterInputSum = 0;
                //    double O2LeftLanceWaterOutputSum = 0;
                //    double O2LeftLanceWaterPressureSum = 0;
                //    double O2LeftLanceWaterTempInputSum = 0;
                //    double O2LeftLanceWaterTempOutputSum = 0;
                //    double O2RightLanceGewBaerSum = 0;
                //    double O2RightLanceGewWeightSum = 0;
                //    int O2RightLanceLeckSum = 0;
                //    double O2RightLanceWaterInputSum = 0;
                //    double O2RightLanceWaterOutputSum = 0;
                //    double O2RightLanceWaterPressureSum = 0;
                //    double O2RightLanceWaterTempInputSum = 0;
                //    double O2RightLanceWaterTempOutputSum = 0;
                //    #endregion

                //    counter = 0;
                //    foreach (LanceEvent lEvent in  _heat.LanceHistory)
                //    {
                //        # region Суммирование
                //        HeightSum += lEvent.LanceHeight;
                //        O2FlowSum += lEvent.O2Flow;
                //        O2PressureSum += lEvent.O2Pressure;
                //        O2VolSum += lEvent.O2TotalVol;
                //        O2LeftLanceGewBaerSum += lEvent.O2LeftLanceGewBaer;
                //        O2LeftLanceGewWeightSum += lEvent.O2LeftLanceGewWeight;
                //        O2LeftLanceLeckSum += lEvent.O2LeftLanceLeck;
                //        O2LeftLanceWaterInputSum += lEvent.O2LeftLanceWaterInput;
                //        O2LeftLanceWaterOutputSum += lEvent.O2LeftLanceWaterOutput;
                //        O2LeftLanceWaterPressureSum += lEvent.O2LeftLanceWaterPressure;
                //        O2LeftLanceWaterTempInputSum += lEvent.O2LeftLanceWaterTempInput;
                //        O2LeftLanceWaterTempOutputSum += lEvent.O2LeftLanceWaterTempOutput;
                //        O2RightLanceGewBaerSum += lEvent.O2RightLanceGewBaer;
                //        O2RightLanceGewWeightSum += lEvent.O2RightLanceGewWeight;
                //        O2RightLanceLeckSum += lEvent.O2RightLanceLeck;
                //        O2RightLanceWaterInputSum += lEvent.O2RightLanceWaterInput;
                //        O2RightLanceWaterOutputSum += lEvent.O2RightLanceWaterOutput;
                //        O2RightLanceWaterPressureSum += lEvent.O2RightLanceWaterPressure;
                //        O2RightLanceWaterTempInputSum += lEvent.O2RightLanceWaterTempInput;
                //        O2RightLanceWaterTempOutputSum += lEvent.O2RightLanceWaterTempOutput;
                //        # endregion

                //        counter++;
                //        if (lastEventTime == null || lastEventTime.Value.AddSeconds(1) < key)
                //        {
                //            #region Создание объекта lance
                //            Lance lance = new Lance();
                //            lance.Date = key;
                //            lance.Height = HeightSum / counter;
                //            lance.O2Flow = O2FlowSum / counter;
                //            lance.O2Pressure = O2PressureSum / counter;
                //            lance.O2Vol = O2VolSum / counter;
                //            //lance.O2FlowMode = _heat.LanceHistory[key].O2FlowMode;
                //            lance.O2LeftLanceGewBaer = O2LeftLanceGewBaerSum / counter;
                //            lance.O2LeftLanceGewWeight = O2LeftLanceGewWeightSum / counter;
                //            lance.O2LeftLanceLeck = O2LeftLanceLeckSum / counter;
                //            lance.O2LeftLanceWaterInput = O2LeftLanceWaterInputSum / counter;
                //            lance.O2LeftLanceWaterOutput = O2LeftLanceWaterOutputSum / counter;
                //            lance.O2LeftLanceWaterPressure = O2LeftLanceWaterPressureSum / counter;
                //            lance.O2LeftLanceWaterTempInput = O2LeftLanceWaterTempInputSum / counter;
                //            lance.O2LeftLanceWaterTempOutput = O2LeftLanceWaterTempOutputSum / counter;
                //            lance.O2RightLanceGewBaer = O2RightLanceGewBaerSum / counter;
                //            lance.O2RightLanceGewWeight = O2RightLanceGewWeightSum / counter;
                //            lance.O2RightLanceLeck = O2RightLanceLeckSum / counter;
                //            lance.O2RightLanceWaterInput = O2RightLanceWaterInputSum / counter;
                //            lance.O2RightLanceWaterOutput = O2RightLanceWaterOutputSum / counter;
                //            lance.O2RightLanceWaterPressure = O2RightLanceWaterPressureSum / counter;
                //            lance.O2RightLanceWaterTempInput = O2RightLanceWaterTempInputSum / counter;
                //            lance.O2RightLanceWaterTempOutput = O2RightLanceWaterTempOutputSum / counter;
                //            #endregion
                //            //_heat.LanceHistory[key].O2LeftLanceWaterInput
                //            CurrentListLance.Add(lance);
                //            BathLevel bathLevel = new BathLevel();
                //            bathLevel.Date = key;
                //            bathLevel.Value = _heat.LanceHistory[key].BathLevel;
                //            CurrentListBathLevel.Add(bathLevel);
                //            lastEventTime = key;

                //            #region Обнуление суммарных значений и счетчика
                //            HeightSum = 0;
                //            O2FlowSum = 0;
                //            O2PressureSum = 0;
                //            O2VolSum = 0;
                //            O2LeftLanceGewBaerSum = 0;
                //            O2LeftLanceGewWeightSum = 0;
                //            O2LeftLanceLeckSum = 0;
                //            O2LeftLanceWaterInputSum = 0;
                //            O2LeftLanceWaterOutputSum = 0;
                //            O2LeftLanceWaterPressureSum = 0;
                //            O2LeftLanceWaterTempInputSum = 0;
                //            O2LeftLanceWaterTempOutputSum = 0;
                //            O2RightLanceGewBaerSum = 0;
                //            O2RightLanceGewWeightSum = 0;
                //            O2RightLanceLeckSum = 0;
                //            O2RightLanceWaterInputSum = 0;
                //            O2RightLanceWaterOutputSum = 0;
                //            O2RightLanceWaterPressureSum = 0;
                //            O2RightLanceWaterTempInputSum = 0;
                //            O2RightLanceWaterTempOutputSum = 0;
                //            counter = 0;
                //            #endregion
                //        }
                //    }
                //}
                //else
                {
                    DateTime first = _heat.OffGasAnalysisHistory.First().Time;
                    DateTime last = _heat.OffGasAnalysisHistory.Last().Time;

                    DateTime current = first.AddMilliseconds(-first.Millisecond).AddSeconds(-first.Second);
                    OffGas og = new OffGas();

                    SummaryIgnition = _heat.IgnitionHistory;
                    SummarySlagOutburst = _heat.SlagOutburstHistory;

                    foreach (OffGasAnalysisEvent ogaEvent in _heat.OffGasAnalysisHistory)
                    {
                        og = new OffGas();
                        og.Ar = ogaEvent.Ar;
                        og.CO = ogaEvent.CO;
                        og.CO2 = ogaEvent.CO2;
                        og.H2 = ogaEvent.H2;
                        og.N2 = ogaEvent.N2;
                        og.O2 = ogaEvent.O2;
                        og.Date = ogaEvent.Time;
                        ListOfAllGas.Add(og);
                    }

                    for (int i = 1; i < (last - first).TotalMinutes * 4; i++)
                    {
                        og.Date = current.AddSeconds(7);
                        var gasArray = _heat.OffGasAnalysisHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                        if (gasArray.Length > 0)
                        {
                            og = new OffGas();
                            og.Ar = gasArray.Average(x => x.Ar);
                            og.CO = gasArray.Average(x => x.CO);
                            og.CO2 = gasArray.Average(x => x.CO2);
                            og.H2 = gasArray.Average(x => x.H2);
                            og.N2 = gasArray.Average(x => x.N2);
                            og.O2 = gasArray.Average(x => x.O2);
                            var gasFlowAndTempArray = _heat.OffGasHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                            if (gasFlowAndTempArray.Length > 0)
                            {
                                og.Temperature = (int)gasFlowAndTempArray.Average(x => x.OffGasTemp);
                                og.Flow = (int)gasFlowAndTempArray.Average(x => x.OffGasFlow);
                            }
                            var gasTempsArray = _heat.BoilerWaterCoolingHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                            if (gasTempsArray.Length > 0)
                            {
                                og.TemperatureOnExit = gasTempsArray.Average(x => x.GasTemperatureOnExit);
                                og.PrecollingTemperature = gasTempsArray.Average(x => x.PrecollingGasTemperature);
                                og.TemperatureAfter1Step = gasTempsArray.Average(x => x.GasTemperatureAfter1Step);
                                og.TemperatureAfter2Step = gasTempsArray.Average(x => x.GasTemperatureAfter2Step);
                            }
                        }
                        if (og.Flow != 0)
                        {
                            CurrentListOfGas.Add(og);
                        }
                        current = current.AddSeconds(15);
                    }

                    CurrentListLance.Clear();
                    CurrentListOfGas.Remove(CurrentListOfGas.Last());
                    current = CurrentListOfGas.First().Date.AddMilliseconds(-CurrentListOfGas.First().Date.Millisecond).AddSeconds(-CurrentListOfGas.First().Date.Second);
                    Lance lance = new Lance();
                    for (int i = 1; i < (CurrentListOfGas.Last().Date - CurrentListOfGas.First().Date).TotalMinutes * 4; i++)
                    {
                        current = current.AddSeconds(15);
                        var LanceEventArray = _heat.LanceHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                        if (LanceEventArray.Length > 0)
                        {
                            lance = new Lance();
                            lance.Date = current.AddSeconds(7);
                            lance.Height = (int)LanceEventArray.Average(x => x.LanceHeight);
                            lance.O2Flow = LanceEventArray.Average(x => x.O2Flow);
                            lance.O2Pressure = LanceEventArray.Average(x => x.O2Pressure);
                            lance.O2Vol = LanceEventArray.Average(x => x.O2TotalVol);
                            lance.O2LeftLanceGewBaer = LanceEventArray.Average(x => x.O2LeftLanceGewBaer);
                            lance.O2LeftLanceGewWeight = LanceEventArray.Average(x => x.O2LeftLanceGewWeight);
                            lance.O2LeftLanceLeck = LanceEventArray.Average(x => x.O2LeftLanceLeck);
                            lance.O2LeftLanceWaterInput = LanceEventArray.Average(x => x.O2LeftLanceWaterInput);
                            lance.O2LeftLanceWaterOutput = LanceEventArray.Average(x => x.O2LeftLanceWaterOutput);
                            lance.O2LeftLanceWaterPressure = LanceEventArray.Average(x => x.O2LeftLanceWaterPressure);
                            lance.O2LeftLanceWaterTempInput = LanceEventArray.Average(x => x.O2LeftLanceWaterTempInput);
                            lance.O2LeftLanceWaterTempOutput = LanceEventArray.Average(x => x.O2LeftLanceWaterTempOutput);
                            lance.O2RightLanceGewBaer = LanceEventArray.Average(x => x.O2RightLanceGewBaer);
                            lance.O2RightLanceGewWeight = LanceEventArray.Average(x => x.O2RightLanceGewWeight);
                            lance.O2RightLanceLeck = LanceEventArray.Average(x => x.O2RightLanceLeck);
                            lance.O2RightLanceWaterInput = LanceEventArray.Average(x => x.O2RightLanceWaterInput);
                            lance.O2RightLanceWaterOutput = LanceEventArray.Average(x => x.O2RightLanceWaterOutput);
                            lance.O2RightLanceWaterPressure = LanceEventArray.Average(x => x.O2RightLanceWaterPressure);
                            lance.O2RightLanceWaterTempInput = LanceEventArray.Average(x => x.O2RightLanceWaterTempInput);
                            lance.O2RightLanceWaterTempOutput = LanceEventArray.Average(x => x.O2RightLanceWaterTempOutput);
                            if (CurrentListBathLevel.Count == 0)
                            {
                                BathLevel level = new BathLevel();
                                level.Value = (int)LanceEventArray.Average(x => x.BathLevel);
                                CurrentListBathLevel.Add(level);
                            }
                        }
                        if (lance.O2Flow > 0)
                        {
                            CurrentListLance.Add(lance);
                        }
                    }
                }
            }
            catch (Exception) { }
            CurrentListAddition.Clear();
            UpdateFusion();
        }
 private void GetHeatDataFromDB()
 {
     Heat heat;
     for (var i = 0; i < _listSelectedHeats.Count; i++)
     {
         var lances = new List<LanceEvent>();
         var offgasanalysys = new List<OffGasAnalysisEvent>();
         var offgases = new List<OffGasEvent>();
         var outburst = new List<SlagOutburstEvent>();
         var boilerWaterCooling = new List<BoilerWaterCoolingEvent>();
         var ignition = new List<IgnitionEvent>();
         var heatNumber = _listSelectedHeats[i].HeatNumber;
         var start = _listSelectedHeats[i].Time;
         var end = i < _listSelectedHeats.Count - 1 ? _listSelectedHeats[i + 1].Time : start.AddHours(3);
         heat = new Heat();
         var unitNumber = int.Parse(_listSelectedHeats[i].HeatNumber.ToString()[0].ToString());
         if ((unitNumber == 1 || unitNumber == 2 || unitNumber == 3) && !File.Exists(TextBoxDownLoadPath.Text + "\\" + heatNumber.ToString() + ".dat"))
         {
             try
             {
                 Invoke((Action) delegate
                                     {
                                         toolStripProgressBar1.Value = 30;
                                         toolStripStatusLabel1.Text =
                                             string.Format(
                                                 " Подгружаем данные по событию: SlagOutburstEvent. Всего загружено:{0}",
                                                 heat.SlagOutburstHistory.Count);
                                     });
                 outburst.AddRange((Trends.GetEvents<SlagOutburstEvent>(unitNumber, start, end)));
             }
             catch
             {
             }
             try
             {
                 Invoke((Action) delegate
                                     {
                                         toolStripProgressBar1.Value = 30;
                                         toolStripStatusLabel1.Text =
                                             string.Format(
                                                 " Подгружаем данные по событию: IgnitionEvent. Всего загружено:{0}",
                                                 heat.IgnitionHistory.Count);
                                     });
                 ignition.AddRange((Trends.GetEvents<IgnitionEvent>(unitNumber, start, end)));
             }
             catch
             {
             }
             try
             {
                 Invoke((Action) delegate
                                     {
                                         toolStripProgressBar1.Value = 30;
                                         toolStripStatusLabel1.Text =
                                             string.Format(
                                                 " Подгружаем данные по событию: BoilerWaterCoolingEvent. Всего загружено:{0}",
                                                 heat.BoilerWaterCoolingHistory.Count);
                                     });
                 boilerWaterCooling.AddRange((Trends.GetEvents<BoilerWaterCoolingEvent>(unitNumber, start, end)));
             }
             catch
             {
             }
             try
             {
                 Invoke((Action) delegate
                                     {
                                         toolStripProgressBar1.Value = 30;
                                         toolStripStatusLabel1.Text =
                                             string.Format(
                                                 " Подгружаем данные по событию: LanceEvent. Всего загружено:{0}",
                                                 heat.LanceHistory.Count);
                                     });
                 lances.AddRange((Trends.GetEvents<LanceEvent>(unitNumber, start, end)));
             }
             catch
             {
             }
             try
             {
                 Invoke((Action) delegate
                                     {
                                         toolStripProgressBar1.Value = 60;
                                         toolStripStatusLabel1.Text =
                                             string.Format(
                                                 " Подгружаем данные по событию: OffGasAnalysisEvent. Всего загружено:{0}",
                                                 heat.LanceHistory.Count);
                                     });
                 offgasanalysys.AddRange(Trends.GetEvents<OffGasAnalysisEvent>(unitNumber, start, end));
             }
             catch
             {
             }
             try
             {
                 Invoke((Action) delegate
                                     {
                                         toolStripProgressBar1.Value = 90;
                                         toolStripStatusLabel1.Text =
                                             string.Format(
                                                 " Подгружаем данные по событию: OffGasEvent. Всего загружено:{0}",
                                                 heat.LanceHistory.Count + heat.OffGasAnalysisHistory.Count);
                                     });
                 offgases.AddRange(Trends.GetEvents<OffGasEvent>(unitNumber, start, end));
                 Invoke((Action) delegate
                                     {
                                         toolStripProgressBar1.Value = 100;
                                         toolStripStatusLabel1.Text = string.Format("Всего загружено:{0}",
                                                                                    heat.LanceHistory.Count +
                                                                                    heat.OffGasAnalysisHistory.
                                                                                        Count +
                                                                                    heat.OffGasHistory.Count);
                                     });
             }
             catch
             {
             }
             Invoke((Action) delegate
                                 {
                                     _db.Reconnect("SMK", "smk");
                                     heat = _db.GetHeatInfo(heatNumber.ToString().Insert(2, "0"));
                                     if (heat.ID != 0)
                                     {
                                         toolStripStatusLabel1.Text = "Получаем данные по чугуну...";
                                         heat.HotMetalAttributes = _db.GetHotMetalAttributes(heat.ID);
                                         toolStripStatusLabel1.Text = "Получаем данные по добавочным...";
                                         toolStripProgressBar1.Value = 15;
                                         heat.Additions = _db.GetAdditions(heat.ID);
                                         toolStripStatusLabel1.Text = "Получаем данные по скрапу...";
                                         toolStripProgressBar1.Value = 25;
                                         heat.ScrapBuckets = _db.GetScrapBuckets(heat.ID);
                                         toolStripStatusLabel1.Text =
                                             "Получаем данные по измерительному зонду...";
                                         toolStripProgressBar1.Value = 35;
                                         heat.Sublances = _db.GetSublance(heat.ID);
                                         _db.Reconnect("XIM", "xim");
                                         toolStripStatusLabel1.Text = "Получаем данные по анализу шлака...";
                                         toolStripProgressBar1.Value = 50;
                                         heat.SlagAnalysys = _db.GetSlagAnalysys(heat.Number);
                                         toolStripStatusLabel1.Text = "Получаем данные по анализу стали...";
                                         toolStripProgressBar1.Value = 70;
                                         heat.SteelAnalysys = _db.GetSteelAnalysys(heat.Number);
                                         toolStripStatusLabel1.Text = "Получаем данные по анализу чугуна...";
                                         toolStripProgressBar1.Value = 90;
                                         heat.HotMetalAnalysyses = _db.GetHotMetalAnalysys(heat.Number);
                                         toolStripProgressBar1.Value = 100;
                                         toolStripStatusLabel1.Text = "Сохранение в файл...";
                                         heat.LanceHistory = lances;
                                         heat.OffGasHistory = offgases;
                                         heat.OffGasAnalysisHistory = offgasanalysys;
                                         heat.IgnitionHistory = ignition;
                                         heat.BoilerWaterCoolingHistory = boilerWaterCooling;
                                         heat.SlagOutburstHistory = outburst;
                                         heat.Number = heatNumber;
                                         SaveToFile(heat);
                                     }
                                     _db.Reconnect("EVENTS", "events");
                                 });
         }
         Invoke((Action)(() =>
         {
             var it = CheckedListBoxHeatNumber.FindString(heatNumber.ToString());
             CheckedListBoxHeatNumber.SetItemCheckState(it, CheckState.Unchecked);
         }));
     }
     Invoke((Action)delegate
     {
         toolStripProgressBar1.Value = 0;
         toolStripStatusLabel1.Text = "Готово";
         GroupBoxLoad.Enabled = true;
         ButtonDownLoad.Enabled = true;
     });
 }