Ejemplo n.º 1
0
        public static IMetaManager CreateMetaManager(IVertexStore myVertexStore,
                                                     IDManager myIDManager,
                                                     GraphDBPlugins myPlugins,
                                                     GraphDBPluginManager myPluginManager,
                                                     GraphApplicationSettings myApplicationSettings,
                                                     ITransactionable myTransactionManager,
                                                     SecurityToken mySecurity)
        {
            var result = new MetaManager(myVertexStore, myIDManager, myPluginManager, myPlugins, myApplicationSettings);

            var transactionID = myTransactionManager.BeginTransaction(mySecurity);

            DBCreationManager creationManager = new DBCreationManager(result.SystemSecurityToken,
                                                                      transactionID,
                                                                      result._baseGraphStorageManager);

            if (!creationManager.CheckBaseGraph(myVertexStore))
            {
                creationManager.CreateBaseGraph(myVertexStore);
            }

            creationManager.AddUserDefinedDataTypes(myVertexStore, myPluginManager);

            result.Initialize();
            result.Load(transactionID);

            SetMaxID(myVertexStore, myIDManager, transactionID, mySecurity, result);

            myTransactionManager.CommitTransaction(mySecurity, transactionID);

            return(result);
        }
Ejemplo n.º 2
0
 public static void RegisterPackedReaction(ITransactionable obj)
 {
     // MAKE IT FASTER!
     if (!registered.Contains(obj))
     {
         registered.Add(obj);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates purchase transactions on <see cref="t"/> at random for the given <see cref="dt"/>.
        /// </summary>
        /// <param name="spender"></param>
        /// <param name="t"></param>
        /// <param name="dt"></param>
        /// <param name="daysMax"></param>
        /// <param name="randMaxFactor">
        /// The multiplier used for the rand dollar's max, raising this value 
        /// will raise every transactions possiable max by a factor of this.
        /// </param>
        public static void CreateSingleDaysPurchases(Personality spender, ITransactionable t, DateTime? dt,
            double daysMax, int randMaxFactor = 10)
        {
            if (t == null)
                throw new ArgumentNullException(nameof(t));
            if (daysMax <= 0)
                return;
            var ccDate = dt ?? DateTime.Today;

            //build charges history
            var keepSpending = true;
            var spentSum = new Pecuniam(0);

            while (keepSpending) //want possiable multiple transactions per day
            {
                //if we reached target then exit
                if (spentSum >= new Pecuniam((decimal)daysMax))
                    return;

                var isXmasSeason = ccDate.Month >= 11 && ccDate.Day >= 20;
                var isWeekend = ccDate.DayOfWeek == DayOfWeek.Friday ||
                                ccDate.DayOfWeek == DayOfWeek.Saturday ||
                                ccDate.DayOfWeek == DayOfWeek.Sunday;
                var actingIrresp = spender?.GetRandomActsIrresponsible() ?? false;
                var isbigTicketItem = Etx.TryAboveOrAt(96, Etx.Dice.OneHundred);
                var isSomeEvenAmt = Etx.TryBelowOrAt(3, Etx.Dice.Ten);

                //keep times during normal waking hours
                var randCcDate =
                    ccDate.Date.AddHours(Etx.IntNumber(6, isWeekend ? 23 : 19))
                        .AddMinutes(Etx.IntNumber(0, 59))
                        .AddSeconds(Etx.IntNumber(0, 59))
                        .AddMilliseconds(Etx.IntNumber(0, 999));

                //make purchase based various factors
                var v = 2;
                v = isXmasSeason ? v + 1 : v;
                v = isWeekend ? v + 2 : v;
                v = actingIrresp ? v + 3 : v;
                randMaxFactor = isbigTicketItem ? randMaxFactor * 10 : randMaxFactor;

                if (Etx.TryBelowOrAt(v, Etx.Dice.Ten))
                {
                    //create some random purchase amount
                    var chargeAmt = Pecuniam.GetRandPecuniam(5, v * randMaxFactor, isSomeEvenAmt ? 10 : 0);

                    //check if account is maxed-out\empty
                    if (!t.Pop(randCcDate, chargeAmt))
                        return;

                    spentSum += chargeAmt;
                }
                //determine if more transactions for this day
                keepSpending = Etx.CoinToss;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a meta manager
 /// </summary>
 /// <param name="myPlugins">The plugin definitions</param>
 /// <returns>A meta manager</returns>
 private IMetaManager CreateMetamanager(GraphDBPlugins myPlugins, ITransactionable myTransactionManager)
 {
     return(MetaManager.CreateMetaManager(_securityManager, _idManager, myPlugins, _graphDBPluginManager, _applicationSettings, myTransactionManager, null));
 }
Ejemplo n.º 5
0
 public TransactionManager(ITransactionable transactionRepository)
 {
     _transactionRepository = transactionRepository;
 }
 /// <summary>
 ///     Update the Database Record of a specified model.
 /// </summary>
 /// <typeparam name="TModel">Model type</typeparam>
 /// <param name="transactionable"></param>
 /// <param name="model">Model Object to update</param>
 public static Task Update <TModel>(this ITransactionable transactionable, TModel model) where TModel : class, new() => transactionable.Update(model, new AutoDbMapper <TModel>());
 public static Task ExecuteNonQuery(this ITransactionable transactionable, string commandText) => transactionable.ExecuteNonQuery(commandText, new Dictionary <string, object>());
 public Bank(ITransactionable transferable, ISavable savable, IInvestable investable)
 {
     _Transact   = transferable;
     _savable    = savable;
     _investable = investable;
 }
Ejemplo n.º 9
0
        public static IMetaManager CreateMetaManager(   IVertexStore myVertexStore, 
                                                        IDManager myIDManager, 
                                                        GraphDBPlugins myPlugins, 
                                                        GraphDBPluginManager myPluginManager, 
                                                        GraphApplicationSettings myApplicationSettings, 
                                                        ITransactionable myTransactionManager, 
                                                        SecurityToken mySecurity)
        {
            var result = new MetaManager(myVertexStore, myIDManager, myPluginManager, myPlugins, myApplicationSettings);

            var transactionID = myTransactionManager.BeginTransaction(mySecurity);

            DBCreationManager creationManager = new DBCreationManager(  result.SystemSecurityToken,
                                                                        transactionID, 
                                                                        result._baseGraphStorageManager);
            
            if (!creationManager.CheckBaseGraph(myVertexStore))
            {
                creationManager.CreateBaseGraph(myVertexStore);
            }

            creationManager.AddUserDefinedDataTypes(myVertexStore, myPluginManager);
            
            result.Initialize();
            result.Load(transactionID);

            SetMaxID(myVertexStore, myIDManager, transactionID, mySecurity, result);

            myTransactionManager.CommitTransaction(mySecurity, transactionID);

            return result;
        }