private void timer_1_sec_Tick(object sender, EventArgs e) { if (!tempLogoffStatus) { if (ProgramData.tempSessionLimit == 0) { if (saveData.sessionLimit != 0) { label_sessionTimeLeft.Text = CalcTimeLeft(saveData); if (DateTime.Now > ProgramData.startTime.AddMinutes(saveData.sessionLimit)) { tempLogoffStatus = true; SqlMethods.writeToPointsLog("has been forced to log off."); WindowsCommandOverrides.WindowsLogOff(); } } } else { label_sessionTimeLeft.Text = CalcTimeLeft(saveData); if (DateTime.Now > ProgramData.startTime.AddMinutes(ProgramData.tempSessionLimit)) { tempLogoffStatus = true; SqlMethods.writeToPointsLog("has been forced to log off."); WindowsCommandOverrides.WindowsLogOff(); } } } }
//private SaveData getSaveDataFromFile() //{ // SaveData result = new SaveData(); // if (!File.Exists(ProgramData.settingsPath)) // file does not exist // { // if (!Directory.Exists(ProgramData.folderPath)) // { // file and folder do not exist // Directory.CreateDirectory(ProgramData.folderPath); // create the folder // // more operations, like creating the file and saving the struct // StructMethods.SaveData(ProgramData.settingsPath, saveData); // create the file with default struct // GrantAccess(ProgramData.settingsPath); // grant full access to the built in users group // } // else // file does not exist but folder exists // { // StructMethods.SaveData(ProgramData.settingsPath, saveData); // create the file with default struct // GrantAccess(ProgramData.settingsPath); // grant full access to the built in users group // } // } // else if (File.Exists(ProgramData.settingsPath)) // file exists, then lets load it in // { // using (var tw = new StreamWriter(ProgramData.settingsPath, true)) // { // // load the struct // result = (SaveData)StructMethods.LoadData(ProgramData.settingsPath); // loads the struct // } // } // return result; //} private void button_Logoff_Click(object sender, EventArgs e) { SqlMethods.writeToPointsLog("has clicked log off."); WindowsCommandOverrides.WindowsLogOff(); }