备用代码

function DataGridHandler(opts)
{
this. _parameters = opts;
}

DataGridHandler.prototype =
{
fillContainer: function () {
$(this._parameters.tblContainerName).datagrid({
url: this._parameters.url,

title: this._parameters.title,

this._parameters.width,

height: this._parameters.height,

fitColumns: this._parameters.fitColumns,

pagination: this._parameters.pagination,

pageSize: this._parameters.pageSize,

singleSelect: this._parameters.singleSelect,

columns: this._parameters.columns
});
},
setPagination: function ()
{
var page = $(this._parameters.tblContainerName).datagrid('getPager');

$(page).pagination({ showPageList: this._parameters.showPageList, showRefresh: this._parameters.showRefresh });
}
}

function StatusConfig() { }

StatusConfig._service = 0;

StatusConfig.updateConfig = function (opts)
{

var tree = $.fn.zTree.getZTreeObj(opts.ele);

var areas = tree.getCheckedNodes(true);

var nochecked = tree.getCheckedNodes(false);

var check = '', checked = '';

$.each(areas, function (i, item)
{
if (!item.chkDisabled)
checked += item.id + ',';

});

$.each(nochecked, function (i, item)
{
if (!item.chkDisabled)
check += item.id + ',';

});

var url = AjaxHelper.buildUrl({ parent: StatusConfig._service, areas: checked.substring(0, checked.lastIndexOf(',')), empty: check.substring(0, check.lastIndexOf(',')) }, opts.url);


AjaxHelper.getJson(url, function (data)
{
StatusConfig._service = 0;

$(opts.dialog).window(opts.command);
});
}

StatusConfig.reloadztree = function (opts)
{
var setting = { check: { enable: true }, data: { simpleData: { enable: true}} };

StatusConfig._service = opts.id;

AjaxHelper.getJson(opts.url, function (data)
{
$.each(data, function (i, item)
{
if (Validation.isValidObject(item.parent) && Validation.isValidObject(opts.id))
{
if (item.parent == opts.id)
{
item.checked = true;
//item.chkDisabled = true;
}
}
});

$.fn.zTree.init($(opts.serviceszTree), setting, data);

DialogBox.executeCommand(opts);


});
}

function Validation() { }

Validation.isValidObject = function (object)
{
var status = true;

if (object == null)
status = false;

if (object == '')
status = false;

if (object == 'undefine')
status = false;

return status;
}

function DialogBox() { }
DialogBox.executeCommand = function (opts)
{

if (Validation.isValidObject(opts.caption))
$(opts.ele).window({ title: opts.caption });

$(opts.ele).window(opts.command);
}

function AjaxHelper() { }

AjaxHelper.buildUrl = function (object, url)
{
url += '?';

for (var key in object) {
url += key + '=' + object[key] + '&';
}

return url.substring(0, url.lastIndexOf('&'));
}

AjaxHelper.getJson = function (url, method) { $.ajax({ type: 'post', dataType: 'json', url: url, cache: false, success: function (data) { method(data); } }); }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;

namespace IS.ParseXml
{
public class XmlParser
{
/// <summary>
///
/// </summary>
/// <param name="strContext">XML字符串,不可为空</param>
/// <param name="type">服务类型</param>
/// <returns>Dictionary</returns>
///
public static Dictionary<List<XmlModel>, List<XmlModel>> Format(string xmlText, ServiceType type)
{

if (string.IsNullOrEmpty(xmlText))
return null;

using (StringReader textReader = new StringReader(xmlText))
{

//try
//{

XmlDocument doc = new XmlDocument();

doc.Load(textReader);

return ObtainXmlList(doc, RetrieveNodeName(type));
//}

//catch (Exception exception)
//{

//}
}
}


public static string RemoveCharacters(string instring)
{
if (instring == null) return null;

StringBuilder sbOutput = new StringBuilder();
char ch;

for (int i = 0; i < instring.Length; i++)
{
ch = instring[i];
if ((ch >= 0x0020 && ch <= 0xD7FF) ||
(ch >= 0xE000 && ch <= 0xFFFD) ||
ch == 0x0009 ||
ch == 0x000A ||
ch == 0x000D)
{
sbOutput.Append(ch);
}
}
return sbOutput.ToString();
}

private static Dictionary<List<XmlModel>, List<XmlModel>> ObtainXmlList(XmlDocument doc, string areas)
{
string[] arrayNodeList = areas.Split(',');

string nodeName = string.Empty;

XmlNodeList xmlNodeList = null;

Dictionary<List<XmlModel>, List<XmlModel>> list = new Dictionary<List<XmlModel>, List<XmlModel>>();

XmlModel xmlModel = null;

XmlModel xmlPropertyModel = null;

List<XmlModel> group = null;

List<XmlModel> data = null;

for (int i = 0; i < arrayNodeList.Length; i++)
{
group = new List<XmlModel>();

data = new List<XmlModel>();

nodeName = arrayNodeList[i];

if (!string.IsNullOrEmpty(nodeName))
{
xmlNodeList = doc.SelectNodes(string.Format("//{0}", arrayNodeList[i]));



foreach (XmlNode item in xmlNodeList)
{
xmlModel = new XmlModel();

xmlModel.Name = item.Attributes[0].Value;

xmlModel.Value = item.Attributes[1].Value;

for (int j = 0; j < item.ChildNodes.Count; j++)
{
xmlPropertyModel = new XmlModel();

xmlPropertyModel.Name = item.ChildNodes[j].Attributes[0].Value;

xmlPropertyModel.Value = item.ChildNodes[j].Attributes[1].Value;

data.Add(xmlPropertyModel);
}

group.Add(xmlModel);
}

list.Add(group, data);
}

}

return list;
}

public static string RetrieveNodeName(ServiceType type)
{
string strNodeName = string.Empty;

switch (type)
{
case ServiceType.Center:
strNodeName = "Summary";
break;
case ServiceType.Control:
strNodeName = "Load";
break;
case ServiceType.Compare:
strNodeName = "Load";
break;
case ServiceType.Build:
strNodeName = "Process";
break;
case ServiceType.WebService:
strNodeName = "Summary";
break;

case ServiceType.Suit:
strNodeName = "Process";
break;
case ServiceType.DataSync:
strNodeName = "Input,Processor,Output";
break;
case ServiceType.TaskSync:
strNodeName = "Process";
break;
case ServiceType.CompareX:
strNodeName = "Summary";
break;

}

return strNodeName;
}


public enum ServiceType
{
/// <summary>
/// 中心服务
/// </summary>
Center = 0,

/// <summary>
/// 比对主控
/// </summary>
Control = 1,

/// <summary>
/// 1:1比对服务
/// </summary>
Compare = 2,

/// <summary>
/// 1:N比对服务
/// </summary>
CompareN = 3,

/// <summary>
/// 查重服务
/// </summary>
NoRepeat = 4,

/// <summary>
/// 建模服务
/// </summary>
Build = 5,

/// <summary>
/// 调度服务
/// </summary>
Suit = 6,

/// <summary>
/// Webservice接口服务
/// </summary>
WebService = 7,

/// <summary>
/// 数据同步服务
/// </summary>
DataSync = 8,

/// <summary>
/// 任务同步服务
/// </summary>
TaskSync = 9,

/// <summary>
/// 1:X比对服务
/// </summary>
CompareX = 10,

/// <summary>
/// 1:X比对服务
/// </summary>
}
}

public class XmlModel
{

public string Name { get; set; }

public string Value { get; set; }
}
}




原文地址:https://www.cnblogs.com/ytjjyy/p/2434347.html