Exemplo n.º 1
0
        public void Execute()
        {
            try
            {
               

                // Activating new campaigns
                int? campaignsActivated = ApplicationContext.Current.Campaigns.ActivateActualCampaigns();
                if (campaignsActivated.HasValue && campaignsActivated.Value != 0)
                {
                    log("Activated " + campaignsActivated.Value + " campaigns.");
                }
                else
                {
                    log("No deactivated campaigns starting today were found.");
                }

                // Deactivating past campaigns
                int? campaignsDeactivated = ApplicationContext.Current.Campaigns.DeactivatePastCampaigns();
                if (campaignsDeactivated.HasValue && campaignsDeactivated.Value != 0)
                {
                    log("Deactivated " + campaignsDeactivated.Value + " past campaigns.");
                }
                else
                {
                    log("No active campaigns ending today were found.");
                }

                // updating currency
                CurrencyConverter.CurrencyConvertorSoapClient currencyClient = new CurrencyConverter.CurrencyConvertorSoapClient("CurrencyConvertorSoap12");
                double rate = currencyClient.ConversionRate(CurrencyConverter.Currency.EUR, CurrencyConverter.Currency.ALL);
                CURRENCY curr = new CURRENCY(){ Date = DateTime.Today.Date, CurrencyRate = (decimal)rate };
                CURRENCY saved = ApplicationContext.Current.Payments.GetLastConversionRate();
                if (saved.Date != DateTime.Today.Date)
                {
                    ApplicationContext.Current.Payments.InsertConversionRate(curr);
                }
                else
                {
                    saved.CurrencyRate = curr.CurrencyRate;
                    ApplicationContext.Current.Payments.UpdateConversionRate(saved);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    log(ex.Message);
                }
                else
                {
                    log(ex.Message + "\n Inner: " + ex.InnerException.Message);
                }
            }
        }
Exemplo n.º 2
0
 public void UpdateConversionRate(CURRENCY Entity)
 {
     _currencyDAO.Update(Entity);
     Context.SaveChanges();
 }
Exemplo n.º 3
0
 public void InsertConversionRate(CURRENCY Entity)
 {
     _currencyDAO.Insert(Entity);
     Context.SaveChanges();
 }
Exemplo n.º 4
0
 public void Delete(CURRENCY Entity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public void Update(CURRENCY Entity)
 {
     //Context.CURRENCY.Attach(Entity);
     //Context.ObjectStateManager.ChangeObjectState(Entity, System.Data.EntityState.Modified);
 }
Exemplo n.º 6
0
 public void Insert(CURRENCY Entity)
 {
     Context.CURRENCY.AddObject(Entity);
 }
Exemplo n.º 7
0
 public List<CURRENCY> Search(CURRENCY Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
 {
     throw new NotImplementedException();
 }