2

I have some sms in database and I want to update their status when all task will be completed, I don't want to use task.Result or await on each submit becouse it works very slow. I need to pass sms Id to the clients and get the Id on response. I use Inetlab. any suggestions?

            var messagesNumber = 30;
            List<Task<SubmitSmResp[]>> tasks = new List<Task<SubmitSmResp[]>>();

            for (int i = 0; i < messagesNumber; i++)
            {
                tasks.Add(client.SubmitAsync(
                          SMS.ForSubmit()
                           .AddUserDataHeader(new Inetlab.SMPP.Headers.UserDataHeader(1, new byte[2]))
                              .From("test")
                              .To("2323")
                              .Coding(DataCodings.UCS2)
                              .Text($"{i}test")));
            }

            await Task.WhenAll(tasks);
            int k = 0; var thr = 0;
            foreach (var t in tasks)
            {
                var res = (SubmitSmResp[])t.Result;
                var ss = res.Select(x => x.Header.Sequence);
                if (res.All(x => x.Header.Status == CommandStatus.ESME_ROK))
                {
                    //want to update this sms in database,I need sms Id
                }
                if (res.All(x => x.Header.Status == CommandStatus.ESME_RTHROTTLED))
                {
                    //want to update this sms in database,I need sms Id
                    thr++;
                }
            }

Alexander
  • 4,420
  • 7
  • 27
  • 42
Saba Shavidze
  • 604
  • 4
  • 14

2 Answers2

0

What you can do in that case so that you can preserve the ID both on transmitting and receiving is to use a parameter. You can append the parameter when you prepare the sms for submit. Please take a look at the official documentation: https://docs.inetlab.com/smpp/v2/api/Inetlab.SMPP.Parameters.TLV.html

Andi Thomaj
  • 67
  • 2
  • 10
-1

GUID could be an option. You can use as a unique identifier.

Gauravsa
  • 6,330
  • 2
  • 21
  • 30
miciry89
  • 196
  • 1
  • 5