コード例 #1
0
 /**
  *  Get Request
  *	@return request
  */
 public MRequest GetRequest()
 {
     if (GetR_Request_ID() == 0)
     {
         _request = null;
     }
     else if (_request == null ||
              _request.GetR_Request_ID() != GetR_Request_ID())
     {
         _request = new MRequest(GetCtx(), GetR_Request_ID(), Get_TrxName());
     }
     return(_request);
 }
コード例 #2
0
        }       //	MRequestUpdate

        /**
         *  Parent Constructor
         *	@param parent request
         */
        public MRequestUpdate(MRequest parent) :
            base(parent.GetCtx(), 0, parent.Get_TrxName())
        {
            //super (parent.GetContext(), 0, parent.Get_TrxName());
            SetClientOrg(parent);
            SetR_Request_ID(parent.GetR_Request_ID());
            //
            SetStartTime(parent.GetStartTime());
            SetEndTime(parent.GetEndTime());
            SetResult(parent.GetResult());
            SetQtySpent(parent.GetQtySpent());
            SetQtyInvoiced(parent.GetQtyInvoiced());
            SetM_ProductSpent_ID(parent.GetM_ProductSpent_ID());
            SetConfidentialTypeEntry(parent.GetConfidentialTypeEntry());
        }       //	MRequestUpdate
コード例 #3
0
        /// <summary>
        /// Send notice to users.
        /// </summary>
        /// <param name="list"> List of columns changed.</param>
        protected void SendNotices(List <String> list)
        {
            bool          isEmailSent = false;
            StringBuilder finalMsg    = new StringBuilder();

            finalMsg.Append(Msg.Translate(GetCtx(), "R_Request_ID") + ": " + _req.GetDocumentNo()).Append("\n").Append(Msg.Translate(GetCtx(), "R_NotificSent"));
            //	Subject
            if (mailText_ID == 0)
            {
                subject = Msg.Translate(GetCtx(), "R_Request_ID")
                          + " " + Msg.GetMsg(GetCtx(), "Updated", true) + ": " + _req.GetDocumentNo() + " (●" + MTable.Get_Table_ID(Table_Name) + "-" + _req.GetR_Request_ID() + "●) " + Msg.GetMsg(GetCtx(), "DoNotChange");
            }
            //	Message

            //		UpdatedBy: Joe
            int   UpdatedBy = GetCtx().GetAD_User_ID();
            MUser from      = MUser.Get(GetCtx(), UpdatedBy);

            FileInfo pdf = CreatePDF();

            log.Finer(message.ToString());

            //	Prepare sending Notice/Mail
            MClient client = MClient.Get(GetCtx(), GetAD_Client_ID());

            //	ReSet from if external
            if (from.GetEMailUser() == null || from.GetEMailUserPW() == null)
            {
                from = null;
            }
            _success = 0;
            _failure = 0;
            _notices = 0;

            /** List of users - aviod duplicates	*/
            List <int> userList = new List <int>();
            String     sql      = "SELECT u.AD_User_ID, u.NotificationType, u.EMail, u.Name, MAX(r.AD_Role_ID) "
                                  + "FROM RV_RequestUpdates_Only ru"
                                  + " INNER JOIN AD_User u ON (ru.AD_User_ID=u.AD_User_ID)"
                                  + " LEFT OUTER JOIN AD_User_Roles r ON (u.AD_User_ID=r.AD_User_ID) "
                                  + "WHERE ru.R_Request_ID= " + _req.GetR_Request_ID()
                                  + " GROUP BY u.AD_User_ID, u.NotificationType, u.EMail, u.Name";

            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, null);
                while (idr.Read())
                {
                    int    AD_User_ID       = Utility.Util.GetValueOfInt(idr[0]);
                    String NotificationType = Util.GetValueOfString(idr[1]); //idr.GetString(1);
                    if (NotificationType == null)
                    {
                        NotificationType = X_AD_User.NOTIFICATIONTYPE_EMail;
                    }
                    String email = Util.GetValueOfString(idr[2]);// idr.GetString(2);

                    if (String.IsNullOrEmpty(email))
                    {
                        continue;
                    }

                    String Name = Util.GetValueOfString(idr[3]);//idr.GetString(3);
                    //	Role
                    int AD_Role_ID = Utility.Util.GetValueOfInt(idr[4]);
                    if (idr == null)
                    {
                        AD_Role_ID = -1;
                    }

                    //	Don't send mail to oneself
                    //		if (AD_User_ID == UpdatedBy)
                    //			continue;

                    //	No confidential to externals
                    if (AD_Role_ID == -1 &&
                        (_req.GetConfidentialTypeEntry().Equals(X_R_Request.CONFIDENTIALTYPE_Internal) ||
                         _req.GetConfidentialTypeEntry().Equals(X_R_Request.CONFIDENTIALTYPE_PrivateInformation)))
                    {
                        continue;
                    }

                    if (X_AD_User.NOTIFICATIONTYPE_None.Equals(NotificationType))
                    {
                        log.Config("Opt out: " + Name);
                        continue;
                    }
                    if ((X_AD_User.NOTIFICATIONTYPE_EMail.Equals(NotificationType) ||
                         X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.Equals(NotificationType)) &&
                        (email == null || email.Length == 0))
                    {
                        if (AD_Role_ID >= 0)
                        {
                            NotificationType = X_AD_User.NOTIFICATIONTYPE_Notice;
                        }
                        else
                        {
                            log.Config("No EMail: " + Name);
                            continue;
                        }
                    }
                    if (X_AD_User.NOTIFICATIONTYPE_Notice.Equals(NotificationType) &&
                        AD_Role_ID >= 0)
                    {
                        log.Config("No internal User: "******"\n").Append(user.GetName()).Append(".");
                    isEmailSent = true;
                }

                idr.Close();
                // Notification For Role
                List <int> _users = SendRoleNotice();
                for (int i = 0; i < _users.Count; i++)
                {
                    MUser  user             = new MUser(GetCtx(), _users[i], null);
                    int    AD_User_ID       = user.GetAD_User_ID();
                    String NotificationType = user.GetNotificationType(); //idr.GetString(1);
                    if (NotificationType == null)
                    {
                        NotificationType = X_AD_User.NOTIFICATIONTYPE_EMail;
                    }
                    String email = user.GetEMail();// idr.GetString(2);

                    if (String.IsNullOrEmpty(email))
                    {
                        continue;
                    }

                    String Name = user.GetName(); //idr.GetString(3);
                                                  //	Role

                    if (X_AD_User.NOTIFICATIONTYPE_None.Equals(NotificationType))
                    {
                        log.Config("Opt out: " + Name);
                        continue;
                    }

                    //
                    SendNoticeNow(_users[i], NotificationType,
                                  client, from, subject, message.ToString(), pdf);
                    finalMsg.Append("\n").Append(user.GetName()).Append(".");
                    isEmailSent = true;
                }

                if (!isEmailSent)
                {
                    finalMsg.Clear();
                    finalMsg.Append(Msg.Translate(GetCtx(), "R_Request_ID") + ": " + _req.GetDocumentNo()).Append("\n").Append(Msg.Translate(GetCtx(), "R_NoNotificationSent"));
                }

                int   AD_Message_ID = 834;
                MNote note          = new MNote(GetCtx(), AD_Message_ID, GetCtx().GetAD_User_ID(),
                                                X_R_Request.Table_ID, _req.GetR_Request_ID(),
                                                subject, finalMsg.ToString(), Get_TrxName());
                if (note.Save())
                {
                    log.Log(Level.INFO, "ProcessFinished", "");
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }


            //	New Sales Rep (may happen if sent from beforeSave
            if (!userList.Contains(_req.GetSalesRep_ID()))
            {
                SendNoticeNow(_req.GetSalesRep_ID(), null,
                              client, from, subject, message.ToString(), pdf);
            }
        }
