public void ChangeIP() { ViewIP changeIP = new ViewIP(); if (changeIP.ShowDialog() == DialogResult.OK) { SERVER_IP = changeIP.newIP; } }
static void RefreshView() { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); var client = DriverConfiguration.Client; var db = client.GetDatabase(DriverConfiguration.DatabaseNamespace.DatabaseName); IMongoCollection <ViewIP> categories = db.GetCollection <ViewIP>("levelIp"); List <ViewIP> list = categories.Find(Builders <ViewIP> .Filter.Eq("view", "BaiSpi")).ToList <ViewIP>(); var newMongoClientSettings = DriverConfiguration.GetClientSettings("mongodb://192.168.30.144:27017"); var newClent = new MongoClient(newMongoClientSettings); var newDB = newClent.GetDatabase("network"); IMongoCollection <NewViewIPData> newCategories = newDB.GetCollection <NewViewIPData>("levelip"); List <NewViewIPData> newlist = newCategories.Find(Builders <NewViewIPData> .Filter.Empty).ToList <NewViewIPData>(); IMongoCollection <ViewIP> newCategories2 = db.GetCollection <ViewIP>("baispi"); List <ViewIP> vslist = new List <ViewIP>(); foreach (NewViewIPData nv in newlist) { ViewIP tempV = new ViewIP(); tempV.start = Convert.ToInt64(nv.start); tempV.end = Convert.ToInt64(nv.end); tempV.view = "BaiSpi"; tempV.level = 0; vslist.Add(tempV); //bool isMixed = false; //foreach (ViewIP v in list) //{ // if (Convert.ToInt64(nv.start) >= v.start && Convert.ToInt64(nv.start) <= v.end) // { // tempV = v; // isMixed = true; // } // else if (Convert.ToInt64(nv.end) >= v.start && Convert.ToInt64(nv.end) <= v.end) // { // tempV = v; // isMixed = true; // } //} //if (isMixed)//有交集 更新 //{ // Console.WriteLine(nv.network + " mixed"); //} //else //{//无交集 添加 // Console.WriteLine(nv.network + " not mixed"); //} } Console.WriteLine(vslist.Count); categories.InsertMany(vslist); watch.Stop(); }