Example #1
0
        private void BackgroundWorkerPrices_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string ItemString = (string)e.Argument;

            string Result = "";

            do
            {
                string EvepraisalResponse = QueryEvepraisal(ItemString);
                if (EvepraisalResponse.Length == 0)
                {
                    break;
                }

                EvepraisalResponse Response = new EvepraisalResponse();
                if (!DeserializeResponse(EvepraisalResponse, ref Response))
                {
                    break;
                }

                Result = ProcessResponse(Response);
            } while (false);

            e.Result = Result;
        }
Example #2
0
        private string ProcessResponse(EvepraisalResponse Response)
        {
            string Result = "";

            foreach (Item it in Response.appraisal.items)
            {
                string Name       = it.typeName;
                double SplitPrice = 0.5 * (it.prices.sell.min + it.prices.buy.max);
                Result += String.Format("{0:f2}\t{1}\n", SplitPrice, Name);
            }
            return(Result);
        }
Example #3
0
        private bool DeserializeResponse(string ResponseString, ref EvepraisalResponse Response)
        {
            bool Success = false;

            try
            {
                Response = JsonConvert.DeserializeObject <EvepraisalResponse>(ResponseString);
                Success  = true;
            }
            catch (Exception)
            {
                Success = false;
            }
            return(Success);
        }