AssistSlowXCoreFunctions
2017-04-18 23:29:47 访问(1944) 赞(0) 踩(0)
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web.UI.WebControls;
using SlowX.Core.TableAttribute;
using System.Xml;
using SlowX.Core.Classes;
namespace SlowX.Core.Functions
{
/// <summary>
/// 辅助操作
/// </summary>
public class AssistSlowXCoreFunctions
{
#region Type相关的静态缓存值
/// <summary>
/// typeof(long)
/// </summary>
protected readonly static Type typeObject = typeof(object);
/// <summary>
/// typeof(long)
/// </summary>
protected readonly static Type typeLong = typeof(long);
/// <summary>
/// typeof(long?)
/// </summary>
protected readonly static Type typeLongNull = typeof(long?);
/// <summary>
/// typeof(float)
/// </summary>
protected readonly static Type typeFloat = typeof(float);
/// <summary>
/// typeof(float?)
/// </summary>
protected readonly static Type typeFloatNull = typeof(float?);
/// <summary>
/// typeof(double)
/// </summary>
protected readonly static Type typeDouble = typeof(double);
/// <summary>
/// typeof(double?)
/// </summary>
protected readonly static Type typeDoubleNull = typeof(double?);
/// <summary>
/// typeof(DateTime)
/// </summary>
protected readonly static Type typeDateTime = typeof(DateTime);
/// <summary>
/// typeof(DateTime?)
/// </summary>
protected readonly static Type typeDateTimeNull = typeof(DateTime?);
/// <summary>
/// typeof(int)
/// </summary>
protected readonly static Type typeInt = typeof(int);
/// <summary>
/// typeof(UInt64)
/// </summary>
protected readonly static Type typeUInt64 = typeof(System.UInt64);
/// <summary>
/// typeof(int?)
/// </summary>
protected readonly static Type typeIntNull = typeof(int?);
/// <summary>
/// typeof(Int32)
/// </summary>
protected readonly static Type typeInt32 = typeof(Int32);
/// <summary>
/// typeof(string)
/// </summary>
protected readonly static Type typeString = typeof(string);
/// <summary>
/// typeof(bool)
/// </summary>
protected readonly static Type typeBoolean = typeof(bool);
/// <summary>
/// typeof(long?)
/// </summary>
protected readonly static Type typeBooleanNull = typeof(bool?);
/// <summary>
/// typeof(Unit)
/// </summary>
protected readonly static Type typeUnit = typeof(Unit);
/// <summary>
/// typeof(Unit?)
/// </summary>
protected readonly static Type typeUnitNull = typeof(Unit?);
/// <summary>
/// typeof(System.Enum)
/// </summary>
protected readonly static Type typeSystemEnum = typeof(System.Enum);
#endregion Type相关的静态缓存值
/// <summary>
/// 创建 BaseTableAttribute 相关结构的DataTable
/// </summary>
/// <returns></returns>
protected static DataTable CreateBaseTableAttributeDataTable()
{
DataTable theResult = new DataTable();
theResult.Columns.Add(new DataColumn("customizeTableId", typeLong));
theResult.Columns.Add(new DataColumn("emBaseEntityModeValue", typeInt));
theResult.Columns.Add(new DataColumn("emPrimaryKeyCreateValue", typeInt));
theResult.Columns.Add(new DataColumn("IDFieldName", typeString));
theResult.Columns.Add(new DataColumn("IDFieldParameterType", typeString));
return theResult;
}
/// <summary>
/// 获得表格属性的XML
/// </summary>
/// <returns></returns>
public static DataSet GetBaseTableAttributeDataSet
(
BaseTableAttribute baseTableAttributeValue
)
{
DataTable dt = CreateBaseTableAttributeDataTable();
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
dt.TableName = "BaseTableAttribute";
dr["customizeTableId"] = baseTableAttributeValue.customizeTableId;
dr["emBaseEntityModeValue"] = (int)baseTableAttributeValue.emBaseEntityModeValue;
dr["emPrimaryKeyCreateValue"] = (int)baseTableAttributeValue.emPrimaryKeyCreateValue;
dr["IDFieldName"] = baseTableAttributeValue.IDFieldName;
if (baseTableAttributeValue.IDFieldParameterType == null)
dr["IDFieldParameterType"] = "";
else
dr["IDFieldParameterType"] = baseTableAttributeValue.IDFieldParameterType.FullName;
// 写到这里 //
DataSet theResult = new DataSet();
theResult.Tables.Add(dt);
return theResult;
}
/// <summary>
/// 获得构建的XML
/// </summary>
/// <param name="baseTableAttributeValue"></param>
/// <returns></returns>
public static string GetBaseTableAttributeXML
(
BaseTableAttribute baseTableAttributeValue
)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<?xml version='1.0' encoding='GB2312'?><BaseTableAttributes></BaseTableAttributes>");
XmlElement root = xmlDoc.DocumentElement;
XmlElement xmlNode = xmlDoc.CreateElement("BaseTableAttribute");
XmlElement xmlNodeItem = null;
xmlNode.SetAttribute("customizeTableId", baseTableAttributeValue.customizeTableId.ToString());
xmlNode.SetAttribute("emBaseEntityModeValue", ((int)baseTableAttributeValue.emBaseEntityModeValue).ToString());
xmlNode.SetAttribute("emPrimaryKeyCreateValue", ((int)baseTableAttributeValue.emPrimaryKeyCreateValue).ToString());
xmlNode.SetAttribute("IDFieldName", baseTableAttributeValue.IDFieldName);
if (baseTableAttributeValue.IDFieldParameterType == null)
xmlNode.SetAttribute("IDFieldParameterType", "");
else
xmlNode.SetAttribute("IDFieldParameterType", baseTableAttributeValue.IDFieldParameterType.FullName);
// xmlNode.SetAttribute("ShowSeqDataColumnName", baseTableAttributeValue.ShowSeqDataColumnName);
xmlNode.SetAttribute("TableComment", baseTableAttributeValue.TableComment);
xmlNode.SetAttribute("TableName", baseTableAttributeValue.TableName);
List<DataColumnAttributeInfo>
listDataColumnAttributeInfoValue = baseTableAttributeValue.listDataColumnAttributeInfoValue;
// 字段名 //
foreach (DataColumnAttributeInfo dataColumnAttributeInfoValue in listDataColumnAttributeInfoValue)
{
xmlNodeItem = xmlDoc.CreateElement("DataColumnAttributeInfo");
xmlNodeItem.SetAttribute("Name", dataColumnAttributeInfoValue.Name);
xmlNodeItem.SetAttribute("AllowDBNull", BooleanSlowXCoreFunctions.GetStrByBoolean(dataColumnAttributeInfoValue.AllowDBNull));
xmlNodeItem.SetAttribute("Comment", dataColumnAttributeInfoValue.Comment);
xmlNodeItem.SetAttribute("DataColumnLinkClassName", dataColumnAttributeInfoValue.DataColumnLinkClassName);
xmlNodeItem.SetAttribute("DataColumnLinkTextChar", dataColumnAttributeInfoValue.DataColumnLinkTextChar);
xmlNodeItem.SetAttribute("DataColumnLinkValueChar", dataColumnAttributeInfoValue.DataColumnLinkValueChar);
xmlNodeItem.SetAttribute("emDataColumnLinkModeValue", ((int)dataColumnAttributeInfoValue.emDataColumnLinkModeValue).ToString());
xmlNodeItem.SetAttribute("emDataColumnLinkValue", ((int)dataColumnAttributeInfoValue.emDataColumnLinkValue).ToString());
xmlNodeItem.SetAttribute("emVarTypeValue", ((int)dataColumnAttributeInfoValue.emVarTypeValue).ToString());
xmlNodeItem.SetAttribute("IsPrimaryKey", BooleanSlowXCoreFunctions.GetStrByBoolean(dataColumnAttributeInfoValue.IsPrimaryKey));
xmlNode.AppendChild(xmlNodeItem);
}
root.AppendChild(xmlNode);
// 创建Xml字段 //
return xmlDoc.InnerXml;
}
}
}
标签:
AssistSlowXCoreFunctions 


上一条:
下一条:
相关评论
发表评论