예제 #1
0
        public void Stop()
        {
            try
            {
                //TODO Закрытие таймеров
                TTimer100ms.Dispose();
                TTimerMessage.Dispose();
                TTimerSQL.Dispose();
                TTimer1s.Dispose();


                int result = stan.UnloadConnection(0);

                if (result == 0)
                {
                    //LogSystem.WriteEventLog("ProDaveStan", "Test", "Close connection", EventLogEntryType.Information);
                }
                else
                {
                    LogSystem.Write("StanStop", Direction.ERROR, "Connect open. Warning - " + stan.Error(result));
                }

                //TODO добавить закрытие сетевого соединения
            }
            catch (Exception ex)
            {
                LogSystem.Write("StanStop", Direction.WARNING, "Ошибка при остановке. " + ex.Message);
            }
        }
예제 #2
0
    private void Connect100ms()
    {
        try
        {
            //short[] buffer_array = new short[158];

            DateTime dt100ms;

            //Console.WriteLine("-"+DateTime.Now.ToString("HH:mm:ss.fff"));



            //var buffer2 = new ushort[128];
            int Byte_Col_r = 0;

            //buffer = null;
            int resultReadField = stan.field_read('M', 0, startBuffer, amount, out buffer, out Byte_Col_r);
            if (resultReadField == 0)
            {
                dt100ms = DateTime.Now;

                Thread PLS100ms = new Thread(BufferToBuffer);
                PLS100ms.Start();
            }
            else
            {
                LogSystem.Write(name + " 100ms", Direction.ERROR, "Error.Read fied PLC. " + stan.Error(resultReadField), mc100CurX, mc100CurY, true);
            }
        }
        catch (Exception ex)
        {
            LogSystem.Write(name + " 100ms", Direction.ERROR, "ИСТОЧНИК: " + ex.Source.ToString() + ".  ОШИБКА: " + ex.Message.ToString(), mc100CurX, mc100CurY, true);
        }
    }
예제 #3
0
        private void Connect100ms()
        {
            try
            {
                //short[] buffer_array = new short[158];

                DateTime dt100ms;



                //var buffer2 = new ushort[128];
                int Byte_Col_r = 0;

                int resultReadField = stan.field_read('M', 0, startBuffer, amount, out buffer, out Byte_Col_r);
                if (resultReadField == 0)
                {
                    dt100ms = DateTime.Now;

                    Thread PLS100ms = new Thread(BufferToBuffer);
                    PLS100ms.Start();
                }
                else
                {
                    LogSystem.Write("100ms", Direction.ERROR, "Error.Read fied M3000-M3315. " + stan.Error(resultReadField));
                }
            }
            catch (Exception ex)
            {
                LogSystem.Write("100ms", Direction.ERROR, "ИСТОЧНИК: " + ex.Source.ToString() + ".  ОШИБКА: " + ex.Message.ToString());
            }
        }
예제 #4
0
    public void Start()
    {
        //Метод производит подключение к котроллеру и устанавливает связь
        //Если соединение успешно то вызывает поток-таймеры. и внутри них выполнение действия по таймеру.

        try
        {
            buffer    = new byte[amount];
            bufferPLC = new byte[amount];
            bufferSQL = new byte[amount];


            //запуск таймеров 100ms(100ms), 101ms(SQL), 200ms(message), 1000ms(1s)
            stan = new Prodave();

            int res = stan.LoadConnection(Connect, 2, conn, slot, rack);

            if (res != 0)
            {
                LogSystem.Write(name + " start", Direction.ERROR, "Error connection!. Error - " + stan.Error(res), ConnectCurX, ConnectCurY, true);
            }
            else
            {
                //LogSystem.Write(name+" start", Direction.Ok, "Connect OK!", ConnectCurY, ConnectCurY, true);

                int resSAC = stan.SetActiveConnection(Connect);
                if (resSAC == 0)
                {
                    LogSystem.Write(name + " start", Direction.Ok, "Соединение активно.", ConnectCurY, ConnectCurY, true);

                    CreateTable(); //В случае успешного подключения к контроллеру формируем таблицу для формирования данных и последующего сохранения в БД

                    TTimer100ms = new Timer(new TimerCallback(TicTimer100ms), null, 0, 100);

                    if (plctodbmessage)
                    {
                        TTimerMessage = new Timer(new TimerCallback(TicTimerMessage), null, 0, 200);
                    }
                    if (plctodb101ms)
                    {
                        TTimerSQL = new Timer(new TimerCallback(TicTimerSQL), null, 0, 101);
                    }
                    if (plctodb1s)
                    {
                        TTimer1s = new Timer(new TimerCallback(TicTimer1s), null, 0, 1000);
                    }
                }
                else
                {
                    LogSystem.Write(name + " start", Direction.WARNING, "Соединение не активировано. " + stan.Error(resSAC), ConnectCurY, ConnectCurY, true);
                }
            }
        }
        catch (Exception ex)
        {
            /*все исключения кидаем в пустоту*/
            LogSystem.Write(name + " start-" + ex.Source, Direction.ERROR, "Start Error-" + ex.Message, ConnectCurY, ConnectCurY, true);
        }
    }
예제 #5
0
        public static void RemovePopupChat(IWebDriver driver)
        {
            IJavaScriptExecutor js = (IJavaScriptExecutor)driver;

            try {
                Thread.Sleep(300);
                js.ExecuteScript("const elements = document.getElementsByClassName('zopim'); while (elements.length > 0) elements[0].remove(); window.$zopim.livechat.window.hide(); return true;");
            } catch (System.Exception ex) {
                LogSystem.Write($"ReadRecaptcha: {ex.Message}");
            }
        }
예제 #6
0
 private void TicTimerMessage(object state)
 {
     try
     {
         //Console.WriteLine(string.Format("\t\t {0} ({1}) {2}", "Message", DateTime.Now - dtMessage, Thread.CurrentThread.ManagedThreadId));
         //dtMessage = DateTime.Now;
     }
     catch (Exception ex)
     {
         LogSystem.Write("Stan(Message)-" + ex.Source, Direction.ERROR, "Stan(Vtssage) Error-" + ex.Message);
     }
 }
예제 #7
0
 private void TicTimer1s(object state)
 {
     try
     {
         //Console.WriteLine(string.Format("\t\t {0} ({1}) {2}", "1c", DateTime.Now - dt1s, Thread.CurrentThread.ManagedThreadId));
         //dt1s = DateTime.Now;
     }
     catch (Exception ex)
     {
         LogSystem.Write(name + " stan(1s)-" + ex.Source, Direction.ERROR, "Stan(1s) Error-" + ex.Message, mc1000CurX, mc1000CurY, true);
     }
 }
예제 #8
0
        public static void LoadSettings()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Environment.CurrentDirectory)
                          .AddJsonFile($"appsettings.{Variables.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Variables.Configuration = builder.Build();
            var appSettings = Variables.Configuration.GetSection("AppSettings");

            Variables.SELENIUM_PATH_UPLOADS     = appSettings["SELENIUM_PATH_UPLOADS"] ?? "C:\\Images";
            Variables.SELENIUM_MAX_RAND_UPLOADS = int.Parse(appSettings["SELENIUM_MAX_RAND_UPLOADS"] ?? "3");
            Variables.SELENIUM_USER_ROOT        = appSettings["SELENIUM_USER_ROOT"] ?? "*****@*****.**";
            Variables.SELENIUM_PASSWORD_ROOT    = appSettings["SELENIUM_PASSWORD_ROOT"] ?? "@iI321321";

            LogSystem.Write($"AppSettings: ${JsonConvert.SerializeObject(Variables.Configuration.GetSection("AppSettings"))}");
        }
