private void caCheckandSendMail_ExecuteCode(object sender, EventArgs e) { AbsentListBOL objAbsentListBOL = new AbsentListBOL(); try { DataSet dsAbsentListBOL = objAbsentListBOL.GetAbsentList(); if (dsAbsentListBOL != null) { for (int i = 0; i < dsAbsentListBOL.Tables[0].Rows.Count; i++) { DateTime dtFrom = Convert.ToDateTime(dsAbsentListBOL.Tables[0].Rows[i]["SignInDate"].ToString()); if (dtFrom.DayOfWeek.ToString() != "Saturday" && dtFrom.DayOfWeek.ToString() != "Sunday") { bool IsHoliday = false; for (int j = 0; j < dsAbsentListBOL.Tables[2].Rows.Count; j++) { if (dsAbsentListBOL.Tables[2].Rows[j]["HolidayDate"].ToString() == dtFrom.Date.ToString()) { IsHoliday = true; break; } } if (!IsHoliday) { MailMessage objMailMessage = new MailMessage(); objMailMessage.From = "*****@*****.**"; objMailMessage.To = dsAbsentListBOL.Tables[0].Rows[i]["EmployeeEmailID"].ToString(); // objMailMessage.To="*****@*****.**"; //string strSubject= objMailMessage.Subject = dsAbsentListBOL.Tables[1].Rows[0]["EmailSubject"].ToString(); // objMailMessage.BodyFormat = MailFormat.Html; //objMailMessage.Body=dsAbsentListBOL.Tables["EmailTemplates"].Rows[0]["EmployeeEmailID"].ToString(); // objMailMessage.BodyFormat = MailFormat.Html; //objMailMessage.Body = mailMessage; string strBody = "Hi ##EmployeeName##" + " \n\n" + "It is observed that there was no Orbit Sign-In / Sign-Out for you on ##SignInDate##," + " \n" + "so if you are present for the day and forgot to login, please do the manual entry for the same." + " \n\n" + "It is absorved that you have Leave Balance so apply for Leave" + " \n\n" + "If you were on approved leave please fill the leave application form and send it to your reporting head." + " \n\n" + "As the salary is being processed based on the Orbit SignIn Approved entries it is necessary to do the same on daily basis."; strBody = Regex.Replace(strBody, "##EmployeeName##", dsAbsentListBOL.Tables[0].Rows[i]["EmployeeName"].ToString()); objMailMessage.Body = Regex.Replace(strBody, "##SignInDate##", dsAbsentListBOL.Tables[0].Rows[i]["SignInDate"].ToString()); //SmtpMail.SmtpServer="192.168.8.10"; //System.Configuration.ConfigurationManager.AppSettings["SMTPServer"].ToString(); SmtpMail.Send(objMailMessage); } } break; } //DateTime dttomorrow=DateTime.Now. daOnTimeAbsentLeave.TimeoutDuration = new TimeSpan(0, 5, 0); } } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "LeaveAbsentCheckWF.cs", "caCheckandSendMail_ExecuteCode", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
private void caCheckAttendance_ExecuteCode(object sender, EventArgs e) { AbsentListBOL objAbsentListBOL = new AbsentListBOL(); //string strFrom=""; //string strDelayTime=""; //string SMTPServer=""; try { DataSet dsAbsentListBOL = objAbsentListBOL.GetAbsentList(); if (dsAbsentListBOL != null) { for (int k = 0; k < dsAbsentListBOL.Tables[3].Rows.Count; k++) { if (dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemName"].ToString() == "Check Attendance Time") { strDelayTime = dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemValue"].ToString(); } if (dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemName"].ToString() == "From EmailID") { strFrom = dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemValue"].ToString(); } if (dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemName"].ToString() == "Mail Server Name") { SMTPServer = dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemValue"].ToString(); } } bool IsHoliday = false; for (int j = 0; j < dsAbsentListBOL.Tables[2].Rows.Count; j++) { DateTime dtHoliday = Convert.ToDateTime(dsAbsentListBOL.Tables[2].Rows[j]["HolidayDate"].ToString()); if (dtHoliday.Date.ToShortDateString() == DateTime.Now.ToShortDateString()) { IsHoliday = true; break; } } if (!IsHoliday) { if (DateTime.Now.DayOfWeek.ToString() != "Saturday" && DateTime.Now.DayOfWeek.ToString() != "Sunday") { for (int i = 0; i < dsAbsentListBOL.Tables[0].Rows.Count; i++) { //DateTime dtFrom=Convert.ToDateTime(dsAbsentListBOL.Tables[0].Rows[i]["SignInDate"].ToString()); MailMessage objMailMessage = new MailMessage(); objMailMessage.BodyFormat = MailFormat.Html; objMailMessage.From = strFrom; //"*****@*****.**" objMailMessage.To = dsAbsentListBOL.Tables[0].Rows[i]["EmployeeEmailID"].ToString(); //objMailMessage.To="*****@*****.**"; objMailMessage.Subject = dsAbsentListBOL.Tables[1].Rows[0]["EmailSubject"].ToString(); string strBody = dsAbsentListBOL.Tables[1].Rows[0]["EmailBody"].ToString(); strBody = Regex.Replace(strBody, "##EmployeeName##", dsAbsentListBOL.Tables[0].Rows[i]["EmployeeName"].ToString()); strBody = Regex.Replace(strBody, "##Environment##", Environment.NewLine); objMailMessage.Body = Regex.Replace(strBody, "##SignInDate##", dsAbsentListBOL.Tables[0].Rows[i]["SignInDate"].ToString()); //SmtpClient sc=new SmtpClient(); // sc.Host=SMTPServer; //sc.Send(objMailMessage); objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "v2system"); objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "mail_123"); SmtpMail.SmtpServer = SMTPServer; //System.Configuration.ConfigurationManager.AppSettings["SMTPServer"].ToString(); SmtpMail.Send(objMailMessage); } } } string strdate = "";//=DateTime.Now.ToShortDateString() +" " +strDelayTime+":00" DateTime dttemp = DateTime.Now; dttemp = dttemp.AddDays(1); strdate = dttemp.ToShortDateString() + " " + strDelayTime + ":00"; dttemp = Convert.ToDateTime(strdate); TimeSpan tsDelay = dttemp.Subtract(DateTime.Now); daCheckAttendance.TimeoutDuration = tsDelay; } } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "AttendanceWF.cs", "caCheckAttendance_ExecuteCode", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }