コード例 #1
0
        }       //	doIt

        /// <summary>
        /// Send No Guarantee EMail
        /// </summary>
        /// <param name="A_Asset_ID">asset</param>
        /// <param name="R_MailText_ID">mail to send</param>
        /// <param name="trxName">trx</param>
        /// <returns>message - delivery errors start with **</returns>
        private String SendNoGuaranteeMail(int A_Asset_ID, int R_MailText_ID, Trx trxName)
        {
            MAsset asset = new MAsset(GetCtx(), A_Asset_ID, trxName);

            if (asset.GetAD_User_ID() == 0)
            {
                return("** No Asset User");
            }
            VAdvantage.Model.MUser user = new VAdvantage.Model.MUser(GetCtx(), asset.GetAD_User_ID(), Get_Trx());
            if (user.GetEMail() == null || user.GetEMail().Length == 0)
            {
                return("** No Asset User Email");
            }
            if (_MailText == null || _MailText.GetR_MailText_ID() != R_MailText_ID)
            {
                _MailText = new VAdvantage.Model.MMailText(GetCtx(), R_MailText_ID, Get_Trx());
            }
            if (_MailText.GetMailHeader() == null || _MailText.GetMailHeader().Length == 0)
            {
                return("** No Subject");
            }

            //	Create Mail
            EMail email = _client.CreateEMail(user.GetEMail(), user.GetName(), null, null);

            if (email == null)
            {
                return("** Invalid: " + user.GetEMail());
            }
            _MailText.SetPO(user);
            _MailText.SetPO(asset);
            String message = _MailText.GetMailText(true);

            if (_MailText.IsHtml())
            {
                email.SetMessageHTML(_MailText.GetMailHeader(), message);
            }
            else
            {
                email.SetSubject(_MailText.GetMailHeader());
                email.SetMessageText(message);
            }
            String msg = email.Send();

            new MUserMail(_MailText, asset.GetAD_User_ID(), email).Save();
            if (!EMail.SENT_OK.Equals(msg))
            {
                return("** Not delivered: " + user.GetEMail() + " - " + msg);
            }
            //
            return(user.GetEMail());
        }       //	sendNoGuaranteeMail
