Esempio n. 1
0
 public static void SaveConfiguration(List <Configuration> configurationList)
 {
     try
     {
         using (var ctx = new VegaEntities())
         {
             foreach (var configuration in configurationList)
             {
                 if (configuration.ParameterId == 0)
                 {
                     ctx.AppConfigurations.Add(configuration);
                     ctx.SaveChanges();
                     continue;
                 }
                 ctx.AppConfigurations.Attach(configuration);
                 var entry = ctx.Entry(configuration);
                 entry.State = System.Data.Entity.EntityState.Modified;
             }
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Logger.Error("ConfigurationManager error: " + ex.Message, ex);
         throw;
     }
 }
Esempio n. 2
0
 public static List <Configuration> GetConfigurationList()
 {
     try
     {
         using (var ctx = new VegaEntities())
         {
             var configurationList = ctx.AppConfigurations.ToList();
             return(configurationList);
         }
     }
     catch (Exception ex)
     {
         Logger.Error("ConfigurationManager error: " + ex.Message, ex);
         throw;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Gets all (not expired) active options chain for specific underline.
 /// </summary>
 /// <returns></returns>
 public static List <DateTime> GetUNLActiveExpiryList(string symbol)
 {
     try
     {
         using (var ctx = new VegaEntities())
         {
             var seList = ctx.SessionsExpirations.Where(se => se.Symbol == symbol && se.ExpiryDate > DateTime.Today && se.IsActive).Select(se => se.ExpiryDate);
             return(seList.ToList());
         }
     }
     catch (Exception ex)
     {
         Logger.Error("DbDalManager.GetUNLActiveExpiryList():: " + ex.Message, ex);
         throw;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Gets all (not expired) active options chain for all underlines.
 /// </summary>
 /// <returns></returns>
 public static List <SessionsExpiration> GetAllActiveOptionChains()
 {
     try
     {
         using (var ctx = new VegaEntities())
         {
             var seList = ctx.SessionsExpirations.Where(se => se.ExpiryDate > DateTime.Today && se.IsActive);
             return(seList.ToList());
         }
     }
     catch (Exception ex)
     {
         Logger.Error("DbDalManager.GetAllActiveOptionChains():: " + ex.Message, ex);
         throw;
     }
 }
Esempio n. 5
0
 private static List <Configuration> GetConfigurationListForCategory(EConfigurationCategory eCategory)
 {
     try
     {
         var category = (int)eCategory;
         using (var ctx = new VegaEntities())
         {
             var configurationList = ctx.AppConfigurations.Where(con => con.Category == category).ToList();
             return(configurationList);
         }
     }
     catch (Exception ex)
     {
         Logger.Error("ConfigurationManager error: " + ex.Message, ex);
         throw;
     }
 }
Esempio n. 6
0
 public static List <MainSecurity> GetMainSecurityList()
 {
     try
     {
         using (var ctx = new VegaEntities())
         {
             var contractList =
                 ctx.MainSecurities.Where(contract => contract.IsActive.Value);
             return(contractList.ToList());
         }
     }
     catch (Exception ex)
     {
         Logger.Error("DbDalManager.GetActiveContractList():: " + ex.Message, ex);
         throw;
     }
 }
Esempio n. 7
0
 public static bool DeleteConfigurationData(Configuration configuration)
 {
     try
     {
         using (var ctx = new VegaEntities())
         {
             ctx.AppConfigurations.Attach(configuration);
             var entry = ctx.Entry(configuration);
             entry.State = System.Data.Entity.EntityState.Deleted;
             ctx.AppConfigurations.Remove(configuration);
             var res = ctx.SaveChanges();
             if (res <= 0)
             {
                 throw new Exception(string.Format("Row '{0}' didn't deleted!!!!", configuration.Name));
             }
             return(res > 0);
         }
     }
     catch (Exception ex)
     {
         Logger.Error("ConfigurationManager error: " + ex.Message, ex);
         throw;
     }
 }