I would like to create a JSON object with the following structure:
var exec_log = {
total_correct: 0,
total_error: 0,
[exec_detail: {
timestamp: "1a",
script: "New Deal",
type: "Bot",
id: "2a",
pair: "3a",
status: "4a",
message: "5a"
},
exec_detail: {
timestamp: "1a",
script: "New Deal",
type: "Bot",
id: "2a",
pair: "3a",
status: "4a",
message: "5a"
},
...]
}
However I don't know how to create an array of objects inside an object or how to access them to populate them correctly.
Current code:
So far I have achieved this but I'm sure the array is not defined correctly and I suspect that I have to create an external array and push it inside the exec_log object.. Should I define 2 separated objects and push one inside the other?
function StartNewDeal(filterAPC){
var exec_log = {
total_correct: 0,
total_error: 0,
exec_detail: {
timestamp: "",
script: "New Deal",
type: "Bot",
id: "",
pair: "",
status: "",
message: ""
}
}
for(var i = 0; i < filterAPC.length; i++){
Logger.log("Passing botID: " + filterAPC[i][1])
var new_deal = StartDeal(filterAPC[i][1]);
var currentDate = Utilities.formatDate(new Date(), "PST", "yyyy-MM-dd HH:mm");
exec_log.exec_detail[timestamp[i]] = currentDate;
exec.log.exec_detail[id[i]] = filterAPC[i][1];
exec_log.exec_detail[pair[i]] = new_deal.pair;
if(new_deal.valid == false){
exec_log.exec_detail[status[i]] = "Error";
exec_log.exec_detail[message[i]] = new_deal.json;
exec.log.total_error = exec.log.total_error + 1;
}else{
exec_log.exec_detail[status[i]] = "Completed";
exec_log.exec_detail[message[i]] = "Completed";
exec.log.total_correct = exec.log.total_correct + 1;
}
}
return exec_log;
}
function createObject() {
let obj={property1:'value1',property2:'value2',property3:[],property4:[],property5:'value5',property6:'value6'};
for(let i=0;i<2;i++) {
let iObj={};
for(let j=0;j<5;j++) {
iObj['item'+j]='donkey'+j;
}
obj.property3.push(iObj);
obj.property4.push(iObj);
}
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput('<textarea>' + JSON.stringify(obj) + '</textarea>'), "Making an object with no parts");
}
Try this:
function StartNewDeal(filterAPC){
var exec_log = {
total_correct: 0,
total_error: 0,
exec_details_list: [] // an array to store your exect_details objects
}
for(var i = 0; i < filterAPC.length; i++) {
Logger.log("Passing botID: " + filterAPC[i][1])
var new_deal = StartDeal(filterAPC[i][1]);
var timestamp = Utilities.formatDate(new Date(), "PST", "yyyy-MM-dd HH:mm");
var id = filterAPC[i][1];
var pair = new_deal.pair;
var status;
var message;
var script; // doesn't seem like you're using this
if (new_deal.valid == false){
status = "Error";
message = new_deal.json;
exec.log.total_error = exec.log.total_error + 1;
} else{
status = "Completed";
message = "Completed";
exec.log.total_correct = exec.log.total_correct + 1;
}
exec_log.exec_details_list.push(new ExecDetailObject(timestamp, script, type, id, pair, status, message));
}
return exec_log;
}
// A function to create new exec_detail objects
// from your code you don't seem to be using the script property. Not sure if that's intentional
function ExecDetailObject(timestamp, script, type, id, pair, status, message) {
this.timestampt = timestamp;
this.script = script;
this.type = type;
this.id = id;
this.pair = pair;
this.status = status;
this.message = message;
}
Related
I want to be able to select a list of options from a dropdown box with "Station" values taken from json array -"smallData.json" (which I am able to do and it is working) and then produce a set of results from the same json array based on the specific "station" option chosen from the dropdown list (which is not working currently). I assume I may need a function to be called and loop through the array with the onchange method, however, I am not certain how that would work.
[
{
"ID": 1,
"Station": "Carmichael Rd.",
"Address": "54 Myers Rd.",
"Monthly_CStore_Sales": "120,000",
"Operator": "Michael Sears",
"Top_SKU": "Hotdogs"
},
{
"ID": 2,
"Station": "Baillou Hill",
"Address": "564 Jackson Ave.",
"Monthly_CStore_Sales": "89000",
"Operator": "Sarah Pikes",
"Top_SKU": "Patties"
},
{
"ID": 3,
"Station": "Oakesfield",
"Address": "42 Peterson St.",
"Monthly_CStore_Sales": "150000",
"Operator": "Yolanda Gray",
"Top_SKU": "Chicken"
}
]
Code
<select id="dmenu"></select>
<div id="optionT"></div>
<script>
let dropdown = document.getElementById('dmenu');
dropdown.length = 0;
let defaultOption = document.createElement('option');
defaultOption.text = 'Choose Station';
dropdown.add(defaultOption);
dropdown.selectedIndex = 0;
const url = './smallData.json';
const request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status === 200) {
const data = JSON.parse(request.responseText);
let option;
for (let i = 0; i < data.length; i++) {
option = document.createElement('option');
option.text = data[i].Station;
dropdown.add(option);
var optionText = "";
for (x in data){
optionText += '<ul>' +
'<li>Station: '+ data.Station[x] +'</li>' +
document.getElementById('optionT').innerHTML = optionText;
}
} else {
// Reached the server, but it returned an error
}
}
request.onerror = function() {
console.error('An error occurred fetching the JSON from ' + url);
};
request.send();
</script>
Example:
If I select for example: "Station Carmichael Road", all the key value pairs associated with that Station field I want to come up:
"ID:1",
"Address": "54 Myers Rd.",
"Monthly_CStore_Sales": "120,000",
"Operator": "Michael Sears",
"Top_SKU": "Hotdogs"
You want to show Station's data when a drop-down option is selected.
Add onchange event on your drop-down element.
<select id="dmenu" onchange="handleOnChange(this)"></select>
Then move your list-rendering logic to handleOnChange()
function handleOnChange(selectedDropdown) {
// Find array element by "Station" value
var station = data.find(function(element) {
return element.Station == selectedDropdown.value;
});
// If station exists
if (station) {
// Show station's key-value in list
let optionText = '<ul>';
Object.keys(station).forEach(function(key) {
optionText += '<li>' + key +': ' + station[key] + '</li>';
document.getElementById('optionT').innerHTML = optionText;
});
optionText += '</ul>';
}
}
Full Code
<script>
function handleOnChange(selectedDropdown) {
// Find array element by "Station" value
var station = data.find(function(element) {
return element.Station == selectedDropdown.value;
});
// If station exists
if (station) {
// Show station's key-value in list
let optionText = '<ul>';
Object.keys(station).forEach(function(key) {
optionText += '<li>' + key +': ' + station[key] + '</li>';
document.getElementById('optionT').innerHTML = optionText;
});
optionText += '</ul>';
}
}
let dropdown = document.getElementById('dmenu');
dropdown.length = 0;
let defaultOption = document.createElement('option');
defaultOption.text = 'Choose Station';
dropdown.add(defaultOption);
dropdown.selectedIndex = 0;
const url = './smallData.json';
let data;
const request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function() {
if (request.status === 200) {
data = JSON.parse(request.responseText);
let option;
for (let i = 0; i < data.length; i++) {
option = document.createElement('option');
option.text = data[i].Station;
dropdown.add(option);
}
}
else {
// Reached the server, but it returned an error
}
}
request.onerror = function() {
console.error('An error occurred fetching the JSON from ' + url);
};
request.send();
</script>
trying to convetr json array to multiple json objects in nodejs looking for help here is my code have tried loops to achieve that but failed just want to send the data as multiple objects not array
router.get('/frontpage-mobile', function (req, res, next) {
qryFilter = { "Product_Group": 'SIMPLE' };
// if we have a cart, pass it - otherwise, pass an empty object
var successMsg = req.flash('success')[0];
var errorMsg = req.flash('error')[0];
Product.find(qryFilter, function (err, product) {
// console.log("Product: " + JSON.stringify(product));
var pro=JSON.stringify(product)
if (err || product === 'undefined' || product == null) {
// replace with err handling
var errorMsg = req.flash('error', 'unable to find product');
res.send(errorMsg);
}
if (!product) {
req.flash('error', 'Product is not found.');
res.send('error', 'Product is not found.');
}
for(i=0;i<pro.length;i++)
res.send(pro[i]);
});
});
// Dummy Mongodb Result Array
var db_result = [{_id:1,name:"Cake_1"},{_id:2,name:"Cake_2"},{_id:3,name:"Cake_3"}]
// define data variable
var data = { total : 0, dataObj : {} } // default total = 0, = {}
var dataObj = {}
// convert array to obj
// { key1 : obj1, key2 : obj2, key3 : obj3, ... }
for(var i=0; i < db_result.length;i++){
let key = "key"+i;
dataObj[key] = db_result[i];
}
// assign data to variable
data.total = db_result.length;
data.dataObj = dataObj
// rend back to client
res.send(data);
// Result
{
"total":3,
"dataObj":{
"key0":{"_id":1,"name":"Cake_1"},
"key1":{"_id":2,"name":"Cake_2"},
"key2":{"_id":3,"name":"Cake_3"}
}
}
For some reason, the else clause in my conditional rewrites the value in the array even when it finds a match. Any idea why this is happening? Code below:
controller.js
$scope.allAds = DummyAdService.dummyAds;
$scope.allStatements = DummyStatementsService.dummyStatements;
for(var i=0; i < $scope.allStatements.length; i++) {
var statement = $scope.allStatements[i];
for(var j=0; j < $scope.allAds.length; j++) {
var ad = $scope.allAds[j];
if(statement.statement.toLowerCase().indexOf(ad.tag) > -1) {
statement.ad = ad.url;
} else {
var randomAd = $scope.allAds[Math.floor(Math.random() * $scope.allAds.length)];
statement.ad = randomAd.url;
}
}
};
services.js
function DummyStatement(id, accountId, reportId, timestamp, rating, statement, url) {
this.id = id;
this.accountId = accountId;
this.reportId = reportId;
this.timestamp = timestamp;
this.rating = rating;
this.statement = statement;
this.url = url;
}
function DummyStatementsService(DummyAccountService) {
this.dummyStatements = [
new DummyStatement(1, 1, 1, 1449635098000, 'pos',
'Time to visit my second home. Gym haha'),
new DummyStatement(2, 1, 1, 1449615098000, 'pos',
'Feeling so much better after 10 hours sleep'),
new DummyStatement(3, 1, 1, 1440615028000, 'pos',
'Excited about going to Thorpe Park tomorrow'),
new DummyStatement(16, 2, 1, 1449635098000, 'neg',
'What a terrible week it\'s been so far. Weekend can\'t come soon enough'),
new DummyStatement(17, 2, 1, 1449615098000, 'neg',
'Rain rain rain go away. We all want some sunshine'),
new DummyStatement(18, 2, 1, 1440615028000, 'neg',
]
}
function DummyAd(id, tag, url) {
this.id = id;
this.tag = tag;
this.url = url;
}
function DummyAdService() {
this.dummyAds = [
new DummyAd(1, "gym", "ad-gym.jpg"),
new DummyAd(2, "sleep", "ad-sleep.jpg"),
new DummyAd(3, "thorpe park", "ad-themepark.jpg"),
]
}
Fixed it by adding statement = $scope.allStatements[i+1].
if(statement.statement.toLowerCase().indexOf(ad.tag) > -1) {
statement.ad = ad.url;
statement = $scope.allStatements[i+1];
} else if(statement.statement.toLowerCase().indexOf(ad.tag) === -1) {
var randomAd = $scope.allAds[Math.floor(Math.random() * $scope.allAds.length)];
statement.ad = randomAd.url;
}
What I'm trying to do:
Update the status to "TAKEN" when the chat is closed.
Issue:
Can't get $scope.currentChat.$set() or $scope.currentChat.$update() to work when trying to update the status. (See the $scope.close() function.)
What I've tried:
Various methods including $set, $update; I don't know. A lot of things. Been researching this for several hours, and can't find a solution that works.
NOTES:
$scope.currentChat.$set({status:"TAKEN"}); Doesn't work.
$scope.currentChat.$getRecord('status'); Works. Returns:
Object {$value: "OPEN", $id: "status", $priority: null}
So what exactly is going on here? Why can't I seem to set the status to TAKEN?
The issue is currently in the $scope.close() function, when trying to update the status:
// $SCOPE.CLOSE
// - Closes the current ticket.
$scope.close = function() {
// $scope.ticketObject.status = "TAKEN";
// $scope.currentChat.$set({status:"TAKEN"});
console.log("===========================");
console.log("STATUS:");
console.log($scope.currentChat.$getRecord('status'));
console.log($scope.currentChat['status']);
console.log("===========================");
$scope.ticketObject = {};
$scope.ticket = false;
$scope.toggle();
}
Here's my code:
bloop.controller('HomeCtrl', ['$scope', '$firebase', function($scope, $firebase) {
console.log("HomeController!");
var url = 'https://**********.firebaseio.com/tickets/';
var ref = new Firebase(url);
// $SCOPE.CREATETICKET
// - This function makes a connection to Firebase and creates the ticket.
$scope.createTicket = function() {
$scope.tickets = $firebase(ref).$asArray();
$scope.tickets.$add($scope.ticketObject).then(function(r) {
var id = r.name();
$scope.currentFBID = id;
$scope.syncTickets();
console.log("===========================");
console.log("CREATED TICKET: " + $scope.currentFBID);
console.log("URL: " + url + $scope.currentFBID);
console.log("===========================");
});
}
// $SCOPE.SYNCTICKETS
// - This function makes a connection to Firebase and syncs the ticket with the $scope to easily update the tickets.
$scope.syncTickets = function() {
var ticketRefURL = new Firebase(url + $scope.currentFBID);
$scope.currentChat = $firebase(ticketRefURL).$asArray();
$scope.currentChat.$save($scope.ticketObject);
var archiveRefURL = new Firebase(url + $scope.currentFBID + "/archive");
$scope.currentChat.archive = $firebase(archiveRefURL).$asArray();
console.log("===========================");
console.log("SAVED TICKET: " + $scope.currentFBID);
console.log("URL: " + ticketRefURL);
console.log("ARCHIVE URL: " + archiveRefURL);
console.log("===========================");
}
// $SCOPE.POST
// - This function pushes whatever is typed into the chat into the chat archive.
// - $scope.ticketObject.archive (is an array of objects)
$scope.post = function(name) {
// Push to ticketObject.archive array...
$scope.ticketObject.archive.push({
"name" : name,
"text" : $scope.chatText
});
// Logging the array to make sure it exists...
console.log("===========================");
console.log("CHAT ARCHIVE:");
console.log($scope.ticketObject.archive);
console.log("===========================");
$scope.currentChat.archive.$add({
"name" : name,
"text" : $scope.chatText
});
// This resets the text area so it's empty...
$scope.chatText = "";
} // WORKS
// $SCOPE.CLOSE
// - Closes the current ticket.
$scope.close = function() {
// $scope.ticketObject.status = "TAKEN";
// $scope.currentChat.$set({status:"TAKEN"});
console.log("===========================");
console.log("STATUS:");
console.log($scope.currentChat.$getRecord('status'));
console.log($scope.currentChat['status']);
console.log("===========================");
$scope.ticketObject = {};
$scope.ticket = false;
$scope.toggle();
}
// $SCOPE.TOGGLE
// - This function toggles the chat to be either open or closed.
$scope.toggle = function() {
if($scope.toggleState === false) {
$scope.toggleState = true;
$scope.checkTicket();
} else if($scope.toggleState === true) {
$scope.toggleState = false;
}
}
// $SCOPE.CHECKTICKET
// - This function checks to see if there's an existing ticket.
// - If there's not an existing ticket, it creates one.
$scope.checkTicket = function() {
if($scope.ticket === false) {
// Generate New Ticket Data
$scope.ticketObject = newTicket();
// Create the Ticket
$scope.createTicket();
// Ticket now exists.
$scope.ticket = true;
}
}
function newTicket() {
var ticketID = generateTicketID();
var newTicket = {
id: ticketID,
status: "OPEN",
name: "N/A",
email: "N/A",
date: generateDate(),
opID: "Unassigned",
opName: "Unassigned",
archive: [],
notes: []
}
return newTicket;
}
function generateTicketID() {
var chars = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
var result = '';
for(var i=12; i>0; --i) {
result += chars[Math.round(Math.random() * (chars.length - 1))];
}
return result;
}
function generateDate() {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
if(dd < 10) {
dd = '0' + dd;
}
if(mm < 10) {
dd = '0' + mm;
}
var date = mm + "/" + dd + "/" + yyyy;
return date;
}
}]);
$update and $set are part of the $firebase API. You are attempting to call them on the synchronized array returned by $asArray(), which is a $FirebaseArray instance. That has its own API, which includes neither update nor set.
var store = new FMP.AspNetJsonStore({
fields: [
{ name: 'AssetID' },
{ name: 'AssociationID' },
{ name: 'Image' },
{ name: 'StatusName' },
{ name: 'ModelName' },
{ name: 'IPAddress' },
{ name: 'InScope', type: 'boolean' },
{ name: 'ServicePlanName' },
{ name: 'PricePlanName' },
{ name: 'PricePlanDescription' },
{ name: 'Program' },
{ name: 'ServicePlanID' },
{ name: 'Customer' },
{ name: 'Black', type: 'float' },
{ name: 'Cyan', type: 'float' },
{ name: 'Magenta', type: 'float' },
{ name: 'Yellow', type: 'float' },
{ name: 'BlackPct' },
{ name: 'CyanPct' },
{ name: 'MagentaPct' },
{ name: 'YellowPct' },
{ name: 'PrinterMarkerSupplies' },
{ name: 'PageCount' },
{ name: 'BlackImpressions' },
{ name: 'ColorImpressions' },
{ name: 'PricePlanID' },
{ name: 'ResponsibilityForAction' },
{ name: 'PrinterSerialNumber' }
],
totalProperty: "TotalCount",
autoLoad: { params: { start: 0, limit: myPageSize} },
//autoLoad: true,
proxy: new Ext.data.HttpProxy({
// Call web service method using GET syntax
url: 'GetPrintersGrid.asmx/buildGrid',
// Ask for Json response
headers: { 'Content-type': 'application/json' },
method: "GET"
}),
remoteSort: true,
//sortInfo: { field: 'PageCount', direction: "DESC" },
groupField: 'Customer',
root: 'Records'
});
store.setDefaultSort('PageCount', 'DESC');
I am using a webservice to sort this.
I am getting an error
{"Message":"Invalid JSON primitive: DESC.","StackTrace":" at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromGetRequest(HttpContext context, JavaScriptSerializer serializer, WebServiceMethodData methodData)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}
Can anyone help me in this issue
I am using Ext.ux.AspWebServiceProxy class and used this proxy class in the store.Also defined the webservice in the user control in scriptmanager proxy
Iam getting an error saying GetPrintersGrid is undefined.Iam using the follwing example for reference.
http://osman.in/aspnet/using-extjs-grid-with-aspnet-ajax-wcf-webservices-c/
Can you please help me in this issue.
/// <reference path="ExtJS/ext-all.js" />
Ext.namespace('Ext.ux');
Ext.ux.AspWebServiceProxy = function(conn)
{
Ext.ux.AspWebServiceProxy.superclass.constructor.call(this);
Ext.apply(this, conn);
};
Ext.extend(Ext.ux.AspWebServiceProxy, Ext.data.DataProxy,
{
load : function (params, reader, callback, scope, arg)
{
var userContext = {
callback: callback,
reader: reader,
arg: arg,
scope: scope
};
var proxyWrapper = this;
//Handles the response we get back from the web service call
var webServiceCallback = function(response, context, methodName)
{
proxyWrapper.loadResponse(response, userContext, methodName);
}
var serviceParams = [];
//Convert the params into an array of values so that they can be used in the call (note assumes that the properties on the object are in the correct order)
for (var property in params)
{
serviceParams.push(params[property]);
}
//Add the webservice callback handlers
serviceParams.push(webServiceCallback);
serviceParams.push(this.handleErrorResponse);
//Make the actual ASP.Net web service call
this.webServiceProxyMethod.apply(this.webServiceProxy, serviceParams);
},
handleErrorResponse : function(response, userContext, methodName)
{
alert("Error while calling method: " + methodName + "\n" + response.get_message());
},
loadResponse : function (response, userContext, methodName)
{
var result = userContext.reader.readRecords(response);
userContext.callback.call(userContext.scope, result, userContext.arg, true);
}
});
var dataStore = new Ext.data.Store(
{
//Note that I have renamed the web service proxy class
proxy: new Ext.ux.AspWebServiceProxy(
{
webServiceProxy: GetPrintersGrid,
webServiceProxyMethod: GetPrintersGrid.buildGrid
}),
remoteSort: true
});
<asp:ScriptManagerProxy ID="PageScriptManager" runat="server">
<Services>
<asp:ServiceReference Path="~/GetPrintersGrid.asmx" />
</Services>
<Scripts>
<asp:ScriptReference Path="~/Ext.ux.AspWebServiceProxy.js" />
</Scripts>
</asp:ScriptManagerProxy>
This is the souce code i ussed
FMP.AspNetJsonReader = Ext.extend(Ext.data.JsonReader, {
read: function(response) {
// Assuming ASP.NET encoding - Data is stored as
var json = response.responseText;
var o = Ext.decode(json);
if (!o) {
throw { message: "AspNetJsonReader.read: Json object not found" };
}
if (!o.d) {
throw { message: "AspNetJsonReader.read: Root element d not found" };
}
return this.readRecords(o.d);
}
});
FMP.AspNetJsonStore = Ext.extend(Ext.data.GroupingStore, {
/**
* #cfg {Ext.data.DataReader} reader #hide
*/
constructor: function(config) {
FMP.AspNetJsonStore.superclass.constructor.call(this, Ext.apply(config, {
reader: new FMP.AspNetJsonReader(config)
}));
}
});
Iam using AS.NET for server side
Here is my webservice
public PagedResult buildGrid(int start, int limit, string sortfield, string dir)
{
var a=5;
Guid AccountID = (Guid)Session["AccountID"];
//string sortdir;
//if( dir == "DESC")
//{
// sortdir = dir.Substring(0, 4).Trim().ToUpper();
//}
//else
//{
// sortdir = dir.Substring(0, 3).Trim().ToUpper();
//}
string SortExpression = sortfield + " " + (!String.IsNullOrEmpty(dir) ? dir : String.Empty);
//string whereClause = "SELECT value a FROM XSP_AssetList_V AS a WHERE a.AccountID = GUID'" + AccountID + "' order by a.PageCount = '" + + "'";
string whereClause = "SELECT value a FROM XSP_AssetList_V AS a WHERE a.AccountID = GUID'" + AccountID + "' Order By a."+SortExpression;
//string whereClause = "SELECT value a , ROW_NUMBER() OVER(ORDER BY" + " " + SortExpression + ") As RowNumber FROM XSP_AssetList_V AS a WHERE a.AccountID = GUID'" + AccountID + "'";
//string whereClause = "SELECT value a FROM XSP_AssetList_V AS a WHERE a.AccountID = GUID'" + AccountID + "'";
List<FMPAsset> fmpAssets = new List<FMPAsset>();
using (XSPAssetModel.XSPAssetEntities assetEntities = new XSPAssetEntities(b.BuildEntityConnectionString1("XSMDSN")))
{
ObjectQuery<XSP_AssetList_V> assets = new ObjectQuery<XSP_AssetList_V>(whereClause, assetEntities);
//var assetOrder = assets.OrderBy(x => x.StatusName).ToList();
var assetPage = assets.Skip(start).Take(limit);
//var totalAssetCount = assets.Count();
currentAssets = assetPage.ToList();
int currentAssetsCount = currentAssets.Count;
string imgprefix = System.Configuration.ConfigurationManager.AppSettings["ImgPrefix"];
char[] separators = { '/' };
string appname = "";
int lastloc = imgprefix.Substring(0, imgprefix.Length - 1).LastIndexOfAny(separators);
if (lastloc > 6)
{
appname = imgprefix.Substring(lastloc + 1);
}
FMPAsset asset = new FMPAsset();
//StreamWriter sw = new StreamWriter("C:\\test.txt");
XSPPrinterMarkerSupplyModel.XSPPrinterMarkerSupplyEntities markerCtx = new XSPPrinterMarkerSupplyModel.XSPPrinterMarkerSupplyEntities(b.BuildEntityConnectionString1("XSMDSN"));
for (int x = 0; x < currentAssetsCount; x++)
{
asset = new FMPAsset();
asset.AssetID = currentAssets[x].AssetID.ToString();
asset.PricePlanID = currentAssets[x].PricePlanID.ToString();
asset.AssociationID = currentAssets[x].AssociationID;
asset.ModelName = currentAssets[x].ModelName;
asset.ResponsibilityForAction = currentAssets[x].ResponsibilityForAction;
asset.IPAddress = (String.IsNullOrEmpty(currentAssets[x].PrinterIPAddress)) ? "No IP" : currentAssets[x].PrinterIPAddress; ;
if (currentAssets[x].InScope)
{
asset.InScope = b.GetString("SDE_YES");
}
else
{
asset.InScope = b.GetString("SDE_NO");
}
asset = SetStatus(appname, asset, x);
asset.PricePlanName = currentAssets[x].Program;
asset.PricePlanDescription = currentAssets[x].PricePlanDescription;
asset.ServicePlanName = currentAssets[x].ServicePlanName;
if (currentAssets[x].PrinterSerialNumber != null)
{
asset.PrinterSerialNumber = currentAssets[x].PrinterSerialNumber;
}
else
{
asset.PrinterSerialNumber = "-";
}
//sw.WriteLine("ChargebackDescription: " + DateTime.Now.Millisecond);
if (this.b.UseChargebackDescription && !String.IsNullOrEmpty(currentAssets[x].CustomerChargebackDescription) && currentAssets[x].CustomerChargebackDescription != "Generated by OUT Integration")
{
asset.Customer = currentAssets[x].CustomerChargebackDescription;
if (asset.Customer.IndexOf(Environment.NewLine) > -1)
{
asset.Customer = asset.Customer.Substring(0, asset.Customer.IndexOf(Environment.NewLine));
}
}
else
{
asset.Customer = currentAssets[x].CustomerChargeBackEntryName;
}
if (this.b.UsePricePlanDescription && !String.IsNullOrEmpty(currentAssets[x].PricePlanDescription))
{
asset.Program = currentAssets[x].PricePlanDescription;
if (asset.Program.IndexOf(Environment.NewLine) > -1)
{
asset.Program = asset.Program.Substring(0, asset.Program.IndexOf(Environment.NewLine));
}
}
else
{
asset.Program = currentAssets[x].Program;
}
asset.BlackPct = -3;
asset.CyanPct = -3;
asset.MagentaPct = -3;
asset.YellowPct = -3;
Guid id = currentAssets[x].AssetID;
asset = SetCMYKvalues(asset, x);
BuilldImpressionsValues(currentAssets[x], ref asset);
fmpAssets.Add(asset);
}
var totalAssetCount = assets.Count();
var y = new PagedResult<FMPAsset>();
y.Records = fmpAssets;
y.TotalCount = totalAssetCount;
return y;
// CommonGrid1.BindDataSource(SortByStatusName(fmpAssets));
}
}
This error is happening when your store is making the call to your web service. Whatever JSON is being sent is not valid for some reason (or .NET does not think it is), hence the server error when ASP.NET is trying to deserialize the data into a valid argument list for your method. I would first look in Firebug to see exactly what JSON is being passed to the server -- that might give you a clue as to what the issue is. If the JSON being sent is not valid then it's a client/Ext issue -- if it is valid, then it's a .NET issue.