private static void Main(string[] args) { CLP.About(); if (args.Length == 0) { char[] delimiterChars = { ' ' }; if (File.Exists("tpccbench.txt")) { //attempt to open file with command line args in it StreamReader re = File.OpenText("tpccbench.txt"); string input = re.ReadToEnd(); string[] cmdargs = input.Split(delimiterChars); re.Close(); //send the command line to the parser CLP.Cmdline(cmdargs); } else { Globals.Err = 1; Console.WriteLine("tpccbench.txt not found, no commands on command line found."); } } else { CLP.Cmdline(args); } if (Globals.Err == 1) { Console.WriteLine("Error detected, execution stopped."); } else if (Globals.Err == 2) { Console.WriteLine("Program Exit."); } else { //LoadGlobal.LoadGeneralGlobals(); LoadGlobals.LoadMasterConnectionString(); LoadGlobals.LoadLogFilePath(); var trd = new Thread(PLOG.WriteLog); //trd.IsBackground = true; trd.Start(); PLOG.Write("Running Benchmark on server: " + Globals.ServerName); PLOG.Write("Running Benchmark on database: " + Globals.DatabaseName); const string query = "select @@version"; //Console.WriteLine(query); try { //Globals.SQLVersion = ClientDataAccess.RunProc(Globals.StrPublisherConn, query); } catch { Console.WriteLine("Unable to connect to database, correct and retry"); PLOG.Write("Unable to connect to database, correct and retry", 1); Thread.Sleep(1000); Globals.Err = 1; } if (Globals.Err == 1) { Console.WriteLine("Error detected, execution stopped."); } else { if (Globals.Heartbeat == 1) { PLOG.Write("Heartbeat enabled."); var heartbeat = new Thread(TpcUtils.Heartbeat) { IsBackground = true }; heartbeat.Start(); } var stpStartInfo = new STPStartInfo(); if (!(Globals.StaggeredLoad == 0)) { stpStartInfo.StartSuspended = false; stpStartInfo.MaxWorkerThreads = Globals.NumClients + 1; stpStartInfo.MinWorkerThreads = Globals.NumClients + 1; stpStartInfo.IdleTimeout = 10 * 1000; } else { stpStartInfo.StartSuspended = true; stpStartInfo.MaxWorkerThreads = Globals.NumClients + 1; stpStartInfo.MinWorkerThreads = Globals.NumClients + 1; stpStartInfo.IdleTimeout = 10 * 1000; } var smartThreadPool = new SmartThreadPool(stpStartInfo); var s = new StopWatch(); int i = 0; var clients = new Tpcc[Globals.NumClients]; PLOG.Write("Start TPC benchmark :" + DateTime.Now); s.Start(); if (!(Globals.StaggeredLoad == 0)) { while (i < Globals.NumClients) { clients[i] = new Tpcc { Clientid = i + 1 }; smartThreadPool.QueueWorkItem(new WorkItemCallback(clients[i].Client)); Console.WriteLine("Client " + i + " Loaded."); Thread.Sleep(Globals.StaggeredLoad); i++; } } else { while (i < Globals.NumClients) { clients[i] = new Tpcc { Clientid = i + 1 }; smartThreadPool.QueueWorkItem(new WorkItemCallback(clients[i].Client)); i++; } } PLOG.Write("Started On: " + DateTime.Now); if (Globals.NumLoops == 0) { PLOG.Write("Target Run Time: " + (Globals.MaxRunTimeMin)); } else { PLOG.Write("Number of Loops: " + (Globals.NumLoops)); } PLOG.Write("number of clients to load: " + i); PLOG.Write("Work load Mix:"); if (Globals.RawWrite == 0) { PLOG.Write("Percent New Orders: " + Globals.PNO); PLOG.Write("Percent Order Status: " + (Globals.POS)); PLOG.Write("Percent Stock Level: " + (Globals.PSL)); PLOG.Write("Percent Payment: " + (Globals.PP)); PLOG.Write("Percent Delivery: " + (Globals.PD)); PLOG.Write("Total Percent: " + ((Globals.PNO) + (Globals.POS) + (Globals.PSL) + (Globals.PD) + (Globals.PP))); } else { PLOG.Write("Raw Inserts: 100"); } PLOG.Read(); //Console.WriteLine("Threads waiting callback: " + smartThreadPool.WaitingCallbacks); if (Globals.StaggeredLoad == 0) { smartThreadPool.Start(); } // Wait for the completion of all work items smartThreadPool.WaitForIdle(); s.Stop(); smartThreadPool.Shutdown(); if (Globals.RawWrite == 1) { PLOG.Write("Total number of operations: " + Globals.TotalCount); PLOG.Write("elapsed time in seconds: " + s.GetElapsedTimeSecs()); PLOG.Write("elapsed time in minutes: " + s.GetElapsedTimeSecs() / 60); PLOG.Write("Total number of operations per minute: " + (Globals.TotalCount / (s.GetElapsedTimeSecs() / 60))); } else { PLOG.Write("Total number of new orders: " + Globals.Countno); PLOG.Write("Total number of order status: " + Globals.Countos); PLOG.Write("Total number of payments: " + Globals.Countp); PLOG.Write("Total number of new diliveries: " + Globals.Countd); PLOG.Write("Total number of new stock level: " + Globals.Countsl); PLOG.Write("Total number of operations: " + (Globals.Countno + Globals.Countos + Globals.Countp + Globals.Countd + Globals.Countsl)); PLOG.Write("elapsed time in seconds: " + s.GetElapsedTimeSecs()); PLOG.Write("elapsed time in minutes: " + s.GetElapsedTimeSecs() / 60); PLOG.Write("Total number of new orders per minute: " + (Globals.Countno / (s.GetElapsedTimeSecs() / 60))); } PLOG.Write("end TPC benchmark :" + DateTime.Now); PLOG.Read(); Globals.RunFlag = 1; } trd.Join(10000); //Console.ReadKey(); } }
public EDI835SchemaModel ParseEDI835(string fileText) { bool payerSeg = false; bool payeeSeg = false; string claimSegment = string.Empty; string segmentValue = string.Empty; string[] ediTextArray = fileText.Split("~"); CLP clp = null; SVC svc = null; bool findNextCLP = false; bool isServiceLineVisited = false; foreach (string stringSegment in ediTextArray) { string[] segmentArray = stringSegment.Split("*"); if (segmentArray != null) { IEnumerable <string> values = Enum.GetValues(typeof(EDI835Segments)) .OfType <EDI835Segments>() .Select(s => Convert.ToString(s)); if (values.Contains(segmentArray[0].TrimStart())) { if (segmentArray[0].TrimStart() != "CLP" && findNextCLP == true) { continue; } //else continue; segmentValue = segmentArray[0].TrimStart(); if (claimSegment == "CLP") { segmentValue = "CLP"; } switch (segmentValue) { case "ISA": { ISA ISA = GetSegmentInfo <ISA>(new ISA(), segmentArray); ediSchemaModel.ISA = ISA; break; } case "GS": { GS GS = GetSegmentInfo <GS>(new GS(), segmentArray); ediSchemaModel.GS = GS; break; } case "ST": { ST ST = GetSegmentInfo <ST>(new ST(), segmentArray); ediSchemaModel.ST = ST; break; } case "BPR": { BPR BPR = GetSegmentInfo <BPR>(new BPR(), segmentArray); ediSchemaModel.BPR = BPR; break; } case "TRN": { TRN TRN = GetSegmentInfo <TRN>(new TRN(), segmentArray); ediSchemaModel.TRN = TRN; break; } case "DTM": { DTM DTM = GetSegmentInfo <DTM>(new DTM(), segmentArray); ediSchemaModel.DTM = DTM; break; } case "N1": { if (segmentArray[1] == "PR") { N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray); ediSchemaModel.PayerInfo = N1; payerSeg = true; } else if (segmentArray[1] == "PE") { N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray); ediSchemaModel.PayeeInfo = N1; payeeSeg = true; } break; } case "N3": { if (payerSeg) { N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray); ediSchemaModel.PayerAddress = N3; } else if (payeeSeg) { N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray); ediSchemaModel.PayeeAddress = N3; } break; } case "N4": { if (payerSeg) { N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray); ediSchemaModel.PayerCityStateZip = N4; payerSeg = false; } else if (payeeSeg) { N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray); ediSchemaModel.PayeeCityStateZip = N4; payeeSeg = false; } break; } case "CLP": { claimSegment = "CLP"; switch (segmentArray[0].TrimStart()) { case "CLP": { findNextCLP = false; if (clp != null) { ediSchemaModel.CLPList.Add(clp); isServiceLineVisited = false; clp = null; } clp = GetSegmentInfo <CLP>(new CLP(), segmentArray); break; } case "SVC": { //if (svc != null) //{ // if (clp.SVCList == null) clp.SVCList = new List<SVC>(); // clp.SVCList.Add(svc); // svc = null; //} svc = GetSegmentInfo <SVC>(new SVC(), segmentArray); if (clp != null && clp.SVCList == null) { clp.SVCList = new List <SVC>(); } clp.SVCList.Add(svc); isServiceLineVisited = true; break; } case "CAS": { if (isServiceLineVisited) { CAS CAS = GetSegmentInfo <CAS>(new CAS(), segmentArray); if (svc.SVCAdjList == null) { svc.SVCAdjList = new List <CAS>(); } svc.SVCAdjList.Add(CAS); CAS = null; } break; } case "REF": { if (segmentArray[1].Trim() == "6R" && svc != null && svc.REF == null) { svc.REF = new REF(); svc.REF = GetSegmentInfo <REF>(new REF(), segmentArray); } break; } case "GE": { if (clp != null) { ediSchemaModel.CLPList.Add(clp); isServiceLineVisited = false; clp = null; findNextCLP = true; } break; } default: { break; } } break; } } } } } return(ediSchemaModel); }