예제 #1
0
        /// <summary>
        /// Get active User with name/pwd
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="email">emal</param>
        /// <param name="password">password</param>
        /// <param name="trxName">transaction</param>
        /// <returns>user or null</returns>
        public static MUser Get(Ctx ctx, String name, String password, Trx trxName)
        {
            if (name == null || name.Length == 0 || password == null || password.Length == 0)
            {
                _log.Warning("Invalid Name/Password = "******"/" + password);
                return(null);
            }
            int AD_Client_ID = ctx.GetAD_Client_ID();

            MUser  retValue = null;
            String sql      = "SELECT * FROM AD_User "
                              + "WHERE Name='" + name + "' AND Password='******' AND IsActive='Y' AND AD_Client_ID=" + AD_Client_ID;

            try
            {
                DataSet ds = DataBase.DB.ExecuteDataset(sql, null, trxName);
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count != 0 && ds.Tables[0].Rows.Count > 1)
                    {
                        _log.Warning("More then one user with Name/Password = "******"No record");
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }
            return(retValue);
        }
예제 #2
0
        /// <summary>
        /// Get User from email
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="email">emal</param>
        /// <param name="trxName">transaction</param>
        /// <returns>user or null</returns>
        public static MUser Get(Ctx ctx, String email, Trx trxName)
        {
            if (email == null || email.Length == 0)
            {
                return(null);
            }

            int    AD_Client_ID = ctx.GetAD_Client_ID();
            MUser  retValue     = null;
            String sql          = "SELECT * FROM AD_User "
                                  + "WHERE EMail='" + email + "' AND AD_Client_ID=" + AD_Client_ID;

            try
            {
                DataSet ds = DataBase.DB.ExecuteDataset(sql, null, trxName);
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count != 0 && ds.Tables[0].Rows.Count > 1)
                    {
                        _log.Warning("More then one user with EMail = " + email);
                    }
                    retValue = new MUser(ctx, ds.Tables[0].Rows[0], trxName);
                }
                else
                {
                    _log.Fine("No record");
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }
            return(retValue);
        }
예제 #3
0
        /// <summary>
        ///     Get User Preference
        /// </summary>
        /// <param name="user">user </param>
        /// <param name="createNew">create new if not found</param>
        /// <returns>user preference</returns>
        public static MUserPreference GetOfUser(MUser user, bool createNew)
        {
            MUserPreference retValue = null;
            String          sql      = "SELECT * FROM AD_UserPreference WHERE AD_User_ID='" + user.GetAD_User_ID() + "'";

            try
            {
                DataSet ds = DataBase.DB.ExecuteDataset(sql);
                foreach (DataRow rs in ds.Tables[0].Rows)
                {
                    retValue = new MUserPreference(user.GetCtx(), rs, null);
                }
                ds.Dispose();
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }
            if (retValue == null && createNew)
            {
                retValue = new MUserPreference(user.GetCtx(), 0, null);
                retValue.SetClientOrg(user);
                retValue.SetAD_User_ID(user.GetAD_User_ID());
                retValue.Save();
            }
            return(retValue);
        }       //	getOfUser
