#region
|
|
using System;
|
using System.Data;
|
using CSFrameworkV5.Common;
|
using CSFrameworkV5.Core;
|
using CSFrameworkV5.Core.CodeGenerator;
|
using CSFrameworkV5.Interfaces;
|
using CSFrameworkV5.WCFContract;
|
|
#endregion
|
|
namespace CSFrameworkV5.WebRef
|
{
|
public class WCF_DataDict : WCF_Base<IDataDictService>, IBridge_DataDict
|
{
|
private string _DBID;
|
private Type _ORM;
|
private string _TableName;
|
|
public WCF_DataDict()
|
{
|
_DBID = Loginer.CurrentUser.DBID;
|
}
|
|
public WCF_DataDict(Type ORM)
|
: this()
|
{
|
_ORM = ORM;
|
_TableName = ORM_Tools.GetTableName(ORM);
|
_DBID = Loginer.CurrentUser.DBID;
|
}
|
|
public WCF_DataDict(string tableName)
|
: this()
|
{
|
_TableName = tableName;
|
_DBID = Loginer.CurrentUser.DBID;
|
}
|
|
public WCF_DataDict(string tableName, string DBID)
|
: this()
|
{
|
_TableName = tableName;
|
_DBID = DBID;
|
}
|
|
private void AssertORM()
|
{
|
if (_ORM == null) throw new Exception("WCF_DATA_DICT:没有指定ORM模型!");
|
}
|
|
#region IBridge_DataDict Members
|
|
public Type ORM
|
{
|
get => _ORM;
|
set => _ORM = value;
|
}
|
|
public string TableName
|
{
|
get => _TableName;
|
set => _TableName = value;
|
}
|
|
public string LastGeneratedKey { get; set; }
|
|
public DataTable GetDataDictByTableName(string tableName)
|
{
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
var receivedData =
|
client.GetDataDictByDBTableName(loginTicket, tableName,
|
_DBID);
|
return ZipTools.DecompressionDataSet(receivedData).Tables[0];
|
});
|
}
|
|
public DataTable GetEmptyTable(string DBName, string tableName)
|
{
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
var receivedData =
|
client.GetEmptyTable(loginTicket, DBName, tableName);
|
return ZipTools.DecompressionDataSet(receivedData).Tables[0];
|
});
|
}
|
|
public DataTable GetDataByKey(string key)
|
{
|
AssertORM();
|
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
var receivedData =
|
client.GetDataByKey(loginTicket, _ORM.FullName, key);
|
return ZipTools.DecompressionDataSet(receivedData).Tables[0];
|
});
|
}
|
|
public DataTable GetSummaryData()
|
{
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
byte[] receivedData;
|
if (_ORM != null)
|
receivedData =
|
client.GetSummaryData(loginTicket, _ORM.FullName);
|
else if (!string.IsNullOrEmpty(_TableName))
|
receivedData =
|
client.GetDataDictByDBTableName(loginTicket, _TableName,
|
_DBID);
|
else
|
throw new Exception("WCF_DATA_DICT:没有指定ORM模型或资料表名!");
|
|
return ZipTools.DecompressionDataSet(receivedData).Tables[0];
|
});
|
}
|
|
public bool Update(DataSet data)
|
{
|
AssertORM();
|
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
var bs = ZipTools.CompressionDataSet(data);
|
return client.Update(loginTicket, bs, _ORM.FullName);
|
});
|
}
|
|
public SaveResultEx UpdateEx(DataSet data)
|
{
|
AssertORM();
|
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
var bs = ZipTools.CompressionDataSet(data);
|
var rt = client.UpdateEx(loginTicket, bs, _ORM.FullName);
|
return (SaveResultEx)ZipTools.DecompressionObject(rt);
|
});
|
}
|
|
public bool Delete(string keyValue)
|
{
|
AssertORM();
|
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
return client.Delete(loginTicket, keyValue, _ORM.FullName);
|
});
|
}
|
|
public bool CheckNoExists(string keyValue)
|
{
|
AssertORM();
|
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
return client.CheckNoExists(loginTicket, keyValue,
|
_ORM.FullName);
|
});
|
}
|
|
public bool CheckNoExists(string keyFieldName, string keyValue)
|
{
|
AssertORM();
|
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
return client.CheckNoExistsEx(loginTicket, keyFieldName,
|
keyValue, _ORM.FullName);
|
});
|
}
|
|
public virtual DateTime GetServerTime()
|
{
|
return Excute<DateTime, ICommonService>(svc =>
|
{
|
var loginTicket = WebServiceSecurity.GetLoginTicket();
|
return svc.GetServerTime(loginTicket);
|
});
|
}
|
|
public DataTable GetLookupData()
|
{
|
return Excute(client =>
|
{
|
var loginTicket =
|
WebServiceSecurity.EncryptLoginer(Loginer.CurrentUser);
|
byte[] receivedData;
|
|
if (_ORM != null)
|
receivedData =
|
client.GetLookupDataByTableName(loginTicket,
|
_TableName);
|
else if (!string.IsNullOrEmpty(_TableName))
|
receivedData =
|
client.GetLookupDataByDBTableName(loginTicket,
|
_TableName, _DBID);
|
else
|
throw new Exception("WCF_DATA_DICT:没有指定ORM模型或资料表名!");
|
|
return ZipTools.DecompressionDataSet(receivedData).Tables[0];
|
});
|
}
|
|
public DataTable GetDataDictBySql(string SQL)
|
{
|
throw new NotImplementedException();
|
}
|
|
#endregion
|
}
|
}
|