Example #1
0
        /// <summary>
        /// Get a list of Historics queries in your account.
        /// </summary>
        /// <param name="user">The user making the request.</param>
        /// <param name="page">The page number to get.</param>
        /// <param name="per_page">The number of items per page.</param>
        /// <returns>A list of Historic objects.</returns>
        public static HistoricList list(User user, int page = 1, int per_page = 20)
        {
            try
            {
                Dictionary<string, string> parameters = new Dictionary<string, string>();
                parameters.Add("page", page.ToString());
                parameters.Add("per_page", per_page.ToString());
                JSONdn res = user.callApi("historics/get", parameters);

                if (!res.has("count"))
                {
                    throw new ApiException("No count in the response");
                }
                HistoricList retval = new HistoricList(res.getIntVal("count"));

                if (!res.has("data") && retval.TotalCount > 0)
                {
                    throw new ApiException("No historics in the response");
                }
                JToken[] children = res.getChildren("data");
                for (int i = 0; i < children.Length; i++)
                {
                    retval.Add(new Historic(user, new JSONdn(children[i])));
                }
                return retval;
            }
            catch (ApiException e)
            {
                if (e.Code == 400)
                {
                    throw new InvalidDataException(e.Message);
                }
                throw new ApiException("Unexpected API response code: " + e.Code.ToString() + " " + e.Message);
            }
        }
Example #2
0
        public void HittingEqual()
        {
            HistoricList.Add(new Tuple <double, char>(double.Parse(Current), CurrentOperation));
            Result = UpdateResult();

            Reset();
        }
Example #3
0
        public string UpdateHistoric()
        {
            if (HistoricList.Count == 0)
            {
                return(string.Empty);
            }

            string histo = string.Join(" ", HistoricList.Select(x => $"{x.Item2} {x.Item1}"));

            return(histo.Remove(0, 2) + " " + CurrentOperation);
        }
Example #4
0
        public void HittingOperation(string operation)
        {
            if (string.IsNullOrEmpty(Current))
            {
                return;
            }

            HistoricList.Add(new Tuple <double, char>(double.Parse(Current), CurrentOperation));

            CurrentOperation = operation.First();
            Historic         = UpdateHistoric();
            Current          = string.Empty;
            Result           = UpdateResult();
        }