Exemplo n.º 1
0
        public string Login(string username, string password, string _ServiceName)
        {
            TaxService.Configuration.Security.UserName = username;
            TaxService.Configuration.Security.Password = password;
            TaxService.Configuration.Url = "https://development.avalara.net/Tax/TaxSvc.asmx?Ping";

            //SOAP in-bulit log settings
            TaxService.Configuration.TraceSoap       = true;
            TaxService.Configuration.LogTransactions = false;
            TaxService.Configuration.LogMessages     = false;
            TaxService.Configuration.LogSoap         = true;
            TaxService.Configuration.LogLevel        = Avalara.AvaTax.Adapter.LogLevel.DEBUG;
            TaxService.Configuration.LogFilePath     = "C:\\LogFile";
            //

            try
            {
                pingResult = TaxService.Ping(_ServiceName);
                if (pingResult.ResultCode == Avalara.AvaTax.Adapter.SeverityLevel.Success)
                {
                    StoreStatus = "success";
                }
                else
                {
                    StoreStatus = "error";
                }
            }
            catch (Exception)
            {
                StoreStatus = "error";
            }

            return(StoreStatus);
        } //Login()
Exemplo n.º 2
0
        public static void Test()
        {
            string accountNumber = ConfigurationManager.AppSettings["AvaTax:AccountNumber"];
            string licenseKey = ConfigurationManager.AppSettings["AvaTax:LicenseKey"];
            string serviceURL = ConfigurationManager.AppSettings["AvaTax:ServiceUrl"];

            TaxSvc taxSvc = new TaxSvc();

            // Header Level Parameters
            // Required Header Parameters
            taxSvc.Configuration.Security.Account = accountNumber;
            taxSvc.Configuration.Security.License = licenseKey;
            taxSvc.Configuration.Url = serviceURL;
            taxSvc.Configuration.ViaUrl = serviceURL;
            taxSvc.Profile.Client = "AvaTaxSample";

            // Optional Header Parameters
            taxSvc.Profile.Name = "Development";

            PingResult pingResult = taxSvc.Ping(string.Empty);

            Console.WriteLine("PingTest Result: " + pingResult.ResultCode.ToString());
            if (!pingResult.ResultCode.Equals(SeverityLevel.Success))
            {
                foreach (Message message in pingResult.Messages)
                {
                    Console.WriteLine(message.Summary);
                }
            }
        }
        private void buttonPing_Click(object sender, EventArgs e)
        {
            try
            {
                Util.PreMethodCall(this, lblStatus);

                TaxSvc taxSvc = new TaxSvc();
                SetConfig(taxSvc);

                PingResult result = taxSvc.Ping("");
                if (result.ResultCode >= SeverityLevel.Error)
                {
                    MessageBox.Show(result.Messages[0].Summary, "Ping Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Result Code: " + result.ResultCode + "\r\n" +
                                    "# Messages: " + result.Messages.Count.ToString() + "\r\n" +
                                    "Service Version: " + result.Version, "Ping Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Util.ShowError(ex);
            }
            finally
            {
                Util.PostMethodCall(this, lblStatus);
            }
        }
        private void buttonTestConnection_Click(object sender, System.EventArgs e)
        {
            //string settings = "";
            //if(_parent.Account != null||_parent.Key!= null||_parent.UserName!=null||_parent.Password!=null)
//				settings = textAccount.Text +","+ textKey.Text +","+textUserName.Text+","+textPassword.Text;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                ApplySettings();

                TaxSvc taxSvc = new TaxSvc();
                _parent.SetConfig(taxSvc);

                PingResult result = taxSvc.Ping("");
                if (result.ResultCode >= SeverityLevel.Error)
                {
                    MessageBox.Show(result.Messages[0].Summary, "Settings Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    IsAuthorizedResult isAuthorizedResult = taxSvc.IsAuthorized("GetTax, PostTax, CommitTax, CancelTax, AdjustTax, GetTaxHistory, ReconcileTaxHistory");

                    if (isAuthorizedResult.ResultCode >= SeverityLevel.Error)
                    {
                        //Util.ShowError(ex);
                        MessageBox.Show(isAuthorizedResult.Messages[0].Summary, "Settings Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        isConnectionSuccess = true;
                        MessageBox.Show("Result Code: " + isAuthorizedResult.ResultCode + "\r\n" +
                                        "# Messages: " + isAuthorizedResult.Messages.Count + "\r\n" +
                                        "Expires: " + isAuthorizedResult.Expires + "\r\n" +
                                        "Operations: " + isAuthorizedResult.Operations, "Settings Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                isConnectionSuccess = false;
                Util.ShowError(ex);
            }
            finally
            {
                RejectChanges(settings);
                if (isConnectionSuccess)
                {
                    buttonApply.Enabled = true;
                }
                else
                {
                    buttonApply.Enabled = false;
                }
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Stops the monitoring clock.
        /// </summary>
        public void Stop(TaxSvc svc, string transactionId)
        {
            _end = DateTime.Now;

            if (!_running)
            {
                throw new ApplicationException("An attempt was made to stop the performance timekeeper that was not running. Call the Start method prior to calling Stop method.");
            }
            try
            {
                //call Ping Method and send ClientMetric
                svc.Ping(Utilities.BuildAuditMetrics("", transactionId, _end.Subtract(_start).Milliseconds));
            }
            catch (Exception ex)
            {
                _avaLog.Error(string.Format("Error sending ClientMetrics: {0}", ex.Message));
            }
            _running = false;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Stops the monitoring clock.
        /// </summary>
        public void Stop(TaxSvc svc, ref Proxies.TaxSvcProxy.ProxyGetTaxResult result)
        {
            _end = DateTime.Now;

            if (!_running)
            {
                throw new ApplicationException("An attempt was made to stop the performance timekeeper that was not running. Call the Start method prior to calling Stop method.");
            }
            try
            {
                if (Utilities.HasClientMetricMessage(result.Messages))
                {
                    //call Ping Method and send ClientMetric
                    //Sample Entry - ClientMetrics:17849,ClientDuration,1500
                    svc.Ping(Utilities.BuildAuditMetrics("", result.TransactionId, _end.Subtract(_start).Milliseconds));
                }
            }
            catch (Exception ex)
            {
                _avaLog.Error(string.Format("Error sending ClientMetrics: {0}", ex.Message));
            }
            _running = false;
        }
Exemplo n.º 7
0
        public IHttpActionResult TestConnection()
        {
            if (!string.IsNullOrEmpty(_taxSettings.Username) && !string.IsNullOrEmpty(_taxSettings.Password) &&
                !string.IsNullOrEmpty(_taxSettings.ServiceUrl) &&
                !string.IsNullOrEmpty(_taxSettings.CompanyCode))
            {
                if (!_taxSettings.IsEnabled)
                {
                    return(BadRequest("Tax calculation disabled, enable before testing connection"));
                }

                var taxSvc = new TaxSvc(_taxSettings.Username, _taxSettings.Password, _taxSettings.ServiceUrl);
                var retVal = taxSvc.Ping();
                if (retVal.ResultCode.Equals(SeverityLevel.Success))
                {
                    return(Ok(new[] { retVal }));
                }

                return(BadRequest(string.Join(", ", retVal.Messages.Select(m => m.Summary))));
            }

            return(BadRequest("AvaTax credentials not provided"));
        }
Exemplo n.º 8
0
        public bool TestAddin(out string reason)
        {
            try
            {
                if (!Enabled)
                {
                    throw new InvalidOperationException("AvalaraInactiveException");
                }

                string expected = "Testing";

                TaxSvc taxService = CreateTaxService();
                var    result     = taxService.Ping(expected);

                if (result.ResultCode == SeverityLevel.Success)
                {
                    reason = null;
                    return(true);
                }

                reason = "<ul>";

                foreach (Message message in result.Messages)
                {
                    reason = String.Format("{0}<li>{1}: {2}</li>", reason, message.Name, message.Details);
                }

                reason += "</ul>";

                return(false);
            }
            catch (Exception exception)
            {
                reason = exception.Message;
                return(false);
            }
        }