Пример #1
0
 protected void ddlReportList_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         chkIndividual.Checked = false;
         chkDirector.Checked   = false;
         chkOptional.Checked   = false;
         MailSetupList         = manager.GetAllMailSetup(Convert.ToInt32(ddlReportList.SelectedValue));
         API.DAO.MailSetup masterInfo = MailSetupList.Find(f => f.IsIndividual || f.IsDirector || f.IsOptional || f.Subject.IsNotNullOrEmpty() || f.FileName.IsNotNullOrEmpty() || f.Body.IsNotNullOrEmpty());
         if (masterInfo.IsNotNull())
         {
             chkIndividual.Checked = masterInfo.IsIndividual;
             chkDirector.Checked   = masterInfo.IsDirector;
             chkOptional.Checked   = masterInfo.IsOptional;
             txtSubject.Text       = masterInfo.Subject;
             txtFileName.Text      = masterInfo.FileName;
             txtBody.Text          = masterInfo.Body;
             chkSubject.Checked    = masterInfo.IsSubjectYM;
             chkFileName.Checked   = masterInfo.IsFileNameYM;
         }
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
Пример #2
0
        protected void btnEmail_Click(object sender, EventArgs e)
        {
            try
            {
                string    checkedRequiredField = "";
                DataTable dt           = new DataTable();
                string    subject      = "";
                string    fileName     = "";
                string    body         = "";
                Boolean   isSubjectYM  = false;
                Boolean   isFileNameYM = false;
                errorList = new CustomList <ErrorList>();
                MailSetupManager       manager   = new MailSetupManager();
                CustomList <MailSetup> mailSetup = manager.GetAllMailSetup(Convert.ToInt32(Session["ReportID"]));
                MailSetup mS = mailSetup.Find(f => f.Subject.IsNotNullOrEmpty());
                if (mS.IsNull())
                {
                    return;
                }
                else
                {
                    subject      = mS.Subject;
                    fileName     = mS.FileName;
                    body         = mS.Body;
                    isSubjectYM  = mS.IsSubjectYM;
                    isFileNameYM = mS.IsFileNameYM;
                }
                #region
                if (isSubjectYM)
                {
                    FilterSets month         = FilterSetList.Find(f => f.ColumnName == "MonthNo");
                    FilterSets year          = FilterSetList.Find(f => f.ColumnName == "YearNo");
                    string     monthYearName = "";
                    if (month.IsNotNull())
                    {
                        monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month.ColumnActualValue.ToInt()).Substring(0, 3) + "' " + year.ColumnActualValue.Substring(2, 2);
                    }

                    if (monthYearName == "")
                    {
                        FilterSets fromDate = FilterSetList.Find(f => f.ColumnName == "FromDate");
                        if (fromDate.IsNotNull())
                        {
                            monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(fromDate.ColumnValue.Substring(0, 2).ToInt()).Substring(0, 3) + "' " + fromDate.ColumnValue.Substring(8, 2);
                        }
                    }
                    if (monthYearName == "")
                    {
                        FilterSets workDate = FilterSetList.Find(f => f.ColumnName == "Workdate");
                        if (workDate.IsNotNull())
                        {
                            monthYearName = Convert.ToDateTime(workDate.ColumnValue).ToString("dd MMM yy");
                        }
                    }
                    subject = subject + "_" + monthYearName;
                }
                if (isFileNameYM)
                {
                    FilterSets month         = FilterSetList.Find(f => f.ColumnName == "MonthNo");
                    FilterSets year          = FilterSetList.Find(f => f.ColumnName == "YearNo");
                    string     monthYearName = "";
                    if (month.IsNotNull())
                    {
                        monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month.ColumnActualValue.ToInt()).Substring(0, 3) + "' " + year.ColumnActualValue.Substring(2, 2);
                    }

                    if (monthYearName == "")
                    {
                        FilterSets fromDate = FilterSetList.Find(f => f.ColumnName == "FromDate");
                        if (fromDate.IsNotNull())
                        {
                            monthYearName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(fromDate.ColumnValue.Substring(0, 2).ToInt()).Substring(0, 3) + "' " + fromDate.ColumnValue.Substring(8, 2);
                        }
                    }
                    if (monthYearName == "")
                    {
                        FilterSets workDate = FilterSetList.Find(f => f.ColumnName == "Workdate");
                        if (workDate.IsNotNull())
                        {
                            monthYearName = Convert.ToDateTime(workDate.ColumnValue).ToString("dd MMM yy");
                        }
                    }
                    fileName = fileName + "_" + monthYearName;
                }
                string    reportPath = Session["reportPath"].ToString();
                DataTable dt1        = new DataTable();
                if (!mS.IsIndividual)
                {
                    Report.LoadSourceDataSet(ref checkedRequiredField, ref dt1);
                }
                FilterSets empCode = FilterSetList.Find(f => f.ColumnName == "EmpCode");
                if (empCode.ColumnActualValue.IsNotNullOrEmpty())
                {
                    mailSetup = mailSetup.FindAll(f => f.EmpKey.ToString() == empCode.ColumnActualValue);
                }
                #endregion
                foreach (MailSetup m in mailSetup)
                {
                    //if (mS.IsIndividual)
                    //    Report.LoadSourceDataSet(m.EmpKey.ToString(), ref dt1);

                    //SentEmail sm = new SentEmail();
                    //string message = sm.EmailUtil(m.EmailAddress, reportPath, dt1, "", subject, fileName, body);
                    //if (message.IsNotNullOrEmpty())
                    //{
                    //    ErrorList eL = new ErrorList();
                    //    eL.EmpName = m.EmpName.Trim();
                    //    eL.Error = message;
                    //    errorList.Add(eL);
                    //}
                }
                ((PageBase)this.Page).SuccessMessage = "Mail sent successfully!";
            }
            catch (Exception ex)
            {
                ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }