private void LoadLogs() { jobSys = SmsFactory.getSystem("eJobs"); //get unset list from db DataTable MessageList = jobSys.getLogs(); //convert datasource to list List <DataRow> Messagelist = MessageList.AsEnumerable().ToList(); LogsTablePanel.RowCount = 0; LogsTablePanel.Controls.Clear(); foreach (DataRow row in MessageList.Rows) { string notificationID = row["NotficationId"].ToString(); string serviceId = row["ServiceId"].ToString(); string clientName = row["ClientName"].ToString(); string message = row["Message"].ToString(); string schedule = row["DTlog"].ToString(); string status = row["Status"].ToString(); LogsControl logs = new LogsControl(); logs.setDetails(Int32.Parse(notificationID), Int32.Parse(serviceId), clientName, status); //SMSinbox msgbox = new SMSinbox(); //msgbox.setContent(Int32.Parse(notificationID), ClientName, message, Schedule, msgStatus); LogsTablePanel.RowCount = LogsTablePanel.RowCount + 1; LogsTablePanel.Controls.Add(logs); } }
/// <summary> /// Send simple test message using HTTP GET API /// </summary> /// <param name="customerId"></param> /// <param name="password"></param> /// <param name="destinationAddress"></param> /// <param name="message"></param> public static void SendSmsMessage(int customerId, string password, long destinationAddress, string message) { //Send 1. var result1 = SmsFactory.SendSms(new SmsHttpMessage { Category = "TEST-MESSAGES", CustomerId = customerId, CustomerPassword = password, DestinationAddress = destinationAddress, Expires = DateTime.Now.AddHours(1), GatewayNumber = 99700999, Price = 0, Qos = 3, //<- Set to 1 if sending password or something that needs to be delivered quickly MessageId = Guid.NewGuid().ToString().Replace("-", ""), MessageType = "11", //<- By specifying 11 the remote server will split message into concatenated if text exceeds 160 chars UserData = message, OriginatorAddress = "+4799700999" }); // TODO: //Just print output to console. You should handle each message and it's status and returned parameters here. Console.WriteLine(JsonSerializer.SerializeToString(result1)); //Print result: if (result1.Success) { //OK } else { //Failed } }
private void LoadSentItems() { jobSys = SmsFactory.getSystem("eJobs"); //get unset list from db DataTable MessageList = jobSys.getRecord(); //convert datasource to list List <DataRow> Messagelist = MessageList.AsEnumerable().ToList(); tableLayoutPanel1.RowCount = 0; tableLayoutPanel1.Controls.Clear(); foreach (DataRow row in MessageList.Rows) { string notificationID = row["NotficationId"].ToString(); string ClientName = row["ClientName"].ToString(); string message = row["Message"].ToString(); string Schedule = row["DTlog"].ToString(); string msgStatus = row["Status"].ToString(); SMSinbox msgbox = new SMSinbox(); msgbox.setContent(Int32.Parse(notificationID), ClientName, message, Schedule, msgStatus); tableLayoutPanel1.RowCount = tableLayoutPanel1.RowCount + 1; tableLayoutPanel1.Controls.Add(msgbox); } }
Sms MaterializeSmsFromDto(SmsDTO smsDTO) { var current = SmsFactory.CreateSms(smsDTO.Code, smsDTO.Mobile, smsDTO.Type, smsDTO.IP, smsDTO.ValidateState); current.ChangeCurrentIdentity(smsDTO.Id); return(current); }
private void SendBtn_Click(object sender, EventArgs e) { jobSys = SmsFactory.getSystem("eJobs"); jobSys.SendSMS("09950753794", "Pickup Details" + "Date:18 Jul 2018 (Wed)" + "Time&Location:12:00:00 Airport" + "Guest:Admin Test #09950753794" + "Driver:Supplier #09950753794" + "Unit:Default "); //jobSys.updateRecordStatus(1); //jobSys.insertLog(2003,"Sent"); //LoadSentItems(); LoadLogs(); }
/// <summary> /// news a account /// </summary> /// <param name="praiseDTO"></param> /// <returns></returns> public SmsDTO AddNewSms(SmsDTO smsDTO) { //check preconditions if (smsDTO == null) { throw new ArgumentException(Messages.warning_CannotAddSmsWithEmptyInformation); } //Create the entity and the required associated data var sms = SmsFactory.CreateSms(smsDTO.Code, smsDTO.Mobile, smsDTO.Type, smsDTO.IP, smsDTO.ValidateState); //save entity SaveSms(sms); //return the data with id and assigned default values return(sms.ProjectedAs <SmsDTO>()); }
/// <summary> /// Send Sms message using SOAP API /// </summary> /// <param name="customerId"></param> /// <param name="password"></param> /// <param name="destinationAddress"></param> /// <param name="message"></param> public static void SendSmsMessageSoap(int customerId, string password, long destinationAddress, string message) { //Send 1. var result1 = SmsFactory.SendSms(new SmsSoapApi.SendSMSRequest { Authorizer = new SmsSoapApi.Authorizer { CustomerID = customerId, Password = password }, smsObj = new SmsSoapApi.SMSMessage { Category = "TEST-MESSAGES", CustomData = "qos=3", DeliveryReportUrl = string.Empty, DestinationAddress = destinationAddress.ToString(), Gateway = "99700999", MessageID = Guid.NewGuid().ToString().Replace("-", ""), MessageType = "11", OriginatorAddress = "+4799700999", Price = 0, ServiceCode = string.Empty, ServiceDescription = string.Empty, ValidationPeriod = DateTime.Now.AddHours(1).ToString("ddmmyyyyHHmmss"), UserDataHeader = string.Empty, UserData = message } }); // TODO: //Just print output to console. You should handle each message and it's status and returned parameters here. Console.WriteLine(JsonSerializer.SerializeToString(result1)); //Print result: if (result1.StatusCode == 0) { //OK } else { //Failed } }
private void LoadMsgPending() { jobSys = SmsFactory.getSystem("eJobs"); //get unset list from db DataTable MessageList = jobSys.getUnsentItemsOnline(); try { //convert datasource to list List <DataRow> Messagelist = MessageList.AsEnumerable().ToList(); tableLayoutPanel1.RowCount = 0; foreach (DataRow row in MessageList.Rows) { string rqID = row["RequestId"].ToString(); string svcID = row["RequestId"].ToString(); string jobId = row["ServiceID"].ToString(); int serviceID = Int32.Parse(svcID); string recipient = row["Recipient"].ToString(); string message = row["Message"].ToString(); string Schedule = row["DTSchedule"].ToString(); string RefId = row["RecType"].ToString(); string ClientName = row["ClientName"].ToString(); //messageStatus = LabSys.SendSMS(recipient, message); //uncomment to enable sending //Console.WriteLine("notificationID: " + serviceID); Console.WriteLine("recipient: " + recipient); //Console.WriteLine("message: " + message); //Console.WriteLine("Schedule: " + Schedule); //Console.WriteLine("RefId: " + RefId); string msgStatus = "Pending"; //check if service id have record in local db if (jobSys.checkrecord(serviceID)) //true if serviceID has record on local db { Console.WriteLine("ID " + serviceID + ", Has Record on local. "); //get notification referenceID int refID = Int32.Parse(jobSys.getRefID(svcID)); Console.WriteLine("RefID : " + refID); //check record status if (jobSys.checkstatus(serviceID)) { Console.WriteLine("Status: Sent"); //possible scenario, status on online db is PENDING, //while status on localdb is SENT //Action: update online db //update onlinedb jobSys.updateRecordOnline(serviceID, refID); } else //local db notification status is PENDING { Console.WriteLine("Status: Pending, Attempting to Send Message."); //attempt to sms //get response (Sent/Failed) string response = "Sent"; //response = jobSys.SendSMS("09950753794", "Test from eJobs Manger program "); response = jobSys.sendMessageOnList(refID, message); if (response == "Sent") { //update onlinedb jobSys.updateRecordOnline(serviceID, refID); //update localdb Console.WriteLine("serviceID: " + serviceID); jobSys.updateRecordStatus(serviceID); //insert sent to log jobSys.insertLog(refID, "Sent"); } else //COM error / Failed //insert failed to log, //no update on notification status //to resend on next refresh { jobSys.insertLog(refID, response); } } Console.WriteLine("Updating Record Successful"); } else { Console.WriteLine("ID " + serviceID + ", Has NO Record on local. "); Console.WriteLine("Adding NEW record to the Local Database"); //add record to the db jobSys.insertRecord(svcID, jobId, "1", message, Schedule, "Pending"); //add message to view Console.WriteLine("adding sms inbox "); //get notification referenceID Console.WriteLine("getRefID : " + svcID); int refID = Int32.Parse(jobSys.getRefID(svcID)); Console.WriteLine("recipient: " + recipient); //add Recipients to the table // Split string on spaces. // ... This will separate all the words. string[] recipients = recipient.Split(','); foreach (string number in recipients) { Console.WriteLine("Recipient " + number + "added - RefID: " + refID); jobSys.insertRecipients(refID.ToString(), number); } Console.WriteLine("Adding Record Successful"); } //inset new activity log //LabSys.SetActivityLog(notificationID, messageStatus, "none"); // break; } } catch (Exception ex) { Console.WriteLine("No Pending Record"); } }
public SmsService(SmsFactory smsFactory, IConfiguration configuration, MongoRepository mongoProxy) { _smsFactory = smsFactory; _configuration = configuration; _mongoProxy = mongoProxy; }
/// <summary> /// Simple Send message test using REST API /// </summary> /// <param name="customerId"></param> /// <param name="password"></param> /// <param name="destinationAddress"></param> /// <param name="message"></param> public static void SendSmsMessageRestApi(int customerId, string password, long destinationAddress, string message) { //Create main request object var restRequest = new RestSmsRequest(); restRequest.Username = customerId.ToString(); //Your Intele Customer Id restRequest.Password = password; //Your Intele Password //Create a message and store in temp list var msgList = new List <RestSmsMessageReq>(); var addMsg = new RestSmsMessageReq { Category = "TEST-MESSAGES", DeliveryReportUrl = string.Empty, //Set to your server uri to receive delivery reports to verify that the message is delivered DestinationAddress = destinationAddress, Gateway = 99700999, MessageId = Guid.NewGuid().ToString().Replace("-", ""), MessageType = "11", //MessageType 11 allows more than default 160 characters. Message is automaticly splitted into parts on server using this MessageType value OriginatorAddress = "+4799700999", //Could be +4797513609 or any valid international mobile number Price = 0, ServiceCode = string.Empty, ServiceDescription = string.Empty, ValidationPeriod = DateTime.Now.AddHours(1).ToString("ddMMyyyyHHmmss"), //Set delivery to timeout if message is not received by end-user in 2 hours. UserDataHeader = string.Empty, //Only used on concatenated messages, or binary messages with MessageType 10 UserData = message, CustomData = addProps("qos=3") }; msgList.Add(addMsg); //Inline function for adding properties to CustomData //Takes input value formatted as value=data,value2=data2 etc Dictionary <string, string> addProps(string addValues) { var addList = new Dictionary <string, string>(); if (string.IsNullOrEmpty(addValues) || addValues.IndexOf("=") == -1) { return(addList); } var addParams = addValues.Split(','); foreach (var p in addParams) { addList.Add(p.Split('=')[0], p.Split('=')[1]); } return(addList); } restRequest.Messages = msgList.ToArray(); var response = SmsFactory.SendSms(restRequest); // TODO: //Just print output to console. You should handle each message and it's status and returned parameters here. Console.WriteLine(JsonSerializer.SerializeToString(response)); }