static void Main() { ILogger log = new Log4NetLogger("TestLog4Net.Program"); const string publisher = "TestLog4Net"; const string category = "Main"; log.LogDebug("This is a Debug log message"); log.LogDebug(publisher, category, "This is a Debug log message with publisher and category"); log.LogInfo("This is an info log message"); log.LogInfo(publisher, category, "This is an info log message with publisher and category"); log.LogWarning("This is a Warning log message"); log.LogWarning(publisher, category, "This is a Warning log message with publisher and category"); log.LogError("This is an Error log message"); log.LogError(publisher, category, "This is an Error log message with publisher and category"); log.LogFatal("This is a Fatal log message"); log.LogFatal(publisher, category, "This is a Fatal log message with publisher and category"); for (var i = 1; i <= 10; ++i) { if (UseThreading) { var t = new Thread(ProcessAlpha); log.LogDebug("Created thread " + t.ManagedThreadId.ToString(CultureInfo.InvariantCulture)); t.Start(i); } else { ProcessAlpha(i); } } Console.WriteLine("Finished!"); Console.ReadLine(); }
/// <summary> /// Gets all the tweets from the api https://badapi.iqvia.io /// </summary> /// <returns>Final JsonResult with all the tweets between the dates</returns> public ActionResult LoadTweets() { try { System.Net.WebClient wc = new System.Net.WebClient();//Create a webclient object DateTime startDate = new DateTime(2016, 1, 1); DateTime endDate = new DateTime(2017, 12, 31, 23, 59, 59); //Contains the list of result set returned by the API List <TwitterModel> lstTwitterModel = new List <TwitterModel>(); //Get the first set of results string str = wc.DownloadString("https://badapi.iqvia.io/api/v1/Tweets?startDate=" + startDate.ToString("yyyy-MM-dd") + "&endDate=" + endDate.ToString("yyyy-MM-dd")); //Loop until the data returned is empty while (str != "[]") { //Get the list for the dates str = wc.DownloadString("https://badapi.iqvia.io/api/v1/Tweets?startDate=" + startDate.ToString("yyyy-MM-dd") + "&endDate=" + endDate.ToString("yyyy-MM-dd")); //Add the result to the final list lstTwitterModel.AddRange(JsonConvert.DeserializeObject <List <TwitterModel> >(str)); //Set the start date as the last records date startDate = lstTwitterModel[lstTwitterModel.Count - 1].stamp; } return(new JsonResult() { Data = lstTwitterModel, MaxJsonLength = Int32.MaxValue }); } catch (Exception ex) { Log4NetLogger.LogError(ex.ToString(), ex, this.ToString()); ViewBag.Message = "Error has occured. Please contact administrator."; return(new JsonResult()); } }