コード例 #1
0
        }       //	prepare

        /// <summary>
        /// Process
        /// </summary>
        /// <returns>summary</returns>
        protected override String DoIt()
        {
            log.Info("C_Lead_ID=" + _C_Lead_ID + ",C_ProjectType_ID=" + _C_ProjectType_ID);
            if (_C_Lead_ID == 0)
            {
                throw new Exception("@C_Lead_ID@ ID=0");
            }
            if (_C_ProjectType_ID == 0)
            {
                throw new Exception("@C_ProjectType_ID@ ID=0");
            }

            MLead lead = new MLead(GetCtx(), _C_Lead_ID, Get_TrxName());

            if (lead.Get_ID() != _C_Lead_ID)
            {
                throw new Exception("@NotFound@: @C_Lead_ID@ ID=" + _C_Lead_ID);
            }
            //
            String retValue = lead.CreateProject(_C_ProjectType_ID);

            if (retValue != null)
            {
                throw new SystemException(retValue);
            }
            lead.Save();
            MProject project = lead.GetProject();

            //
            return("@C_Project_ID@ " + project.GetName());
        } //	doIt
コード例 #2
0
        }       //	prepare

        /// <summary>
        /// Process
        /// </summary>
        /// <returns>summary</returns>
        protected override String DoIt()
        {
            log.Info("C_Lead_ID=" + _C_Lead_ID);
            if (_C_Lead_ID == 0)
            {
                throw new Exception("@C_Lead_ID@ ID=0");
            }
            MLead lead = new MLead(GetCtx(), _C_Lead_ID, Get_TrxName());

            if (lead.Get_ID() != _C_Lead_ID)
            {
                throw new Exception("@NotFound@: @C_Lead_ID@ ID=" + _C_Lead_ID);
            }
            //
            String retValue = lead.CreateRequest();

            if (retValue != null)
            {
                throw new SystemException(retValue);
            }
            lead.Save();
            MRequest request = lead.GetRequest();

            //
            return("@R_Request_ID@ " + request.GetDocumentNo());
        } //	doIt
コード例 #3
0
        }       //	prepare

        /// <summary>
        /// Create BPartner
        /// </summary>
        /// <returns>BPartner</returns>
        protected override String DoIt()
        {
            log.Info("C_Lead_ID=" + _C_Lead_ID);
            if (_C_Lead_ID == 0)
            {
                throw new Exception("@C_Lead_ID@ ID=0");
            }
            MLead lead = new MLead(GetCtx(), _C_Lead_ID, Get_TrxName());

            if (lead.GetC_BP_Group_ID() == 0)
            {
                return(Msg.GetMsg(GetCtx(), "SelectBPGroup"));
            }
            if (lead.GetBPName() == null)
            {
                return(Msg.GetMsg(GetCtx(), "Please enter Company name, Prospect or Business Partner"));
            }
            if (lead.Get_ID() != _C_Lead_ID)
            {
                throw new Exception("@NotFound@: @C_Lead_ID@ ID=" + _C_Lead_ID);
            }
            //
            String retValue = lead.CreateBP();

            if (retValue != null)
            {
                return(GetRetrievedError(lead, retValue));
                //throw new SystemException(retValue);
            }
            lead.Save();
            //
            if (lead.GetRef_BPartner_ID() != 0)
            {
                return(Msg.GetMsg(GetCtx(), "Prospect generated successfully"));
            }
            else
            {
                return(Msg.GetMsg(GetCtx(), "Prospect not generated "));
            }
            //MBPartner bp = lead.GetBPartner();
            //if (bp != null)
            //{
            //    return "@C_BPartner_ID@: " + bp.GetName();
            //}
            //MUser user = lead.GetUser();
            //if (user != null)
            //{
            //    return "@AD_User_ID@: " + user.GetName();
            //}
            //return "@SaveError@";
        }       //	doIt
コード例 #4
0
        }       //	doIt

        /// <summary>
        /// impoert process
        /// </summary>
        /// <param name="imp">import</param>
        /// <returns>true if processed</returns>
        private bool Process(X_I_Contact imp)
        {
            if (imp.GetEMail() == null || imp.GetEMail().Length == 0)
            {
                return(ProcessFail(imp, "No EMail"));
            }

            MUser user = MUser.Get(GetCtx(), imp.GetEMail(), Get_TrxName());

            //	New User
            if (user == null || user.GetAD_User_ID() == 0)
            {
                if (imp.IsEMailBounced())
                {
                    return(ProcessFail(imp, "No User found with email - cannou set Bounced flag"));
                }
                if (imp.GetContactName() == null || imp.GetContactName().Length == 0)
                {
                    return(ProcessFail(imp, "No Name for User/Contact"));
                }

                user = new MUser(GetCtx(), 0, Get_TrxName());
                user.SetName(imp.GetContactName());
                user.SetDescription(imp.GetContactDescription());
                user.SetEMail(imp.GetEMail());
            }
            //	Existing User
            else
            {
                if (imp.IsEMailBounced())
                {
                    user.SetIsEMailBounced(true);
                    user.SetBouncedInfo(imp.GetBouncedInfo());
                }
            }
            if (!user.Save())
            {
                return(ProcessFail(imp, "Cannot save User"));
            }

            //	Create BP
            if (imp.IsCreateBP())
            {
                if (user.GetC_BPartner_ID() == 0)
                {
                    MBPartner bp = new MBPartner(GetCtx(), 0, Get_TrxName());
                    bp.SetName(user.GetName());
                    if (!bp.Save())
                    {
                        return(ProcessFail(imp, "Cannot create BPartner"));
                    }
                    else
                    {
                        user.SetC_BPartner_ID(bp.GetC_BPartner_ID());
                        if (!user.Save())
                        {
                            return(ProcessFail(imp, "Cannot update User"));
                        }
                    }
                }
                imp.SetC_BPartner_ID(user.GetC_BPartner_ID());
            }

            //	Create Lead
            if (imp.IsCreateLead())
            {
                MLead lead = new MLead(GetCtx(), 0, Get_TrxName());
                lead.SetName(imp.GetContactName());
                lead.SetDescription(imp.GetContactDescription());
                lead.SetAD_User_ID(user.GetAD_User_ID());
                lead.SetC_BPartner_ID(user.GetC_BPartner_ID());
                lead.Save();
                imp.SetC_Lead_ID(lead.GetC_Lead_ID());
            }

            //	Interest Area
            if (imp.GetR_InterestArea_ID() != 0 && user != null)
            {
                MContactInterest ci = MContactInterest.Get(GetCtx(),
                                                           imp.GetR_InterestArea_ID(), user.GetAD_User_ID(),
                                                           true, Get_TrxName());
                ci.Save();              //	don't subscribe or re-activate
            }

            imp.SetAD_User_ID(user.GetAD_User_ID());
            imp.SetI_IsImported(true);
            imp.SetI_ErrorMsg(null);
            imp.Save();
            return(true);
        }       //	process