예제 #9
0
        private void TicTimerSQL(object state)
        {
            //??????вопрос с dispatcher????????
            string numberTable;

            try
            {
                //Console.WriteLine(string.Format("\t\t {0} ({1}) {2}", "SQL 101mc", DateTime.Now - dtSQL, Thread.CurrentThread.ManagedThreadId));
                dtSQL = DateTime.Now;


                //Из критичной секции получаем значения из PLC
                Thread tSQL = new Thread(BufferSQLToBufferPLC);
                tSQL.Start();


                if (bufferSQL == null)
                {
                    Console.WriteLine("Кол-во элементтов - 0 ");
                }
                else
                {
                    if (blRulonSaveData101ms)
                    {
                        //Формируем строку для таблицы и ее записываем при условии что начата прокатка рулона
                        DataRow dr101ms = dt101ms.NewRow();
                        dr101ms["dtStan"] = DateTime.Now;

                        foreach (var item in dic101ms)
                        {
                            if (item.Value.floatdata)
                            {
                                //Console.WriteLine(item.Key + " = " + item.Value.startbit + " - " + item.Value.coefficient);
                                float a = (float)(BitConverter.ToInt16(bufferSQL, item.Value.startbit)) / item.Value.coefficient;
                                //Console.WriteLine(a);
                                dr101ms[item.Key] = a;
                            }
                            else
                            {
                                //Console.WriteLine(item.Key + " = " + item.Value.startbit + " - " + item.Value.coefficient);
                                dr101ms[item.Key] = (BitConverter.ToInt16(bufferSQL, item.Value.startbit)) / item.Value.coefficient;
                            }
                        }

                        dt101ms.Rows.Add(dr101ms);
                        //   Console.WriteLine(" Кол-во строк в таблице=" +  dt101ms.Rows.Count);
                    }



                    //Console.WriteLine("В массиве строчек "+dt101ms.Rows.Count);

                    if (PasportRulona)
                    {
                        D_tek_mot = (float)(BitConverter.ToInt16(bufferSQL, 20)) / 1000;

                        h5w = (float)(BitConverter.ToInt16(bufferSQL, 12)) / 1000;

                        speed4kl = (float)(BitConverter.ToInt16(bufferSQL, 6)) / 100;

                        Bw = BitConverter.ToInt16(bufferSQL, 14);

                        #region Формирование признака окончания прокатки рулона
                        if (D_tek_mot > D_pred_mot)
                        {
                            if (D_tek_mot < 0.615)
                            {
                                Time_Start           = DateTime.Now;
                                blRulonSaveData101ms = true; //включаем сбор данных по прокатке рулона
                            }
                        }

                        //Console.WriteLine("Time_Start=" + Time_Start + "  H5_work=" + H5_work + "  D_tek_mot=" + D_tek_mot + "  D_pred_mot=" + D_pred_mot + " speed4kl=" + speed4kl);
                        if ((Time_Start != new DateTime()) && (H5_work == 0) && (D_tek_mot > 0.7) && (speed4kl > 2))
                        {
                            H5_work = h5w;
                            B_Work  = Bw;
                        }

                        #endregion

                        #region Окончание прокатки рулона
                        //Console.WriteLine("Time_Start="+ Time_Start+ "  H5_work="+ H5_work+ "  D_tek_mot=" + D_tek_mot+ "  D_pred_mot=" + D_pred_mot);
                        if ((Time_Start != new DateTime()) && (H5_work != 0) && (D_tek_mot < 0.610) && (D_tek_mot < D_pred_mot))
                        {
                            #region  Формируем шифр таблицы (yyyyMMddсмена)

                            if (Convert.ToInt32(DateTime.Now.ToString("HH")) >= 7 && Convert.ToInt32(DateTime.Now.ToString("HH")) < 19)
                            {
                                numberTable = DateTime.Now.ToString("yyyyMMdd") + "2";
                            }
                            else if (Convert.ToInt32(DateTime.Now.ToString("HH")) < 7)
                            {
                                numberTable = DateTime.Now.ToString("yyyyMMdd") + "1";
                            }
                            else if (Convert.ToInt32(DateTime.Now.ToString("HH")) >= 19)
                            {
                                numberTable = DateTime.Now.AddDays(1).ToString("yyyyMMdd") + "1";
                            }
                            #endregion

                            //Time_Stop = DateTime.Now;
                            Console.BackgroundColor = ConsoleColor.Blue;
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine("Время начала записи SQL=" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));

                            Ves_Work  = (((((D_pred_mot * D_pred_mot) - 0.36F) * 3.141593F) / 4) * (B_Work / 1000)) * 7.85F;
                            Time_Stop = DateTime.Now;

                            Dlina_Work = ((Ves_Work / 7.85F) / (B_Work / 1000)) / (H5_work / 1000);

                            //Ellipse101ms.Fill = onOK;

                            #region Формируем данные для передачи в Базу Данных

                            //yyyy - MM - dd HH: mm: ss.fff
                            string strTimeStart = Time_Start.ToString("yyyy-MM-dd HH:mm:ss.fff");
                            string strTimeStop  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

                            TimeSpan tp    = Time_Stop.Subtract(Time_Start);
                            double   dbltp = tp.TotalMilliseconds;
                            Console.BackgroundColor = ConsoleColor.Blue;
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine("Время сбора информации (ms):" + dbltp.ToString());
                            Console.WriteLine("Кол-во строк полученных в системе:" + dt101ms.Rows.Count.ToString());
                            Console.WriteLine("Среднее время цикла обновления данных:" + (dbltp / (dt101ms.Rows.Count)).ToString());
                            Console.ResetColor();


                            string strNumberRulon = DateTime.Now.ToString("yyyyMMdd") + Time_Start.ToString("HHmm") + DateTime.Now.ToString("HHmm");
                            #endregion


                            //TODO после записи удаляем таблицу и заново создаем
                            dt101ms.Clear();
                            Console.WriteLine("Очистка таблицы");

                            //CreateTable();
                            Console.WriteLine("Кол-во строк в таблице после очистки - " + dt101ms.Rows.Count.ToString());
                        }

                        D_pred_mot = D_tek_mot;
                        #endregion
                    }
                }
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("ytne");
            }
            catch (Exception ex)
            {
                LogSystem.Write("Stan(101ms)-" + ex.Source, Direction.ERROR, "Stan(101ms) Error-" + ex.Message);
            }
        }
