Example #1
0
        public UmbracoMediaSeedingTask(DatabaseSize sizeOptions) : base(
                sizeOptions.CmsMediaFolders * sizeOptions.CmsImagesPerFolder)
        {
            _faker           = new Faker();
            _sizeOptions     = sizeOptions;
            _folderNodeFaker = new Faker <UmbracoNode>()
                               .RuleFor(x => x.Level, f => 1)
                               .RuleFor(x => x.Path, f => "-1,1051")
                               .RuleFor(x => x.ParentId, f => - 1)
                               .RuleFor(x => x.UniqueId, f => f.Random.Guid())
                               .RuleFor(x => x.SortOrder, f => 0)
                               .RuleFor(x => x.NodeUser, f => - 1)
                               .RuleFor(x => x.NodeObjectType, f => UmbracoContentProvider.UmbracoMediaNodeType)
                               .RuleFor(x => x.CreateDate, f => f.Date.Recent())
                               .RuleFor(x => x.Trashed, f => false)
                               .RuleFor(x => x.Text, f => f.Name.JobArea());

            _imageNodeFaker = new Faker <UmbracoNode>()
                              .RuleFor(x => x.Level, f => 2)
                              .RuleFor(x => x.UniqueId, f => f.Random.Guid())
                              .RuleFor(x => x.SortOrder, f => 0)
                              .RuleFor(x => x.NodeUser, f => - 1)
                              .RuleFor(x => x.NodeObjectType, f => UmbracoContentProvider.UmbracoMediaNodeType)
                              .RuleFor(x => x.CreateDate, f => f.Date.Recent())
                              .RuleFor(x => x.Trashed, f => false)
                              .RuleFor(x => x.Text, f => f.Name.JobArea());
        }
        public List <DatabaseSize> GetDatabaseSize()
        {
            var     databasesizeList = new List <DatabaseSize>();
            DataSet ds    = new DataSet();
            string  query = Resources.DatabaseSize;

            try
            {
                ds = (DataSet)ExecuteQuery(query);
                foreach (DataTable t in ds.Tables)
                {
                    foreach (DataRow r in t.Rows)
                    {
                        DatabaseSize DBS = new DatabaseSize();
                        DBS.Name          = (String)r["DBname"];
                        DBS.Size          = Convert.ToDecimal(r["DBSize"]);
                        DBS.Used_Space_MB = Convert.ToDecimal(r["UsedMB"]);
                        DBS.Free_Space_MB = Convert.ToDecimal(r["FreeMB"]);
                        DBS.PercentFree   = Convert.ToDecimal(r["Free"]);
                        DBS.Updateability = (String)r["ReadOnly"];
                        DBS.StateDesc     = (String)r["Status"];
                        databasesizeList.Add(DBS);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception catched: " + ex.Message);
                throw;
                //Console.WriteLine("Exception catched: " + ex.Message);
                //DO2.Success = false;
            }

            return(databasesizeList);
        }
 public DatabaseSize Insert(DatabaseSize obj)
 {
     using (InsightEntities db = new InsightEntities())
     {
         db.DatabaseSize.Add(obj);
         db.SaveChanges();
         return(obj);
     }
 }
        public ProductCategoryRelationSeedingTask(DatabaseSize databaseSize) : base(
                databaseSize.AverageProductsPerCategory * databaseSize.CategoriesPerCatalog *
                databaseSize.CatalogsPerStore * databaseSize.Stores)
        {
            _databaseSize = databaseSize;

            _faker = new Faker <UCommerceCategoryProductRelation>()
                     .RuleFor(x => x.Guid, f => f.Random.Guid())
                     .RuleFor(x => x.SortOrder, f => f.Random.Int(0, (int)Count));
        }
Example #5
0
        public static IEnumerable <Tuple <string, int> > GetSizes(Session session, JET_DBID db)
        {
            int dbPages;

            Api.JetGetDatabaseInfo(session, db, out dbPages, JET_DbInfo.Filesize);

            var dbTotalSize = dbPages * SystemParameters.DatabasePageSize;

            yield return(Tuple.Create("Total db size: " + DatabaseSize.Humane(dbTotalSize), dbTotalSize));

            foreach (var tableName in Api.GetTableNames(session, db))
            {
                using (var tbl = new Table(session, db, tableName, OpenTableGrbit.None))
                {
                    Api.JetComputeStats(session, tbl);

                    JET_OBJECTINFO result;
                    Api.JetGetTableInfo(session, tbl, out result, JET_TblInfo.Default);
                    var sb       = new StringBuilder(tableName).AppendLine();
                    var usedSize = result.cPage * SystemParameters.DatabasePageSize;
                    int ownedPages;
                    Api.JetGetTableInfo(session, tbl, out ownedPages, JET_TblInfo.SpaceOwned);

                    sb.Append("\tOwned Size: ")
                    .Append(DatabaseSize.Humane(ownedPages * SystemParameters.DatabasePageSize))
                    .AppendLine();


                    sb.Append("\tUsed Size: ")
                    .Append(DatabaseSize.Humane(usedSize))
                    .AppendLine();


                    sb.Append("\tRecords: ").AppendFormat("{0:#,#;;0}", result.cRecord).AppendLine();
                    sb.Append("\tIndexes:").AppendLine();

                    foreach (var index in Api.GetTableIndexes(session, tbl))
                    {
                        sb.Append("\t\t")
                        .Append(index.Name)
                        .Append(": ")
                        .Append(DatabaseSize.Humane(index.Pages * (SystemParameters.DatabasePageSize)))
                        .AppendLine();
                    }
                    yield return(Tuple.Create(sb.ToString(), ownedPages * SystemParameters.DatabasePageSize));
                }
            }
        }
Example #6
0
        static void Main()
        {
            try
            {
                var server = new MetricServer(port: 5725);
                server.Start();

                // Run test
                string dbName = Guid.NewGuid().ToString();

                using var db = new SampleDBContext();


                Task.Run(() =>
                {
                    while (true)
                    {
                        if (File.Exists(db.DbName))
                        {
                            DatabaseSize.Set(new FileInfo(db.DbName).Length);
                        }
                        Task.Delay(5000).Wait();
                    }
                });

                Log("Insert 1000000 of objects");
                for (int i = 0; i < 1000000; i++)
                {
                    var obj = new ExampleObject()
                    {
                        Name  = "example name",
                        Value = 1234567890
                    };

                    db.ExampleObjects.Add(obj);
                    db.SaveChanges();
                    InsertObjectCounter.Inc();
                }

                Log("Process finished");
            }
            catch (Exception ex)
            {
                Log($"Error: {ex.Message} - {ex.StackTrace}");
            }
        }
Example #7
0
        static void Main()
        {
            try
            {
                var server = new MetricServer(port: 5724);
                server.Start();

                // Run test
                string dbName = Guid.NewGuid().ToString();

                using var db = new LiteDatabase($"Filename={dbName};");

                Task.Run(() =>
                {
                    while (true)
                    {
                        DatabaseSize.Set(new FileInfo(dbName).Length);
                        Task.Delay(5000).Wait();
                    }
                });

                // Insert 1M of objects
                var insertCollection = db.GetCollection <ExampleObject>("insertData");
                Log("Insert 1000000 of objects");
                for (int i = 0; i < 1000000; i++)
                {
                    var obj = new ExampleObject()
                    {
                        Name  = "example name",
                        Value = 1234567890
                    };

                    insertCollection.Insert(obj);
                    InsertObjectCounter.Inc();
                }

                Log("Process finished");
            }
            catch (Exception ex)
            {
                Log($"Error: {ex.Message} - {ex.StackTrace}");
            }
        }
Example #8
0
        public ProductSeedingTask(DatabaseSize databaseSize, ICmsContent cmsContent) : base(databaseSize.Products)
        {
            _databaseSize = databaseSize;
            _cmsContent   = cmsContent;
            _productFaker = new Faker <UCommerceProduct>()
                            .RuleFor(x => x.Guid, f => f.Random.Guid())
                            .RuleFor(x => x.Name, f => f.Commerce.ProductName())
                            .RuleFor(x => x.Rating, f => f.Random.Double(0, 10))
                            .RuleFor(x => x.Sku, f => f.Commerce.Ean13())
                            .RuleFor(x => x.Weight, f => f.Random.Decimal(0.1M, 1000M))
                            .RuleFor(x => x.AllowOrdering, f => f.Random.Bool(0.9f))
                            .RuleFor(x => x.CreatedBy, f => f.Name.FullName())
                            .RuleFor(x => x.CreatedOn, f => f.Date.Past())
                            .RuleFor(x => x.ModifiedBy, f => f.Name.FullName())
                            .RuleFor(x => x.ModifiedOn, f => f.Date.Recent())
                            .RuleFor(x => x.DisplayOnSite, f => f.Random.Bool(0.85f));

            _productRelationFaker = new Faker <UCommerceProductRelation>()
                                    .RuleFor(x => x.Guid, f => f.Random.Guid());

            _priceFaker = new Faker <UCommercePrice>()
                          .RuleFor(y => y.Amount, g => g.Finance.Amount())
                          .RuleFor(y => y.Guid, g => g.Random.Guid());

            _productPriceFaker = new Faker <UCommerceProductPrice>()
                                 .RuleFor(x => x.Guid, f => f.Random.Guid())
                                 .RuleFor(x => x.MinimumQuantity, f => f.Random.Int(1, 1000));

            _productPropertyFaker = new Faker <UCommerceProductProperty>()
                                    .RuleFor(x => x.Guid, f => f.Random.Guid())
                                    .RuleFor(x => x.Value, f => f.Random.Word());

            _productDescriptionFaker = new Faker <UCommerceProductDescription>()
                                       .RuleFor(x => x.Guid, f => f.Random.Guid())
                                       .RuleFor(x => x.DisplayName, f => f.Commerce.ProductName())
                                       .RuleFor(x => x.LongDescription, f => f.Lorem.Sentences(3))
                                       .RuleFor(x => x.ShortDescription, f => f.Lorem.Sentence());

            _productDescriptionPropertyFaker = new Faker <UCommerceProductDescriptionProperty>()
                                               .RuleFor(x => x.Guid, f => f.Random.Guid());
        }
Example #9
0
        void ReleaseDesignerOutlets()
        {
            if (ConnectionTimeout != null)
            {
                ConnectionTimeout.Dispose();
                ConnectionTimeout = null;
            }

            if (DBInitialisedOn != null)
            {
                DBInitialisedOn.Dispose();
                DBInitialisedOn = null;
            }

            if (UpdateAppUri != null)
            {
                UpdateAppUri.Dispose();
                UpdateAppUri = null;
            }

            if (EventUTCOffset != null)
            {
                EventUTCOffset.Dispose();
                EventUTCOffset = null;
            }

            if (NotificationsBtn != null)
            {
                NotificationsBtn.Dispose();
                NotificationsBtn = null;
            }

            if (PromptsBtn != null)
            {
                PromptsBtn.Dispose();
                PromptsBtn = null;
            }

            if (LogsBtn != null)
            {
                LogsBtn.Dispose();
                LogsBtn = null;
            }

            if (PromptView != null)
            {
                PromptView.Dispose();
                PromptView = null;
            }

            if (NotificationView != null)
            {
                NotificationView.Dispose();
                NotificationView = null;
            }

            if (CancelBtn != null)
            {
                CancelBtn.Dispose();
                CancelBtn = null;
            }

            if (DatabaseSize != null)
            {
                DatabaseSize.Dispose();
                DatabaseSize = null;
            }

            if (RunningMode != null)
            {
                RunningMode.Dispose();
                RunningMode = null;
            }

            if (CurrentVersion != null)
            {
                CurrentVersion.Dispose();
                CurrentVersion = null;
            }

            if (GoLiveDate != null)
            {
                GoLiveDate.Dispose();
                GoLiveDate = null;
            }

            if (ResponderRegion != null)
            {
                ResponderRegion.Dispose();
                ResponderRegion = null;
            }

            if (EventPasscode != null)
            {
                EventPasscode.Dispose();
                EventPasscode = null;
            }

            if (RefreshViewBtn != null)
            {
                RefreshViewBtn.Dispose();
                RefreshViewBtn = null;
            }

            if (EventName != null)
            {
                EventName.Dispose();
                EventName = null;
            }

            if (SyncDataBtn != null)
            {
                SyncDataBtn.Dispose();
                SyncDataBtn = null;
            }

            if (ResponderId != null)
            {
                ResponderId.Dispose();
                ResponderId = null;
            }

            if (SyncDataInterval != null)
            {
                SyncDataInterval.Dispose();
                SyncDataInterval = null;
            }

            if (SyncMode != null)
            {
                SyncMode.Dispose();
                SyncMode = null;
            }

            if (WANServiceUri != null)
            {
                WANServiceUri.Dispose();
                WANServiceUri = null;
            }

            if (SaveChangesBtn != null)
            {
                SaveChangesBtn.Dispose();
                SaveChangesBtn = null;
            }

            if (LANServiceUri != null)
            {
                LANServiceUri.Dispose();
                LANServiceUri = null;
            }

            if (LastSuccessfulDataPush != null)
            {
                LastSuccessfulDataPush.Dispose();
                LastSuccessfulDataPush = null;
            }

            if (LogView != null)
            {
                LogView.Dispose();
                LogView = null;
            }

            if (LastSuccessfulServiceUpdate != null)
            {
                LastSuccessfulServiceUpdate.Dispose();
                LastSuccessfulServiceUpdate = null;
            }
        }
Example #10
0
 public VariantSeedingTask(DatabaseSize databaseSize, ICmsContent cmsContent) : base(databaseSize, cmsContent)
 {
     _cmsContent = cmsContent;
 }
Example #11
0
 public DataSeeder(DatabaseSize sizeOptions, bool excludeCmsTables)
 {
     _sizeOptions      = sizeOptions;
     _excludeCmsTables = excludeCmsTables;
 }
 public static DatabaseSize Insert(DatabaseSize obj)
 {
     return(repository.Insert(obj));
 }