コード例 #4
0
        /**
         *  Create Request from Lead
         *  @param R_RequestType_ID request type
         *	@return error message
         */
        private String CreateRequest(int R_RequestType_ID)
        {
            if (GetR_Request_ID() != 0)
            {
                return("@AlreadyExists@: @R_Request_ID@ (ID=" + GetR_Request_ID() + ")");
            }
            if (GetC_BPartner_ID() == 0)
            {
                String retValue = CreateBP();
                if (retValue != null)
                {
                    return(retValue);
                }
            }
            _request = new MRequest(GetCtx(), 0, Get_TrxName());
            _request.SetAD_Org_ID(GetAD_Org_ID());
            String summary = GetName();

            if (summary == null)
            {
                summary = GetHelp();
            }
            if (summary == null)
            {
                summary = GetSummary();
            }
            if (summary == null)
            {
                summary = GetDescription();
            }
            _request.SetSummary(summary);
            //
            _request.SetR_RequestType_ID(R_RequestType_ID);
            if (IsR_Status_IDValid(GetR_Status_ID()))
            {
                _request.SetR_Status_ID(GetR_Status_ID());
            }
            else
            {
                _request.SetR_Status_ID();
            }
            //
            _request.SetC_Lead_ID(GetC_Lead_ID());
            //
            _request.SetC_BPartner_ID(GetC_BPartner_ID());
            _request.SetAD_User_ID(GetAD_User_ID());
            _request.SetC_Project_ID(GetC_Project_ID());
            _request.SetC_Campaign_ID(GetC_Campaign_ID());
            _request.SetR_Source_ID(GetR_Source_ID());
            _request.SetC_BPartnerSR_ID(GetC_BPartnerSR_ID());
            _request.SetC_SalesRegion_ID(GetC_SalesRegion_ID());

            _request.SetSalesRep_ID(GetSalesRep_ID());
            if (!_request.Save())
            {
                return("@SaveError@");
            }
            //
            SetR_Request_ID(_request.GetR_Request_ID());
            return(null);
        }
コード例 #5
0
 /**
  *  Parent Action Constructor
  *	@param request parent
  *	@param newRecord new (copy all)
  */
 public MRequestAction(MRequest request, bool newRecord)
     : this(request.GetCtx(), 0, request.Get_TrxName())
 {
     SetClientOrg(request);
     SetR_Request_ID(request.GetR_Request_ID());
 }