public void SendEmail_AcceptEditRequestByPTT(List <int> lstSubFacility, int nIndID, int nYear, int nQuarter, string sComment)
        {
            string sMsg = @"Dear All, <br />" +
                          "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Environmental Report has been accepted request edit by ptt as detailed below.<br />" +
                          "Facility : {0}<br />" +
                          "Group Indicator : {1}<br />" +
                          "Year : {2}<br />" +
                          "Quarter : {3}<br /><br />" +
                          "Comment : {4}<br /><br />" +
                          "Click <a href='{5}' target='_blank'>link</a> to view for further action.";
            var    dataFac    = db.mTFacility.Where(w => w.cDel == "N" && w.cActive == "Y" && w.nLevel == 2 && lstSubFacility.Contains(w.ID)).ToList();
            string strFacName = String.Join(", ", dataFac.Select(s => s.Name).OrderBy(o => o).ToList());
            var    dataInd    = db.mTIndicator.FirstOrDefault(w => w.ID == nIndID);

            string _sUrl      = sUrlWebSite + "AD/loginAD.aspx";
            string sFrom      = System.Configuration.ConfigurationSettings.AppSettings["SystemMail"] + "";
            var    dataToUser = (from d in db.mTWorkFlow.Where(w => w.IDIndicator == nIndID && lstSubFacility.Contains(w.IDFac))
                                 from u in db.mTUser.Where(w => w.cDel == "N" && w.cActive == "Y" && w.ID == d.L2)
                                 select new
            {
                u.Email
            }).GroupBy(g => g.Email).Select(s => s.Key).ToList();
            string strTo    = String.Join(",", dataToUser);
            string sMsgSend = string.Format(sMsg, strFacName, (dataInd != null ? dataInd.Indicator : ""), nYear, nQuarter, sComment, _sUrl);
            string sSubject = string.Format("Accepted request edit by ptt of {0} of quarter {1} {2} ", (dataInd != null ? dataInd.Indicator : ""), nQuarter, nYear); // 0 = Group Indicator,1=Quater,2=Year

            Workflow.DataMail_log Log = new Workflow.DataMail_log();
            Log = SystemFunction.SendMailAll(sFrom, strTo, "", "", sSubject, sMsgSend, "");
            new Workflow().SaveLogMail(Log);
        }
