コード例 #1
0
        /// <summary>
        /// Process.
        /// <pre>
        /// - ignore 0 or invalid responses
        /// - rank among qty
        /// - for selected PO qty select winner
        /// - if all lines are winner - select that
        ///  </pre>
        /// </summary>
        /// <returns>message</returns>
        protected override String DoIt()
        {
            MRfQ rfq = new MRfQ(GetCtx(), _C_RfQ_ID, Get_TrxName());

            if (rfq.Get_ID() == 0)
            {
                throw new ArgumentException("No RfQ found");
            }
            log.Info(rfq.ToString());
            String error = rfq.CheckQuoteTotalAmtOnly();

            if (error != null && error.Length > 0)
            {
                throw new Exception(error);
            }

            //	Get Completed, Active Responses
            MRfQResponse[] responses = rfq.GetResponses(true, true);
            log.Fine("doIt - #Responses=" + responses.Length);
            if (responses.Length == 0)
            {
                throw new ArgumentException("No completed RfQ Responses found");
            }
            if (responses.Length == 1)
            {
                responses[0].SetIsSelectedWinner(true);
                responses[0].Save();
                throw new ArgumentException("Only one completed RfQ Response found");
            }

            //	Rank
            if (rfq.IsQuoteTotalAmtOnly())
            {
                RankResponses(rfq, responses);
            }
            else
            {
                RankLines(rfq, responses);
            }
            return("# " + responses.Length);
        }
コード例 #2
0
        /// <summary>
        /// Perform Process.
        /// </summary>
        /// <returns>Message (translated text)</returns>
        protected override String DoIt()
        {
            MRfQ rfq = new MRfQ(GetCtx(), _C_RfQ_ID, Get_TrxName());

            log.Info("doIt - " + rfq + ", Send=" + _IsSendRfQ);
            ////ErrorLog.FillErrorLog("", "", "doIt - " + rfq + ", Send=" + _IsSendRfQ, VAdvantage.Framework.Message.MessageType.INFORMATION);
            String error = rfq.CheckQuoteTotalAmtOnly();

            if (error != null && error.Length > 0)
            {
                throw new Exception(error);
            }

            int counter = 0;
            int sent    = 0;
            int notSent = 0;

            //	Get all existing responses
            MRfQResponse[] responses = rfq.GetResponses(false, false);

            //	Topic
            MRfQTopic topic = new MRfQTopic(GetCtx(), rfq.GetC_RfQ_Topic_ID(), Get_TrxName());

            MRfQTopicSubscriber[] subscribers = topic.GetSubscribers();
            for (int i = 0; i < subscribers.Length; i++)
            {
                MRfQTopicSubscriber subscriber = subscribers[i];
                bool skip = false;
                //	existing response
                for (int r = 0; r < responses.Length; r++)
                {
                    if (subscriber.GetC_BPartner_ID() == responses[r].GetC_BPartner_ID() &&
                        subscriber.GetC_BPartner_Location_ID() == responses[r].GetC_BPartner_Location_ID())
                    {
                        skip = true;
                        break;
                    }
                }
                if (skip)
                {
                    continue;
                }

                //	Create Response
                MRfQResponse response = new MRfQResponse(rfq, subscriber);
                if (response.Get_ID() == 0)     //	no lines
                {
                    continue;
                }

                counter++;
                if (_IsSendRfQ)//send mail check
                {
                    if (response.SendRfQ())
                    {
                        sent++;
                    }
                    else
                    {
                        notSent++;
                    }
                }
            }   //	for all subscribers

            String retValue = "@Created@ " + counter;

            if (_IsSendRfQ)
            {
                retValue += " - @IsSendRfQ@=" + sent + " - @Error@=" + notSent;
            }
            return(retValue);
        }