Example #1
0
        private static void GetFinancialHistory()
        {
            var stockCompanies = StockCompanyDataHandler.GetAllStockCompany();

            stockCompanies = stockCompanies.Where(x => x.LatsUpdatedOn == null).ToList();

            if (stockCompanies == null || stockCompanies.Count == 0)
            {
                Console.WriteLine("GetFinancialHistory: no stock company.");
                return;
            }
            var url     = "https://sgx-premium.wealthmsi.com/sgx/company/financials";
            var reqBody = "{{\"id\":\"{0}\"}}";

            foreach (var cmp in stockCompanies)
            {
                var tmpReqBody = string.Format(reqBody, cmp.TickerCode);
                var response   = WebRequestHelper.RequestUrlPost(url, tmpReqBody);

                if (!string.IsNullOrEmpty(response) && !response.ToLower().Contains("errorcode"))
                {
                    RequestLogDataHandler.AddRequestLog(url, tmpReqBody, response, RequestType.FinancialHistory);
                    cmp.LatsUpdatedOn = DateTime.UtcNow;
                    StockCompanyDataHandler.UpdateStockCompany(cmp);
                }
            }
            Console.WriteLine("GetFinancialHistory: done");
        }
Example #2
0
        private static void ConvertCompaniesListRequestLog()
        {
            var requestLogs = RequestLogDataHandler.GetRequestLog(RequestType.CompaniesList);

            if (requestLogs != null)
            {
                var requestLog = requestLogs[0];
                var jsonData   = JsonConvert.DeserializeObject <CompaniesJson>(requestLog.ResponseData);

                Console.WriteLine(jsonData.companies);

                if (jsonData.companies != null)
                {
                    foreach (var cmp in jsonData.companies)
                    {
                        StockCompanyDataHandler.AddStockCompany(cmp);
                    }
                }
            }

            Console.WriteLine("ConvertCompaniesListRequestLog completed.");
        }