Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            bool   success = false;
            string reason  = String.Empty;

            if (!AppLogic.AppConfigBool("AvalaraTax.Enabled"))
            {
                ResultLabel.Text = "AvaTax is not enabled. Enable AvaTax by setting the AvalaraTax.Enabled AppConfig to True.";
            }
            else
            {
                AvaTax avaTax = new AvaTax();
                success = avaTax.TestAddin(out reason);

                if (success)
                {
                    ResultLabel.Text = "Successfully connected to AvaTax.";
                }
                else if (String.IsNullOrEmpty(reason))
                {
                    ResultLabel.Text = "AvaTax connection was not successful. Please review your configuration.";
                }
                else
                {
                    ResultLabel.Text = String.Format("AvaTax connection was not successful. AvaTax returned the following message: {0}", reason);
                }
            }
        }
        catch (Exception exception)
        {
            ResultLabel.Text = "Connection test failed due to an exception:<br />" + exception.ToString().Replace("\n", "<br />");
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        btnCloseTop.DataBind();

        if (!Page.IsPostBack)
        {
            try
            {
                var success = false;
                var reason  = string.Empty;

                if (!AppLogic.AppConfigBool("AvalaraTax.Enabled"))
                {
                    ctlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.avalara.NotEnabled"), AlertMessage.AlertType.Warning);
                }
                else
                {
                    var avaTax = new AvaTax();
                    success = avaTax.TestAddin(out reason);

                    if (success)
                    {
                        ctlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.avalara.TestSuccess"), AlertMessage.AlertType.Success);
                    }
                    else if (string.IsNullOrEmpty(reason))
                    {
                        ctlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.avalara.TestFailureGeneric"), AlertMessage.AlertType.Error);
                    }
                    else
                    {
                        ctlAlertMessage.PushAlertMessage(string.Format(AppLogic.GetString("admin.avalara.TestFailureError"), reason), AlertMessage.AlertType.Error);
                    }
                }
            }
            catch (Exception exception)
            {
                ctlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.avalara.TestFailureException") + exception.ToString().Replace("\n", "<br />"), AlertMessage.AlertType.Error);
            }
        }
    }