public JsonResult DoExecute() { var authorizedToken = ConfigManager.Setting["Marin_Token"]; var hasToken = this.Request.Headers.ContainsKey("marin-auth-token"); if (!hasToken) { throw new ArgumentException("Missing header"); } var tokenValue = Convert.ToString(this.Request.Headers["marin-auth-token"]); if (!authorizedToken.Equals(tokenValue)) { throw new ArgumentException("Invalid token provided"); } var extractor = new Extractor(); extractor.StatusMessage += Extractor_StatusMessage; int records = 0; try { records = extractor.DoUpsert(); } catch (Exception ex) { var newEx = new InvalidOperationException("Failed to complete the operation", ex); throw newEx; } return(Json(string.Format("Completed. {0} records affected", records))); }
public static void Run([TimerTrigger("0 6-18/2 * * 1-5")] TimerInfo myTimer, ILogger log) { _localLogger = log; _localLogger.LogInformation(string.Format("Starting the exececution of the function")); var extractor = new Extractor(); extractor.StatusMessage += Extractor_StatusMessage; try { extractor.DoUpsert(); } catch (Exception ex) { _localLogger.LogError(ex.ToString()); throw ex; } }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.White; Console.Clear(); var extractor = new Extractor(); extractor.StatusMessage += Extractor_StatusMessage; //var banks = new List<Bank>(new[] { new Bank() { Id = 99, Name = "Banco Central de Costa Rica", BuyCode = 317, SaleCode = 318, Type = "Publico" } }); try { extractor.DoUpsert(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("**** ERROR ****"); Console.WriteLine(ex.ToString()); Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine(); Console.WriteLine("Press Enter to finish"); Console.ReadLine(); }