private void SyncThreadPoolSum(object model) { TaskDataParam dataparam = model as TaskDataParam; long revalue = CommonHelper.ToLong(DBProxy.GetDBHelper(dataparam.dbtype).GetSingle(dataparam.connstr, dataparam.sqlstr)); Threadrunnum++; Console.WriteLine("线程执行" + Threadrunnum + ",总数:" + revalue + "," + dataparam.sqlstr); rowcount += revalue; }
public long SyncTaskSum(TaskDataParam model) { long revalue = CommonHelper.ToLong(DBProxy.GetDBHelper(model.dbtype).GetSingle(model.connstr, model.sqlstr)); if (revalue < 1) { ; } Threadrunnum++; Console.WriteLine("线程执行" + Threadrunnum + ",总数:" + revalue + ",服务器名:" + model.servername); return(revalue); }
public int ServerConnectionCheckItem(object model) { var item = model as SqlServerItemXml; var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); bool connectionstatus = SocketHelper.TestConnection(item.ServerName, item.ServerPort, basemodel.SocketMillisecondsTimeout); if (connectionstatus) { string connstr = DBProxyAction.GetConnStr(basemodel, item); connectionstatus = DBProxy.GetDBHelper(item.DBType).ConnectionIsUse(connstr); } new ManagerConfig().ServerChangeIsUse(item, connectionstatus); Console.WriteLine("服务器:" + item.ServerName + ",isuse:" + connectionstatus); return(1); }
public static SqlTableItemXml AddTable(string currentconnstr, SqlServerItemXml item, SqlDatabaseItemXml item2) { var basemodel = DBConfig.GetBaseXmlConfig(item.BaseNumber); SqlTableItemXml tabletempmodel = new SqlTableItemXml(); tabletempmodel.BaseNumber = item.BaseNumber; tabletempmodel.ServerNumber = item.Number; tabletempmodel.DataBaseNumber = item2.Number; tabletempmodel.Number = DBConfig.GetTableNumber; tabletempmodel.TableName = basemodel.TablePrev + tabletempmodel.Number; tabletempmodel.IsWrite = true; tabletempmodel.IsUse = true; tabletempmodel.RowNum = basemodel.DefaultTableRowNum; tabletempmodel.StorageSize = (item2.StorageSize - item2.StorageSize / 5) / item2.TableNum; DBConfig.TableAdd(basemodel, tabletempmodel); DBProxy.GetDBHelper(item.DBType).ExecuteSql(currentconnstr, DBConfig.GetTableSql(basemodel, tabletempmodel.TableName)); return(tabletempmodel); }
public static void AddBulkRow(SqlBaseItemXml basemodel, SqlServerItemXml servermodel, string connstr, DataTable bulkdata, long databasenumber, long tablenumber, List <string> fieldtotal) { if (fieldtotal != null && fieldtotal.Count > 0) { var fieldlist = DBConfig.GetFieldXmlConfig(basemodel); foreach (var fieldname in fieldtotal) { string currentfieldname = fieldname; long rowmin = CommonHelper.ToLong(bulkdata.Compute("min(" + currentfieldname + ")", "")); long rowmax = CommonHelper.ToLong(bulkdata.Compute("max(" + currentfieldname + ")", "")); var fileldobjecttemp = fieldlist.SqlFieldList.Where(m => m.FieldName == currentfieldname && m.TableNumber == tablenumber).FirstOrDefault(); if (fileldobjecttemp != null) { DBConfig.FieldRemove(basemodel, fileldobjecttemp); if (fileldobjecttemp.ValueMin > rowmin) { fileldobjecttemp.ValueMin = rowmin; } if (fileldobjecttemp.ValueMax < rowmax) { fileldobjecttemp.ValueMax = rowmax; } DBConfig.FieldAdd(basemodel, fileldobjecttemp); } else { SqlFieldItemXml fileldmodel = new SqlFieldItemXml(); fileldmodel.BaseNumber = servermodel.BaseNumber; fileldmodel.ServerNumber = servermodel.Number; fileldmodel.DatabaseNumber = databasenumber; fileldmodel.TableNumber = tablenumber; fileldmodel.Number = DBConfig.GetFieldNumber; fileldmodel.FieldName = currentfieldname; fileldmodel.ValueMin = rowmin; fileldmodel.ValueMax = rowmax; DBConfig.FieldAdd(basemodel, fileldmodel); } } } DBProxy.GetDBHelper(servermodel.DBType).WriteBlockDataToDB(connstr, bulkdata); }
public DataTable GetList(SqlBaseItemXml basemodel, ConditionFieldModel condition, ref long sqlnum) { sqlnum = 0; long getmaxnum = 500; long getrowcount = 0; DataTable dt = new DataTable(); DBRule serverrule = new DBRule(); List <MatchServerList> serverlist = serverrule.GetMatchServer(basemodel, condition); if (serverlist != null && serverlist.Count > 0) { List <TaskDataParam> taskdataparam = new List <TaskDataParam>(); foreach (var item in serverlist) { var servermodel = DBConfig.GetServerItemXmlConfig(basemodel, item.ServerNumber); if (servermodel != null) { TaskDataParam tempparam = new TaskDataParam(); tempparam.servername = servermodel.ServerName; tempparam.dbtype = servermodel.DBType; tempparam.connstr = DBProxyAction.GetConnStr(basemodel, servermodel); tempparam.sqlstr = DBProxyAction.GetSqlList(servermodel, item, condition, getmaxnum); taskdataparam.Add(tempparam); } } Console.WriteLine("满足条件的数据库表:" + taskdataparam.Count); foreach (var itemparam in taskdataparam) { Console.WriteLine("访问服务器:" + itemparam.servername); var dttemp = DBProxy.GetDBHelper(itemparam.dbtype).GetDataDable(itemparam.connstr, itemparam.sqlstr); sqlnum++; if (dttemp != null && dttemp.Rows.Count > 0) { var dttempcount = dttemp.Rows.Count; if (getrowcount > 0) { foreach (DataRow dtrow in dttemp.Rows) { if (getrowcount >= getmaxnum) { return(dt); } getrowcount++; DataRow r = dt.NewRow(); r.ItemArray = dtrow.ItemArray; dt.Rows.Add(r); } } else { getrowcount = dttemp.Rows.Count; dt = dttemp; } } if (getrowcount >= getmaxnum) { return(dt); } } } return(dt); }