private void frmEmployeeRecover_Load(object sender, EventArgs e) { try { clsISUtilities = new clsISUtilities(); clsDBConnectionObjects = new InteractPayroll.clsDBConnectionObjects(); } catch (Exception eException) { clsISUtilities.ErrorHandler(eException); } }
protected override void OnStart(string[] args) { try { WriteLog("### RunTimeAttenanceWinService OnStart Entered ###"); clsDBConnectionObjectsProcessRunQueue = new clsDBConnectionObjects(); clsDBConnectionObjectsProcessCloseQueue = new clsDBConnectionObjects(); clsDBConnectionObjectsProcessOpenRunQueue = new clsDBConnectionObjects(); clsDBConnectionObjectsProcessEmailPayslipQueue = new clsDBConnectionObjects(); tmrCheckToRunJobsTimer = new System.Timers.Timer(); tmrCheckToRunJobsTimer.Elapsed += ProcessRunQueue_Elapsed; //Every Second tmrCheckToRunJobsTimer.Interval = 1000; tmrCheckToRunJobsTimer.Start(); WriteLog("RunTimeAttenanceWinService tmrCheckToRunJobsTimer Started"); tmrCheckToRunCloseJobsTimer = new System.Timers.Timer(); tmrCheckToRunCloseJobsTimer.Elapsed += ProcessCloseRunQueue_Elapsed; //Every Second tmrCheckToRunCloseJobsTimer.Interval = 1000; tmrCheckToRunCloseJobsTimer.Start(); WriteLog("RunTimeAttenanceWinService tmrCheckToRunCloseJobsTimer Started"); tmrCheckToOpenJobsTimer = new System.Timers.Timer(); tmrCheckToOpenJobsTimer.Elapsed += ProcessOpenRunQueue_Elapsed; //Every Second tmrCheckToOpenJobsTimer.Interval = 1000; tmrCheckToOpenJobsTimer.Start(); WriteLog("RunTimeAttenanceWinService tmrCheckToOpenJobsTimer Started"); tmrCheckToEmailPayslipsJobsTimer = new System.Timers.Timer(); tmrCheckToEmailPayslipsJobsTimer.Elapsed += ProcessEmailPayslipQueue_Elapsed; //Every 2 Seconds tmrCheckToEmailPayslipsJobsTimer.Interval = 2000; tmrCheckToEmailPayslipsJobsTimer.Start(); WriteLog("RunTimeAttenanceWinService tmrCheckToEmailPayslipsJobsTimer Started"); } catch (Exception ex) { WriteExceptionErrorLog("@@@@@@@@@@@@@@@@@@@@ RunTimeAttenanceWinService OnStart FAILED @@@@@@@@@@@@@@@@@@@", ex); } }
private void frmCreateDBFromBackups_Load(object sender, EventArgs e) { try { clsDBConnectionObjects = new InteractPayroll.clsDBConnectionObjects(); clsISUtilities = new clsISUtilities(); iAmazonS3 = new AmazonS3Client(); this.lblFilesHeader.Paint += new System.Windows.Forms.PaintEventHandler(clsISUtilities.Label_Paint); pvtDataSet = new System.Data.DataSet(); strQry = new StringBuilder(); strQry.Clear(); strQry.AppendLine(" SELECT"); strQry.AppendLine(" BACKUP_DATABASE_PATH"); strQry.AppendLine(",BACKUP_GMAIL_ACCOUNT"); strQry.AppendLine(",BACKUP_GMAIL_PASSWORD"); strQry.AppendLine(",BACKUP_S3_BUCKET_NAME"); strQry.AppendLine(" FROM InteractPayroll.dbo.BACKUP_DATABASE_PATH"); clsDBConnectionObjects.Create_DataTable(strQry.ToString(), pvtDataSet, "Directory", -1); pvtstrFileDirectory = pvtDataSet.Tables["Directory"].Rows[0]["BACKUP_DATABASE_PATH"].ToString(); pvtstrEmail = pvtDataSet.Tables["Directory"].Rows[0]["BACKUP_GMAIL_ACCOUNT"].ToString(); pvtstrEmailPassword = pvtDataSet.Tables["Directory"].Rows[0]["BACKUP_GMAIL_PASSWORD"].ToString(); pvtstrBucketName = pvtDataSet.Tables["Directory"].Rows[0]["BACKUP_S3_BUCKET_NAME"].ToString(); strQry.Clear(); //Create Table For Compare to Remote Files (via Dataview) strQry.AppendLine(" SELECT"); strQry.AppendLine(" BACKUP_DATABASE_PATH AS LOCAL_FILE"); strQry.AppendLine(" FROM InteractPayroll.dbo.BACKUP_DATABASE_PATH"); strQry.AppendLine(" WHERE BACKUP_DATABASE_PATH = 'ZZZZ'"); clsDBConnectionObjects.Create_DataTable(strQry.ToString(), pvtDataSet, "LocalBackupFiles", -1); Get_Local_Backup_Files(); } catch (Exception ex) { } }
public Service() { InitializeComponent(); pvtstrLogFileName = ConfigurationManager.AppSettings["LogFileName"]; AppDomain.CurrentDomain.SetData("LogFileName", pvtstrLogFileName); pvtstrSmtpEmailAddressDescription = ConfigurationManager.AppSettings["SmtpEmailAddressDescription"]; AppDomain.CurrentDomain.SetData("SmtpEmailAddressDescription", pvtstrSmtpEmailAddressDescription); pvtstrSmtpEmailAddress = ConfigurationManager.AppSettings["SmtpEmailAddress"]; AppDomain.CurrentDomain.SetData("SmtpEmailAddress", pvtstrSmtpEmailAddress); pvtstrSmtpEmailAddressPassword = ConfigurationManager.AppSettings["SmtpEmailAddressPassword"]; AppDomain.CurrentDomain.SetData("SmtpEmailAddressPassword", pvtstrSmtpEmailAddressPassword); pvtstrSmtpHostName = ConfigurationManager.AppSettings["SmtpHostName"]; AppDomain.CurrentDomain.SetData("SmtpHostName", pvtstrSmtpHostName); pvtstrSmtpHostPort = ConfigurationManager.AppSettings["SmtpHostPort"]; AppDomain.CurrentDomain.SetData("SmtpHostPort", pvtstrSmtpHostPort); pvtstrEmailFolder = ConfigurationManager.AppSettings["EmailFolder"]; AppDomain.CurrentDomain.SetData("EmailFolder", pvtstrEmailFolder); pvtstrSmtpSysAdminEmailAddressFirstName = ConfigurationManager.AppSettings["SmtpSysAdminEmailAddressFirstName"]; AppDomain.CurrentDomain.SetData("SmtpSysAdminEmailAddressFirstName", pvtstrSmtpSysAdminEmailAddressFirstName); pvtstrSmtpSysAdminEmailAddressLastName = ConfigurationManager.AppSettings["SmtpSysAdminEmailAddressLastName"]; AppDomain.CurrentDomain.SetData("SmtpSysAdminEmailAddressLastName", pvtstrSmtpSysAdminEmailAddressLastName); pvtstrSmtpSysAdminEmailAddress = ConfigurationManager.AppSettings["SmtpSysAdminEmailAddress"]; AppDomain.CurrentDomain.SetData("SmtpSysAdminEmailAddress", pvtstrSmtpSysAdminEmailAddress); #if (DEBUG) //clsDBConnectionObjectsProcessOpenRunQueue = new clsDBConnectionObjects(); //ProcessOpenRunQueue(); //clsDBConnectionObjectsProcessCloseQueue = new clsDBConnectionObjects(); //ProcessCloseQueue(); //clsDBConnectionObjectsProcessRunQueue = new clsDBConnectionObjects(); //ProcessRunQueue(); clsDBConnectionObjectsProcessEmailPayslipQueue = new clsDBConnectionObjects(); ProcessEmailPayslipQueue(); #endif }
public busTimeAttendanceLogon() { clsDBConnectionObjects = new clsDBConnectionObjects(); clsCrc32 = new clsCrc32(); try { #if (DEBUG) #else //2017-05-10 Fix To Make Sure Databases are In Sync clsFixInteractPayrollClientDatabase clsFixInteractPayrollClientDatabase = new clsFixInteractPayrollClientDatabase(); clsFixInteractPayrollClientDatabase.Fix_Client_Database(); #endif } catch { } }
public busCalender() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busFileUpload() { clsDBConnectionObjects = new clsDBConnectionObjects(); clsCrc32 = new clsCrc32(); }
public busEmployeeGroup() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busPasswordReset() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public void RunBackupJob() { bool blnBackupCompletedSuccessful = false; string strEmail = ""; string strEmailPassword = ""; try { using (System.IO.StreamWriter file = new System.IO.StreamWriter(pvtstrLogFileDirectory + "DailyDBBackup_Info.txt", true)) { file.WriteLine("RunBackupJob ... " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } clsDBConnectionObjects = null; clsDBConnectionObjects = new InteractPayroll.clsDBConnectionObjects(); DataSet DataSet = new System.Data.DataSet(); StringBuilder strQry = new StringBuilder(); strQry.Clear(); strQry.AppendLine(" SELECT"); strQry.AppendLine(" BACKUP_DATABASE_PATH"); strQry.AppendLine(",BACKUP_GMAIL_ACCOUNT"); strQry.AppendLine(",BACKUP_GMAIL_PASSWORD"); strQry.AppendLine(",BACKUP_S3_BUCKET_NAME"); strQry.AppendLine(",BACKUP_DB_IND"); strQry.AppendLine(" FROM InteractPayroll.dbo.BACKUP_DATABASE_PATH"); clsDBConnectionObjects.Create_DataTable(strQry.ToString(), DataSet, "Directory", -1); string strFileDirectory = DataSet.Tables["Directory"].Rows[0]["BACKUP_DATABASE_PATH"].ToString(); strEmail = DataSet.Tables["Directory"].Rows[0]["BACKUP_GMAIL_ACCOUNT"].ToString(); strEmailPassword = DataSet.Tables["Directory"].Rows[0]["BACKUP_GMAIL_PASSWORD"].ToString(); pvtstrBucketName = DataSet.Tables["Directory"].Rows[0]["BACKUP_S3_BUCKET_NAME"].ToString(); string strDatabaseName = "InteractPayroll"; string strBackupFileName = strDatabaseName + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_Daily.bak"; //Move Files Offshore client = new AmazonS3Client(); string[] fileInteractPayrollPaths; FileInfo fileinfo; bool blnFound = false; if (DataSet.Tables["Directory"].Rows[0]["BACKUP_DB_IND"].ToString() == "Y" || DateTime.Now.DayOfWeek == DayOfWeek.Saturday) { //Backup InteractPayroll Master fileInteractPayrollPaths = Directory.GetFiles(@strFileDirectory, @"*InteractPayroll_" + DateTime.Now.ToString("yyyyMMdd") + "_*.bak"); if (fileInteractPayrollPaths.Length == 0) { strQry.Clear(); strQry.AppendLine("BACKUP DATABASE " + strDatabaseName + " TO DISK = '" + strFileDirectory + "\\" + strBackupFileName + "'"); clsDBConnectionObjects.Execute_SQLCommand(strQry.ToString(), -1); } strQry.Clear(); strQry.AppendLine(" UPDATE InteractPayroll.dbo.BACKUP_DATABASE_PATH"); strQry.AppendLine(" SET BACKUP_DB_IND = 'N'"); clsDBConnectionObjects.Execute_SQLCommand(strQry.ToString(), -1); } fileInteractPayrollPaths = Directory.GetFiles(@strFileDirectory, @"*InteractPayroll_" + DateTime.Now.ToString("yyyyMMdd") + "_*.bak"); if (fileInteractPayrollPaths.Length > 0) { fileinfo = new FileInfo(fileInteractPayrollPaths[0]); blnFound = FindFile(fileinfo.Name); if (blnFound == false) { #if (DEBUG) //Don't Want To Write Test DBs to Backup Bucket #else TransferUtilityUploadRequest fileTransferUtilityRequest = new TransferUtilityUploadRequest { BucketName = pvtstrBucketName, FilePath = fileInteractPayrollPaths[0] }; fileTransferUtilityRequest.Metadata.Add("fileName", fileinfo.Name); fileTransferUtilityRequest.Metadata.Add("fileDesc", fileinfo.Name); TransferUtility fileTransferUtility = new TransferUtility(client); fileTransferUtility.Upload(fileTransferUtilityRequest); #endif } } strQry.Clear(); strQry.AppendLine(" SELECT "); strQry.AppendLine(" COMPANY_NO "); strQry.AppendLine(" FROM InteractPayroll.dbo.COMPANY_LINK"); strQry.AppendLine(" WHERE BACKUP_DB_IND = 1"); clsDBConnectionObjects.Create_DataTable(strQry.ToString(), DataSet, "BackUpInfo", -1); //First Complete Todays Backups for (int intRow = 0; intRow < DataSet.Tables["BackUpInfo"].Rows.Count; intRow++) { strDatabaseName = "InteractPayroll_" + Convert.ToInt32(DataSet.Tables["BackUpInfo"].Rows[intRow]["COMPANY_NO"]).ToString("00000"); strBackupFileName = strDatabaseName + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_Daily.bak"; strQry.Clear(); strQry.AppendLine("BACKUP DATABASE " + strDatabaseName + " TO DISK = '" + strFileDirectory + "\\" + strBackupFileName + "'"); clsDBConnectionObjects.Execute_SQLCommand(strQry.ToString(), -1); strQry.Clear(); strQry.AppendLine(" UPDATE InteractPayroll.dbo.COMPANY_LINK"); strQry.AppendLine(" SET BACKUP_DB_IND = 0"); strQry.AppendLine(" WHERE COMPANY_NO = " + DataSet.Tables["BackUpInfo"].Rows[intRow]["COMPANY_NO"].ToString()); clsDBConnectionObjects.Execute_SQLCommand(strQry.ToString(), -1); string[] fileOldDBPaths = Directory.GetFiles(strFileDirectory, strDatabaseName + "_*_Daily.bak"); if (fileOldDBPaths.Length > 5) { //Delete Old Array.Sort(fileOldDBPaths); for (int intFileRow = 0; intFileRow < fileOldDBPaths.Length - 5; intFileRow++) { File.Delete(fileOldDBPaths[intFileRow]); } } } //Complete Todays Offsite DB Backups string[] fileTodaysPaths = Directory.GetFiles(@strFileDirectory, @"*_" + DateTime.Now.ToString("yyyyMMdd") + "*.bak"); if (fileTodaysPaths.Length > 0) { for (int intFileCount = 0; intFileCount < fileTodaysPaths.Length; intFileCount++) { fileinfo = new FileInfo(fileTodaysPaths[intFileCount]); blnFound = FindFile(fileinfo.Name); if (blnFound == false) { #if (DEBUG) //Don't Want To Write Test DBs to Backup Bucket #else TransferUtilityUploadRequest fileTransferUtilityRequest = new TransferUtilityUploadRequest { BucketName = pvtstrBucketName, FilePath = fileTodaysPaths[intFileCount] }; //LifecycleConfiguration a = new LifecycleConfiguration(); fileTransferUtilityRequest.Metadata.Add("fileName", fileinfo.Name); fileTransferUtilityRequest.Metadata.Add("fileDesc", fileinfo.Name); /////fileTransferUtilityRequest.Metadata.Add("expires","Tue, 16 Feb 2016 16:00:00 GMT"); TransferUtility fileTransferUtility = new TransferUtility(client); fileTransferUtility.Upload(fileTransferUtilityRequest); #endif } } } //Check Yesterdays DB Backups string[] fileYesterdaysPaths = Directory.GetFiles(@strFileDirectory, @"*_" + DateTime.Now.AddDays(-1).ToString("yyyyMMdd") + "*.bak"); if (fileYesterdaysPaths.Length > 0) { for (int intFileCount = 0; intFileCount < fileYesterdaysPaths.Length; intFileCount++) { fileinfo = new FileInfo(fileYesterdaysPaths[intFileCount]); blnFound = FindFile(fileinfo.Name); if (blnFound == false) { #if (DEBUG) //Don't Want To Write Test DBs to Backup Bucket #else TransferUtilityUploadRequest fileTransferUtilityRequest = new TransferUtilityUploadRequest { BucketName = pvtstrBucketName, FilePath = fileYesterdaysPaths[intFileCount] }; fileTransferUtilityRequest.Metadata.Add("fileName", fileinfo.Name); fileTransferUtilityRequest.Metadata.Add("fileDesc", fileinfo.Name); TransferUtility fileTransferUtility = new TransferUtility(client); fileTransferUtility.Upload(fileTransferUtilityRequest); #endif } } } bool blnFirstPass = true; string[] fileOldDaysPaths; RunBackupJob_Continue: if (blnFirstPass == true) { //Clean Up Old Backups Older than 1 Month Old fileOldDaysPaths = Directory.GetFiles(@strFileDirectory, @"*_" + DateTime.Now.AddMonths(-1).ToString("yyyyMM") + "*.bak"); } else { fileOldDaysPaths = Directory.GetFiles(@strFileDirectory, @"*_" + DateTime.Now.AddMonths(-2).ToString("yyyyMM") + "*.bak"); } foreach (string file in fileOldDaysPaths) { int intOffset = file.IndexOf("InteractPayroll_"); if (intOffset > -1) { if (file.Length > intOffset + 30) { try { //Client Databases DateTime myFileDateTime = DateTime.ParseExact(file.Substring(intOffset + 22, 8), "yyyyMMdd", null).AddMonths(1); if (myFileDateTime < DateTime.Now) { File.Delete(file); } } catch { //InteractPayroll Master try { DateTime myFileDateTime = DateTime.ParseExact(file.Substring(intOffset + 16, 8), "yyyyMMdd", null).AddMonths(1); if (myFileDateTime < DateTime.Now) { File.Delete(file); } } catch { } } } } } if (blnFirstPass == true) { blnFirstPass = false; goto RunBackupJob_Continue; } strQry.Clear(); strQry.AppendLine(" UPDATE InteractPayroll.dbo.BACKUP_DATABASE_PATH"); strQry.AppendLine(" SET BACKUP_LAST_DATETIME = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'"); clsDBConnectionObjects.Execute_SQLCommand(strQry.ToString(), -1); blnBackupCompletedSuccessful = true; } catch (Exception ex) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(pvtstrLogFileDirectory + "DailyDBBackup_Error.txt", true)) { file.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Error = " + ex.Message); } } finally { using (System.IO.StreamWriter file = new System.IO.StreamWriter(pvtstrLogFileDirectory + "DailyDBBackup_Info.txt", true)) { file.WriteLine("RunBackupJob Setting Timer ... " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } //Set Next Time for Timer to Fire double tickTime = Calculate_Next_Time_Timer_Fires(blnBackupCompletedSuccessful); tmrTimer.Interval = tickTime; tmrTimer.Start(); if (client != null) { client.Dispose(); client = null; } if (blnBackupCompletedSuccessful == true || DateTime.Now.Hour == 7) { var smtp = new SmtpClient(); try { //Email var fromAddress = new MailAddress(strEmail, "DB Backup Server"); var toAddress = new MailAddress(strEmail, "Errol Le Roux"); string subject = "Daily DB Backups - " + DateTime.Now.ToString("dd MMMM yyyy"); string body = "Backup Successful"; if (blnBackupCompletedSuccessful == false) { body = "Backup UNSUCCESSFUL"; } smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(fromAddress.Address, strEmailPassword); var message = new MailMessage(fromAddress, toAddress); message.Subject = subject; message.Body = body; smtp.Send(message); using (System.IO.StreamWriter file = new System.IO.StreamWriter(pvtstrLogFileDirectory + "DailyDBBackup_Info.txt", true)) { file.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Email Sent Successfully"); } } catch (Exception ex) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(pvtstrLogFileDirectory + "DailyDBBackup_Error.txt", true)) { file.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Email Error = " + ex.Message); } } finally { smtp.Dispose(); smtp = null; } } } }
public busUserEmployeeLink() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busFix() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busUserMenuAccess() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busEmployeeLeaveTakeOn() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busPayrollHelp() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busShiftSchedule() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busBackupRestoreClientDatabase() { clsDBConnectionObjects = new clsDBConnectionObjects(); clsCrc32 = new clsCrc32(); }
public busClock() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busLeaveProcess() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busDateLoad() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busLeaveAuthorisation() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busRptTimeSheetTotals() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busValiditeClockingsSyncViaDB() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busPayrollMain() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busNormalSickLeave() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busConvertEmployeeType() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busRptLeaveTimeSheet() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busPasswordChange() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busClientDataUpload() { clsDBConnectionObjects = new clsDBConnectionObjects(); }
public busDeduction() { clsDBConnectionObjects = new clsDBConnectionObjects(); }