Пример #1
0
        public void TestMethod1()
        {
            ac = new ArchiveControl();
            MainWindow.ac_m = ac;
            wnt = new Write_NewTube();
            cc = new CollectClass();

            ac._countLastIndex = wnt.lastIndex_defectsdata();
            for (int i = 0; i < 50; i++)
            {
                cc.Cyears(_countYears);
                cc.Cdyears(_countDefectsYears);
                cc.Cmonths(_countMonths);
                cc.Cdmonths(_countDefectsMonths);
                cc.Cdays(_countDays);
                cc.Cddays(_countDefectsDays);
                cc.Csmens(_countSmens);
                cc.Cdsmens(_countDefectsSmens);
                cc.Cparts(_countParts);
                cc.cdparts(_countDefectsParts);
            }
        }
Пример #2
0
        //=======================================

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            //var worker = sender as BackgroundWorker;
            CollectClass collectClass = new CollectClass();

            _countsLoaded = false;
            _countLastIndex = 0;

            _countYears.Clear();
            _countDefectsYears.Clear();
            _countMonths.Clear();
            _countDefectsMonths.Clear();
            _countDays.Clear();
            _countDefectsDays.Clear();
            _countSmens.Clear();
            _countDefectsSmens.Clear();
            _countParts.Clear();
            _countDefectsParts.Clear();

            Connection connection = null;
            MySqlCommand myCommand = null;
            MySqlDataReader dataReader = null;

            try
            {
                Console.WriteLine("Begin load Statistic " + DateTime.Now.ToString());
                #region last index
                try
                {
                    connection = new Connection();
                    connection.Open();
                }
                catch
                { throw (new Exception("Open Error")); }

                try
                {
                    myCommand = new MySqlCommand(@"
SELECT IndexData
FROM defectsdata
ORDER BY IndexData DESC
LIMIT 1", connection.mySqlConnection);
                }
                catch
                { throw (new Exception("Open Error")); }

                try
                {
                    dataReader = (MySqlDataReader)myCommand.ExecuteReader();
                    dataReader.Read();
                    _countLastIndex = dataReader.GetInt64(0);
                }
                catch
                { throw (new Exception("Read Error")); }

                try
                {
                    dataReader.Close();
                    connection.Close();
                }
                catch
                { throw (new Exception("Close Error")); }
                #endregion

                collectClass.Cyears(_countYears);
                collectClass.Cdyears(_countDefectsYears);
                collectClass.Cmonths(_countMonths);
                collectClass.Cdmonths(_countDefectsMonths);
                collectClass.Cdays(_countDays);
                collectClass.Cddays(_countDefectsDays);
                collectClass.Csmens(_countSmens);
                collectClass.Cdsmens(_countDefectsSmens);
                collectClass.Cparts(_countParts);
                collectClass.cdparts(_countDefectsParts);
                Console.WriteLine("End load Statistic " + DateTime.Now.ToString());
            }
            catch (Exception ex)
            {
                /*Console.WriteLine("========================================");
                Console.WriteLine("ArchiveControl.cs");
                Console.WriteLine("backgroundWorker1_DoWork()  :  " + DateTime.Now.ToString());
                Console.WriteLine(ex.Message);*/
                MessageBox.Show("Ошибка загрузки статистики");
                if (MainWindow.mainWindow.myThrArchive != null)
                {
                    archiveWindow.buttonReload.IsEnabled = true;
                }
            }
        }