2020-11-28 07:44:21 +00:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
using ryCommon;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// json 的摘要说明
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class Json
|
|
|
|
|
|
{
|
|
|
|
|
|
string jsonText = "";
|
|
|
|
|
|
public JObject jo;
|
|
|
|
|
|
public Json(string _jsonText)
|
|
|
|
|
|
{
|
|
|
|
|
|
string xx = _jsonText.GetStr("descUrl", "counterApi",0,out int pos1,"");
|
|
|
|
|
|
jsonText = _jsonText.Replace("+new Date,", "'',");
|
|
|
|
|
|
jsonText = jsonText.Replace("!true,", "false,");
|
|
|
|
|
|
if (xx != "") { jsonText = jsonText.Replace(xx, " :'',\r\n "); }
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jsonText == "")
|
|
|
|
|
|
{ jo = new JObject(); }
|
|
|
|
|
|
else
|
|
|
|
|
|
jo = (JObject)JsonConvert.DeserializeObject(jsonText);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch(Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
jo = new JObject();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public string Text
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return jo.ToString(); }
|
|
|
|
|
|
set { jo = (JObject)JsonConvert.DeserializeObject(jsonText); }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string GetJsonValue(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return ""; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{ return jo[name].ToString(); }
|
|
|
|
|
|
}
|
|
|
|
|
|
public string GetJsonValue(string name,string defvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return defvalue; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{ return jo[name].ToString(); }
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool GetJsonValue(string name,bool defvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return defvalue; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = jo[name].ToString().ToLower();
|
|
|
|
|
|
return value == "1" || value == "true"; }
|
|
|
|
|
|
}
|
|
|
|
|
|
public int GetJsonValue(string name, int defvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return defvalue; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{ return jo[name].ToInt(defvalue); }
|
|
|
|
|
|
}
|
### 2024-12-10更新
------
#### VSoft V2.0.2412.1001
- *.[新增]拖放文件到主界面,支持直接插入到拖放的位置。
- *.[新增]新增支持设置运行次数的功能,可以快速进行多开。
- *.[新增]支持保存大小和选中的栏目和分类位置。
- *.[改进]切换栏目会记录列表滚动条位置和选中的分类。
- *.[改进]编辑添加的内置功能,将不允许修改路径。
- *.[改进]读取快捷方式时,支持自动获取图标信息。
- *.[改进]新增软件完成后,不再刷新列表,而是直接添加到列表末尾。
- *.[改进]新增软件或拖放软件后,界面直接定位到添加的列表位置。
- *.[改进]点击显示主界面时,如果存在模式窗体,则将模式窗体显示在前面。
- *.[改进]当百度翻译出错时自动重试翻译。
- *.[修复]栏目和分类进行拖放操作时,拖放出控件会残留拖放标志的BUG。
2024-12-10 08:55:25 +00:00
|
|
|
|
public int GetJsonValue(string name, int min, int max, int defValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return defValue; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{ return jo[name].ToInt(min, max,defValue); }
|
|
|
|
|
|
}
|
2020-11-28 07:44:21 +00:00
|
|
|
|
public Int64 GetJsonValue(string name, Int64 defvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return defvalue; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{ return jo[name].ToInt64(defvalue); }
|
|
|
|
|
|
}
|
|
|
|
|
|
public decimal GetJsonValue(string name, decimal defvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return defvalue; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{ return jo[name].ToDecimal(defvalue); }
|
|
|
|
|
|
}
|
|
|
|
|
|
public double GetJsonValue(string name, double defvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return defvalue; }
|
|
|
|
|
|
else
|
|
|
|
|
|
{ return jo[name].ToDouble(defvalue); }
|
|
|
|
|
|
}
|
|
|
|
|
|
public DataTable GetJsonValueByTable(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (jo[name] == null) { return new DataTable(); }
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
return JsonConvert.DeserializeObject(jo[name].ToString(), typeof(DataTable)) as DataTable;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { return new DataTable(); }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Add(string Name, string value)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
jo.Add(Name, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Add(string Name, int value)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
jo.Add(Name, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Add(string Name, bool value)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
jo.Add(Name, value?1:0);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Add(string Name, decimal value)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
jo.Add(Name, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Add(string Name, DataTable value)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
jo.Add(Name, Newtonsoft.Json.JsonConvert.SerializeObject(value));
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|