Site Tools


guides:sample_updatemoucoirequest_snippet

Differences

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

Link to this comparison view

guides:sample_updatemoucoirequest_snippet [2024/01/12 20:24] – created brett.zamoraguides:sample_updatemoucoirequest_snippet [2024/01/12 20:31] (current) brett.zamora
Line 1: Line 1:
 <code C#> <code C#>
-        private void updateMOUCOIRequest() +private void updateMOUCOIRequest() 
-        +
-            string strUpdateRequestID = "0";+    string strUpdateRequestID = "0";
  
-            RestClient client = null; +    RestClient client = null; 
-            RestRequest request = null; +    RestRequest request = null; 
-            IRestResponse response = null;+    IRestResponse response = null;
  
-            string strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/user/login";+    string strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/user/login";
  
-            // Password has to be hashed. +    // Password has to be hashed. 
-            // New convention uses a Salt value from the user record+    // New convention uses a Salt value from the user record
  
-            string strSalt = GetSalt(tbUserName.Text); +    string strSalt = GetSalt(tbUserName.Text); 
-            string strPassword = tbPassword.Password.ToString();+    string strPassword = tbPassword.Password.ToString();
  
-            string strHashedPassword = HashPassword(strPassword, strSalt);+    string strHashedPassword = HashPassword(strPassword, strSalt);
  
-            string strParms = "{\n\t\"user_name\" : \""; +    string strParms = "{\n\t\"user_name\" : \""; 
-            strParms += tbUserName.Text; +    strParms += tbUserName.Text; 
-            strParms += "\",\n\t\"password\" : \""; +    strParms += "\",\n\t\"password\" : \""; 
-            strParms += strHashedPassword; +    strParms += strHashedPassword; 
-            strParms += "\"\n}";+    strParms += "\"\n}";
  
-            client = new RestClient(strURL); +    client = new RestClient(strURL); 
-            request = new RestRequest(Method.POST);+    request = new RestRequest(Method.POST);
  
-            request.AddHeader("Cache-Control", "no-cache"); +    request.AddHeader("Cache-Control", "no-cache"); 
-            request.AddHeader("Content-Type", "application/json");+    request.AddHeader("Content-Type", "application/json");
  
-            request.AddParameter("Login", strParms, ParameterType.RequestBody); +    request.AddParameter("Login", strParms, ParameterType.RequestBody); 
-            response = client.Execute(request);+    response = client.Execute(request);
  
-            if (response.IsSuccessful)  // Successfully logged in and a token has been provided +    if (response.IsSuccessful)  // Successfully logged in and a token has been provided 
-            +    
-                var jsonResult1 = JsonConvert.DeserializeObject<dynamic>(response.Content); +        var jsonResult1 = JsonConvert.DeserializeObject<dynamic>(response.Content); 
-                string token = jsonResult1.access_token;+        string token = jsonResult1.access_token;
  
-                strURL = null; +        strURL = null; 
-                client = null; +        client = null; 
-                request = null; +        request = null; 
-                response = null;+        response = null;
  
-                strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/updateMOUCOIRequest";+        strURL = "https://" + getHost() + "/APEX/Service/APEXPublicServer.svc/updateMOUCOIRequest";
  
-                if (tbRequestID.Text == "" || tbRequestID.Text == " " || tbRequestID.Text == "0"+        if (tbRequestID.Text == "" || tbRequestID.Text == " " || tbRequestID.Text == "0"
-                +        
-                    strURL = strURL + "?" + "RequestID=0"; +            strURL = strURL + "?" + "RequestID=0"; 
-                +        
-                else +        else 
-                +        
-                    strURL = strURL + "?" + "RequestID=" + tbRequestID.Text; +            strURL = strURL + "?" + "RequestID=" + tbRequestID.Text; 
-                }+        }
  
