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 bool Delete(SqlBaseItemXml basemodel, long rowid) { bool revalue = false; bool changexml = false; var fieldmodel = DBConfig.GetFieldXmlConfig(basemodel).SqlFieldList.Where(m => m.FieldName == basemodel.PrimarykeyName && m.ValueMin <= rowid && m.ValueMax >= rowid).FirstOrDefault(); if (fieldmodel == null) { return(false); } var servermodel = DBConfig.GetServerItemXmlConfig(basemodel, fieldmodel.ServerNumber); var databasemodel = DBConfig.GetDatabaseItemXmlConfig(basemodel, fieldmodel.DatabaseNumber); var tablemodel = DBConfig.GetTableItemXmlConfig(basemodel, fieldmodel.TableNumber); revalue = DBProxyAction.Delete(basemodel, rowid, servermodel, databasemodel, tablemodel, fieldmodel); if (revalue) { if (fieldmodel.ValueMin == rowid) { DBConfig.FieldRemove(basemodel, fieldmodel); fieldmodel.ValueMin = rowid + 1; DBConfig.FieldAdd(basemodel, fieldmodel); changexml = true; } else if (fieldmodel.ValueMax == rowid) { DBConfig.FieldRemove(basemodel, fieldmodel); fieldmodel.ValueMax = rowid - 1; DBConfig.FieldAdd(basemodel, fieldmodel); changexml = true; } } if (changexml) { new ManagerConfig().SaveConfigField(basemodel); } return(revalue); }