Method PostAssocDevMgmt

Summary

Associated Device Maintenance - Coming soon ... targeted release 21.3

Remarks

If associated device type is used to store Radio Read information in the ID field it can be maintained here.

Input Parameters

NameTypeLengthDescription
function System.String 1 [Required] ‘A’ = Add, ‘C’ = Change and ‘D’ = Delete
meterNumber System.String 12 [Required] Meter Number This is an alpha field that is left justified.
assocDevType System.String 2 [Required] Associated Device Type (Maintained in Generic Codes)
oldAssocDevID System.String 12 [Required] Old Associated Device ID Required for a Change or Delete
newAssocDevID System.String 12 [Required] New Associated Device ID Required for an Add or Change

Example

POST http://localhost/FusionServices/v3/Naviline/Utilities/AssocDevMgmt

Return Values

NameDescription
ErrorCode 0000:Success, 0090:Record not found, 0091:Record already exist
ErrorMessage * Function was performed as requested.

Sample Responses

Sample Code

using System.Net;
using Newtonsoft.Json.Linq;

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/Utilities/AssocDevMgmt";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("function",System.Web.HttpUtility.UrlEncode("D"));
   postParms.Add("meterNumber",System.Web.HttpUtility.UrlEncode("76682497"));
   postParms.Add("assocDevType",System.Web.HttpUtility.UrlEncode("RR"));
   postParms.Add("oldAssocDevID",System.Web.HttpUtility.UrlEncode("1105043885"));

   WebClient req = new WebClient();
   wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
   wc.Headers.Set("X-APPID", "YOURID");
   wc.Headers.Set("X-APPKEY", "YOURKEY");

   byte[] responseBytes = wc.UploadValues(new Uri(uri), "POST", postParms);
   string stringResult = Encoding.UTF8.GetString(responseBytes); 
   JObject response = JObject.Parse(stringResult);
   string error = response["OutputParms"]["ErrorCode"].ToString();
   if (error == "0000")
   {
         // TODO - YOUR CODE HERE
   }
}

C# Razor MVC Sample Code

using System;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Collections.Specialized;
using FusionServiceHelper.Models;

// NOTE: Use the namespace generated when you add the class, so that it is correct.
namespace FusionRazor.Models
{
   public class PostAssocDevMgmt
   {
       // Add property for each input param in order to map a field to it
       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,1}$).*", ErrorMessage = "Must be 1 characters or less. ")]
       public string function{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,12}$).*", ErrorMessage = "Must be 12 characters or less. ")]
       public string meterNumber{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,2}$).*", ErrorMessage = "Must be 2 characters or less. ")]
       public string assocDevType{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,12}$).*", ErrorMessage = "Must be 12 characters or less. ")]
       public string oldAssocDevID{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,12}$).*", ErrorMessage = "Must be 12 characters or less. ")]
       public string newAssocDevID{get; set;}

       public PostAssocDevMgmt()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostAssocDevMgmt class. *@
@* NOTE: Select Edit as the Scaffold template. *@
@* NOTE: Use the @model line that is generated at the top.  Replace the rest with the lines below.
@model FusionRazor.Models.PostAssocDevMgmt

@{
   ViewBag.Title = "PostAssocDevMgmt";
}

<h2>PostAssocDevMgmt</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostAssocDevMgmt</legend>
       <div class="editor-label">
           @Html.LabelFor(model => model.function)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.function)
           @Html.ValidationMessageFor(model => model.function)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.meterNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.meterNumber)
           @Html.ValidationMessageFor(model => model.meterNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.assocDevType)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.assocDevType)
           @Html.ValidationMessageFor(model => model.assocDevType)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.oldAssocDevID)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.oldAssocDevID)
           @Html.ValidationMessageFor(model => model.oldAssocDevID)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.newAssocDevID)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.newAssocDevID)
           @Html.ValidationMessageFor(model => model.newAssocDevID)
       </div>
       <p>
       <input type="submit" value="Submit"/>
       </p>
   </fieldset>

}

@section Scripts {
   @Scripts.Render("~/bundles/jqueryval")
}
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FusionServiceHelper.Models;

// NOTE: Replace 'MyController' with the name of your controller.

// 
// GET: /MyController/PostAssocDevMgmt
public ActionResult PostAssocDevMgmt()
{
   // Create a new instance of the model to pick up any default values.
   PostAssocDevMgmt model =  new PostAssocDevMgmt();

   // pass model to set to default values
   // NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
   return View("~/Views/MyFolderPath/PostAssocDevMgmt.cshtml", model);
}

// 
// POST: /MyController/PostAssocDevMgmt
[HttpPost]
public ActionResult PostAssocDevMgmt(FormCollection collection)
{
   string url = "v3/Naviline/Utilities/AssocDevMgmt";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("function", collection["function"]);
   inputParms.Add("meterNumber", collection["meterNumber"]);
   inputParms.Add("assocDevType", collection["assocDevType"]);
   inputParms.Add("oldAssocDevID", collection["oldAssocDevID"]);
   inputParms.Add("newAssocDevID", collection["newAssocDevID"]);

   try
   {
       // Send the request
       FusionServiceRequest request = new FusionServiceRequest();
       FusionServiceResult result = request.Post(url, inputParms);

       return View("Result", result);
   }
   catch(Exception e)
   {
       HandleErrorInfo info = new HandleErrorInfo(e, "MyController", "PostAssocDevMgmt");
       return View("Error", info);
   }
}