public frmSimTlv(SimTlv objTlv, EFrmType eFrmType) { InitializeComponent(); m_eFrmType = eFrmType; switch (m_eFrmType) { case EFrmType.ADD: Text = "Create new Tlv"; break; case EFrmType.EDIT: Text = "Edit Tlv"; break; } if (objTlv == null) { m_objSimTlv = new SimTlv(); } else { m_objSimTlv = objTlv; } }
private void btAdd_Click(object sender, EventArgs e) { frmSimTlv frm = new frmSimTlv(null, frmSimTlv.EFrmType.ADD); if (frm.ShowDialog() == DialogResult.Cancel) { return; } SimTlv objTlv = frm.Tlv; // If there's already a TLV with the tag, remove it. foreach (ListViewItem li in lvTlvs.Items) { SimTlv objInfo = (SimTlv)li.Tag; if (objInfo.Tag == objTlv.Tag) { lvTlvs.Items.Remove(li); } } // Add the newly created TLV value to the listview ListViewItem item = new ListViewItem(new String[] { m_objConstants.SmppTlvToString(objTlv.Tag).Replace("SMPP_TLV_", ""), objTlv.TlvType.ToString(), objTlv.TypedValue }); item.Tag = frm.Tlv; lvTlvs.Items.Insert(0, item); }
public SimTlv(SimTlv objOther) { m_nTag = objOther.m_nTag; m_eTlvType = objOther.m_eTlvType; m_stTypedValue = objOther.m_stTypedValue; m_strHexValue = objOther.m_strHexValue; }
SimMessage bw_CreateDlr(SimMessage objIn, int nVersion, int nStatusCode, string strStatusText, AxSms.Constants objSmsConst) { SimMessage objDlr = new SimMessage(); // Swap adress objDlr.FromAddress = objIn.ToAddress; objDlr.FromAddressNpi = objIn.ToAddressNpi; objDlr.FromAddressTon = objIn.FromAddressTon; objDlr.ToAddress = ""; objDlr.ToAddressNpi = 0; objDlr.ToAddressTon = objSmsConst.TON_ALPHANUMERIC; // Set session information objDlr.SessionId = objIn.SessionId; objDlr.SystemId = objIn.SystemId; // Add TLV's, only for 3.4 or 5.0 clients. if (nVersion != objSmsConst.SMPP_VERSION_33) { objDlr.Tlvs.Clear(); AxSms.Tlv objAxTlv = new AxSms.Tlv(); SimTlv objTlv = new SimTlv(); objTlv.Tag = objSmsConst.SMPP_TLV_MESSAGE_STATE; objAxTlv.ValueAsInt8 = nStatusCode; objTlv.TlvType = SimTlv.TlvTypes.HEX; objTlv.TypedValue = objAxTlv.ValueAsHexString; objTlv.HexValue = objTlv.TypedValue; objDlr.Tlvs.Add(objTlv); objTlv = new SimTlv(); objTlv.Tag = objSmsConst.SMPP_TLV_RECEIPTED_MESSAGE_ID; objAxTlv.ValueAsString = objIn.Reference; objTlv.TlvType = SimTlv.TlvTypes.HEX; objTlv.TypedValue = objAxTlv.ValueAsHexString; objTlv.HexValue = objTlv.TypedValue; objDlr.Tlvs.Add(objTlv); } // NOTE: submit date and done date are the same! string strExcerpt = objIn.Body.Substring(0, Math.Min(objIn.Body.Length, 60)); int iNumSmsDelivered = nStatusCode == objSmsConst.SMPP_MESSAGESTATE_DELIVERED ? 1: 0; string strBody = string.Format("id:{0} sub:001 dlvrd:{1:D3} submit date:{2:yyMMddHHmmss} done date:{2:yyMMddHHmmss} stat:{3} err:000 text:{4}", objIn.Reference, iNumSmsDelivered, DateTime.Now, strStatusText, strExcerpt); // Complete delivery report formatting objDlr.IsDeliveryReport = true; objDlr.Body = strBody.Substring(0, Math.Min(strBody.Length, 160)); return(objDlr); }
private void btEdit_Click(object sender, EventArgs e) { if (lvTlvs.SelectedItems.Count <= 0) { return; } SimTlv objEditted = (SimTlv)lvTlvs.SelectedItems[0].Tag; frmSimTlv frm = new frmSimTlv(objEditted, m_eFrmType == EFrmType.VIEW ? frmSimTlv.EFrmType.VIEW : frmSimTlv.EFrmType.EDIT); if (frm.ShowDialog() == DialogResult.OK) { ListViewItem item = lvTlvs.SelectedItems[0]; item.SubItems[1].Text = frm.Tlv.TlvType.ToString(); item.SubItems[2].Text = frm.Tlv.TypedValue; } }
private int LoadAutoMessages(string strFile) { XmlTextReader objXml = null; try { var lsAutoMsg = new List <SimMessage>(); objXml = new XmlTextReader(strFile); SimMessage objMessage = null; while (objXml.Read()) { if (objXml.NodeType == XmlNodeType.Element && objXml.Name == SimConstants.XML_AUTOMESSAGE_ELEMENT_NODE) { objMessage = new SimMessage(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_TOADDRESS], objXml[SimConstants.XML_AUTOMESSAGE_FIELD_FROMADDRESS], objXml[SimConstants.XML_AUTOMESSAGE_FIELD_BODY]); objMessage.ToAddressNpi = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_TONPI]); objMessage.ToAddressTon = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_TOTON]); objMessage.FromAddressNpi = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_FROMNPI]); objMessage.FromAddressTon = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_FROMTON]); objMessage.HasUdh = bool.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_HASUDH]); objMessage.IsDeliveryReport = bool.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_ISDLR]); objMessage.DataCoding = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_DATACODING]); objMessage.BodyFormat = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_BODYFORMAT]); objMessage.LanguageShift = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_LANGUAGESHIFT]); lsAutoMsg.Add(objMessage); } else if (objXml.NodeType == XmlNodeType.Element && objXml.Name == SimConstants.XML_AUTOMESSAGE_ELEMENT_TLV) { SimTlv objTlv = new SimTlv(); objTlv.Tag = int.Parse(objXml[SimConstants.XML_AUTOMESSAGE_FIELD_TAG]); objTlv.TlvType = (SimTlv.TlvTypes)Enum.Parse(typeof(SimTlv.TlvTypes), objXml[SimConstants.XML_AUTOMESSAGE_FIELD_TYPE]); objTlv.HexValue = objXml[SimConstants.XML_AUTOMESSAGE_FIELD_HEXVALUE]; objTlv.TypedValue = objXml[SimConstants.XML_AUTOMESSAGE_FIELD_TYPEDVALUE]; if (objMessage != null) { objMessage.Tlvs.Add(objTlv); } } } lvAutoMessage.Items.Clear(); foreach (SimMessage objSms in lsAutoMsg) { AddToAutoMessage(objSms); } PushAutoMessages(); } catch (Exception e) { // Error while reading the XML file m_Logger.WriteLine("LoadAutoMessages failed, exception: {0}", e.ToString()); return(1); } if (objXml != null) { objXml.Close(); } return(0); }