SafeDispatch/ServiceGatewaySDR/SMSmanager.cs

61 lines
1.9 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using SafeMobileLib;
using SDRGatewayService.Enums;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SDRGatewayService
{
class SMSmanager
{
private static System.Threading.Timer tCheckMail;
private Thread t_CheckSMS_out;
private SDR sdr;
public SMSmanager(SDR _sdr)
{
sdr = _sdr;
//tCheckSMSqueue = new System.Threading.Timer(CheckQueue, null, new TimeSpan(0, 0, 5), new TimeSpan(0, 0, 5));
t_CheckSMS_out = new Thread(new ThreadStart(CheckQueue));
t_CheckSMS_out.IsBackground = true;
t_CheckSMS_out.Start();
}
private void CheckQueue()
{
while (true)
{
try
{
msgCell cell = Program.smsOutQueue.GetItem(100);
while (cell != null)
{
// if CallOut option is selected
if (ConfigHelper.SdrCallOut == 1)
sdr.SendCallOutMessage(Int32.Parse(cell.IMEI),
LIPSDR.Stds_CallOutAlertPDU_sdsEncoder(LIPSDR.callOutNumber++, LIPSDR.CallOutFunction.Clear, 3, 0x00, cell.sms, LIPSDR.TGctrl.TGControlNotUsed));
else
sdr.SEND_SMS(uint.Parse(cell.IMEI), cell.sms);
Thread.Sleep(100);
cell = Program.smsOutQueue.GetItem(100);
}
}
catch (Exception ex)
{
Utils.WriteEventLog(Program.COMPANY, "Error in SMSmanager/CheckQueue \n" + ex.ToString(), EventLogEntryType.Error, (int)EventId.EVENT_SMS);
Thread.Sleep(1000);
}
Thread.Sleep(1000);
}
}
}
}