Method PostMeterSync

Summary

Meter Sync - Coming soon ... targeted release 21.3

Remarks

Meter Information Sync. This API currently provides 3 Sync’s for 3 3rd party providers most commonly requested data. Badger Beacon FlexNet, Generic (can be used by any one) and Sensus Radio Reads. For the Generic and Sensus requests the API will return 9999 records and for Badger will return 4999 at a time.To request more info recall the program with the previous Last Record field. Last Record as *BLANK will create a new request and start at record 1.

Input Parameters

NameTypeLengthDescription
type System.String 1 [Required] B, for Badger Beacon FlexNet, G for Generic and S for Sensus Radio Reads.
lastRec System.String 9 Blank indicates a new request. Leading Zeros must be entered, Badger returns 4999 at a time, Generic and Sensus returns 9999. To continue processing enter the LastRec from the previous run as the new starting point.

Example

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

Return Values

NameDescription
LASTREC 000010000
ErrorCode 000
ErrorMessage More records recall program with LastRec

Sample Responses

Sample Code

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

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/Utilities/MeterSync";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("type",System.Web.HttpUtility.UrlEncode("G"));
   postParms.Add("lastRec",System.Web.HttpUtility.UrlEncode(""));

   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")
   {
        JArray jRows = (JArray)response["Rows"];
        foreach (JObject row in jRows)
        {
             string FILE = row["FILE"].ToString();
             // 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 PostMeterSync
   {
       // 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 type{get; set;}

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

       public PostMeterSync()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostMeterSync 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.PostMeterSync

@{
   ViewBag.Title = "PostMeterSync";
}

<h2>PostMeterSync</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostMeterSync</legend>
       <div class="editor-label">
           @Html.LabelFor(model => model.type)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.type)
           @Html.ValidationMessageFor(model => model.type)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.lastRec)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.lastRec)
           @Html.ValidationMessageFor(model => model.lastRec)
       </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/PostMeterSync
public ActionResult PostMeterSync()
{
   // Create a new instance of the model to pick up any default values.
   PostMeterSync model =  new PostMeterSync();

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

// 
// POST: /MyController/PostMeterSync
[HttpPost]
public ActionResult PostMeterSync(FormCollection collection)
{
   string url = "v3/Naviline/Utilities/MeterSync";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("type", collection["type"]);
   inputParms.Add("lastRec", collection["lastRec"]);

   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", "PostMeterSync");
       return View("Error", info);
   }
}