private void metroButton_next_Click(object sender, EventArgs e) { try { if (_mysession != null) { if (!textBox_password.Text.Trim().Equals("")) { if (textBox_password.Text.Equals(MiscClass.GetMiscValue("AdminPassword"))) { CurrentlyActive ca = new CurrentlyActive(_mainwindow, _commandcontrol, this, _mysession); ca.Show(); } else { MessageBox.Show("Password is incorrect !.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Password cannot be empty/spaces.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (!textBox_password.Text.Trim().Equals("")) { if (textBox_password.Text.Equals(MiscClass.GetMiscValue("AdminPassword"))) { _lockwindow.server.Stop(); _lockwindow.backgroundWorker1.CancelAsync(); //_lockwindow.backgroundWorker_processviewer.CancelAsync(); _lockwindow.Close(); _mainwindow.Visible = true; _mainwindow.ShowInTaskbar = true; this.Close(); } else { MessageBox.Show("Password is incorrect !.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Password cannot be empty/spaces.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void timer1_Tick(object sender, EventArgs e) { hour = Convert.ToInt32(label_hour.Text); min = Convert.ToInt32(label_minute.Text); sec = Convert.ToInt32(label_second.Text); if (min == 59 && sec == 59) { label_hour.Text = (hour + 1).ToString("00"); label_minute.Text = "00"; label_second.Text = "00"; min = 0; sec = 0; isenter = true; } else if (sec == 59) { label_minute.Text = (min + 1).ToString("00"); label_second.Text = "00"; sec = 0; isenter = true; } else { isenter = false; } if (!isenter) { label_second.Text = (sec + 1).ToString("00"); } if (isdisconnect) { try { // close the form on the forms thread LockWindow lw = new LockWindow(mycomputer, mainwind); lw.Show(); server.Stop(); backgroundWorker1.CancelAsync(); MiscClass.SetConfigValue("ActiveSession", mysession.Id.ToString() + "{{Session}}" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } label_pagesprinted_value.Text = pagescount; }
private void metroButton_redeem_Click(object sender, EventArgs e) { if (metroTextBox_accesscode.Text.Trim().Length == 4) { try { if (MiscClass.CheckNetworkAvailablity(tw.adapter_public, tw.ip_public)) { if (!MiscClass.GetConfigValue("ActiveSession").Equals("")) { string[] values = MiscClass.GetConfigValue("ActiveSession").Split(new string[] { "{{Session}}" }, StringSplitOptions.None); if (Session.PauseSession_CloseUnexpectedly(values[0], values[1])) { MiscClass.SetConfigValue("ActiveSession", ""); } } metroTextBox_accesscode.Enabled = false; metroButton_redeem.Enabled = false; var sessionobject = Session.GetNonClosedSession(mypc.Id, metroTextBox_accesscode.Text.Trim()); if (sessionobject.StartSession("Session Start By User", null)) { CommandControl cc = new CommandControl(sessionobject, mypc, tw, gkh); server.Stop(); backgroundWorker1.CancelAsync(); cc.Show(); this.Close(); } else { MessageBox.Show("Some thing went wrong while starting your session !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { metroTextBox_accesscode.Enabled = true; metroButton_redeem.Enabled = true; } } else { MessageBox.Show("Access code should be 4 characters long.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void UpdatePrintLog() { if (File.Exists(MiscClass.GetConfigValue("LogPath") + "\\papercut-print-log-" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv")) { dtdata.Rows.Clear(); File.Copy(MiscClass.GetConfigValue("LogPath") + "\\papercut-print-log-" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv", MiscClass.GetConfigValue("LogPath") + "\\papercut-print-log-" + DateTime.Now.ToString("yyyy-MM-dd") + " - Copy.csv", true); if (MiscClass.IsFileLocked(MiscClass.GetConfigValue("LogPath") + "\\papercut-print-log-" + DateTime.Now.ToString("yyyy-MM-dd") + " - Copy.csv")) { return; } try { using (TextReader reader = File.OpenText(MiscClass.GetConfigValue("LogPath") + "\\papercut-print-log-" + DateTime.Now.ToString("yyyy-MM-dd") + " - Copy.csv")) { reader.ReadLine(); // now initialize the CsvReader var parser = new CsvReader(new StringReader(reader.ReadToEnd())); // ... while (parser.Read()) { if (parser.GetField <DateTime>(0).CompareTo(latestlogintime) >= 0) { dr = dtdata.NewRow(); dr["Time"] = parser.GetField <DateTime>(0); dr["User"] = parser.GetField <string>(1); dr["Pages"] = parser.GetField <int>(2); dr["Copies"] = parser.GetField <int>(3); dr["Printer"] = parser.GetField <string>(4); dr["DocumentName"] = parser.GetField <string>(5); dr["Client"] = parser.GetField <string>(6); dr["PaperSize"] = parser.GetField <string>(7); dr["Language"] = parser.GetField <string>(8); dr["Height"] = parser.GetField <string>(9); dr["Width"] = parser.GetField <string>(10); dr["Duplex"] = parser.GetField <string>(11); dr["Grayscale"] = parser.GetField <string>(12); dr["Size"] = parser.GetField <string>(13); dtdata.Rows.Add(dr); } } } pagescount = PrintJob.DumpJobsToDatabase(mysession.Id, mycomputer.Id, dtdata); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void button_start_Click(object sender, EventArgs e) { try { if (pc != null) { if (MiscClass.CheckNetworkAvailablity(adapter_public, ip_public)) { if (checkBox_monitorprocess.Checked) { is_monitorable_public = "Yes"; } else { is_monitorable_public = "No"; } if (!GetConfigValue("LogPath").Equals("")) { if (Directory.Exists(GetConfigValue("LogPath"))) { LockWindow lw = new LockWindow(pc, this); lw.Show(); this.Visible = false; this.ShowInTaskbar = false; } else { MessageBox.Show("LogPath directory is not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("LogPath is not set.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }