Exemplo n.º 1
0
 public double OldGetCurrentCredit()
 {
     try
     {
         var binding = new BasicHttpBinding();
         using (var proxy = new UsersSoapClient(binding, new EndpointAddress("http://n.sms.ir/ws/Users.asmx")))
         {
             var message = "";
             var userid  = proxy.GetUserIDByUserNameAndPassword(_username, _password, ref message);
             if (!string.IsNullOrEmpty(message.Trim()))
             {
                 throw new Exception(message);
             }
             int countOfAll = 0;
             if (userid != null)
             {
                 return(Convert.ToInt64(proxy.GetCreditArticles(_username, _password, userid.Value, SqlDateTime.MinValue.Value, SqlDateTime.MaxValue.Value, 1, int.MaxValue, ref countOfAll, ref message)[0].Remain * 120));
             }
             throw new Exception("شناسه كاربري در بانك اطلاعاتي سامانه ايده پردازان الكترونيك يافت نشد");
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("GetCurrentCredit", ex);
     }
     return(0);
 }
Exemplo n.º 2
0
 public SendReturnObject SendSms(string txt, string receiver, DateTime dt)
 {
     try
     {
         LogStringValue?.Invoke("متن پیام", txt);
         LogStringValue?.Invoke("گیرنده", receiver);
         var binding = new BasicHttpBinding();
         using (var op = new Iv2SoapClient(binding, new EndpointAddress("http://smsapp.ir/webservice/v2.asmx")))
         {
             var res = op.SendSMS(_username, _password, new ArrayOfString {
                 _sender
             }, new ArrayOfString {
                 receiver
             },
                                  new ArrayOfString {
                 txt
             }, new ArrayOfString {
                 dt.ToShortDateString()
             }, new ArrayOfInt {
                 0
             },
                                  new ArrayOfLong {
                 0
             });
             return(new SendReturnObject(string.Empty, SentStatus.Successful, 1));
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("SendSms", ex);
     }
     return(new SendReturnObject(string.Empty, SentStatus.Failed, -1));
 }
        private string FindNumber(string strCallLog, string lineKey)
        {
            if (strCallLog.Contains("Dial"))
            {
                return(string.Empty);
            }
            if (strCallLog.Contains("hook"))
            {
                return(string.Empty);
            }
            var str = string.Empty;

            try
            {
                if (strCallLog.IndexOf(lineKey, StringComparison.OrdinalIgnoreCase) != -1 && strCallLog.IndexOf("Dialed", StringComparison.OrdinalIgnoreCase) == -1 && strCallLog.IndexOf("hook-off", StringComparison.OrdinalIgnoreCase) == -1 && strCallLog.IndexOf("hook-on", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    var index      = strCallLog.IndexOf(lineKey, StringComparison.OrdinalIgnoreCase);
                    var num2       = strCallLog.IndexOf("@", index, StringComparison.OrdinalIgnoreCase);
                    var startIndex = index + lineKey.Length + 1;
                    if (num2 == startIndex)
                    {
                        return(string.Empty);
                    }
                    str = strCallLog.Substring(startIndex, num2 - startIndex);
                    str = FixPhoneNumber(str);
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("FindNumber", ex);
            }
            return(str);
        }
        private string FindDialedNumber(string strCallLog)
        {
            var str = string.Empty;

            try
            {
                if ((strCallLog.IndexOf("D", StringComparison.OrdinalIgnoreCase) != -1) && (strCallLog.IndexOf("HND", StringComparison.OrdinalIgnoreCase) == -1))
                {
                    var index      = strCallLog.IndexOf("D", StringComparison.OrdinalIgnoreCase);
                    var num2       = strCallLog.IndexOf("@", index, StringComparison.OrdinalIgnoreCase);
                    var startIndex = (index + "D".Length);
                    if (num2 == startIndex)
                    {
                        return(String.Empty);
                    }
                    str = strCallLog.Substring(startIndex, num2 - startIndex);
                    str = FixPhoneNumber(str);
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("FindDialedNumber", ex);
            }
            return(str);
        }
        private int FindDuration(string strCallLog)
        {
            var dur = -1;

            try
            {
                if (strCallLog.IndexOf("T", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    var index      = strCallLog.IndexOf("T", StringComparison.OrdinalIgnoreCase);
                    var num2       = strCallLog.IndexOf("@", index, StringComparison.OrdinalIgnoreCase);
                    var startIndex = (index + "T".Length);
                    if (num2 == startIndex)
                    {
                        return(-1);
                    }
                    var str = strCallLog.Substring(startIndex, num2 - startIndex);
                    dur = Convert.ToInt32(str);
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("FindDuration", ex);
            }
            return(dur);
        }
 private int FindLineNumber(string strCallLog)
 {
     try
     {
         int num;
         var num1 = 1;
         while (true)
         {
             if (num1 > this.LinesCount)
             {
                 num = 0;
                 break;
             }
             if (strCallLog.IndexOf(this.GetLineKey(num1), StringComparison.Ordinal) == -1)
             {
                 num1++;
             }
             else
             {
                 num = num1;
                 break;
             }
         }
         return(num);
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("FindLineNumber", ex);
     }
     return(0);
 }
        private string FindNumber(string strCallLog)
        {
            var str = string.Empty;

            try
            {
                var empty = string.Empty;
                if (strCallLog.IndexOf("L", StringComparison.Ordinal) == -1)
                {
                    return(empty);
                }
                if (strCallLog.IndexOf("C", StringComparison.Ordinal) == -1)
                {
                    return(empty);
                }
                var num  = strCallLog.IndexOf("L", StringComparison.Ordinal);
                var num1 = strCallLog.IndexOf("@", num, StringComparison.Ordinal);
                var num2 = num + 2 + 1;
                empty = strCallLog.Substring(num2, num1 - num2);
                empty = FixPhoneNumber(empty);
                return(empty);
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("FindNumber", ex);
            }
            return(str);
        }
 private void SetLinesState(string receivedData)
 {
     try
     {
         if (receivedData == null)
         {
             return;
         }
         var lineNo = FindLineNumber(receivedData);
         if (lineNo == 0)
         {
             return;
         }
         ILine line = null;
         if (GetLinesMap().ContainsKey(GetLineKey(lineNo)))
         {
             line = GetLinesMap()[GetLineKey(lineNo)];
         }
         if (line == null)
         {
             return;
         }
         lock (line)
         {
             var status = FindCallStatus(receivedData);
             LogStringValue?.Invoke("Status", status.ToString());
             if (status > 0)
             {
                 line.Status = status;
             }
             SetDurationState(receivedData, line);
             SetDialedNumberState(receivedData, line);
             var str = FindNumber(receivedData);
             if (str != string.Empty)
             {
                 line.Number = str;
                 LogStringValue?.Invoke("PhoneNumber", str);
             }
             var num2 = FindRingCounts(receivedData);
             if (num2 > 0)
             {
                 line.RingCounts = num2;
                 LogIntValue?.Invoke("RingCount", num2);
             }
             line.LastUpdate = DateTime.UtcNow;
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("SetLinesState", ex);
     }
 }
Exemplo n.º 9
0
 public double GetCurrentCredit()
 {
     try
     {
         Send sms = new Send();
         return(sms.GetCredit(_username, _password));
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("GetCurrentCredit", ex);
     }
     return(0);
 }
Exemplo n.º 10
0
 public double GetCurrentCredit()
 {
     try
     {
         var binding = new BasicHttpBinding();
         var alma    = new AlmaSms.smsserverPortTypeClient(binding, new EndpointAddress("http://37.130.202.188/public/class/sms/webservice3/server.php?wsdl"));
         return(Convert.ToDouble(alma.GetCredit(_username, _password)));
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("GetCurrentCredit", ex);
     }
     return(0);
 }
Exemplo n.º 11
0
 public double GetCurrentCredit()
 {
     try
     {
         using (var proxy = new sms_webservice())
         {
             return(proxy.sms_credit(_username, _password));
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("GetCurrentCredit", ex);
     }
     return(0);
 }
Exemplo n.º 12
0
 public SendReturnObject SendSms(string txt, string receiver, DateTime dt)
 {
     try
     {
         LogStringValue?.Invoke("متن پیام", txt);
         LogStringValue?.Invoke("گیرنده", receiver);
         mCore.SMS ObjSMS;
         //ObjSMS.
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("SendSms", ex);
     }
     return(new SendReturnObject(string.Empty, SentStatus.Failed, -1));
 }
Exemplo n.º 13
0
 public bool IsNumberBlackList(string number)
 {
     try
     {
         LogStringValue?.Invoke("شماره جهت بررسی وضعیت لیست سیاه", number);
         using (var proxy = new sms_webservice())
         {
             return(proxy.is_number_in_blacklist(number) == 1);
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("IsNumberBlackList", ex);
     }
     return(false);
 }
Exemplo n.º 14
0
 public double GetCurrentCredit()
 {
     try
     {
         var binding = new BasicHttpBinding();
         using (var op = new Iv2SoapClient(binding, new EndpointAddress("http://smsapp.ir/webservice/v2.asmx")))
         {
             return(Convert.ToDouble(op.GetCredit(_username, _password)));
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("GetCurrentCredit", ex);
     }
     return(0);
 }
Exemplo n.º 15
0
 public SendReturnObject[] SendSmsList(string txt, string[] receivers)
 {
     try
     {
         LogStringValue?.Invoke("متن پیام", txt);
         var binding = new BasicHttpBinding();
         var alma    = new AlmaSms.smsserverPortTypeClient(binding, new EndpointAddress("http://37.130.202.188/public/class/sms/webservice3/server.php?wsdl"));
         var res     = alma.SendSMS(_sender, receivers, txt, "", _username, _password);
         LogStringValue?.Invoke("Result", res);
         return(new[] { new SendReturnObject(string.Empty, SentStatus.Successful, -1) });
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("SendSms", ex);
     }
     return(new[] { new SendReturnObject(string.Empty, SentStatus.Failed, -1) });
 }
Exemplo n.º 16
0
        public RetrievalStatus GetRetrievalStatus(string id)
        {
            try
            {
                LogStringValue?.Invoke("شناسه جهت پیگیری وضعیت ارسال", id);

                using (var proxy = new sms_webservice())
                {
                    return(HandleRetrievalStatusMessage(proxy.sms_deliver(id)));
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("GetRetrievalStatus", ex);
            }
            return(RetrievalStatus.Unknown);
        }
Exemplo n.º 17
0
 public SendReturnObject OldSendSms(string txt, string receiver, DateTime dt)
 {
     try
     {
         LogStringValue?.Invoke("متن پیام", txt);
         LogStringValue?.Invoke("گیرنده", receiver);
         long resNum;
         var  resOfConvert = long.TryParse(receiver, out resNum);
         if (!resOfConvert)
         {
             throw new Exception("شماره موبايل مي بايست به شكل يك عدد باشد");
         }
         var binding = new BasicHttpBinding();
         using (var proxy = new SendReceiveSoapClient(binding, new EndpointAddress("http://n.sms.ir/ws/SendReceive.asmx")))
         {
             var message  = "";
             var smsLines = proxy.GetSMSLines(_username, _password, ref message);
             if (!string.IsNullOrEmpty(message.Trim()))
             {
                 throw new Exception(message);
             }
             var lst = new List <WebServiceSmsSend>
             {
                 new WebServiceSmsSend
                 {
                     IsFlash     = false,
                     MessageBody = txt,
                     MobileNo    = resNum
                 }
             };
             var retObject = proxy.SendMessage(_username, _password, lst.ToArray(), smsLines.First(x => x.LineNumber == Convert.ToInt64(_sender)).ID, DateTime.Now, ref message);
             if (!string.IsNullOrEmpty(message.Trim()))
             {
                 throw new Exception(message);
             }
             var status = SentStatus.Successful;
             var id     = Convert.ToInt32(retObject[0].ToString());
             return(new SendReturnObject("", status, id));
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("SendSms", ex);
     }
     return(new SendReturnObject(string.Empty, SentStatus.Failed, -1));
 }
Exemplo n.º 18
0
        public SendReturnObject SendFlashSms(string txt, string receiver)
        {
            try
            {
                LogStringValue?.Invoke("متن پیام", txt);
                LogStringValue?.Invoke("گیرنده", receiver);
                long resNum;
                var  resOfConvert = long.TryParse(receiver, out resNum);
                if (!resOfConvert)
                {
                    throw new Exception("شماره موبايل مي بايست به شكل يك عدد باشد");
                }
                var token = new Token().GetToken(_password, _username);

                var messageSendObject = new MessageSendObject()
                {
                    Messages = new List <string> {
                        txt
                    }.ToArray(),
                    MobileNumbers = new List <string> {
                        receiver
                    }.ToArray(),
                    LineNumber               = _sender,
                    SendDateTime             = null,
                    CanContinueInCaseOfError = true
                };

                MessageSendResponseObject messageSendResponseObject = new MessageSend().Send(token, messageSendObject);

                if (messageSendResponseObject.IsSuccessful)
                {
                    var id = Convert.ToInt32(messageSendResponseObject.Ids[0]);
                    return(new SendReturnObject("", SentStatus.Successful, id));
                }
                else
                {
                    throw new Exception(messageSendResponseObject.Message);
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("SendSms", ex);
            }
            return(new SendReturnObject(string.Empty, SentStatus.Failed, -1));
        }
Exemplo n.º 19
0
 private int FindLineNumber(string strCallLog)
 {
     try
     {
         for (var i = 1; i <= LinesCount; i++)
         {
             if (strCallLog.IndexOf(GetLineKey(i), StringComparison.Ordinal) != -1)
             {
                 LogIntValue?.Invoke("LineNumber", i);
                 return(i);
             }
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("FindLineNumber", ex);
     }
     return(0);
 }
Exemplo n.º 20
0
        public SendReturnObject SendFlashSms(string txt, string receiver)
        {
            try
            {
                LogStringValue?.Invoke("متن پیام", txt);
                LogStringValue?.Invoke("گیرنده", receiver);
                //retval :
                // Invalid User Pass=0,
                // Successfull = 1,
                // No Credit = 2,
                // DailyLimit = 3,
                // SendLimit = 4,
                // Invalid Number = 5
                // System IS Disable = 6
                // Bad Words= 7
                // Pardis Minimum Receivers=8
                // Number Is Public=9

                //Status :
                // Sent=0,
                // Failed=1
                Send   sms    = new Send();
                long[] rec    = null;
                byte[] status = null;
                int    retval = sms.SendSms(_username, _password, receiver.Split(','), _sender, txt, true, "", ref rec, ref status);
                if (retval == 1)
                {
                    return(new SendReturnObject(string.Empty, SentStatus.Successful, -1));
                }
                if (status.Length > 0 && rec.Length > 0)
                {
                    return(new SendReturnObject($"{status[0]}|{rec[0]}", SentStatus.Failed, -1));
                }
                return(new SendReturnObject(string.Empty, SentStatus.Failed, -1));
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("SendSms", ex);
            }
            return(new SendReturnObject(string.Empty, SentStatus.Failed, -1));
        }
Exemplo n.º 21
0
        private string FindNumber(string strCallLog, string lineKey)
        {
            if (!strCallLog.Contains("CallerID"))
            {
                return(string.Empty);
            }
            var str = string.Empty;

            try
            {
                /*if (strCallLog.IndexOf(lineKey, StringComparison.OrdinalIgnoreCase) != -1 && strCallLog.IndexOf("Dial", StringComparison.OrdinalIgnoreCase) != -1)
                 * {
                 *  //D1:L1:Dial=9.
                 *  var index = strCallLog.IndexOf(lineKey, StringComparison.OrdinalIgnoreCase);
                 *  var num2 = strCallLog.IndexOf(".", index, StringComparison.OrdinalIgnoreCase);
                 *  var startIndex = index + lineKey.Length + 7;
                 *  if (num2 == startIndex) return string.Empty;
                 *  str = strCallLog.Substring(startIndex, num2 - startIndex);
                 *  str = FixPhoneNumber(str);
                 * }*/
                if (strCallLog.IndexOf(lineKey, StringComparison.OrdinalIgnoreCase) != -1 && strCallLog.IndexOf("CallerID", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    //D1:L1:CallerID=02166595961.
                    var index      = strCallLog.IndexOf(lineKey, StringComparison.OrdinalIgnoreCase);
                    var num2       = strCallLog.IndexOf(".", index, StringComparison.OrdinalIgnoreCase);
                    var startIndex = index + lineKey.Length + 11;
                    if (num2 == startIndex)
                    {
                        return(string.Empty);
                    }
                    str = strCallLog.Substring(startIndex, num2 - startIndex);
                    str = FixPhoneNumber(str);
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("FindNumber", ex);
            }
            return(str);
        }
Exemplo n.º 22
0
        public double GetCurrentCredit()
        {
            try
            {
                var token = new Token().GetToken(_password, _username);

                CreditResponse credit = new Credit().GetCredit(token);

                if (credit.IsSuccessful)
                {
                    return(credit.Credit);
                }
                else
                {
                    throw new Exception(credit.Message);
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("GetCurrentCredit", ex);
            }
            return(0);
        }
Exemplo n.º 23
0
        private int FindRingCounts(string strCallLog)
        {
            var result = 0;

            try
            {
                if (strCallLog.IndexOf("RingsCount", StringComparison.Ordinal) != -1)
                {
                    var index      = strCallLog.IndexOf("RingsCount", StringComparison.Ordinal);
                    var num3       = strCallLog.IndexOf(" ", index, StringComparison.Ordinal);
                    var startIndex = (index + "RingsCount".Length) + 1;
                    if (!int.TryParse(strCallLog.Substring(startIndex, num3 - startIndex), out result))
                    {
                        result = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                LogInternalException?.Invoke("FindRingCounts", ex);
            }
            return(result);
        }
Exemplo n.º 24
0
 public SendReturnObject SendFlashSms(string txt, string receiver)
 {
     try
     {
         LogStringValue?.Invoke("متن پیام", txt);
         LogStringValue?.Invoke("گیرنده", receiver);
         using (var proxy = new sms_webservice())
         {
             var retObject = proxy.send_sms(_username, _password, _sender, receiver, txt, "True", null, 0, null);
             var status    = HandleSendErrorMessage(retObject);
             int id        = 0;
             if (status == SentStatus.Successful)
             {
                 id = Convert.ToInt32(status);
             }
             return(new SendReturnObject(retObject, status, id));
         }
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("SendSms", ex);
     }
     return(new SendReturnObject(string.Empty, SentStatus.Failed, -1));
 }
Exemplo n.º 25
0
        private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                if (e.EventType == SerialData.Chars && this.Port.BytesToRead > 16)
                {
                    string str = this.Port.ReadExisting();
                    LogStringObject?.Invoke("DataReceived", str);
                    if (str.StartsWith("ST"))
                    {
                        var decGr = Convert.ToDecimal(str.Substring(4, 8));
                        WeightReceived?.Invoke(new WeightReceivedEventArgs(decGr / 1000));
                        LogStringObject?.Invoke("WeightReceivedEventArgs",
                                                (decGr / 1000).ToString(CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        if (!str.Contains("ST"))
                        {
                            return;
                        }
                        str = leftRotateShift(str, str.IndexOf("ST", StringComparison.Ordinal));
                        var decGr = Convert.ToDecimal(str.Substring(4, 8));
                        WeightReceived?.Invoke(new WeightReceivedEventArgs(decGr / 1000));
                        LogStringObject?.Invoke("WeightReceivedEventArgs",
                                                (decGr / 1000).ToString(CultureInfo.InvariantCulture));
                    }
                }

                //ST,+00000.00  g
            }
            catch (System.Exception ex)
            {
                LogInternalException?.Invoke("Port_DataReceived", ex);
            }
        }
 private int FindRingCounts(string strCallLog)
 {
     try
     {
         var num = 0;
         if (strCallLog.IndexOf("R", StringComparison.Ordinal) == -1)
         {
             return(num);
         }
         var num1 = strCallLog.IndexOf("R", StringComparison.Ordinal);
         var num2 = strCallLog.IndexOf("@", num1, StringComparison.Ordinal);
         var num3 = num1 + 1;
         if (!int.TryParse(strCallLog.Substring(num3, num2 - num3), out num))
         {
             num = 0;
         }
         return(num);
     }
     catch (Exception ex)
     {
         LogInternalException?.Invoke("FindRingCounts", ex);
     }
     return(0);
 }
Exemplo n.º 27
0
 public bool IsNumberBlackList(string number)
 {
     LogInternalException?.Invoke("IsNumberBlackList", new NotSupportedException("دریافت وضعيت بلك ليست شماره پشتیبانی نمی شود"));
     return(false);
 }
Exemplo n.º 28
0
 public RetrievalStatus[] GetRetrievalStatuses(string[] id)
 {
     LogInternalException?.Invoke("GetRetrievalStatuses", new NotSupportedException("دریافت گروهی وضعیت پشتیبانی نمی شود"));
     return(null);
 }
Exemplo n.º 29
0
 public RetrievalStatus GetRetrievalStatus(string id)
 {
     LogInternalException?.Invoke("GetRetrievalStatus", new NotSupportedException("شناسايي وضعيت پيامك پشتیبانی نمی شود"));
     return(RetrievalStatus.Unknown);
 }
Exemplo n.º 30
0
 public int GetUnreadCount()
 {
     LogInternalException?.Invoke("GetUnreadCount", new NotSupportedException("استفاده از باکس دریافتی پشتیبانی نمی شود"));
     return(0);
 }