예제 #1
0
        private void Send(string username, string password, int accountType)
        {
            System.Exception error = null;
            SendResponse sendResponseResult = null;

            try
            {
                if (_numbers.Length == 0)
                    throw new SmsException(SmsExceptionType.NoNumberSpecified);
                if (_message == null)
                    throw new SmsException(SmsExceptionType.NoMessageSpecified);
                if (!IsConnectedToInternet())
                    throw new SmsException(SmsExceptionType.NoInternetAccess);

                Cookie cookie = ProcessStepOneRequest(username, password, accountType);

                if (cookie != null)
                {
                    ProcessStepTwoRequest(cookie, _numbers);
                    sendResponseResult = ProcessStepThreeRequest(cookie, _message);
                }
                else
                    sendResponseResult = new SendResponse { SmsErrorType = SmsErrorType.AuthenticationFailed };
                        // TODO :  Mast maali :-"
            }
            catch (System.Exception exp)
            {
                error = new SmsException(SmsExceptionType.UnknownError, exp);
            }

            this.OnSendComplete(error, sendResponseResult);
        }
예제 #2
0
        private void GetSettings(string username, string password, int accountType)
        {
            System.Exception error = null;
            SmsSettings getSettingsResult = null;
            try
            {
                if (!IsConnectedToInternet()) throw new SmsException(SmsExceptionType.NoInternetAccess);

                HttpWebRequest request = SendPostRequest(RscSetting.SmsServiceAddress, null, 100, username, password, 0);
                HttpResponseContainer httpResponse = GetResponse(request);
                string jsonResponse = httpResponse.Body;
                getSettingsResult = JsonConvert.DeserializeObject<SmsSettings>(jsonResponse);
            }
            catch (SmsException exp)
            {
                error = exp;
            }
            catch (System.Exception exp)
            {
                error = new SmsException(SmsExceptionType.UnknownError, exp);
            }

            this.OnGetSettingsComplete(error, getSettingsResult);
        }