예제 #10
0
        /// <summary>
        /// SelectLi: chọn combobox thẻ li
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="idDrop"></param>
        /// <param name="value"></param>
        public static void SelectLi(IWebDriver driver, string idDrop, object value, string text = null)
        {
            string idListDrop = idDrop + "Options";
            var    eleDrop    = driver.FindElement(By.Id(idDrop));

            eleDrop.Click();
            var     listDrop = driver.FindElement(By.Id(idListDrop));
            var     listLi   = listDrop.FindElements(By.TagName("li"));
            dynamic el       = null;

            try {
                if (value != null && ((value.GetType() == typeof(string) && !string.IsNullOrEmpty((string)value)) || (value.GetType() == typeof(int) && (int)value > 0)))
                {
                    el = listLi.FirstOrDefault(item => {
                        var vl = item.GetAttribute("vl");
                        return(vl == Convert.ToString(value));
                    });
                }
                else
                {
                    text = text.ToLower();
                    el   = listLi.FirstOrDefault(item => {
                        var itext = item.Text.ToLower();
                        return(itext == text);
                    });
                    if (el == null)
                    {
                        var ntext = text.Replace("tỉnh", "")
                                    .Replace("thành phố ", "")
                                    .Replace("tp.", "")
                                    .Replace("quận ", "")
                                    .Replace("huyện ", "")
                                    .Replace("phường ", "")
                                    .Replace("xã ", "").Trim();

                        el = listLi.FirstOrDefault(item => {
                            var itext = item.Text.ToLower().Trim();
                            return(itext == ntext);
                        });
                        if (el == null)
                        {
                            el = listLi.FirstOrDefault(item => {
                                var itext = item.Text.ToLower().Trim();
                                return(itext.IndexOf(ntext) >= 0);
                            });
                        }
                    }
                }
            } catch (Exception ex) {
                LogSystem.Write($"SelectLi - {idDrop}: {ex.InnerException.ToString()}");
            }
            if (el != null)
            {
                try {
                    try {
                        el.Click();
                    } catch (Exception) {
                        Actions action = new Actions(driver);
                        action.MoveToElement(el).Click().Perform();
                    }
                } catch (Exception) {
                    LogSystem.Write($"SelectLi-{idDrop}: Không tìm thấy");
                    if (listLi.Count >= 2)
                    {
                        listLi[1].Click();
                    }
                }
            }
            else
            {
                LogSystem.Write($"SelectLi-{idDrop}: Không tìm thấy");
                if (listLi.Count >= 2)
                {
                    listLi[1].Click();
                }
            }
        }
예제 #11
0
        public JObject checkLinks(List <String> links, int top)
        {
            List <string> listLinkChecked = DataMasterHelper.getLinkChecked();
            List <string> listAccounts    = DataMasterHelper.getAccounts();

            if (listLinkChecked == null)
            {
                listLinkChecked = new List <string> ();
            }
            JObject ob   = new JObject();
            String  mess = String.Empty;

            mess += $"DANH SÁCH TIN MỚI - TOP {top}%0A";
            JObject obRes = new JObject();

            try {
                foreach (var link in links)
                {
                    try {
                        driver.Navigate().GoToUrl(link);
                        Thread.Sleep(300);
                        var           ewrapplinks  = driver.FindElements(By.ClassName("wrap-plink"));
                        List <String> wrapplinks   = ewrapplinks.Select(item => item.GetAttribute("href")).ToList();
                        String        tenNguoiDang = String.Empty;
                        String        tenDangNhap  = String.Empty;
                        String        gia          = String.Empty;
                        String        dienTich     = String.Empty;
                        String        email        = string.Empty;
                        String        phone        = string.Empty;
                        int           index        = 1;
                        var           obWrappLink  = new JObject();
                        JObject       obItemRes    = new JObject();
                        top = top <= wrapplinks.Count ? top : wrapplinks.Count;
                        for (int i = 0; i < top; i++)
                        {
                            var wrapplink = wrapplinks[i];
                            var isExist   = listLinkChecked.IndexOf(wrapplink) >= 0;
                            if (!isExist)
                            {
                                try {
                                    driver.Navigate().GoToUrl(wrapplink);
                                    var user = driver.FindElements(By.XPath("//div[@class = 'user']/div"));
                                    foreach (var elDiv in user)
                                    {
                                        var cl = elDiv.GetAttribute("class");

                                        switch (cl)
                                        {
                                        case "mail":
                                            string pattern = "mailto:(.+)\\?subject(.+)";
                                            email = Regex.Replace(CommonMethods.FindElement(elDiv, By.TagName("a"))?.GetAttribute("href"), pattern, "$1")?.ToLower();
                                            break;

                                        case "phone text-center":
                                            phone = CommonMethods.FindElement(elDiv, By.TagName("span"))?.GetAttribute("raw");
                                            break;

                                        case "name":
                                            tenNguoiDang = elDiv.GetAttribute("title");
                                            break;
                                        }
                                    }
                                    var detail   = driver.FindElement(By.ClassName("short-detail-wrap"));
                                    var detailLi = detail.FindElements(By.TagName("li"));
                                    if (detailLi != null && detailLi.Count >= 2)
                                    {
                                        var elGia = CommonMethods.FindElement(detailLi[0], By.ClassName("sp2"));
                                        gia = elGia == null ? string.Empty : elGia.Text;
                                        var elDienTich = CommonMethods.FindElement(detailLi[1], By.ClassName("sp2"));
                                        dienTich = elDienTich == null ? string.Empty : elDienTich.Text;
                                    }

                                    tenDangNhap = string.IsNullOrEmpty(email) ? phone : email;
                                    int indexEmail = listAccounts.IndexOf(tenDangNhap);
                                    if (string.IsNullOrEmpty(tenDangNhap) || indexEmail < 0)
                                    {
                                        obWrappLink[wrapplink] = $"{index++}. {tenNguoiDang} - {gia} - {dienTich} - {phone} ";
                                        dynamic jsonObject = new JObject();
                                        jsonObject.TenNguoiDang = tenNguoiDang;
                                        jsonObject.Gia          = gia;
                                        jsonObject.DienTich     = dienTich;
                                        jsonObject.DienThoai    = phone;
                                        obItemRes[wrapplink]    = jsonObject;
                                        listLinkChecked.Add(wrapplink);
                                    }
                                } catch (Exception ex) {
                                    obWrappLink[wrapplink] = $"+ Chưa xác định: {wrapplink}";
                                }
                            }
                        }

                        if (obWrappLink.HasValues)
                        {
                            ob[link]    = $"Có {obWrappLink.Keys().Count} tin đăng mới.%0A" + string.Join("%0A", obWrappLink.Values().ToList());
                            obRes[link] = obItemRes;
                        }
                    } catch (Exception ex) {
                        ob[link] = ex.InnerException.ToString();
                    }
                }

                if (ob.HasValues)
                {
                    DataMasterHelper.setLinkChecked(listLinkChecked);
                    foreach (var item in ob)
                    {
                        mess += $"{item.Key}: {item.Value}%0A";
                    }
                    List <string> lMessage = CommonMethods.Split(mess, 4000);
                    foreach (var m in lMessage)
                    {
                        CommonMethods.notifycation_tele(m);
                    }
                }
            } catch (System.Exception ex) {
                mess += ex.InnerException.ToString();
                LogSystem.Write($"checkLinks: {mess}");
                CommonMethods.notifycation_tele(mess);
            }
            driver.Quit();
            return(obRes);
        }
