Esempio n. 1
0
        public ApproverEmailProfile getUserInfo(int?userId)
        {
            ApproverEmailProfile UserInfo = new ApproverEmailProfile();

            try
            {
                UserInfo = (from user in db.UserProfiles
                            where user.UserId == userId && user.IsDeleted == false
                            select new ApproverEmailProfile
                {
                    ApproverName = user.CallName,
                    EmailId = user.email,
                    ApproverUserId = user.UserId
                }).FirstOrDefault();
            }
            catch (Exception ex)
            {
                exceptionObj.RecordUnHandledException(ex);
            }
            return(UserInfo);
        }
Esempio n. 2
0
        public void POEmail_Rejected(int?phsId, int?submitterId, int?lastModifiedBy)
        {
            try
            {
                ApproverEmailProfile submitterInfo = new ApproverEmailProfile();

                ApproverEmailProfile loginApproverInfo = getUserInfo(lastModifiedBy);

                var poApproversList = (from apr in db.TEPOApprovers
                                       where apr.IsDeleted == false && apr.POStructureId == phsId
                                       select new { apr.ApproverId, apr.ApproverName, apr.Status, apr.SequenceNumber }).OrderBy(a => a.SequenceNumber).ToList();
                var purchaseheaderstructInfo = (from phs in db.TEPOHeaderStructures
                                                join vendor in db.TEPOVendorMasterDetails on phs.VendorID equals vendor.POVendorDetailId into tempvendorDtl
                                                from vndrdtl in tempvendorDtl.DefaultIfEmpty()
                                                join vendorms in db.TEPOVendorMasters on vndrdtl.POVendorMasterId equals vendorms.POVendorMasterId into tempvendorMstr
                                                from vndrmstr in tempvendorMstr.DefaultIfEmpty()
                                                where phs.Uniqueid == phsId && phs.IsDeleted == false
                                                select new
                {
                    phs.Uniqueid,
                    phs.PO_Title,
                    phs.Fugue_Purchasing_Order_Number,
                    phs.Purchasing_Order_Number,
                    phs.Version,
                    Vendor_Code = vndrdtl.VendorCode,
                    Vendor_Owner = vndrmstr.VendorName
                }).FirstOrDefault();
                if (poApproversList.Count > 0)
                {
                    if (submitterId > 0)
                    {
                        submitterInfo = getUserInfo(submitterId);
                    }
                }
                if (submitterInfo != null)
                {
                    string templateContent = string.Empty;
                    string subjectContent  = string.Empty;
                    var    templateinfo    = db.TEEmailTemplates.Where(a => a.ModuleName == "POReject" && a.IsDeleted == false).FirstOrDefault();
                    if (templateinfo != null)
                    {
                        templateContent = templateinfo.EmailTemplate;
                        subjectContent  = templateinfo.Subject;
                    }
                    if (!string.IsNullOrEmpty(templateContent))
                    {
                        templateContent = templateContent.Replace("$Employee", submitterInfo.ApproverName);
                        if (purchaseheaderstructInfo.Purchasing_Order_Number != null)
                        {
                            templateContent = templateContent.Replace("$PONumber", purchaseheaderstructInfo.Purchasing_Order_Number);
                        }
                        else
                        {
                            templateContent = templateContent.Replace("$PONumber", purchaseheaderstructInfo.Uniqueid.ToString());
                        }
                        templateContent = templateContent.Replace("$VendorName", purchaseheaderstructInfo.Vendor_Code + '-' + purchaseheaderstructInfo.Vendor_Owner);
                        templateContent = templateContent.Replace("$ApproverName", loginApproverInfo.ApproverName);
                    }
                    if (!string.IsNullOrEmpty(subjectContent))
                    {
                        subjectContent = subjectContent.Replace("$ApproverName", loginApproverInfo.ApproverName);
                        if (purchaseheaderstructInfo.Purchasing_Order_Number != null)
                        {
                            subjectContent = subjectContent.Replace("$PO", purchaseheaderstructInfo.Purchasing_Order_Number);
                        }
                        else
                        {
                            subjectContent = subjectContent.Replace("$PO", purchaseheaderstructInfo.Uniqueid.ToString());
                        }
                    }
                    string   TO          = submitterInfo.EmailId;
                    string   CC          = "";
                    string   BCC         = "";
                    string   body        = templateContent;
                    string   subject     = subjectContent;
                    string[] attachments = new string[0];
                    var      mail        = new Mailing();
                    var      sendingmail = mail.SendEMail(TO, CC, BCC, body, subject, attachments, null);
                }
            }
            catch (Exception ex)
            {
                exceptionObj.RecordUnHandledException(ex);
            }
        }