SMS.ForDeliver in a bulk

Post Reply
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

SMS.ForDeliver in a bulk

Post by developerlearn999 »

i need to send to some customers all parts of the Delivered sms, and for some not.
for the ones which i need to send all parts, is there another way except looping through this and sending all 1 bulk?

Code: Select all

foreach (string internalId in internalIds)
            {
                var dlrBuilder = SMS.ForDeliver()............
                ..............
                client.Deliver(dlrBuilder).ConfigureAwait(false);
               } 
alt
Site Admin
Posts: 992
Joined: Tue Apr 25, 2006 9:45 am

Re: SMS.ForDeliver in a bulk

Post by alt »

client.Deliver method accept also a collection of DeliverSm PDUs.
You can create all PDUs with SMS.ForDeliver()...Create(client);, add all PDU in the collection and send it with one call of Deliver method.
This method sends all DeliverSm PDUs to the client and waits for all responses. When all responses are received, it returns collection of responses.
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: SMS.ForDeliver in a bulk

Post by developerlearn999 »

how do i do it?
i tried and got stuck
alt
Site Admin
Posts: 992
Joined: Tue Apr 25, 2006 9:45 am

Re: SMS.ForDeliver in a bulk

Post by alt »

Code: Select all

public async Task SubmitAll() 
{

   List<SubmitSm> pduToSubmit = new List<SubmitSm>();
   foreach (string internalId in internalIds)
   {
            
                var pduList = SMS.ForDeliver().......Create(client);
                
                pduToSubmit.AddRange(pduList );
   }
             
   var allResponses =  await  client.Deliver(pduToSubmit).ConfigureAwait(false); 
                
 }
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: SMS.ForDeliver in a bulk

Post by developerlearn999 »

shouldn't it be
List<DeliverSm> pduToSubmit = new List<DeliverSm>();
because the SMS.ForDeliver() return IDeliverSmBuilder.
i tried to change and add to list
pduToSubmit.AddRange(dlrBuilder);
but still i do something wrong.
thanks fr the help
alt
Site Admin
Posts: 992
Joined: Tue Apr 25, 2006 9:45 am

Re: SMS.ForDeliver in a bulk

Post by alt »

Sorry, you are right should be List<DeliverSm>.

You need to create PDUs from SMS builder:
pduToSubmit.AddRange(dlrBuilder.Create(client));
developerlearn999
Posts: 85
Joined: Thu Jun 20, 2019 9:34 am

Re: SMS.ForDeliver in a bulk

Post by developerlearn999 »

thanks!
Post Reply