/// <summary>Gets the bitfinex active orders asynchronous.</summary> /// <param name="stoppingToken">The stopping token.</param> /// <returns>Task of IEnumerable of BitfinexOrder.</returns> /// <exception cref="Exception">processed.</exception> public async Task <IEnumerable <BitfinexOrder> > GetBitfinexActiveOrdersAsync(CancellationToken stoppingToken) { int activeOrdersRequestMaxTry = 5; do { var activeOrdersRequest = await _bitfinexClient.GetActiveOrdersAsync(); if (!activeOrdersRequest.Success) { activeOrdersRequestMaxTry -= 1; if (activeOrdersRequestMaxTry == 0) { await _loggerService.CreateLog(new Log(LogType.Error, $"AutoTrader v{_assemblyVersion}, GetBitfinexActiveOrdersAsync()", activeOrdersRequest.Error.Message)); throw new Exception("processed"); } await Task.Delay(1000 * 20 * 1, stoppingToken); } else { return(activeOrdersRequest.Data); } }while (true); }
public void SendEmails() { try { _loggerService.CreateLog(LoggerService.LogType.Info, "Get data from file", null); var messages = GetMessages(100); messages.ForEach(message => { _mailService.SendEmail(message.Email, message.Body, message.Subject); }); } catch (Exception ex) { _loggerService.CreateLog(LoggerService.LogType.Error, "Messages send error", ex); } }
public async Task SendEmail(string email, string subject, string body) { try { await _fluentMailer.CreateMessage() .WithViewBody(body) .WithReceiver(email) .WithSubject(subject) .SendAsync(); _loggerService.CreateLog(LoggerService.LogType.Info, "Message was sent", null); } catch (Exception ex) { _loggerService.CreateLog(LoggerService.LogType.Warning, "Messages was not sent", ex); } }
public void Start() { try { _webApp = WebApp.Start <Startup>(_settings.HostingUrl); _sender.SetSkipValue(0); _sender.LoadAllMessagesFromFile(_settings.DataFilePath); RecurringJob.AddOrUpdate( () => _sender.SendEmails(), Cron.Minutely ); _loggerService.CreateLog(LoggerService.LogType.Info, "Start service", null); } catch (Exception ex) { _loggerService.CreateLog(LoggerService.LogType.Error, "Start service error", ex); } }
public List <MinistryViewModel> GetAll() { _loggerService.CreateLog(_user, "API", "MinistryController", "Ministry", "GetAll", null, null); //This does not include the Up In Out Relationship names... not sure if it should yet or not. Seems to cause circular referencing var ministries = _ministryRepository.GetMinistries(); List <MinistryViewModel> viewModel = new List <MinistryViewModel>(); foreach (var ministry in ministries) { viewModel.Add(MapViewModel(ministry)); } return(viewModel); }
public IQueryable <ResourceInvolvement> GetAll() { _loggerService.CreateLog(_user, "API", "ResourceInvolvementController", "ResourceInvolvement", "GetAll", null, null); return(_resourceInvolvementRepository.GetResourceInvolvements()); }
public IQueryable <UpInOutRelationship> GetAll() { _loggerService.CreateLog(_user, "API", "UpInOutRelationshipController", "UpInOutRelationship", "GetAll", null, null); return(_upInOutRelationshipRepository.GetUpInOutRelationships()); }
public IQueryable <LevelOfImportance> GetAll() { _loggerService.CreateLog(_user, "API", "LevelOfImportanceController", "LevelOfImportance", "GetAll", null, null); return(_levelOfImportanceRepository.GetLevelOfImportances()); }
public Ministry GetMinistryById(int id) { Ministry ministry = db.Ministry.Find(id); _loggerService.CreateLog("Jordan", "Ministry", "Get By Id", id.ToString(), $"Results found: {ministry != null}"); return(ministry); }
public ResourceInvolvement GetResourceInvolvementById(int id) { ResourceInvolvement resourceInvolvement = db.ResourceInvolvement.Find(id); _loggerService.CreateLog("Jordan", "ResourceInvolvement", "Get By Id", id.ToString(), $"Results found: {resourceInvolvement != null}"); return(resourceInvolvement); }
public Practice GetPracticeById(int id) { Practice practice = db.Practice.Find(id); _loggerService.CreateLog("Jordan", "Practice", "Get By Id", id.ToString(), $"Results found: {practice != null}"); return(practice); }
public IQueryable <Frequency> GetAll() { _loggerService.CreateLog(_user, "API", "FrequencyController", "Frequency", "GetAll", null, null); return(_frequencyRepository.GetFrequencys()); }
public IQueryable <Practice> GetAll() { _loggerService.CreateLog(_user, "API", "PracticeController", "Practice", "GetAll", null, null); return(_practiceRepository.GetPractices()); }
public IQueryable <Funnel> GetAll() { _loggerService.CreateLog(_user, "API", "FunnelController", "Funnel", "GetAll", null, null); return(_funnelRepository.GetFunnels()); }
public MinistryOwner GetMinistryOwnerById(int id) { MinistryOwner ministryOwner = db.MinistryOwner.Find(id); _loggerService.CreateLog("Jordan", "MinistryOwner", "Get By Id", id.ToString(), $"Results found: {ministryOwner != null}"); return(ministryOwner); }
public Campus GetCampusById(int id) { Campus campus = db.Campus.Find(id); _loggerService.CreateLog("Jordan", "Campus", "Get By Id", id.ToString(), $"Results found: {campus != null}"); return(campus); }
public LevelOfImportance GetLevelOfImportanceById(int id) { LevelOfImportance levelOfImportance = db.LevelOfImportance.Find(id); _loggerService.CreateLog("Jordan", "LevelOfImportance", "Get By Id", id.ToString(), $"Results found: {levelOfImportance != null}"); return(levelOfImportance); }
public void Handle(LogRequestMessage message) { _loggerService.CreateLog(message.Type, message.Message, message.Exception); }
public IQueryable <Campus> GetAll() { _loggerService.CreateLog(_user, "API", "CampusController", "Campus", "GetAll", null, null); return(_campusRepository.GetCampuss()); }
public IQueryable <Approval> GetAll() { _loggerService.CreateLog(_user, "API", "ApprovalController", "Approval", "GetAll", null, null); return(_approvalRepository.GetApprovals()); }
public IQueryable <Location> GetAll() { _loggerService.CreateLog(_user, "API", "LocationController", "Location", "GetAll", null, null); return(_locationRepository.GetLocations()); }
/// <summary>Updates the database pairs.</summary> /// <exception cref="Exception">Exception.</exception> /// <returns>Task.</returns> public async Task UpdateDbPairs() { try { var configPairs = _configuration.GetSection("Pairs").Get <List <PairDto> >(); if (configPairs.GroupBy(p => p.Name).Any(x => x.Count() > 1)) { string msg = "There are duplicate pairs. Please check and restart the service!"; throw new Exception(msg); } if (configPairs.Any(p => string.IsNullOrEmpty(p.Name))) { string msg = "There are pairs with empty value for name. Please check and restart the service!"; throw new Exception(msg); } if (configPairs.Any(p => p.OrderAmount == 0)) { string msg = $"The pair {configPairs.FirstOrDefault(p => p.OrderAmount == 0).Name} has empty value for OrderAmount. Please check and restart the service!"; throw new Exception(msg); } if (configPairs.Any(p => p.MaxOrderLevel < 1)) { string msg = $"The pair {configPairs.FirstOrDefault(p => p.MaxOrderLevel < 1).Name} has value smaller than 1 for MaxOrderLevel. Please check and restart the service!"; throw new Exception(msg); } var dbPairs = _sqlContext.Pairs; foreach (var dbPair in dbPairs.Where(p => p.IsActive)) { if (!configPairs.Any(pc => pc.Name == dbPair.Name)) { DeactivatePairAndHistory(dbPair); } } foreach (var pair in configPairs) { var dbPair = dbPairs.FirstOrDefault(o => o.Name == pair.Name); if (dbPair == null) { // Adding the new Pair from the config file to the database. var newPair = new Pair { CreateDate = DateTime.UtcNow, Name = pair.Name, OrderAmount = pair.OrderAmount, MaxOrderLevel = pair.MaxOrderLevel, IsActive = pair.IsActive, }; AddPairHistory(newPair); _sqlContext.Pairs.Add(newPair); } else { if (dbPair.OrderAmount != pair.OrderAmount || dbPair.MaxOrderLevel != pair.MaxOrderLevel || dbPair.IsActive != pair.IsActive) { // Updating the existing DB pair with changed data from the actual config file. dbPair.OrderAmount = pair.OrderAmount; // TODO : // Calculate active hours // Update Pair History dbPair.LastUpdateDate = DateTime.UtcNow; } if (dbPair.PairHistory.Count(ph => ph.IsActive) != pair.MaxOrderLevel) { if (dbPair.PairHistory.Count(ph => ph.IsActive) > pair.MaxOrderLevel) { dbPair.PairHistory .Where(ph => ph.OrderLevel > pair.MaxOrderLevel) .ToList() .ForEach(ph => { ph.IsActive = false; ph.EndDate = DateTime.UtcNow; ph.ActiveHours = (int)(ph.EndDate - ph.StartDate).Value.TotalHours; }); } else { for (int i = dbPair.PairHistory.Count(ph => ph.IsActive) + 1; i <= pair.MaxOrderLevel; i++) { dbPair.PairHistory.Add(new PairHistory(dbPair.OrderAmount, i, true)); } } dbPair.MaxOrderLevel = pair.MaxOrderLevel; } if (dbPair.IsActive != pair.IsActive) { dbPair.IsActive = pair.IsActive; if (!pair.IsActive) //{ // AddPairHistory(dbPair); //} //else { DeactivatePairAndHistory(dbPair); } } } } _sqlContext.SaveChanges(); } catch (Exception ex) { await _loggerService.CreateLog(new Log(LogType.Error, $"AutoTrader v{_assemblyVersion}, UpdateDbPairs()", ex.Message)); await _loggerService.CreateLog(new Log(LogType.Error, $"AutoTrader v{_assemblyVersion}, UpdateDbPairs()", "The service has stopped incidentally.")); throw ex; } }
public Frequency GetFrequencyById(int id) { Frequency frequency = db.Frequency.Find(id); _loggerService.CreateLog("Jordan", "Frequency", "Get By Id", id.ToString(), $"Results found: {frequency != null}"); return(frequency); }
public Location GetLocationById(int id) { Location location = db.Location.Find(id); _loggerService.CreateLog("Jordan", "Location", "Get By Id", id.ToString(), $"Results found: {location != null}"); return(location); }
public Funnel GetFunnelById(int id) { Funnel funnel = db.Funnel.Find(id); _loggerService.CreateLog("Jordan", "Funnel", "Get By Id", id.ToString(), $"Results found: {funnel != null}"); return(funnel); }
public UpInOut GetUpInOutById(int id) { UpInOut upInOut = db.UpInOut.Find(id); _loggerService.CreateLog("Jordan", "UpInOut", "Get By Id", id.ToString(), $"Results found: {upInOut != null}"); return(upInOut); }
public IQueryable <MinistryOwner> GetAll() { _loggerService.CreateLog(_user, "API", "MinistryOwnerController", "MinistryOwner", "GetAll", null, null); return(_ministryOwnerRepository.GetMinistryOwners()); }
public Approval GetApprovalById(int id) { Approval approval = db.Approval.Find(id); _loggerService.CreateLog("Jordan", "API", "ApprovalRepository", "Approval", "Get By Id", id.ToString(), $"Results found: {approval != null}"); return(approval); }