public main_page() { InitializeComponent(); //File.WriteAllText(GF.path, String.Empty); GF.doDebug("===== MAIN FORM :: " + this.Name + " IS OPENED ====="); this.FormClosing += (s, e) => { GF.doDebug("===== MAIN FORM :: " + this.Name + " IS CLOSED ====="); }; GF.mainPage = this; GF.initLoading(); GF.showLoading(this); DB.initLocalVars(); switch (CultureInfo.CurrentCulture.Name) { case "th-TH": case "en-US": GF.dateSep = "/"; GF.thousandSep = ","; GF.decimalSep = "."; break; case "ru-RU": GF.dateSep = "."; GF.thousandSep = " "; GF.decimalSep = ","; break; } using (clock = new Timer()) { clock.Enabled = true; clock.Interval = 100; int count = 0; clock.Tick += (s, ee) => { count++; uint idleTime = 0; GF.LASTINPUTINFO lastInputInfo = new GF.LASTINPUTINFO(); lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo); lastInputInfo.dwTime = 0; uint envTicks = (uint)Environment.TickCount; if (GF.GetLastInputInfo(ref lastInputInfo)) { uint lastInputTick = lastInputInfo.dwTime; idleTime = envTicks - lastInputTick; } //GF.doDebug(">>>>>>>>>> " + idleTime.ToString()); if (Math.Floor(Convert.ToDouble(idleTime / 1000)) >= (10 * 60)) { logOutTopToolStripMenuItem.PerformClick(); } String language_txt = InputLanguage.CurrentInputLanguage.Culture.EnglishName; if (language_txt.ToUpper().IndexOf("ENGLISH") != -1) { language_txt = "ENGLISH"; } if (language_txt.ToUpper().IndexOf("THAI") != -1) { language_txt = "ไทย"; } if (language_txt.ToUpper().IndexOf("RUSSIAN") != -1) { language_txt = "РУССКИЙ"; } language.Text = language_txt; if (count % 10 == 0) { timenow.Text = GF.NOW(); count = 0; } GF.ClickButtonLabeledOK("Hotel lock system interface"); }; } if (!GF.is_logged_in) { this.Hide(); /*if (!DB.skipFileCheck) * { * using (progress progressPage = new progress()) * { * progressPage.Owner = this; * progressPage.ShowDialog(); * } * } * else * {*/ using (login loginPage = new login()) { loginPage.Owner = this; GF.closeLoading(); loginPage.ShowDialog(); } //} } }
public static void submitErrorLog() { return; Boolean halt = false; try { //GF.doDebug("========== SEND EMAIL =========="); client = new SmtpClient("smtp.yandex.com", 587); client.EnableSsl = true; client.Credentials = new NetworkCredential("*****@*****.**", "abc1234567890"); client.Timeout = 10000; MailAddress from = new MailAddress("*****@*****.**", "Error Log", System.Text.Encoding.UTF8); MailAddress to = new MailAddress("*****@*****.**"); /*GF.doDebug("INIT SMTP CLIENT"); * GF.doDebug("HOST : " + client.Host); * GF.doDebug("PORT : " + client.Port.ToString()); * GF.doDebug("USERNAME : "******"PASSWORD : "******"SSL : " + client.EnableSsl.ToString()); * * GF.doDebug("SETUP MESSAGE");*/ message = new MailMessage(from, to); message.Body = "System Error on " + GF.NOW() + Environment.NewLine; message.Body += Environment.NewLine; string[] lines = File.ReadAllLines(GF.path); foreach (string line in lines) { if (line.IndexOf("0x80004005") != -1 && (line.ToLower().IndexOf("превышен таймаут семафора") != -1 || line.ToLower().IndexOf("semaphore timeout period has expired") != -1)) { halt = true; break; } message.Body += line + Environment.NewLine; } if (halt) { message.Dispose(); client.Dispose(); return; } message.Body += Environment.NewLine; message.BodyEncoding = System.Text.Encoding.UTF8; message.Subject = "SMS ERROR !!"; message.SubjectEncoding = System.Text.Encoding.UTF8; GF.doDebug("SENDING E-MAIL"); client.SendCompleted += (ss, ee) => { GF.doDebug("E-MAIL SENT"); //MessageBox.Show("E-MAIL SENT !!"); Program.waitHandle.Set(); // CLEAN UP GF.doDebug("========== CLEAN UP ==========="); message.Dispose(); client.Dispose(); }; client.SendAsync(message, "SEND E-MAIL"); //client.Send(message); } catch (Exception ee) { MessageBox.Show(ee.Message, "SEND EMAIL ERROR"); } }