public bool IsValidPrice(string ctrlC_PoE, CustomerInfo customer) { bool isvalidprice = false; bool isvalidcurrency = false; if (!String.IsNullOrEmpty(ctrlC_PoE) && ctrlC_PoE != "empty_string") { var lines = ctrlC_PoE.Split('\n'); foreach (string str in lines) { if (str.Contains("Note: ~price")) { var result = Regex.Replace(str, "[^0-9.]", ""); double price = Convert.ToDouble(result); if (price <= customer.Cost) { isvalidprice = true; } int length = str.Length - 1; int begin = 0; for (int i = length; i > 0; i--) { if (str[i] == ' ') { begin = i + 1; break; } } result = str.Substring(begin, str.Length - begin).Replace("\r", ""); if (_CurrenciesService.GetCurrencyByName(result).Name == customer.Currency.Name) { isvalidcurrency = true; } if (isvalidcurrency && isvalidprice) { return(true); } } } } return(false); }
public Item GetCurrency(CurrenciesService _CurrenciesService, string clip) { if (String.IsNullOrEmpty(clip) || clip == "empty_string") { return(null); } Item retItem = new Item(); retItem.Name = GetName(clip); retItem.StackSize = GetStackSize(clip); retItem.Price = new Price() { CurrencyType = _CurrenciesService.GetCurrencyByName(retItem.Name) }; if (retItem.Price.CurrencyType == null) { return(null); } retItem.Price.Cost = retItem.Price.CurrencyType.ChaosEquivalent * retItem.StackSize; return(retItem); }
private CustomerInfo GetInfo(string log24) { //GetFullInfoCustomer try { if (log24.Contains("@From")) { if (log24.Contains("Hi, I would like to buy your")) { var cus_inf = new CustomerInfo(); cus_inf.OrderType = CustomerInfo.OrderTypes.SINGLE; int length; int begin; //Nickname if (!log24.Contains("> ")) { begin = log24.IndexOf("@From ") + 6; length = log24.IndexOf(": ") - begin; cus_inf.Nickname = log24.Substring(begin, length); } else { begin = log24.IndexOf("> ") + 2; length = log24.IndexOf(": ") - begin; cus_inf.Nickname = log24.Substring(begin, length); } //Product begin = log24.IndexOf("your ") + 5; length = log24.IndexOf(" listed") - begin; cus_inf.Product = log24.Substring(begin, length); //Currency begin = log24.IndexOf(" in") - 1; for (int i = 0; i < 50; i++) { if (log24[begin - i] == ' ') { begin = begin - i + 1; break; } } length = log24.IndexOf(" in") - begin; cus_inf.Currency = _CurrenciesService.GetCurrencyByName(log24.Substring(begin, length)); //Price begin = log24.IndexOf("for ") + 4; cus_inf.Cost = Utils.GetNumber(begin, log24); //Stash Tab begin = log24.IndexOf("tab \"") + 5; length = log24.IndexOf("\"; position") - begin; cus_inf.Stash_Tab = log24.Substring(begin, length); //left begin = log24.IndexOf("left ") + 5; cus_inf.Left = (int)Utils.GetNumber(begin, log24); //top begin = log24.IndexOf("top ") + 4; cus_inf.Top = (int)Utils.GetNumber(begin, log24); //to chaos chaosequivalent cus_inf.Chaos_Price = cus_inf.Currency.ChaosEquivalent * cus_inf.Cost; //trade accepted cus_inf.TradeStatus = CustomerInfo.TradeStatuses.STARTED; return(cus_inf); } if (log24.Contains("I'd like to buy your")) { var cus = new CustomerInfo(); cus.OrderType = CustomerInfo.OrderTypes.MANY; cus.Nickname = Regex.Replace(log24, @"([\w\s\W]+@From )|(: [\w\W\s]*)|(<[\w\W\s]+> )", ""); cus.Product = Regex.Replace(log24, @"([\w\W]+your +[\d,]* )|( for+[\w\s\W]*)|( Map [()\d\w]+)", ""); string test = Regex.Match(log24, @"your ([\d]+)").Groups[1].Value; cus.NumberProducts = Convert.ToInt32(test); cus.Cost = Convert.ToDouble(Regex.Replace(log24, @"([\s\w\W]+for my )|([\D])", "").Replace(".", ",")); cus.Currency = _CurrenciesService.GetCurrencyByName(Regex.Replace(log24, @"([\w\s\W]+my +[\d,.]* )|( in +[\w\W\s]*)", "")); return(cus); } } } catch (Exception e) { _LoggerService.Log(e.Message); } return(null); }