| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using IwbZero.IwbBase;
- using IwbZero.ToolCommon.StringModel;
- namespace IwbZero.IwbDataQuery
- {
- public class IwbDataSource
- {
- public IwbDataSource(IwbDsSourceType poDataSourceType, string pcDataSourceId)
- {
- DataSourceType = poDataSourceType;
- DataSourceId = pcDataSourceId;
- }
- public IwbDataSource(string pcId, string pcName, string pcDataSourceId, IwbDsSourceType peType) :this(peType,pcDataSourceId)
- {
- AutoOpen = false;
- DSId = pcId;
- DSName = pcName;
-
- }
- public static IwbDataSource ConvertFrom(IwbXmlNode poNode)
- {
- string childValue = poNode.GetChildValue("Id");
- string pcString = poNode.GetChildValue("Content");
- string pcName = poNode.GetChildValue("Name");
- bool flag = poNode.GetChildValue("Open").StrToBool();
- IwbDataSource source = ConvertFrom(pcString);
- if (source != null)
- {
- return new IwbDataSource(childValue, pcName, source.DataSourceId, source.DataSourceType) { AutoOpen = flag };
- }
- return null;
- }
- public static IwbDataSource ConvertFrom(string pcId, string pcName, string pcContent)
- {
- IwbDataSource source = ConvertFrom(pcContent);
- if (source != null)
- {
- return new IwbDataSource(pcId, pcName, source.DataSourceId, source.DataSourceType);
- }
- return null;
- }
- public static IwbDataSource ConvertFrom(string pcString)
- {
- Array array = pcString.StrToArray();
- if (array.Length != 2)
- {
- return null;
- }
- string str = array.GetValue(0).ToString().UAndT();
- IwbDsSourceType table = IwbDsSourceType.Table;
- switch (str)
- {
- case "QUERY":
- table = IwbDsSourceType.Query;
- break;
- case "VIEW":
- table = IwbDsSourceType.View;
- break;
- }
- return new IwbDataSource(table, array.GetValue(1).ToString());
- }
- public string DataSourceToString()
- {
- return base.ToString();
- }
- public IwbXmlNode GetXmlNode()
- {
- IwbXmlNode node = new IwbXmlNode("DataSource", "");
- node.AddChild(new IwbXmlNode("Id", DSId));
- node.AddChild(new IwbXmlNode("Content", DataSourceToString()));
- node.AddChild(new IwbXmlNode("Name", DSName));
- node.AddChild(new IwbXmlNode("Open", AutoOpen.ToString()));
- return node;
-
- }
- public override string ToString()
- {
- return DSName;
- }
- public bool AutoOpen { get; set; }
- public string DSId { get; }
- public string DSName { get; }
- public IwbQuery GetData()
- {
- return GetData(DataSourceId);
- }
- public IwbQuery GetData(string sourceId)
- {
- return new IwbQuery(sourceId);
- }
- public void SaveData()
- {
- Data.SaveToXml();
- }
- public IwbQuery Data { get; set; }
- public string DataSourceId { get; set; }
- public IwbDsSourceType DataSourceType { get; set; }
- public bool IsEmpty
- {
- get
- {
- if (DataSourceType != IwbDsSourceType.Empty)
- {
- return (DataSourceId == "");
- }
- return true;
- }
- }
- }
- }
|