private void mnuServerStat_Click(object sender, EventArgs e) { Form t = Application.OpenForms["frmServerStatus"]; if (t == null) { Attendance.Forms.frmServerStatus m = new Attendance.Forms.frmServerStatus(); m.MdiParent = this; m.WindowState = FormWindowState.Maximized; m.Show(); } }
private void frmMain_Load(object sender, EventArgs e) { ToolStripItemCollection tmnu = menuStrip1.Items; SetToolStripItems(tmnu); mnuAdmin.Enabled = true; mnuConfig.Enabled = true; mnuMast.Enabled = true; mnuProfile.Enabled = true; mnuEmployee.Enabled = true; mnuMess.Enabled = true; mnuTranS.Enabled = true; mnuLeave.Enabled = true; mnuShift.Enabled = true; mnuSanction.Enabled = true; mnuData.Enabled = true; mnuCostCent.Enabled = true; mnuChangePass.Enabled = true; mnuLogOff.Enabled = true; DataSet ds = new DataSet(); string sql = "select menuname from MastFrm where formid in (select FormId from userRights where UserId ='" + Utils.User.GUserID + "' and View1=1) order by seqid"; ds = Utils.Helper.GetData(sql, cnstr); mnuUser.Enabled = true; Boolean hasRows = ds.Tables.Cast <DataTable>() .Any(table => table.Rows.Count != 0); if (hasRows) { foreach (DataRow dr in ds.Tables[0].Rows) { string mnu = dr["menuname"].ToString(); ToolStripItem[] t = tmnu.Find(mnu, true); foreach (ToolStripItem ti in t) { ti.Enabled = true; } } } this.mnuHelp.Enabled = true; this.mnuAbout.Enabled = true; this.mnuStatus.Enabled = true; this.mnuServerStat.Enabled = true; //Set GateInOutIP Globals.SetGateInOutIPList(); //set LunchInOutIP Globals.SetLunchInOutIPList(); //set waterip Globals.SetWaterIPList(); //set ShiftList Globals.SetShiftList(); //set global vars Globals.GetGlobalVars(); //get localmodification date string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string localfile = Uri.UnescapeDataString(uri.Path); if (IsNetworkPath(localfile)) { MessageBox.Show("Does not allow to run from remote location/shared folder..," + Environment.NewLine + "Please Copy to Local Drive and Run Again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } //here we can start Quartz if host is server if (Utils.User.GUserID == "SERVER") { Globals.G_myscheduler = new Scheduler(); mnuRFIDUser.Enabled = true; mnuDataDownload.Enabled = true; mnuDataProcess.Enabled = true; mnuAutoMailSender.Enabled = true; Form t = Application.OpenForms["frmServerStatus"]; if (t == null) { Attendance.Forms.frmServerStatus m = new Attendance.Forms.frmServerStatus(); m.MdiParent = this; m.WindowState = FormWindowState.Maximized; m.Show(); } Thread.Sleep(TimeSpan.FromSeconds(5)); Globals.G_myscheduler.Start(); //create triggers Globals.G_myscheduler.RegSchedule_AutoTimeSet(); Globals.G_myscheduler.RegSchedule_WorkerProcess(); Globals.G_myscheduler.RegSchedule_AutoArrival(); Globals.G_myscheduler.RegSchedule_AutoProcess(); Globals.G_myscheduler.RegSchedule_DownloadPunch(); Globals.G_myscheduler.RegSchedule_AutoMail(); } else { //check for update version. DateTime servermodified = new DateTime(); DateTime localmodified = new DateTime(); if (!string.IsNullOrEmpty(Globals.G_UpdateChkPath)) { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); using (UNCAccessWithCredentials unc = new UNCAccessWithCredentials()) { if (unc.NetUseWithCredentials(Globals.G_UpdateChkPath, Globals.G_NetworkUser, Globals.G_NetworkDomain, Globals.G_NetworkPass)) { string fullpath = Path.Combine(Globals.G_UpdateChkPath, "AttendanceOKH.exe"); if (File.Exists(fullpath)) { servermodified = File.GetLastWriteTime(fullpath); } } } localmodified = File.GetLastWriteTime(localfile); if (servermodified > localmodified) { MessageBox.Show("New Upgrade is available, please update", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } this.Cursor = Cursors.Default; } } }