-                strURL = strURL + "&" + "COIExpirationDate=" + tbCOIExpires.Text; +        strURL = strURL + "&" + "COIExpirationDate=" + tbCOIExpires.Text; 
-                strURL = strURL + "&" + "SubmitterID=" + tbSubmitterID.Text; +        strURL = strURL + "&" + "SubmitterID=" + tbSubmitterID.Text; 
-                strURL = strURL + "&" + "Address1=" + tbAddress1.Text; +        strURL = strURL + "&" + "Address1=" + tbAddress1.Text; 
-                strURL = strURL + "&" + "Address2=" + tbAddress2.Text; +        strURL = strURL + "&" + "Address2=" + tbAddress2.Text; 
-                strURL = strURL + "&" + "City=" + tbCity.Text; +        strURL = strURL + "&" + "City=" + tbCity.Text; 
-                strURL = strURL + "&" + "StateName=" + tbState.Text;  // This property needs to be changed to StateName (2 character state abbreviation.) +        strURL = strURL + "&" + "StateName=" + tbState.Text;  // This property needs to be changed to StateName (2 character state abbreviation.) 
-                strURL = strURL + "&" + "PostalCode=" + tbZipCode.Text; +        strURL = strURL + "&" + "PostalCode=" + tbZipCode.Text; 
-                if ((bool)cbUpdateMOU.IsChecked) +         
-                +        if ((bool)cbUpdateMOU.IsChecked) 
-                    strURL = strURL + "&" + "UpdateMOU=true"; +        
-                +            strURL = strURL + "&" + "UpdateMOU=true"; 
-                else +        
-                +        else 
-                    strURL = strURL + "&" + "UpdateMOU=false"; +        
-                +            strURL = strURL + "&" + "UpdateMOU=false"; 
-                if ((bool)cbUpdateCOI.IsChecked) +        
-                +        if ((bool)cbUpdateCOI.IsChecked) 
-                    strURL = strURL + "&" + "UpdateCOI=true"; +        
-                +            strURL = strURL + "&" + "UpdateCOI=true"; 
-                else +        
-                +        else 
-                    strURL = strURL + "&" + "UpdateCOI=false"; +        
-                }+            strURL = strURL + "&" + "UpdateCOI=false"; 
 +        }
  
-                client = new RestClient(strURL); +        client = new RestClient(strURL); 
-                request = new RestRequest(Method.POST);+        request = new RestRequest(Method.POST); 
 +         
 +        request.AddHeader("Cache-Control", "no-cache"); 
 +        request.AddHeader("access_token", token); 
 +        request.AddHeader("content-type", "text/plain"); 
 +        response = client.Execute(request);
  
-                request.AddHeader("Cache-Control", "no-cache"); +        if (response.IsSuccessful
-                request.AddHeader("access_token", token); +        { 
-                request.AddHeader("content-type", "text/plain"); +            var jsonResult2 = JsonConvert.DeserializeObject<dynamic>(response.Content);
-                response = client.Execute(request);+
  
-                if (response.IsSuccessful+            strUpdateRequestID = jsonResult2.result; 
-                +            tbRequestID.Text = strUpdateRequestID; 
-                    var jsonResult2 = JsonConvert.DeserializeObject<dynamic>(response.Content);+             
 +            if ((bool)cbUpdateMOU.IsChecked
 +            
 +                // Increase the test count below to validate that runaway calls are being protected.
  
-                    strUpdateRequestID jsonResult2.result; +                int testCtr 0;
-                    tbRequestID.Text = strUpdateRequestID;+
  
-                    if ((bool)cbUpdateMOU.IsChecked+                for (testCtr = 0; testCtr < 1; testCtr++
-                    +                
-                        // Increase the test count below to validate that runaway calls are being protected.+                    // Note the following syntax 
 +                    sendPDFFile("MOURequest"); 
 +                } 
 +            }
  
-                        int testCtr = 0; +            if ((bool)cbUpdateCOI.IsChecked
- +            
-                        for (testCtr = 0; testCtr < 1; testCtr+++                // Increase the test count below to validate that runaway calls are being protected.
-                        +
-                            // Note the following syntax +
-                            sendPDFFile("MOURequest"); +
-                        } +
-                    }+
  
-                    if ((bool)cbUpdateCOI.IsChecked) +                int testCtr = 0;
-                    { +
-                        // Increase the test count below to validate that runaway calls are being protected.+
  
-                        int testCtr = 0; +                for (testCtr = 0; testCtr < 1; testCtr++) 
- +                
-                        for (testCtr = 0; testCtr < 1; testCtr++) +                    // Note the following syntax 
-                        +                    sendPDFFile("COIRequest");
-                            // Note the following syntax +
-                            sendPDFFile("COIRequest"); +
-                        } +
-                    }+
                 }                 }
             }             }
- 
-            return; 
         }         }
 +    }
 +
 +    return;
 +}
 </code> </code>
  
guides/sample_updatemoucoirequest_snippet.1705091056.txt.gz · Last modified: by brett.zamora