Пример #2
0
    public static sysGlobalClass.CResutlWebMethod ForgetPassword(string sEmail, string sUsername)
    {
        PTTGC_EPIEntities db = new PTTGC_EPIEntities();

        sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod();
        sEmail    = sEmail.ToLower();
        sUsername = sUsername.ToLower();

        var lstUser = db.mTUser.Where(w => w.cActive == "Y" && w.cDel == "N" && w.Username.ToLower() == sUsername && w.Email.ToLower() == sEmail).ToList();

        if (lstUser.Any())
        {
            var Data = lstUser.First();

            string sTitle  = "";
            string sText   = "";
            string subject = "";
            string message = "";
            string sURL    = "";
            string sFoot   = "";// "Should you have any questions about RD&T work process.";

            // sURL = Applicationpath + "login_forget.aspx?str=" + SystemFunction.Encrypt_UrlEncrypt(nDocID + "");

            subject = "Password Confirmation | " + SystemFunction.SystemName + "";

            sText += "<p>Your password is " + STCrypt.Decrypt(Data.PasswordEncrypt) + "</p>";

            string From = SystemFunction.GetSystemMail;
            string To   = Data.Email;
            message = string.Format(GET_TemplateEmail(),
                                    "Dear " + Data.Firstname + ' ' + Data.Lastname,
                                    sText,
                                    sURL,
                                    sFoot,
                                    "",
                                    "");
            Workflow.DataMail_log log = new Workflow.DataMail_log();
            log           = SystemFunction.SendMailAll(From, To, "", "", subject, message, "");
            log.nDataID   = SystemFunction.GetIntNullToZero(Data.ID + "");
            log.sPageName = "login.aspx";
            new Workflow().SaveLogMail(log);
            if (log.bStatus)
            {
                result.Status = SystemFunction.process_Success;
            }
        }
        else
        {
            result.Status = SystemFunction.process_Failed;
            result.Msg    = "data not found user";
        }
        return(result);
    }
    public static sysGlobalClass.CResutlWebMethod SaveToDB(CSave_Data item, List <dataFileContactUs> objFile)
    {
        sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod();
        PTTGC_EPIEntities db  = new PTTGC_EPIEntities();
        DateTime          now = DateTime.Now;

        if (UserAcc.UserExpired())
        {
            result.Status = SystemFunction.process_SessionExpired;
        }
        else
        {
            UserAcc ua = UserAcc.GetObjUser();
            try
            {
                string     sPathSend = "";
                int        nID       = db.TContactUs.Any() ? db.TContactUs.Max(m => m.nContactID) + 1 : 1;
                TContactUs t         = new TContactUs();
                t.nContactID    = nID;
                t.sContactName  = item.sName;
                t.sContactEmail = item.sEmail;
                t.sContactTel   = item.sTel;
                t.sSubject      = item.sSubject;
                t.sDetail       = item.sDec;
                t.dCreate       = now;
                t.dUpdate       = now;
                t.cDel          = "N";
                if (objFile.Count > 0 && objFile != null)
                {
                    string sPathSave = string.Format(sFolderInPathSave, nID);
                    SystemFunction.CreateDirectory(sPathSave);
                    //string sPathSave = string.Format(sFolderInPathSave, nID);
                    //SystemFunction.CreateDirectory(sPathSave);
                    var    f = objFile.First();
                    string sSystemFileName = nID + "_" + "-" + DateTime.Now.ToString("ddMMyyyyHHmmss") + "." + SystemFunction.GetFileNameFromFileupload(f.sFileName, ""); //SystemFunction2.GetFileType(item.SaveToFileName);
                    SystemFunction.UpFile2Server(f.sPath, sPathSave, f.sSysFileName, sSystemFileName);

                    t.sContactFile    = f.sFileName;
                    t.sContactSysFile = sSystemFileName;
                    t.sContactPath    = sPathSave;
                    sPathSend         = HttpContext.Current.Server.MapPath("./") + sPathSave + sSystemFileName;
                }
                //t.cStatusAns = "NULL";
                db.TContactUs.Add(t);
                var Ispass = db.SaveChanges() > 0;

                if (Ispass)
                {
                    string From    = "";
                    var    lstUser = db.mTUser.FirstOrDefault(w => w.ID == ua.nUserID);
                    if (lstUser != null)
                    {
                        From = lstUser.Email;
                    }

                    // string From = item.sEmail;
                    #region Get_Email_Admin
                    string AdminContactmail = "";
                    var    lst_Email_Admin  = db.TMenu_Permission.Where(w => w.nRoleID == 1 && w.nMenuID == 65 && w.nPermission == 2).ToList();
                    if (lst_Email_Admin.Any())
                    {
                        lst_Email_Admin.ForEach(f =>
                        {
                            int nUserID   = f.nUserID;
                            var lst_Tuser = db.mTUser.FirstOrDefault(w => w.cActive == "Y" && w.ID == nUserID);
                            if (lst_Tuser != null)
                            {
                                AdminContactmail += "," + lst_Tuser.Email + " ";
                            }
                        });
                        AdminContactmail = AdminContactmail.Remove(0, 1);
                    }
                    else
                    {
                        AdminContactmail = WebConfigurationManager.AppSettings["ContactMail"] + "";
                    }
                    #endregion



                    string To       = "*****@*****.**";
                    string sSubject = SystemFunction.sAbbrSystem + " : Contact Us." + item.sSubject;
                    string sGurl    = SystemFunction.RequestUrl() + WebConfigurationManager.AppSettings["DefaultPage"] + "";
                    string sHtml    = @"
                    <table align='left'  border='0' cellspacing='2' cellpadding='3'>

                        <tr>
                            <td align='left'>Dear administrator: " + SystemFunction.SystemName + @" </td>
                        </tr>
                         <tr>
                           <td align='left'>Subject: " + item.sSubject + @"</td>
                        </tr>
                         <tr>
                           <td align='left'>Description: " + item.sDec + @"</td>
                        </tr>
                         <tr>
                           <td align='left'>From: " + item.sName + " E-mail: " + item.sEmail + " Contact phone number: " + item.sTel + @"</td>
                        </tr>
                        <tr>
                            <td align='left'><b>Check out more details.</b>: <a href='" + sGurl + @"' target='_blank'>Please click here</a></td>
                        </tr>
                       
                    </table>";
                    //sPathSend != "" ? sPathSend.Replace("/", "\\") : ""
                    Workflow.DataMail_log log = new Workflow.DataMail_log();
                    log           = SystemFunction.SendMailAll(From, AdminContactmail, "", "", sSubject, sHtml, sPathSend != "" ? sPathSend.Replace("/", "\\") : "");
                    log.nDataID   = SystemFunction.GetIntNullToZero(nID + "");
                    log.sPageName = "f_ContactUs.aspx";
                    new Workflow().SaveLogMail(log);
                    if (log.bStatus)
                    {
                        result.Status = SystemFunction.process_Success;
                    }
                }
            }
            catch (Exception e)
            {
                result.Msg    = e.Message;
                result.Status = SystemFunction.process_Failed;
            }

            result.Status = SystemFunction.process_Success;
        }

        return(result);
    }
    public static sysGlobalClass.CResutlWebMethod SaveToDB(string sDesc, string sID, List <dataFileContactUs> objFile)
    {
        sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod();
        PTTGC_EPIEntities db  = new PTTGC_EPIEntities();
        DateTime          now = DateTime.Now;

        if (UserAcc.UserExpired())
        {
            result.Status = SystemFunction.process_SessionExpired;
        }
        else
        {
            try
            {
                UserAcc ua = UserAcc.GetObjUser();
                if (!string.IsNullOrEmpty(sID))
                {
                    string sPathSend = "";
                    int    nID       = int.Parse(STCrypt.Decrypt(sID));
                    var    Query     = db.TContactUs.FirstOrDefault(w => w.cDel == "N" && w.nContactID == nID);
                    if (Query != null)
                    {
                        Query.sAnswer    = sDesc;
                        Query.cStatusAns = "2";
                        Query.dAnswer    = now;
                        Query.dUpdate    = now;
                        Query.nAnswerBy  = UserAcc.GetObjUser().nUserID;

                        if (objFile.Count > 0 && objFile != null)
                        {
                            string sPathSave = string.Format(sFolderInPathSave, nID);
                            SystemFunction.CreateDirectory(sPathSave);
                            //string sPathSave = string.Format(sFolderInPathSave, nID);
                            //SystemFunction.CreateDirectory(sPathSave);
                            var    f = objFile.First();
                            string sSystemFileName = nID + "_" + "-" + DateTime.Now.ToString("ddMMyyyyHHmmss") + "." + SystemFunction.GetFileNameFromFileupload(f.sFileName, ""); //SystemFunction2.GetFileType(item.SaveToFileName);
                            SystemFunction.UpFile2Server(f.sPath, sPathSave, f.sSysFileName, sSystemFileName);

                            Query.sAnsFile    = f.sFileName;
                            Query.sAnsSysFile = sSystemFileName;
                            Query.sAnsPath    = sPathSave;
                            sPathSend         = HttpContext.Current.Server.MapPath("./") + sPathSave + sSystemFileName;
                        }

                        var Ispass = db.SaveChanges() > 0;
                        if (Ispass)
                        {
                            string To = Query.sContactEmail;                                                   // Contact Mail
                            string AdminContactmail = WebConfigurationManager.AppSettings["ContactMail"] + ""; // Mail Admin
                            //string To1 = "*****@*****.**";

                            string sSubject           = SystemFunction.sAbbrSystem + " : Contact Us." + Query.sSubject;
                            string sGurl              = SystemFunction.RequestUrl() + WebConfigurationManager.AppSettings["DefaultPage"] + "";
                            string sHtml              = @"
                                    <table align='left'  border='0' cellspacing='2' cellpadding='3'>

                                        <tr>
                                            <td align='left'>Dear: " + Query.sContactName + @"</td>
                                        </tr>
                                         <tr>
                                           <td align='left'>Subject: " + Query.sSubject + @"</td>
                                        </tr>
                                         <tr>
                                           <td align='left'>Description: " + Query.sDetail + @"</td>
                                        </tr>
                                        <tr>
                                           <td align='left'>Answer: " + Query.sAnswer + @"</td>
                                        </tr>

                                    </table>";
                            Workflow.DataMail_log log = new Workflow.DataMail_log();

                            string ccMail  = "";
                            var    lstUser = db.mTUser.FirstOrDefault(w => w.ID == ua.nUserID);
                            if (lstUser != null)
                            {
                                ccMail = lstUser.Email;
                            }

                            log           = SystemFunction.SendMailAll(AdminContactmail, To, ccMail, "", sSubject, sHtml, sPathSend != "" ? sPathSend.Replace("/", "\\") : "");
                            log.nDataID   = SystemFunction.GetIntNullToZero(nID + "");
                            log.sPageName = "admin_ContactUs_update.aspx";
                            new Workflow().SaveLogMail(log);
                            if (log.bStatus)
                            {
                                result.Status = SystemFunction.process_Success;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.Msg    = e.Message;
                result.Status = SystemFunction.process_Failed;
            }

            result.Status = SystemFunction.process_Success;
        }

        return(result);
    }