示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        private void caUploadandSendingMail_ExecuteCode(object sender, EventArgs e)
        {
            AbsentListBOL objAbsentListBOL = new  AbsentListBOL();
            string        strFrom = "", SMTPServer = "";
            DateTime      dtLastUsed = DateTime.Now;

            try
            {
                DataSet dsAbsentListBOL = objAbsentListBOL.GetLeaveUploadEmployeeList();

                for (int k = 0; k < dsAbsentListBOL.Tables[0].Rows.Count; k++)
                {
                    if (dsAbsentListBOL.Tables[0].Rows[k]["ConfigItemName"].ToString() == "From EmailID")
                    {
                        strFrom = dsAbsentListBOL.Tables[0].Rows[k]["ConfigItemValue"].ToString();
                    }
                    if (dsAbsentListBOL.Tables[0].Rows[k]["ConfigItemName"].ToString() == "Lock Upload Date")
                    {
                        dtLastUsed = Convert.ToDateTime(dsAbsentListBOL.Tables[0].Rows[k]["ConfigItemValue"].ToString());
                    }
                    if (dsAbsentListBOL.Tables[0].Rows[k]["ConfigItemName"].ToString() == "Mail Server Name")
                    {
                        SMTPServer = dsAbsentListBOL.Tables[0].Rows[k]["ConfigItemValue"].ToString();
                    }
                }

                if (dsAbsentListBOL.Tables.Count > 1)
                {
                    for (int j = 0; j < dsAbsentListBOL.Tables[1].Rows.Count; j++)
                    {
                        if (dsAbsentListBOL.Tables[1].Rows[j]["EmailTemplateName"].ToString() == "Leave Upload")
                        {
                            for (int i = 0; i < dsAbsentListBOL.Tables[3].Rows.Count; i++)
                            {
                                MailMessage objMailMessage = new MailMessage();

                                objMailMessage.From    = strFrom;                                                         //new MailAddress(strFrom) ;
                                objMailMessage.To      = dsAbsentListBOL.Tables[3].Rows[i]["EmployeeEmailID"].ToString(); //.Add(new MailAddress(dsAbsentListBOL.Tables[0].Rows[i]["EmployeeEmailID"].ToString()));
                                objMailMessage.Subject = dsAbsentListBOL.Tables[1].Rows[j]["EmailSubject"].ToString();
                                objMailMessage.Body    = dsAbsentListBOL.Tables[1].Rows[j]["EmailBody"].ToString();
                                objMailMessage.Subject = Regex.Replace(objMailMessage.Subject, "##Month##", dsAbsentListBOL.Tables[2].Rows[0]["Month"].ToString());
                                objMailMessage.Subject = Regex.Replace(objMailMessage.Subject, "##Year##", dsAbsentListBOL.Tables[2].Rows[0]["Year"].ToString());
                                objMailMessage.Body    = Regex.Replace(objMailMessage.Body, " ##EmployeeName##", dsAbsentListBOL.Tables[3].Rows[i]["EmployeeName"].ToString());

                                objMailMessage.Body = Regex.Replace(objMailMessage.Body, "##Month##", dsAbsentListBOL.Tables[2].Rows[0]["Month"].ToString());
                                objMailMessage.Body = Regex.Replace(objMailMessage.Body, "##Year##", dsAbsentListBOL.Tables[2].Rows[0]["Year"].ToString());

                                objMailMessage.BodyFormat = MailFormat.Html;

                                //SmtpClient sc=new SmtpClient();
                                //sc.Host=SMTPServer;
                                // sc.Send(objMailMessage);
                                objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0");
                                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);
                            }
                        }
                    }
                }

                dtLastUsed = dtLastUsed.AddMonths(1);
                int day = dtLastUsed.Day;
                dtLastUsed = dtLastUsed.AddDays(-(day - 1));
                string strdate = dtLastUsed.ToShortDateString() + " 00:00:00";
                dtLastUsed = Convert.ToDateTime(strdate);
                TimeSpan tsDelay = dtLastUsed.Subtract(DateTime.Now);
                daTimeOut.TimeoutDuration = tsDelay;
            }
            catch (V2Exceptions ex)
            {
                throw;
            }

            catch (System.Exception ex)
            {
                FileLog objFileLog = FileLog.GetLogger();
                objFileLog.WriteLine(LogType.Error, ex.Message, "LeaveUpLoadWF.cs", "caUploadandSendingMail_ExecuteCode", ex.StackTrace);
                throw new V2Exceptions(ex.ToString(), ex);
            }



            #region Not Required Code

            //catch(System.Data.SqlClient.SqlException ex)
            //{
            //    FileLog objFileLog = FileLog.GetLogger();
            //    objFileLog.WriteLine(LogType.Error, ex.Message, "LeaveUpLoadWF.cs", "caUploadandSendingMail_ExecuteCode", ex.StackTrace);
            //    throw new V2Exceptions(ex.ToString(),ex);


            //}

            //for(int k=0;k<dsAbsentListBOL.Tables[3].Rows.Count;k++)
            //{
            //    if(dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemName"].ToString()=="Lock Upload Date")
            //    {
            //        DateTime dtLock=Convert.ToDateTime( dsAbsentListBOL.Tables[3].Rows[k]["ConfigItemValue"].ToString());

            //        if(dtLock.Month==DateTime.Now.Month)
            //        {
            //            booLock=true;
            //            break;
            //        }

            //    }
            //}

            #endregion
        }