Exemple #1
0
 public void testAddRow(SqlBaseItemXml basemodel)
 {
     try
     {
         ManagerConfig servicemanagerconfig = new ManagerConfig();
         int           writenum             = 0;
         for (int i = 0; i < 100000000; i++)
         {
             DBPosition position = new DBPosition();
             var        getbool  = position.GetPosition(basemodel);
             servicemanagerconfig.SaveConfigServer(basemodel);
             servicemanagerconfig.SaveConfigDatabase(basemodel);
             servicemanagerconfig.SaveConfigTable(basemodel);
             if (getbool)
             {
                 var serveritem = DBConfig.GetServerItemXmlConfig(basemodel, position.currentservernumber);
                 DBWrite.AddBulkRow(basemodel, serveritem, position.currentconnstrdatabase, testBulkRowData(basemodel, position.currenttable), position.currentdatabasenumber, position.currenttablenumber, basemodel.FieldIndexList);
                 servicemanagerconfig.SaveConfigField(basemodel);
                 Console.WriteLine("" + (++writenum));
             }
             else
             {
                 Console.WriteLine("请配置更多服务器后写入");
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemple #2
0
        public bool GetTable(SqlBaseItemXml basemodel, SqlServerItemXml item, SqlDatabaseItemXml item2)
        {
            var tablelist  = DBConfig.GetTableItemXmlConfigList(basemodel, item2.Number);
            var tablelist2 = tablelist.Where(m => m.IsUse == true && m.IsWrite == true).ToList();

            foreach (var tableobjectitem2 in tablelist2)
            {
                var temp3      = DBProxy.GetDBAccess(item.DBType).TableStorageSize(currentconnstrdatabase, tableobjectitem2.TableName);
                var temp3count = DBProxy.GetDBAccess(item.DBType).TableCount(currentconnstrdatabase, tableobjectitem2.TableName);
                if (tableobjectitem2.StorageSize > temp3 && tableobjectitem2.RowNum > temp3count)
                {
                    currenttable       = tableobjectitem2.TableName;
                    currenttablenumber = tableobjectitem2.Number;
                    isposition         = true;
                    return(isposition);
                }
                else
                {
                    new ManagerConfig().TableChangeIsWrite(tableobjectitem2);
                }
            }
            if (item2.TableNum > tablelist.Count() && item2.IsCreate)
            {
                var temptable = DBWrite.AddTable(currentconnstrdatabase, item, item2);
                currenttable       = temptable.TableName;
                currenttablenumber = temptable.Number;
                isposition         = true;
                return(isposition);
            }
            return(isposition);
        }
Exemple #3
0
        public bool GetDatabase(SqlBaseItemXml basemodel, SqlServerItemXml item)
        {
            var databaselist  = DBConfig.GetDatabaseItemXmlConfigList(basemodel, item.Number);
            var databaselist2 = databaselist.Where(m => m.IsUse == true && m.IsWrite == true).ToList();

            foreach (var item2 in databaselist2)
            {
                currentdatabase        = item2.DatabaseName;
                currentdatabasenumber  = item2.Number;
                currentconnstrdatabase = DBProxyAction.GetConnStr(basemodel, item, item2);
                var temp2      = DBProxy.GetDBAccess(item.DBType).DatabaseStorageSize(currentconnstrdatabase, item2.DatabaseName);
                var temp2count = DBConfig.GetTableXmlConfig(basemodel).SqlTableList.Where(m => m.DataBaseNumber == item2.Number).Count();
                if (item2.StorageSize > temp2 && item2.TableNum >= temp2count && GetTable(basemodel, item, item2))
                {
                    return(isposition);
                }
                else
                {
                    new ManagerConfig().DatabaseChangeIsWrite(item2);
                }
            }
            if (item.DatabaseNum > databaselist.Count() && item.IsCreate)
            {
                var tempdata = DBWrite.AddDatabase(currentconnstrserver, item);
                currentdatabase        = tempdata.DatabaseName;
                currentdatabasenumber  = tempdata.Number;
                currentconnstrdatabase = DBProxyAction.GetConnStr(basemodel, item, tempdata);
                var temptable = DBWrite.AddTable(currentconnstrdatabase, item, tempdata);
                currenttable       = temptable.TableName;
                currenttablenumber = temptable.Number;
                isposition         = true;
                return(isposition);
            }
            else
            {
                new ManagerConfig().ServerChangeIsWrite(item);
            }

            return(isposition);
        }