├── GOTO.BigDataAccess ├── DBSql │ ├── Access │ │ ├── DBAccessFactory.cs │ │ ├── DBHelperFactory.cs │ │ ├── DBProxy.cs │ │ ├── DBProxyAction.cs │ │ ├── SqlServerAccess.cs │ │ └── SqlServerHelper.cs │ ├── DBAction.cs │ ├── DBConfig.cs │ ├── DBPosition.cs │ ├── DBRead.cs │ ├── DBRule.cs │ ├── DBTask.cs │ ├── DBWrite.cs │ ├── Manager │ │ ├── ManagerConfig.cs │ │ ├── ManagerDatabase.cs │ │ ├── ManagerServer.cs │ │ └── ManagerTable.cs │ ├── Model │ │ ├── ConditionFieldModel.cs │ │ ├── MatchServerList.cs │ │ └── TaskDataParam.cs │ └── XmlModel │ │ ├── SqlBaseItemXml.cs │ │ ├── SqlBaseXml.cs │ │ ├── SqlDatabaseItemXml.cs │ │ ├── SqlDatabaseXml.cs │ │ ├── SqlFieldItemXml.cs │ │ ├── SqlFieldXml.cs │ │ ├── SqlServerItemXml.cs │ │ ├── SqlServerXml.cs │ │ ├── SqlTableItemXml.cs │ │ └── SqlTableXml.cs ├── GOTO.BigDataAccess.csproj ├── Properties │ └── AssemblyInfo.cs ├── RedisConfig │ ├── RedisConfigBase.cs │ ├── RedisConfigKey.cs │ └── RedisConfigService.cs ├── app.config ├── bin │ └── Debug │ │ ├── GOTO.BigDataAccess.dll │ │ ├── GOTO.BigDataAccess.dll.config │ │ ├── GOTO.BigDataAccess.pdb │ │ ├── GOTO.Common.dll │ │ ├── GOTO.Common.pdb │ │ ├── Microsoft.Threading.Tasks.Extensions.Desktop.dll │ │ ├── Microsoft.Threading.Tasks.Extensions.Desktop.xml │ │ ├── Microsoft.Threading.Tasks.Extensions.dll │ │ ├── Microsoft.Threading.Tasks.Extensions.xml │ │ ├── Microsoft.Threading.Tasks.dll │ │ ├── Microsoft.Threading.Tasks.xml │ │ ├── MongoDB.Bson.dll │ │ ├── MongoDB.Driver.dll │ │ ├── StackExchange.Redis.dll │ │ ├── StackExchange.Redis.xml │ │ ├── System.IO.dll │ │ ├── System.IO.xml │ │ ├── System.Runtime.dll │ │ ├── System.Runtime.xml │ │ ├── System.Threading.Tasks.dll │ │ └── System.Threading.Tasks.xml └── packages.config ├── GOTO.Common ├── CacheHelper.cs ├── CommonHelper.cs ├── CookieHelper.cs ├── FileHelper.cs ├── GOTO.Common.csproj ├── JsonHelper.cs ├── Properties │ └── AssemblyInfo.cs ├── SocketHelper.cs ├── XMLSerilizable.cs └── bin │ └── Debug │ ├── GOTO.Common.dll │ └── GOTO.Common.pdb ├── GOTO.ConsoleTest ├── GOTO.ConsoleTest.csproj ├── GOTO.ConsoleTest.csproj.user ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── TestDB.cs ├── app.config ├── bin │ └── Debug │ │ ├── GOTO.BigDataAccess.dll │ │ ├── GOTO.BigDataAccess.pdb │ │ ├── GOTO.Common.dll │ │ ├── GOTO.Common.pdb │ │ ├── GOTO.ConsoleTest.exe │ │ ├── GOTO.ConsoleTest.exe.config │ │ ├── GOTO.ConsoleTest.pdb │ │ ├── GOTO.ConsoleTest.vshost.exe │ │ ├── GOTO.ConsoleTest.vshost.exe.config │ │ ├── GOTO.ConsoleTest.vshost.exe.manifest │ │ ├── Microsoft.Threading.Tasks.Extensions.Desktop.dll │ │ ├── Microsoft.Threading.Tasks.Extensions.Desktop.xml │ │ ├── Microsoft.Threading.Tasks.Extensions.dll │ │ ├── Microsoft.Threading.Tasks.Extensions.xml │ │ ├── Microsoft.Threading.Tasks.dll │ │ ├── Microsoft.Threading.Tasks.xml │ │ ├── StackExchange.Redis.dll │ │ ├── StackExchange.Redis.xml │ │ ├── System.IO.dll │ │ ├── System.IO.xml │ │ ├── System.Runtime.dll │ │ ├── System.Runtime.xml │ │ ├── System.Threading.Tasks.dll │ │ └── System.Threading.Tasks.xml └── packages.config ├── GOTO.Segment.sln ├── LICENSE ├── README.md └── doc ├── bigdataconfig ├── SqlBaseXml.xml ├── t1 │ ├── SqlDatabaseXml.xml │ ├── SqlFieldXml.xml │ ├── SqlServerXml.xml │ ├── SqlTableSqlFilePath.xml │ ├── SqlTableStructFilePath.xml │ └── SqlTableXml.xml └── t2 │ ├── SqlDatabaseXml.xml │ ├── SqlFieldXml.xml │ ├── SqlServerXml.xml │ ├── SqlTableSqlFilePath.xml │ ├── SqlTableStructFilePath.xml │ └── SqlTableXml.xml ├── datadel.jpg ├── datamove.jpg ├── datarecover.jpg ├── datasearch.jpg ├── datastoragescheme.jpg ├── dataupdate.jpg ├── datawrite.jpg └── logicalarchitecture.jpg /GOTO.BigDataAccess/DBSql/Access/DBAccessFactory.cs: -------------------------------------------------------------------------------- 1 | namespace GOTO.BigDataAccess.DBSql.Access 2 | { 3 | public abstract class DBAccessFactory 4 | { 5 | #region 索引 6 | public abstract bool TableIndexExists(string connstr, string databasename, string tablename, string indexname); 7 | public abstract bool TableIndexAdd(string connstr, string databasename, string tablename, string columnname, string indexname); 8 | public abstract bool TableIndexDel(string connstr, string tablename, string indexname); 9 | #endregion 10 | #region 操作表 11 | public abstract long TableStorageSize(string connstr, string tablename); 12 | public abstract bool TableExists(string connstr, string dbname, string tablename); 13 | public abstract long TableCount(string connstr, string tablename); 14 | #endregion 15 | #region 操作数据库 16 | public abstract long DatabaseStorageSizeAll(string connstr, string databaseprev); 17 | public abstract long DatabaseStorageSize(string connstr, string databasename); 18 | public abstract bool DatabaseExists(string connstr, string dbname); 19 | public abstract bool DatabaseCreate(string connstr, string dbname, string dirpath); 20 | public abstract void DatabaseDrop(string connstr, string dbname); 21 | public abstract void DatabaseSHRINK(string connstr, string dbname); 22 | public abstract void DatabaseClearLog(string connstr, string dbname); 23 | public abstract void DatabaseSPAttach(string connstr, string dbname, string dbpath); 24 | public abstract void DatabaseSPDetach(string connstr, string dbname); 25 | #endregion 26 | #region 操作服务器 27 | public abstract bool ServerConnectionCheck(string connstr, string servername, string username, string userpwd, string databasename = ""); 28 | public abstract bool DirectoryExists(string connstr, string dirpath); 29 | public abstract bool DirectoryCreate(string connstr, string dirpath); 30 | public abstract bool DirectoryDrop(string connstr, string dirpath); 31 | public abstract void ServerCacheClear(string connstr); 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Access/DBHelperFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Data; 5 | using System.Data.SqlClient; 6 | 7 | namespace GOTO.BigDataAccess.DBSql.Access 8 | { 9 | public abstract class DBHelperFactory 10 | { 11 | #region 公用方法 12 | public abstract bool ConnectionIsUse(string connectionString); 13 | /// 14 | /// 判断是否存在某表的某个字段 15 | /// 16 | public abstract bool ColumnExists(string connectionString, string tableName, string columnName); 17 | public abstract int GetMaxID(string connectionString, string FieldName, string TableName); 18 | public abstract bool Exists(string connectionString, string strSql); 19 | /// 20 | /// 表是否存在 21 | /// 22 | /// 23 | /// 24 | public abstract bool TabExists(string connectionString, string TableName); 25 | public abstract bool Exists(string connectionString, string strSql, params SqlParameter[] cmdParms); 26 | #endregion 27 | #region 执行简单SQL语句 28 | /// 29 | /// 执行SQL语句,返回影响的记录数 30 | /// 31 | /// SQL语句 32 | /// 影响的记录数 33 | public abstract int ExecuteSql(string connectionString, string SQLString); 34 | 35 | /// 36 | /// 执行多条SQL语句,实现数据库事务。 37 | /// 38 | /// 多条SQL语句 39 | public abstract void ExecuteSqlTran(string connectionString, ArrayList SQLStringList); 40 | 41 | /// 42 | /// 执行多条SQL语句,实现数据库事务。 43 | /// 44 | /// 多条SQL语句 45 | /// SQL语句对应的参数 46 | public abstract int ExecuteSqlTran(string connectionString, ArrayList SQLStringList, List ParamList); 47 | /// 48 | /// 执行带一个存储过程参数的的SQL语句。 49 | /// 50 | /// SQL语句 51 | /// 参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加 52 | /// 影响的记录数 53 | public abstract int ExecuteSql(string connectionString, string SQLString, string content); 54 | /// 55 | /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例) 56 | /// 57 | /// SQL语句 58 | /// 图像字节,数据库的字段类型为image的情况 59 | /// 影响的记录数 60 | public abstract int ExecuteSqlInsertImg(string connectionString, string strSQL, byte[] fs); 61 | 62 | /// 63 | /// 执行一条计算查询结果语句,返回查询结果(object)。 64 | /// 65 | /// 计算查询结果语句 66 | /// 查询结果(object) 67 | public abstract object GetSingle(string connectionString, string SQLString); 68 | /// 69 | /// 执行查询语句,返回SqlDataReader 70 | /// 71 | /// 查询语句 72 | /// SqlDataReader 73 | public abstract SqlDataReader ExecuteReader(string connectionString, string strSQL); 74 | /// 75 | /// 执行查询语句,返回DataSet 76 | /// 77 | /// 查询语句 78 | /// DataSet 79 | public abstract DataSet Query(string connectionString, string strSQLString); 80 | /// 81 | /// 执行查询语句,返回DataSet 82 | /// 83 | /// 查询语句 84 | /// DataSet 85 | public abstract DataTable GetDataDable(string connectionString, string strSQLString); 86 | 87 | 88 | #endregion 89 | #region 执行带参数的SQL语句 90 | 91 | /// 92 | /// 执行SQL语句,返回影响的记录数 93 | /// 94 | /// SQL语句 95 | /// 影响的记录数 96 | public abstract int ExecuteSql(string connectionString, string SQLString, params SqlParameter[] cmdParms); 97 | 98 | 99 | /// 100 | /// 执行多条SQL语句,实现数据库事务。 101 | /// 102 | /// SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[]) 103 | public abstract void ExecuteSqlTran(string connectionString, Hashtable SQLStringList); 104 | 105 | /// 106 | /// 执行多条SQL语句,实现数据库事务。 107 | /// 108 | /// SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[]) 109 | public abstract int ExecuteSqlTran1(string connectionString, Hashtable SQLStringList); 110 | 111 | /// 112 | /// 执行一条计算查询结果语句,返回查询结果(object)。 113 | /// 114 | /// 计算查询结果语句 115 | /// 查询结果(object) 116 | public abstract object GetSingle(string connectionString, string SQLString, params SqlParameter[] cmdParms); 117 | 118 | /// 119 | /// 执行查询语句,返回SqlDataReader 120 | /// 121 | /// 查询语句 122 | /// SqlDataReader 123 | public abstract SqlDataReader ExecuteReader(string connectionString, string SQLString, params SqlParameter[] cmdParms); 124 | 125 | /// 126 | /// 执行查询语句,返回DataSet 127 | /// 128 | /// 查询语句 129 | /// DataSet 130 | public abstract DataSet Query(string connectionString, string SQLString, params SqlParameter[] cmdParms); 131 | 132 | #endregion 133 | #region 数据大批量的插入数据库中 134 | /// 135 | /// 将Datatable中的数据大批量的插入数据库中 136 | /// 137 | /// 138 | public abstract void WriteBlockDataToDB(string connectionString, DataTable dt); 139 | #endregion 140 | #region 存储过程操作 141 | 142 | /// 143 | /// 执行存储过程 144 | /// 145 | /// 存储过程名 146 | /// 存储过程参数 147 | /// SqlDataReader 148 | public abstract SqlDataReader RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters); 149 | 150 | /// 151 | /// 执行存储过程 152 | /// 153 | /// 存储过程名 154 | /// 存储过程参数 155 | /// DataSet结果中的表名 156 | /// DataSet 157 | public abstract DataSet RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters, string tableName); 158 | 159 | 160 | /// 161 | /// 执行存储过程,返回影响的行数 162 | /// 163 | /// 存储过程名 164 | /// 存储过程参数 165 | /// 影响的行数 166 | /// 167 | public abstract int RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters, out int rowsAffected); 168 | /// 169 | /// 执行存储过程,返回第一行第一列 170 | /// 171 | /// 存储过程名 172 | /// 存储过程参数 173 | /// 第一行第一列值 174 | /// 175 | public abstract string RunProcedure(string connectionString, string storedProcName, IDataParameter[] parameters, out string rowsAffected); 176 | 177 | #endregion 178 | #region 执行SQL语句,实现数据库事务 179 | /// 180 | /// 执行多条SQL语句,实现数据库事务。 181 | /// 182 | /// 多条SQL语句 183 | public abstract int ExecuteSqlTran(string connectionString, List SQLStringList); 184 | 185 | /// 186 | /// 执行1条SQL语句,实现数据库事务。 187 | /// 188 | /// 多条SQL语句 189 | public abstract int ExecuteSqlTran(string connectionString, string SQLString); 190 | #endregion 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Access/DBProxy.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace GOTO.BigDataAccess.DBSql.Access 3 | { 4 | public static class DBProxy 5 | { 6 | public static DBAccessFactory GetDBAccess(string dbtype) 7 | { 8 | DBAccessFactory dbservice = new SqlServerAccess(); 9 | switch (dbtype) 10 | { 11 | case "sqlserver": return new SqlServerAccess(); 12 | } 13 | return dbservice; 14 | } 15 | public static DBHelperFactory GetDBHelper(string dbtype) 16 | { 17 | switch (dbtype) 18 | { 19 | case "sqlserver": return new SqlServerHelper(); 20 | } 21 | return new SqlServerHelper(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Access/DBProxyAction.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Model; 2 | using GOTO.BigDataAccess.DBSql.XmlModel; 3 | using GOTO.Common; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace GOTO.BigDataAccess.DBSql.Access 9 | { 10 | public static class DBProxyAction 11 | { 12 | public static string GetConnStr(SqlBaseItemXml basemodel, SqlServerItemXml servermodel) 13 | { 14 | return string.Format(basemodel.TemplateSqlConnServer, servermodel.ServerName, servermodel.ServerUserName, servermodel.ServerUserPwd); 15 | } 16 | public static string GetConnStr(SqlBaseItemXml basemodel, SqlServerItemXml item, SqlDatabaseItemXml item2) 17 | { 18 | return string.Format(basemodel.TemplateSqlConnDatabase, item.ServerName, item2.DatabaseName, item.ServerUserName, item.ServerUserPwd); 19 | } 20 | public static string GetSqlWhere(SqlServerItemXml servermodel, ConditionFieldModel conditionfield) 21 | { 22 | StringBuilder sqlwhere = new StringBuilder(); 23 | if (conditionfield != null) 24 | { 25 | int i = 0; 26 | foreach (var item in conditionfield.List) 27 | { 28 | if (i++ > 0) 29 | { 30 | sqlwhere.Append(" and "); 31 | } 32 | sqlwhere.AppendFormat(" {0} between {1} and {2} ", item.FieldName, item.ValueMin, item.ValueMax); 33 | } 34 | } 35 | return sqlwhere.ToString(); 36 | } 37 | public static string GetSqlList(SqlServerItemXml servermodel, MatchServerList item, ConditionFieldModel conditionfield, long getmaxnum = 500) 38 | { 39 | return string.Format(@"select top {3} * from {0}.dbo.{1} where {2} ", item.DatabaseNumber, item.TableNumber, GetSqlWhere(servermodel,conditionfield), getmaxnum); 40 | } 41 | public static string GetSqlUpdate(SqlBaseItemXml basemodel, Dictionary updatefieldlist) 42 | { 43 | StringBuilder sqlstr = new StringBuilder(); 44 | if (updatefieldlist != null) 45 | { 46 | foreach (var tempitem in updatefieldlist) 47 | { 48 | if (basemodel.FieldUpdateList.Contains(tempitem.Key)) 49 | { 50 | if (sqlstr.Length > 0) 51 | { 52 | sqlstr.Append(','); 53 | } 54 | if (tempitem.Value is int || tempitem.Value is long || tempitem.Value is float || tempitem.Value is double || tempitem.Value is decimal) 55 | { 56 | sqlstr.AppendFormat("{0}={1} ", tempitem.Key, tempitem.Value.ToString()); 57 | } 58 | else 59 | { 60 | sqlstr.AppendFormat("{0}='{1}' ", tempitem.Key, tempitem.Value.ToString()); 61 | } 62 | } 63 | } 64 | } 65 | return sqlstr.ToString(); 66 | } 67 | public static string GetSqlCount(SqlServerItemXml servermodel, MatchServerList item, ConditionFieldModel conditionfield) 68 | { 69 | return string.Format(@"select COUNT(0) from {0}.dbo.{1} where {2}", item.DatabaseNumber, item.TableNumber, GetSqlWhere(servermodel, conditionfield)); 70 | } 71 | public static bool Delete(SqlBaseItemXml basemodel, long rowid, SqlServerItemXml servermodel, SqlDatabaseItemXml databasemodel, SqlTableItemXml tablemodel, SqlFieldItemXml fieldmodel) 72 | { 73 | bool revalue = false; 74 | string connstr = GetConnStr(basemodel,servermodel); 75 | string sqlstr = string.Format("delete from {0}.dbo.{1} where {2}={3}", databasemodel.DatabaseName, tablemodel.TableName, basemodel.PrimarykeyName, rowid); 76 | 77 | long temp = CommonHelper.ToLong(DBProxy.GetDBHelper(servermodel.DBType).ExecuteSql(connstr, sqlstr)); 78 | if (temp > 0) 79 | { 80 | revalue = true; 81 | } 82 | return revalue; 83 | } 84 | public static bool Update(SqlBaseItemXml basemodel, long rowid, SqlServerItemXml servermodel, SqlDatabaseItemXml databasemodel, SqlTableItemXml tablemodel, Dictionary updatefieldlist) 85 | { 86 | bool revalue = false; 87 | string connstr = GetConnStr(basemodel, servermodel); 88 | string sqlstr = string.Format("update {0}.dbo.{1} set {4} where {2}={3}", databasemodel.DatabaseName, tablemodel.TableName, basemodel.PrimarykeyName, rowid, GetSqlUpdate(basemodel,updatefieldlist)); 89 | 90 | long temp = CommonHelper.ToLong(DBProxy.GetDBHelper(servermodel.DBType).ExecuteSql(connstr, sqlstr)); 91 | if (temp > 0) 92 | { 93 | revalue = true; 94 | } 95 | return revalue; 96 | } 97 | public static long GetAllCount(SqlBaseItemXml basemodel, ref long sqlnum) 98 | { 99 | sqlnum = 0; 100 | long rownum = 0; 101 | List taskdataparam = new List(); 102 | var databaselist = DBConfig.GetDatabaseXmlConfig(basemodel).SqlDatabaseList.Where(m => m.IsUse == true).ToList(); 103 | foreach (var item in databaselist) 104 | { 105 | var servermodel = DBConfig.GetServerItemXmlConfig(basemodel,item.ServerNumber); 106 | if (servermodel != null) 107 | { 108 | TaskDataParam tempparam = new TaskDataParam(); 109 | tempparam.servername = servermodel.ServerName; 110 | tempparam.dbtype = servermodel.DBType; 111 | tempparam.connstr = GetConnStr(basemodel, servermodel,item); 112 | tempparam.sqlstr = "select sum(b.rows) as 记录条数 from sysobjects a,sysindexes b where a.id=b.id and a.xtype='u' and b.indid=1 "; 113 | taskdataparam.Add(tempparam); 114 | } 115 | } 116 | DBTask servicetask = new DBTask(); 117 | rownum = servicetask.SyncThreadPoolManagerSum(taskdataparam, 100, false); 118 | sqlnum = servicetask.runnumcurrent; 119 | return rownum; 120 | } 121 | public static long GetAllCount2(SqlBaseItemXml basemodel, ref long sqlnum) 122 | { 123 | sqlnum = 0; 124 | long rownum = 0; 125 | List taskdataparam = new List(); 126 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 127 | foreach (var item in serverlist) 128 | { 129 | StringBuilder sqlstr = new System.Text.StringBuilder(); 130 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel, item.Number); 131 | foreach (var item2 in databaselist) 132 | { 133 | if (sqlstr.Length > 0) 134 | { 135 | sqlstr.Append(" union all "); 136 | } 137 | sqlstr.AppendFormat(" select sum(b.rows) as 记录条数 from {0}.sys.sysobjects a,{0}.sys.sysindexes b where a.id=b.id and a.xtype='u' and b.indid=1 ", item2.DatabaseName); 138 | } 139 | if (sqlstr.Length > 0) 140 | { 141 | TaskDataParam tempparam = new TaskDataParam(); 142 | tempparam.servername = item.ServerName; 143 | tempparam.dbtype = item.DBType; 144 | tempparam.connstr = GetConnStr(basemodel, item); 145 | tempparam.sqlstr = string.Format("select SUM([记录条数]) from ({0})t1", sqlstr.ToString()); 146 | taskdataparam.Add(tempparam); 147 | } 148 | sqlstr.Clear(); 149 | } 150 | DBTask servicetask = new DBTask(); 151 | rownum = servicetask.SyncTaskManagerSum(taskdataparam, 100, false); 152 | sqlnum = servicetask.runnumcurrent; 153 | return rownum; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Access/SqlServerAccess.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using GOTO.Common; 3 | 4 | namespace GOTO.BigDataAccess.DBSql.Access 5 | { 6 | public class SqlServerAccess:DBAccessFactory 7 | { 8 | #region 索引 9 | public override bool TableIndexExists(string connstr,string databasename, string tablename, string indexname) 10 | { 11 | bool revalue = false; 12 | try 13 | { 14 | StringBuilder sqlstr = new StringBuilder(); 15 | sqlstr.AppendFormat(" select 1 from {0}.dbo.sysindexes where id=object_id('{0}.dbo.{1}') and name='{2}' ", databasename,tablename, indexname); 16 | int temp = CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr,sqlstr.ToString())); 17 | if (temp > 0) 18 | { 19 | revalue = true; 20 | } 21 | } 22 | catch 23 | { 24 | } 25 | return revalue; 26 | } 27 | public override bool TableIndexAdd(string connstr, string databasename, string tablename, string columnname, string indexname) 28 | { 29 | bool revalue = false; 30 | try 31 | { 32 | StringBuilder sqlstr = new StringBuilder(); 33 | sqlstr.AppendFormat(" create index {0} on {1}.dbo.{2}({3}) ", indexname,databasename, tablename, columnname); 34 | int temp = CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr.ToString())); 35 | if (temp > 0) 36 | { 37 | revalue = true; 38 | } 39 | } 40 | catch 41 | { 42 | } 43 | return revalue; 44 | } 45 | public override bool TableIndexDel(string connstr, string tablename, string indexname) 46 | { 47 | bool revalue = false; 48 | try 49 | { 50 | StringBuilder sqlstr = new StringBuilder(); 51 | sqlstr.AppendFormat(" DROP INDEX {0}.{1} ", tablename, indexname); 52 | int temp = CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr.ToString())); 53 | if (temp > 0) 54 | { 55 | revalue = true; 56 | } 57 | } 58 | catch 59 | { 60 | } 61 | return revalue; 62 | } 63 | #endregion 64 | #region 操作表 65 | public override long TableStorageSize(string connstr, string tablename) 66 | { 67 | StringBuilder sqlstr = new StringBuilder(); 68 | sqlstr.Append("select SUM(used_pages)*8 size from "); 69 | sqlstr.AppendFormat(" (select object_id from sys.objects where name='{0}') t1", tablename); 70 | sqlstr.Append(" left join(select partition_id,object_id from sys.partitions) t2"); 71 | sqlstr.Append(" on t1.object_id=t2.object_id"); 72 | sqlstr.Append(" left join(select container_id,used_pages from sys.allocation_units) t3"); 73 | sqlstr.Append(" on t2.partition_id=t3.container_id"); 74 | return CommonHelper.ToLong(new SqlServerHelper().GetSingle(connstr, sqlstr.ToString())); 75 | } 76 | public override bool TableExists(string connstr, string dbname, string tablename) 77 | { 78 | bool revalue = false; 79 | string sqlstr = string.Format(@"select COUNT(0) from {0}.dbo.sysobjects where name='{1}'", dbname, tablename); 80 | if (CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr)) > 0) 81 | { 82 | revalue = true; 83 | } 84 | return revalue; 85 | } 86 | public override long TableCount(string connstr, string tablename) 87 | { 88 | long revalue = 0; 89 | string sqlstr = string.Format(" select sum(b.rows) as 记录条数 from sys.sysobjects a,sys.sysindexes b where a.name='{0}' and a.id=b.id and a.xtype='u' ", tablename); 90 | revalue = CommonHelper.ToLong(new SqlServerHelper().GetSingle(connstr, sqlstr)); 91 | return revalue; 92 | } 93 | #endregion 94 | #region 操作数据库 95 | public override long DatabaseStorageSizeAll(string connstr, string databaseprev) 96 | { 97 | StringBuilder sqlstr = new StringBuilder(); 98 | sqlstr.AppendFormat("select sum(size)*8 size from master..sysaltfiles where name like '{0}%'", databaseprev); 99 | return CommonHelper.ToLong(new SqlServerHelper().GetSingle(connstr, sqlstr.ToString())); 100 | } 101 | public override long DatabaseStorageSize(string connstr, string databasename) 102 | { 103 | StringBuilder sqlstr = new StringBuilder(); 104 | sqlstr.AppendFormat("select sum(size)*8 size from master..sysaltfiles where name like '{0}%'", databasename); 105 | return CommonHelper.ToLong(new SqlServerHelper().GetSingle(connstr, sqlstr.ToString())); 106 | } 107 | public override bool DatabaseExists(string connstr, string dbname) 108 | { 109 | bool revalue = false; 110 | string sqlstr = string.Format(@"select dbid from sysdatabases where name='{0}'", dbname); 111 | if (CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr)) > 0) 112 | { 113 | revalue = true; 114 | } 115 | return revalue; 116 | } 117 | public override bool DatabaseCreate(string connstr, string dbname, string dirpath) 118 | { 119 | bool revalue = false; 120 | string sqlstr = string.Format(@"create database {0} 121 | on primary( 122 | name='{0}', 123 | filename='{1}\{0}.mdf',size=5mb,maxsize=10gb,filegrowth=10% 124 | ) 125 | log on( 126 | name='{0}_log', 127 | filename='{1}\{0}_log.ldf',size=2mb,filegrowth=1mb 128 | );", dbname, dirpath); 129 | if (CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr)) > 0) 130 | { 131 | revalue = true; 132 | } 133 | return revalue; 134 | } 135 | public override void DatabaseDrop(string connstr, string dbname) 136 | { 137 | string sqlstr = string.Format(@"drop database {0}", dbname); 138 | new SqlServerHelper().ExecuteSql(connstr, sqlstr); 139 | } 140 | public override void DatabaseSHRINK(string connstr, string dbname) 141 | { 142 | string sqlstr = string.Format(@"DBCC SHRINKDATABASE({0})", dbname); 143 | new SqlServerHelper().GetSingle(connstr, sqlstr); 144 | } 145 | public override void DatabaseClearLog(string connstr, string dbname) 146 | { 147 | string sqlstr = string.Format(@"DBCC SHRINKFILE (N'{0}_Log' , 11, TRUNCATEONLY)", dbname); 148 | new SqlServerHelper().GetSingle(connstr, sqlstr); 149 | } 150 | public override void DatabaseSPAttach(string connstr, string dbname, string dbpath) 151 | { 152 | string sqlstr = string.Format("EXEC sp_attach_db @dbname = '{0}', @filename1 = '{1}\\{0}.mdf',@filename2= '{1}\\{0}_log.LDF'", dbname, dbpath); 153 | new SqlServerHelper().GetSingle(connstr, sqlstr); 154 | } 155 | public override void DatabaseSPDetach(string connstr, string dbname) 156 | { 157 | string sqlstr = string.Format("EXEC sp_detach_db @dbname = '{0}'", dbname); 158 | new SqlServerHelper().GetSingle(connstr, sqlstr); 159 | } 160 | #endregion 161 | #region 操作服务器 162 | public override bool ServerConnectionCheck(string connstr, string servername, string username, string userpwd, string databasename = "") 163 | { 164 | bool revalue = false; 165 | string conditiondb = ""; 166 | if (!string.IsNullOrEmpty(databasename)) 167 | { 168 | conditiondb = "-d " + databasename; 169 | } 170 | string sqlstr = string.Format(@" 171 | EXEC sp_configure 'show advanced options', 1;RECONFIGURE; 172 | EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE; 173 | declare @result int 174 | exec @result = master..xp_cmdshell 'osql -S {0} {3} -U {1} -P {2}',no_output 175 | select @result 176 | EXEC sp_configure 'show advanced options', 1;RECONFIGURE; 177 | EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE; 178 | ", servername, username, userpwd, conditiondb); 179 | if (CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr)) == 0) 180 | { 181 | revalue = true; 182 | } 183 | return revalue; 184 | } 185 | public override bool DirectoryExists(string connstr, string dirpath) 186 | { 187 | bool revalue = false; 188 | string sqlstr = string.Format(@"declare @cmdstr nvarchar(1000) 189 | set @cmdstr='dir {0}' 190 | exec sp_configure 'show advanced options', 1 191 | reconfigure 192 | exec sp_configure 'xp_cmdshell', 1 193 | reconfigure 194 | declare @n int; 195 | exec @n=xp_cmdshell @cmdstr,NO_OUTPUT 196 | IF (@n=0) 197 | select 1 198 | else 199 | select 0 200 | exec sp_configure 'show advanced options', 0 201 | reconfigure", dirpath); 202 | if (CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr)) == 1) 203 | { 204 | revalue = true; 205 | } 206 | return revalue; 207 | } 208 | public override bool DirectoryCreate(string connstr, string dirpath) 209 | { 210 | bool revalue = false; 211 | string sqlstr = string.Format(@"declare @cmdstr nvarchar(1000) 212 | set @cmdstr='mkdir {0}' 213 | exec sp_configure 'show advanced options', 1 214 | reconfigure 215 | exec sp_configure 'xp_cmdshell', 1 216 | reconfigure 217 | declare @n int; 218 | exec @n=xp_cmdshell @cmdstr,NO_OUTPUT 219 | IF (@n=0) 220 | select 1 221 | else 222 | select 0 223 | exec sp_configure 'show advanced options', 0 224 | reconfigure", dirpath); 225 | if (CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr)) == 1) 226 | { 227 | revalue = true; 228 | } 229 | return revalue; 230 | } 231 | public override bool DirectoryDrop(string connstr, string dirpath) 232 | { 233 | bool revalue = false; 234 | string sqlstr = string.Format(@"declare @cmdstr nvarchar(1000) 235 | set @cmdstr='rd {0}' 236 | exec sp_configure 'show advanced options', 1 237 | reconfigure 238 | exec sp_configure 'xp_cmdshell', 1 239 | reconfigure 240 | declare @n int; 241 | exec @n=xp_cmdshell @cmdstr,NO_OUTPUT 242 | IF (@n=0) 243 | select 1 244 | else 245 | select 0 246 | exec sp_configure 'show advanced options', 0 247 | reconfigure", dirpath); 248 | if (CommonHelper.ToInt(new SqlServerHelper().GetSingle(connstr, sqlstr)) == 1) 249 | { 250 | revalue = true; 251 | } 252 | return revalue; 253 | } 254 | public override void ServerCacheClear(string connstr) 255 | { 256 | string sqlstr = ("DBCC DROPCLEANBUFFERS;DBCC FREESESSIONCACHE;DBCC FREEPROCCACHE;DBCC FREESYSTEMCACHE('ALL');"); 257 | new SqlServerHelper().GetSingle(connstr, sqlstr); 258 | } 259 | #endregion 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/DBAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Data; 5 | using GOTO.BigDataAccess.DBSql.XmlModel; 6 | using GOTO.BigDataAccess.DBSql.Manager; 7 | using GOTO.BigDataAccess.DBSql.Access; 8 | 9 | namespace GOTO.BigDataAccess.DBSql 10 | { 11 | public class DBAction 12 | { 13 | public void testAddRow(SqlBaseItemXml basemodel) 14 | { 15 | try 16 | { 17 | ManagerConfig servicemanagerconfig = new ManagerConfig(); 18 | int writenum = 0; 19 | for (int i = 0; i < 100000000; i++) 20 | { 21 | DBPosition position = new DBPosition(); 22 | var getbool = position.GetPosition(basemodel); 23 | servicemanagerconfig.SaveConfigServer(basemodel); 24 | servicemanagerconfig.SaveConfigDatabase(basemodel); 25 | servicemanagerconfig.SaveConfigTable(basemodel); 26 | if (getbool) 27 | { 28 | var serveritem = DBConfig.GetServerItemXmlConfig(basemodel, position.currentservernumber); 29 | DBWrite.AddBulkRow(basemodel, serveritem, position.currentconnstrdatabase, testBulkRowData(basemodel, position.currenttable), position.currentdatabasenumber, position.currenttablenumber, basemodel.FieldIndexList); 30 | servicemanagerconfig.SaveConfigField(basemodel); 31 | Console.WriteLine("" + (++writenum)); 32 | } 33 | else 34 | { 35 | Console.WriteLine("请配置更多服务器后写入"); 36 | break; 37 | } 38 | } 39 | } 40 | catch (Exception ex) 41 | { 42 | Console.WriteLine(ex.Message); 43 | } 44 | } 45 | public DataTable testBulkRowData(SqlBaseItemXml basemodel,string tablename) 46 | { 47 | DataTable bulkdata = DBConfig.GetTableStruct(basemodel, tablename); 48 | Random random = new Random(); 49 | long rowmin = 0; 50 | long rowcurrent = 0; 51 | long rowmax = 0; 52 | int rownum = 10000; 53 | 54 | long rowidrrr = DBConfig.GetRowId(basemodel.Number); 55 | DBConfig.UpdateRowId(basemodel.Number,rownum); 56 | rowmin = rowidrrr + 1; 57 | rowmax = rowmin + rownum; 58 | rowcurrent = rowmin; 59 | for (int i = 0; i < rownum; i++) 60 | { 61 | DataRow newRow; 62 | newRow = bulkdata.NewRow(); 63 | #region 64 | newRow["id"] = rowcurrent++; 65 | newRow["num1"] = rowcurrent / 100000; 66 | newRow["num2"] = random.Next(10000); 67 | newRow["num3"] = random.NextDouble(); 68 | newRow["str11"] = tablename + i; 69 | #endregion 70 | bulkdata.Rows.Add(newRow); 71 | } 72 | return bulkdata; 73 | } 74 | public bool Update(SqlBaseItemXml basemodel, long rowid, Dictionary updatefieldlist) 75 | { 76 | var fieldmodel = DBConfig.GetFieldXmlConfig(basemodel).SqlFieldList.Where(m => m.FieldName == basemodel.PrimarykeyName && m.ValueMin <= rowid && m.ValueMax >= rowid).FirstOrDefault(); 77 | if (fieldmodel == null) 78 | return false; 79 | var servermodel = DBConfig.GetServerItemXmlConfig(basemodel, fieldmodel.ServerNumber); 80 | var databasemodel = DBConfig.GetDatabaseItemXmlConfig(basemodel, fieldmodel.DatabaseNumber); 81 | var tablemodel = DBConfig.GetTableItemXmlConfig(basemodel, fieldmodel.TableNumber); 82 | return DBProxyAction.Update(basemodel,rowid,servermodel,databasemodel,tablemodel, updatefieldlist); 83 | } 84 | public bool Delete(SqlBaseItemXml basemodel,long rowid) 85 | { 86 | bool revalue = false; 87 | bool changexml = false; 88 | var fieldmodel = DBConfig.GetFieldXmlConfig(basemodel).SqlFieldList.Where(m => m.FieldName == basemodel.PrimarykeyName && m.ValueMin <= rowid && m.ValueMax >= rowid).FirstOrDefault(); 89 | if (fieldmodel == null) 90 | return false; 91 | var servermodel = DBConfig.GetServerItemXmlConfig(basemodel, fieldmodel.ServerNumber); 92 | var databasemodel = DBConfig.GetDatabaseItemXmlConfig(basemodel, fieldmodel.DatabaseNumber); 93 | var tablemodel = DBConfig.GetTableItemXmlConfig(basemodel, fieldmodel.TableNumber); 94 | revalue= DBProxyAction.Delete(basemodel,rowid,servermodel,databasemodel,tablemodel,fieldmodel); 95 | if (revalue) 96 | { 97 | if (fieldmodel.ValueMin == rowid) 98 | { 99 | DBConfig.FieldRemove(basemodel, fieldmodel); 100 | fieldmodel.ValueMin = rowid + 1; 101 | DBConfig.FieldAdd(basemodel, fieldmodel); 102 | changexml = true; 103 | } 104 | else if(fieldmodel.ValueMax==rowid) 105 | { 106 | DBConfig.FieldRemove(basemodel, fieldmodel); 107 | fieldmodel.ValueMax = rowid - 1; 108 | DBConfig.FieldAdd(basemodel, fieldmodel); 109 | changexml = true; 110 | } 111 | } 112 | if (changexml) 113 | { 114 | new ManagerConfig().SaveConfigField(basemodel); 115 | } 116 | return revalue; 117 | } 118 | public bool SqlBaseClear(SqlBaseItemXml basemodel) 119 | { 120 | bool revalue = false; 121 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 122 | if (serverlist != null) 123 | { 124 | foreach (var serveritem in serverlist) 125 | { 126 | string connstr = DBProxyAction.GetConnStr(basemodel, serveritem); 127 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel,serveritem.Number); 128 | if (databaselist != null) 129 | { 130 | foreach (var databaseitem in databaselist) 131 | { 132 | DBProxy.GetDBAccess(serveritem.DBType).DatabaseDrop(connstr, databaseitem.DatabaseName); 133 | } 134 | } 135 | } 136 | ManagerConfig servermanagerconfig = new ManagerConfig(); 137 | //servermanagerconfig.InitServerXml(basemodel); 138 | servermanagerconfig.InitDatabaseXml(basemodel); 139 | servermanagerconfig.InitTableXml(basemodel); 140 | servermanagerconfig.InitFieldXml(basemodel); 141 | } 142 | return revalue; 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/DBConfig.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.XmlModel; 2 | using GOTO.BigDataAccess.RedisConfig; 3 | using GOTO.Common; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Data; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | namespace GOTO.BigDataAccess.DBSql 12 | { 13 | public static class DBConfig 14 | { 15 | public static string sqlbasexmlpath = CommonHelper.ToStr(ConfigurationManager.AppSettings["SqlBaseConfigPath"]); 16 | private static SqlBaseXml listbasexmlconfig = null; 17 | private static Dictionary listserverxmlconfig = new Dictionary(); 18 | private static Dictionary listdatabasexmlconfig = new Dictionary(); 19 | private static Dictionary listtablexmlconfig = new Dictionary(); 20 | private static Dictionary listfieldxmlconfig = new Dictionary(); 21 | #region getobject 22 | public static SqlBaseItemXml GetBaseXmlConfig(long number, string DatabasePrev=null) 23 | { 24 | SqlBaseItemXml model =null; 25 | if (listbasexmlconfig == null) 26 | { 27 | listbasexmlconfig = LoadSqlBaseXmlConfig(sqlbasexmlpath); 28 | } 29 | if (number > 0) 30 | { 31 | model = listbasexmlconfig.SqlBaseList.Where(m => m.Number == number).FirstOrDefault(); 32 | } 33 | if (model==null&&!string.IsNullOrEmpty(DatabasePrev)) 34 | { 35 | model = listbasexmlconfig.SqlBaseList.Where(m => m.DatabasePrev == DatabasePrev).FirstOrDefault(); 36 | } 37 | return model; 38 | } 39 | public static SqlServerXml GetServerXmlConfig(SqlBaseItemXml basemodel) 40 | { 41 | if (!listserverxmlconfig.ContainsKey(basemodel.Number)) 42 | { 43 | listserverxmlconfig.Add(basemodel.Number, LoadSqlServerXmlConfig(basemodel.ServerFilePath)); 44 | } 45 | return listserverxmlconfig[basemodel.Number]; 46 | } 47 | public static SqlDatabaseXml GetDatabaseXmlConfig(SqlBaseItemXml basemodel) 48 | { 49 | if (!listdatabasexmlconfig.ContainsKey(basemodel.Number)) 50 | { 51 | listdatabasexmlconfig.Add(basemodel.Number, LoadSqlDatabaseXmlConfig(basemodel.DatabaseFilePath)); 52 | } 53 | return listdatabasexmlconfig[basemodel.Number]; 54 | } 55 | public static SqlTableXml GetTableXmlConfig(SqlBaseItemXml basemodel) 56 | { 57 | if (!listtablexmlconfig.ContainsKey(basemodel.Number)) 58 | { 59 | listtablexmlconfig.Add(basemodel.Number, LoadSqlTableXmlConfig(basemodel.TableFilePath)); 60 | } 61 | return listtablexmlconfig[basemodel.Number]; 62 | } 63 | public static SqlFieldXml GetFieldXmlConfig(SqlBaseItemXml basemodel) 64 | { 65 | if (!listfieldxmlconfig.ContainsKey(basemodel.Number)) 66 | { 67 | listfieldxmlconfig.Add(basemodel.Number, LoadSqlFieldXmlConfig(basemodel.FieldFilePath)); 68 | } 69 | return listfieldxmlconfig[basemodel.Number]; 70 | } 71 | 72 | public static List GetServerItemXmlConfigList(SqlBaseItemXml basemodel, bool IsUse = true) 73 | { 74 | return DBConfig.GetServerXmlConfig(basemodel).SqlServerList.Where(m => m.IsUse == IsUse).ToList(); 75 | } 76 | public static List GetDatabaseItemXmlConfigList(SqlBaseItemXml basemodel, long ServerNumber, bool IsUse = true) 77 | { 78 | return DBConfig.GetDatabaseXmlConfig(basemodel).SqlDatabaseList.Where(m => m.IsUse == IsUse && m.ServerNumber == ServerNumber).ToList(); 79 | } 80 | public static List GetTableItemXmlConfigList(SqlBaseItemXml basemodel,long DatabaseNumber, bool IsUse = true) 81 | { 82 | return DBConfig.GetTableXmlConfig(basemodel).SqlTableList.Where(m => m.IsUse == IsUse&&m.DataBaseNumber==DatabaseNumber).ToList(); 83 | } 84 | public static List GetFieldItemXmlConfigList(SqlBaseItemXml basemodel,long TableNumber, bool IsDelete = false) 85 | { 86 | return DBConfig.GetFieldXmlConfig(basemodel).SqlFieldList.Where(m => m.IsDelete == IsDelete && m.TableNumber == TableNumber).ToList(); 87 | } 88 | 89 | public static SqlServerItemXml GetServerItemXmlConfig(SqlBaseItemXml basemodel,long Number, bool IsUse = true) 90 | { 91 | return DBConfig.GetServerXmlConfig(basemodel).SqlServerList.Where(m => m.IsUse == IsUse && m.Number == Number).FirstOrDefault(); 92 | } 93 | public static SqlDatabaseItemXml GetDatabaseItemXmlConfig(SqlBaseItemXml basemodel, long Number, bool IsUse = true) 94 | { 95 | return DBConfig.GetDatabaseXmlConfig(basemodel).SqlDatabaseList.Where(m => m.IsUse == IsUse && m.Number == Number).FirstOrDefault(); 96 | } 97 | public static SqlTableItemXml GetTableItemXmlConfig(SqlBaseItemXml basemodel, long Number, bool IsUse = true) 98 | { 99 | return DBConfig.GetTableXmlConfig(basemodel).SqlTableList.Where(m => m.IsUse == IsUse && m.Number == Number).FirstOrDefault(); 100 | } 101 | public static SqlFieldItemXml GetFieldItemXmlConfig(SqlBaseItemXml basemodel, long Number, bool IsDelete = false) 102 | { 103 | return DBConfig.GetFieldXmlConfig(basemodel).SqlFieldList.Where(m => m.IsDelete == IsDelete && m.Number == Number).FirstOrDefault(); 104 | } 105 | #endregion 106 | 107 | 108 | 109 | #region Reloadobject 110 | public static SqlServerXml ReloadServerXmlConfig(SqlBaseItemXml basemodel) 111 | { 112 | listserverxmlconfig[basemodel.Number] = LoadSqlServerXmlConfig(basemodel.ServerFilePath); 113 | return listserverxmlconfig[basemodel.Number]; 114 | } 115 | public static SqlDatabaseXml ReloadDatabaseXmlConfig(SqlBaseItemXml basemodel) 116 | { 117 | listdatabasexmlconfig[basemodel.Number] = LoadSqlDatabaseXmlConfig(basemodel.DatabaseFilePath); 118 | return listdatabasexmlconfig[basemodel.Number]; 119 | } 120 | public static SqlTableXml ReloadTableXmlConfig(SqlBaseItemXml basemodel) 121 | { 122 | listtablexmlconfig[basemodel.Number] = LoadSqlTableXmlConfig(basemodel.TableFilePath); 123 | return listtablexmlconfig[basemodel.Number]; 124 | } 125 | public static SqlFieldXml ReloadFieldXmlConfig(SqlBaseItemXml basemodel) 126 | { 127 | listfieldxmlconfig[basemodel.Number] = LoadSqlFieldXmlConfig(basemodel.FieldFilePath); 128 | return listfieldxmlconfig[basemodel.Number]; 129 | } 130 | #endregion 131 | #region loadobject 132 | public static SqlBaseXml LoadSqlBaseXmlConfig(string filepath) 133 | { 134 | var servercontent = FileHelper.FileToString(filepath, Encoding.UTF8); 135 | return XMLSerilizable.XMLToObject(servercontent, Encoding.UTF8); 136 | } 137 | public static SqlServerXml LoadSqlServerXmlConfig(string filepath) 138 | { 139 | var servercontent = FileHelper.FileToString(filepath, Encoding.UTF8); 140 | return XMLSerilizable.XMLToObject(servercontent, Encoding.UTF8); 141 | } 142 | public static SqlDatabaseXml LoadSqlDatabaseXmlConfig(string filepath) 143 | { 144 | var databasecontent = FileHelper.FileToString(filepath, Encoding.UTF8); 145 | return XMLSerilizable.XMLToObject(databasecontent, Encoding.UTF8); 146 | } 147 | public static SqlTableXml LoadSqlTableXmlConfig(string filepath) 148 | { 149 | var tablecontent = FileHelper.FileToString(filepath, Encoding.UTF8); 150 | return XMLSerilizable.XMLToObject(tablecontent, Encoding.UTF8); 151 | } 152 | public static SqlFieldXml LoadSqlFieldXmlConfig(string filepath) 153 | { 154 | var fieldcontent = FileHelper.FileToString(filepath, Encoding.UTF8); 155 | return XMLSerilizable.XMLToObject(fieldcontent, Encoding.UTF8); 156 | } 157 | #endregion 158 | #region getnumber 159 | public static long GetRowId(long basenumber) 160 | { 161 | return CommonHelper.ToLong(RedisConfigService.Get(RedisConfigKey.keysqlserverdatarowid+basenumber)); 162 | } 163 | public static bool UpdateRowId(long basenumber, int updaterownum) 164 | { 165 | long rowidrrr = GetRowId(basenumber); 166 | return RedisConfigService.Set(RedisConfigKey.keysqlserverdatarowid + basenumber, (rowidrrr + updaterownum).ToString()); 167 | } 168 | 169 | public static long GetBaseNumber 170 | { 171 | get { return DateTime.Now.Ticks; } 172 | } 173 | public static long GetServerNumber 174 | { 175 | get { return DateTime.Now.Ticks; } 176 | } 177 | public static long GetDatabaseNumber 178 | { 179 | get { return DateTime.Now.Ticks; } 180 | } 181 | public static long GetTableNumber 182 | { 183 | get { return DateTime.Now.Ticks; } 184 | } 185 | public static long GetFieldNumber 186 | { 187 | get { return DateTime.Now.Ticks; } 188 | } 189 | #endregion 190 | public static string GetTableSql(SqlBaseItemXml basemodel,string tablename) 191 | { 192 | string restr = ""; 193 | //StringBuilder sqlstr = new StringBuilder(); 194 | //sqlstr.Append("CREATE TABLE {0}("); 195 | //sqlstr.Append(" [id] [bigint] primary key ,"); 196 | //sqlstr.Append(" [num1] [int] NULL,"); 197 | //sqlstr.Append(" [num2] [bigint] NULL,"); 198 | //sqlstr.Append(" [num3] [float] NULL,"); 199 | //sqlstr.Append(" [str11] [nvarchar](50) NULL,"); 200 | //sqlstr.Append(" [createdate] [datetime] default getdate(),"); 201 | //sqlstr.Append(" [isdelete] [bit] default 0);"); 202 | //FileHelper.WriteText(SqlServerConfig.SqlBaseXmlConfig.TableSqlFilePath, sqlstr.ToString()); 203 | string strcontent = FileHelper.FileToString(basemodel.TableSqlFilePath, Encoding.UTF8); 204 | restr = string.Format(strcontent, tablename); 205 | return restr; 206 | } 207 | public static DataTable GetTableStruct(SqlBaseItemXml basemodel, string tablename) 208 | { 209 | DataTable bulkdata = new DataTable(); 210 | //bulkdata.TableName = tablename; 211 | //#region 212 | //bulkdata.Columns.Add("id", typeof(long)); 213 | //bulkdata.Columns.Add("num1", typeof(int)); 214 | //bulkdata.Columns.Add("num2", typeof(long)); 215 | //bulkdata.Columns.Add("num3", typeof(double)); 216 | //bulkdata.Columns.Add("str11", typeof(string)); 217 | //#endregion 218 | //var t1 = XMLSerilizable.ObjectToXML(bulkdata); 219 | //FileHelper.WriteText(SqlServerConfig.SqlBaseXmlConfig.TableStructFilePath, t1); 220 | 221 | var fieldcontent = FileHelper.FileToString(basemodel.TableStructFilePath, Encoding.UTF8); 222 | bulkdata = XMLSerilizable.XMLToObject(fieldcontent, Encoding.UTF8); 223 | bulkdata.TableName = tablename; 224 | return bulkdata; 225 | } 226 | #region changelist 227 | public static void ServerRemove(SqlBaseItemXml basemodel, SqlServerItemXml item) 228 | { 229 | var templist = DBConfig.listserverxmlconfig[basemodel.Number]; 230 | templist.SqlServerList.Remove(item); 231 | DBConfig.listserverxmlconfig[basemodel.Number] = templist; 232 | } 233 | public static void ServerAdd(SqlBaseItemXml basemodel, SqlServerItemXml item) 234 | { 235 | var templist = DBConfig.listserverxmlconfig[basemodel.Number]; 236 | templist.SqlServerList.Add(item); 237 | DBConfig.listserverxmlconfig[basemodel.Number] = templist; 238 | } 239 | public static void DatabaseRemove(SqlBaseItemXml basemodel, SqlDatabaseItemXml item) 240 | { 241 | var templist = DBConfig.listdatabasexmlconfig[basemodel.Number]; 242 | templist.SqlDatabaseList.Remove(item); 243 | DBConfig.listdatabasexmlconfig[basemodel.Number] = templist; 244 | } 245 | public static void DatabaseAdd(SqlBaseItemXml basemodel, SqlDatabaseItemXml item) 246 | { 247 | var templist = DBConfig.listdatabasexmlconfig[basemodel.Number]; 248 | templist.SqlDatabaseList.Add(item); 249 | DBConfig.listdatabasexmlconfig[basemodel.Number] = templist; 250 | } 251 | public static void TableRemove(SqlBaseItemXml basemodel, SqlTableItemXml item) 252 | { 253 | var templist = DBConfig.listtablexmlconfig[basemodel.Number]; 254 | templist.SqlTableList.Remove(item); 255 | DBConfig.listtablexmlconfig[basemodel.Number] = templist; 256 | } 257 | public static void TableAdd(SqlBaseItemXml basemodel, SqlTableItemXml item) 258 | { 259 | var templist = DBConfig.listtablexmlconfig[basemodel.Number]; 260 | templist.SqlTableList.Add(item); 261 | DBConfig.listtablexmlconfig[basemodel.Number] = templist; 262 | } 263 | 264 | public static void FieldRemove(SqlBaseItemXml basemodel, SqlFieldItemXml item) 265 | { 266 | var templist = DBConfig.listfieldxmlconfig[basemodel.Number]; 267 | templist.SqlFieldList.Remove(item); 268 | DBConfig.listfieldxmlconfig[basemodel.Number] = templist; 269 | } 270 | public static void FieldAdd(SqlBaseItemXml basemodel, SqlFieldItemXml item) 271 | { 272 | var templist = DBConfig.listfieldxmlconfig[basemodel.Number]; 273 | templist.SqlFieldList.Add(item); 274 | DBConfig.listfieldxmlconfig[basemodel.Number] = templist; 275 | } 276 | #endregion 277 | } 278 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/DBPosition.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Access; 2 | using GOTO.BigDataAccess.DBSql.Manager; 3 | using GOTO.BigDataAccess.DBSql.XmlModel; 4 | using System; 5 | using System.Linq; 6 | 7 | namespace GOTO.BigDataAccess.DBSql 8 | { 9 | public class DBPosition 10 | { 11 | public string currentconnstrserver = ""; 12 | public string currentconnstrdatabase = ""; 13 | public string currentserver = ""; 14 | public long currentservernumber = 0; 15 | public string currentdatabase = ""; 16 | public long currentdatabasenumber = 0; 17 | public string currenttable = ""; 18 | public long currenttablenumber = 0; 19 | public bool isposition = false; 20 | public string msg = "请添加更多的服务器资源"; 21 | public bool GetPosition(SqlBaseItemXml basemodel) 22 | { 23 | return GetServer(basemodel); 24 | } 25 | public bool GetServer(SqlBaseItemXml basemodel) 26 | { 27 | var templist = DBConfig.GetServerXmlConfig(basemodel).SqlServerList.Where(m => m.IsUse == true && m.IsWrite == true).ToList(); 28 | foreach (SqlServerItemXml item in templist) 29 | { 30 | long currentStorageSize = 0; 31 | currentserver = item.ServerName; 32 | currentservernumber = item.Number; 33 | currentconnstrserver = DBProxyAction.GetConnStr(basemodel,item); 34 | try 35 | { 36 | currentStorageSize = DBProxy.GetDBAccess(item.DBType).DatabaseStorageSizeAll(currentconnstrserver, basemodel.DatabasePrev); 37 | } 38 | catch (Exception ex) 39 | { 40 | Console.WriteLine("error:" + ex.Message); 41 | new ManagerConfig().ServerChangeIsUse(item); 42 | return false; 43 | } 44 | if ((item.StorageSize - item.RetainStorageSize) > currentStorageSize) 45 | { 46 | if (GetDatabase(basemodel,item)) 47 | return isposition; 48 | } 49 | else 50 | { 51 | new ManagerConfig().ServerChangeIsWrite(item); 52 | } 53 | } 54 | return false; 55 | } 56 | public bool GetDatabase(SqlBaseItemXml basemodel,SqlServerItemXml item) 57 | { 58 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel,item.Number); 59 | var databaselist2 = databaselist.Where(m => m.IsUse == true && m.IsWrite == true).ToList(); 60 | foreach (var item2 in databaselist2) 61 | { 62 | currentdatabase = item2.DatabaseName; 63 | currentdatabasenumber = item2.Number; 64 | currentconnstrdatabase = DBProxyAction.GetConnStr(basemodel, item, item2); 65 | var temp2 = DBProxy.GetDBAccess(item.DBType).DatabaseStorageSize(currentconnstrdatabase, item2.DatabaseName); 66 | var temp2count = DBConfig.GetTableXmlConfig(basemodel).SqlTableList.Where(m => m.DataBaseNumber == item2.Number).Count(); 67 | if (item2.StorageSize > temp2 && item2.TableNum >= temp2count && GetTable(basemodel,item, item2)) 68 | { 69 | return isposition; 70 | } 71 | else 72 | { 73 | new ManagerConfig().DatabaseChangeIsWrite(item2); 74 | } 75 | } 76 | if (item.DatabaseNum > databaselist.Count() && item.IsCreate) 77 | { 78 | var tempdata = DBWrite.AddDatabase(currentconnstrserver, item); 79 | currentdatabase = tempdata.DatabaseName; 80 | currentdatabasenumber = tempdata.Number; 81 | currentconnstrdatabase = DBProxyAction.GetConnStr(basemodel, item, tempdata); 82 | var temptable = DBWrite.AddTable(currentconnstrdatabase, item, tempdata); 83 | currenttable = temptable.TableName; 84 | currenttablenumber = temptable.Number; 85 | isposition = true; 86 | return isposition; 87 | } 88 | else 89 | { 90 | new ManagerConfig().ServerChangeIsWrite(item); 91 | } 92 | 93 | return isposition; 94 | } 95 | public bool GetTable(SqlBaseItemXml basemodel,SqlServerItemXml item, SqlDatabaseItemXml item2) 96 | { 97 | var tablelist = DBConfig.GetTableItemXmlConfigList(basemodel,item2.Number); 98 | var tablelist2 = tablelist.Where(m => m.IsUse == true && m.IsWrite == true).ToList(); 99 | foreach (var tableobjectitem2 in tablelist2) 100 | { 101 | var temp3 = DBProxy.GetDBAccess(item.DBType).TableStorageSize(currentconnstrdatabase, tableobjectitem2.TableName); 102 | var temp3count = DBProxy.GetDBAccess(item.DBType).TableCount(currentconnstrdatabase, tableobjectitem2.TableName); 103 | if (tableobjectitem2.StorageSize > temp3 && tableobjectitem2.RowNum > temp3count) 104 | { 105 | currenttable = tableobjectitem2.TableName; 106 | currenttablenumber = tableobjectitem2.Number; 107 | isposition = true; 108 | return isposition; 109 | } 110 | else 111 | { 112 | new ManagerConfig().TableChangeIsWrite(tableobjectitem2); 113 | } 114 | } 115 | if (item2.TableNum > tablelist.Count() && item2.IsCreate) 116 | { 117 | var temptable = DBWrite.AddTable(currentconnstrdatabase, item, item2); 118 | currenttable = temptable.TableName; 119 | currenttablenumber = temptable.Number; 120 | isposition = true; 121 | return isposition; 122 | } 123 | return isposition; 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/DBRead.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Access; 2 | using GOTO.BigDataAccess.DBSql.Model; 3 | using GOTO.BigDataAccess.DBSql.XmlModel; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Data; 7 | using System.Linq; 8 | 9 | namespace GOTO.BigDataAccess.DBSql 10 | { 11 | public class DBRead 12 | { 13 | public long GetAllCount(SqlBaseItemXml basemodel,ref long sqlnum) 14 | { 15 | return DBProxyAction.GetAllCount(basemodel,ref sqlnum); 16 | } 17 | public long GetAllCount2(SqlBaseItemXml basemodel,ref long sqlnum) 18 | { 19 | return DBProxyAction.GetAllCount2(basemodel, ref sqlnum); 20 | } 21 | public long GetCount(SqlBaseItemXml basemodel,ConditionFieldModel condition, ref long sqlnum) 22 | { 23 | sqlnum = 0; 24 | long rownum = 0; 25 | DataTable dt = new DataTable(); 26 | DBRule serverrule=new DBRule(); 27 | List serverlist = serverrule.GetMatchServer(basemodel,condition); 28 | if (serverlist != null && serverlist.Count > 0) 29 | { 30 | List taskdataparam = new List(); 31 | foreach (var item in serverlist) 32 | { 33 | var servermodel = DBConfig.GetServerItemXmlConfig(basemodel,item.ServerNumber); 34 | if (servermodel != null) 35 | { 36 | TaskDataParam tempparam = new TaskDataParam(); 37 | tempparam.servername = servermodel.ServerName; 38 | tempparam.dbtype = servermodel.DBType; 39 | tempparam.connstr = DBProxyAction.GetConnStr(basemodel, servermodel); 40 | tempparam.sqlstr = DBProxyAction.GetSqlCount(servermodel, item, condition); 41 | taskdataparam.Add(tempparam); 42 | } 43 | } 44 | DBTask servicetask = new DBTask(); 45 | Console.WriteLine("满足条件的数据库表:"+taskdataparam.Count); 46 | rownum = servicetask.SyncTaskManagerSum(taskdataparam, 50,false); 47 | sqlnum = servicetask.runnumcurrent; 48 | } 49 | return rownum; 50 | } 51 | public DataTable GetList(SqlBaseItemXml basemodel,ConditionFieldModel condition, ref long sqlnum) 52 | { 53 | sqlnum = 0; 54 | long getmaxnum = 500; 55 | long getrowcount = 0; 56 | DataTable dt = new DataTable(); 57 | DBRule serverrule = new DBRule(); 58 | List serverlist = serverrule.GetMatchServer(basemodel, condition); 59 | 60 | if (serverlist != null && serverlist.Count > 0) 61 | { 62 | List taskdataparam = new List(); 63 | foreach (var item in serverlist) 64 | { 65 | var servermodel = DBConfig.GetServerItemXmlConfig(basemodel, item.ServerNumber); 66 | if (servermodel != null) 67 | { 68 | TaskDataParam tempparam = new TaskDataParam(); 69 | tempparam.servername = servermodel.ServerName; 70 | tempparam.dbtype = servermodel.DBType; 71 | tempparam.connstr = DBProxyAction.GetConnStr(basemodel,servermodel); 72 | tempparam.sqlstr = DBProxyAction.GetSqlList(servermodel, item, condition, getmaxnum); 73 | taskdataparam.Add(tempparam); 74 | } 75 | } 76 | Console.WriteLine("满足条件的数据库表:" + taskdataparam.Count); 77 | foreach (var itemparam in taskdataparam) 78 | { 79 | Console.WriteLine("访问服务器:"+itemparam.servername); 80 | var dttemp =DBProxy.GetDBHelper(itemparam.dbtype).GetDataDable(itemparam.connstr, itemparam.sqlstr); 81 | sqlnum++; 82 | if (dttemp != null && dttemp.Rows.Count>0) 83 | { 84 | var dttempcount = dttemp.Rows.Count; 85 | if (getrowcount>0) 86 | { 87 | foreach (DataRow dtrow in dttemp.Rows) 88 | { 89 | if (getrowcount >= getmaxnum) 90 | { 91 | return dt; 92 | } 93 | getrowcount++; 94 | DataRow r = dt.NewRow(); 95 | r.ItemArray = dtrow.ItemArray; 96 | dt.Rows.Add(r); 97 | 98 | } 99 | } 100 | else 101 | { 102 | getrowcount = dttemp.Rows.Count; 103 | dt = dttemp; 104 | } 105 | } 106 | if (getrowcount >= getmaxnum) 107 | { 108 | return dt; 109 | } 110 | } 111 | } 112 | return dt; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/DBRule.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Model; 2 | using GOTO.BigDataAccess.DBSql.XmlModel; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace GOTO.BigDataAccess.DBSql 7 | { 8 | public class DBRule 9 | { 10 | public List GetMatchServer(SqlBaseItemXml basemodel,ConditionFieldModel conditionfield) 11 | { 12 | int matchnum = 0; 13 | List ServerList = new List(); 14 | List fieldlist = new List(); 15 | if (conditionfield != null && conditionfield.List != null && conditionfield.List.Count > 0) 16 | { 17 | List templist = new List(); 18 | foreach (var condition in conditionfield.List) 19 | { 20 | long valuemin = condition.ValueMin; 21 | long valuemax = condition.ValueMax; 22 | if (matchnum<1) 23 | { 24 | var tempfieldlist = DBConfig.GetFieldXmlConfig(basemodel).SqlFieldList.Where(m => m.FieldName == condition.FieldName).ToList(); 25 | foreach (var item in tempfieldlist) 26 | { 27 | if (GetMatchValid(item, condition.ValueMin, condition.ValueMax)) 28 | { 29 | ServerList.Add(GetMatchObject(item)); 30 | } 31 | } 32 | } 33 | else 34 | { 35 | int conditionvalidnum = 0; 36 | foreach(var serverlist in ServerList.ToList()) 37 | { 38 | var tempfield = DBConfig.GetFieldXmlConfig(basemodel).SqlFieldList.Where(m => m.TableNumber == serverlist.TableNumber && m.FieldName == condition.FieldName).ToList(); 39 | if (tempfield != null) 40 | { 41 | foreach (var itemfield in tempfield) 42 | { 43 | if (GetMatchValid(itemfield, condition.ValueMin, condition.ValueMax)) 44 | { 45 | conditionvalidnum++; 46 | break; 47 | } 48 | } 49 | } 50 | if (conditionvalidnum < 1) 51 | { 52 | ServerList.Remove(serverlist); 53 | } 54 | } 55 | } 56 | 57 | matchnum++; 58 | 59 | } 60 | } 61 | 62 | return ServerList; 63 | } 64 | private bool GetMatchValid(SqlFieldItemXml item, long valuemin, long valuemax) 65 | { 66 | bool revalue = false; 67 | if ((item.ValueMin <= valuemin && item.ValueMax >= valuemin) || (item.ValueMin <= valuemax && item.ValueMax >= valuemax) || 68 | (valuemin <= item.ValueMin && valuemax >= item.ValueMin) || (valuemin <= item.ValueMax && valuemax >= item.ValueMax)) 69 | { 70 | revalue = true; 71 | } 72 | return revalue; 73 | } 74 | private MatchServerList GetMatchObject(SqlFieldItemXml item) 75 | { 76 | MatchServerList temp = new MatchServerList(); 77 | temp.ServerNumber = item.ServerNumber; 78 | temp.DatabaseNumber = item.DatabaseNumber; 79 | temp.TableNumber = item.TableNumber; 80 | return temp; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/DBTask.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Access; 2 | using GOTO.BigDataAccess.DBSql.Model; 3 | using GOTO.Common; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace GOTO.BigDataAccess.DBSql 11 | { 12 | public class DBTask 13 | { 14 | int runnumold = 0; 15 | public int runnumcurrent = 0; 16 | private volatile int ThreadRunNum; 17 | object ThreadRunNumlockThis = new object(); 18 | public int Threadrunnum 19 | { 20 | get { return ThreadRunNum; } 21 | set 22 | { 23 | lock (ThreadRunNumlockThis) 24 | { 25 | ThreadRunNum = value; 26 | } 27 | } 28 | } 29 | private int ThreadNum; 30 | object ThreadNumlockThis = new object(); 31 | public int Threadnum 32 | { 33 | get { return ThreadNum; } 34 | set 35 | { 36 | lock (ThreadNumlockThis) 37 | { 38 | ThreadNum = value; 39 | } 40 | } 41 | } 42 | public long rowcount = 0; 43 | public long SyncTaskManagerSum(List taskdata, int tasknum = 20, bool IsFreeCache=true) 44 | { 45 | List> listtask = new List>(); 46 | runnumold = taskdata.Count; 47 | runnumcurrent = 0; 48 | while (runnumold > runnumcurrent) 49 | { 50 | listtask.Clear(); 51 | if (IsFreeCache) 52 | { 53 | var tempmodel = taskdata[runnumcurrent]; 54 | DBProxy.GetDBAccess(tempmodel.dbtype).ServerCacheClear(tempmodel.connstr); 55 | } 56 | for (int i = 1; (i < tasknum) && (runnumold > runnumcurrent); i++) 57 | { 58 | Task t = new Task(n => SyncTaskSum((TaskDataParam)n), taskdata[runnumcurrent++]); 59 | t.Start(); 60 | listtask.Add(t); 61 | } 62 | rowcount += listtask.Sum(m => m.Result); 63 | } 64 | Console.WriteLine("执行完成:" + rowcount); 65 | return rowcount; 66 | } 67 | public long SyncTaskSum(TaskDataParam model) 68 | { 69 | long revalue = CommonHelper.ToLong(DBProxy.GetDBHelper(model.dbtype).GetSingle(model.connstr, model.sqlstr)); 70 | if (revalue < 1) 71 | { 72 | ; 73 | } 74 | Threadrunnum++; 75 | Console.WriteLine("线程执行" + Threadrunnum + ",总数:" + revalue + ",服务器名:" + model.servername); 76 | return revalue; 77 | } 78 | public long SyncThreadPoolManagerSum(List taskdata, int tasknum = 20,bool IsFreeCache=true) 79 | { 80 | runnumold = taskdata.Count; 81 | runnumcurrent = 0; 82 | while (runnumold > runnumcurrent) 83 | { 84 | if (IsFreeCache) 85 | { 86 | var tempmodel = taskdata[runnumcurrent]; 87 | DBProxy.GetDBAccess(tempmodel.dbtype).ServerCacheClear(tempmodel.connstr); 88 | } 89 | for (int i = 1; (i < tasknum) && (runnumold > runnumcurrent); i++) 90 | { 91 | Threadnum++; 92 | ThreadPool.QueueUserWorkItem(SyncThreadPoolSum, taskdata[runnumcurrent++]); 93 | } 94 | while (Threadrunnum < (Threadnum - 1)) 95 | { 96 | Thread.Sleep(50); 97 | } 98 | } 99 | 100 | Console.WriteLine("执行完成:" + rowcount); 101 | return rowcount; 102 | } 103 | private void SyncThreadPoolSum(object model) 104 | { 105 | TaskDataParam dataparam = model as TaskDataParam; 106 | long revalue = CommonHelper.ToLong(DBProxy.GetDBHelper(dataparam.dbtype).GetSingle(dataparam.connstr, dataparam.sqlstr)); 107 | Threadrunnum++; 108 | Console.WriteLine("线程执行" + Threadrunnum + ",总数:" + revalue + "," + dataparam.sqlstr); 109 | rowcount += revalue; 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/DBWrite.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Linq; 5 | using GOTO.BigDataAccess.DBSql.XmlModel; 6 | using GOTO.Common; 7 | using GOTO.BigDataAccess.DBSql.Access; 8 | 9 | namespace GOTO.BigDataAccess.DBSql 10 | { 11 | public class DBWrite 12 | { 13 | public static SqlDatabaseItemXml AddDatabase(string currentconnstrserver, SqlServerItemXml item) 14 | { 15 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 16 | SqlDatabaseItemXml databasetempmodel = new SqlDatabaseItemXml(); 17 | databasetempmodel.BaseNumber = item.BaseNumber; 18 | databasetempmodel.ServerNumber = item.Number; 19 | databasetempmodel.Number = DBConfig.GetDatabaseNumber; 20 | databasetempmodel.DatabaseName = basemodel.DatabasePrev + databasetempmodel.Number; 21 | databasetempmodel.StorageSize = ((item.StorageSize - item.StorageSize / 5) - item.RetainStorageSize) / 10; 22 | databasetempmodel.TableNum = basemodel.DefaultTableNum; 23 | databasetempmodel.IsWrite = true; 24 | databasetempmodel.IsUse = true; 25 | databasetempmodel.IsCreate = true; 26 | databasetempmodel.StorageDirectory = item.StorageDirectory; 27 | DBConfig.DatabaseAdd(basemodel, databasetempmodel); 28 | 29 | DBProxy.GetDBAccess(item.DBType).DatabaseCreate(currentconnstrserver, databasetempmodel.DatabaseName, databasetempmodel.StorageDirectory); 30 | return databasetempmodel; 31 | } 32 | public static SqlTableItemXml AddTable(string currentconnstr, SqlServerItemXml item, SqlDatabaseItemXml item2) 33 | { 34 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 35 | SqlTableItemXml tabletempmodel = new SqlTableItemXml(); 36 | tabletempmodel.BaseNumber = item.BaseNumber; 37 | tabletempmodel.ServerNumber = item.Number; 38 | tabletempmodel.DataBaseNumber = item2.Number; 39 | tabletempmodel.Number = DBConfig.GetTableNumber; 40 | tabletempmodel.TableName = basemodel.TablePrev + tabletempmodel.Number; 41 | tabletempmodel.IsWrite = true; 42 | tabletempmodel.IsUse = true; 43 | tabletempmodel.RowNum = basemodel.DefaultTableRowNum; 44 | tabletempmodel.StorageSize = (item2.StorageSize - item2.StorageSize / 5) / item2.TableNum; 45 | DBConfig.TableAdd(basemodel, tabletempmodel); 46 | DBProxy.GetDBHelper(item.DBType).ExecuteSql(currentconnstr, DBConfig.GetTableSql(basemodel, tabletempmodel.TableName)); 47 | return tabletempmodel; 48 | } 49 | 50 | public static void AddBulkRow(SqlBaseItemXml basemodel, SqlServerItemXml servermodel, string connstr, DataTable bulkdata, long databasenumber, long tablenumber, List fieldtotal) 51 | { 52 | if (fieldtotal != null && fieldtotal.Count > 0) 53 | { 54 | var fieldlist = DBConfig.GetFieldXmlConfig(basemodel); 55 | foreach (var fieldname in fieldtotal) 56 | { 57 | string currentfieldname = fieldname; 58 | long rowmin = CommonHelper.ToLong(bulkdata.Compute("min(" + currentfieldname + ")", "")); 59 | long rowmax = CommonHelper.ToLong(bulkdata.Compute("max(" + currentfieldname + ")", "")); 60 | var fileldobjecttemp = fieldlist.SqlFieldList.Where(m => m.FieldName == currentfieldname && m.TableNumber == tablenumber).FirstOrDefault(); 61 | if (fileldobjecttemp != null) 62 | { 63 | DBConfig.FieldRemove(basemodel, fileldobjecttemp); 64 | if (fileldobjecttemp.ValueMin > rowmin) 65 | { 66 | fileldobjecttemp.ValueMin = rowmin; 67 | } 68 | if (fileldobjecttemp.ValueMax < rowmax) 69 | { 70 | fileldobjecttemp.ValueMax = rowmax; 71 | } 72 | DBConfig.FieldAdd(basemodel, fileldobjecttemp); 73 | } 74 | else 75 | { 76 | SqlFieldItemXml fileldmodel = new SqlFieldItemXml(); 77 | fileldmodel.BaseNumber = servermodel.BaseNumber; 78 | fileldmodel.ServerNumber = servermodel.Number; 79 | fileldmodel.DatabaseNumber = databasenumber; 80 | fileldmodel.TableNumber = tablenumber; 81 | fileldmodel.Number = DBConfig.GetFieldNumber; 82 | fileldmodel.FieldName = currentfieldname; 83 | fileldmodel.ValueMin = rowmin; 84 | fileldmodel.ValueMax = rowmax; 85 | DBConfig.FieldAdd(basemodel, fileldmodel); 86 | } 87 | } 88 | } 89 | DBProxy.GetDBHelper(servermodel.DBType).WriteBlockDataToDB(connstr, bulkdata); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Manager/ManagerConfig.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.XmlModel; 2 | using GOTO.Common; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace GOTO.BigDataAccess.DBSql.Manager 7 | { 8 | public class ManagerConfig 9 | { 10 | public void InitServerXml(SqlBaseItemXml basemodel) 11 | { 12 | SqlServerXml modelserver = new SqlServerXml(); 13 | FileHelper.WriteText(basemodel.ServerFilePath, XMLSerilizable.ObjectToXML(modelserver)); 14 | DBConfig.ReloadServerXmlConfig(basemodel); 15 | } 16 | public void InitDatabaseXml(SqlBaseItemXml basemodel) 17 | { 18 | SqlDatabaseXml modeldatabase = new SqlDatabaseXml(); 19 | FileHelper.WriteText(basemodel.DatabaseFilePath, XMLSerilizable.ObjectToXML(modeldatabase)); 20 | DBConfig.ReloadDatabaseXmlConfig(basemodel); 21 | } 22 | public void InitTableXml(SqlBaseItemXml basemodel) 23 | { 24 | SqlTableXml modeltable = new SqlTableXml(); 25 | FileHelper.WriteText(basemodel.TableFilePath, XMLSerilizable.ObjectToXML(modeltable)); 26 | DBConfig.ReloadTableXmlConfig(basemodel); 27 | } 28 | public void InitFieldXml(SqlBaseItemXml basemodel) 29 | { 30 | SqlFieldXml modelfield = new SqlFieldXml(); 31 | FileHelper.WriteText(basemodel.FieldFilePath, XMLSerilizable.ObjectToXML(modelfield)); 32 | DBConfig.ReloadFieldXmlConfig(basemodel); 33 | } 34 | public void SaveConfig(SqlBaseItemXml basemodel) 35 | { 36 | SaveConfigServer(basemodel); 37 | SaveConfigDatabase(basemodel); 38 | SaveConfigTable(basemodel); 39 | SaveConfigField(basemodel); 40 | } 41 | public void SaveConfigServer(SqlBaseItemXml basemodel) 42 | { 43 | FileHelper.WriteText(basemodel.ServerFilePath, XMLSerilizable.ObjectToXML(DBConfig.GetServerXmlConfig(basemodel), Encoding.UTF8)); 44 | } 45 | public void SaveConfigDatabase(SqlBaseItemXml basemodel) 46 | { 47 | FileHelper.WriteText(basemodel.DatabaseFilePath, XMLSerilizable.ObjectToXML(DBConfig.GetDatabaseXmlConfig(basemodel), Encoding.UTF8)); 48 | } 49 | public void SaveConfigTable(SqlBaseItemXml basemodel) 50 | { 51 | FileHelper.WriteText(basemodel.TableFilePath, XMLSerilizable.ObjectToXML(DBConfig.GetTableXmlConfig(basemodel), Encoding.UTF8)); 52 | } 53 | public void SaveConfigField(SqlBaseItemXml basemodel) 54 | { 55 | FileHelper.WriteText(basemodel.FieldFilePath, XMLSerilizable.ObjectToXML(DBConfig.GetFieldXmlConfig(basemodel), Encoding.UTF8)); 56 | } 57 | public void ServerChangeIsWrite(SqlServerItemXml item, bool iswrite = false) 58 | { 59 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 60 | DBConfig.ServerRemove(basemodel,item); 61 | item.IsWrite = iswrite; 62 | DBConfig.ServerAdd(basemodel, item); 63 | } 64 | public void ServerChangeIsUse(SqlServerItemXml item, bool isuse = false) 65 | { 66 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 67 | DBConfig.ServerRemove(basemodel, item); 68 | item.IsUse = isuse; 69 | DBConfig.ServerAdd(basemodel, item); 70 | } 71 | public void DatabaseChangeIsWrite(SqlDatabaseItemXml item, bool iswrite = false) 72 | { 73 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 74 | DBConfig.DatabaseRemove(basemodel, item); 75 | item.IsWrite = iswrite; 76 | DBConfig.DatabaseAdd(basemodel, item); 77 | } 78 | public void DatabaseChangeIsUse(SqlDatabaseItemXml item, bool isuse = false) 79 | { 80 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 81 | DBConfig.DatabaseRemove(basemodel, item); 82 | item.IsUse = isuse; 83 | DBConfig.DatabaseAdd(basemodel, item); 84 | } 85 | public void TableChangeIsWrite(SqlTableItemXml item, bool iswrite = false) 86 | { 87 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 88 | DBConfig.TableRemove(basemodel, item); 89 | item.IsWrite = iswrite; 90 | DBConfig.TableAdd(basemodel, item); 91 | } 92 | public void TableChangeIsUse(SqlTableItemXml item, bool isuse = false) 93 | { 94 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 95 | DBConfig.TableRemove(basemodel, item); 96 | item.IsUse = isuse; 97 | DBConfig.TableAdd(basemodel, item); 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Manager/ManagerDatabase.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Access; 2 | using GOTO.BigDataAccess.DBSql.XmlModel; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace GOTO.BigDataAccess.DBSql.Manager 9 | { 10 | public class ManagerDatabase 11 | { 12 | public int DatabaseAttachAll(SqlBaseItemXml basemodel) 13 | { 14 | List> listtask = new List>(); 15 | int revalue = 0; 16 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 17 | foreach (var item in serverlist) 18 | { 19 | Task t = new Task(n => AttachTask((SqlServerItemXml)n), item); 20 | t.Start(); 21 | listtask.Add(t); 22 | } 23 | revalue = listtask.Sum(m => m.Result); 24 | Console.WriteLine("执行完成,附加数据库:" + revalue); 25 | return revalue; 26 | } 27 | public int AttachTask(object model) 28 | { 29 | var item = model as SqlServerItemXml; 30 | int revalue = 0; 31 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 32 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel,item.Number); 33 | foreach (var item2 in databaselist) 34 | { 35 | string connstr =DBProxyAction.GetConnStr(basemodel, item); 36 | DBProxy.GetDBAccess(item.DBType).DatabaseSPAttach(connstr, item2.DatabaseName, item2.StorageDirectory); 37 | revalue++; 38 | Console.WriteLine("附加服务器:" + item.ServerName + ",数据库:" + item2.DatabaseName); 39 | } 40 | return revalue; 41 | } 42 | public int DatabaseDetachAll(SqlBaseItemXml basemodel) 43 | { 44 | List> listtask = new List>(); 45 | int revalue = 0; 46 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 47 | foreach (var item in serverlist) 48 | { 49 | Task t = new Task(n => DetachTask((SqlServerItemXml)n), item); 50 | t.Start(); 51 | listtask.Add(t); 52 | } 53 | revalue = listtask.Sum(m => m.Result); 54 | Console.WriteLine("执行完成,分离数据库:" + revalue); 55 | return revalue; 56 | } 57 | public int DetachTask(object model) 58 | { 59 | var item = model as SqlServerItemXml; 60 | int revalue = 0; 61 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 62 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel, item.Number); 63 | foreach (var item2 in databaselist) 64 | { 65 | string connstr = DBProxyAction.GetConnStr(basemodel, item); 66 | DBProxy.GetDBAccess(item.DBType).DatabaseSPDetach(connstr, item2.DatabaseName); 67 | revalue++; 68 | Console.WriteLine("分离服务器:" + item.ServerName + ",数据库:" + item2.DatabaseName); 69 | } 70 | return revalue; 71 | } 72 | public void DatabaseUseCheckAll(SqlBaseItemXml basemodel) 73 | { 74 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 75 | int servernum = serverlist.Count; 76 | int databasenum = 0; 77 | ManagerConfig serverconfig=new ManagerConfig(); 78 | foreach (var item in serverlist) 79 | { 80 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel, item.Number); 81 | string connstr = DBProxyAction.GetConnStr(basemodel, item); 82 | foreach (var item2 in databaselist) 83 | { 84 | var restatus = DBProxy.GetDBAccess(item.DBType).DatabaseExists(connstr, item2.DatabaseName); 85 | if (item2.IsUse != restatus) 86 | { 87 | databasenum++; 88 | serverconfig.DatabaseChangeIsUse(item2, restatus); 89 | } 90 | Console.WriteLine("检查数据库连接,服务器:" + item.ServerName+",数据库:"+item2.DatabaseName+",status:"+restatus); 91 | } 92 | } 93 | new ManagerConfig().SaveConfig(basemodel); 94 | Console.WriteLine("测试连接执行完成,操作服务器:" + servernum+",操作数据库:"+databasenum); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Manager/ManagerServer.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Access; 2 | using GOTO.BigDataAccess.DBSql.XmlModel; 3 | using GOTO.Common; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace GOTO.BigDataAccess.DBSql.Manager 10 | { 11 | public class ManagerServer 12 | { 13 | public void ServerCacheClearAll(SqlBaseItemXml basemodel) 14 | { 15 | List> listtask = new List>(); 16 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 17 | foreach (var item in serverlist) 18 | { 19 | Task t = new Task(n => ServerCacheClearItem((SqlServerItemXml)n), item); 20 | t.Start(); 21 | listtask.Add(t); 22 | } 23 | int revalue = listtask.Sum(m => m.Result); 24 | Console.WriteLine("测试连接执行完成,操作服务器数:" + revalue); 25 | } 26 | 27 | public int ServerCacheClearItem(object model) 28 | { 29 | var item = model as SqlServerItemXml; 30 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 31 | string connstr = DBProxyAction.GetConnStr(basemodel, item); 32 | Console.WriteLine("操作服务器开始:" + item.ServerName); 33 | DBProxy.GetDBAccess(item.DBType).ServerCacheClear(connstr); 34 | Console.WriteLine("操作服务器完成:" + item.ServerName); 35 | return 1; 36 | } 37 | public void ServerConnectionCheckAll(SqlBaseItemXml basemodel) 38 | { 39 | List> listtask = new List>(); 40 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 41 | foreach (var item in serverlist) 42 | { 43 | Task t = new Task(n => ServerConnectionCheckItem((SqlServerItemXml)n), item); 44 | t.Start(); 45 | listtask.Add(t); 46 | } 47 | int revalue = listtask.Sum(m => m.Result); 48 | new ManagerConfig().SaveConfig(basemodel); 49 | Console.WriteLine("测试连接执行完成,操作服务器数:" + revalue); 50 | } 51 | public int ServerConnectionCheckItem(object model) 52 | { 53 | var item = model as SqlServerItemXml; 54 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 55 | bool connectionstatus = SocketHelper.TestConnection(item.ServerName, item.ServerPort, basemodel.SocketMillisecondsTimeout); 56 | if (connectionstatus) 57 | { 58 | string connstr = DBProxyAction.GetConnStr(basemodel, item); 59 | connectionstatus = DBProxy.GetDBHelper(item.DBType).ConnectionIsUse(connstr); 60 | } 61 | new ManagerConfig().ServerChangeIsUse(item, connectionstatus); 62 | Console.WriteLine("服务器:" + item.ServerName + ",isuse:" + connectionstatus); 63 | return 1; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Manager/ManagerTable.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql.Access; 2 | using GOTO.BigDataAccess.DBSql.XmlModel; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace GOTO.BigDataAccess.DBSql.Manager 9 | { 10 | public class ManagerTable 11 | { 12 | public void TableAddIndexAll(SqlBaseItemXml basemodel) 13 | { 14 | List> listtask = new List>(); 15 | int revalue = 0; 16 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 17 | foreach (var item in serverlist) 18 | { 19 | Task t = new Task(n => TableAddIndexServer((SqlServerItemXml)n), item); 20 | t.Start(); 21 | listtask.Add(t); 22 | } 23 | revalue = listtask.Sum(m => m.Result); 24 | Console.WriteLine("添加索引执行完成,影响服务器数:" + revalue); 25 | } 26 | public int TableAddIndexServer(object model) 27 | { 28 | int changetablenum = 0; 29 | int changetableindexnum = 0; 30 | var item = model as SqlServerItemXml; 31 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 32 | if (item != null) 33 | { 34 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel,item.Number); 35 | foreach (var item2 in databaselist) 36 | { 37 | var tablelist = DBConfig.GetTableItemXmlConfigList(basemodel, item2.Number); 38 | string connstr = DBProxyAction.GetConnStr(basemodel, item); 39 | foreach (var item3 in tablelist) 40 | { 41 | int validnum = 0; 42 | foreach (var itemfield in basemodel.FieldIndexList) 43 | { 44 | string indexname = basemodel.IndexPrev + item3.TableName + itemfield; 45 | if (!DBProxy.GetDBAccess(item.DBType).TableIndexExists(connstr, item2.DatabaseName, item3.TableName, indexname)) 46 | { 47 | validnum++; 48 | changetableindexnum++; 49 | DBProxy.GetDBAccess(item.DBType).TableIndexAdd(connstr, item2.DatabaseName, item3.TableName, itemfield, indexname); 50 | Console.WriteLine("添加索引服务器:" + item.ServerName + ",数据库:" + item2.DatabaseName + ",表:" + item3.TableName); 51 | } 52 | } 53 | if (validnum > 0) 54 | { 55 | changetablenum++; 56 | } 57 | } 58 | } 59 | } 60 | Console.WriteLine("服务器:" + item.ServerName + ",涉及表总数:" + changetablenum + ",添加索引总数:" + changetableindexnum); 61 | return 1; 62 | } 63 | public void TableDelIndexAll(SqlBaseItemXml basemodel) 64 | { 65 | List> listtask = new List>(); 66 | int revalue = 0; 67 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 68 | foreach (var item in serverlist) 69 | { 70 | Task t = new Task(n => TableDelIndexServer((SqlServerItemXml)n), item); 71 | t.Start(); 72 | listtask.Add(t); 73 | } 74 | revalue = listtask.Sum(m => m.Result); 75 | Console.WriteLine("删除索引执行完成,影响服务器数:" + revalue); 76 | } 77 | public int TableDelIndexServer(object model) 78 | { 79 | int changetablenum = 0; 80 | int changetableindexnum = 0; 81 | var item = model as SqlServerItemXml; 82 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 83 | if (item != null) 84 | { 85 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel, item.Number); 86 | foreach (var item2 in databaselist) 87 | { 88 | var tablelist = DBConfig.GetTableItemXmlConfigList(basemodel, item2.Number); 89 | DBProxyAction.GetConnStr(basemodel, item,item2); 90 | string conndatabasestr = DBProxyAction.GetConnStr(basemodel, item, item2); 91 | foreach (var item3 in tablelist) 92 | { 93 | int validnum = 0; 94 | foreach (var itemfield in basemodel.FieldIndexList) 95 | { 96 | string indexname = basemodel.IndexPrev + item3.TableName + itemfield; 97 | if (!DBProxy.GetDBAccess(item.DBType).TableIndexExists(conndatabasestr, item2.DatabaseName, item3.TableName, indexname)) 98 | { 99 | validnum++; 100 | changetableindexnum++; 101 | 102 | DBProxy.GetDBAccess(item.DBType).TableIndexDel(conndatabasestr, item3.TableName, indexname); 103 | Console.WriteLine("删除索引服务器:" + item.ServerName + ",数据库:" + item2.DatabaseName + ",表:" + item3.TableName); 104 | } 105 | } 106 | if (validnum > 0) 107 | { 108 | changetablenum++; 109 | } 110 | } 111 | } 112 | } 113 | Console.WriteLine("服务器:" + item.ServerName + ",涉及表总数:" + changetablenum + ",添加索引总数:" + changetableindexnum); 114 | return 1; 115 | } 116 | public void TableUseCheckAll(SqlBaseItemXml basemodel) 117 | { 118 | List> listtask = new List>(); 119 | int revalue = 0; 120 | var serverlist = DBConfig.GetServerItemXmlConfigList(basemodel); 121 | foreach (var item in serverlist) 122 | { 123 | Task t = new Task(n => TableUseCheckServer((SqlServerItemXml)n), item); 124 | t.Start(); 125 | listtask.Add(t); 126 | } 127 | revalue = listtask.Sum(m => m.Result); 128 | new ManagerConfig().SaveConfig(basemodel); 129 | Console.WriteLine("检查表,涉及服务器数:" + revalue); 130 | } 131 | public int TableUseCheckServer(object model) 132 | { 133 | int changetablenum = 0; 134 | var item = model as SqlServerItemXml; 135 | var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); 136 | if (item != null) 137 | { 138 | ManagerConfig serverconfig = new ManagerConfig(); 139 | var databaselist = DBConfig.GetDatabaseItemXmlConfigList(basemodel, item.Number); 140 | string connstr = DBProxyAction.GetConnStr(basemodel, item); 141 | foreach (var item2 in databaselist) 142 | { 143 | var tablelist = DBConfig.GetTableItemXmlConfigList(basemodel, item2.Number); 144 | foreach (var item3 in tablelist) 145 | { 146 | var restatus = DBProxy.GetDBAccess(item.DBType).TableExists(connstr, item2.DatabaseName, item3.TableName); 147 | if (item3.IsUse != restatus) 148 | { 149 | changetablenum++; 150 | serverconfig.TableChangeIsUse(item3, restatus); 151 | } 152 | Console.WriteLine("检查数据表连接,服务器:" + item.ServerName + ",数据库:" + item2.DatabaseName + ",表:"+item3.TableName+",status:" + restatus); 153 | } 154 | } 155 | } 156 | Console.WriteLine("服务器:" + item.ServerName + ",涉及表总数:" + changetablenum); 157 | return 1; 158 | } 159 | } 160 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Model/ConditionFieldModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace GOTO.BigDataAccess.DBSql.Model 4 | { 5 | public class ConditionFieldModel 6 | { 7 | public ConditionFieldModel() 8 | { 9 | List = new List(); 10 | } 11 | public List List; 12 | } 13 | public class ConditionFieldItemModel 14 | { 15 | public string FieldName 16 | { get; set; } 17 | public long ValueMin 18 | { get; set; } 19 | public long ValueMax 20 | { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Model/MatchServerList.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace GOTO.BigDataAccess.DBSql.Model 3 | { 4 | public class MatchServerList 5 | { 6 | public long ServerNumber 7 | { get; set; } 8 | public long DatabaseNumber 9 | { get; set; } 10 | public long TableNumber 11 | { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/Model/TaskDataParam.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace GOTO.BigDataAccess.DBSql.Model 3 | { 4 | public class TaskDataParam 5 | { 6 | public string servername 7 | { get; set; } 8 | public string connstr 9 | { get; set; } 10 | public string sqlstr 11 | { get; set; } 12 | public string dbtype 13 | { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlBaseItemXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace GOTO.BigDataAccess.DBSql.XmlModel 6 | { 7 | [Serializable] 8 | [XmlRoot("SqlBaseItem")] 9 | public class SqlBaseItemXml 10 | { 11 | [XmlElement("Number")] 12 | public long Number 13 | { get; set; } 14 | [XmlElement("SocketMillisecondsTimeout")] 15 | public int SocketMillisecondsTimeout 16 | { get; set; } 17 | [XmlElement("DatabasePrev")] 18 | public string DatabasePrev 19 | { get; set; } 20 | [XmlElement("TablePrev")] 21 | public string TablePrev 22 | { get; set; } 23 | [XmlElement("IndexPrev")] 24 | public string IndexPrev 25 | { get; set; } 26 | 27 | [XmlElement("PrimarykeyName")] 28 | public string PrimarykeyName 29 | { get; set; } 30 | [XmlElement("FieldIndexList")] 31 | public List FieldIndexList 32 | { get; set; } 33 | [XmlElement("FieldUpdateList")] 34 | public List FieldUpdateList 35 | { get; set; } 36 | [XmlElement("FileDirDefault")] 37 | public string FileDirDefault 38 | { get; set; } 39 | [XmlElement("DefaultTableNum")] 40 | public long DefaultTableNum 41 | { get; set; } 42 | [XmlElement("DefaultTableRowNum")] 43 | public long DefaultTableRowNum 44 | { get; set; } 45 | [XmlElement("TemplateSqlConnServer")] 46 | public string TemplateSqlConnServer 47 | { get; set; } 48 | [XmlElement("TemplateSqlConnDatabase")] 49 | public string TemplateSqlConnDatabase 50 | { get; set; } 51 | [XmlElement("ServerFilePath")] 52 | public string ServerFilePath 53 | { get; set; } 54 | [XmlElement("DatabaseFilePath")] 55 | public string DatabaseFilePath 56 | { get; set; } 57 | [XmlElement("TableFilePath")] 58 | public string TableFilePath 59 | { get; set; } 60 | [XmlElement("FieldFilePath")] 61 | public string TableSqlFilePath 62 | { get; set; } 63 | 64 | [XmlElement("TableSqlFilePath")] 65 | public string FieldFilePath 66 | { get; set; } 67 | 68 | [XmlElement("TableStructFilePath")] 69 | public string TableStructFilePath 70 | { get; set; } 71 | } 72 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlBaseXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace GOTO.BigDataAccess.DBSql.XmlModel 6 | { 7 | [Serializable] 8 | [XmlRoot("SqlBaseXml")] 9 | public class SqlBaseXml 10 | { 11 | [XmlElement("SqlBaseList")] 12 | public List SqlBaseList 13 | { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlDatabaseItemXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | 4 | namespace GOTO.BigDataAccess.DBSql.XmlModel 5 | { 6 | [Serializable] 7 | [XmlRoot("SqlDatabaseItem")] 8 | public class SqlDatabaseItemXml 9 | { 10 | [XmlElement("BaseNumber")] 11 | public long BaseNumber 12 | { get; set; } 13 | [XmlElement("ServerNumber")] 14 | public long ServerNumber 15 | { get; set; } 16 | [XmlElement("Number")] 17 | public long Number 18 | { get; set; } 19 | [XmlElement("DatabaseName")] 20 | public string DatabaseName 21 | { get; set; } 22 | /// 23 | /// 存储空间(字节) 24 | /// 25 | [XmlElement("StorageSize")] 26 | public long StorageSize 27 | { get; set; } 28 | /// 29 | /// 存储路径 30 | /// 31 | [XmlElement("StorageDirectory")] 32 | public string StorageDirectory 33 | { get; set; } 34 | [XmlElement("IsWrite")] 35 | public bool IsWrite 36 | { get; set; } 37 | /// 38 | /// 数据表最大个数 39 | /// 40 | [XmlElement("TableNum")] 41 | public long TableNum 42 | { get; set; } 43 | /// 44 | /// 数据库文件目录 45 | /// 46 | [XmlElement("FilePath")] 47 | public string FilePath 48 | { get; set; } 49 | /// 50 | /// 是否可用 51 | /// 52 | [XmlElement("IsUse")] 53 | public bool IsUse 54 | { get; set; } 55 | /// 56 | /// 是否自动创建表 57 | /// 58 | [XmlElement("IsCreate")] 59 | public bool IsCreate 60 | { get; set; } 61 | } 62 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlDatabaseXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace GOTO.BigDataAccess.DBSql.XmlModel 6 | { 7 | [Serializable] 8 | [XmlRoot("SqlDatabaseXml")] 9 | public class SqlDatabaseXml 10 | { 11 | [XmlElement("SqlDatabaseList")] 12 | public List SqlDatabaseList 13 | { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlFieldItemXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | 4 | namespace GOTO.BigDataAccess.DBSql.XmlModel 5 | { 6 | [Serializable] 7 | [XmlRoot("SqlFieldItem")] 8 | public class SqlFieldItemXml 9 | { 10 | [XmlElement("BaseNumber")] 11 | public long BaseNumber 12 | { get; set; } 13 | [XmlElement("ServerNumber")] 14 | public long ServerNumber 15 | { get; set; } 16 | [XmlElement("DatabaseNumber")] 17 | public long DatabaseNumber 18 | { get; set; } 19 | [XmlElement("TableNumber")] 20 | public long TableNumber 21 | { get; set; } 22 | [XmlElement("FieldName")] 23 | public string FieldName 24 | { get; set; } 25 | [XmlElement("Number")] 26 | public long Number 27 | { get; set; } 28 | [XmlElement("ValueMin")] 29 | public long ValueMin 30 | { get; set; } 31 | [XmlElement("ValueMax")] 32 | public long ValueMax 33 | { get; set; } 34 | [XmlElement("IsDelete")] 35 | public bool IsDelete 36 | { get; set; } 37 | } 38 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlFieldXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace GOTO.BigDataAccess.DBSql.XmlModel 6 | { 7 | [Serializable] 8 | [XmlRoot("SqlFieldXml")] 9 | public class SqlFieldXml 10 | { 11 | [XmlElement("SqlFieldList")] 12 | public List SqlFieldList 13 | { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlServerItemXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | 4 | namespace GOTO.BigDataAccess.DBSql.XmlModel 5 | { 6 | [Serializable] 7 | [XmlRoot("SqlServerItem")] 8 | public class SqlServerItemXml 9 | { 10 | [XmlElement("BaseNumber")] 11 | public long BaseNumber 12 | { get; set; } 13 | [XmlElement("Number")] 14 | public long Number 15 | { get; set; } 16 | [XmlElement("ServerName")] 17 | public string ServerName 18 | { get; set; } 19 | [XmlElement("ServerPort")] 20 | public int ServerPort 21 | { get; set; } 22 | [XmlElement("ServerUserName")] 23 | public string ServerUserName 24 | { get; set; } 25 | [XmlElement("ServerUserPwd")] 26 | public string ServerUserPwd 27 | { get; set; } 28 | /// 29 | /// 存储空间(字节) 30 | /// 31 | [XmlElement("StorageSize")] 32 | public long StorageSize 33 | { get; set; } 34 | /// 35 | /// 保留剩余空间(字节) 36 | /// 37 | [XmlElement("RetainStorageSize")] 38 | public long RetainStorageSize 39 | { get; set; } 40 | /// 41 | /// 数据库最大个数 42 | /// 43 | [XmlElement("DatabaseNum")] 44 | public long DatabaseNum 45 | { get; set; } 46 | /// 47 | /// 数据库类型 48 | /// 49 | [XmlElement("DBType")] 50 | public string DBType 51 | { get; set; } 52 | /// 53 | /// 存储路径 54 | /// 55 | [XmlElement("StorageDirectory")] 56 | public string StorageDirectory 57 | { get; set; } 58 | /// 59 | /// 是否可写入 60 | /// 61 | [XmlElement("IsWrite")] 62 | public bool IsWrite 63 | { get; set; } 64 | /// 65 | /// 是否可用 66 | /// 67 | [XmlElement("IsUse")] 68 | public bool IsUse 69 | { get; set; } 70 | /// 71 | /// 是否自动创建库 72 | /// 73 | [XmlElement("IsCreate")] 74 | public bool IsCreate 75 | { get; set; } 76 | } 77 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlServerXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace GOTO.BigDataAccess.DBSql.XmlModel 6 | { 7 | [Serializable] 8 | [XmlRoot("SqlServerXml")] 9 | public class SqlServerXml 10 | { 11 | [XmlElement("SqlServerList")] 12 | public List SqlServerList 13 | { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlTableItemXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | 4 | namespace GOTO.BigDataAccess.DBSql.XmlModel 5 | { 6 | [Serializable] 7 | [XmlRoot("SqlTableItem")] 8 | public class SqlTableItemXml 9 | { 10 | [XmlElement("BaseNumber")] 11 | public long BaseNumber 12 | { get; set; } 13 | [XmlElement("ServerNumber")] 14 | public long ServerNumber 15 | { get; set; } 16 | [XmlElement("DataBaseNumber")] 17 | public long DataBaseNumber 18 | { get; set; } 19 | [XmlElement("Number")] 20 | public long Number 21 | { get; set; } 22 | [XmlElement("TableName")] 23 | public string TableName 24 | { get; set; } 25 | /// 26 | /// 存储空间(字节) 27 | /// 28 | [XmlElement("StorageSize")] 29 | public long StorageSize 30 | { get; set; } 31 | /// 32 | /// 是否可用 33 | /// 34 | [XmlElement("IsUse")] 35 | public bool IsUse 36 | { get; set; } 37 | [XmlElement("IsWrite")] 38 | public bool IsWrite 39 | { get; set; } 40 | /// 41 | /// 数据表最大记录数 42 | /// 43 | [XmlElement("RowNum")] 44 | public long RowNum 45 | { get; set; } 46 | } 47 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/DBSql/XmlModel/SqlTableXml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace GOTO.BigDataAccess.DBSql.XmlModel 6 | { 7 | [Serializable] 8 | [XmlRoot("SqlTableXml")] 9 | public class SqlTableXml 10 | { 11 | [XmlElement("SqlTableList")] 12 | public List SqlTableList 13 | { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /GOTO.BigDataAccess/GOTO.BigDataAccess.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4B9C7261-E683-48FB-BACF-4BDE95BC4130} 8 | Library 9 | Properties 10 | GOTO.BigDataAccess 11 | GOTO.BigDataAccess 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | 37 | ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll 38 | True 39 | 40 | 41 | ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll 42 | True 43 | 44 | 45 | ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll 46 | True 47 | 48 | 49 | ..\packages\mongodb1.7.0.4714\MongoDB.Bson.dll 50 | 51 | 52 | ..\packages\mongodb1.7.0.4714\MongoDB.Driver.dll 53 | 54 | 55 | ..\packages\StackExchange.Redis.1.1.608\lib\net40\StackExchange.Redis.dll 56 | True 57 | 58 | 59 | 60 | 61 | 62 | ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll 63 | True 64 | 65 | 66 | 67 | ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Runtime.dll 68 | True 69 | 70 | 71 | ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll 72 | True 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | {d8c9d1d5-84f3-4d21-8560-c2d7ae8aff1a} 119 | GOTO.Common 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 140 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("GOTO.BigDataAccess")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("GOTO.BigDataAccess")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("35328bb5-814c-4ea7-9a80-ca6e69136e56")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/RedisConfig/RedisConfigBase.cs: -------------------------------------------------------------------------------- 1 | using GOTO.Common; 2 | using StackExchange.Redis; 3 | using System; 4 | using System.Configuration; 5 | 6 | namespace GOTO.BigDataAccess.RedisConfig 7 | { 8 | public static class RedisConfigBase 9 | { 10 | private static string redisconstr =CommonHelper.ToStr(ConfigurationManager.AppSettings["RedisConstr"]); 11 | public static string Redisconstr 12 | { 13 | get { return redisconstr; } 14 | set { redisconstr = value; } 15 | } 16 | 17 | private static Lazy lazyConnection = new Lazy(() => 18 | { 19 | return ConnectionMultiplexer.Connect(redisconstr); 20 | }); 21 | 22 | public static IDatabase redis 23 | { 24 | get 25 | { 26 | return lazyConnection.Value.GetDatabase(); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/RedisConfig/RedisConfigKey.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace GOTO.BigDataAccess.RedisConfig 3 | { 4 | public class RedisConfigKey 5 | { 6 | public const string keymongodbdatarowid = "redis_mongodb_data_row_id"; 7 | public const string keyredisdatarowid = "redis_data_row_id"; 8 | public const string keysqlserverdatarowid = "redis_sqlserver_data_row_id"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/RedisConfig/RedisConfigService.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace GOTO.BigDataAccess.RedisConfig 3 | { 4 | public static class RedisConfigService 5 | { 6 | public static string Get(string key) 7 | { 8 | return RedisConfigBase.redis.StringGet(key); 9 | } 10 | public static bool Set(string key, string value) 11 | { 12 | return RedisConfigBase.redis.StringSet(key, value); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/GOTO.BigDataAccess.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/GOTO.BigDataAccess.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/GOTO.BigDataAccess.dll.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/GOTO.BigDataAccess.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/GOTO.BigDataAccess.pdb -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/GOTO.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/GOTO.Common.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/GOTO.Common.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/GOTO.Common.pdb -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/Microsoft.Threading.Tasks.Extensions.Desktop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/Microsoft.Threading.Tasks.Extensions.Desktop.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/Microsoft.Threading.Tasks.Extensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/Microsoft.Threading.Tasks.Extensions.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/Microsoft.Threading.Tasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/Microsoft.Threading.Tasks.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/MongoDB.Bson.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/MongoDB.Bson.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/MongoDB.Driver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/MongoDB.Driver.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/StackExchange.Redis.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/StackExchange.Redis.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/System.IO.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/System.IO.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/System.IO.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | System.IO 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/System.Runtime.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/System.Runtime.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/System.Runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | System.Runtime 5 | 6 | 7 | 8 | Defines a provider for progress updates. 9 | The type of progress update value. 10 | 11 | 12 | Reports a progress update. 13 | The value of the updated progress. 14 | 15 | 16 | Identities the async state machine type for this method. 17 | 18 | 19 | Identities the state machine type for this method. 20 | 21 | 22 | Initializes the attribute. 23 | The type that implements the state machine. 24 | 25 | 26 | Gets the type that implements the state machine. 27 | 28 | 29 | Initializes the attribute. 30 | The type that implements the state machine. 31 | 32 | 33 | 34 | Allows you to obtain the method or property name of the caller to the method. 35 | 36 | 37 | 38 | 39 | Allows you to obtain the line number in the source file at which the method is called. 40 | 41 | 42 | 43 | 44 | Allows you to obtain the full path of the source file that contains the caller. 45 | This is the file path at the time of compile. 46 | 47 | 48 | 49 | Identities the iterator state machine type for this method. 50 | 51 | 52 | Initializes the attribute. 53 | The type that implements the state machine. 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /GOTO.BigDataAccess/bin/Debug/System.Threading.Tasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.BigDataAccess/bin/Debug/System.Threading.Tasks.dll -------------------------------------------------------------------------------- /GOTO.BigDataAccess/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /GOTO.Common/CacheHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Web; 4 | 5 | namespace GOTO.Common 6 | { 7 | public class CacheBase 8 | { 9 | public static object GetCache(string CacheKey) 10 | { 11 | System.Web.Caching.Cache objCache = HttpRuntime.Cache; 12 | return objCache[CacheKey]; 13 | } 14 | public static void SetCache(string CacheKey, object objObject) 15 | { 16 | System.Web.Caching.Cache objCache = HttpRuntime.Cache; 17 | objCache.Insert(CacheKey, objObject); 18 | } 19 | public static void SetCache(string CacheKey, object objObject, DateTime absdate) 20 | { 21 | System.Web.Caching.Cache objCache = HttpRuntime.Cache; 22 | objCache.Insert(CacheKey, objObject, null, absdate, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, null); 23 | } 24 | public static void SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration) 25 | { 26 | System.Web.Caching.Cache objCache = HttpRuntime.Cache; 27 | objCache.Insert(CacheKey, objObject, null, absoluteExpiration, slidingExpiration); 28 | } 29 | public static void RemoveAllCache(string CacheKey) 30 | { 31 | System.Web.Caching.Cache _cache = HttpRuntime.Cache; 32 | _cache.Remove(CacheKey); 33 | } 34 | public static void RemoveAllCache() 35 | { 36 | System.Web.Caching.Cache _cache = HttpRuntime.Cache; 37 | IDictionaryEnumerator CacheEnum = _cache.GetEnumerator(); 38 | while (CacheEnum.MoveNext()) 39 | { 40 | _cache.Remove(CacheEnum.Key.ToString()); 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /GOTO.Common/CookieHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | 4 | namespace GOTO.Common 5 | { 6 | public class CookieBase 7 | { 8 | /// 9 | /// 清除指定Cookie 10 | /// 11 | /// 12 | public static void ClearCookie(string cookiename) 13 | { 14 | HttpCookie cookie = HttpContext.Current.Request.Cookies[cookiename]; 15 | if (cookie != null) 16 | { 17 | cookie.Expires = DateTime.Now.AddYears(-3); 18 | HttpContext.Current.Response.Cookies.Add(cookie); 19 | } 20 | } 21 | /// 22 | /// 获取指定Cookie值 23 | /// 24 | /// 25 | /// 26 | public static string GetCookieValue(string cookiename) 27 | { 28 | HttpCookie cookie = HttpContext.Current.Request.Cookies[cookiename]; 29 | string str = string.Empty; 30 | if (cookie != null) 31 | { 32 | str = cookie.Value; 33 | } 34 | return str; 35 | } 36 | /// 37 | /// 添加一个Cookie(7天后过期) 38 | /// 39 | /// 40 | /// 41 | public static void SetCookie(string cookiename, string cookievalue) 42 | { 43 | SetCookie(cookiename, cookievalue, DateTime.Now.AddDays(7)); 44 | } 45 | /// 46 | /// 添加一个Cookie 47 | /// 48 | /// 49 | /// 50 | /// 51 | public static void SetCookie(string cookiename, string cookievalue, DateTime expires) 52 | { 53 | HttpCookie cookie = new HttpCookie(cookiename) 54 | { 55 | Value = cookievalue, 56 | Expires = expires 57 | }; 58 | HttpContext.Current.Response.Cookies.Add(cookie); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /GOTO.Common/GOTO.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D8C9D1D5-84F3-4D21-8560-C2D7AE8AFF1A} 8 | Library 9 | Properties 10 | GOTO.Common 11 | GOTO.Common 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /GOTO.Common/JsonHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.Serialization.Json; 4 | using System.Text; 5 | 6 | namespace GOTO.Common 7 | { 8 | public class JsonHelper 9 | { 10 | public JsonHelper() 11 | { 12 | } 13 | /// 14 | /// 把对象序列化 JSON 字符串 15 | /// 16 | /// 对象类型 17 | /// 对象实体 18 | /// JSON字符串 19 | public static string GetJson(T obj) 20 | { 21 | DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(T)); 22 | using (MemoryStream ms = new MemoryStream()) 23 | { 24 | json.WriteObject(ms, obj); 25 | string szJson = Encoding.UTF8.GetString(ms.ToArray()); 26 | return szJson; 27 | } 28 | } 29 | /// 30 | /// 把JSON字符串还原为对象 31 | /// 32 | /// 对象类型 33 | /// JSON字符串 34 | /// 对象实体 35 | public static T ParseFormJson(string szJson) 36 | { 37 | T obj = Activator.CreateInstance(); 38 | using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(szJson))) 39 | { 40 | DataContractJsonSerializer dcj = new DataContractJsonSerializer(typeof(T)); 41 | return (T)dcj.ReadObject(ms); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /GOTO.Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("GOTO.Common")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("GOTO.Common")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("b1c961af-2b06-4dc0-ad9e-272e4e874ba6")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GOTO.Common/SocketHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Sockets; 3 | 4 | namespace GOTO.Common 5 | { 6 | public class SocketHelper 7 | { 8 | /// 9 | /// 采用Socket方式,测试服务器连接 10 | /// 11 | /// 服务器主机名或IP 12 | /// 端口号 13 | /// 等待时间:毫秒 14 | /// 15 | public static bool TestConnection(string host, int port, int millisecondsTimeout) 16 | { 17 | TcpClient client = new TcpClient(); 18 | try 19 | { 20 | var ar = client.BeginConnect(host, port, null, null); 21 | ar.AsyncWaitHandle.WaitOne(millisecondsTimeout); 22 | return client.Connected; 23 | } 24 | catch (Exception e) 25 | { 26 | throw e; 27 | } 28 | finally 29 | { 30 | client.Close(); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /GOTO.Common/XMLSerilizable.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Runtime.Serialization.Formatters.Binary; 3 | using System.Text; 4 | using System.Xml; 5 | using System.Xml.Serialization; 6 | 7 | namespace GOTO.Common 8 | { 9 | public class XMLSerilizable 10 | { 11 | /// 12 | /// 将object对象序列化成XML 13 | /// 14 | /// 15 | /// 16 | /// 17 | public static string ObjectToXML(T t, Encoding encoding) 18 | { 19 | XmlSerializer ser = new XmlSerializer(t.GetType()); 20 | using (MemoryStream mem = new MemoryStream()) 21 | { 22 | using (XmlTextWriter writer = new XmlTextWriter(mem, encoding)) 23 | { 24 | XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); 25 | ns.Add("", ""); 26 | ser.Serialize(writer, t, ns); 27 | return encoding.GetString(mem.ToArray()).Trim(); 28 | } 29 | } 30 | } 31 | public static string ObjectToXML(T t) 32 | { 33 | XmlSerializer ser = new XmlSerializer(t.GetType()); 34 | using (MemoryStream mem = new MemoryStream()) 35 | { 36 | using (XmlTextWriter writer = new XmlTextWriter(mem, Encoding.UTF8)) 37 | { 38 | XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); 39 | ns.Add("", ""); 40 | ser.Serialize(writer, t, ns); 41 | return Encoding.UTF8.GetString(mem.ToArray()).Trim(); 42 | } 43 | } 44 | } 45 | /// 46 | /// 将XML反序列化成对象 47 | /// 48 | /// 49 | /// 50 | /// 51 | /// 52 | public static T XMLToObject(string source, Encoding encoding) 53 | { 54 | XmlSerializer mySerializer = new XmlSerializer(typeof(T)); 55 | using (MemoryStream stream = new MemoryStream(encoding.GetBytes(source))) 56 | { 57 | return (T)mySerializer.Deserialize(stream); 58 | } 59 | } 60 | public static T XMLToObject(string source) 61 | { 62 | XmlSerializer mySerializer = new XmlSerializer(typeof(T)); 63 | using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(source))) 64 | { 65 | return (T)mySerializer.Deserialize(stream); 66 | } 67 | } 68 | /// 69 | /// 二进制方式序列化对象 70 | /// 71 | /// 72 | public static string Serialize(T obj) 73 | { 74 | MemoryStream ms = new MemoryStream(); 75 | BinaryFormatter formatter = new BinaryFormatter(); 76 | formatter.Serialize(ms, obj); 77 | return ms.ToString(); 78 | } 79 | /// 80 | /// 二进制方式反序列化对象 81 | /// 82 | /// 83 | public static T DeSerialize(string str) where T : class 84 | { 85 | MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(str)); 86 | BinaryFormatter formatter = new BinaryFormatter(); 87 | T t = formatter.Deserialize(ms) as T; 88 | return t; 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /GOTO.Common/bin/Debug/GOTO.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.Common/bin/Debug/GOTO.Common.dll -------------------------------------------------------------------------------- /GOTO.Common/bin/Debug/GOTO.Common.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.Common/bin/Debug/GOTO.Common.pdb -------------------------------------------------------------------------------- /GOTO.ConsoleTest/GOTO.ConsoleTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E2646B5E-5595-4F3F-885B-3C1E5714850A} 8 | Exe 9 | Properties 10 | GOTO.ConsoleTest 11 | GOTO.ConsoleTest 12 | v4.0 13 | 512 14 | 发布\ 15 | true 16 | Disk 17 | false 18 | Foreground 19 | 7 20 | Days 21 | false 22 | false 23 | true 24 | 0 25 | 1.0.0.%2a 26 | false 27 | false 28 | true 29 | 30 | 31 | AnyCPU 32 | true 33 | full 34 | false 35 | bin\Debug\ 36 | DEBUG;TRACE 37 | prompt 38 | 4 39 | 40 | 41 | AnyCPU 42 | pdbonly 43 | true 44 | bin\Release\ 45 | TRACE 46 | prompt 47 | 4 48 | 49 | 50 | 51 | ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll 52 | True 53 | 54 | 55 | ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll 56 | True 57 | 58 | 59 | ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll 60 | True 61 | 62 | 63 | ..\packages\StackExchange.Redis.1.1.608\lib\net40\StackExchange.Redis.dll 64 | True 65 | 66 | 67 | 68 | 69 | 70 | ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll 71 | True 72 | 73 | 74 | 75 | ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Runtime.dll 76 | True 77 | 78 | 79 | ..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll 80 | True 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | {4b9c7261-e683-48fb-bacf-4bde95bc4130} 96 | GOTO.BigDataAccess 97 | 98 | 99 | {d8c9d1d5-84f3-4d21-8560-c2d7ae8aff1a} 100 | GOTO.Common 101 | 102 | 103 | 104 | 105 | Designer 106 | 107 | 108 | 109 | 110 | 111 | False 112 | Microsoft .NET Framework 4 %28x86 和 x64%29 113 | true 114 | 115 | 116 | False 117 | .NET Framework 3.5 SP1 Client Profile 118 | false 119 | 120 | 121 | False 122 | .NET Framework 3.5 SP1 123 | false 124 | 125 | 126 | False 127 | Windows Installer 4.5 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 144 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/GOTO.ConsoleTest.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | zh-CN 11 | false 12 | 13 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using GOTO.Common; 3 | using System.Diagnostics; 4 | 5 | namespace GOTO.ConsoleTest 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | Stopwatch sw = new Stopwatch(); 12 | int readvalue = 0; 13 | Console.WriteLine("当前时间:" + DateTime.Now); 14 | while (true) 15 | { 16 | Console.WriteLine("请输入操作选项:获取所有记录数(1),根据条件查询(2),数据写入(3),分离数据库(4),附加数据库(5),表添加索引(6),表删除索引(7),服务器缓存清除(9),检查服务器连接(11),检查数据库连接(12),检查表连接(13),删除记录(14),修改记录(15),清空某一数据结构存储(16),退出(q)"); 17 | string getread = Console.ReadLine(); 18 | if (getread.ToLower().Trim() == "q") 19 | { 20 | System.Environment.Exit(0); 21 | } 22 | readvalue = CommonHelper.ToInt(getread); 23 | sw.Restart(); 24 | switch (readvalue) 25 | { 26 | case 1: TestDB.getrowallcount(); break; 27 | case 2: TestDB.getlistcondition(); break; 28 | case 3: TestDB.addrow(); break; 29 | case 4: TestDB.databasedetach(); break; 30 | case 5: TestDB.databaseattach(); break; 31 | case 6: TestDB.tableindexadd(); break; 32 | case 7: TestDB.tableindexdel(); break; 33 | case 9: TestDB.servercacheclear(); break; 34 | case 11: TestDB.serverconnectioncheck(); break; 35 | case 12: TestDB.databaseexistsall(); break; 36 | case 13: TestDB.tableexistsall(); break; 37 | case 14: TestDB.delete(); break; 38 | case 15: TestDB.update(); break; 39 | case 16: TestDB.sqlbaseclear(); break; 40 | } 41 | sw.Stop(); 42 | Console.WriteLine(" 执行时间:" + sw.ElapsedMilliseconds+"毫秒"); 43 | } 44 | 45 | Console.WriteLine("当前时间:"+DateTime.Now); 46 | Console.ReadKey(); 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /GOTO.ConsoleTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("GOTO.ConsoleTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("GOTO.ConsoleTest")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("1ed075a4-92a9-495c-94b4-cb2f4a3b348e")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/TestDB.cs: -------------------------------------------------------------------------------- 1 | using GOTO.BigDataAccess.DBSql; 2 | using GOTO.BigDataAccess.DBSql.Manager; 3 | using GOTO.BigDataAccess.DBSql.Model; 4 | using GOTO.Common; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Data; 8 | using System.Linq; 9 | 10 | namespace GOTO.ConsoleTest 11 | { 12 | public static class TestDB 13 | { 14 | private static BigDataAccess.DBSql.XmlModel.SqlBaseItemXml basemodel = DBConfig.GetBaseXmlConfig(1112); 15 | /// 16 | /// 分离数据库 17 | /// 18 | public static void databasedetach() 19 | { 20 | var t1 = new ManagerDatabase().DatabaseDetachAll(basemodel); 21 | Console.WriteLine("分离数据库个数:" + t1); 22 | } 23 | /// 24 | /// 附加数据库 25 | /// 26 | public static void databaseattach() 27 | { 28 | var t2 = new ManagerDatabase().DatabaseAttachAll(basemodel); 29 | Console.WriteLine("附加数据库个数:" + t2); 30 | } 31 | /// 32 | /// 表添加索引 33 | /// 34 | public static void tableindexadd() 35 | { 36 | new ManagerTable().TableAddIndexAll(basemodel); 37 | } 38 | /// 39 | /// 表删除索引 40 | /// 41 | public static void tableindexdel() 42 | { 43 | new ManagerTable().TableDelIndexAll(basemodel); 44 | } 45 | /// 46 | /// 删除示例 47 | /// 48 | public static void delete() 49 | { 50 | Console.WriteLine(new DBAction().Delete(basemodel, 40001)); 51 | } 52 | /// 53 | /// 清除一组数据对象 54 | /// 55 | public static void sqlbaseclear() 56 | { 57 | new DBAction().SqlBaseClear(basemodel); 58 | } 59 | /// 60 | /// 更新记录示例 61 | /// 62 | public static void update() 63 | { 64 | Dictionary dic = new Dictionary(); 65 | dic.Add("str11", "dddddddddd"); 66 | dic.Add("num1", 11); 67 | dic.Add("num3", 0.11111111); 68 | Console.WriteLine(new DBAction().Update(basemodel, 40002, dic)); 69 | } 70 | /// 71 | /// 数据写入示列 72 | /// 73 | public static void addrow() 74 | { 75 | new DBAction().testAddRow(basemodel); 76 | } 77 | /// 78 | ///查询所有数据示列 79 | /// 80 | public static void getrowallcount() 81 | { 82 | long sqlnum1 = 0; 83 | DBRead serverread1 = new DBRead(); 84 | var d1 = serverread1.GetAllCount2(basemodel, ref sqlnum1); 85 | Console.WriteLine("返回记录总数:" + d1 + ",执行数据库次数:" + sqlnum1); 86 | } 87 | //查询列表示例 88 | public static void getlistcondition() 89 | { 90 | ConditionFieldModel condition = new ConditionFieldModel(); 91 | ConditionFieldItemModel fieldmodel = new ConditionFieldItemModel() { FieldName = "id", ValueMin = 0, ValueMax = 2012199998 }; 92 | condition.List.Add(fieldmodel); 93 | ConditionFieldItemModel fieldmodel2 = new ConditionFieldItemModel() { FieldName = "num1", ValueMin = 0, ValueMax = 35000 }; 94 | condition.List.Add(fieldmodel2); 95 | //ConditionFieldItemModel fieldmodel3 = new ConditionFieldItemModel() { FieldName = "num2", ValueMin = 300, ValueMax = 3500 }; 96 | //condition.List.Add(fieldmodel3); 97 | long sqlnum = 0; 98 | DBRead serverread = new DBRead(); 99 | //var d1 = serverread.GetCount(condition, ref sqlnum); 100 | //Console.WriteLine("返回记录总数:" + d1 + ",执行数据库次数:" + sqlnum); 101 | DataTable ddd2 = serverread.GetList(basemodel, condition, ref sqlnum); 102 | Console.WriteLine("返回记录数:" + ddd2.Rows.Count + ",执行数据库次数:" + sqlnum); 103 | } 104 | /// 105 | /// 服务器连接检查 106 | /// 107 | public static void serverconnectioncheck() 108 | { 109 | new ManagerServer().ServerConnectionCheckAll(basemodel); 110 | } 111 | /// 112 | /// 数据库检查 113 | /// 114 | public static void databaseexistsall() 115 | { 116 | new ManagerDatabase().DatabaseUseCheckAll(basemodel); 117 | } 118 | /// 119 | /// 数据表检查 120 | /// 121 | public static void tableexistsall() 122 | { 123 | new ManagerTable().TableUseCheckAll(basemodel); 124 | } 125 | public static void servercacheclear() 126 | { 127 | Console.WriteLine("请输入服务器编号(all:所有服务器)"); 128 | string servernumber = CommonHelper.ToStr(Console.ReadLine()); 129 | if (servernumber.ToLower().Trim() == "all") 130 | { 131 | new ManagerServer().ServerCacheClearAll(basemodel); 132 | } 133 | else 134 | { 135 | var item = DBConfig.GetServerXmlConfig(basemodel).SqlServerList.Where(m => m.Number == CommonHelper.ToLong(servernumber)).FirstOrDefault(); 136 | 137 | if (item != null) 138 | { 139 | new ManagerServer().ServerCacheClearItem(item); 140 | } 141 | } 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /GOTO.ConsoleTest/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.BigDataAccess.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/GOTO.BigDataAccess.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.BigDataAccess.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/GOTO.BigDataAccess.pdb -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/GOTO.Common.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.Common.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/GOTO.Common.pdb -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.exe -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.pdb -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.vshost.exe -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.vshost.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/GOTO.ConsoleTest.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/Microsoft.Threading.Tasks.Extensions.Desktop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/Microsoft.Threading.Tasks.Extensions.Desktop.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/Microsoft.Threading.Tasks.Extensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/Microsoft.Threading.Tasks.Extensions.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/Microsoft.Threading.Tasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/Microsoft.Threading.Tasks.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/StackExchange.Redis.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/StackExchange.Redis.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/System.IO.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/System.IO.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/System.IO.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | System.IO 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/System.Runtime.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/System.Runtime.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/System.Runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | System.Runtime 5 | 6 | 7 | 8 | Defines a provider for progress updates. 9 | The type of progress update value. 10 | 11 | 12 | Reports a progress update. 13 | The value of the updated progress. 14 | 15 | 16 | Identities the async state machine type for this method. 17 | 18 | 19 | Identities the state machine type for this method. 20 | 21 | 22 | Initializes the attribute. 23 | The type that implements the state machine. 24 | 25 | 26 | Gets the type that implements the state machine. 27 | 28 | 29 | Initializes the attribute. 30 | The type that implements the state machine. 31 | 32 | 33 | 34 | Allows you to obtain the method or property name of the caller to the method. 35 | 36 | 37 | 38 | 39 | Allows you to obtain the line number in the source file at which the method is called. 40 | 41 | 42 | 43 | 44 | Allows you to obtain the full path of the source file that contains the caller. 45 | This is the file path at the time of compile. 46 | 47 | 48 | 49 | Identities the iterator state machine type for this method. 50 | 51 | 52 | Initializes the attribute. 53 | The type that implements the state machine. 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /GOTO.ConsoleTest/bin/Debug/System.Threading.Tasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/GOTO.ConsoleTest/bin/Debug/System.Threading.Tasks.dll -------------------------------------------------------------------------------- /GOTO.ConsoleTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /GOTO.Segment.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GOTO.BigDataAccess", "GOTO.BigDataAccess\GOTO.BigDataAccess.csproj", "{4B9C7261-E683-48FB-BACF-4BDE95BC4130}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GOTO.Common", "GOTO.Common\GOTO.Common.csproj", "{D8C9D1D5-84F3-4D21-8560-C2D7AE8AFF1A}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GOTO.ConsoleTest", "GOTO.ConsoleTest\GOTO.ConsoleTest.csproj", "{E2646B5E-5595-4F3F-885B-3C1E5714850A}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {4B9C7261-E683-48FB-BACF-4BDE95BC4130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {4B9C7261-E683-48FB-BACF-4BDE95BC4130}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {4B9C7261-E683-48FB-BACF-4BDE95BC4130}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {4B9C7261-E683-48FB-BACF-4BDE95BC4130}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {D8C9D1D5-84F3-4D21-8560-C2D7AE8AFF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {D8C9D1D5-84F3-4D21-8560-C2D7AE8AFF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {D8C9D1D5-84F3-4D21-8560-C2D7AE8AFF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {D8C9D1D5-84F3-4D21-8560-C2D7AE8AFF1A}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {E2646B5E-5595-4F3F-885B-3C1E5714850A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {E2646B5E-5595-4F3F-885B-3C1E5714850A}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {E2646B5E-5595-4F3F-885B-3C1E5714850A}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {E2646B5E-5595-4F3F-885B-3C1E5714850A}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## 项目简介 3 | 设计大数据集成分析平台,主要功能是多种数据库及文件数据;访问;采集;解析,清洗,ETL,同时可以编写模型支持后台统计分析算法。设计数据可视化平台 ,应用于大数据的可视化和互动操作。为此,根据“先进实用、稳定可靠”的原则设计本数据处理平台。 4 | * 系统高可用、高性能、易扩展,安全稳定,实时可靠,满足用户的需要。 5 | * 系统可以进行扩展,增加数据的种类和数量。 6 | * 系统可以复用别的软件和算法。 7 | * 与其他大数据处理系统兼容性良好。 8 | * 系统使用c#开发,以服务或是中间件方式部署。 9 | 10 | ## 数据存储方案 11 | 12 | ![数据存储方案](/doc/datastoragescheme.jpg) 13 | 14 | 数据可以同时存入多种sql数据库服务器里面,每个数据库服务器中包含多个数据库,每个数据库中包含多张数据表。 15 | * 服务器配置见服务器配置存储空间配置。 16 | * 数据库配置见服务器配置数据库配置。 17 | * 数据表配置见服务器配置数据表配置。 18 | 19 | ## 逻辑架构 20 | 21 | ![逻辑架构](/doc/logicalarchitecture.jpg) 22 | 23 | ## 服务器配置 24 | 基于数据存放状态,配合算法实现快速定位数据所在区间。 25 | 26 | ## 配置同步规则 27 | 多个代理访问点的情况下防止数据配置文件差异化造成数据不准确性。 28 | * 存储空间配置 29 | * 某种数据存入数据库时根据此配置文件申请和使用资源,对此数据库服务器下的数据库和数据表作相应限制。 30 | * 常用配置属性有唯一编号,数据存放位置,数据存储空间大小,是否自动创建库,数据库服务器连接参数,数据库类型,数据库连接状态,存储数据结构标识,记录数据索引字段等。 31 | * 数据库配置 32 | * 常用配置属性有存储数据结构编号,数据库服务器编号,数据库唯一编号,数据库名,数据库使用空间大小,数据库存放位置,是否自动创建表,数据库是否可用,数据库是否可写入数据等。 33 | * 数据表配置 34 | * 常用配置属性有存储数据结构编号,数据库服务器编号,数据库编号,数据表唯一编号,表名,表使用空间大小,表存放记录总数,是否自动创建表,数据库是否可用,数据库是否可写入数据等。 35 | * 数据写入规则 36 | * 定位写入表位置 37 | * 根据服务器配置定位可写入表位置返回。 38 | * 服务器配置规则更新 39 | * 定位写入表位置时检测服务器,数据库,数据表可用状态,写入状态,存储空间,发现状态不一致时自动更新配置。 40 | * 数据写入表后更新服务器配置中数据表字段索引状态配置。 41 | * 数据存储状态记录 42 | * 更新数据存储记录 43 | * 更新数据库数据后,更新服务器配置中数据表字段索引状态配置,检查服务器、数据库、数据表存储空间是否占满,占满后更新可用状态为不可写入。 44 | * 定位数据存位置 45 | * 根据查询条件去服务器配置数据表字段索引状态配置中逐步缩小查询区间,同时满足所有条件的表即为数据存放位置。 46 | 47 | ## 部署方式 48 | * 统一服务代理 49 | * 以服务的方式部署一个访问点,所有需要操作数据库的请求,都由部署的这个访问点代理发起数据库操作。 50 | * 分布式代理 51 | * 部署多个数据访问点,每个访问点之间不冲突,所有的服务器配置更新都实时更新到多个访问点。 52 | 53 | ## 数据库访问方式 54 | * 为了更好的兼容消息中间件,实时操作,非实时操作等,提供以下几种操作数据库方式。 55 | * 单线程同步 56 | * 单线程异步 57 | * 多线程同步 58 | * 多线程异步 59 | 60 | ## 数据操作 61 | * 数据写入 62 | * 根据数据写入规则定位可写入位置写入数据库后,更新服务器配置。 63 | 64 | ![数据写入](/doc/datawrite.jpg) 65 | 66 | * 数据查询 67 | * 根据数据存储状态记录定位数据位置,然后查询数据,满足查询条件即返回。如前500条,查询的数据记录满500立即返回。 68 | 69 | ![数据查询](/doc/datasearch.jpg) 70 | 71 | * 数据删除 72 | * 根据数据库主键ID去数据存储状态记录定位数据位置,然后执行记录删除操作,执行成功后更新数据表字段索引状态配置。 73 | 74 | ![数据删除](/doc/datadel.jpg) 75 | 76 | * 数据修改 77 | * 根据数据库主键ID去数据存储状态记录定位数据位置,然后执行记录修改操作,执行成功后更新数据表字段索引状态配置。 78 | 79 | ![数据修改](/doc/dataupdate.jpg) 80 | 81 | ## 数据库管理 82 | * 回收机制 83 | * 增加数据库回收缓存和垃圾数据清理操作,当应用场景会消耗非常大的资源时数据库服务器自动的回收机制无法实时回收导致操作运行缓慢前,可以主动发起回收操作。 84 | 85 | ![回收机制](/doc/datarecover.jpg) 86 | 87 | * 数据迁移 88 | * 数据频繁的增删改导致系统表中的数据存在空白空间,和数据表记录的存放顺序变的混乱,增加数据迁移操作。 89 | 90 | ![数据迁移](/doc/datamove.jpg) 91 | 92 | ## 数据可靠性保证 93 | 数据安全性要求非常高时,对每个数据库服务器进行容灾备份设置;数据访问量非常大时可以设置主从分离;与此系统不会有任何冲突。 94 | * 缓存交互 95 | * 减少数据库查询负担,增加频繁访问数据写入第三方缓存,增加缓存数据定时更新操作。 96 | 97 | ## 系统特点 98 | 与其他大数据处理软件兼容性良好,在现有系统上增加此架构做数据操作简单,快速上手。 99 | -------------------------------------------------------------------------------- /doc/bigdataconfig/SqlBaseXml.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 1111 5 | 100 6 | testxmldatabase1_ 7 | testxmldatab1_ 8 | id 9 | id 10 | num1 11 | num2 12 | str11 13 | createdate 14 | D:\dbtest\db1 15 | 10 16 | 20000 17 | data source={0};user id={1};password={2};Connect Timeout=120;Pooling=true;Max Pool Size=4000;Min Pool Size=0; 18 | data source={0};initial catalog={1};user id={2};password={3};Connect Timeout=120;Pooling=true;Max Pool Size=4000;Min Pool Size=0; 19 | D:\dbtest\t1\SqlServerXml.xml 20 | D:\dbtest\t1\SqlDatabaseXml.xml 21 | D:\dbtest\t1\SqlTableXml.xml 22 | D:\dbtest\t1\SqlTableSqlFilePath.xml 23 | D:\dbtest\t1\SqlFieldXml.xml 24 | D:\dbtest\t1\SqlTableStructFilePath.xml 25 | 26 | 27 | 1112 28 | 100 29 | testxmldatabase2_ 30 | testxmldatab2_ 31 | id 32 | id 33 | num1 34 | num2 35 | str11 36 | createdate 37 | num3 38 | D:\dbtest\db2 39 | 10 40 | 20000 41 | data source={0};user id={1};password={2};Connect Timeout=120;Pooling=true;Max Pool Size=4000;Min Pool Size=0; 42 | data source={0};initial catalog={1};user id={2};password={3};Connect Timeout=120;Pooling=true;Max Pool Size=4000;Min Pool Size=0; 43 | D:\dbtest\t2\SqlServerXml.xml 44 | D:\dbtest\t2\SqlDatabaseXml.xml 45 | D:\dbtest\t2\SqlTableXml.xml 46 | D:\dbtest\t2\SqlTableSqlFilePath.xml 47 | D:\dbtest\t2\SqlFieldXml.xml 48 | D:\dbtest\t2\SqlTableStructFilePath.xml 49 | 50 | -------------------------------------------------------------------------------- /doc/bigdataconfig/t1/SqlDatabaseXml.xml: -------------------------------------------------------------------------------- 1 | 111110111636177656663278533testxmldatabase1_6361776566632785336501171D:\dbtest\db1false10truetrue111110111636177656863089021testxmldatabase1_6361776568630890216501171D:\dbtest\db1false10truetrue111110111636177656942795420testxmldatabase1_6361776569427954206501171D:\dbtest\db1false10truetrue111110111636177657022999562testxmldatabase1_6361776570229995626501171D:\dbtest\db1false10truetrue111110111636177657110721719testxmldatabase1_6361776571107217196501171D:\dbtest\db1false10truetrue111110111636177657193959870testxmldatabase1_6361776571939598706501171D:\dbtest\db1false10truetrue111110111636177657268794008testxmldatabase1_6361776572687940086501171D:\dbtest\db1false10truetrue111110111636177657345394151testxmldatabase1_6361776573453941516501171D:\dbtest\db1false10truetrue111110111636177657418110280testxmldatabase1_6361776574181102806501171D:\dbtest\db1false10truetrue111110111636177657490376426testxmldatabase1_6361776574903764266501171D:\dbtest\db1false10truetrue -------------------------------------------------------------------------------- /doc/bigdataconfig/t1/SqlServerXml.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 1111 5 | 10111 6 | 192.168.0.111 7 | 1433 8 | sa 9 | 123 10 | 94371840 11 | 10485760 12 | sqlserver 13 | 10 14 | D:\dbtest\db1 15 | false 16 | true 17 | true 18 | 19 | -------------------------------------------------------------------------------- /doc/bigdataconfig/t1/SqlTableSqlFilePath.xml: -------------------------------------------------------------------------------- 1 | CREATE TABLE {0}( [id] [bigint] primary key , [num1] [int] NULL, [num2] [bigint] NULL, [num3] [float] NULL, [str11] [nvarchar](50) NULL, [createdate] [datetime] default getdate(), [isdelete] [bit] default 0); -------------------------------------------------------------------------------- /doc/bigdataconfig/t1/SqlTableStructFilePath.xml: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /doc/bigdataconfig/t2/SqlDatabaseXml.xml: -------------------------------------------------------------------------------- 1 | 111210111636177657945250292testxmldatabase2_6361776579452502926501171D:\dbtest\db2false10truetrue111210111636177658012742416testxmldatabase2_6361776580127424166501171D:\dbtest\db2false10truetrue111210111636177658085714551testxmldatabase2_6361776580857145516501171D:\dbtest\db2false10truetrue111210111636177658160136682testxmldatabase2_6361776581601366826501171D:\dbtest\db2false10truetrue111210111636177658234432815testxmldatabase2_6361776582344328156501171D:\dbtest\db2false10truetrue111210111636177658301260936testxmldatabase2_6361776583012609366501171D:\dbtest\db2false10truetrue111210111636177658380453080testxmldatabase2_6361776583804530806501171D:\dbtest\db2false10truetrue111210111636177658445751200testxmldatabase2_6361776584457512006501171D:\dbtest\db2false10truetrue111210111636177658512553318testxmldatabase2_6361776585125533186501171D:\dbtest\db2false10truetrue111210111636177658584563460testxmldatabase2_6361776585845634606501171D:\dbtest\db2false10truetrue111210111636178401917472696testxmldatabase2_6361784019174726966501171D:\dbtest\db2false10truetrue111210111636178401999868859testxmldatabase2_6361784019998688596501171D:\dbtest\db2false10truetrue111210111636178402088201397testxmldatabase2_6361784020882013976501171D:\dbtest\db2false10truetrue111210111636178402157309518testxmldatabase2_6361784021573095186501171D:\dbtest\db2false10truetrue111210111636178402231253648testxmldatabase2_6361784022312536486501171D:\dbtest\db2false10truetrue111210111636178402304261776testxmldatabase2_6361784023042617766501171D:\dbtest\db2false10truetrue111210111636178402375085901testxmldatabase2_6361784023750859016501171D:\dbtest\db2false10truetrue111210111636178402453710039testxmldatabase2_6361784024537100396501171D:\dbtest\db2false10truetrue111210111636178402548870206testxmldatabase2_6361784025488702066501171D:\dbtest\db2false10truetrue111210111636178402613454319testxmldatabase2_6361784026134543196501171D:\dbtest\db2false10truetrue -------------------------------------------------------------------------------- /doc/bigdataconfig/t2/SqlServerXml.xml: -------------------------------------------------------------------------------- 1 | 111210111192.168.0.1111433sa123943718401048576020sqlserverD:\dbtest\db2falsetruetrue -------------------------------------------------------------------------------- /doc/bigdataconfig/t2/SqlTableSqlFilePath.xml: -------------------------------------------------------------------------------- 1 | CREATE TABLE {0}( [id] [bigint] primary key , [num1] [int] NULL, [num2] [bigint] NULL, [num3] [float] NULL, [str11] [nvarchar](50) NULL, [createdate] [datetime] default getdate(), [isdelete] [bit] default 0); -------------------------------------------------------------------------------- /doc/bigdataconfig/t2/SqlTableStructFilePath.xml: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /doc/datadel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/datadel.jpg -------------------------------------------------------------------------------- /doc/datamove.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/datamove.jpg -------------------------------------------------------------------------------- /doc/datarecover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/datarecover.jpg -------------------------------------------------------------------------------- /doc/datasearch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/datasearch.jpg -------------------------------------------------------------------------------- /doc/datastoragescheme.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/datastoragescheme.jpg -------------------------------------------------------------------------------- /doc/dataupdate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/dataupdate.jpg -------------------------------------------------------------------------------- /doc/datawrite.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/datawrite.jpg -------------------------------------------------------------------------------- /doc/logicalarchitecture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/108912/GOTO.Segment/a21bcaaecf658aebecb8cf72b4d26d51230c46b0/doc/logicalarchitecture.jpg --------------------------------------------------------------------------------