예제 #12
0
        public string dangTin(TinDang tinDang)
        {
            string nameFolderImages = tinDang.Ma;
            string link             = String.Empty;

            try {
                //B1 Login
                login(driver, tinDang.TenDangNhap, tinDang.MatKhau);
                //B2 Đăng tin
                driver.Navigate().GoToUrl(pathDangTin);
                Thread.Sleep(2000);
                CommonMethods.SetInput(driver, "txtProductTitle20180807", tinDang.TieuDe);
                var hinhThuc = tinDang.HinhThuc > 0 ? tinDang.HinhThuc : 38;
                CommonMethods.SelectLi(driver, "divProductType", hinhThuc, tinDang.TenHinhThuc);
                Thread.Sleep(300);
                CommonMethods.RemovePopupChat(driver);
                tinDang.TenLoai = String.IsNullOrEmpty(tinDang.TenLoai) ? "Bán đất" : tinDang.TenLoai;
                CommonMethods.SelectLi(driver, "divProductCate", tinDang.Loai, tinDang.TenLoai);
                if (tinDang.TenLoai != "Bán đât")
                {
                    nameFolderImages += ($"\\{tinDang.KieuNha}");
                }
                Thread.Sleep(300);
                CommonMethods.SelectLi(driver, "divCity", tinDang.TinhThanh, tinDang.TenTinhThanh);
                Thread.Sleep(300);
                CommonMethods.RemovePopupChat(driver);
                CommonMethods.SelectLi(driver, "divDistrict", tinDang.QuanHuyen, tinDang.TenQuanHuyen);
                Thread.Sleep(500);
                CommonMethods.SelectLi(driver, "divWard", tinDang.PhuongXa, tinDang.TenPhuongXa);
                Thread.Sleep(300);
                var    regex    = new Regex(@"(.+)đường(.+)");
                string duongPho = Regex.Replace(tinDang.SoNha.ToLower(), "(.+)đường(.+)", "đường$2") ?? Regex.Replace(tinDang.SoNha.ToLower(), "(.+)phố(.+)", "phố$2");

                if (!String.IsNullOrEmpty(duongPho))
                {
                    CommonMethods.SelectLi(driver, "divStreet", null, duongPho);
                }
                Thread.Sleep(300);
                CommonMethods.SetInput(driver, "txtArea", tinDang.DienTich);
                CommonMethods.SetInput(driver, "txtPrice", (tinDang.Gia / 1000000));
                CommonMethods.SelectOptions(driver, "ddlPriceType", tinDang.DonViTinh == 1 ? 7 : 1);  //set đơn vị của giá
                CommonMethods.SetInput(driver, "txtDescription", tinDang.MoTa);
                CommonMethods.SetInput(driver, "txtWidth", tinDang.MatTien);
                CommonMethods.SetInput(driver, "txtLandWidth", tinDang.DuongVao);
                if (tinDang.TenLoai != "Bán đât")
                {
                    if (tinDang.SoPhongNgu != null && tinDang.SoPhongNgu > 0)
                    {
                        CommonMethods.SetInput(driver, "txtRoomNumber", tinDang.SoPhongNgu);
                    }
                    if (tinDang.SoToilet != null && tinDang.SoToilet > 0)
                    {
                        CommonMethods.SetInput(driver, "txtToiletNumber", tinDang.SoToilet);
                    }
                }
                if (tinDang.HuongNha != null && tinDang.HuongNha > 0)
                {
                    CommonMethods.SelectOptions(driver, "ddlHomeDirection", tinDang.HuongNha);
                }
                CommonMethods.SetInput(driver, "txtLegality", tinDang.ThongTinPhapLy);
                if (!String.IsNullOrEmpty(duongPho))
                {
                    tinDang.SoNha  = tinDang.SoNha.ToLower().Replace(duongPho, "").Trim();
                    tinDang.DiaChi = tinDang.SoNha + " " + driver.FindElement(By.Id("txtAddress")).GetAttribute("value");
                }
                else
                {
                    tinDang.DiaChi = tinDang.SoNha + ", " + driver.FindElement(By.Id("txtAddress")).GetAttribute("value");
                }
                CommonMethods.SetInput(driver, "txtAddress", tinDang.DiaChi);


                //B3: upload load hình
                CommonMethods.UploadImages(driver, "file", tinDang.ListHinhAnh, nameFolderImages);
                //B4: set maps

                CommonMethods.SetInput(driver, "txtBrName", tinDang.TenLienHe);
                CommonMethods.SetInput(driver, "txtBrAddress", tinDang.DiaChiLienHe);
                CommonMethods.SetInput(driver, "txtBrEmail", tinDang.EmailLienHe);
                CommonMethods.SelectLi(driver, "divBrMobile", tinDang.DienThoaiLienHe);
                if (tinDang.TuNgay != null && tinDang.TuNgay != DateTime.MinValue)
                {
                    CommonMethods.SetDateTime_BatDongSan(driver, "txtStartDate", tinDang.TuNgay);
                }
                if (tinDang.DenNgay != null && tinDang.DenNgay != DateTime.MinValue)
                {
                    CommonMethods.SetDateTime_BatDongSan(driver, "txtEndDate", tinDang.DenNgay);
                }
                var error = getError(driver) ?? "Bạn nhập mã an toàn không hợp lệ";
                while (error != null && error == "Bạn nhập mã an toàn không hợp lệ")
                {
                    try {
                        string strResult = CommonMethods.ReadRecaptcha(driver, "img_CAPTCHA_RESULT_314", "reloadCaptcha");
                        driver.FindElement(By.Id("secode")).SendKeys(strResult);
                        driver.FindElement(By.Name("ctl00$MainContent$_userPage$ctl00$btnSave")).Click();
                        //Bắt lỗi error lần
                        error = getError(driver);
                        if (!string.IsNullOrEmpty(error))
                        {
                            LogSystem.Write(error);
                        }
                    } catch (System.Exception ex) {
                        throw new Exception($"ReadRecaptcha: {ex.Message}");
                    }
                }
                if (!String.IsNullOrEmpty(error))
                {
                    throw new Exception(error);
                }
                driver.Navigate().GoToUrl("https://batdongsan.com.vn/trang-ca-nhan");
                var eleItem = driver.FindElement(By.Id("MainContent__userPage_ctl00_rpItems_lnkEdit_0"));
                if (eleItem != null)
                {
                    link = eleItem.GetAttribute("href")?.ToString();
                    link = link.IndexOf("https://batdongsan.com.vn") >= 0 ? link : $"https://batdongsan.com.vn{link}";
                }
            } catch (Exception ex) {
                driver.Quit();
                throw new Exception(ex.Message);
            }
            driver.Quit();

            return(link);
        }
