public void FixtureSetUp() { // // TODO: Add constructor logic here // if (!_inited) { ServiceSettings.InitService("UnitTest-Common"); RpcProxyFactory.RegisterClientChannel(new RpcHttpClientChannel()); RpcProxyFactory.RegisterClientChannel(new RpcPipeClientChannel()); RpcProxyFactory.RegisterClientChannel(RpcInprocClientChannel.Instance); RpcProxyFactory.RegisterClientChannel(new RpcTcpClientChannel()); RpcServiceManager.RegisterServerChannel(new RpcHttpServerChannel(8899)); RpcServiceManager.RegisterServerChannel(new RpcPipeServerChannel("UnitTest", 10)); RpcServiceManager.RegisterServerChannel(RpcInprocServerChannel.Instance); RpcServiceManager.RegisterServerChannel(new RpcTcpServerChannel(3900)); RpcServiceManager.Start(); RpcServiceManager.RegisterService <IRpcTestService>(new RpcTestService()); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); _inited = true; } CurrentTestUrl = RpcTcpUrl; CurrentFailedUrl = "tcp://127.0.0.1:49494"; }
static void Main(string[] args) { ServiceSettings.InitService("IICCommon"); ITracing tracing = TracingManager.GetTracing(typeof(Program)); tracing.Info("test"); LinkedNode <string> linkedNode = new LinkedNode <string>(); linkedNode.Value = "1"; linkedNode.AddNext("2"); linkedNode.AddNext("3"); foreach (string str in linkedNode.GetValues()) { Console.WriteLine(str); } Console.ReadLine(); }
public static void MyClassInitialize(TestContext testContext) { ServiceSettings.InitService("UnitTest-Common"); }
static void Main(string[] args) { //Tuple<string, int> t = new Tuple<string, int>(item1: "test", item2: 1); //Console.WriteLine(t.Item1 + "_" +t.Item2); //return; //var strt= @"{""appid"":2312335602,""channel"":""ntsvc"",""event"":""updateresult"",""eggid"":7,""version"":""1000.0.0.112"",""locale"":2058,""os"":""5.1"",""uid"":""{ 4fe985127e49412bb9480bf1f6ec1cc1}"",""amd64"":false,""data"":{""eggid"":7,""parameter"":""update result"",""result"":3758096384}}"; //var aliveLog1 = JsonConvert.DeserializeObject<Alivelog>(strt); var path = System.Configuration.ConfigurationSettings.AppSettings["path"]; ServiceSettings.InitService("test"); //Console.WriteLine(DateTime.Now); //for (var i = 0; i < 1000; i++) { // DB.GetInstance.Test(); //} //Console.WriteLine(DateTime.Now); //return; AliveFilter afilter = new AliveFilter(); DirectoryInfo TheFolder = new DirectoryInfo(path); var lst = new List <string>(); //遍历文件夹 // var total = 0; System.Diagnostics.Stopwatch sp = new System.Diagnostics.Stopwatch(); Console.WriteLine("start " + DateTime.Now); var ff = TheFolder.GetFiles(); for (var i = 0; i < ff.Length; i++) { Console.WriteLine("process " + ff[i].FullName); var lines = File.ReadLines(ff[i].FullName); //lstStr.AddRange(lines); // tmpInt ++; // 3g个文件一批 sp.Start(); var aliveLst = new ConcurrentDictionary <string, Alivelog>(); Semaphore sem = new Semaphore(8, 8); try { // foreach(string str in lines) Console.WriteLine("foreach 开始" + DateTime.Now.ToString()); System.Threading.Tasks.Parallel.ForEach(lines, (str) => { sem.WaitOne(); string type = null; string date = null; string ip = null; string jsonStr = null; string eventValue = null; string killer = null; var b = BeforeFilter.Filter(str, out type, out date, out ip, out jsonStr, out eventValue, out killer); if (!b) { if (eventValue == "taskresult" && jsonStr.IndexOf(@"""eggid"":7") > -1) //(eventValue == "checkupdate") // (eventValue == "checkupdate2") //(eventValue == "updateresult" || eventValue == "checkupdate") { try { var aliveLog = JsonConvert.DeserializeObject <Alivelog>(jsonStr); if (aliveLog.uid.Length > 50) { aliveLog.uid = aliveLog.uid.Substring(0, 50); } if (aliveLog.channel.Length > 20) { aliveLog.channel = aliveLog.channel.Substring(0, 20); } if (aliveLog.data != null) { aliveLog.result = aliveLog.data.result; //aliveLog.str1 = aliveLog.data.dsq; //aliveLog.str2 = aliveLog.data.kill; aliveLog.str1 = aliveLog.data.taskid + ""; aliveLog.str2 = aliveLog.data.Return + ""; if (aliveLog.str2.Length > 100) { aliveLog.str2 = aliveLog.str2.Substring(0, 100); } aliveLog.str3 = aliveLog.data.parameter; if (aliveLog.str3.Length > 100) { aliveLog.str3 = aliveLog.str3.Substring(0, 100); } } aliveLog.Event = eventValue; aliveLog.kill = killer; aliveLog.alivetime = DateTime.Parse(date); aliveLog.ip = ip; //afilter.Process(aliveLog, aliveLst); // if (!aliveLst.ContainsKey(aliveLog.uid)) { aliveLst.TryAdd(Guid.NewGuid().ToString(), aliveLog); } } catch (Exception ex) { //eat } } } sem.Release(); } ); Console.WriteLine("foreach 结束" + DateTime.Now.ToString()); Console.WriteLine("total lines " + aliveLst.Count); Console.WriteLine("bulkinsert 开始" + DateTime.Now.ToString()); DB._proxyDb.BulkInsert <Alivelog>("alivelog", aliveLst.Values.ToArray()); Console.WriteLine("bulkinsert 结束" + DateTime.Now.ToString()); // Thread.Sleep(1000 * 1); } catch (Exception ex) { Console.WriteLine(ex); } finally { GC.Collect(); } sp.Stop(); Console.WriteLine(sp.ElapsedMilliseconds); } Console.WriteLine("finished"); Console.WriteLine("end " + DateTime.Now); Console.ReadLine(); }
static void Main(string[] args) { ServiceSettings.InitService("test"); // HaveEggLog(); // InsertLog(); // LogInUUids(); //CheckTaskFineshed(); // return; var path = System.Configuration.ConfigurationSettings.AppSettings["path"]; DirectoryInfo TheFolder = new DirectoryInfo(path); Console.WriteLine("start " + DateTime.Now); var ff = TheFolder.GetFiles(); for (var i = 0; i < ff.Length; i++) { var lst = new Dictionary <string, commonlog>(); Console.WriteLine("process " + ff[i].FullName); var lines = File.ReadLines(ff[i].FullName); var total = 0; foreach (var str in lines) { try { total++; //计算killer //var cl = taskresult_killer(str); //计算dsq var cl = update_dsq(str); if (cl != null) { var key = cl.uuid + "_" + cl.Event; if (!lst.Keys.Contains(key)) { lst.Add(key, cl); } } if (lst.Values.Count >= 80000) { DB._proxyDb.BulkInsert <commonlog>("commonlog", lst.Values.ToArray()); Console.WriteLine("lines " + lst.Values.Count); lst = new Dictionary <string, commonlog>(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } if (lst.Values.Count > 0) { DB._proxyDb.BulkInsert <commonlog>("commonlog", lst.Values.ToArray()); Console.WriteLine("lines " + lst.Values.Count); } Console.WriteLine("finished lines " + total); } Console.WriteLine("finished"); Console.ReadLine(); }