Posted by Michael Horvath under Technology  Test Automation  .Net Web API  on Aug 21 2022


We have been working on .Net Web APIs that provide functionality that you may incorporate into your own application. As of this posting we have three APIs available: 1) GetFoodsAPI, 2) PasswordGeneratorAPI and 3) PeopleGeneratorAPI.

The get foods API will return records from the USDA Food Database used in our Food Allergy Checker. You may pass your criterion to the API to search the database for foods matching the criterion. We limit the result set to top {Count} parameter setting which allows values from 1 to 20.

The password generator can be used in a number of ways. Some examples are to generate access keys for your applications, to generate passwords to login to your various accounts, and more...

The people generator will generate random fictional people information that is useful for test automation where you need to test an application with fictitious people. This API is configurable to let you select the state you want the people to be located in. The addresses are made up randomly but do use actual city names and zip codes for more realistic data. The phone numbers are appropriate for the area code of the city the people are located in. The API could for example be consumed from a Selenium test automation using your code to call the API. We will work on examples of using this API to aid you in your development of these. Please check back later for future posts on the topic.

We hope you find these to be useful and look for future APIs to appear on the store site. Thanks for reading about our efforts and have a blessed day!

Tagged --no tags--
Posted by Michael Horvath under Technology  on Aug 09 2022

We make use of a script on our server that hosts our websites to encrypt our web.config and perform various other deployment tasks. For some time we have logged into the server to run this script after publishing our websites from Visual Studio. After doing this for a while we had the idea that Visual Studio should be able to execute our script once the website publish task is completed. We were using File System publish to deploy our website. Long story short, we failed to get the script to execute when our publish task completes. It turns out that this is not supported for File System publish.

After getting some rest from our attempts at implementing this, we decided to give it another try. This time we carefully read what we found from Google searches and found that web deploy of website does support execution of a script after publish completes. Here is what we learned: add the following to your .csproj file for the web application in Visual Studio just before the </Project> tag.

<Target Name="MyTarget" AfterTargets="MSDeployPublish">
     <Exec Command="cmd /c c:\Users\mjhorvath\deployall.bat" />
</Target>

The Exec Command may be any command you wish to use. In our case we execute a batch file script that makes a call to Power Shell to execute another script on our server that performs the tasks we need to complete deployment of the website.

We hope this saves you from duplicating our mistakes while developing this solution. Have a blessed day!

Visual Studio Screen Snapshot That Shows Start Of Script After Publish

Tagged --no tags--
Posted by Michael Horvath under Technology  on Aug 01 2022

Square Up has updated their SDK for payment processing and made a change that will obsolete the method we were using to take customer payments. We've updated our payment processing code to make use of the CheckoutApi CreatePaymentLinkAsync method. The Square Up SDK documentation for this does not include the client local variable definition so to help those who may want to use the same payment processing method we've included a code snippet from our Buy controller.

We hope this helps with your development efforts. Thanks for reading our post!

            
                if (tempProduct.SalePrice.HasValue)
                {
                    var client = new Square.SquareClient.Builder()
                        .Environment(Square.Environment.Production)
                        .AccessToken(ConfigurationManager.AppSettings["squareUpAPIKey"])
                        .Build();

                    var priceMoney = new Square.Models.Money.Builder()
                        .Amount((long?)(tempProduct.SalePrice * 100.0M))
                        .Currency("USD")
                        .Build();

                    var quickPay = new QuickPay.Builder(
                        name: tempProduct.FileName + " Activation Key",
                        priceMoney: priceMoney,
                        locationId: ConfigurationManager.AppSettings["HSS_squareUpLocationID"])
                      .Build();

                    var prePopulatedData = new PrePopulatedData.Builder()
                      .BuyerEmail(currentEmail)
                      .BuyerPhoneNumber("+1" + tblPRESSCustomer.PhoneNumber)
                      .Build();

                    var checkoutOptions = new CheckoutOptions.Builder()
                        .RedirectUrl(@"https://horvathsoftware.com/tblPRESSCustomerTransactionData/Success?activationKey=" + keyWeFound + @"&EmailAddress=" + currentEmail + @"&FileName=" + tempProduct.FileName + @"&customerID=" + customerID.ToString() + @"&transactionAmount=" + ((decimal)tempProduct.SalePrice).ToString())
                        .Build();

                    var body = new CreatePaymentLinkRequest.Builder()
                      .IdempotencyKey(NewIdempotencyKey())
                      .QuickPay(quickPay)
                      .PrePopulatedData(prePopulatedData)
                      .CheckoutOptions(checkoutOptions)
                      .Build();

                    try
                    {
                        var resultLink = await client.CheckoutApi.CreatePaymentLinkAsync(body: body);
                        int waitTime=3000;
                        HSS_DB_Settings.DBAppSettings.GetSettingInt32("waitToRedirectPayment", out waitTime);
                        System.Threading.Thread.Sleep(waitTime);
                        return Redirect(resultLink.PaymentLink.Url);
                    }
                    catch (ApiException e)
                    {
                        Console.WriteLine("Failed to make the request");
                        Console.WriteLine($"Response Code: {e.ResponseCode}");
                        Console.WriteLine($"Exception: {e.Message}");
                        goto returnView;
                    }
                }

Tagged --no tags--