| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/New folder/New folder/software/Services/Penpal SMPP - Transmitter/SMPP/ |
Upload File : |
//------------------------------------------------------------------------------
// SMSC Server components SMPP sample application
//
// $Header: $
// Copyright (c) 2003-2006 Tops. All rights reserved.
//--------------------------------------------------------------------------
using System;
using System.IO;
using System.Windows.Forms;
using System.Text;
using smscs.SMPP;
using smscc;
using smscc.SMPP;
using smsce;
using smsce.SMS;
using MySql.Data.MySqlClient;
using System.Text.RegularExpressions;
using System.Net;
using System.Linq;
using System.Xml;
using System.Web;
using System.Xml.Linq;
namespace sampleSMPP
{
public class fmMain : System.Windows.Forms.Form
{
public System.Windows.Forms.TextBox txtDestTON;
public System.Windows.Forms.TextBox txtDestNPI;
public System.Windows.Forms.TextBox txtOrigTON;
public System.Windows.Forms.TextBox txtOrigNPI;
public System.Windows.Forms.TextBox txtOriginator;
public System.Windows.Forms.TextBox txtDestination;
public System.Windows.Forms.TextBox txtLog;
public System.Windows.Forms.TextBox txtPort;
public System.Windows.Forms.Label Label17;
public System.Windows.Forms.Label Line2;
public System.Windows.Forms.Label Label12;
public System.Windows.Forms.Label Label9;
public System.Windows.Forms.Label Label7;
public System.Windows.Forms.Label Label6;
public System.Windows.Forms.Label Label2;
private System.Windows.Forms.Button cmdClose;
public System.Windows.Forms.Label label1;
public System.Windows.Forms.Label label18;
public System.Windows.Forms.Button cmdDeliverMessage;
public System.Windows.Forms.Button cmdDeliverStatusReport;
public System.Windows.Forms.Label label3;
public System.Windows.Forms.Label label4;
public System.Windows.Forms.Label label5;
public System.Windows.Forms.Label label8;
private System.Windows.Forms.ComboBox cbMessageStatus;
private System.Windows.Forms.ComboBox cbClients;
public System.Windows.Forms.TextBox txtMessageID;
public System.Windows.Forms.Button cmdStartServer;
public System.Windows.Forms.Button cmdStopServer;
private System.ComponentModel.IContainer components;
public System.Windows.Forms.TextBox txtMessage;
private int sequenceNumber;
private smscs.SMPP.SMSCserverSMPP SMSCserverSMPP;
private int messageNumber;
private Timer timer1;
private smscc.SMPP.SMSCclientSMPP SMSCclientSMPP;
private smscc.SMPP.SMSCclientSMPP smsCclientSMPP1;
private smscc.SMPP.SMSCclientSMPP smsCclientSMPP2;
private smscc.SMPP.SMSCclientSMPP smsCclientSMPP3;
private smscc.SMPP.SMSCclientSMPP smsCclientSMPP4;
private Label label10;
private Label label11;
private TextBox textBox1;
private TextBox textBox2;
private Label label13;
private Label label14;
private TextBox textBox3;
private TextBox textBox4;
private Label label15;
private Label label16;
private Label label19;
private Label label20;
private Label label21;
private Label label22;
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private TextBox textBox5;
private TextBox textBox6;
private TextBox textBox7;
private TextBox textBox8;
private TextBox textBox9;
private TextBox textBox10;
private Button button5;
private MySqlConnection connection;
private string server;
private string database;
private string uid;
private string password;
private string query;
private string serialno;
private string messtype;
private string phonenumber;
private string mymessage;
private string senderid;
private string username;
private string transid;
private string billcode;
private TextBox textBox11;
private TextBox textBox12;
private TextBox textBox13;
private TextBox textBox14;
private TextBox textBox15;
private TextBox textBox16;
private TextBox textBox17;
private TextBox textBox18;
private TextBox textBox19;
private TextBox textBox20;
private Label label23;
private Label label24;
private Label label25;
private Label label26;
private Label label27;
private Label label28;
private Label label29;
private Label label30;
private Label label31;
private Label label32;
private Label label33;
private Button button6;
private Label label34;
private Label label35;
private Label label36;
private Label label37;
private bool bConnected1 = false;
private bool bServiceReady1 = false;
private bool bConnected2 = false;
private bool bServiceReady2 = false;
private bool bConnected3= false;
private bool bServiceReady3 = false;
private bool bConnected4 = false;
private Button button7;
private Button button8;
private Button button9;
private Button button10;
private Button button11;
private Button button12;
private Timer timer2;
private Timer timer3;
private Timer timer4;
string MessageID;
private Timer timer5;
private Button button13;
private Button button14;
private bool bServiceReady4 = false;
int cnt1 = 0;
int cnt2 = 0;
int cnt3 = 0;
int cnt4 = 0;
int cnt9 =1;//for transid;
private Label label38;
private TextBox textBox21;
int cnt7 = 0;
public fmMain()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.txtDestTON = new System.Windows.Forms.TextBox();
this.txtDestNPI = new System.Windows.Forms.TextBox();
this.txtOrigTON = new System.Windows.Forms.TextBox();
this.txtOrigNPI = new System.Windows.Forms.TextBox();
this.txtOriginator = new System.Windows.Forms.TextBox();
this.cmdDeliverMessage = new System.Windows.Forms.Button();
this.txtDestination = new System.Windows.Forms.TextBox();
this.txtLog = new System.Windows.Forms.TextBox();
this.cmdDeliverStatusReport = new System.Windows.Forms.Button();
this.txtMessage = new System.Windows.Forms.TextBox();
this.cmdStopServer = new System.Windows.Forms.Button();
this.txtPort = new System.Windows.Forms.TextBox();
this.cmdStartServer = new System.Windows.Forms.Button();
this.Label17 = new System.Windows.Forms.Label();
this.Line2 = new System.Windows.Forms.Label();
this.Label12 = new System.Windows.Forms.Label();
this.Label9 = new System.Windows.Forms.Label();
this.Label7 = new System.Windows.Forms.Label();
this.Label6 = new System.Windows.Forms.Label();
this.Label2 = new System.Windows.Forms.Label();
this.cmdClose = new System.Windows.Forms.Button();
this.cbClients = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txtMessageID = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.cbMessageStatus = new System.Windows.Forms.ComboBox();
this.label8 = new System.Windows.Forms.Label();
this.SMSCserverSMPP = new smscs.SMPP.SMSCserverSMPP();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SMSCclientSMPP = new smscc.SMPP.SMSCclientSMPP();
this.smsCclientSMPP1 = new smscc.SMPP.SMSCclientSMPP();
this.smsCclientSMPP2 = new smscc.SMPP.SMSCclientSMPP();
this.smsCclientSMPP3 = new smscc.SMPP.SMSCclientSMPP();
this.smsCclientSMPP4 = new smscc.SMPP.SMSCclientSMPP();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label15 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.textBox7 = new System.Windows.Forms.TextBox();
this.textBox8 = new System.Windows.Forms.TextBox();
this.textBox9 = new System.Windows.Forms.TextBox();
this.textBox10 = new System.Windows.Forms.TextBox();
this.button5 = new System.Windows.Forms.Button();
this.textBox11 = new System.Windows.Forms.TextBox();
this.textBox12 = new System.Windows.Forms.TextBox();
this.textBox13 = new System.Windows.Forms.TextBox();
this.textBox14 = new System.Windows.Forms.TextBox();
this.textBox15 = new System.Windows.Forms.TextBox();
this.textBox16 = new System.Windows.Forms.TextBox();
this.textBox17 = new System.Windows.Forms.TextBox();
this.textBox18 = new System.Windows.Forms.TextBox();
this.textBox19 = new System.Windows.Forms.TextBox();
this.textBox20 = new System.Windows.Forms.TextBox();
this.label23 = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.label25 = new System.Windows.Forms.Label();
this.label26 = new System.Windows.Forms.Label();
this.label27 = new System.Windows.Forms.Label();
this.label28 = new System.Windows.Forms.Label();
this.label29 = new System.Windows.Forms.Label();
this.label30 = new System.Windows.Forms.Label();
this.label31 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.label33 = new System.Windows.Forms.Label();
this.button6 = new System.Windows.Forms.Button();
this.label34 = new System.Windows.Forms.Label();
this.label35 = new System.Windows.Forms.Label();
this.label36 = new System.Windows.Forms.Label();
this.label37 = new System.Windows.Forms.Label();
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.timer4 = new System.Windows.Forms.Timer(this.components);
this.timer5 = new System.Windows.Forms.Timer(this.components);
this.button13 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.label38 = new System.Windows.Forms.Label();
this.textBox21 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtDestTON
//
this.txtDestTON.AcceptsReturn = true;
this.txtDestTON.BackColor = System.Drawing.SystemColors.Window;
this.txtDestTON.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtDestTON.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtDestTON.Location = new System.Drawing.Point(463, 285);
this.txtDestTON.MaxLength = 0;
this.txtDestTON.Name = "txtDestTON";
this.txtDestTON.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtDestTON.Size = new System.Drawing.Size(24, 20);
this.txtDestTON.TabIndex = 15;
this.txtDestTON.Text = "1";
//
// txtDestNPI
//
this.txtDestNPI.AcceptsReturn = true;
this.txtDestNPI.BackColor = System.Drawing.SystemColors.Window;
this.txtDestNPI.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtDestNPI.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtDestNPI.Location = new System.Drawing.Point(296, 253);
this.txtDestNPI.MaxLength = 0;
this.txtDestNPI.Name = "txtDestNPI";
this.txtDestNPI.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtDestNPI.Size = new System.Drawing.Size(24, 20);
this.txtDestNPI.TabIndex = 16;
this.txtDestNPI.Text = "1";
//
// txtOrigTON
//
this.txtOrigTON.AcceptsReturn = true;
this.txtOrigTON.BackColor = System.Drawing.SystemColors.Window;
this.txtOrigTON.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtOrigTON.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtOrigTON.Location = new System.Drawing.Point(526, 317);
this.txtOrigTON.MaxLength = 0;
this.txtOrigTON.Name = "txtOrigTON";
this.txtOrigTON.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtOrigTON.Size = new System.Drawing.Size(51, 20);
this.txtOrigTON.TabIndex = 12;
this.txtOrigTON.Text = "1";
this.txtOrigTON.TextChanged += new System.EventHandler(this.txtOrigTON_TextChanged);
//
// txtOrigNPI
//
this.txtOrigNPI.AcceptsReturn = true;
this.txtOrigNPI.BackColor = System.Drawing.SystemColors.Window;
this.txtOrigNPI.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtOrigNPI.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtOrigNPI.Location = new System.Drawing.Point(412, 336);
this.txtOrigNPI.MaxLength = 0;
this.txtOrigNPI.Name = "txtOrigNPI";
this.txtOrigNPI.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtOrigNPI.Size = new System.Drawing.Size(24, 20);
this.txtOrigNPI.TabIndex = 13;
this.txtOrigNPI.Text = "1";
//
// txtOriginator
//
this.txtOriginator.AcceptsReturn = true;
this.txtOriginator.BackColor = System.Drawing.SystemColors.Window;
this.txtOriginator.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtOriginator.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtOriginator.Location = new System.Drawing.Point(489, 415);
this.txtOriginator.MaxLength = 0;
this.txtOriginator.Name = "txtOriginator";
this.txtOriginator.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtOriginator.Size = new System.Drawing.Size(136, 20);
this.txtOriginator.TabIndex = 11;
//
// cmdDeliverMessage
//
this.cmdDeliverMessage.BackColor = System.Drawing.SystemColors.Control;
this.cmdDeliverMessage.Cursor = System.Windows.Forms.Cursors.Default;
this.cmdDeliverMessage.ForeColor = System.Drawing.SystemColors.ControlText;
this.cmdDeliverMessage.Location = new System.Drawing.Point(813, 483);
this.cmdDeliverMessage.Name = "cmdDeliverMessage";
this.cmdDeliverMessage.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cmdDeliverMessage.Size = new System.Drawing.Size(69, 23);
this.cmdDeliverMessage.TabIndex = 2;
this.cmdDeliverMessage.Text = "Deliver";
this.cmdDeliverMessage.UseVisualStyleBackColor = false;
this.cmdDeliverMessage.Click += new System.EventHandler(this.cmdDeliverMessage_Click);
//
// txtDestination
//
this.txtDestination.AcceptsReturn = true;
this.txtDestination.BackColor = System.Drawing.SystemColors.Window;
this.txtDestination.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtDestination.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtDestination.Location = new System.Drawing.Point(489, 389);
this.txtDestination.MaxLength = 0;
this.txtDestination.Name = "txtDestination";
this.txtDestination.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtDestination.Size = new System.Drawing.Size(136, 20);
this.txtDestination.TabIndex = 14;
//
// txtLog
//
this.txtLog.AcceptsReturn = true;
this.txtLog.BackColor = System.Drawing.SystemColors.Window;
this.txtLog.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtLog.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtLog.Location = new System.Drawing.Point(17, 415);
this.txtLog.MaxLength = 0;
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.ReadOnly = true;
this.txtLog.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtLog.Size = new System.Drawing.Size(408, 101);
this.txtLog.TabIndex = 22;
this.txtLog.WordWrap = false;
//
// cmdDeliverStatusReport
//
this.cmdDeliverStatusReport.BackColor = System.Drawing.SystemColors.Control;
this.cmdDeliverStatusReport.Cursor = System.Windows.Forms.Cursors.Default;
this.cmdDeliverStatusReport.ForeColor = System.Drawing.SystemColors.ControlText;
this.cmdDeliverStatusReport.Location = new System.Drawing.Point(451, 483);
this.cmdDeliverStatusReport.Name = "cmdDeliverStatusReport";
this.cmdDeliverStatusReport.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cmdDeliverStatusReport.Size = new System.Drawing.Size(69, 23);
this.cmdDeliverStatusReport.TabIndex = 3;
this.cmdDeliverStatusReport.Text = "Deliver";
this.cmdDeliverStatusReport.UseVisualStyleBackColor = false;
this.cmdDeliverStatusReport.Click += new System.EventHandler(this.cmdDeliverStatusReport_Click);
//
// txtMessage
//
this.txtMessage.AcceptsReturn = true;
this.txtMessage.BackColor = System.Drawing.SystemColors.Window;
this.txtMessage.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtMessage.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtMessage.Location = new System.Drawing.Point(538, 453);
this.txtMessage.MaxLength = 0;
this.txtMessage.Multiline = true;
this.txtMessage.Name = "txtMessage";
this.txtMessage.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtMessage.Size = new System.Drawing.Size(256, 53);
this.txtMessage.TabIndex = 17;
//
// cmdStopServer
//
this.cmdStopServer.BackColor = System.Drawing.SystemColors.Control;
this.cmdStopServer.Cursor = System.Windows.Forms.Cursors.Default;
this.cmdStopServer.ForeColor = System.Drawing.SystemColors.ControlText;
this.cmdStopServer.Location = new System.Drawing.Point(205, 205);
this.cmdStopServer.Name = "cmdStopServer";
this.cmdStopServer.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cmdStopServer.Size = new System.Drawing.Size(69, 23);
this.cmdStopServer.TabIndex = 1;
this.cmdStopServer.Text = "Stop";
this.cmdStopServer.UseVisualStyleBackColor = false;
this.cmdStopServer.Click += new System.EventHandler(this.cmdStopServer_Click);
//
// txtPort
//
this.txtPort.AcceptsReturn = true;
this.txtPort.BackColor = System.Drawing.SystemColors.Window;
this.txtPort.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtPort.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtPort.Location = new System.Drawing.Point(92, 208);
this.txtPort.MaxLength = 0;
this.txtPort.Name = "txtPort";
this.txtPort.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtPort.Size = new System.Drawing.Size(88, 20);
this.txtPort.TabIndex = 5;
this.txtPort.Text = "2345";
//
// cmdStartServer
//
this.cmdStartServer.BackColor = System.Drawing.SystemColors.Control;
this.cmdStartServer.Cursor = System.Windows.Forms.Cursors.Default;
this.cmdStartServer.ForeColor = System.Drawing.SystemColors.ControlText;
this.cmdStartServer.Location = new System.Drawing.Point(418, 208);
this.cmdStartServer.Name = "cmdStartServer";
this.cmdStartServer.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cmdStartServer.Size = new System.Drawing.Size(69, 23);
this.cmdStartServer.TabIndex = 0;
this.cmdStartServer.Text = "Start";
this.cmdStartServer.UseVisualStyleBackColor = false;
this.cmdStartServer.Click += new System.EventHandler(this.cmdStartServer_Click);
//
// Label17
//
this.Label17.AutoSize = true;
this.Label17.BackColor = System.Drawing.SystemColors.Control;
this.Label17.Cursor = System.Windows.Forms.Cursors.Default;
this.Label17.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label17.Location = new System.Drawing.Point(20, 391);
this.Label17.Name = "Label17";
this.Label17.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label17.Size = new System.Drawing.Size(55, 13);
this.Label17.TabIndex = 84;
this.Label17.Text = "Event log:";
//
// Line2
//
this.Line2.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.Line2.Location = new System.Drawing.Point(12, 377);
this.Line2.Name = "Line2";
this.Line2.Size = new System.Drawing.Size(424, 1);
this.Line2.TabIndex = 85;
//
// Label12
//
this.Label12.AutoSize = true;
this.Label12.BackColor = System.Drawing.SystemColors.Control;
this.Label12.Cursor = System.Windows.Forms.Cursors.Default;
this.Label12.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label12.Location = new System.Drawing.Point(616, 324);
this.Label12.Name = "Label12";
this.Label12.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label12.Size = new System.Drawing.Size(56, 13);
this.Label12.TabIndex = 78;
this.Label12.Text = "TON/NPI:";
//
// Label9
//
this.Label9.AutoSize = true;
this.Label9.BackColor = System.Drawing.SystemColors.Control;
this.Label9.Cursor = System.Windows.Forms.Cursors.Default;
this.Label9.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label9.Location = new System.Drawing.Point(636, 292);
this.Label9.Name = "Label9";
this.Label9.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label9.Size = new System.Drawing.Size(55, 13);
this.Label9.TabIndex = 76;
this.Label9.Text = "Originator:";
//
// Label7
//
this.Label7.AutoSize = true;
this.Label7.BackColor = System.Drawing.SystemColors.Control;
this.Label7.Cursor = System.Windows.Forms.Cursors.Default;
this.Label7.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label7.Location = new System.Drawing.Point(685, 343);
this.Label7.Name = "Label7";
this.Label7.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label7.Size = new System.Drawing.Size(53, 13);
this.Label7.TabIndex = 74;
this.Label7.Text = "Message:";
//
// Label6
//
this.Label6.AutoSize = true;
this.Label6.BackColor = System.Drawing.SystemColors.Control;
this.Label6.Cursor = System.Windows.Forms.Cursors.Default;
this.Label6.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label6.Location = new System.Drawing.Point(616, 255);
this.Label6.Name = "Label6";
this.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label6.Size = new System.Drawing.Size(63, 13);
this.Label6.TabIndex = 73;
this.Label6.Text = "Destination:";
//
// Label2
//
this.Label2.AutoSize = true;
this.Label2.BackColor = System.Drawing.SystemColors.Control;
this.Label2.Cursor = System.Windows.Forms.Cursors.Default;
this.Label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label2.Location = new System.Drawing.Point(20, 208);
this.Label2.Name = "Label2";
this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label2.Size = new System.Drawing.Size(29, 13);
this.Label2.TabIndex = 69;
this.Label2.Text = "Port:";
//
// cmdClose
//
this.cmdClose.Location = new System.Drawing.Point(296, 206);
this.cmdClose.Name = "cmdClose";
this.cmdClose.Size = new System.Drawing.Size(100, 23);
this.cmdClose.TabIndex = 89;
this.cmdClose.Text = "Disconnect ";
this.cmdClose.Click += new System.EventHandler(this.cmdClose_Click);
//
// cbClients
//
this.cbClients.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbClients.Location = new System.Drawing.Point(87, 257);
this.cbClients.Name = "cbClients";
this.cbClients.Size = new System.Drawing.Size(88, 21);
this.cbClients.TabIndex = 90;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.SystemColors.Control;
this.label1.Cursor = System.Windows.Forms.Cursors.Default;
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(14, 260);
this.label1.Name = "label1";
this.label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label1.Size = new System.Drawing.Size(50, 13);
this.label1.TabIndex = 91;
this.label1.Text = "Client ID:";
//
// label18
//
this.label18.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.label18.Location = new System.Drawing.Point(12, 201);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(840, 1);
this.label18.TabIndex = 92;
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.SystemColors.Control;
this.label3.Cursor = System.Windows.Forms.Cursors.Default;
this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
this.label3.Location = new System.Drawing.Point(369, 343);
this.label3.Name = "label3";
this.label3.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label3.Size = new System.Drawing.Size(56, 13);
this.label3.TabIndex = 93;
this.label3.Text = "TON/NPI:";
//
// label4
//
this.label4.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.label4.Location = new System.Drawing.Point(12, 244);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(424, 1);
this.label4.TabIndex = 94;
//
// txtMessageID
//
this.txtMessageID.AcceptsReturn = true;
this.txtMessageID.BackColor = System.Drawing.SystemColors.Window;
this.txtMessageID.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txtMessageID.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtMessageID.Location = new System.Drawing.Point(87, 307);
this.txtMessageID.MaxLength = 0;
this.txtMessageID.Name = "txtMessageID";
this.txtMessageID.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtMessageID.Size = new System.Drawing.Size(256, 20);
this.txtMessageID.TabIndex = 95;
//
// label5
//
this.label5.AutoSize = true;
this.label5.BackColor = System.Drawing.SystemColors.Control;
this.label5.Cursor = System.Windows.Forms.Cursors.Default;
this.label5.ForeColor = System.Drawing.SystemColors.ControlText;
this.label5.Location = new System.Drawing.Point(14, 310);
this.label5.Name = "label5";
this.label5.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label5.Size = new System.Drawing.Size(67, 13);
this.label5.TabIndex = 96;
this.label5.Text = "Message ID:";
//
// cbMessageStatus
//
this.cbMessageStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbMessageStatus.Items.AddRange(new object[] {
"Message \"en route\" (1, msEnRoute)",
"Message delivered (2, msDelivered)",
"Message expired (3, msExpired)",
"Message deleted (4, msDeleted)",
"Message undelivereable (5, msUndeliverable)",
"Message accepted (6, msAccepted)",
"State unknown (7, msUnknown)",
"Message rejected (8, msRejected)"});
this.cbMessageStatus.Location = new System.Drawing.Point(74, 343);
this.cbMessageStatus.Name = "cbMessageStatus";
this.cbMessageStatus.Size = new System.Drawing.Size(274, 21);
this.cbMessageStatus.TabIndex = 97;
//
// label8
//
this.label8.AutoSize = true;
this.label8.BackColor = System.Drawing.SystemColors.Control;
this.label8.Cursor = System.Windows.Forms.Cursors.Default;
this.label8.ForeColor = System.Drawing.SystemColors.ControlText;
this.label8.Location = new System.Drawing.Point(20, 324);
this.label8.Name = "label8";
this.label8.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label8.Size = new System.Drawing.Size(40, 13);
this.label8.TabIndex = 98;
this.label8.Text = "Status:";
//
// SMSCserverSMPP
//
this.SMSCserverSMPP.KeepAliveInterval = 30;
this.SMSCserverSMPP.ThrottleRate = 0;
this.SMSCserverSMPP.OnTcpConnected += new smscs.tcpConnectedEvent(this.SMSCserverSMPP_OnTcpConnected);
this.SMSCserverSMPP.OnTcpDisconnected += new smscs.tcpDisconnectedEvent(this.SMSCserverSMPP_OnTcpDisconnected);
this.SMSCserverSMPP.OnSmppRAWReceived += new smscs.SMPP.smppRAWReceivedEvent(this.SMSCserverSMPP_OnSmppRAWReceived);
this.SMSCserverSMPP.OnSmppLoginReceived += new smscs.SMPP.smppLoginReceivedEvent(this.SMSCserverSMPP_OnSmppLoginReceived);
this.SMSCserverSMPP.OnSmppLogoutReceived += new smscs.SMPP.smppLogoutReceivedEvent(this.SMSCserverSMPP_OnSmppLogoutReceived);
this.SMSCserverSMPP.OnSmppDeliverResponseReceived += new smscs.SMPP.smppDeliverResponseReceivedEvent(this.SMSCserverSMPP_OnSmppDeliverResponseReceived);
this.SMSCserverSMPP.OnSmppSubmitMessageReceived += new smscs.SMPP.smppSubmitMessageReceivedEvent(this.SMSCserverSMPP_OnSmppSubmitMessageReceived);
//
// timer1
//
this.timer1.Interval = 5000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// SMSCclientSMPP
//
this.SMSCclientSMPP.ImmediateResponse = false;
this.SMSCclientSMPP.KeepAliveInterval = 30;
this.SMSCclientSMPP.ResponseTimeOut = 30;
this.SMSCclientSMPP.ThrottleRate = 0;
this.SMSCclientSMPP.OnTcpDisconnected += new smscc.tcpDisconnectedEvent(this.SMSCRelaySMPP_OnTcpDisconnected);
this.SMSCclientSMPP.OnSmppMessageReceived += new smscc.SMPP.smppMessageReceivedEvent(this.SMSCRelaySMPP_OnSmppMessageReceived);
this.SMSCclientSMPP.OnSmppStatusReportReceived += new smscc.SMPP.smppStatusReportReceivedEvent(this.SMSCRelaySMPP_OnSmppStatusReportReceived);
//
// smsCclientSMPP1
//
this.smsCclientSMPP1.ImmediateResponse = false;
this.smsCclientSMPP1.KeepAliveInterval = 10;
this.smsCclientSMPP1.ResponseTimeOut = 30;
this.smsCclientSMPP1.ThrottleRate = 0;
this.smsCclientSMPP1.OnTcpDisconnected += new smscc.tcpDisconnectedEvent(this.SMSCRelaySMPP1_OnTcpDisconnected);
this.smsCclientSMPP1.OnSmppMessageReceived += new smscc.SMPP.smppMessageReceivedEvent(this.SMSCRelaySMPP_OnSmppMessageReceived);
this.smsCclientSMPP1.OnSmppStatusReportReceived += new smscc.SMPP.smppStatusReportReceivedEvent(this.SMSCRelaySMPP_OnSmppStatusReportReceived);
//
// smsCclientSMPP2
//
this.smsCclientSMPP2.ImmediateResponse = false;
this.smsCclientSMPP2.KeepAliveInterval = 10;
this.smsCclientSMPP2.ResponseTimeOut = 30;
this.smsCclientSMPP2.ThrottleRate = 0;
this.smsCclientSMPP2.OnTcpDisconnected += new smscc.tcpDisconnectedEvent(this.SMSCRelaySMPP2_OnTcpDisconnected);
this.smsCclientSMPP2.OnSmppMessageReceived += new smscc.SMPP.smppMessageReceivedEvent(this.SMSCRelaySMPP_OnSmppMessageReceived);
this.smsCclientSMPP2.OnSmppStatusReportReceived += new smscc.SMPP.smppStatusReportReceivedEvent(this.SMSCRelaySMPP_OnSmppStatusReportReceived);
//
// smsCclientSMPP3
//
this.smsCclientSMPP3.ImmediateResponse = false;
this.smsCclientSMPP3.KeepAliveInterval = 10;
this.smsCclientSMPP3.ResponseTimeOut = 10;
this.smsCclientSMPP3.ThrottleRate = 0;
this.smsCclientSMPP3.OnTcpDisconnected += new smscc.tcpDisconnectedEvent(this.SMSCRelaySMPP3_OnTcpDisconnected);
this.smsCclientSMPP3.OnSmppMessageReceived += new smscc.SMPP.smppMessageReceivedEvent(this.SMSCRelaySMPP_OnSmppMessageReceived);
this.smsCclientSMPP3.OnSmppStatusReportReceived += new smscc.SMPP.smppStatusReportReceivedEvent(this.SMSCRelaySMPP_OnSmppStatusReportReceived);
//
// smsCclientSMPP4
//
this.smsCclientSMPP4.ImmediateResponse = false;
this.smsCclientSMPP4.KeepAliveInterval = 10;
this.smsCclientSMPP4.ResponseTimeOut = 10;
this.smsCclientSMPP4.ThrottleRate = 0;
this.smsCclientSMPP4.OnTcpDisconnected += new smscc.tcpDisconnectedEvent(this.SMSCRelaySMPP4_OnTcpDisconnected);
this.smsCclientSMPP4.OnSmppMessageReceived += new smscc.SMPP.smppMessageReceivedEvent(this.SMSCRelaySMPP_OnSmppMessageReceived);
this.smsCclientSMPP4.OnSmppStatusReportReceived += new smscc.SMPP.smppStatusReportReceivedEvent(this.SMSCRelaySMPP_OnSmppStatusReportReceived);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(20, 49);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(56, 13);
this.label10.TabIndex = 99;
this.label10.Text = "SMSC1 IP";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(20, 76);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(56, 13);
this.label11.TabIndex = 100;
this.label11.Text = "SMSC2 IP";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(92, 42);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(88, 20);
this.textBox1.TabIndex = 101;
this.textBox1.Text = "0.0.0.0";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(92, 73);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(88, 20);
this.textBox2.TabIndex = 102;
this.textBox2.Text = "0.0.0.0";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(202, 49);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(26, 13);
this.label13.TabIndex = 103;
this.label13.Text = "Port";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(202, 73);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(26, 13);
this.label14.TabIndex = 104;
this.label14.Text = "Port";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(234, 42);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(51, 20);
this.textBox3.TabIndex = 105;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(234, 73);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(51, 20);
this.textBox4.TabIndex = 106;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(293, 49);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(52, 13);
this.label15.TabIndex = 107;
this.label15.Text = "SystemID";
this.label15.Click += new System.EventHandler(this.label15_Click);
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(462, 45);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(30, 13);
this.label16.TabIndex = 108;
this.label16.Text = "Pass";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(604, 42);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(68, 13);
this.label19.TabIndex = 109;
this.label19.Text = "System Type";
this.label19.Click += new System.EventHandler(this.label19_Click);
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(293, 76);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(52, 13);
this.label20.TabIndex = 110;
this.label20.Text = "SystemID";
this.label20.Click += new System.EventHandler(this.label20_Click);
//
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(462, 76);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(30, 13);
this.label21.TabIndex = 111;
this.label21.Text = "Pass";
//
// label22
//
this.label22.AutoSize = true;
this.label22.Location = new System.Drawing.Point(604, 80);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(68, 13);
this.label22.TabIndex = 112;
this.label22.Text = "System Type";
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 166);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(87, 23);
this.button1.TabIndex = 113;
this.button1.Text = "Start Gate1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(763, 264);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(61, 24);
this.button2.TabIndex = 114;
this.button2.Text = "Stop";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(800, 314);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 115;
this.button3.Text = "Disconnect1";
this.button3.UseVisualStyleBackColor = true;
//
// button4
//
this.button4.Location = new System.Drawing.Point(719, 305);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 116;
this.button4.Text = "Disconnect2";
this.button4.UseVisualStyleBackColor = true;
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(351, 42);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 20);
this.textBox5.TabIndex = 117;
this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged);
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(351, 68);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(100, 20);
this.textBox6.TabIndex = 118;
this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged);
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(498, 42);
this.textBox7.Name = "textBox7";
this.textBox7.PasswordChar = '*';
this.textBox7.Size = new System.Drawing.Size(100, 20);
this.textBox7.TabIndex = 119;
this.textBox7.TextChanged += new System.EventHandler(this.textBox7_TextChanged);
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(498, 69);
this.textBox8.Name = "textBox8";
this.textBox8.PasswordChar = '*';
this.textBox8.Size = new System.Drawing.Size(100, 20);
this.textBox8.TabIndex = 120;
//
// textBox9
//
this.textBox9.Location = new System.Drawing.Point(674, 36);
this.textBox9.Name = "textBox9";
this.textBox9.Size = new System.Drawing.Size(100, 20);
this.textBox9.TabIndex = 121;
//
// textBox10
//
this.textBox10.Location = new System.Drawing.Point(674, 70);
this.textBox10.Name = "textBox10";
this.textBox10.Size = new System.Drawing.Size(100, 20);
this.textBox10.TabIndex = 122;
this.textBox10.TextChanged += new System.EventHandler(this.textBox10_TextChanged);
//
// button5
//
this.button5.Location = new System.Drawing.Point(780, 37);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(62, 22);
this.button5.TabIndex = 123;
this.button5.Text = "Exit";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// textBox11
//
this.textBox11.Location = new System.Drawing.Point(92, 105);
this.textBox11.Name = "textBox11";
this.textBox11.Size = new System.Drawing.Size(88, 20);
this.textBox11.TabIndex = 124;
//
// textBox12
//
this.textBox12.Location = new System.Drawing.Point(234, 105);
this.textBox12.Name = "textBox12";
this.textBox12.Size = new System.Drawing.Size(51, 20);
this.textBox12.TabIndex = 125;
//
// textBox13
//
this.textBox13.Location = new System.Drawing.Point(351, 105);
this.textBox13.Name = "textBox13";
this.textBox13.Size = new System.Drawing.Size(100, 20);
this.textBox13.TabIndex = 126;
//
// textBox14
//
this.textBox14.Location = new System.Drawing.Point(498, 101);
this.textBox14.Name = "textBox14";
this.textBox14.PasswordChar = '*';
this.textBox14.Size = new System.Drawing.Size(100, 20);
this.textBox14.TabIndex = 127;
//
// textBox15
//
this.textBox15.Location = new System.Drawing.Point(674, 105);
this.textBox15.Name = "textBox15";
this.textBox15.Size = new System.Drawing.Size(100, 20);
this.textBox15.TabIndex = 128;
//
// textBox16
//
this.textBox16.Location = new System.Drawing.Point(92, 140);
this.textBox16.Name = "textBox16";
this.textBox16.Size = new System.Drawing.Size(88, 20);
this.textBox16.TabIndex = 129;
//
// textBox17
//
this.textBox17.Location = new System.Drawing.Point(234, 140);
this.textBox17.Name = "textBox17";
this.textBox17.Size = new System.Drawing.Size(51, 20);
this.textBox17.TabIndex = 130;
//
// textBox18
//
this.textBox18.Location = new System.Drawing.Point(351, 140);
this.textBox18.Name = "textBox18";
this.textBox18.Size = new System.Drawing.Size(100, 20);
this.textBox18.TabIndex = 131;
//
// textBox19
//
this.textBox19.Location = new System.Drawing.Point(498, 140);
this.textBox19.Name = "textBox19";
this.textBox19.PasswordChar = '*';
this.textBox19.Size = new System.Drawing.Size(100, 20);
this.textBox19.TabIndex = 132;
//
// textBox20
//
this.textBox20.Location = new System.Drawing.Point(674, 140);
this.textBox20.Name = "textBox20";
this.textBox20.Size = new System.Drawing.Size(100, 20);
this.textBox20.TabIndex = 133;
//
// label23
//
this.label23.AutoSize = true;
this.label23.Location = new System.Drawing.Point(202, 147);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(26, 13);
this.label23.TabIndex = 134;
this.label23.Text = "Port";
//
// label24
//
this.label24.AutoSize = true;
this.label24.Location = new System.Drawing.Point(604, 101);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(68, 13);
this.label24.TabIndex = 135;
this.label24.Text = "System Type";
//
// label25
//
this.label25.AutoSize = true;
this.label25.Location = new System.Drawing.Point(293, 147);
this.label25.Name = "label25";
this.label25.Size = new System.Drawing.Size(55, 13);
this.label25.TabIndex = 136;
this.label25.Text = "System ID";
//
// label26
//
this.label26.AutoSize = true;
this.label26.Location = new System.Drawing.Point(20, 147);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(56, 13);
this.label26.TabIndex = 137;
this.label26.Text = "SMSC4 IP";
//
// label27
//
this.label27.AutoSize = true;
this.label27.Location = new System.Drawing.Point(462, 105);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(30, 13);
this.label27.TabIndex = 138;
this.label27.Text = "Pass";
//
// label28
//
this.label28.AutoSize = true;
this.label28.Location = new System.Drawing.Point(462, 143);
this.label28.Name = "label28";
this.label28.Size = new System.Drawing.Size(30, 13);
this.label28.TabIndex = 139;
this.label28.Text = "Pass";
//
// label29
//
this.label29.AutoSize = true;
this.label29.Location = new System.Drawing.Point(293, 105);
this.label29.Name = "label29";
this.label29.Size = new System.Drawing.Size(52, 13);
this.label29.TabIndex = 140;
this.label29.Text = "SystemID";
//
// label30
//
this.label30.AutoSize = true;
this.label30.Location = new System.Drawing.Point(604, 143);
this.label30.Name = "label30";
this.label30.Size = new System.Drawing.Size(68, 13);
this.label30.TabIndex = 141;
this.label30.Text = "System Type";
//
// label31
//
this.label31.AutoSize = true;
this.label31.Location = new System.Drawing.Point(555, 260);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(41, 13);
this.label31.TabIndex = 142;
this.label31.Text = "label31";
//
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(202, 105);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(26, 13);
this.label32.TabIndex = 143;
this.label32.Text = "Port";
//
// label33
//
this.label33.AutoSize = true;
this.label33.Location = new System.Drawing.Point(20, 105);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(56, 13);
this.label33.TabIndex = 144;
this.label33.Text = "SMSC3 IP";
//
// button6
//
this.button6.Location = new System.Drawing.Point(387, 171);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(108, 22);
this.button6.TabIndex = 145;
this.button6.Text = "Disconnect Gate1";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// label34
//
this.label34.AutoSize = true;
this.label34.Location = new System.Drawing.Point(20, 9);
this.label34.Name = "label34";
this.label34.Size = new System.Drawing.Size(30, 13);
this.label34.TabIndex = 146;
this.label34.Text = "Time";
//
// label35
//
this.label35.AutoSize = true;
this.label35.Location = new System.Drawing.Point(79, 9);
this.label35.Name = "label35";
this.label35.Size = new System.Drawing.Size(0, 13);
this.label35.TabIndex = 147;
//
// label36
//
this.label36.AutoSize = true;
this.label36.Location = new System.Drawing.Point(231, 257);
this.label36.Name = "label36";
this.label36.Size = new System.Drawing.Size(61, 13);
this.label36.TabIndex = 148;
this.label36.Text = "DnD Route";
//
// label37
//
this.label37.AutoSize = true;
this.label37.Location = new System.Drawing.Point(231, 285);
this.label37.Name = "label37";
this.label37.Size = new System.Drawing.Size(41, 13);
this.label37.TabIndex = 149;
this.label37.Text = "label37";
//
// button7
//
this.button7.Location = new System.Drawing.Point(105, 166);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(89, 23);
this.button7.TabIndex = 150;
this.button7.Text = "Start Gate 2";
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// button8
//
this.button8.Location = new System.Drawing.Point(200, 168);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(75, 23);
this.button8.TabIndex = 151;
this.button8.Text = "Start Gate 3";
this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button9
//
this.button9.Location = new System.Drawing.Point(281, 166);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(99, 25);
this.button9.TabIndex = 152;
this.button9.Text = "Start Gate 4";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// button10
//
this.button10.Location = new System.Drawing.Point(501, 171);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(118, 21);
this.button10.TabIndex = 153;
this.button10.Text = "Disconnect Gate 2";
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// button11
//
this.button11.Location = new System.Drawing.Point(625, 170);
this.button11.Name = "button11";
this.button11.Size = new System.Drawing.Size(129, 22);
this.button11.TabIndex = 154;
this.button11.Text = "Disconnect Gate 3";
this.button11.UseVisualStyleBackColor = true;
this.button11.Click += new System.EventHandler(this.button11_Click);
//
// button12
//
this.button12.Location = new System.Drawing.Point(760, 171);
this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(115, 20);
this.button12.TabIndex = 155;
this.button12.Text = "Disconnect Gate 4";
this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.button12_Click);
//
// timer2
//
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// timer3
//
this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
//
// timer4
//
this.timer4.Tick += new System.EventHandler(this.timer4_Tick);
//
// timer5
//
this.timer5.Tick += new System.EventHandler(this.timer5_Tick);
//
// button13
//
this.button13.Location = new System.Drawing.Point(511, 209);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(87, 25);
this.button13.TabIndex = 156;
this.button13.Text = "Start Gate 5";
this.button13.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.button13_Click);
//
// button14
//
this.button14.Location = new System.Drawing.Point(632, 212);
this.button14.Name = "button14";
this.button14.Size = new System.Drawing.Size(106, 22);
this.button14.TabIndex = 157;
this.button14.Text = "Disconnect Gate 5";
this.button14.UseVisualStyleBackColor = true;
this.button14.Click += new System.EventHandler(this.button14_Click);
//
// label38
//
this.label38.AutoSize = true;
this.label38.Location = new System.Drawing.Point(683, 387);
this.label38.Name = "label38";
this.label38.Size = new System.Drawing.Size(40, 13);
this.label38.TabIndex = 158;
this.label38.Text = "Engine";
//
// textBox21
//
this.textBox21.Location = new System.Drawing.Point(746, 382);
this.textBox21.Name = "textBox21";
this.textBox21.Size = new System.Drawing.Size(47, 20);
this.textBox21.TabIndex = 159;
this.textBox21.Text = "1";
//
// fmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(894, 541);
this.Controls.Add(this.textBox21);
this.Controls.Add(this.label38);
this.Controls.Add(this.button14);
this.Controls.Add(this.button13);
this.Controls.Add(this.button12);
this.Controls.Add(this.button11);
this.Controls.Add(this.button10);
this.Controls.Add(this.button9);
this.Controls.Add(this.button8);
this.Controls.Add(this.button7);
this.Controls.Add(this.label37);
this.Controls.Add(this.label36);
this.Controls.Add(this.label35);
this.Controls.Add(this.label34);
this.Controls.Add(this.button6);
this.Controls.Add(this.label33);
this.Controls.Add(this.label32);
this.Controls.Add(this.label31);
this.Controls.Add(this.label30);
this.Controls.Add(this.label29);
this.Controls.Add(this.label28);
this.Controls.Add(this.label27);
this.Controls.Add(this.label26);
this.Controls.Add(this.label25);
this.Controls.Add(this.label24);
this.Controls.Add(this.label23);
this.Controls.Add(this.textBox20);
this.Controls.Add(this.textBox19);
this.Controls.Add(this.textBox18);
this.Controls.Add(this.textBox17);
this.Controls.Add(this.textBox16);
this.Controls.Add(this.textBox15);
this.Controls.Add(this.textBox14);
this.Controls.Add(this.textBox13);
this.Controls.Add(this.textBox12);
this.Controls.Add(this.textBox11);
this.Controls.Add(this.button5);
this.Controls.Add(this.textBox10);
this.Controls.Add(this.textBox9);
this.Controls.Add(this.textBox8);
this.Controls.Add(this.textBox7);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label22);
this.Controls.Add(this.label21);
this.Controls.Add(this.label20);
this.Controls.Add(this.label19);
this.Controls.Add(this.label16);
this.Controls.Add(this.label15);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label14);
this.Controls.Add(this.label13);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label8);
this.Controls.Add(this.cbMessageStatus);
this.Controls.Add(this.txtMessageID);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label18);
this.Controls.Add(this.label1);
this.Controls.Add(this.cbClients);
this.Controls.Add(this.cmdClose);
this.Controls.Add(this.txtDestTON);
this.Controls.Add(this.txtDestNPI);
this.Controls.Add(this.txtOrigTON);
this.Controls.Add(this.txtOrigNPI);
this.Controls.Add(this.txtOriginator);
this.Controls.Add(this.cmdDeliverMessage);
this.Controls.Add(this.txtDestination);
this.Controls.Add(this.txtLog);
this.Controls.Add(this.cmdDeliverStatusReport);
this.Controls.Add(this.txtMessage);
this.Controls.Add(this.cmdStopServer);
this.Controls.Add(this.txtPort);
this.Controls.Add(this.cmdStartServer);
this.Controls.Add(this.Label17);
this.Controls.Add(this.Line2);
this.Controls.Add(this.Label12);
this.Controls.Add(this.Label9);
this.Controls.Add(this.Label7);
this.Controls.Add(this.Label6);
this.Controls.Add(this.Label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "fmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SMARTSMS ROUTER PENPAL";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.fmMain_FormClosing);
this.Load += new System.EventHandler(this.fmMain_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private EventLog Log;
private SMSCencoder en;
string[] online = new string[100];
//string[][][] online2 = new string[100][][];
string[,] online2 = new string[100, 4];
// 0,0 = username
// 0,1 = IP
// 0,2 =
// 0,3 = message/content
string myclient;
[STAThread]
static void Main()
{
Application.Run(new fmMain());
}
private string getMessageID()
{
return "smartsms router-" + messageNumber++.ToString("x");
}
private void fmMain_FormClosing(object sender, FormClosingEventArgs e)
{
string path = Application.StartupPath;
//smppserver port
path = Application.StartupPath + "\\appsys\\smppserverport.txt";
System.IO.StreamWriter stringWriter1 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(txtPort.Text))
{
stringWriter1.Write(txtPort.Text); // Write text to textfile.
} // end of if loop
stringWriter1.Close();
// smsc1 IP
path = Application.StartupPath + "\\appsys\\smsc1IP.txt";
System.IO.StreamWriter stringWriter2 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox1.Text))
{
stringWriter2.Write(textBox1.Text); // Write text to textfile.
} // end of if loop
stringWriter2.Close();
// smsc2 IP
path = Application.StartupPath + "\\appsys\\smsc2IP.txt";
System.IO.StreamWriter stringWriter3 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox2.Text))
{
stringWriter3.Write(textBox2.Text); // Write text to textfile.
} // end of if loop
stringWriter3.Close();
// smsc1 Port
path = Application.StartupPath + "\\appsys\\smsc1port.txt";
System.IO.StreamWriter stringWriter4 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox3.Text))
{
stringWriter4.Write(textBox3.Text); // Write text to textfile.
} // end of if loop
stringWriter4.Close();
// smsc2 Port
path = Application.StartupPath + "\\appsys\\smsc2port.txt";
System.IO.StreamWriter stringWriter5 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox4.Text))
{
stringWriter5.Write(textBox4.Text); // Write text to textfile.
} // end of if loop
stringWriter5.Close();
// smsc1 SystemID
path = Application.StartupPath + "\\appsys\\smsc1systemID.txt";
System.IO.StreamWriter stringWriter6 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox5.Text))
{
stringWriter6.Write(textBox5.Text); // Write text to textfile.
} // end of if loop
stringWriter6.Close();
// smsc2 SystemID
path = Application.StartupPath + "\\appsys\\smsc2systemID.txt";
System.IO.StreamWriter stringWriter7 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox6.Text))
{
stringWriter7.Write(textBox6.Text); // Write text to textfile.
} // end of if loop
stringWriter7.Close();
// smsc1 pass
path = Application.StartupPath + "\\appsys\\smsc1pass.txt";
System.IO.StreamWriter stringWriter8 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox7.Text))
{
stringWriter8.Write(textBox7.Text); // Write text to textfile.
} // end of if loop
stringWriter8.Close();
// smsc2 pass
path = Application.StartupPath + "\\appsys\\smsc2pass.txt";
System.IO.StreamWriter stringWriter9 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox8.Text))
{
stringWriter9.Write(textBox8.Text); // Write text to textfile.
} // end of if loop
stringWriter9.Close();
// smsc1 systemtype
path = Application.StartupPath + "\\appsys\\smsc1systemtype.txt";
System.IO.StreamWriter stringWriter10 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox9.Text))
{
stringWriter10.Write(textBox9.Text); // Write text to textfile.
} // end of if loop
stringWriter10.Close();
// smsc2 systemtype
path = Application.StartupPath + "\\appsys\\smsc2systemtype.txt";
System.IO.StreamWriter stringWriter11 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox10.Text))
{
stringWriter11.Write(textBox10.Text); // Write text to textfile.
} // end of if loop
stringWriter11.Close();
// smsc3 IP
path = Application.StartupPath + "\\appsys\\smsc3IP.txt";
System.IO.StreamWriter stringWriter12 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox11.Text))
{
stringWriter12.Write(textBox11.Text); // Write text to textfile.
} // end of if loop
stringWriter12.Close();
// smsc3 Port
path = Application.StartupPath + "\\appsys\\smsc3port.txt";
System.IO.StreamWriter stringWriter13 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox12.Text))
{
stringWriter13.Write(textBox12.Text); // Write text to textfile.
} // end of if loop
stringWriter13.Close();
// smsc3 SystemID
path = Application.StartupPath + "\\appsys\\smsc3systemID.txt";
System.IO.StreamWriter stringWriter14 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox13.Text))
{
stringWriter14.Write(textBox13.Text); // Write text to textfile.
} // end of if loop
stringWriter14.Close();
// smsc3 pass
path = Application.StartupPath + "\\appsys\\smsc3pass.txt";
System.IO.StreamWriter stringWriter15 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox14.Text))
{
stringWriter15.Write(textBox14.Text); // Write text to textfile.
} // end of if loop
stringWriter15.Close();
// smsc3 systemtype
path = Application.StartupPath + "\\appsys\\smsc3systemtype.txt";
System.IO.StreamWriter stringWriter16 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox15.Text))
{
stringWriter16.Write(textBox15.Text); // Write text to textfile.
} // end of if loop
stringWriter16.Close();
// smsc4 IP
path = Application.StartupPath + "\\appsys\\smsc4IP.txt";
System.IO.StreamWriter stringWriter17 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox16.Text))
{
stringWriter17.Write(textBox16.Text); // Write text to textfile.
} // end of if loop
stringWriter17.Close();
// smsc4 Port
path = Application.StartupPath + "\\appsys\\smsc4port.txt";
System.IO.StreamWriter stringWriter18 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox17.Text))
{
stringWriter18.Write(textBox17.Text); // Write text to textfile.
} // end of if loop
stringWriter18.Close();
// smsc4 SystemID
path = Application.StartupPath + "\\appsys\\smsc4systemID.txt";
System.IO.StreamWriter stringWriter19 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox18.Text))
{
stringWriter19.Write(textBox18.Text); // Write text to textfile.
} // end of if loop
stringWriter19.Close();
// smsc4 pass
path = Application.StartupPath + "\\appsys\\smsc4pass.txt";
System.IO.StreamWriter stringWriter20 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox19.Text))
{
stringWriter20.Write(textBox19.Text); // Write text to textfile.
} // end of if loop
stringWriter20.Close();
// smsc4 systemtype
path = Application.StartupPath + "\\appsys\\smsc4systemtype.txt";
System.IO.StreamWriter stringWriter21 = new System.IO.StreamWriter(path);
if (!string.IsNullOrEmpty(textBox20.Text))
{
stringWriter21.Write(textBox20.Text); // Write text to textfile.
} // end of if loop
stringWriter21.Close();
}
private void fmMain_Load(object sender, System.EventArgs e)
{
en = new SMSCencoder();
Log = new EventLog(txtLog);
cbMessageStatus.SelectedIndex = 1;
// MessageBox.Show("FormOpen Event");
string path = Application.StartupPath;
//smppserverport
path = Application.StartupPath + "\\appsys\\smppserverport.txt";
using (StreamReader reader = new StreamReader(path))
{
txtPort.Text = reader.ReadLine();
}
//smsc1 IP
path = Application.StartupPath + "\\appsys\\smsc1IP.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox1.Text = reader.ReadLine();
}
//smsc2 IP
path = Application.StartupPath + "\\appsys\\smsc2IP.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox2.Text = reader.ReadLine();
}
// smsc1 Port
path = Application.StartupPath + "\\appsys\\smsc1port.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox3.Text = reader.ReadLine();
}
// smsc2 Port
path = Application.StartupPath + "\\appsys\\smsc2port.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox4.Text = reader.ReadLine();
}
// smsc1 SystemID
path = Application.StartupPath + "\\appsys\\smsc1systemID.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox5.Text = reader.ReadLine();
}
// smsc2 SystemID
path = Application.StartupPath + "\\appsys\\smsc2systemID.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox6.Text = reader.ReadLine();
}
// smsc1 pass
path = Application.StartupPath + "\\appsys\\smsc1pass.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox7.Text = reader.ReadLine();
}
// smsc2 pass
path = Application.StartupPath + "\\appsys\\smsc2pass.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox8.Text = reader.ReadLine();
}
// smsc1 systemtype
path = Application.StartupPath + "\\appsys\\smsc1systemtype.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox9.Text = reader.ReadLine();
}
// smsc2 systemtype
path = Application.StartupPath + "\\appsys\\smsc2systemtype.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox10.Text = reader.ReadLine();
}
//smsc3 IP
path = Application.StartupPath + "\\appsys\\smsc3IP.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox11.Text = reader.ReadLine();
}
// smsc3 Port
path = Application.StartupPath + "\\appsys\\smsc3port.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox12.Text = reader.ReadLine();
}
// smsc3 SystemID
path = Application.StartupPath + "\\appsys\\smsc3systemID.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox13.Text = reader.ReadLine();
}
// smsc3 pass
path = Application.StartupPath + "\\appsys\\smsc3pass.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox14.Text = reader.ReadLine();
}
// smsc3 systemtype
path = Application.StartupPath + "\\appsys\\smsc3systemtype.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox15.Text = reader.ReadLine();
}
//smsc4 IP
path = Application.StartupPath + "\\appsys\\smsc4IP.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox16.Text = reader.ReadLine();
}
// smsc4 Port
path = Application.StartupPath + "\\appsys\\smsc4port.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox17.Text = reader.ReadLine();
}
// smsc4 SystemID
path = Application.StartupPath + "\\appsys\\smsc4systemID.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox18.Text = reader.ReadLine();
}
// smsc4 pass
path = Application.StartupPath + "\\appsys\\smsc4pass.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox19.Text = reader.ReadLine();
}
// smsc4 systemtype
path = Application.StartupPath + "\\appsys\\smsc4systemtype.txt";
using (StreamReader reader = new StreamReader(path))
{
textBox20.Text = reader.ReadLine();
}
}
//
// Start SMSC Server
//
private void cmdStartServer_Click(object sender, System.EventArgs e)
{
SMSCserverSMPP.smppInitializeServer("", int.Parse(txtPort.Text), "");
Log.AddServerStarted();
}
//
// Stop SMSC Server
//
private void cmdStopServer_Click(object sender, System.EventArgs e)
{
SMSCserverSMPP.smppFinalizeServer();
Log.AddServerStopped();
}
//
// Close client connection
//
private void cmdClose_Click(object sender, System.EventArgs e)
{
if (cbClients.SelectedIndex != -1)
{
string tmp = cbClients.Text;
int mystr = tmp.IndexOf(" ") + 1;
myclient = tmp.Substring(0, mystr);
int clientID = int.Parse(cbClients.Text.Replace(myclient, ""));
SMSCserverSMPP.tcpCloseConnection(clientID);
}
else
{
MessageBox.Show("No client connection selected. Please select " +
"client from Client ID dropdown list to deliver message.",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
//
// Deliver (deliver_sm) a regular message to client
//
private void cmdDeliverMessage_Click(object sender, System.EventArgs e)
{
if (cbClients.SelectedIndex != -1)
{
int clientID = int.Parse(cbClients.Text.Replace("client ", ""));
SMSCserverSMPP.smppSendDeliverMessage(clientID, sequenceNumber++,
txtDestination.Text, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
txtOriginator.Text, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
txtMessage.Text, smscs.EncodingEnum.et7BitText, "", 0, "", "");
Log.AddDeliverMessageEvent(clientID);
}
else
{
MessageBox.Show("No client connection selected. Please select " +
"client from Client ID dropdown list to deliver message.",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
//
// Deliver (deliver_sm) a status report to client
//
private void cmdDeliverStatusReport_Click(object sender, System.EventArgs e)
{
if (cbClients.SelectedIndex != -1)
{
int clientID = int.Parse(cbClients.Text.Replace("client ", ""));
SMSCserverSMPP.smppSendDeliverStatusReport(clientID, sequenceNumber++,
txtDestination.Text, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
txtOriginator.Text, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", txtMessageID.Text, 1, 1, DateTime.Now,
DateTime.Now, (smppMessageStateEnum)cbMessageStatus.SelectedIndex,
0, txtMessage.Text, "");
Log.AddDeliverStatusReport(clientID);
}
else
{
MessageBox.Show("No client connection selected. Please select " +
"client from Client ID dropdown list to deliver message.",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
//
// Event fired on client connect on TCP/IP level
//
private void SMSCserverSMPP_OnTcpConnected(object sender,
smscs.tcpConnectedEventArgs e)
{
//
// Here you can examine information like client's
// address (e.RemoteHost) and/or port (e.RemotePort)
// and either accept connection (tcpAcceptConnection)
// or reject it (tcpCloseConnection).
//
SMSCserverSMPP.tcpAcceptConnection(e.ClientID);
// cbClients.Items.Add("client " + e.ClientID.ToString());
online[e.ClientID] = e.RemoteHost;
online2[e.ClientID,1] = e.RemoteHost;
Log.AddConnectedEvent(e.ClientID, e.RemoteHost, e.RemotePort);
}
//
// Event fired on client disconnection on TCP/IP level
//
private void SMSCserverSMPP_OnTcpDisconnected(object sender,
smscs.tcpDisconnectedEventArgs e)
{
//
// This event can be used to remove connection from
// application's internal structures.
//
//try{
myclient = online[e.ClientID] + " ";
// myclient = e.SystemID
int i = cbClients.Items.IndexOf(myclient + e.ClientID.ToString());
if (i != -1)
{
cbClients.Items.RemoveAt(i);
online[e.ClientID] = "";
}
// int k = online.Length - 1;
//for (int j =i; j <= (online.Length-1); j++)
// {
// if (j < k) {
// online[j] = online[j + 1];
//}
// }
//}catch (Exception ex)
//{
// MessageBox.Show(ex.Message);
// }
Log.AddDisconnectedEvent(e.ClientID, e.Reason);
}
//
// Event fired when an SMPP message is received that is not
// reported by any other events.
//
private void SMSCserverSMPP_OnSmppRAWReceived(object sender,
smscs.SMPP.smppRAWReceivedEventArgs e)
{
Log.AddReceivedGeneric(e.ClientID);
}
//
// Event fired on login (bind) message receive
//
private void SMSCserverSMPP_OnSmppLoginReceived(object sender,
smscs.SMPP.smppLoginReceivedEventArgs e)
{
//
// Here client tries to login to the SMSC. On the basis of
// information passed server has to decide what status code to
// pass and/or whether to close the connection. Information
// that can be examined is account name (e.SystemID), password
// (e.Password), bind mode (transceiver, transmitter or receiver
// contained in e.BindMode) etc.
//
// Login status is passed to the client via smppSendLoginResponse and
// if client should be rejected the connection should be dropped
// using tcpCloseConnection.
//
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection4 = new MySqlConnection(connectionString);
using (connection4)
{
online2[e.ClientID, 2] = e.SystemType;
//query = "select * from userlogin where username='" + e.SystemID + "' and pass='"+e.Password +"' and clientip='"+ online[e.ClientID]+"' and mlock='4'";
query = "select * from userlogin where username='" + e.SystemID + "' and pass='" + e.Password + "' and domain = '" + e.SystemType +"'";// and clientip='" + online[e.ClientID] + "' and mlock='4'";
MySqlCommand command4 = new MySqlCommand(query, connection4);
connection4.Open();
MySqlDataReader reader4 = command4.ExecuteReader();
if (reader4.HasRows)
{
while (reader4.Read())
{
SMSCserverSMPP.smppSendLoginResponse(e.ClientID, e.SequenceNumber, e.BindMode,
0, "SmartSMS Router","");
cbClients.Items.Add(e.SystemID + " " + e.ClientID.ToString());
online[e.ClientID] = e.SystemID;
online2[e.ClientID,0] = e.SystemID;
Log.AddReceivedLoginEvent(e.ClientID);
//log login
query = "insert into loginhistory(username,pass,clientremoteip,datesent) values( '" + e.SystemID + "','" + e.Password + "','" + online2[e.ClientID,1] + "','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "')";
Update(query);
}
}
else
{
SMSCserverSMPP.smppSendLoginResponse(e.ClientID, e.SequenceNumber, e.BindMode,
13, "SmartSMS Router","");
SMSCserverSMPP.tcpCloseConnection(e.ClientID);
Log.AddReceivedLoginEvent(e.ClientID);
}
}
connection4.Close();
}
//
// Event fired on logout (unbind) message receive
//
private void SMSCserverSMPP_OnSmppLogoutReceived(object sender,
smscs.SMPP.smppLogoutReceivedEventArgs e)
{
//
// To close the connection on SMPP level gracefully
// server should respond with smppSendLogoutResponse function.
// Then after waiting a while it can drop the connection
// using tcpCloseConnection. The wait is time to finish
// transmitting the response and possibly client closing
// the connection on TCP/IP level.
//
SMSCserverSMPP.smppSendLogoutResponse(e.ClientID, e.SequenceNumber, 0);
Log.AddReceivedLogoutEvent(e.ClientID);
SMSCserverSMPP.tcpCloseConnection(e.ClientID);
}
//
// Event fired when message to submit is received (send_sm) from client
//
private void SMSCserverSMPP_OnSmppSubmitMessageReceived(object sender,
smscs.SMPP.smppSubmitMessageReceivedEventArgs e)
{
//
// After receiving message server should analyze it and
// send an appropriate status code in return. Status can be
// of course forwarded from ahother SMPP entity while proxying
// or generated on the basis of message analysis (e.g. destination
// number, content etc.)
//
int result = 0;
int options;
EncodingEnum Encoding;
//string MessageID = "";// getMessageID();
//string messout= e.Content;
//string destout =e.Destination;
string encodeout = e.Encoding.ToString();
//string senderout = e.Originator;
String ClientName = online[e.ClientID];
string ClientName2 = online2[e.ClientID, 0];
string message = e.Content;
int sek = e.SequenceNumber;
int strlen = e.Content.Length;
String cnt6 = getBalanceSMPP(ClientName, online2[e.ClientID, 2]);
// string cnt6 = chargeSMPP(ClientName, e.SMText, routeprice, online2[e.ClientID, 2], e.SequenceNumber, e.Destination);
//cnt6 = "0";
if (cnt6 == "0")
{
//there is enough money
string smpproute = getRouteSmpp(e.Destination);
if (smpproute == "-1") smpproute = "1";
switch (encodeout)
{
case "et7BitText":
Encoding = EncodingEnum.et7BitText;
break;
case "et8BitHexadecimal":
Encoding = EncodingEnum.et8BitHexadecimal;
break;
case "etUCS2Text":
Encoding = EncodingEnum.etUCS2Text;
break;
case "etISO88591":
Encoding = EncodingEnum.etISO88591;
break;
case "etISO88595":
Encoding = EncodingEnum.etISO88595;
break;
case "etISO88598":
Encoding = EncodingEnum.etISO88598;
break;
default:
Encoding = EncodingEnum.et7BitText;
break;
}
if (e.Destination.Length > 6)
{
options = (int)SubmitOptionEnum.soRequestStatusReport;
if (e.Content.Length > 160)
{
//long message
options = (int)SubmitOptionEnum.soRequestStatusReport;
SMSCencoder en = new SMSCencoder();
//result = SMSCclientSMPP.smppSubmitMessage(phone, 1, 1, org, 1, 5, message, Encoding, "", options, out messageID);
// MultipartMessage em = en.EncodeMultipartMessage(message,"", EncodingEnum.et7BitText);
Encoding = EncodingEnum.et7BitText;
string cmessage = convertUnicode(e.Content);
// //message = "Thesu susus us su sus sus sus sus us susu s us sus sus su";
MultipartMessage em = en.EncodeMultipartMessage(SplitMethodEnum.smUDH,cmessage,"",Encoding,"");
foreach (MessagePart mp in em.Parts)
{
if (smpproute == "1")
result = smsCclientSMPP1.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, mp.Content, Encoding, mp.UDH, options, out MessageID);
if (smpproute == "2")
result = smsCclientSMPP2.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, mp.Content, Encoding, mp.UDH, options, out MessageID);
if (smpproute == "3")
result = smsCclientSMPP3.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, mp.Content, Encoding, mp.UDH, options, out MessageID);
if (smpproute == "4")
result = smsCclientSMPP4.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, mp.Content, Encoding, mp.UDH, options, out MessageID);
if (result == 0)
{
// SMSCserverSMPP.smppSendSubmitMultiMessageResponse(e.ClientID,
// e.SequenceNumber, 0, MessageID);
SMSCserverSMPP.smppSendSubmitMessageResponse(e.ClientID, e.SequenceNumber, 0, MessageID);
query = "insert into MessagestatusSMPP(messageid,username,sender,destination,Status,datesent)" +
" values ('" + MessageID + "','" + online[e.ClientID] + "','" + e.Originator.Replace("'", "^") + "','" + e.Destination + "','3','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "')";
Update(query);
transid = DateTime.Now.ToString("dMMyyyyHHmmss") + e.SequenceNumber;
// e.SequenceNumber = MySequenceNumber++;
query = "insert into messagesent(transid,username,phonenumber,message,sender,sentcode,billcode,messtype,mcount,messageid,status,failurereason,domain,dateused)" +
" values ('" + transid + "','" + online[e.ClientID] + "','" + e.Destination + "','" + mp.Content.Replace("'", "^") + "','" + e.Originator.Replace("'", "^") + "','2','0','1','1','" + MessageID + "','Awaiting Report','Awaiting Report','" + online2[e.ClientID, 2] + "','" + DateTime.Now.ToString("yyyy/MM/d/ HH:mm:ss") + "' )";
Update(query);
query = "insert into Messagestatus(messageid,username,Status,datesent)" +
" values ('" + MessageID + "','" + username + "','3','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "')";
Update(query);
Log.AddMessageSubmissionErrorEvent(result);
}
else
{
//submit failed
SMSCserverSMPP.smppSendSubmitMessageResponse(e.ClientID,
e.SequenceNumber, result, MessageID);
Log.AddMessageSubmitedEvent(MessageID);
}
}
//long message ends here
}
else
{
//single message
if (smpproute == "1")
{
if (e.UserDataHeader =="")
{
result = smsCclientSMPP1.smppSubmitMessage(e.Destination, 1, 1, e.Originator, 1, e.DNPI,
e.Content, Encoding, "", options,
out MessageID);
}else
{
result = smsCclientSMPP1.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, e.Content, Encoding, e.UserDataHeader, options, out MessageID);
}
//route 1 ends here.
}
if (smpproute == "2")
{
if (e.UserDataHeader == "")
{
result = smsCclientSMPP2.smppSubmitMessage(e.Destination, 1, 1, e.Originator, 1, e.DNPI,
e.Content, Encoding, "", options,
out MessageID);
}
else
{
result = smsCclientSMPP2.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, e.Content, Encoding, e.UserDataHeader, options, out MessageID);
}
}
if (smpproute == "3")
{
if (e.UserDataHeader == "")
{
result = smsCclientSMPP3.smppSubmitMessage(e.Destination, 1, 1, e.Originator, 1, e.DNPI,
e.Content, Encoding, "", options,
out MessageID);
}
else
{
result = smsCclientSMPP3.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, e.Content, Encoding, e.UserDataHeader, options, out MessageID);
}
}
if (smpproute == "4")
{
if (e.UserDataHeader == "")
{
result = smsCclientSMPP4.smppSubmitMessage(e.Destination, 1, 1, e.Originator, 1, e.DNPI,
e.Content, Encoding, "", options,
out MessageID);
}
else
{
result = smsCclientSMPP4.smppSubmitMessage(e.Destination, byte.Parse(txtDestTON.Text),
byte.Parse(txtDestNPI.Text), e.Originator, byte.Parse(txtOrigTON.Text), 5, e.Content, Encoding, e.UserDataHeader, options, out MessageID);
}
}
//if (smpproute == "3")
//{
// result = smsCclientSMPP3.smppSubmitMessage(e.Destination, 1, 1, e.Originator, 1, e.DNPI,
// e.Content, Encoding, "", options,
// out MessageID);
// //route 3 ends here.
//}
//if (smpproute == "4")
//{
// result = smsCclientSMPP4.smppSubmitMessage(e.Destination, 1, 1, e.Originator, 1, e.DNPI,
// e.Content, Encoding, "", options,
// out MessageID);
// //route 4 ends here.
//}
if (result == 0)
{
// SMSCserverSMPP.smppSendSubmitMultiMessageResponse(e.ClientID,
// e.SequenceNumber, 0, MessageID);
SMSCserverSMPP.smppSendSubmitMessageResponse(e.ClientID, e.SequenceNumber, 0, MessageID);
query = "insert into MessagestatusSMPP(messageid,username,sender,destination,Status,datesent)" +
" values ('" + MessageID + "','" + online[e.ClientID] + "','" + e.Originator.Replace("'", "^") + "','" + e.Destination + "','3','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "')";
Update(query);
// e.SequenceNumber = MySequenceNumber++;
query = "insert into messagesent(transid,username,phonenumber,message,sender,sentcode,billcode,messtype,mcount,messageid,status,failurereason,domain,dateused)" +
" values ('" + e.SequenceNumber + "','" + online[e.ClientID] + "','" + e.Destination + "','" + e.Content.Replace("'", "^") + "','" + e.Originator.Replace("'", "^") + "','2','0','1','1','" + MessageID + "','Awaiting Report','Awaiting Report','" + online2[e.ClientID, 2] + "','" + DateTime.Now.ToString("yyyy/MM/d/ HH:mm:ss") + "' )";
Update(query);
query = "insert into Messagestatus(messageid,username,Status,datesent)" +
" values ('" + MessageID + "','" + username + "','3','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "')";
Update(query);
query = e.Content + " nosa " + e.UserDataHeader + " blue " + e.Content.Length;
Log.AddEvent(query);
}
else
{
//submit failed
SMSCserverSMPP.smppSendSubmitMessageResponse(e.ClientID,
e.SequenceNumber, result, MessageID);
}
//single message ends here
}
//destination > 6 ends here
}
else
{
//submit failed - destination too short
SMSCserverSMPP.smppSendSubmitMessageResponse(e.ClientID,
e.SequenceNumber, 11, MessageID);
}
txtMessageID.Text = MessageID;
Log.AddReceivedSubmitMessageEvent(e.ClientID);
}
else
{
//No Money
SMSCserverSMPP.smppSendSubmitMessageResponse(e.ClientID,
e.SequenceNumber, 1025, MessageID);
}
}
//
// Event fired when response to message or status response (deliver_sm)
// has been received from the client party
//
private void SMSCserverSMPP_OnSmppDeliverResponseReceived(object sender,
smscs.SMPP.smppDeliverResponseReceivedEventArgs e)
{
//
// This ensures that message or status report sent earlier using
// smppSendDeliverMessage or smppSendDeliverStatusReport has been
// received by the client application. Appropriate transaction is
// identified via e.SequenceNumber field.
//
// MessageBox.Show("Nosa");
Log.AddReceivedDeliverResponseEvent(e.ClientID);
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
}
private void label19_Click(object sender, EventArgs e)
{
}
private void textBox6_TextChanged(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void connectgateway1()
{
int Result;
txtLog.Text = "";
txtLog.Refresh();
Result = smsCclientSMPP1.tcpConnect(textBox1.Text, int.Parse(textBox3.Text), "");
if (Result != 0)
Log.AddConnectionErrorEvent(Result);
else
Log.AddConnectedEvent("connected1");
//initialize
//Result = smsCclientSMPP1.smppInitializeSession(textBox5.Text, textBox7.Text, byte.Parse("1"), byte.Parse("1"), textBox9.Text);
Result = smsCclientSMPP1.smppInitializeSessionEx(textBox5.Text, textBox7.Text, byte.Parse("1"), byte.Parse("1"), textBox9.Text, smscc.SMPP.smppBindModeEnum.bmTransceiver, 3, "");
if (Result != 0)
Log.AddInitializationErrorEvent(Result);
else
{
Log.AddInitializedEvent("Initialized1");
//gateway1 = true;
bConnected1 = true;
}
timer1.Interval = 1000;
}
private void connectgateway2()
{
int Result;
txtLog.Text = "";
txtLog.Refresh();
Result = smsCclientSMPP2.tcpConnect(textBox2.Text, int.Parse(textBox4.Text), "");
if (Result != 0)
Log.AddConnectionErrorEvent(Result);
else
Log.AddConnectedEvent("Connected2");
//initialize
//Result = smsCclientSMPP2.smppInitializeSession(textBox6.Text, textBox8.Text, byte.Parse("1"), byte.Parse("1"), textBox10.Text);
Result = smsCclientSMPP2.smppInitializeSessionEx(textBox6.Text, textBox8.Text, byte.Parse("1"), byte.Parse("1"), textBox10.Text, smscc.SMPP.smppBindModeEnum.bmTransmitter, 3, "");
if (Result != 0)
Log.AddInitializationErrorEvent(Result);
else
{
Log.AddInitializedEvent("Initialized2");
//gateway2 = true;
bConnected2 = true;
}
}
private void connectgateway3()
{
int Result;
txtLog.Text = "";
txtLog.Refresh();
Result = smsCclientSMPP3.tcpConnect(textBox11.Text, int.Parse(textBox12.Text), "");
if (Result != 0)
Log.AddConnectionErrorEvent(Result);
else
Log.AddConnectedEvent("Connected3");
//initialize
//Result = smsCclientSMPP3.smppInitializeSession(textBox13.Text, textBox14.Text, byte.Parse("1"), byte.Parse("1"), textBox15.Text);
Result = smsCclientSMPP3.smppInitializeSessionEx(textBox13.Text, textBox14.Text, byte.Parse("1"), byte.Parse("1"), textBox15.Text, smscc.SMPP.smppBindModeEnum.bmTransmitter, 3, "");
if (Result != 0)
Log.AddInitializationErrorEvent(Result);
else
{
Log.AddInitializedEvent("Initialized3");
//gateway3 = true;
bConnected3 = true;
}
}
private void connectgateway4()
{
int Result;
txtLog.Text = "";
txtLog.Refresh();
Result = smsCclientSMPP4.tcpConnect(textBox16.Text, int.Parse(textBox17.Text), "");
if (Result != 0)
Log.AddConnectionErrorEvent(Result);
else
Log.AddConnectedEvent("Connected4");
//initialize
//Result = smsCclientSMPP4.smppInitializeSession(textBox18.Text, textBox19.Text, byte.Parse("1"), byte.Parse("1"), textBox20.Text);
Result = smsCclientSMPP4.smppInitializeSessionEx(textBox18.Text, textBox19.Text, byte.Parse("1"), byte.Parse("1"), textBox20.Text, smscc.SMPP.smppBindModeEnum.bmTransmitter, 3, "");
if (Result != 0)
Log.AddInitializationErrorEvent(Result);
else
{
Log.AddInitializedEvent("Initialized4");
//gateway4 = true;
bConnected4 = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
connectgateway1();
// System.Threading.Thread.Sleep(1000);
//connectgateway2();
//System.Threading.Thread.Sleep(1000);
//connectgateway3();
//System.Threading.Thread.Sleep(1000);
//connectgateway4();
bServiceReady1 = true;
timer1.Enabled = true;
timer1.Interval = 5000;
}
private void label15_Click(object sender, EventArgs e)
{
}
private void label20_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
// Check to see whether the user wants to exit the application.
// If not, add a number to the list box.
if (MessageBox.Show("Exit application?", "SMARTSMS ROUTER",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Application.Exit();
}
}
// Disconnected from SMSC
private void SMSCRelaySMPP_OnTcpDisconnected(object sender, tcpDisconnectedEventArgs e)
{
Log.AddDisconnectedEvent(e.Reason);
bConnected1 = false;
bConnected2 = false;
bConnected3 = false;
bConnected4 = false;
}
private void SMSCRelaySMPP1_OnTcpDisconnected(object sender, tcpDisconnectedEventArgs e)
{
Log.AddDisconnectedEvent(e.Reason, "Gateway1");
bConnected1 = false;
}
private void SMSCRelaySMPP2_OnTcpDisconnected(object sender, tcpDisconnectedEventArgs e)
{
Log.AddDisconnectedEvent(e.Reason, "Gateway2");
bConnected2 = false;
}
private void SMSCRelaySMPP3_OnTcpDisconnected(object sender, tcpDisconnectedEventArgs e)
{
Log.AddDisconnectedEvent(e.Reason, "Gateway3");
bConnected3 = false;
}
private void SMSCRelaySMPP4_OnTcpDisconnected(object sender, tcpDisconnectedEventArgs e)
{
Log.AddDisconnectedEvent(e.Reason, "Gateway4");
bConnected4 = false;
}
// Message received from SMSC
private void SMSCRelaySMPP_OnSmppMessageReceived(object sender, smppMessageReceivedEventArgs e)
{
int result = 0;
//EncodingEnum Encoding;
int cnt = 0;
string queryResult = "";
String messageID = "";
String league = "";
String datein ="";
String insertvalues = "";
String myMessageID = "";
string response ="";
string confirmation = "";
DateTime ExpiryDate;
DateTime thisDay = DateTime.Today;
string productID = "";
string SE_errorCode = "";
string SE_productID = "";
int validity =0;
string product_Name = "";
string keyword = "";
string keyword2 = "";
string shortcode="";
string[] keywords;
String myExpiryDate ="";
String myExpiryDate2 = "";
EncodedMessage em = en.AddMessageToDecode(e.Destination,e.Originator,e.Content, e.UserDataHeader,
e.Encoding, e.ExtendedParameters);
transid = DateTime.Now.ToString("yyyyMMdHHmmss")+generate_Digits(7);
if (em != null)
{
if (em is NoDecodingNeededMessage)
{
Log.AddMessageReceivedEvent(e.Destination, e.Originator,
e.Content, e.Encoding, e.UserDataHeader);
//send message
//options = (int)SubmitOptionEnum.soRequestStatusReport;
//SMSCencoder en = new SMSCencoder();
datein = DateTime.Now.ToString("yyyy-MM-d HH:mm:ss");
myExpiryDate2 = DateTime.Now.AddDays(14).ToString("yyyy-MM-d HH:mm:ss");
myExpiryDate = DateTime.Today.AddDays(14).ToString("d-MM-yyyy");
//log message received
string me3 = e.Content.Replace("'", "^");
if (e.Destination == "32811")
{
insertvalues = "'" + transid + "','" + e.Originator + "','" + e.Destination + "','" + me3 + "','0','" + datein + "'";
query = "insert into penpalreceived (transid,msisdn,sender,message,status,datesent) values ( " + insertvalues + ")";
Update(query);
insertvalues = "'" + transid + "','" + e.Originator + "','" + e.Destination + "','" + me3 + "'";
query = "insert gtsmessagereceived (transid,msisdn,shortcode,message) values ( " + insertvalues + ")";
Update(query);
}
//handle 33811 for zeeword
if (e.Destination == "33811")
{
insertvalues = "'" + transid + "','" + e.Originator + "','" + e.Destination + "','" + me3 + "','0'";
query = "insert into ZeeWorldreceived (transid,msisdn,shortcode,message,status) values ( " + insertvalues + ")";
Update(query);
insertvalues = "'" + transid + "','" + e.Originator + "','" + e.Destination + "','" + me3 + "'";
query = "insert gtsmessagereceived (transid,msisdn,shortcode,message) values ( " + insertvalues + ")";
Update(query);
}
}
}
}
public static string generate_Digits(int length)
{
var rndDigits = new System.Text.StringBuilder().Insert(0, "0123456789", length).ToString().ToCharArray();
return string.Join("", rndDigits.OrderBy(o => Guid.NewGuid()).Take(length));
}
private int GetNDigitsRandomNumber(int digits)
{
var min = 1;
for (int i = 0; i < digits - 1; i++)
{
min *= 10;
}
var max = min * 10;
//return _rnd.Next(min, max);
return max;
}
/// Execute a Soap WebService call
/// </summary>
public string ExecuteSE(string msisdn,string productid)
{
string SE_XML_input ="";
string SE_XML_output = "";
string errorCode ="";
string productID_received = "";
string SoapResponse = "";
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
SE_XML_input = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sub='http://SubscriptionEngine.ibm.com'>";
SE_XML_input = SE_XML_input+ "<soapenv:Header/>";
SE_XML_input = SE_XML_input+ "<soapenv:Body>";
SE_XML_input = SE_XML_input+"<sub:handleNewSubscription>";
SE_XML_input = SE_XML_input+"<custAttributesDTO>";
SE_XML_input = SE_XML_input+"<cpId>72</cpId>";
SE_XML_input = SE_XML_input+"<cpPwd>Md4t6#2y</cpPwd>";
SE_XML_input = SE_XML_input+"<msisdn>"+msisdn+"</msisdn>";
SE_XML_input = SE_XML_input + "<channelName>SMS</channelName>";
SE_XML_input = SE_XML_input+"<productId>"+productid+"</productId>";
SE_XML_input = SE_XML_input+"<cpName>2358614_CELLCAST_NG_SE</cpName>";
SE_XML_input = SE_XML_input+"<aocMsg1>1</aocMsg1>";
SE_XML_input = SE_XML_input+"<aocMsg2>9</aocMsg2>";
SE_XML_input = SE_XML_input+"<firstConfirmationDTTM>2015-05-05T15:23:03.890Z</firstConfirmationDTTM></custAttributesDTO></sub:handleNewSubscription><sub:handleHTNewActivation><activationRequest><cpID/><songProdID/><subProdID/></activationRequest></sub:handleHTNewActivation></soapenv:Body></soapenv:Envelope>";
HttpWebRequest request = CreateWebRequest();
XmlDocument soapEnvelopeXml = new XmlDocument();
soapEnvelopeXml.LoadXml(@SE_XML_input);
try
{
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
if (rd != null)
{
SE_XML_output = rd.ReadToEnd();
Console.WriteLine(SE_XML_output);
//parse for errorcode
String beginStr = "<errorCode>";
String endStr = "</errorCode>";
int cnt1 = SE_XML_output.IndexOf(beginStr);
int cnt2 = SE_XML_output.IndexOf(endStr);
errorCode = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
beginStr = "<productId>";
endStr = "</productId>";
cnt1 = SE_XML_output.IndexOf(beginStr);
cnt2 = SE_XML_output.IndexOf(endStr);
productID_received = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
SoapResponse = errorCode + "," + productID_received;
SE_XML_input = SE_XML_input.Replace("'", "^");
SE_XML_output = SE_XML_output.Replace("'", "^");
string insertvalues = "'" + transid + "','" + msisdn + "','" + productid + "','" + SE_XML_input + "','" + SE_XML_output + "','" + errorCode + "','" + productID_received + "'";
query = "insert into cellcast_SE_logs (transid,msisdn,productID_Sent,SOAP_Sent,SOAP_response,errorCode,productID_Received) values ( " + insertvalues + ")";
Update(query);
}
else
{
MessageBox.Show("Error Message detected");
}
//Console.WriteLine(erorrCode);
}
}
}
catch (WebException webex)
{
WebResponse errResp = webex.Response;
using (Stream respStream = errResp.GetResponseStream())
{
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
Console.WriteLine(text);
}
}
return SoapResponse;
}
/// <summary>
/// Create a soap webrequest to [Url]
/// </summary>
/// <returns></returns>
///
public string ExecuteSE_3PP(string msisdn, string productid)
{
string SE_XML_input = "";
string SE_XML_output = "";
string errorCode = "";
string productID_received = "";
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
SE_XML_input = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sub='http://SubscriptionEngine.ibm.com'>";
SE_XML_input = SE_XML_input + "<soapenv:Header/>";
SE_XML_input = SE_XML_input + "<soapenv:Body>";
SE_XML_input = SE_XML_input + "<sub:handleNewSubscription>";
SE_XML_input = SE_XML_input + "<custAttributesDTO>";
SE_XML_input = SE_XML_input + "<cpId>72</cpId>";
SE_XML_input = SE_XML_input + "<cpPwd>Md4t6#2y</cpPwd>";
SE_XML_input = SE_XML_input + "<msisdn>" + msisdn + "</msisdn>";
SE_XML_input = SE_XML_input + "<channelName>SMS</channelName>";
SE_XML_input = SE_XML_input + "<productId>" + productid + "</productId>";
SE_XML_input = SE_XML_input + "<cpName>2358614_CELLCAST_NG_SE</cpName>";
SE_XML_input = SE_XML_input + "<aocMsg1>1</aocMsg1>";
SE_XML_input = SE_XML_input + "<aocMsg2>9</aocMsg2>";
SE_XML_input = SE_XML_input + "<firstConfirmationDTTM>2015-05-05T15:23:03.890Z</firstConfirmationDTTM></custAttributesDTO></sub:handleNewSubscription><sub:handleHTNewActivation><activationRequest><cpID/><songProdID/><subProdID/></activationRequest></sub:handleHTNewActivation></soapenv:Body></soapenv:Envelope>";
HttpWebRequest request = CreateWebRequest();
XmlDocument soapEnvelopeXml = new XmlDocument();
soapEnvelopeXml.LoadXml(@SE_XML_input);
try
{
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
SE_XML_output = rd.ReadToEnd();
Console.WriteLine(SE_XML_output);
//parse for errorcode
String beginStr = "<errorCode>";
String endStr = "</errorCode>";
int cnt1 = SE_XML_output.IndexOf(beginStr);
int cnt2 = SE_XML_output.IndexOf(endStr);
errorCode = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
beginStr = "<productId>";
endStr = "</productId>";
cnt1 = SE_XML_output.IndexOf(beginStr);
cnt2 = SE_XML_output.IndexOf(endStr);
productID_received = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
SE_XML_input = SE_XML_input.Replace("'", "^");
SE_XML_output = SE_XML_output.Replace("'", "^");
string insertvalues = "'" + transid + "','" + msisdn + "','" + productid + "','" + SE_XML_input + "','" + SE_XML_output + "','" + errorCode + "','" + productID_received + "'";
query = "insert into cellcast_SE_logs (transid,msisdn,productID_Sent,SOAP_Sent,SOAP_response,errorCode,productID_Received) values ( " + insertvalues + ")";
Update(query);
//Console.WriteLine(erorrCode);
}
}
}
catch (WebException webex)
{
WebResponse errResp = webex.Response;
using (Stream respStream = errResp.GetResponseStream())
{
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
Console.WriteLine(text);
}
}
return SE_XML_output;
}
/// <summary>
/// Create a soap webrequest to [Url]
/// </summary>
/// <returns></returns>
///
public string ExecuteSE_3PP_UNSUB(string msisdn, string productid)
{
string SE_XML_input = "";
string SE_XML_output = "";
string errorCode = "";
string productID_received = "";
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
SE_XML_input = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sub='http://SubscriptionEngine.ibm.com'>";
SE_XML_input = SE_XML_input + "<soapenv:Header/>";
SE_XML_input = SE_XML_input + "<soapenv:Body>";
SE_XML_input = SE_XML_input + "<sub:handleDeSubscription>";
SE_XML_input = SE_XML_input + "<custAttributesDTO>";
SE_XML_input = SE_XML_input + "<msisdn>" + msisdn + "</msisdn>";
SE_XML_input = SE_XML_input + "<productId>" + productid + "</productId>";
SE_XML_input = SE_XML_input + "<cpId>72</cpId>";
SE_XML_input = SE_XML_input + "<cpPwd>Md4t6#2y</cpPwd>";
SE_XML_input = SE_XML_input + "</custAttributesDTO>";
SE_XML_input = SE_XML_input + "</sub:handleDeSubscription>";
SE_XML_input = SE_XML_input + "</soapenv:Body>";
SE_XML_input = SE_XML_input + "</soapenv:Envelope>";
HttpWebRequest request = CreateWebRequest();
XmlDocument soapEnvelopeXml = new XmlDocument();
soapEnvelopeXml.LoadXml(@SE_XML_input);
try
{
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
if (rd != null)
{
SE_XML_output = rd.ReadToEnd();
Console.WriteLine(SE_XML_output);
//parse for errorcode
String beginStr = "<errorCode>";
String endStr = "</errorCode>";
int cnt1 = SE_XML_output.IndexOf(beginStr);
int cnt2 = SE_XML_output.IndexOf(endStr);
errorCode = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
beginStr = "<productId>";
endStr = "</productId>";
cnt1 = SE_XML_output.IndexOf(beginStr);
cnt2 = SE_XML_output.IndexOf(endStr);
productID_received = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
SE_XML_input = SE_XML_input.Replace("'", "^");
SE_XML_output = SE_XML_output.Replace("'", "^");
string insertvalues = "'" + transid + "','" + msisdn + "','" + productid + "','" + SE_XML_input + "','" + SE_XML_output + "','" + errorCode + "','" + productID_received + "'";
query = "insert into cellcast_SE_logs (transid,msisdn,productID_Sent,SOAP_Sent,SOAP_response,errorCode,productID_Received) values ( " + insertvalues + ")";
Update(query);
//Console.WriteLine(erorrCode);
}else{
MessageBox.Show("Error Occurred");
}
}
}
}
catch (WebException webex)
{
WebResponse errResp = webex.Response;
using (Stream respStream = errResp.GetResponseStream())
{
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
Console.WriteLine(text);
}
}
return SE_XML_output;
}
/// <summary>
/// Create a soap webrequest to [Url]
/// </summary>
/// <returns></returns>
///
public string ExecuteSE_UNSUB(string msisdn, string productid)
{
string SE_XML_input = "";
string SE_XML_output = "";
string errorCode = "";
string productID_received = "";
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
SE_XML_input = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sub='http://SubscriptionEngine.ibm.com'>";
SE_XML_input = SE_XML_input + "<soapenv:Header/>";
SE_XML_input = SE_XML_input + "<soapenv:Body>";
SE_XML_input = SE_XML_input + "<sub:handleDeSubscription>";
SE_XML_input = SE_XML_input + "<custAttributesDTO>";
SE_XML_input = SE_XML_input + "<msisdn>" + msisdn + "</msisdn>";
SE_XML_input = SE_XML_input + "<productId>" + productid + "</productId>";
SE_XML_input = SE_XML_input + "<cpId>72</cpId>";
SE_XML_input = SE_XML_input + "<cpPwd>Md4t6#2y</cpPwd>";
SE_XML_input = SE_XML_input + "</custAttributesDTO>";
SE_XML_input = SE_XML_input + "</sub:handleDeSubscription>";
SE_XML_input = SE_XML_input + "</soapenv:Body>";
SE_XML_input = SE_XML_input + "</soapenv:Envelope>";
HttpWebRequest request = CreateWebRequest();
XmlDocument soapEnvelopeXml = new XmlDocument();
soapEnvelopeXml.LoadXml(@SE_XML_input);
try
{
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
SE_XML_output = rd.ReadToEnd();
Console.WriteLine(SE_XML_output);
//parse for errorcode
String beginStr = "<errorCode>";
String endStr = "</errorCode>";
int cnt1 = SE_XML_output.IndexOf(beginStr);
int cnt2 = SE_XML_output.IndexOf(endStr);
errorCode = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
beginStr = "<productId>";
endStr = "</productId>";
cnt1 = SE_XML_output.IndexOf(beginStr);
cnt2 = SE_XML_output.IndexOf(endStr);
productID_received = SE_XML_output.Substring(cnt1 + 11, cnt2 - (cnt1 + 11));
SE_XML_input = SE_XML_input.Replace("'", "^");
SE_XML_output = SE_XML_output.Replace("'", "^");
string insertvalues = "'" + transid + "','" + msisdn + "','" + productid + "','" + SE_XML_input + "','" + SE_XML_output + "','" + errorCode + "','" + productID_received + "'";
query = "insert into cellcast_SE_logs (transid,msisdn,productID_Sent,SOAP_Sent,SOAP_response,errorCode,productID_Received) values ( " + insertvalues + ")";
Update(query);
//Console.WriteLine(erorrCode);
}
}
}
catch (WebException webex)
{
WebResponse errResp = webex.Response;
using (Stream respStream = errResp.GetResponseStream())
{
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
Console.WriteLine(text);
}
}
return errorCode;
}
/// <summary>
/// Create a soap webrequest to [Url]
/// </summary>
/// <returns></returns>
public static HttpWebRequest CreateWebRequest()
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"https://68.169.54.76:8090/SchedulingEngineWeb/services/CallSubscription");
webRequest.Headers.Add(@"SOAPAction","handleHTNewActivation");
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
return webRequest;
}
public string HttpPost(string URI, string Parameters)
{
try
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
// req.Proxy = new System.Net.WebProxy(, true);
//Add these, as we're doing a POST
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
//We need to count how many bytes we're sending.
//Post'ed Faked Forms should be name=value&
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length); //Push it out there
os.Close();
System.Net.WebResponse resp = req.GetResponse();
if (resp == null) return null;
System.IO.StreamReader sr =
new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}
catch (WebException e)
{
string serverError = "URL "+ URI + " Parameters " + Parameters +" Error " + e.Message;
serverError = serverError.Replace("'", "^");
string query = "insert into cellcastErrorLogs(Error) values ('"+serverError+"')";
Update(query);
return "Server Return Error " + e.Message;
}
}
private Boolean isSubscriberExist(String msisdn, string league)
{
String response="";
Boolean flag = false;
String SQL = "";
SQL = "Select * from cellcastsubs where msisdn ='" + msisdn + "' and league ='" + league + "'";
response = getSubscriber(SQL);
if( response =="YES")
flag =true;
return flag;
}
// Status Report (SR) received from SMSC
private void SMSCRelaySMPP_OnSmppStatusReportReceived(object sender, smppStatusReportReceivedEventArgs e)
{
String MessageStatus = "";
String myMessageID = "";
using (connection)
{
switch (e.MessageState)
{
case 1:
MessageStatus = "ENROUTE";
break;
case 2:
MessageStatus = "DELIVERED";
break;
case 3:
MessageStatus = "EXPIRED";
break;
case 4:
MessageStatus = "DELETED";
break;
case 5:
MessageStatus = "UNDELIVERABLE";
break;
case 6:
MessageStatus = "ACCEPTED";
break;
case 7:
MessageStatus = "UNKNOWN";
break;
case 8:
MessageStatus = "REJECTED";
break;
}
// if( e.MessageID.Substring(0,1)=="0")
// myMessageID = e.MessageID.Substring(1);
//else
myMessageID = e.MessageID;
//query = "update cellcastlogs set status = '" + MessageStatus + "' where messageid = '" + myMessageID + "'";
// Update(query);
query = "update penpalmessagesent set status = '" + MessageStatus + "',flag='2' where messageid = '" + myMessageID + "'";
Update(query);
}
Log.AddEvent(query);
Log.AddStatusReportReceivedEvent(e.MessageID, e.Destination, e.Originator, e.MessageState, e.NetworkErrorCode);
}
// private void SMSCclientSMPP_OnSmppTraceProtocol(object Sender, smppTraceProtocolCallbackArgs e)
//{
// if (String.Equals(e.ToAddress, txtHost.Text + ":" + txtPort.Text) && (e.CommandID < 0x80000000))
//{
// e.SequenceNumber = MySequenceNumber++;
// }
// }
private void timer1_Tick(object sender, EventArgs e)
{
int options;
string messageID;
string myMessage1;
int result;
string league ="";
string[] keywords;
string errorCode ="";
String errorMsg ="";
String productID ="";
string xmlSoap ="";
string shortcode = "";
string URL2="";
String Param = "";
string messageOut = "Blank Message";
string Product_Name = "";
string datein, myExpiryDate2, queryResult,myExpiryDate = "";
int validity = 0;
DateTime ExpiryDate;
//URL2 = "http://103.43.154.86:9443/Kalibrate/Ren_Callback";
transid = DateTime.Now.ToString("yyyyMMdHHmmss") + generate_Digits(7);
datein = DateTime.Now.ToString("yyyy-MM-d HH:mm:ss");
myExpiryDate2 = DateTime.Now.AddDays(14).ToString("yyyy-MM-d HH:mm:ss");
myExpiryDate = DateTime.Today.AddDays(14).ToString("d-MM-yyyy");
if (bServiceReady1 && !bConnected1)
connectgateway1();
label35.Text = DateTime.Now.ToString("yyyy/MM/d HH:mm:ss");
cnt1++;
if (cnt1 > 10)
cnt1 = 0;
if (bServiceReady1 && bConnected1)
{
Log.AddConnectedEvent("Gate 1 " + label35.Text + " cnt1 = " + cnt1);
// Log.AddConnectedEvent("Gate 1 " + label35.Text + " cnt1 = " + cnt1);
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection = new MySqlConnection(connectionString);
using (connection)
{
try
{
MySqlCommand command = new MySqlCommand(
"SELECT sn, msisdn, sender, message from penpalmessagesent where engine ='1' and flag ='0' order by sn limit 100 ;",
connection);
connection.Open();
MySqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
serialno = reader.GetString(0);
phonenumber = reader.GetString(1);
senderid = reader.GetString(2);
mymessage = reader.GetString(3);
options = (int)SubmitOptionEnum.soRequestStatusReport;
myMessage1 = mymessage.Replace("<br>", "\n");
myMessage1 = myMessage1.Replace("^", "'");
result = smsCclientSMPP1.smppSubmitMessage(phonenumber, 1, 1, senderid, 5, 1,
myMessage1, EncodingEnum.et7BitText, "", options, out messageID);
if (result == 0)
{
// Message submitted correctly
Log.AddMessageSubmitedEvent(messageID);
//update messagesent
query = "Update Penpalmessagesent set flag ='1',Status ='Awaiting Report',messageid='" + messageID + "',result='" + result + "', mcount =1 where sn ='" + serialno + "'";
Update(query);
}
else
{
// Error while submitting message
Log.AddMessageSubmissionErrorEvent(result);
query = "Update Penpalmessagesent set flag ='1',result='" + result + "' where sn ='" + serialno + "'";
Update(query);
}
}//while loop
//house keeping work
// query = "update cellcastmessagesent set flag = '0' where result ='-2';";
// Update(query);
// query = "update cellcastmessagesent set flag = '0' where result ='-1' ;";
//Update(query);
}
reader.Close();
connection.Close();
}
catch (MySqlException ex)
{
//label1.Text = "Connection Error!\n" + ex.Message;
string serverError = ex.Message.Replace("'","^");
string query = "insert into cellcastErrorLogs(Error) values ('" + serverError + "')";
Update(query);
}
finally
{
connection.Close();
}
}
}
}
private void textBox10_TextChanged(object sender, EventArgs e)
{
}
private bool OpenConnection()
{
try
{
connection.Open();
return true;
}
catch (MySqlException ex)
{
//When handling errors, you can your application's response based
//on the error number.
//The two most common error numbers when connecting are as follows:
//0: Cannot connect to server.
//1045: Invalid user name and/or password.
switch (ex.Number)
{
case 0:
MessageBox.Show("Cannot connect to server. Contact administrator");
break;
case 1045:
MessageBox.Show("Invalid username/password, please try again");
break;
}
return false;
}
}
//Close connection
private bool CloseConnection()
{
try
{
connection.Close();
return true;
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
//Insert statement
public void Insert(string query)
{
//string query = "INSERT INTO tableinfo (name, age) VALUES('John Smith', '33')";
//open connection
if (this.OpenConnection() == true)
{
//create command and assign the query and connection from the constructor
MySqlCommand cmd = new MySqlCommand(query, connection);
//Execute command
cmd.ExecuteNonQuery();
//close connection
this.CloseConnection();
}
}
//Update statement
public void Update(string query)
{
int reader2 = 0;
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection2 = new MySqlConnection(connectionString);
using (connection2)
try
{
MySqlCommand command2 = new MySqlCommand(query, connection2);
connection2.Open();
reader2 = command2.ExecuteNonQuery();
//if (reader2 == 0)
//{
// timer1.Enabled = false;
// if( MessageBox.Show("Error updating " + query + " Exit application?", "SMARTSMS ROUTER",
// MessageBoxButtons.YesNo) == DialogResult.Yes)
// {
// Application.Exit();
// }
//}
}
catch (Exception ex)
{
timer1.Enabled = false;
//timer1.Interval = 0;
if (MessageBox.Show("Error updating " + query + " Exit application?" + ex.Message, "SMARTSMS ROUTER",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Application.Exit();
}
}
connection2.Close();
}
public string lookupDnD(string phone)
{
string response = "0";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection2 = new MySqlConnection(connectionString);
query = "Select phonenumber from DnD where phonenumber ='" + phone + "'";
using (connection2)
{
MySqlCommand command2 = new MySqlCommand(query, connection2);
connection2.Open();
MySqlDataReader reader2 = command2.ExecuteReader();
if (reader2.HasRows)
{
while (reader2.Read())
{
response = "1";
}
}
}
connection2.Close();
return response;
}
public string getBalance(string query)
{
string balsms = "-99";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection2 = new MySqlConnection(connectionString);
using (connection2)
{
MySqlCommand command2 = new MySqlCommand(query, connection2);
connection2.Open();
MySqlDataReader reader2 = command2.ExecuteReader();
if (reader2.HasRows)
{
while (reader2.Read())
{
balsms = reader2.GetString(0);
}
}
}
connection2.Close();
return balsms;
}
public string getQuery1(string query)
{
string result = "#";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection2 = new MySqlConnection(connectionString);
using (connection2)
{
MySqlCommand command2 = new MySqlCommand(query, connection2);
connection2.Open();
MySqlDataReader reader2 = command2.ExecuteReader();
if (reader2.HasRows)
{
while (reader2.Read())
{
result = reader2.GetString(0);
}
}
}
connection2.Close();
return result;
}
public string getQuery2(string query)
{
string result = "#";
string result1 = "";
string result2 = "";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection2 = new MySqlConnection(connectionString);
using (connection2)
{
MySqlCommand command2 = new MySqlCommand(query, connection2);
connection2.Open();
MySqlDataReader reader2 = command2.ExecuteReader();
if (reader2.HasRows)
{
while (reader2.Read())
{
result1 = reader2.GetString(0);
result2 = reader2.GetString(1);
result = result1 + "," + result2;
}
}
}
connection2.Close();
return result;
}
public String getDate(string query)
{
String mydate ="";//DateTime.Today;
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection2 = new MySqlConnection(connectionString);
using (connection2)
{
MySqlCommand command2 = new MySqlCommand(query, connection2);
connection2.Open();
MySqlDataReader reader2 = command2.ExecuteReader();
if (reader2.HasRows)
{
while (reader2.Read())
{
mydate = reader2.GetString(0);
}
}
}
connection2.Close();
return mydate;
}
public string getSubscriber(string query)
{
string subexist = "NO";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection2 = new MySqlConnection(connectionString);
using (connection2)
{
MySqlCommand command2 = new MySqlCommand(query, connection2);
connection2.Open();
MySqlDataReader reader2 = command2.ExecuteReader();
if (reader2.HasRows)
{
while (reader2.Read())
{
subexist = "YES";
}
}
}
connection2.Close();
return subexist;
}
public void updateMessageStatus()
{
string smscID = "";
string stateID = "";
string networkID = "";
string stateResult = "";
string networkResult = "";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection3 = new MySqlConnection(connectionString);
using (connection3)
{
query = "Select messageid, messagestate,networkerror from messagestatus where status=0 limit 20";
MySqlCommand command3 = new MySqlCommand(query, connection3);
connection3.Open();
MySqlDataReader reader3 = command3.ExecuteReader();
if (reader3.HasRows)
{
while (reader3.Read())
{
smscID = reader3.GetString(0);
stateID = reader3.GetString(1);
networkID = reader3.GetString(2);
//get Messagestatus
query = "select description from messagestate where code ='" + stateID + "'";
stateResult = getBalance(query);
query = "select description from status where code ='" + networkID + "'";
networkResult = getBalance(query);
//update messagesent;
if (networkResult == "-99") networkResult = "Unknown Error from Provider Side";
query = "update messagesent set status ='" + stateResult.Trim() + "',failurereason='" + networkResult.Trim() + "' where messageID ='" + smscID + "'";
Update(query);
query = "update messagestatus set status ='1' where messageID ='" + smscID + "'";
Update(query);
}
}
}
connection3.Close();
// return balsms;
}
public void updateMessageStatus(string onlineclient)
{
string smscID = "";
string stateID = "";
string networkID = "";
int myclientID = 201;
//string stateResult = "";
//string networkResult = "";
string OrgID = "";
string Dest = "";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection3 = new MySqlConnection(connectionString);
using (connection3)
{
query = "Select messageid,sender,destination, messagestate,networkerror from messagestatussmpp where username='" + onlineclient + "' and status=0";
MySqlCommand command3 = new MySqlCommand(query, connection3);
connection3.Open();
MySqlDataReader reader3 = command3.ExecuteReader();
if (reader3.HasRows)
{
while (reader3.Read())
{
smscID = reader3.GetString(0);
OrgID = reader3.GetString(1);
Dest = reader3.GetString(2);
stateID = reader3.GetString(3);
networkID = reader3.GetString(4);
//get Messagestatus
//query = "select description from messagestate where code ='" + stateID + "'";
//stateResult = getBalance(query);
//query = "select description from status where code ='" + networkID + "'";
//networkResult = getBalance(query);
//update messagesent;
//if (networkResult == "-99") networkResult = "Unknown Error from Provider Side";
//query = "update messagesent set status ='" + stateResult.Trim() + "',failurereason='" + networkResult.Trim() + "' where messageID ='" + smscID + "'";
//Update(query);
try
{
for (int j = 0; j <= (online.Length - 1); j++)
{
if (online[j] == onlineclient.Trim())
{
myclientID = j;
label36.Text = j.ToString();
label37.Text = onlineclient;
if (stateID=="1" ){
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msEnRoute,int.Parse(networkID), "", "");
}
if (stateID == "2")
{
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msDelivered, int.Parse(networkID), "", "");
}
if (stateID == "3")
{
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msExpired, int.Parse(networkID), "", "");
}
if (stateID == "4")
{
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msDeleted, int.Parse(networkID), "", "");
}
if (stateID == "5")
{
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msUndeliverable, int.Parse(networkID), "", "");
}
if (stateID == "6")
{
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msAccepted, int.Parse(networkID), "", "");
}
if (stateID == "7")
{
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msUnknown, int.Parse(networkID), "", "");
}
if (stateID == "8")
{
SMSCserverSMPP.smppSendDeliverStatusReport(myclientID, sequenceNumber++,
OrgID, byte.Parse(txtDestTON.Text), byte.Parse(txtDestNPI.Text),
Dest, byte.Parse(txtOrigTON.Text), byte.Parse(txtOrigNPI.Text),
smppReportTypeEnum.rtFinal, "", smscID, 1, 1, DateTime.Now,
DateTime.Now, smppMessageStateEnum.msRejected, int.Parse(networkID), "", "");
}
query = "update messagestatussmpp set status ='1' where messageID ='" + smscID + "'";
Update(query);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "NosaMore");
}
}
}
}
connection3.Close();
// return balsms;
}
public bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle)
{
Double result;
return Double.TryParse(val, NumberStyle,
System.Globalization.CultureInfo.CurrentCulture, out result);
}
public bool IsNumber(string text)
{
Regex regex = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$");
return regex.IsMatch(text);
}
private void txtOrigTON_TextChanged(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
bServiceReady1 = false;
smsCclientSMPP1.tcpDisconnect();
// smsCclientSMPP2.tcpDisconnect();
// smsCclientSMPP3.tcpDisconnect();
// smsCclientSMPP4.tcpDisconnect();
}
private string getBalanceSMPP(string clientName,string mdomain)
{
string subprofile = "";
//get sub profile
query = "Select subprofile from smsprofile where username ='" + clientName + "' and domain ='"+ mdomain + "'";
string queryresult = getBalance(query);
if (queryresult == "-99")
{
subprofile = "99";
return "1";
}
else
{
subprofile = queryresult;
//check for balance before sending if the message is to be billed
if (subprofile == "1")
{
query = "Select balnaira from smsAccount where username ='" + clientName + "' and domain ='" + mdomain + "'";
}
if (subprofile == "2")
{
query = "Select baleuro from smsAccount where username ='" + clientName + "' and domain ='" + mdomain + "'";
}
if (subprofile == "3")
{
query = "Select baldollar from smsAccount where username ='" + clientName + "' and domain ='" + mdomain + "'";
}
queryresult = getBalance(query);
if (queryresult == "-99")
{
return "1";
}
else
{
if (float.Parse(queryresult) > 3.0)
{
return "0";
}
else
{
return "1";
}
}
}
}
private string chargeSMPP(string clientName,string submessage,string routeprice,string mdomain,string mtransid,string mphone,string subprofile)
{
// string subprofile = "";
string realbal = "";
string queryresult ="";
string route = "";
string cnt7 = "";
int cnt2;
//get sub profile
// query = "Select subprofile from smsprofile where username ='" + clientName + "' and domain ='"+mdomain +"'";
//queryresult = getBalance(query);
//if (queryresult == "-99")
//{
// subprofile = "99";
//cnt7 = "1";
//return cnt7;
//}
//else
// subprofile
//check for balance before sending if the message is to be billed
if (subprofile == "1")
{
query = "Select balnaira from smsAccount where username ='" + clientName + "' and domain ='" + mdomain + "'";
}
if (subprofile == "2")
{
query = "Select baleuro from smsAccount where username ='" + clientName + "' and domain ='" + mdomain + "'";
}
if (subprofile == "3")
{
query = "Select baldollar from smsAccount where username ='" + clientName + "' and domain ='" + mdomain + "'";
}
queryresult = getBalance(query);
if (queryresult == "-99")
{
cnt7 = "1";
return cnt7;
}
else
{
if (float.Parse(queryresult) > 1.0)
{
//charge the client
realbal = queryresult;
if (submessage.Length > 160)
cnt2 = (submessage.Length / 153) + 1;
else
cnt2 = 1;
Double amtcharged = Double.Parse(routeprice) * cnt2;
Double newbal2 = Double.Parse(realbal) - amtcharged;
string newbal = newbal2.ToString();
//update subscriber
if (newbal2 >= 0.0)
{
//there is money for the message
if (subprofile == "1")
{
query = "update SMSAccount set balnaira = " + newbal + ",dateused ='" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "' where username = '" + clientName + "' and domain='" + mdomain + "'";
}
if (subprofile == "2")
{
query = "update SMSAccount set baleuro = " + newbal + ",dateused ='" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "' where username = '" + clientName + "' and domain='" + mdomain + "'";
}
if (subprofile == "3")
{
query = "update SMSAccount set baldollar = " + newbal + ",dateused ='" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "' where username = '" + clientName + "' and domain='" + mdomain + "'";
}
//query = "update SMSAccount set balsms = " + newbal + ",dateused ='" + date() + "' where username = '" + username + "'";
Update(query);
//insert into accounthistory
string insertvalues = "'" + mtransid + "','" + clientName + "','" + realbal + "','" + amtcharged.ToString() + "','" + newbal + "','" + cnt2.ToString() + "','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "','" + mdomain + "','" + mphone + "'";
query = "insert into accounthistory (transid,username,oldbal,amtcharged,newbal,page,dateused,domain,phonenumber) values ( " + insertvalues + ")";
Update(query);
//Update messagesent
query = "update messagesent set sentcode = '2' ,billcode='2', route='" + route + "', amtcharged ='" + amtcharged.ToString() + "' where transid = '" + mtransid + "'";
Update(query);
cnt7 = "0";
return cnt7;
}
else
{
cnt7 = "1";
return cnt7;
}
}
}
return cnt7;
}
private string getRouteSmpp(string Phonenumber)
{
bool cnt3 = false;
string Phone = "";
string queryresult = "";
string groute = "";
//cnt3 = false;
//get route
Phone = Phonenumber.Substring(0, 7);
query = "select routeno from globalrouting1 where NDC ='" + Phone + "'";
queryresult = getBalance(query);
if (queryresult != "-99")
{
cnt3 = true;
groute = queryresult;
}
if (!cnt3)
{
Phone = Phonenumber.Substring(0, 6);
query = "select routeno from globalrouting1 where NDC ='" + Phone + "'";
queryresult = getBalance(query);
if (queryresult != "-99")
{
cnt3 = true;
groute = queryresult;
}
}
if (!cnt3)
{
Phone = Phonenumber.Substring(0, 5);
query = "select routeno from globalrouting1 where NDC ='" + Phone + "'";
queryresult = getBalance(query);
if (queryresult != "-99")
{
cnt3 = true;
groute = queryresult;
}
}
if (!cnt3)
{
Phone = Phonenumber.Substring(0, 4);
query = "select routeno from globalrouting1 where NDC ='" + Phone + "'";
queryresult = getBalance(query);
if (queryresult != "-99")
{
cnt3 = true;
groute = queryresult;
}
}
if (!cnt3)
{
Phone = Phonenumber.Substring(0, 3);
query = "select routeno from globalrouting1 where NDC ='" + Phone + "'";
queryresult = getBalance(query);
if (queryresult != "-99")
{
cnt3 = true;
groute = queryresult;
}
}
if (!cnt3)
{
Phone = Phonenumber.Substring(0, 2);
query = "select routeno from globalrouting1 where NDC ='" + Phone + "'";
queryresult = getBalance(query);
if (queryresult != "-99")
{
cnt3 = true;
groute = queryresult;
}
}
if (!cnt3)
{
Phone = Phonenumber.Substring(0, 1);
query = "select routeno from globalrouting1 where NDC ='" + Phone + "'";
queryresult = getBalance(query);
if (queryresult != "-99")
{
cnt3 = true;
groute = queryresult;
}
}
if (cnt3)
{
return groute;
}
else
{
return "-1";
}
//getRouteSmpp ends here
}
private void button7_Click(object sender, EventArgs e)
{
connectgateway2();
bServiceReady2 = true;
timer2.Enabled = true;
timer2.Interval = 5000;
}
private void button8_Click(object sender, EventArgs e)
{
connectgateway3();
bServiceReady3 = true;
timer3.Enabled = true;
timer3.Interval = 5000;
}
private void button9_Click(object sender, EventArgs e)
{
connectgateway4();
bServiceReady4 = true;
timer4.Enabled = true;
timer4.Interval = 5000;
}
private void button10_Click(object sender, EventArgs e)
{
timer2.Enabled = false;
bServiceReady2 = false;
smsCclientSMPP2.tcpDisconnect();
}
private void button11_Click(object sender, EventArgs e)
{
timer3.Enabled = false;
bServiceReady3 = false;
smsCclientSMPP3.tcpDisconnect();
}
private void button12_Click(object sender, EventArgs e)
{
timer4.Enabled = false;
bServiceReady4 = false;
smsCclientSMPP4.tcpDisconnect();
}
private void timer2_Tick(object sender, EventArgs e)
{
int cnt11 = 0;
int options;
string messageID;
string myMessage = "";
int result;
string league = "";
string[] keywords;
string errorCode = "";
String errorMsg = "";
String productID = "";
string xmlSoap = "";
string shortcode = "";
string URL2 = "";
String Param = "";
string messageOut = "Blank Message";
string Product_Name = "";
string datein, myExpiryDate2, queryResult, myExpiryDate = "";
int validity = 0;
if (bServiceReady2 && !bConnected2)
connectgateway2();
label35.Text = DateTime.Now.ToString("yyyy/MM/d HH:mm:ss");
cnt2++;
if (cnt2 > 10)
cnt2 = 0;
if (bServiceReady2 && bConnected2)
{
Log.AddConnectedEvent("Gate 2 "+label35.Text + " cnt2 = " + cnt2);
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection = new MySqlConnection(connectionString);
using (connection)
{
try
{
MySqlCommand command = new MySqlCommand(
"SELECT sn, msisdn, sender, message from penpalmessagesent where engine ='2' and flag ='0' order by sn limit 4 ;",
connection);
connection.Open();
MySqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
serialno = reader.GetString(0);
phonenumber = reader.GetString(1);
senderid = reader.GetString(2);
mymessage = reader.GetString(3);
options = (int)SubmitOptionEnum.soRequestStatusReport;
myMessage = mymessage.Replace("<br>", "\n");
myMessage = myMessage.Replace("^", "'");
result = smsCclientSMPP2.smppSubmitMessage(phonenumber, 1, 1, senderid, 5, 1,
myMessage, EncodingEnum.et7BitText, "", options, out messageID);
if (result == 0)
{
// Message submitted correctly
Log.AddMessageSubmitedEvent(messageID);
//update messagesent
query = "Update Penpalmessagesent set flag ='1',Status ='Awaiting Report',messageid='" + messageID + "',result='" + result + "', mcount =1 where sn ='" + serialno + "'";
Update(query);
}
else
{
// Error while submitting message
Log.AddMessageSubmissionErrorEvent(result);
query = "Update penpalmessagesent set flag ='1',result='" + result + "' where sn ='" + serialno + "'";
Update(query);
}
if (cnt11 > 4)
{
System.Threading.Thread.Sleep(15000);
cnt11 = 0;
}
}//while loop
//house keeping work
//query = "update cellcastmessagesent set flag = '0' where result ='-2';";
//Update(query);
//query = "update cellcastmessagesent set flag = '0' where result ='-1';";
//Update(query);
}
reader.Close();
connection.Close();
}
catch (MySqlException ex)
{
//label1.Text = "Connection Error!\n" + ex.Message;
string serverError = ex.Message;
string query = "insert into cellcastErrorLogs(Error) values ('" + serverError + "')";
Update(query);
}
finally
{
connection.Close();
}
}
}
}
private void timer3_Tick(object sender, EventArgs e)
{
if (bServiceReady3 && !bConnected3)
connectgateway3();
label35.Text = DateTime.Now.ToString("yyyy/MM/d HH:mm:ss");
cnt3++;
if (cnt3 > 10)
cnt3 = 0;
if (bServiceReady3 && bConnected3)
{
Log.AddConnectedEvent("Gate 3 "+label35.Text + " cnt3 = " + cnt3);
}
}
private void timer4_Tick(object sender, EventArgs e)
{
string route = "";
int result = 1;
string messageID = "";
int NPI;
int options;
EncodingEnum Encoding;
int cnt6 = 0;
string domain = "";
string mccmnc = "";
string mtransid = "";
if (bServiceReady4 && !bConnected4)
connectgateway4();
label35.Text = DateTime.Now.ToString("yyyy/MM/d HH:mm:ss");
cnt4++;
if (cnt4 > 10)
cnt4 = 0;
if (bServiceReady4 && bConnected4)
{
Log.AddConnectedEvent("Gate 4 "+label35.Text + " cnt4 = " +cnt4);
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection = new MySqlConnection(connectionString);
using (connection)
{
MySqlCommand command = new MySqlCommand(
"SELECT sn,username,phonenumber,message,sender,messtype,transid,billcode,route,domain,mccmnc FROM messagesent where sentcode = '1' and billcode ='1' and route ='4' ;",
connection);
connection.Open();
MySqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
serialno = reader.GetString(0);
username = reader.GetString(1);
phonenumber = reader.GetString(2);
mymessage = reader.GetString(3);
senderid = reader.GetString(4);
messtype = reader.GetString(5);
transid = reader.GetString(6);
billcode = reader.GetString(7);
route = reader.GetString(8);
domain = reader.GetString(9);
mccmnc = reader.GetString(10);
options = (int)SubmitOptionEnum.soRequestStatusReport;
cnt7 = 0;
//check for DnD
// if (mccmnc == "62130")
//{
if (username == "De_mmms")
{
query = "Update messagesent set route='" + txtDestNPI.Text.Trim() + "' where sn ='" + serialno + "'";
Update(query);
cnt7 = 1;
Log.AddEvent("DnD Rerouted");
}
if (lookupDnD(phonenumber) == "1")
{
query = "Update messagesent set route='" + txtDestNPI.Text.Trim() + "' where sn ='" + serialno + "'";
Update(query);
cnt7 = 1;
Log.AddEvent("DnD Rerouted");
}
//}
if (cnt7 == 0)
{
//check sender type
if (IsNumber(senderid))
{
NPI = 1;
}
else
{
NPI = 5;
}
//check message type
switch (messtype)
{
case "1":
Encoding = EncodingEnum.et7BitText;
break;
case "2":
Encoding = EncodingEnum.et8BitHexadecimal;
break;
case "3":
Encoding = EncodingEnum.etUCS2Text;
break;
case "4":
Encoding = EncodingEnum.etISO88591;
break;
case "5":
Encoding = EncodingEnum.etISO88595;
break;
case "6":
Encoding = EncodingEnum.etISO88598;
break;
default:
Encoding = EncodingEnum.et7BitText;
break;
}
//check if long message
if (mymessage.Length > 160)
{
MultipartMessage em = en.EncodeMultipartMessage(SplitMethodEnum.smUDH, mymessage, "", EncodingEnum.et7BitText, "");
cnt6 = 1;
foreach (MessagePart mp in em.Parts)
{
string Mess = mp.Content.Replace("<br>", "\n");
Mess = Mess.Replace("'", "^");
result = smsCclientSMPP4.smppSubmitMessage(phonenumber, 1, 1, senderid, 1, NPI,
Mess, EncodingEnum.et7BitText, mp.UDH, options, out messageID);
mtransid = transid + cnt6;
cnt6++;
query = "insert into messagesent(transid,username,track,domain,smpp,phonenumber,result,mccmnc,route,message,sender,sentcode,billcode,messtype,mcount,messageid,dateused)" +
" values ('" + mtransid + "','" + username + "','0','" + domain + "','0','" + phonenumber + "','" + result + "','" + mccmnc + "','" + route + "','" + Mess.Replace("'", "^") + "','" + senderid.Replace("'", "^") + "','2','" + billcode + "','1','1','" + messageID + "','" + DateTime.Now.ToString("yyyy/MM/d/ HH:mm:ss") + "' )";
Update(query);
query = "insert into Messagestatus(messageid,username,domain,Status,datesent)" +
" values ('" + messageID + "','" + username + "','" + domain + "','3','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "')";
Update(query);
// Message submitted correctly
Log.AddMessageSubmitedEvent(messageID + " Results = " + result);
}
//912 = long message
//update messagesent
query = "Update messagesent set sentcode ='4',track='1',smpp='0',status='Long Message',failurereason='Long Message' ,result='912' where sn ='" + serialno + "'";
Update(query);
}
else
{ //submit message // single message
mymessage = mymessage.Replace("<br>", "\n");
mymessage = mymessage.Replace("'", "^");
result = smsCclientSMPP4.smppSubmitMessage(phonenumber, 1, 1, senderid, 1, NPI,
mymessage, Encoding, "", options,
out messageID);
if (result == 0)
{
// Message submitted correctly
Log.AddMessageSubmitedEvent(messageID);
//update messagesent
query = "Update messagesent set sentcode ='2',smpp='0',Status ='Awaiting Report',messageid='" + messageID + "',result='" + result + "', mcount =1 where sn ='" + serialno + "'";
// query = "Update messagesent set sentcode ='2',Status ='Awaiting Report',result='" + result + "', mccmnc ='" + MCCMNC + "', route='" + route + "',mcount =1 where sn ='" + serialno + "'";
Update(query);
query = "insert into Messagestatus(messageid,username,domain,Status,datesent)" +
" values ('" + messageID + "','" + username + "','" + domain + "','3','" + DateTime.Now.ToString("yyyy/MM/d HH:mm:ss") + "')";
Update(query);
}
else
{
// Error while submitting message
Log.AddMessageSubmissionErrorEvent(result);
//update messagesent
query = "Update messagesent set sentcode ='3',smpp='0',result='" + result + "' where sn ='" + serialno + "'";
Update(query);
}
}
}
}// cnt7
}
reader.Close();
}
//resend messages that results fields are -1;
if (cnt4 ==10)
{
query = "Update messagesent set sentcode ='1' where (result ='-1' and smpp='0' and route ='4') or (result ='255' and smpp='0' and route ='4') ";
Update(query);
cnt4 = 0;
}
}
}
public string convertUnicode(string unicodeString)
{
//string unicodeString = "Dearly blvd, as soldiers of Christ, we�r mandated 2 preach d gospel of our Lord Jesus Christ 2 all nations. World Evangelism day is here again, 30th May, 2015. We�r espected 2 meet @ Abundant Life Parish 2 fulfill dis mandate. God bless u as u partake in Jesus� Name, Amen";
//MessageBox.Show(unicodeString);
// Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
// Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString);
// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
// Convert the new byte[] into a char[] and then into a string.
// This is a slightly different approach to converting to illustrate
// the use of GetCharCount/GetChars.
char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
string asciiString = new string(asciiChars);
// Display the strings created before and after the conversion.
//MessageBox.Show("Original string: {0}", unicodeString);
// MessageBox.Show("Ascii converted string: {0}", asciiString);
return asciiString;
}
private void timer5_Tick(object sender, EventArgs e)
{
Log.AddConnectedEvent("am here gate5");
//update messagestatus
//updateMessageStatus();
string smscID = "";
string stateID = "";
string networkID = "";
string stateResult = "";
string networkResult = "";
//Database connection
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection3 = new MySqlConnection(connectionString);
using (connection3)
{
query = "Select messageid, messagestate,networkerror from messagestatus where status=0 limit 10";
MySqlCommand command3 = new MySqlCommand(query, connection3);
connection3.Open();
MySqlDataReader reader3 = command3.ExecuteReader();
if (reader3.HasRows)
{
while (reader3.Read())
{
smscID = reader3.GetString(0);
stateID = reader3.GetString(1);
networkID = reader3.GetString(2);
//get Messagestatus
query = "select description from messagestate where code ='" + stateID + "'";
stateResult = getBalance(query);
query = "select description from status where code ='" + networkID + "'";
networkResult = getBalance(query);
//update messagesent;
if (networkResult == "-99") networkResult = "Unknown Error from Provider Side";
query = "update messagesent set status ='" + stateResult.Trim() + "',failurereason='" + networkResult.Trim() + "' where messageID ='" + smscID + "'";
Update(query);
query = "update messagestatus set status ='1' where messageID ='" + smscID + "'";
Update(query);
}
}
}
connection3.Close();
//end database connection
for (int i = 0; i < cbClients.Items.Count; i++)
{
string tmp = cbClients.GetItemText(cbClients.Items[i]);
int mystr = tmp.IndexOf(" ") + 1;
string myclient2 = tmp.Substring(0, mystr);
//MessageBox.Show(myclient2);
updateMessageStatus(myclient2);
}
}
private void button13_Click(object sender, EventArgs e)
{
timer5.Enabled = true;
timer5.Interval = 15000;
}
private void button14_Click(object sender, EventArgs e)
{
timer5.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
int options;
string messageID;
string myMessage = "";
int result1 =1014;
string league = "";
string[] keywords;
string errorCode = "";
String errorMsg = "";
String productID = "";
string xmlSoap = "";
string shortcode = "";
string URL2 = "";
String Param = "";
string messageOut = "Blank Message";
string Product_Name = "";
string datein, myExpiryDate2, queryResult, myExpiryDate = "";
int validity = 0;
server = "localhost";
database = "smartsmsrouter";
uid = "smsEngine";
password = "guEnaR28T";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection = new MySqlConnection(connectionString);
using (connection)
{
try
{
MySqlCommand command = new MySqlCommand(
"SELECT msisdn from campaign where sn>='2';",
connection);
connection.Open();
MySqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
phonenumber = reader.GetString(0);
//phonenumber = reader.GetString(1);
//senderid = reader.GetString(2);
//mymessage = reader.GetString(3);
query = "insert into penpalmessagesent(transid,msisdn,sender,message,flag,engine) values ('"+ result1.ToString() +"','" + phonenumber+ "','1903','Join our SMS chat Service to make New Friends in Nigeria & Ghana. Send Penpal to 1903 to get started. 50p per sms.','0','1');";
Update(query);
result1++;
}//while loop
MessageBox.Show("Done");
//house keeping work
//query = "update cellcastmessagesent set flag = '0' where result ='-2';";
//Update(query);
//query = "update cellcastmessagesent set flag = '0' where result ='-1';";
//Update(query);
}
reader.Close();
connection.Close();
}
catch (MySqlException ex)
{
//label1.Text = "Connection Error!\n" + ex.Message;
string serverError = ex.Message;
string query = "insert into cellcastErrorLogs(Error) values ('" + serverError + "')";
Update(query);
}
finally
{
connection.Close();
}
}
}//stop button
}
}