コード例 #2
0
        /// <summary>
        ///     Send RfQ, mail subject and body from mail template
        /// </summary>
        /// <returns>true if RfQ is sent per email.</returns>
        public bool SendRfQ()
        {
            try
            {
                MUser     to     = MUser.Get(GetCtx(), GetAD_User_ID());
                MClient   client = MClient.Get(GetCtx());
                MMailText mtext  = new MMailText(GetCtx(), GetRfQ().GetR_MailText_ID(), Get_TrxName());

                if (to.Get_ID() == 0 || to.GetEMail() == null || to.GetEMail().Length == 0)
                {
                    log.Log(Level.SEVERE, "No User or no EMail - " + to);
                    return(false);
                }

                // Check if mail template is set for RfQ window, if not then get from RfQ Topic window.
                if (mtext.GetR_MailText_ID() == 0)
                {
                    MRfQTopic mRfQTopic = new MRfQTopic(GetCtx(), GetRfQ().GetC_RfQ_Topic_ID(), Get_TrxName());
                    if (mRfQTopic.GetC_RfQ_Topic_ID() > 0)
                    {
                        mtext = new MMailText(GetCtx(), mRfQTopic.GetR_MailText_ID(), Get_TrxName());
                    }
                }

                //Replace the email template constants with tables values.
                StringBuilder message = new StringBuilder();
                mtext.SetPO(GetRfQ(), true);
                message.Append(mtext.GetMailText(true).Equals(string.Empty) ? "** No Email Body" : mtext.GetMailText(true));

                String subject = String.IsNullOrEmpty(mtext.GetMailHeader()) ? "** No Subject" : mtext.GetMailHeader();;

                EMail email = client.CreateEMail(to.GetEMail(), to.GetName(), subject, message.ToString());
                if (email == null)
                {
                    return(false);
                }
                email.AddAttachment(CreatePDF());
                if (EMail.SENT_OK.Equals(email.Send()))
                {
                    //SetDateInvited(new Timestamp(System.currentTimeMillis()));
                    SetDateInvited(DateTime.Now);
                    Save();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log.Severe(ex.ToString());
                //MessageBox.Show("error--" + ex.ToString());
            }
            return(false);
        }
コード例 #3
0
 /// <summary>
 /// User Mail
 /// </summary>
 /// <param name="parent">Request Mail Text</param>
 /// <param name="AD_User_ID">recipient user</param>
 /// <param name="mail">email</param>
 public MUserMail(MMailText parent, int AD_User_ID, EMail mail)
     : this(parent.GetCtx(), 0, parent.Get_TrxName())
 {
     SetClientOrg(parent);
     SetAD_User_ID(AD_User_ID);
     SetR_MailText_ID(parent.GetR_MailText_ID());
     //
     if (mail.IsSentOK())
     {
         SetMessageID(mail.GetMessageID());
     }
     else
     {
         SetMessageID(mail.GetSentMsg());
         SetIsDelivered(ISDELIVERED_No);
     }
 }
コード例 #4
0
        }       //	sendNoGuaranteeMail

        /// <summary>
        /// Deliver Asset
        /// </summary>
        /// <param name="A_Asset_ID">asset</param>
        /// <returns>message - delivery errors start with **</returns>
        private String DeliverIt(int A_Asset_ID)
        {
            log.Fine("A_Asset_ID=" + A_Asset_ID);
            long start = CommonFunctions.CurrentTimeMillis();
            //
            MAsset asset = new MAsset(GetCtx(), A_Asset_ID, Get_Trx());

            if (asset.GetAD_User_ID() == 0)
            {
                return("** No Asset User");
            }
            VAdvantage.Model.MUser user = new VAdvantage.Model.MUser(GetCtx(), asset.GetAD_User_ID(), Get_Trx());
            if (user.GetEMail() == null || user.GetEMail().Length == 0)
            {
                return("** No Asset User Email");
            }
            if (asset.GetProductR_MailText_ID() == 0)
            {
                return("** Product Mail Text");
            }
            if (_MailText == null || _MailText.GetR_MailText_ID() != asset.GetProductR_MailText_ID())
            {
                _MailText = new VAdvantage.Model.MMailText(GetCtx(), asset.GetProductR_MailText_ID(), Get_Trx());
            }
            if (_MailText.GetMailHeader() == null || _MailText.GetMailHeader().Length == 0)
            {
                return("** No Subject");
            }

            //	Create Mail
            EMail email = _client.CreateEMail(user.GetEMail(), user.GetName(), null, null);

            if (email == null || !email.IsValid())
            {
                asset.SetHelp(asset.GetHelp() + " - Invalid EMail");
                asset.SetIsActive(false);
                return("** Invalid EMail: " + user.GetEMail() + " - " + email);
            }
            if (_client.IsSmtpAuthorization())
            {
                email.CreateAuthenticator(_client.GetRequestUser(), _client.GetRequestUserPW());
            }
            _MailText.SetUser(user);
            _MailText.SetPO(asset);
            String message = _MailText.GetMailText(true);

            if (_MailText.IsHtml() || _AttachAsset)
            {
                email.SetMessageHTML(_MailText.GetMailHeader(), message);
            }
            else
            {
                email.SetSubject(_MailText.GetMailHeader());
                email.SetMessageText(message);
            }
            if (_AttachAsset)
            {
                MProductDownload[] pdls = asset.GetProductDownloads();
                if (pdls != null)
                {
                    foreach (MProductDownload element in pdls)
                    {
                        //URL url = element.getDownloadURL(m_client.getDocumentDir());
                        Url url = element.GetDownloadURL(_client.GetDocumentDir());
                        if (url != null)
                        {
                            email.AddAttachment(url.Value);
                        }
                    }
                }
                else
                {
                    log.Warning("No DowloadURL for A_Asset_ID=" + A_Asset_ID);
                }
            }
            String msg = email.Send();

            new MUserMail(_MailText, asset.GetAD_User_ID(), email).Save();
            if (!EMail.SENT_OK.Equals(msg))
            {
                return("** Not delivered: " + user.GetEMail() + " - " + msg);
            }

            MAssetDelivery ad = asset.ConfirmDelivery(email, user.GetAD_User_ID());

            ad.Save();
            asset.Save();
            //
            log.Fine((CommonFunctions.CurrentTimeMillis() - start) + " ms");
            //	success
            return(user.GetEMail() + " - " + asset.GetProductVersionNo());
        }