예제 #4
0
        /**
         *  Set AD_User_ID from email
         */
        public void SetAD_User_ID()
        {
            if (GetAD_User_ID() != 0)
            {
                return;
            }
            String email = GetEMail();

            if (email != null && email.Length > 0)
            {
                _user = MUser.Get(GetCtx(), email, Get_TrxName());
                if (_user != null)
                {
                    base.SetAD_User_ID(_user.GetAD_User_ID());
                    if (GetC_BPartner_ID() == 0)
                    {
                        SetC_BPartner_ID(_user.GetC_BPartner_ID());
                    }
                    else if (_user.GetC_BPartner_ID() != GetC_BPartner_ID())
                    {
                        log.Warning("@C_BPartner_ID@ (ID=" + GetC_BPartner_ID()
                                    + ") <> @AD_User_ID@ @C_BPartner_ID@ (ID=" + _user.GetC_BPartner_ID() + ")");
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Get active Users of BPartner sorted by date updated desc.
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="C_BPartner_ID">id</param>
        /// <returns>array of users</returns>
        /// Writer - Mohit , Date - 7 may 2019
        public static MUser[] GetOfBPartner(Ctx ctx, int C_BPartner_ID)
        {
            List <MUser> list = new List <MUser>();
            String       sql  = "SELECT * FROM AD_User WHERE C_BPartner_ID=" + C_BPartner_ID + " AND IsActive='Y' ORDER BY Updated DESC ";

            try
            {
                DataSet ds = DataBase.DB.ExecuteDataset(sql, null, null);
                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        list.Add(new MUser(ctx, dr, null));
                    }
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }

            MUser[] retValue = new MUser[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AD_User_ID"></param>
        /// <param name="subject"></param>
        /// <param name="message"></param>
        /// <param name="attachment"></param>
        /// <returns></returns>
        public bool SendEMail(int AD_User_ID, String subject, String message, FileInfo attachment)
        {
            MUser  to      = MUser.Get(GetCtx(), AD_User_ID);
            String toEMail = to.GetEMail();

            if (toEMail == null || toEMail.Length == 0)
            {
                //log.warning("No EMail for recipient: " + to);
                return(false);
            }
            if (to.IsEMailBounced())
            {
                //log.warning("EMail bounced for recipient: " + to);
                return(false);
            }
            EMail email = CreateEMail(null, to, subject, message);

            if (email == null)
            {
                return(false);
            }
            if (attachment != null)
            {
                email.AddAttachment(attachment);
            }
            try
            {
                return(SendEmailNow(null, to, email));
            }
            catch (Exception ex)
            {
                log.Severe(GetName() + " - " + ex.Message);
                return(false);
            }
        }
예제 #7
0
        /// <summary>
        /// Get Users with Role
        /// </summary>
        /// <param name="role">role</param>
        /// <returns>array of users</returns>
        public static MUser[] GetWithRole(MRole role)
        {
            List <MUser> list = new List <MUser>();
            String       sql  = "SELECT * FROM AD_User u "
                                + "WHERE u.IsActive='Y'"
                                + " AND EXISTS (SELECT * FROM AD_User_Roles ur "
                                + "WHERE ur.AD_User_ID=u.AD_User_ID AND ur.AD_Role_ID=" + role.GetAD_Role_ID() + " AND ur.IsActive='Y')";

            try
            {
                DataSet ds = DataBase.DB.ExecuteDataset(sql, null, null);
                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        list.Add(new MUser(role.GetCtx(), dr, null));
                    }
                }
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }

            MUser[] retValue = new MUser[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="from"></param>
        /// <param name="toEMail"></param>
        /// <param name="toName"></param>
        /// <param name="subject"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public EMail CreateEMail(MUser from, String toEMail, String toName, String subject, String message, bool isHTML)
        {
            if (toEMail == null || toEMail.Length == 0)
            {
                //log.warning("No To address");
                return(null);
            }
            //	No From - send from Request
            if (from == null)
            {
                return(CreateEMail(toEMail, toName, subject, message, isHTML));
            }
            //	No From details - Error
            if (from.GetEMail() == null ||
                from.GetEMailUser() == null || from.GetEMailUserPW() == null)
            {
                //log.warning("From EMail incomplete: " + from + " (" + GetName() + ")");
                return(null);
            }
            //
            EMail email = null;

            if (IsServerEMail() && Ini.IsClient())
            {
                //Server server = CConnection.get().getServer();
                //try
                //{
                //    if (server != null)
                //    {	//	See ServerBean
                //        email = server.createEMail(GetCtx(), GetAD_Client_ID(),
                //            from.GetAD_User_ID(),
                //            toEMail, toName,
                //            subject, message);
                //    }
                //    else
                //        log.log(Level.WARNING, "No AppsServer");
                //}
                //catch (RemoteException ex)
                //{
                //    log.log(Level.SEVERE, GetName() + " - AppsServer error", ex);
                //}
            }
            if (email == null)
            {
                email = new EMail(this, from.GetEMail(), from.GetName(), toEMail, toName,
                                  subject, message);
                email.ISHTML = isHTML;
            }
            if (!email.IsValid())
            {
                return(null);
            }
            if (IsSmtpAuthorization())
            {
                email.CreateAuthenticator(from.GetEMailUser(), from.GetEMailUserPW());
            }
            return(email);
        }
예제 #9
0
        /**
         *  Before Save
         *	@param newRecord new
         *	@return true
         */
        protected override Boolean BeforeSave(Boolean newRecord)
        {
            //	Measure required if nor Summary
            if (!IsSummary() && GetPA_Measure_ID() == 0)
            {
                log.SaveError("FillMandatory", Msg.GetElement(GetCtx(), "PA_Measure_ID"));
                return(false);
            }
            if (IsSummary() && GetPA_Measure_ID() != 0)
            {
                SetPA_Measure_ID(0);
            }

            //	User/Role Check
            if ((newRecord || Is_ValueChanged("AD_User_ID") || Is_ValueChanged("AD_Role_ID")) &&
                GetAD_User_ID() != 0)
            {
                MUser   user  = MUser.Get(GetCtx(), GetAD_User_ID());
                MRole[] roles = user.GetRoles(GetAD_Org_ID());
                if (roles.Length == 0)          //	No Role
                {
                    SetAD_Role_ID(0);
                }
                else if (roles.Length == 1)     //	One
                {
                    SetAD_Role_ID(roles[0].GetAD_Role_ID());
                }
                else
                {
                    int AD_Role_ID = GetAD_Role_ID();
                    if (AD_Role_ID != 0)        //	validate
                    {
                        Boolean found = false;
                        for (int i = 0; i < roles.Length; i++)
                        {
                            if (AD_Role_ID == roles[i].GetAD_Role_ID())
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            AD_Role_ID = 0;
                        }
                    }
                    if (AD_Role_ID == 0)                //	Set to first one
                    {
                        SetAD_Role_ID(roles[0].GetAD_Role_ID());
                    }
                }       //	multiple roles
            }

            return(true);
        }
예제 #10
0
        public static bool GetIsEmployee(Ctx ctx, int AD_USER_ID)
        {
            MUser     user = MUser.Get(ctx, AD_USER_ID);
            MBPartner bp   = MBPartner.Get(ctx, user.GetC_BPartner_ID());

            user = null;
            if (bp == null)
            {
                return(false);
            }
            return(bp.IsEmployee());
        }
예제 #11
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
        /// <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);
        }
예제 #13
0
 /**
  *  Get User
  *	@return user
  */
 public MUser GetUser()
 {
     if (GetAD_User_ID() == 0)
     {
         _user = null;
     }
     else if (_user == null ||
              _user.GetAD_User_ID() != GetAD_User_ID())
     {
         _user = new MUser(GetCtx(), GetAD_User_ID(), Get_TrxName());
     }
     return(_user);
 }
예제 #14
0
 protected override bool AfterDelete(bool success)
 {
     if (success)
     {
         deleteRoleForLogin();
         MUser obj = new MUser(role_ctx, GetAD_User_ID(), null);
         if (obj.IsVA039_IsJasperUser())
         {
             obj.createJasperUser();
         }
     }
     return(success);
 }
예제 #15
0
        /// <summary>
        /// Set Created/Updated By
        /// </summary>
        /// <param name="email">mail address</param>
        private void SetCreatedBy(String email)
        {
            if (email == null || email.Length == 0)
            {
                return;
            }
            int AD_User_ID = MUser.GetAD_User_ID(email, GetAD_Client_ID());

            Set_ValueNoCheck("CreatedBy", AD_User_ID);
            SetUpdatedBy(AD_User_ID);
            GetCtx().SetContext("##AD_User_ID", AD_User_ID.ToString());
            SetAD_User_ID(AD_User_ID);
        }
예제 #16
0
 /// <summary>
 /// Set Approved
 /// </summary>
 /// <param name="isApproved">approval</param>
 public new void SetIsApproved(Boolean isApproved)
 {
     if (isApproved && !IsApproved())
     {
         int    AD_User_ID = GetCtx().GetAD_User_ID();
         MUser  user       = MUser.Get(GetCtx(), AD_User_ID);
         String info       = user.GetName()
                             + ": "
                             + Msg.Translate(GetCtx(), "IsApproved")
                             + " - " + new DateTime(CommonFunctions.CurrentTimeMillis());
         AddDescription(info);
     }
     base.SetIsApproved(isApproved);
 }
예제 #17
0
 /// <summary>
 /// Set Approved
 /// </summary>
 /// <param name="isApproved">approval</param>
 public new void SetIsApproved(Boolean isApproved)
 {
     if (isApproved && !IsApproved())
     {
         int    AD_User_ID = GetCtx().GetAD_User_ID();
         MUser  user       = MUser.Get(GetCtx(), AD_User_ID);
         String info       = user.GetName()
                             + ": "
                             + Msg.Translate(GetCtx(), "IsApproved")
                             + " - " + DateTime.Now.ToString();
         AddDescription(info);
     }
     base.SetIsApproved(isApproved);
 }
예제 #18
0
        }       //	isSubscribed

        /**
         *  After Save
         *	@param newRecord new
         *	@param success success
         *	@return success
         */
        protected override Boolean AfterSave(Boolean newRecord, Boolean success)
        {
            if (success && newRecord && IsSubscribed())
            {
                MInterestArea ia = MInterestArea.Get(GetCtx(), GetR_InterestArea_ID());
                if (ia.GetR_Source_ID() != 0)
                {
                    String summary = "Subscribe: " + ia.GetName();
                    //
                    MSource source = MSource.Get(GetCtx(), ia.GetR_Source_ID());
                    MUser   user   = null;
                    if (Get_TrxName() == null)
                    {
                        user = MUser.Get(GetCtx(), GetAD_User_ID());
                    }
                    else
                    {
                        user = new MUser(GetCtx(), GetAD_User_ID(), Get_TrxName());
                    }
                    //	Create Request
                    if (MSource.SOURCECREATETYPE_Both.Equals(source.GetSourceCreateType()) ||
                        MSource.SOURCECREATETYPE_Request.Equals(source.GetSourceCreateType()))
                    {
                        MRequest request = new MRequest(GetCtx(), 0, Get_TrxName());
                        request.SetClientOrg(this);
                        request.SetSummary(summary);
                        request.SetAD_User_ID(GetAD_User_ID());
                        request.SetC_BPartner_ID(user.GetC_BPartner_ID());
                        request.SetR_Source_ID(source.GetR_Source_ID());
                        request.Save();
                    }
                    //	Create Lead
                    if (MSource.SOURCECREATETYPE_Both.Equals(source.GetSourceCreateType()) ||
                        MSource.SOURCECREATETYPE_Lead.Equals(source.GetSourceCreateType()))
                    {
                        MLead lead = new MLead(GetCtx(), 0, Get_TrxName());
                        lead.SetClientOrg(this);
                        lead.SetDescription(summary);
                        lead.SetAD_User_ID(GetAD_User_ID());
                        lead.SetR_InterestArea_ID(GetR_InterestArea_ID());
                        lead.SetC_BPartner_ID(user.GetC_BPartner_ID());
                        lead.SetR_Source_ID(source.GetR_Source_ID());
                        lead.Save();
                    }
                }
            }
            return(success);
        }       //	afterSave
 /**
  *  Constructor
  *	@param ctx context
  *  @param bp BP
  *	@param bpc BP Contact
  *  @param location Location
  */
 public MBPBankAccount(Ctx ctx, MBPartner bp, MUser bpc, MLocation location)
     : this(ctx, 0, bp.Get_TrxName())
 {
     SetIsACH(false);
     //
     SetC_BPartner_ID(bp.GetC_BPartner_ID());
     //
     SetA_Name(bpc.GetName());
     SetA_EMail(bpc.GetEMail());
     //
     SetA_Street(location.GetAddress1());
     SetA_City(location.GetCity());
     SetA_Zip(location.GetPostal());
     SetA_State(location.GetRegionName(true));
     SetA_Country(location.GetCountryName());
 }
예제 #20
0
 /// <summary>
 ///     Send RfQ
 /// </summary>
 /// <returns>true if RfQ is sent per email.</returns>
 public bool SendRfQ()
 {
     try
     {
         MUser to = MUser.Get(GetCtx(), GetAD_User_ID());
         if (to.Get_ID() == 0 || to.GetEMail() == null || to.GetEMail().Length == 0)
         {
             log.Log(Level.SEVERE, "No User or no EMail - " + to);
             return(false);
         }
         MClient client = MClient.Get(GetCtx());
         //
         String message = GetDescription();
         if (message == null || message.Length == 0)
         {
             message = GetHelp();
         }
         else if (GetHelp() != null)
         {
             message += "\n" + GetHelp();
         }
         if (message == null)
         {
             message = GetName();
         }
         //
         EMail email = client.CreateEMail(to.GetEMail(), to.GetName(), "RfQ: " + GetName(), message);
         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);
 }
예제 #21
0
        /// <summary>
        /// Get User (cached). Also loads Admninistrator (0)
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="AD_User_ID">id</param>
        /// <returns>user</returns>
        public static MUser Get(Ctx ctx, int AD_User_ID)
        {
            int   key      = AD_User_ID;
            MUser retValue = (MUser)cache[key];

            if (retValue == null)
            {
                retValue = new MUser(ctx, AD_User_ID, null);
                if (AD_User_ID == 0)
                {
                    Trx trxName = null;
                    retValue.Load(trxName);     //	load System Record
                }
                cache.Add(key, retValue);
            }
            return(retValue);
        }
예제 #22
0
        }       //	setAD_Role_ID

        protected override bool AfterSave(bool newRecord, bool success)
        {
            if (success)
            {
                if (!IsActive())
                {
                    deleteRoleForLogin();
                }
                //Update Role on Japser User..............
                MUser obj = new MUser(role_ctx, GetAD_User_ID(), null);
                if (obj.IsVA039_IsJasperUser())
                {
                    obj.createJasperUser();
                }
            }
            return(success);
        }
예제 #23
0
        /// <summary>
        /// Send Email Now
        /// </summary>
        /// <param name="from">optional from user</param>
        /// <param name="to">to user</param>
        /// <param name="email">email</param>
        /// <returns>true if sent</returns>
        private bool SendEmailNow(MUser from, MUser to, EMail email)
        {
            String msg = email.Send();
            //
            X_AD_UserMail um = new X_AD_UserMail(GetCtx(), 0, null);

            um.SetClientOrg(this);
            um.SetAD_User_ID(to.GetAD_User_ID());
            um.SetSubject(email.GetSubject());
            um.SetMailText(email.GetMessageCRLF());
            if (email.IsSentOK())
            {
                um.SetMessageID(email.GetMessageID());
            }
            else
            {
                um.SetMessageID(email.GetSentMsg());
                um.SetIsDelivered(X_AD_UserMail.ISDELIVERED_No);
            }
            um.Save();

            //
            if (email.IsSentOK())
            {
                //if (from != null)
                //    log.info("Sent Email: " + email.GetSubject() + " from " + from.GetEMail() + " to " + to.GetEMail());
                //else
                //    log.info("Sent Email: " + email.GetSubject() + " to " + to.GetEMail());
                return(true);
            }
            else
            {
                //if (from != null)
                //    log.warning("Could NOT Send Email: " + email.GetSubject()
                //        + " from " + from.GetEMail()
                //        + " to " + to.GetEMail() + ": " + msg
                //        + " (" + GetName() + ")");
                //else
                //    log.warning("Could NOT Send Email: " + email.GetSubject()
                //        + " to " + to.GetEMail() + ": " + msg
                //        + " (" + GetName() + ")");
                return(false);
            }
        }
예제 #24
0
        }       //	getAD_Language

        /// <summary>
        ///
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public EMail CreateEMail(MUser from, MUser to, String subject, String message)
        {
            if (to == null)
            {
                //log.warning("No To user");
                return(null);
            }
            if (to.GetEMail() == null || to.GetEMail().Length == 0)
            {
                //log.warning("No To address: " + to);
                return(null);
            }
            if (to.IsEMailBounced())
            {
                //log.warning("EMail bounced: " + to.GetBouncedInfo() + " - " + to.GetEMail());
                return(null);
            }
            return(CreateEMail(from, to.GetEMail(), to.GetName(), subject, message));
        }
예제 #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="message"></param>
        /// <param name="attachment"></param>
        /// <returns></returns>
        public bool SendEMail(MUser from, MUser to, String subject, String message, FileInfo attachment)
        {
            EMail email = CreateEMail(from, to, subject, message);

            if (email == null)
            {
                return(false);
            }
            if (attachment != null)
            {
                email.AddAttachment(attachment);
            }
            MailAddress emailFrom = email.GetFrom();

            try
            {
                return(SendEmailNow(from, to, email));
            }
            catch (Exception ex)
            {
                log.Severe(GetName() + " - from " + emailFrom + " to " + to + ": " + ex.Message);
                return(false);
            }
        }
예제 #26
0
 /// <summary>
 /// Set User for parse
 /// </summary>
 /// <param name="user">user</param>
 public void SetUser(MUser user)
 {
     _user = user;
 }
예제 #27
0
 /// <summary>
 /// Set User for parse
 /// </summary>
 /// <param name="AD_User_ID">user</param>
 public void SetUser(int AD_User_ID)
 {
     _user = MUser.Get(GetCtx(), AD_User_ID);
 }
예제 #28
0
        /**
         *  Create Trial Asset
         *	@param ctx context
         *	@param user user
         *	@param entityType entity type
         *	@return asset or null if no product found
         */
        public static MAsset GetTrial(Ctx ctx, MUser user, String entityType)
        {
            if (user == null)
            {
                _log.Warning("Cannot create Trial - No User");
                return(null);
            }
            if (Utility.Util.IsEmpty(entityType))
            {
                _log.Warning("Cannot create Trial - No Entity Type");
                return(null);
            }
            MProduct product = MProduct.GetTrial(ctx, entityType);

            if (product == null)
            {
                _log.Warning("No Trial for Entity Type=" + entityType);
                return(null);
            }
            //
            DateTime now = Convert.ToDateTime(CommonFunctions.CurrentTimeMillis());
            //
            MAsset asset = new MAsset(ctx, 0, null);

            asset.SetClientOrg(user);
            asset.SetAssetServiceDate(now);
            asset.SetIsOwned(false);
            asset.SetIsTrialPhase(true);
            //
            MBPartner partner    = new MBPartner(ctx, user.GetC_BPartner_ID(), null);
            String    documentNo = "Trial";
            //	Value
            String value = partner.GetValue() + "_" + product.GetValue();

            if (value.Length > 40 - documentNo.Length)
            {
                value = value.Substring(0, 40 - documentNo.Length) + documentNo;
            }
            asset.SetValue(value);
            //	Name		MProduct.afterSave
            String name = "Trial " + partner.GetName() + " - " + product.GetName();

            if (name.Length > 60)
            {
                name = name.Substring(0, 60);
            }
            asset.SetName(name);
            //	Description
            String description = product.GetDescription();

            asset.SetDescription(description);

            //	User
            asset.SetAD_User_ID(user.GetAD_User_ID());
            asset.SetC_BPartner_ID(user.GetC_BPartner_ID());
            //	Product
            asset.SetM_Product_ID(product.GetM_Product_ID());
            asset.SetA_Asset_Group_ID(product.GetA_Asset_Group_ID());
            asset.SetQty(new Decimal(product.GetSupportUnits()));
            //	Guarantee & Version
            asset.SetGuaranteeDate(TimeUtil.AddDays(now, product.GetTrialPhaseDays()));
            asset.SetVersionNo(product.GetVersionNo());
            //
            return(asset);
        }
예제 #29
0
        /// <summary>
        /// Set BPartner
        /// </summary>
        /// <param name="bp">partner</param>
        /// <param name="isSOTrx">SO</param>
        public void SetBPartner(MBPartner bp, bool isSOTrx)
        {
            SetC_BPartner_ID(bp.GetC_BPartner_ID());
            MBPartnerLocation[] locations = bp.GetLocations(false);
            //	Location
            if (locations.Length == 1)
            {
                SetC_BPartner_Location_ID(locations[0].GetC_BPartner_Location_ID());
            }
            else
            {
                for (int i = 0; i < locations.Length; i++)
                {
                    MBPartnerLocation location = locations[i];
                    if (!location.IsActive())
                    {
                        continue;
                    }
                    if ((location.IsPayFrom() && isSOTrx) ||
                        (location.IsRemitTo() && !isSOTrx))
                    {
                        SetC_BPartner_Location_ID(location.GetC_BPartner_Location_ID());
                        break;
                    }
                }
            }
            if (GetC_BPartner_Location_ID() == 0)
            {
                String msg = "@C_BPartner_ID@ " + bp.GetName();
                if (isSOTrx)
                {
                    msg += " @No@ @IsPayFrom@";
                }
                else
                {
                    msg += " @No@ @IsRemitTo@";
                }
                throw new ArgumentException(msg);
            }
            //	User with location
            MUser[] users = MUser.GetOfBPartner(GetCtx(), bp.GetC_BPartner_ID());
            if (users.Length == 1)
            {
                SetAD_User_ID(users[0].GetAD_User_ID());
            }
            else
            {
                for (int i = 0; i < users.Length; i++)
                {
                    MUser user = users[i];
                    if (user.GetC_BPartner_Location_ID() == GetC_BPartner_Location_ID())
                    {
                        SetAD_User_ID(users[i].GetAD_User_ID());
                        break;
                    }
                }
            }
            //
            int SalesRep_ID = bp.GetSalesRep_ID();

            if (SalesRep_ID != 0)
            {
                SetSalesRep_ID(SalesRep_ID);
            }
        }
예제 #30
0
        /// <summary>
        /// Set BPartner
        /// </summary>
        /// <param name="bp">partner</param>
        /// <param name="isSOTrx">SO</param>
        public void SetBPartner(MBPartner bp, bool isSOTrx)
        {
            SetC_BPartner_ID(bp.GetC_BPartner_ID());
            MBPartnerLocation[] locations = GetLocations();
            //	Location

            for (int i = 0; i < locations.Length; i++)
            {
                MBPartnerLocation location = locations[i];
                if (!location.IsActive())
                {
                    continue;
                }
                if ((location.IsPayFrom() && isSOTrx) ||
                    (location.IsRemitTo() && !isSOTrx))
                {
                    SetC_BPartner_Location_ID(location.GetC_BPartner_Location_ID());
                    break;
                }
            }
            //}
            if (GetC_BPartner_Location_ID() == 0)
            {
                String msg = "@C_BPartner_ID@ " + bp.GetName();
                if (isSOTrx)
                {
                    msg += " @No@ @IsPayFrom@";
                }
                else
                {
                    msg += " @No@ @IsRemitTo@";
                }
                //throw new ArgumentException(msg);
                log.SaveInfo("", msg);
                return;
            }

            //	User with location
            // Change done by mohit to pick users sorted by date updated. 7 May 2019.
            MUser[] users = GetOfBPartner(GetCtx(), bp.GetC_BPartner_ID());
            if (users.Length == 1)
            {
                if (users[0].IsEmail() || users[0].GetNotificationType() == MUser.NOTIFICATIONTYPE_EMail ||
                    users[0].GetNotificationType() == MUser.NOTIFICATIONTYPE_EMailPlusNotice || users[0].GetNotificationType() == MUser.NOTIFICATIONTYPE_EMailPlusFaxEMail)
                {
                    SetAD_User_ID(users[0].GetAD_User_ID());
                }
            }
            else
            {
                for (int i = 0; i < users.Length; i++)
                {
                    MUser user = users[i];
                    if (user.GetC_BPartner_Location_ID() == GetC_BPartner_Location_ID() && (user.IsEmail() || user.GetNotificationType() == MUser.NOTIFICATIONTYPE_EMail ||
                                                                                            user.GetNotificationType() == MUser.NOTIFICATIONTYPE_EMailPlusNotice || user.GetNotificationType() == MUser.NOTIFICATIONTYPE_EMailPlusFaxEMail))
                    {
                        SetAD_User_ID(users[i].GetAD_User_ID());
                        break;
                    }
                }
            }
            //
            int SalesRep_ID = bp.GetSalesRep_ID();

            if (SalesRep_ID != 0)
            {
                SetSalesRep_ID(SalesRep_ID);
            }
        }