예제 #13
0
        private void SQL101ms()
        {
            try
            {
                CreateTable();


                while (true)
                {
                    Thread.Sleep(101);

                    if (bufferSQL == null)
                    {
                        Console.WriteLine("0");
                    }
                    else
                    {
                        //Формируем строку для таблицы и ее записываем при условии что начата прокатка рулона

                        DataRow dr101ms = dt101ms.NewRow();
                        dr101ms["dtStan"] = DateTime.Now;



                        foreach (var item in dic101ms)
                        {
                            if (item.Value.floatdata) //Если данные имеют тип float
                            {
                                float a = (float)(BitConverter.ToInt16(bufferSQL, item.Value.startbit)) / item.Value.coefficient;
                                //Console.WriteLine(a);
                                dr101ms[item.Key] = a;
                                string namepol = item.Key;

                                switch (item.Key)
                                {
                                case "dmot":
                                    D_tek_mot = a;
                                    Console.WriteLine(item.Key + " = " + D_tek_mot);
                                    break;

                                case "h":
                                    hw = a;
                                    break;

                                case "v4":
                                    speed4kl = a;
                                    break;

                                case "b":
                                    Bw = a;
                                    break;

                                default:
                                    break;
                                }
                            }
                            else
                            {
                                //Console.WriteLine(item.Key + " = " + item.Value.startbit + " - " + item.Value.coefficient);
                                int a = (BitConverter.ToInt16(bufferSQL, item.Value.startbit)) / item.Value.coefficient;
                                dr101ms[item.Key] = a;

                                string namepol = item.Key;

                                switch (item.Key)
                                {
                                case "dmot":
                                    D_tek_mot = a;
                                    //Console.WriteLine(item.Key + " = " + item.Value.startbit + " - " + item.Value.coefficient);
                                    break;

                                case "h":
                                    hw = a;
                                    break;

                                case "v4":
                                    speed4kl = a;
                                    break;

                                case "b":
                                    Bw = a;
                                    break;

                                default:
                                    break;
                                }
                            }
                        }

                        if (blRulonProkatSaveInData101ms)
                        {
                            dt101ms.Rows.Add(dr101ms); //Добавляем троку в таблицу
                            //LogSystem.Write(namePLC + " SQL", Direction.Ok, "+", curLeft, (curTop+4), true);
                            //LogSystem.Write(namePLC + " SQL", Direction.Ok, "+", curLeft, 4, true);
                            //Console.WriteLine(" Кол-во строк в таблице=" +  dt101ms.Rows.Count);
                            //Console.Write(".");

                            Console.WriteLine(namePLC + " " + DateTime.Now.ToShortTimeString() + "  + " + D_tek_mot);
                        }
                        else
                        {
                            //LogSystem.Write(namePLC + " SQL", Direction.Ok, "-", curLeft, (curTop+4), true);
                            //LogSystem.Write(namePLC + " SQL", Direction.Ok, "-", curLeft, 4, true);
                            //Console.Write("_");

                            Console.WriteLine(namePLC + " " + DateTime.Now.ToShortTimeString() + "  - " + D_tek_mot);
                        }


                        if (D_tek_mot > D_pred_mot)
                        {
                            //if (D_tek_mot<0.615)
                            if (D_tek_mot < diametr_motalki)
                            {
                                TimeStart = DateTime.Now;
                                blRulonProkatSaveInData101ms = false; //включаем сбор данных по прокатке рулона
                                //Console.Write(D_tek_mot);
                            }
                            else
                            {
                                blRulonProkatSaveInData101ms = true;
                                //Console.Write(D_tek_mot);
                            }
                        }
                    }



                    D_pred_mot = D_tek_mot;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Write(namePLC + " SQL(101ms)-" + ex.Source, Direction.ERROR, "Start Error-" + ex.Message, curLeft, (curTop + 3), true);
            }
        }
예제 #14
0
        private void PLC()
        {
            try
            {
                int i = curTop;         //начальная позиция по Top
                int y = curTop + 2;     //Конечная позиция по Top

                Prodave rs2 = new Prodave();

                buffer    = new byte[amount];
                bufferPLC = new byte[amount];
                bufferSQL = new byte[amount];

                int resultReadField = 5;


                while (true)
                {
                    Thread.Sleep(100);

                    if (resultReadField != 0)
                    {
                        int res = rs2.LoadConnection(Connect, 2, conn, slot, rack);

                        if (res != 0)
                        {
                            //Console.WriteLine("error" + rs2.Error(res));
                            LogSystem.Write(namePLC + " start", Direction.ERROR, "Error connection!. Error - " + rs2.Error(res), curLeft, i, true);
                        }
                        else
                        {
                            int resSAC = rs2.SetActiveConnection(Connect);
                        }
                    }

                    int Byte_Col_r = 0;

                    resultReadField = rs2.field_read('M', 0, startBuffer, amount, out buffer, out Byte_Col_r);

                    if (resultReadField == 0)
                    {
                        //LogSystem.Write(namePLC + " start", Direction.Ok, "Соединение активно.", curLeft, (i+1), true);

                        //Буфер PLC
                        Thread PLS100ms = new Thread(BufferToBuffer);
                        PLS100ms.Start();

                        //Буфер SQL 100mc
                        Thread PLS101ms = new Thread(BufferSQLToBufferPLC);
                        PLS101ms.Start();

                        //Буфер сообщений

                        //Буфер 1с
                    }
                    else
                    {
                        rs2.UnloadConnection(Connect);
                        LogSystem.Write(namePLC + " 100ms", Direction.ERROR, "Error.Read fied PLC. " + rs2.Error(resultReadField), curLeft, i, true);
                    }
                }

                //if (i < y)
                //{
                //    i = i + 1;
                //    Console.SetCursorPosition(curLeft, i);
                //    Console.Write(namePLC + " 100ms - " + DateTime.Now.ToString("HH:mm:ss.fff"));

                //}
                //else
                //{
                //    i = curTop;
                //    Console.SetCursorPosition(curLeft, i);
                //    Console.Write(namePLC + " 100ms - " + DateTime.Now.ToString("HH:mm:ss.fff"));

                //}
            }
            catch (Exception ex)
            {
                /*все исключения кидаем в пустоту*/
                LogSystem.Write(namePLC + " start-" + ex.Source, Direction.ERROR, "Start Error-" + ex.Message, curLeft, curTop, true);
            }
        }
예제 #15
0
        private void PLC()
        {
            try
            {
                int i = 100;   //начальная позиция по Top
                int y = 2;     //Конечная позиция по Top

                Prodave rs2 = new Prodave();

                buffer    = new byte[amount];
                bufferPLC = new byte[amount];
                bufferSQL = new byte[amount];

                int resultReadField = 5;


                while (true)
                {
                    Thread.Sleep(100);

                    if (resultReadField != 0)
                    {
                        int res = rs2.LoadConnection(connect, 2, IPconnPLC, SlotconnPC, RackconnPC);

                        if (res != 0)
                        {
                            //Console.WriteLine("error" + rs2.Error(res));
                            LogSystem.Write(NamePLC + " start", Direction.ERROR, "Error connection!. Error - " + rs2.Error(res), 100, 0, true);
                        }
                        else
                        {
                            int resSAC = rs2.SetActiveConnection(connect);
                        }
                    }

                    int Byte_Col_r = 0;

                    resultReadField = rs2.field_read('M', 0, StartAdressTag, amount, out buffer, out Byte_Col_r);

                    if (resultReadField == 0)
                    {
                        //LogSystem.Write(NamePLC + " start", Direction.Ok, "Соединение активно.", 100, 1, true);

                        //Буфер PLC
                        Thread PLS100ms = new Thread(BufferToBuffer);
                        PLS100ms.Start();

                        //Буфер SQL 100mc
                        Thread PLS101ms = new Thread(BufferSQLToBufferPLC);
                        PLS101ms.Start();

                        //Буфер сообщений

                        //Буфер 1с
                    }
                    else
                    {
                        rs2.UnloadConnection(connect);
                        LogSystem.Write(NamePLC + " 100ms", Direction.ERROR, "Error.Read fied PLC. " + rs2.Error(resultReadField), 100, 0, true);
                    }
                }
            }
            catch (Exception ex)
            {
                /*все исключения кидаем в пустоту*/
                LogSystem.Write(NamePLC + " start-" + ex.Source, Direction.ERROR, "Start Error-" + ex.Message, 100, 0, true);
            }
        }
예제 #16
0
        static void Main(string[] args)
        {
            //Настройка на региональных параметров
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Для выбора ветки программы выберите 1 или 2");
            Console.WriteLine();
            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("1) Запуск сбора данных по стану 1700");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine();
            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("2) Запуск сбора данных по дрессировочному стану");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine();
            Console.WriteLine("Выберите 1 или 2");
            ConsoleKeyInfo key;

            switch (Console.ReadLine())
            {
            case "2":
                clDs   stanDs = new clDs();
                Thread task2  = new Thread(stanDs.goStart);
                task2.Start();
                break;

            case "1":
                clStan1700 stan1700 = new clStan1700();
                Thread     task1    = new Thread(stan1700.goStart);
                task1.Start();
                break;

            default:
                break;
            }



            //if (key.Key.ToString() == "d" || key.Key.ToString() == "D" || key.Key.ToString() == "В" || key.Key.ToString() == "в")
            //{
            //    clDs stanDs = new clDs();
            //    Thread task2 = new Thread(stanDs.goStart);
            //    task2.Start();
            //}
            //else if (key.Key.ToString() == "s" || key.Key.ToString() == "S" || key.Key.ToString() == "Ы" || key.Key.ToString() == "ы")
            //{
            //    clStan1700 stan1700 = new clStan1700();
            //    Thread task1 = new Thread(stan1700.goStart);
            //    task1.Start();
            //}

            Console.Clear();
            Console.SetWindowSize(190, 40);



            //clStan1700 stan1700 = new clStan1700();
            //Thread task1 = new Thread(stan1700.goStart);
            //task1.Start();

            //clDs stanDs = new clDs();
            //Thread task2 = new Thread(stanDs.goStart);
            //task2.Start();

            string MesMain    = DateTime.Now.ToString("HH:mm dd.MM.yyyy");
            String strVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();


            string strVersionData = strVersion + "  (" + clVersionDT.Decript() + ")";
            //Console.Clear();


            bool clean = false;

            while (true)
            {
                Thread.Sleep(5000);



                if (false)
                {
                    messageErrorSt100mc        = null;
                    messageOKSt100mc           = null;
                    messageErrorSt101mc        = null;
                    messageOKSt101mc           = null;
                    messageErrorSt200mc        = null;
                    messageOKSt200mc           = null;
                    messageErrorSt1c           = null;
                    messageOKSt1c              = null;
                    messageErrorStRulon        = null;
                    messageOKStRulon           = null;
                    messageErrorStProizvodstvo = null;
                    messageOKStProizvodstvo    = null;
                    messageErrorStValki        = null;
                    messageOKStValki           = null;

                    messageErrorDs100mc        = null;
                    messageOKDs100mc           = null;
                    messageErrorDs101mc        = null;
                    messageOKDs101mc           = null;
                    messageErrorDs200mc        = null;
                    messageOKDs200mc           = null;
                    messageErrorDs1c           = null;
                    messageOKDs1c              = null;
                    messageErrorDsRulon        = null;
                    messageOKDsRulon           = null;
                    messageErrorDsProizvodstvo = null;
                    messageOKDsProizvodstvo    = null;
                    messageErrorDsValki        = null;
                    messageOKDsValki           = null;
                }



                LogSystem.Write("Время запуска программы: ", Direction.Ok, MesMain, 20, 0, true);

                LogSystem.Write("Version: ", Direction.Ok, strVersionData, 120, 0, true);

                LogSystem.Write("Для очистки экрана нажмите на клавишу С", Direction.Ok, "", 70, 1, true);


                #region Вывод на консоль сообщений по стану

                LogSystem.Write("Стан1700", Direction.Ok, "Информация о работе методов класса clStan1700 ( Цикл 5сек )", 1, 3, true);

                if (messageErrorSt100mc != null)
                {
                    ConMessageErrorSt100mc = messageErrorSt100mc;
                    LogSystem.Write("Стан1700 ERROR цикла 100mc", Direction.ERROR, dtErrorSt100mc, ConMessageErrorSt100mc, 1, 5, true);
                }
                if (messageOKSt100mc != null)
                {
                    ConMessageOKSt100mc = messageOKSt100mc;
                    LogSystem.Write("Стан1700 connection (цикл 100mc)", Direction.Ok, dtOKSt100mc, ConMessageOKSt100mc, 1, 6, true);
                }
                if (messageErrorSt101mc != null)
                {
                    ConMessageErrorSt101mc = messageErrorSt101mc;
                    LogSystem.Write("Стан1700 ERROR цикла 101mc", Direction.ERROR, dtErrorSt101mc, ConMessageErrorSt101mc, 1, 8, true);
                }
                if (messageOKSt101mc != null)
                {
                    ConMessageOKSt101mc = messageOKSt101mc;
                    LogSystem.Write("Стан1700. Read PLC and Write во временную таблицу (цикл 101mc)", Direction.Ok, dtOKSt101mc, ConMessageOKSt101mc, 1, 9, true);
                }
                if (messageErrorSt200mc != null)
                {
                    ConMessageErrorSt200mc = messageErrorSt200mc;
                    LogSystem.Write("Стан1700 ERROR цикла 200mc", Direction.ERROR, dtErrorSt200mc, ConMessageErrorSt200mc, 1, 11, true);
                }
                if (messageOKSt200mc != null)
                {
                    ConMessageOKSt200mc = messageOKSt200mc;
                    LogSystem.Write("Стан1700 Сообщения(цикл 200mc)", Direction.Ok, dtOKSt200mc, ConMessageOKSt200mc, 1, 12, true);
                }
                if (messageErrorSt1c != null)
                {
                    ConMessageErrorSt1c = messageErrorSt1c;

                    LogSystem.Write("Стан1700 ERROR цикла 1c", Direction.ERROR, dtErrorSt1c, ConMessageErrorSt1c, 1, 14, true);
                }
                if (messageOKSt1c != null)
                {
                    ConMessageOKSt1c = messageOKSt1c;
                    LogSystem.Write("Стан1700. Цикл 1c.", Direction.Ok, dtOKSt1c, ConMessageOKSt1c, 1, 15, true);
                }
                if (messageErrorStRulon != null)
                {
                    ConMessageErrorStRulon = messageErrorStRulon;
                    LogSystem.Write("Стан1700 ERROR при переименовании таблицы рулонов", Direction.ERROR, dtErrorStRulon, ConMessageErrorStRulon, 1, 17, true);
                }
                if (messageOKStRulon != null)
                {
                    ConMessageOKStRulon = messageOKStRulon;
                    LogSystem.Write("Стан1700. Rename-", Direction.Ok, dtOKStRulon, ConMessageOKStRulon, 1, 18, true);
                }
                if (messageErrorStProizvodstvo != null)
                {
                    ConMessageErrorStProizvodstvo = messageErrorStProizvodstvo;

                    LogSystem.Write("Стан1700 ERROR записи в таблицу Производства", Direction.ERROR, dtErrorStProizvodstvo, ConMessageErrorStProizvodstvo, 1, 20, true);
                }
                if (messageOKStProizvodstvo != null)
                {
                    ConMessageOKStProizvodstvo = messageOKStProizvodstvo;
                    LogSystem.Write("Стан1700. Производствo.", Direction.Ok, dtOKStProizvodstvo, ConMessageOKStProizvodstvo, 1, 21, true);
                }
                if (messageErrorStValki != null)
                {
                    ConMessageErrorStValki = messageErrorStValki;

                    LogSystem.Write("Стан1700 ERROR записи в таблицу перевалок валков", Direction.ERROR, dtErrorStValki, ConMessageErrorStValki, 1, 23, true);
                }
                if (messageOKStValki != null)
                {
                    ConMessageOKStValki = messageOKStValki;

                    LogSystem.Write("Стан1700. Write перевалок валков.", Direction.Ok, dtOKStValki, ConMessageOKStValki, 1, 24, true);
                }


                #endregion

                #region Вывод на консоль сообщений по дрессировке


                LogSystem.Write("Дрессировка", Direction.Ok, "Информация о работе методов класса Дрессировочного стана ( Цикл 5сек )", 100, 3, true);

                if (messageErrorDs100mc != null)
                {
                    ConMessageErrorDs100mc = messageErrorDs100mc;

                    LogSystem.Write("Дрессировка. ERROR цикла 70mc", Direction.ERROR, dtErrorDs100mc, ConMessageErrorDs100mc, 100, 5, true);
                }
                if (messageOKDs100mc != null)
                {
                    ConMessageOKDs100mc = messageOKDs100mc;
                    LogSystem.Write("Дрессировка. Сonnection (цикл 70mc)", Direction.Ok, dtOKDs100mc, ConMessageOKDs100mc, 100, 6, true);
                }
                if (messageErrorDs101mc != null)
                {
                    ConMessageErrorDs101mc = messageErrorDs101mc;

                    LogSystem.Write("Дрессировка. ERROR цикла 80mc", Direction.ERROR, dtErrorDs101mc, ConMessageErrorDs101mc, 100, 8, true);
                }
                if (messageOKDs101mc != null)
                {
                    ConMessageOKDs101mc = messageOKDs101mc;
                    LogSystem.Write("Дрессировка. Read PLC and Write во временную таблицу (цикл 80mc)", Direction.Ok, dtOKDs101mc, ConMessageOKDs101mc, 100, 9, true);
                }
                if (messageErrorDs200mc != null)
                {
                    ConMessageErrorDs200mc = messageErrorDs200mc;

                    LogSystem.Write("Дрессировка.ERROR цикла 200mc", Direction.ERROR, dtErrorDs200mc, ConMessageErrorDs200mc, 100, 11, true);
                }
                if (messageOKDs200mc != null)
                {
                    ConMessageOKDs200mc = messageOKDs200mc;
                    LogSystem.Write("Дрессировка.Сообщения(цикл 200mc)", Direction.Ok, dtOKDs200mc, ConMessageOKDs200mc, 100, 12, true);
                }
                if (messageErrorDs1c != null)
                {
                    ConMessageErrorDs1c = messageErrorDs1c;

                    LogSystem.Write("Дрессировка.ERROR цикла 1c", Direction.ERROR, dtErrorDs1c, ConMessageErrorDs1c, 100, 14, true);
                }
                if (messageOKDs1c != null)
                {
                    ConMessageOKDs1c = messageOKDs1c;
                    LogSystem.Write("Дрессировка.Цикл 1c.", Direction.Ok, dtOKDs1c, ConMessageOKDs1c, 100, 15, true);
                }
                if (messageErrorDsRulon != null)
                {
                    ConMessageErrorDsRulon = messageErrorDsRulon;

                    LogSystem.Write("Дрессировка. ERROR Rename", Direction.ERROR, dtErrorDsRulon, ConMessageErrorDsRulon, 100, 17, true);
                }
                if (messageOKDsRulon != null)
                {
                    ConMessageOKDsRulon = messageOKDsRulon;

                    LogSystem.Write("Дрессировка. Rename", Direction.Ok, dtOKDsRulon, ConMessageOKDsRulon, 100, 18, true);
                }
                if (messageErrorDsProizvodstvo != null)
                {
                    ConMessageErrorDsProizvodstvo = messageErrorDsProizvodstvo;

                    LogSystem.Write("Дрессировка. ERROR Write Производства", Direction.ERROR, dtErrorDsProizvodstvo, ConMessageErrorDsProizvodstvo, 100, 20, true);
                }
                if (messageOKDsProizvodstvo != null)
                {
                    ConMessageOKDsProizvodstvo = messageOKDsProizvodstvo;

                    LogSystem.Write("Дрессировка. Производство", Direction.Ok, dtOKDsProizvodstvo, ConMessageOKDsProizvodstvo, 100, 21, true);
                }
                if (messageErrorDsValki != null)
                {
                    ConMessageErrorDsValki = messageErrorDsValki;

                    LogSystem.Write("Дрессировка. ERROR записи в таблицу перевалок валков", Direction.ERROR, dtErrorDsValki, ConMessageErrorDsValki, 100, 23, true);
                }
                if (messageOKDsValki != null)
                {
                    ConMessageOKDsValki = messageOKDsValki;

                    LogSystem.Write("Дрессировка. Запись в таблицу перевалок валков", Direction.Ok, dtOKDsValki, ConMessageOKDsValki, 100, 24, true);
                }


                #endregion

                #region Сброс сообщений в конце цикла


                messageOKSt100mc           = null;
                messageErrorSt101mc        = null;
                messageOKSt101mc           = null;
                messageErrorSt200mc        = null;
                messageOKSt200mc           = null;
                messageErrorSt1c           = null;
                messageOKSt1c              = null;
                messageErrorStRulon        = null;
                messageOKStRulon           = null;
                messageErrorStProizvodstvo = null;
                messageOKStProizvodstvo    = null;
                messageErrorStValki        = null;
                messageOKStValki           = null;

                messageErrorDs100mc        = null;
                messageOKDs100mc           = null;
                messageErrorDs101mc        = null;
                messageOKDs101mc           = null;
                messageErrorDs200mc        = null;
                messageOKDs200mc           = null;
                messageErrorDs1c           = null;
                messageOKDs1c              = null;
                messageErrorDsRulon        = null;
                messageOKDsRulon           = null;
                messageErrorDsProizvodstvo = null;
                messageOKDsProizvodstvo    = null;
                messageErrorDsValki        = null;
                messageOKDsValki           = null;

                #endregion

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                    if (keyInfo.Key == ConsoleKey.C)
                    {
                        clean = true;
                    }
                    else
                    {
                        break;
                    }

                    if (clean)
                    {
                        Console.Clear();
                    }

                    System.Threading.Thread.Sleep(1000);
                }
            }


            //ConsoleKeyInfo cki;
            //do
            //{
            //    while (Console.KeyAvailable == false)
            //    {
            //        Thread.Sleep(5000);
            //        Console.Clear();

            //        //int iKey = Console.Read();
            //        //char cKey = Convert.ToChar(iKey);

            //        //ConsoleKeyInfo key = Console.ReadKey();

            //        if (false)
            //        {

            //            messageErrorSt100mc = null;
            //            messageOKSt100mc = null;
            //            messageErrorSt101mc = null;
            //            messageOKSt101mc = null;
            //            messageErrorSt200mc = null;
            //            messageOKSt200mc = null;
            //            messageErrorSt1c = null;
            //            messageOKSt1c = null;
            //            messageErrorStRulon = null;
            //            messageOKStRulon = null;
            //            messageErrorStProizvodstvo = null;
            //            messageOKStProizvodstvo = null;
            //            messageErrorStValki = null;
            //            messageOKStValki = null;

            //            messageErrorDs100mc = null;
            //            messageOKDs100mc = null;
            //            messageErrorDs101mc = null;
            //            messageOKDs101mc = null;
            //            messageErrorDs200mc = null;
            //            messageOKDs200mc = null;
            //            messageErrorDs1c = null;
            //            messageOKDs1c = null;
            //            messageErrorDsRulon = null;
            //            messageOKDsRulon = null;
            //            messageErrorDsProizvodstvo = null;
            //            messageOKDsProizvodstvo = null;
            //            messageErrorDsValki = null;
            //            messageOKDsValki = null;



            //        }

            //        #region Вывод на консоль сообщений по стану

            //        LogSystem.Write("Стан1700", Direction.Ok, "Информация о работе методов класса clStan1700 ( Цикл 5сек )", 1, 1, true);

            //        if (messageErrorSt100mc != null)
            //        {
            //            LogSystem.Write("Стан1700 ERROR цикла 100mc", Direction.ERROR, dtErrorSt100mc, messageErrorSt100mc, 1, 5, true);
            //        }
            //        if (messageOKSt100mc != null)
            //        {
            //            LogSystem.Write("Стан1700 connection (цикл 100mc)", Direction.Ok, dtOKSt100mc, messageOKSt100mc, 1, 6, true);
            //        }


            //        if (messageErrorSt101mc != null)
            //        {
            //            LogSystem.Write("Стан1700 ERROR цикла 101mc", Direction.ERROR, dtErrorSt101mc, messageErrorSt101mc, 1, 8, true);
            //        }
            //        if (messageOKSt101mc != null)
            //        {
            //            LogSystem.Write("Стан1700. Read PLC and Write во временную таблицу (цикл 101mc)", Direction.Ok, dtOKSt101mc, messageOKSt101mc, 1, 9, true);
            //        }

            //        if (messageErrorSt200mc != null)
            //        {
            //            LogSystem.Write("Стан1700 ERROR цикла 200mc", Direction.ERROR, dtErrorSt200mc, messageErrorSt200mc, 1, 11, true);
            //        }
            //        if (messageOKSt200mc != null)
            //        {
            //            LogSystem.Write("Стан1700 Сообщения(цикл 200mc)", Direction.Ok, dtOKSt200mc, messageOKSt200mc, 1, 12, true);
            //        }

            //        if (messageErrorSt1c != null)
            //        {
            //            LogSystem.Write("Стан1700 ERROR цикла 1c", Direction.ERROR, dtErrorSt1c, messageErrorSt1c, 1, 14, true);
            //        }
            //        if (messageOKSt1c != null)
            //        {
            //            LogSystem.Write("Стан1700. Цикл 1c.", Direction.Ok, dtOKSt1c, messageOKSt1c, 1, 15, true);
            //        }



            //        if (messageErrorStRulon != null)
            //        {
            //            LogSystem.Write("Стан1700 ERROR при переименовании таблицы рулонов", Direction.ERROR, dtErrorStRulon, messageErrorStRulon, 1, 17, true);
            //        }
            //        if (messageOKStRulon != null)
            //        {
            //            LogSystem.Write("Стан1700. Rename-", Direction.Ok, dtOKStRulon, messageOKStRulon, 1, 18, true);
            //        }



            //        if (messageErrorStProizvodstvo != null)
            //        {
            //            LogSystem.Write("Стан1700 ERROR записи в таблицу Производства", Direction.ERROR, dtErrorStProizvodstvo, messageErrorStProizvodstvo, 1, 20, true);
            //        }
            //        if (messageOKStProizvodstvo != null)
            //        {
            //            LogSystem.Write("Стан1700. Производствo.", Direction.Ok, dtOKStProizvodstvo, messageOKStProizvodstvo, 1, 21, true);
            //        }



            //        if (messageErrorStValki != null)
            //        {
            //            LogSystem.Write("Стан1700 ERROR записи в таблицу перевалок валков", Direction.ERROR, dtErrorStValki, messageErrorStValki, 1, 23, true);
            //        }
            //        if (messageOKStValki != null)
            //        {
            //            LogSystem.Write("Стан1700. Write перевалок валков.", Direction.Ok, dtOKStValki, messageOKStValki, 1, 24, true);
            //        }


            //        #endregion

            //        #region Вывод на консоль сообщений по дрессировке

            //        LogSystem.Write("Дрессировка", Direction.Ok, "Информация о работе методов класса Дрессировочного стана ( Цикл 5сек )", 100, 1, true);

            //        if (messageErrorDs100mc != null)
            //        {
            //            LogSystem.Write("Дрессировка. ERROR цикла 70mc", Direction.ERROR, dtErrorDs100mc, messageErrorDs100mc, 100, 5, true);
            //        }
            //        if (messageOKDs100mc != null)
            //        {
            //            LogSystem.Write("Дрессировка. Сonnection (цикл 70mc)", Direction.Ok, dtOKDs100mc, messageOKDs100mc, 100, 6, true);
            //        }


            //        if (messageErrorDs101mc != null)
            //        {
            //            LogSystem.Write("Дрессировка. ERROR цикла 80mc", Direction.ERROR, dtErrorDs101mc, messageErrorDs101mc, 100, 8, true);
            //        }
            //        if (messageOKDs101mc != null)
            //        {
            //            LogSystem.Write("Дрессировка. Read PLC and Write во временную таблицу (цикл 80mc)", Direction.Ok, dtOKDs101mc, messageOKDs101mc, 100, 9, true);
            //        }

            //        if (messageErrorDs200mc != null)
            //        {
            //            LogSystem.Write("Дрессировка.ERROR цикла 200mc", Direction.ERROR, dtErrorDs200mc, messageErrorDs200mc, 100, 11, true);
            //        }
            //        if (messageOKDs200mc != null)
            //        {
            //            LogSystem.Write("Дрессировка.Сообщения(цикл 200mc)", Direction.Ok, dtOKDs200mc, messageOKDs200mc, 100, 12, true);
            //        }

            //        if (messageErrorDs1c != null)
            //        {
            //            LogSystem.Write("Дрессировка.ERROR цикла 1c", Direction.ERROR, dtErrorDs1c, messageErrorDs1c, 100, 14, true);
            //        }
            //        if (messageOKDs1c != null)
            //        {
            //            LogSystem.Write("Дрессировка.Цикл 1c.", Direction.Ok, dtOKDs1c, messageOKDs1c, 100, 15, true);
            //        }



            //        if (messageErrorDsRulon != null)
            //        {
            //            LogSystem.Write("Дрессировка. ERROR Rename", Direction.ERROR, dtErrorDsRulon, messageErrorDsRulon, 100, 17, true);
            //        }
            //        if (messageOKDsRulon != null)
            //        {
            //            LogSystem.Write("Дрессировка. Rename", Direction.Ok, dtOKDsRulon, messageOKDsRulon, 100, 18, true);
            //        }



            //        if (messageErrorDsProizvodstvo != null)
            //        {
            //            LogSystem.Write("Дрессировка. ERROR Write Производства", Direction.ERROR, dtErrorDsProizvodstvo, messageErrorDsProizvodstvo, 100, 20, true);
            //        }
            //        if (messageOKDsProizvodstvo != null)
            //        {
            //            LogSystem.Write("Дрессировка. Производство", Direction.Ok, dtOKDsProizvodstvo, messageOKDsProizvodstvo, 100, 21, true);
            //        }



            //        if (messageErrorDsValki != null)
            //        {
            //            LogSystem.Write("Дрессировка. ERROR записи в таблицу перевалок валков", Direction.ERROR, dtErrorDsValki, messageErrorDsValki, 100, 23, true);
            //        }
            //        if (messageOKDsValki != null)
            //        {
            //            LogSystem.Write("Дрессировка. Запись в таблицу перевалок валков", Direction.Ok, dtOKDsValki, messageOKDsValki, 100, 24, true);
            //        }


            //        #endregion


            //    }

            //    cki = Console.ReadKey(true);
            //    Console.WriteLine(cki.Key);
            //} while (cki.Key != ConsoleKey.X);
        }