public void SearchTheElem(int position) { Stopwatch time = new Stopwatch(); Stopwatch time1 = new Stopwatch(); Stopwatch time2 = new Stopwatch(); Stopwatch time3 = new Stopwatch(); Stopwatch time4 = new Stopwatch(); Stopwatch time5 = new Stopwatch(); if (position > PersonList.Count || position > StringList.Count || position > PersonManDictionary.Count || position > StringManDictionary.Count) { time.Start(); PersonList.Contains(new Person($"PersonList {position},", $"PersonList {position}", DateTime.Today)); Console.WriteLine($"The item is not included in the collection.\nIn PersonList is {position} element, time: {time.Elapsed}\n"); time.Stop(); time1.Start(); StringList.Contains($"String {position}"); Console.WriteLine($"The item is not included in the collection.\nIn StringList is {position} element, time: {time1.Elapsed}\n"); time1.Stop(); time2.Start(); PersonManDictionary.ContainsKey(new Person($"PersonManDictionary {position},", $"PersonManDictionary {position}", DateTime.Today)); Console.WriteLine($"The item is not included in the collection.\nIn PersonManDictionary is {position} element, time: {time2.Elapsed}\n"); time2.Stop(); time3.Start(); PersonManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The item is not included in the collection.\nIn PersonManDictionary is {position} element, time: {time3.Elapsed}\n"); time3.Stop(); time4.Start(); StringManDictionary.ContainsKey($"StringManDictionary {position}"); Console.WriteLine($"The item is not included in the collection.\nIn StringManDictionary is {position} element, time: {time4.Elapsed}\n"); time4.Stop(); time5.Start(); StringManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The item is not included in the collection.\nIn StringManDictionary is {position} element, time: {time5.Elapsed}\n"); time5.Stop(); } else if (position == PersonList.Count || position == StringList.Count || position == PersonManDictionary.Count || position == StringManDictionary.Count) { time.Start(); PersonList.Contains(new Person($"PersonList {position},", $"PersonList {position}", DateTime.Today)); Console.WriteLine($"The last element of the collection.\nIn PersonList is {position} element, time: {time.Elapsed}\n"); time.Stop(); time1.Start(); StringList.Contains($"String {position}"); Console.WriteLine($"The last element of the collection.\nIn StringList is {position} element, time: {time1.Elapsed}\n"); time1.Stop(); time2.Start(); PersonManDictionary.ContainsKey(new Person($"PersonManDictionary {position},", $"PersonManDictionary {position}", DateTime.Today)); Console.WriteLine($"The last element of the collection.\nIn PersonManDictionary is {position} element, time: {time2.Elapsed}\n"); time2.Stop(); time3.Start(); PersonManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The last element of the collection.\nIn PersonManDictionary is {position} element, time: {time3.Elapsed}\n"); time3.Stop(); time4.Start(); StringManDictionary.ContainsKey($"StringManDictionary {position}"); Console.WriteLine($"The last element of the collection.\nIn StringManDictionary is {position} element, time: {time4.Elapsed}\n"); time4.Stop(); time5.Start(); StringManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The last element of the collection.\nIn StringManDictionary is {position} element, time: {time5.Elapsed}\n"); time5.Stop(); } else if (position == PersonList.Count / 2 || position == StringList.Count / 2 || position == PersonManDictionary.Count / 2 || position == StringManDictionary.Count / 2) { time.Start(); PersonList.Contains(new Person($"PersonList {position},", $"PersonList {position}", DateTime.Today)); Console.WriteLine($"The item is in the middle of the collection.\nIn PersonList is {position} element, time: {time.Elapsed}\n"); time.Stop(); time1.Start(); StringList.Contains($"String {position}"); Console.WriteLine($"The item is in the middle of the collection.\nIn StringList is {position} element, time: {time1.Elapsed}\n"); time1.Stop(); time2.Start(); PersonManDictionary.ContainsKey(new Person($"PersonManDictionary {position},", $"PersonManDictionary {position}", DateTime.Today)); Console.WriteLine($"The item is in the middle of the collection.\nIn PersonManDictionary is {position} element, time: {time2.Elapsed}\n"); time2.Stop(); time3.Start(); PersonManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The item is in the middle of the collection.\nIn PersonManDictionary is {position} element, time: {time3.Elapsed}\n"); time3.Stop(); time4.Start(); StringManDictionary.ContainsKey($"StringManDictionary {position}"); Console.WriteLine($"The item is in the middle of the collection.\nIn StringManDictionary is {position} element, time: {time4.Elapsed}\n"); time4.Stop(); time5.Start(); StringManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The item is in the middle of the collection.\nIn StringManDictionary is {position} element, time: {time5.Elapsed}\n"); time5.Stop(); } else { time.Start(); PersonList.Contains(new Person($"PersonList {position},", $"PersonList {position}", DateTime.Today)); Console.WriteLine($"The first element of the collection.\nIn PersonList is {position} element, time: {time.Elapsed}\n"); time.Stop(); time1.Start(); StringList.Contains($"String {position}"); Console.WriteLine($"The first element of the collection.\nIn StringList is {position} element, time: {time1.Elapsed}\n"); time1.Stop(); time2.Start(); PersonManDictionary.ContainsKey(new Person($"PersonManDictionary {position},", $"PersonManDictionary {position}", DateTime.Today)); Console.WriteLine($"The first element of the collection.\nIn PersonManDictionary is {position} element, time: {time2.Elapsed}\n"); time2.Stop(); time3.Start(); PersonManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The first element of the collection.\nIn PersonManDictionary is {position} element, time: {time3.Elapsed}\n"); time3.Stop(); time4.Start(); StringManDictionary.ContainsKey($"StringManDictionary {position}"); Console.WriteLine($"The first element of the collection.\nIn StringManDictionary is {position} element, time: {time4.Elapsed}\n"); time4.Stop(); time5.Start(); StringManDictionary.ContainsValue(new Man(new Person($"\nPerson {position},", $"Person {position}", DateTime.Now), LevelsOfProficiency.A, position)); Console.WriteLine($"The first element of the collection.\nIn StringManDictionary is {position} element, time: {time5.Elapsed}\n"); time5.Stop(); } }
public ParseOrderResult ParseOrder(string orderAsString) { if (Organisation == null) { return(new ParseOrderResult(ParseOrderResultState.OrganisationNotFound)); } ParseOrderResultState state = ParseOrderResultState.OK; List <string> catalogIds = Catalogs.Select(c => c.Id).ToList(); List <string> orderLineArray = orderAsString.Split(',').ToList(); Order order = Order.CreateNew(); //new Order() /* * { * OrganisationId = this.Organisation.Id * };*/ order.OrganisationId = this.Organisation.Id; if (this.Account != null) { order.Account = this.Account; order.AccountId = this.Account.Id; } if (this.Party != null) { order.Party = this.Party; order.PartyId = this.Party.Id; } order.OrderType = OrderType.SalesOrder; order.OrderLines = new List <OrderLine>(); List <ParseOrderLineResult> orderLineResults = new List <ParseOrderLineResult>(); PersonList personList = new PersonList(); int lineNumber = 10; orderLineArray.ForEach(ol => { ParseOrderLineResult orderLineResult = ParseOrderLine(this.Organisation, catalogIds, ol.Trim()); orderLineResults.Add(orderLineResult); if (orderLineResult.State == ParseOrderLineResultState.OK) { if (lineNumber == 10) { //order.TaxIncluded = orderLineResult } var orderLine = orderLineResult.OrderLine; if (!string.IsNullOrWhiteSpace(orderLine.Persons)) { PersonCodes codes = new PersonCodes(orderLine.Persons); foreach (string code in codes.Codes) { if (!personList.Contains(code)) { personList.AddPerson(new Person(code, code)); } } } orderLine.Order = order; orderLine.LineNumber = lineNumber; order.OrderLines.Add(orderLine); if (orderLine.Product.NeedsPlanning) { order.IsAppointment = true; } lineNumber += 10; } else { state = ParseOrderResultState.AtLeastOneProblem; } }); order.Persons = personList.ToString(); order.NrOfPersons = personList.Persons.Count; ParseOrderResult result = new ParseOrderResult(order, state); result.OrderLineResults = orderLineResults; return(result); }