本文整理汇总了C#中Com.Aote.ObjectTools.GeneralObject.FromJson方法的典型用法代码示例。如果您正苦于以下问题:C# GeneralObject.FromJson方法的具体用法?C# GeneralObject.FromJson怎么用?C# GeneralObject.FromJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Com.Aote.ObjectTools.GeneralObject
的用法示例。
在下文中一共展示了GeneralObject.FromJson方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteCard_DownloadStringCompleted
//所有写卡结束后的统一处理过程
void WriteCard_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
IsBusy = false;
//通讯错误
if (e.Error != null)
{
Error = "通讯错误:" + e.Error.Message;
State = State.LoadError;
}
else
{
//更新数据
JsonObject item = JsonValue.Parse(e.Result) as JsonObject;
GeneralObject go = new GeneralObject();
go.FromJson(item);
string exception = (string)go.GetPropertyValue("Exception");
string err = (string)go.GetPropertyValue("Err");
//如果后台有异常
if (exception != null)
{
Error = "系统异常:" + exception;
State = State.LoadError;
}
//写卡错误
else if (err != null)
{
Error = "写卡错误:" + err;
State = State.LoadError;
}
else
{
Kmm = (string)go.GetPropertyValue("Kmm");
State = State.End;
}
}
OnCompleted(null);
}
示例2: work_Tick
/**
* 主工作方法定时得到通道信息
**/
void work_Tick(object sender, EventArgs e)
{
string address = this.TelServiceUrl + "/GetLineInfo?lineNum=" + this.LineNum + "&gonghao=" + this.GongHao;
Uri uri = new Uri(address);
WebClient client = new WebClient();
client.DownloadStringCompleted += (o, a) =>
{
if (a.Error == null)
{
//更新数据
JsonObject items = JsonValue.Parse(a.Result) as JsonObject;
items["PhoneState"] = items["State"];
items.Remove("State");
GeneralObject go = new GeneralObject();
go.FromJson(items);
if (go == null)
{
this.PhoneState = GetPropertyValue("14") + "";
return;
}
//设置电话信息
string stateIndex = go.GetPropertyValue("PhoneState") + "";
//如果状态是接听,并且电话号码和录音号与语音服务部相同,设置
this.PhoneState = GetPropertyValue(stateIndex) + "";
//如果电话号码相同,不通知
string oldNumber = this.CallNumber;
if (oldNumber == null)
{
oldNumber = "";
}
string newNumber = go.GetPropertyValue("CallerPhone") + "";
if (newNumber != null && !newNumber.Equals("") && !oldNumber.Equals(newNumber))
{
this.CallNumber = newNumber;
}
//如果记录号不相同,设置
string oldRecordFile = this.RecordFile;
if (oldRecordFile == null)
{
oldRecordFile = "";
}
string newRecordFile = go.GetPropertyValue("RecordFile") + "";
if (newRecordFile != null && !newRecordFile.Equals("") && !oldRecordFile.Equals(newRecordFile))
{
this.RecordFile = newRecordFile;
}
State = State.Loaded;
}
else
{
this.PhoneState = GetPropertyValue("14") + "";
State = State.LoadError;
Error = a.Error.Message;
}
};
//client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(uri, "");
}
示例3: ReadCard_DownloadStringCompleted
void ReadCard_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
IsBusy = false;
//通讯错误
if (e.Error != null)
{
Error = "通讯错误:" + e.Error.Message;
State = State.LoadError;
}
else
{
//更新数据
JsonObject item = JsonValue.Parse(e.Result) as JsonObject;
GeneralObject go = new GeneralObject();
go.FromJson(item);
string exception = (string)go.GetPropertyValue("Exception");
string err = (string)go.GetPropertyValue("Err");
//如果后台有异常
if (exception != null)
{
Error = "系统异常:" + exception;
State = State.LoadError;
}
//读卡错误
else if (err != null)
{
Error = "读卡错误:" + err;
State = State.LoadError;
}
else
{
//获取卡上内容
Factory = (string)go.GetPropertyValue("Factory");
CardId = (string)go.GetPropertyValue("CardID");
Gas = double.Parse(go.GetPropertyValue("Gas").ToString()) ;
Money = double.Parse(go.GetPropertyValue("Money").ToString());
BuyTimes = int.Parse(go.GetPropertyValue("Times").ToString());
Bkcs = int.Parse(go.GetPropertyValue("RenewTimes").ToString());
Dqdm = (string)go.GetPropertyValue("Dqdm");
State = State.Loaded;
}
}
//通知读卡完成
OnReadCompleted(null);
}
示例4: jsonToTable
/// <summary>
/// 把json转成报表对象
/// </summary>
/// <param name="json"></param>
private void jsonToTable(string json)
{
this.cells.Clear();
this.columns.Clear();
this.rows.Clear();
JsonObject item = JsonValue.Parse(json) as JsonObject;
GeneralObject go = new GeneralObject();
go.FromJson(item);
//列
ObjectList ol = go.GetPropertyValue("Column") as ObjectList;
foreach (GeneralObject one in ol)
{
Column c = new Column();
c.Width = Int32.Parse(one.GetPropertyValue("Width") + "");
this.columns.Add(c);
}
//行
ol = go.GetPropertyValue("Row") as ObjectList;
foreach (GeneralObject one in ol)
{
Row r = new Row();
r.Height = Int32.Parse(one.GetPropertyValue("Height")+"");
this.rows.Add(r);
}
//单元格
ol = go.GetPropertyValue("Cell") as ObjectList;
foreach (GeneralObject one in ol)
{
Cell c = new Cell();
c.Content = one.GetPropertyValue("Content") + "";
c.Column = Int32.Parse(one.GetPropertyValue("Column") + "");
c.ColumnSpan = Int32.Parse(one.GetPropertyValue("ColumnSpan") + "");
c.Row = Int32.Parse(one.GetPropertyValue("Row") + "");
c.RowSpan = Int32.Parse(one.GetPropertyValue("RowSpan") + "");
c.Location = one.GetPropertyValue("Location") + "";
this.cells.Add(c);
}
//绘制报表
Layout();
}
示例5: FromJson
public void FromJson(JsonArray array)
{
//整个复制过程完成后,再通知列表发生变化了
objects.CollectionChanged -= this.OnCollectionChanged;
List<GeneralObject> delObjs = new List<GeneralObject>(this.objects);
//新增或重新给对象赋值
foreach (JsonObject obj in array)
{
GeneralObject temp = new GeneralObject();
temp.FromJson(obj);
this.Add(temp);
}
//删除不在获取的数据中的对象
foreach (GeneralObject go in delObjs)
{
//空行数据不删除
if (go == EmptyRow)
{
continue;
}
this.objects.Remove(go);
}
//通知对象序号发生变化
foreach (GeneralObject go in objects)
{
go.OnPropertyChanged("Index");
}
//修改状态为新
//发送列表变化通知, 新增对象为列表本身
NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);
this.OnCollectionChanged(args);
//还原继续监听列表单个数据变化过程
objects.CollectionChanged += this.OnCollectionChanged;
IsOld = false;
}
示例6: FromJson
/// <summary>
/// 由Json串给对象赋值,将递归进行调用,碰到JsonArray自动把JsonArray转换成ObjectList。
/// 碰到JsonObject,自动转换成GeneralOject。
/// </summary>
/// <param name="item">从这个json对象给对象属性赋值</param>
public void FromJson(JsonObject item)
{
//通过获取类型,给_ctype赋值
this.NewGetType();
//如果有实体类型,则设置实体类型
if (item.ContainsKey("EntityType"))
{
EntityType = item["EntityType"];
item.Remove("EntityType");
}
foreach (string key in item.Keys)
{
object value = item[key];
Log.Debug("from json name=" + this.Name);
if (key.Equals("id"))
{
Log.Debug("from json id=" + value);
}
//如果是数组,对数组中的每一个对象调用转换过程
if (value is JsonArray)
{
//数组转换成对象列表
ObjectList ol = new ObjectList();
ol.FromJson(value as JsonArray);
SetCollectionProperty(key, ol);
}
else if (value is JsonObject)
{
//JsonObject转换成一般对象
GeneralObject go = new GeneralObject();
go.FromJson(value as JsonObject);
SetPropertyValue(key, go, true);
}
else if (value is JsonPrimitive)
{
this.NewGetType().GetProperty(key).SetValue(this, value as JsonPrimitive, null);
}
else if (value == null)
{
SetPropertyValue(key, null, true);
}
else
{
throw new Exception("类型错误");
}
}
//新加载的对象为未修改
IsModified = false;
}
示例7: work_Tick
/**
* 主工作方法定时得到通道信息
**/
void work_Tick(object sender, EventArgs e)
{
JsonObject jo = new JsonObject();
jo.Add("aId", this.GongHao);
jo.Add("aChannel", int.Parse(this.LineNum));
jo.Add("aModule", 1);
jo.Add("aBzType", "nvl");
jo.Add("aName", this.LoginName);
WebClient client = new WebClient();
client.UploadStringCompleted += (o, a) =>
{
if (a.Error == null)
{
//更新数据
JsonObject items = JsonValue.Parse(a.Result) as JsonObject;
GeneralObject go = new GeneralObject();
go.FromJson(items);
if (go == null)
{
this.PhoneState = GetPropertyValue("14") + "";
this.callNumber = "";
return;
}
//设置电话信息
//string stateIndex = go.GetPropertyValue("aState") + "";
////如果状态是接听,并且电话号码和录音号与语音服务部相同,设置
//this.PhoneState = GetPropertyValue(stateIndex) + "";
this.PhoneState = (String)go.GetPropertyValue("aState");
//如果电话号码相同,不通知
string oldNumber = this.CallNumber;
if (oldNumber == null)
{
oldNumber = "";
}
string newNumber = (String)(go.GetPropertyValue("callingNo"));
if(newNumber == null || newNumber.Length==0)
newNumber = "";
if (newNumber != null && !newNumber.Equals("") && !oldNumber.Equals(newNumber))
{
this.CallNumber = newNumber;
}
//如果记录号不相同,设置
string oldRecordFile = this.RecordFile;
if (oldRecordFile == null)
{
oldRecordFile = "";
}
string newRecordFile = go.GetPropertyValue("callRecId") + "";
if (newRecordFile != null && !newRecordFile.Equals("") && !oldRecordFile.Equals(newRecordFile))
{
this.RecordFile = newRecordFile;
}
object yhaf = go.GetPropertyValue("yhaf");
if (yhaf != null && yhaf.ToString() == "1")
this.FaxHint = "有传真";
else
this.FaxHint = "";
object ss = go.GetPropertyValue("serverState");
if (bool.Parse(ss.ToString()))
ServerState = "语音服务正常";
else
ServerState = "语音服务异常";
State = State.Loaded;
}
else
{
this.PhoneState = GetPropertyValue("14") + "";
ServerState = "语音服务异常";
this.CallNumber = "";
this.FaxHint = "";
State = State.LoadError;
Error = a.Error.Message;
}
};
client.Headers["Content-Type"] = "text/plain";
client.UploadStringAsync(new Uri(this.TelServiceUrl), jo.ToString());
}