Site Tools


guides:ws_transaction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
guides:ws_transaction [2020/08/24 15:02] – created brett.zamoraguides:ws_transaction [2020/08/24 18:25] (current) brett.zamora
Line 16: Line 16:
 **Arguments:** **Arguments:**
  
-{{tablelayout?colwidth="100px,75px,475px"&rowsFixed=1&rowsVisible=10&float=center}}+{{tablelayout?colwidth="175px,75px,400px"&rowsFixed=1&rowsVisible=10&float=center}}
 ^ Variable ^ Usage ^ Description ^ ^ Variable ^ Usage ^ Description ^
 | {submitter_id} | Required | Submitter ID number. | | {submitter_id} | Required | Submitter ID number. |
Line 178: Line 178:
 } }
 </code> </code>
 +
 +
 +**Comment 1:**
 +
 +Following is a C# / .NET sample code snippet that shows how to call the transaction web service. This example shows the syntax for calling the web service with or without transaction history, processing the transaction details that are returned and processing the history records that are returned, if history was requested.
 +
 +This snippet was derived from the [[guides:web_service_toolbox_project|Web Service Toolbox]] that is available on the CeRTNA Wiki. The sample application is intended for easy to read demonstration purposes and not production quality code. The Web Service Toolbox application is documented, on the CeRTNA Wiki, to aid in understanding the code snippet shown below.
 +
 +
 +<code C#>
 +private void btnGetStatus_Click(object sender, RoutedEventArgs e)
 +{
 +    RestClient client = null;
 +    RestRequest request = null;
 +    IRestResponse response = null;
 +
 +    ResetTransactionPanels();
 +
 +    string strURL = "https://apex-prd.certna.org/APEX/Service/APEXPublicServer.svc/user/login";
 +
 +    // Password has to be hashed.
 +    // New convention uses a Salt value from the user record
 +    // See login web service for more detail.
 +
 +    string strSalt = GetSalt(tbUserName.Text);
 +    string strPassword = tbPassword.Password.ToString();
 +
 +    string strHashedPassword = HashPassword(strPassword, strSalt);
 +
 +    string strParms = "{\n\t\"user_name\" : \"";
 +    strParms += tbUserName.Text;
 +    strParms += "\",\n\t\"password\" : \"";
 +    strParms += strHashedPassword;
 +    strParms += "\"\n}";
 +
 +    client = new RestClient(strURL);
 +    request = new RestRequest(Method.POST);
 +
 +    request.AddHeader("Cache-Control", "no-cache");
 +    request.AddHeader("Content-Type", "application/json");
 +
 +    request.AddParameter("Login", strParms, ParameterType.RequestBody);
 +    response = client.Execute(request);
 +
 +    if (response.IsSuccessful)
 +    {
 +        var jsonResult1 = JsonConvert.DeserializeObject<dynamic>(response.Content);
 +        string token = jsonResult1.access_token;
 +
 +        if (chkTransactionHistory.IsChecked == true)
 +        {
 +            strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/transaction?submitter_id=" + tbSubmitterID.Text + "&primary_reference=" + tbPrimaryReference.Text + "&include_history=true";
 +        }
 +        else
 +        {
 +            strURL = "https://apex-prd.certna.org/APEX/Service/APEXPublicServer.svc/transaction?submitter_id=" + tbSubmitterID.Text + "&primary_reference=" + tbPrimaryReference.Text + "&include_history=false";
 +        }
 +
 +        client = new RestClient(strURL);
 +        request = new RestRequest(Method.GET);
 +
 +        request.AddHeader("Cache-Control", "no-cache");
 +        request.AddHeader("access_token", token);
 +        response = client.Execute(request);
 +
 +        if (response.IsSuccessful)
 +        {
 +            if (chkTransactionHistory.IsChecked == true)
 +            {
 +                panelTranDetails.Visibility = Visibility.Visible;
 +                panelTranHistory.Visibility = Visibility.Visible;
 +            }
 +            else
 +            {
 +                panelTranDetails.Visibility = Visibility.Visible;
 +                panelTranHistory.Visibility = Visibility.Hidden;
 +            }
 +
 +            var jsonResult2 = JsonConvert.DeserializeObject<dynamic>(response.Content);
 +
 +            tbTransactionID.Text = jsonResult2.result.TRANSACTION_ID;
 +            tbPrimaryRef.Text = jsonResult2.result.PRIMARY_REFERENCE;
 +            tbSecondaryRef.Text = jsonResult2.result.SECONDARY_REFERENCE;
 +            tbCountyName.Text = jsonResult2.result.COUNTY_NAME;
 +            tbSubID.Text = jsonResult2.result.SUBMITTER_ID;
 +            tbAgentID.Text = jsonResult2.result.AGENT_ID;
 +            tbCreatorUserName.Text = jsonResult2.result.CREATOR_USER_NAME;
 +            tbDateCreated.Text = jsonResult2.result.CREATED;
 +            tbLastModified.Text = jsonResult2.result.LAST_MODIFIED;
 +            tbStatusID.Text = jsonResult2.result.TRANSACTION_STATUS_ID;
 +            tbStatusName.Text = jsonResult2.result.TRANSACTION_STATUS;
 +
 +            if (chkTransactionHistory.IsChecked == true)
 +            {
 +                JObject joResponse = JObject.Parse(response.Content);
 +                JArray jaHistory = (JArray)joResponse["result"]["TRANSACTION_STATUS_HISTORY"];
 +
 +                // Load the grid
 +
 +                historyGrid.Children.Clear();
 +                historyGrid.RowDefinitions.Clear();
 +
 +                historyGrid.RowDefinitions.Add(new RowDefinition());
 +
 +                if (jaHistory.Count == 0)
 +                {
 +                    tbMessageLine.Text = "*** No Transaction History Available ***";
 +                }
 +                else
 +                {
 +                    TextBlock[] txtStatusCode = new TextBlock[jaHistory.Count + 1];
 +                    TextBlock[] txtStatusName = new TextBlock[jaHistory.Count + 1];
 +                    TextBlock[] txtTimeStamp = new TextBlock[jaHistory.Count + 1];
 +
 +                    // Header row
 +
 +                    txtStatusCode[0] = new TextBlock();
 +                    txtStatusCode[0].Padding = new Thickness(0, 5, 25, 5);
 +                    txtStatusCode[0].Text = "Code";
 +                    Grid.SetRow(txtStatusCode[0], 0);
 +                    Grid.SetColumn(txtStatusCode[0], 0);
 +                    historyGrid.Children.Add(txtStatusCode[0]);
 +                    txtStatusName[0] = new TextBlock();
 +                    txtStatusName[0].Padding = new Thickness(0, 5, 25, 5);
 +                    txtStatusName[0].Text = "Status";
 +                    Grid.SetRow(txtStatusName[0], 0);
 +                    Grid.SetColumn(txtStatusName[0], 1);
 +                    historyGrid.Children.Add(txtStatusName[0]);
 +                    txtTimeStamp[0] = new TextBlock();
 +                    txtTimeStamp[0].Padding = new Thickness(0, 5, 25, 5);
 +                    txtTimeStamp[0].Text = "Timestamp";
 +                    Grid.SetRow(txtTimeStamp[0], 0);
 +                    Grid.SetColumn(txtTimeStamp[0], 2);
 +                    historyGrid.Children.Add(txtTimeStamp[0]);
 +
 +                    for (int i = 1; i <= jaHistory.Count; i++)
 +                    {
 +                        historyGrid.RowDefinitions.Add(new RowDefinition());
 +
 +                        txtStatusCode[i] = new TextBlock();
 +                        txtStatusCode[i].Padding = new Thickness(0, 5, 25, 5);
 +                        txtStatusCode[i].Text = (String)jaHistory[i - 1]["TRANSACTION_STATUS_ID"];
 +                        Grid.SetRow(txtStatusCode[i], i);
 +                        Grid.SetColumn(txtStatusCode[i], 0);
 +                        historyGrid.Children.Add(txtStatusCode[i]);
 +                        txtStatusName[i] = new TextBlock();
 +                        txtStatusName[i].Padding = new Thickness(0, 5, 25, 5);
 +                        txtStatusName[i].Text = (String)jaHistory[i - 1]["TRANSACTION_STATUS"];
 +                        Grid.SetRow(txtStatusName[i], i);
 +                        Grid.SetColumn(txtStatusName[i], 1);
 +                        historyGrid.Children.Add(txtStatusName[i]);
 +                        txtTimeStamp[i] = new TextBlock();
 +                        txtTimeStamp[i].Padding = new Thickness(0, 5, 25, 5);
 +                        txtTimeStamp[i].Text = (String)jaHistory[i - 1]["TIMESTAMP"];
 +                        Grid.SetRow(txtTimeStamp[i], i);
 +                        Grid.SetColumn(txtTimeStamp[i], 2);
 +                        historyGrid.Children.Add(txtTimeStamp[i]);
 +                    }
 +                }
 +            }
 +        }
 +        else
 +        {
 +            var jsonResult2 = JsonConvert.DeserializeObject<dynamic>(response.Content);
 +            string strMessage = jsonResult2.Exception.Message;
 +            tbMessageLine.Text = strMessage;
 +        }
 +    }
 +    else
 +    {
 +        var jsonResult2 = JsonConvert.DeserializeObject<dynamic>(response.Content);
 +        tbMessageLine.Text = jsonResult2.ToString();
 +    }
 +    return;
 +
 +}
 +</code>
 +
 +
 +
 +
  
  
guides/ws_transaction.1598281376.txt.gz · Last modified: by brett.zamora