|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.SysMng.Models.DBTableConn
|
|
|
|
|
{
|
|
|
|
|
[JsonObject]
|
|
|
|
|
public class SYS_TABLECONNMC : ModelObjectBillHead
|
|
|
|
|
{//用于连接两个不同数据库的表
|
|
|
|
|
|
|
|
|
|
ModelObjectBillHead _DBFrom;
|
|
|
|
|
ModelObjectBillHead _DBSave;
|
|
|
|
|
|
|
|
|
|
public override Dictionary<string, ModelDBOprationType> GetPKey()
|
|
|
|
|
{//用于给扩展的动态数据提供主键字段名
|
|
|
|
|
var d = new Dictionary<string, ModelDBOprationType>() { { "ID", ModelDBOprationType.EditDelete } };
|
|
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string _sql = "select [ID],[NAME],[FROMDB],[FROMTABLE],[FROMPKEY],[TODB],[TOTABLE],[TOPKEY],dbo.trimtime([SYNCTIME]) SYNCTIME,[SYNCTYPE],[SYNCFREQ],[DESCRPTION],[CONDITION],convert(bigint ,TIMEMARK) as [TIMEMARK],FROMTIMEMARK,TOTIMEMARK ,dbo.trimtime( SYNCSTARTTIME) SYNCSTARTTIME,SYNCSTATES from SYS_TABLECONN";
|
|
|
|
|
private static string _sqlex = "";
|
|
|
|
|
|
|
|
|
|
public static string getSQL(){
|
|
|
|
|
if(_sqlex==""){
|
|
|
|
|
return _sql;
|
|
|
|
|
}else{
|
|
|
|
|
return _sqlex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SYS_TABLECONNMC()
|
|
|
|
|
{
|
|
|
|
|
TableName = "SYS_TABLECONN";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void getInfo(){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetBillNoFieldName()
|
|
|
|
|
{
|
|
|
|
|
return "ID";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetTimeMarkFieldName()
|
|
|
|
|
{
|
|
|
|
|
return "TIMEMARK"; //如果需要的话写入时间标签
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public DBTableConnModel()
|
|
|
|
|
//{
|
|
|
|
|
// TableName = "Demo_XSGL_BJ";
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonObject]
|
|
|
|
|
public class SYS_TABLECONN_FIELDMC : ModelObjectBillBody
|
|
|
|
|
{//用于连接两个不同数据库的表
|
|
|
|
|
|
|
|
|
|
public override Dictionary<string, ModelDBOprationType> GetPKey()
|
|
|
|
|
{//用于给扩展的动态数据提供主键字段名
|
|
|
|
|
var d = new Dictionary<string, ModelDBOprationType>() { { "ID", ModelDBOprationType.EditDelete } };
|
|
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string _sql = "select [ID],[CONNID],[NAME],[FROMFIELDNAME],[TOFIELDNAME],[CALCULATE] from SYS_TABLECONN_FIELD";
|
|
|
|
|
private static string _sqlex = "";
|
|
|
|
|
public static string getSQL()
|
|
|
|
|
{
|
|
|
|
|
if (_sqlex == "")
|
|
|
|
|
{
|
|
|
|
|
return _sql;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return _sqlex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SYS_TABLECONN_FIELDMC()
|
|
|
|
|
{
|
|
|
|
|
TableName = "SYS_TABLECONN_FIELD";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void getInfo()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetBillNoFieldName()
|
|
|
|
|
{
|
|
|
|
|
return "CONNID";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetTimeMarkFieldName()
|
|
|
|
|
{
|
|
|
|
|
return ""; //如果需要的话写入时间标签
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonObject]
|
|
|
|
|
public class BaseTableMC : ModelObjectBillHead
|
|
|
|
|
{//用于连接两个不同数据库的表
|
|
|
|
|
|
|
|
|
|
public string _PKEY = "";
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, ModelDBOprationType> _PKEYDic = new Dictionary<string, ModelDBOprationType>();
|
|
|
|
|
|
|
|
|
|
public override Dictionary<string, ModelDBOprationType> GetPKey()
|
|
|
|
|
{//用于给扩展的动态数据提供主键字段名
|
|
|
|
|
var d = new Dictionary<string, ModelDBOprationType>() { { _PKEY, ModelDBOprationType.All } };
|
|
|
|
|
|
|
|
|
|
if (_PKEYDic.Count > 0) {
|
|
|
|
|
return _PKEYDic;
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _sql = "select 1";
|
|
|
|
|
private string _sqlex = "";
|
|
|
|
|
|
|
|
|
|
public string getSQL()
|
|
|
|
|
{
|
|
|
|
|
if (_sqlex == "")
|
|
|
|
|
{
|
|
|
|
|
return _sql;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return _sqlex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void setSQL(string _sql)
|
|
|
|
|
{
|
|
|
|
|
_sqlex=_sql;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string DBNAME = "";
|
|
|
|
|
|
|
|
|
|
public BaseTableMC(string TABLENAME,string _PKEY,string _sql,string DBNAME)
|
|
|
|
|
{
|
|
|
|
|
this._PKEY = _PKEY;
|
|
|
|
|
if (_PKEY.Contains(",") && _PKEYDic.Count()==0) {
|
|
|
|
|
var _array = _PKEY.Split(',');
|
|
|
|
|
for (var _i = 0; _i < _array.Count(); _i++) {
|
|
|
|
|
_PKEYDic.Add(_array[_i], ModelDBOprationType.All);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.TableName = TABLENAME;
|
|
|
|
|
this._sql = _sql;
|
|
|
|
|
this.DBNAME = DBNAME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BaseTableMC(BaseTableMC Obj)
|
|
|
|
|
{
|
|
|
|
|
this._PKEY = Obj._PKEY;
|
|
|
|
|
this._PKEYDic = Obj._PKEYDic;
|
|
|
|
|
this.TableName = Obj.TableName;
|
|
|
|
|
this._sql = Obj._sql;
|
|
|
|
|
this.DBNAME = Obj.DBNAME;
|
|
|
|
|
this.SaveDic = Obj.SaveDic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BaseTableMC()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetBillNoFieldName()
|
|
|
|
|
{
|
|
|
|
|
if (_PKEYDic.Count > 0) {
|
|
|
|
|
List<string> KeyList = new List<string>(_PKEYDic.Keys);
|
|
|
|
|
return KeyList[0];
|
|
|
|
|
}
|
|
|
|
|
return _PKEY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetTimeMarkFieldName()
|
|
|
|
|
{
|
|
|
|
|
return ""; //如果需要的话写入时间标签
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BaseTableMC gettodata(List<SYS_TABLECONN_FIELDMC> bodylist) {
|
|
|
|
|
BaseTableMC todata = new BaseTableMC();
|
|
|
|
|
foreach (var field in bodylist)
|
|
|
|
|
{
|
|
|
|
|
todata.SetValue(field.GetValue("TOFIELDNAME"),this.GetValue(field.GetValue("FROMFIELDNAME")));
|
|
|
|
|
}
|
|
|
|
|
return todata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 用于解析:在同一字段中记录多个数据 通常会使用某种规律的分隔符
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="FIELDNAME"></param>
|
|
|
|
|
/// <param name="Splitmark"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string[] GetSplitField(string FIELDNAME, string Splitmark) {
|
|
|
|
|
var valuestr = GetValue(FIELDNAME);
|
|
|
|
|
|
|
|
|
|
var result = Regex.Split(valuestr, Splitmark, RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|