Method PostStructureData

Summary

Add Structure Data

Remarks

Process for creating a new permit application:

Input Parameters

NameTypeLengthDescription
type System.String 1 1=Add Generic Code data, 2=Add Structure Information, S=Save all stucture data. This is the CodeType value from GetRequiredStructureInfo
sessionNumber numeric 9 [Required] Session Number from GetNewPermitSession
description System.String 40 [Required] Description of structure
powerOnDate System.String 8 Date to turn power on. Format MMddyyyy
codeType System.String 4 This is the StructTypeCode value from GetRequiredStructureInfo
codeData System.String 15 Text value for the corresponding Structure Type. If the FieldType value from GetRequiredStructureInfo is C, then enter the text value here. Max 15 characters.
codeNumber numeric 9 Numeric value for the corresponding Structure Type. If the FieldType value from GetRequiredStructureInfo is N, then enter the numeric value here. Max 9 digits.

Example

POST http://localhost/FusionServices/v3/Naviline/Permit/Application/StructureData

Return Values

NameDescription
ErrorCode 0000 or blank is successful.
ErrorMessage Description of error, if any.

Sample Responses

Sample Code

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

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/Permit/Application/StructureData";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("type",System.Web.HttpUtility.UrlEncode("2"));
   postParms.Add("sessionNumber",System.Web.HttpUtility.UrlEncode("000002191"));
   postParms.Add("description",System.Web.HttpUtility.UrlEncode("Fusion warehouse"));
   postParms.Add("codeType",System.Web.HttpUtility.UrlEncode("NR"));
   postParms.Add("codeNumber",System.Web.HttpUtility.UrlEncode("100"));

   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 PostStructureData
   {
       // Add property for each input param in order to map a field to it
       [RegularExpression("^(?=.{0,1}$).*", ErrorMessage = "Must be 1 characters or less. ")]
       public string type{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("[0-9]{0,9}", ErrorMessage = "Numeric values only. Must be 9 digits or less. ")]
       public string sessionNumber{get; set;}

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

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

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

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

       [RegularExpression("[0-9]{0,9}", ErrorMessage = "Numeric values only. Must be 9 digits or less. ")]
       public string codeNumber{get; set;}

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

@{
   ViewBag.Title = "PostStructureData";
}

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

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

// 
// POST: /MyController/PostStructureData
[HttpPost]
public ActionResult PostStructureData(FormCollection collection)
{
   string url = "v3/Naviline/Permit/Application/StructureData";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("type", collection["type"]);
   inputParms.Add("sessionNumber", collection["sessionNumber"]);
   inputParms.Add("description", collection["description"]);
   inputParms.Add("powerOnDate", collection["powerOnDate"]);
   inputParms.Add("codeType", collection["codeType"]);
   inputParms.Add("codeData", collection["codeData"]);
   inputParms.Add("codeNumber", collection["codeNumber"]);

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