コード例 #1
0
        public void MigrateAndSeedData()
        {
            if (Database.GetPendingMigrations().Any())
            {
                Database.Migrate();
            }

            if (!Components.Any())
            {
                //Seed database here
                var imagePath = Path.Combine(Directory.GetCurrentDirectory(), @".\seedImages\pump.jpg");
                var esImage   = new EsImage
                {
                    ImageMimeType = "image/jpeg",
                    ImageData     = Util.Util.ImageToByteArray(imagePath, FREE_IMAGE_FORMAT.FIF_JPEG),
                    Thumbnail     = Util.Util.ThumbNailByteArray(imagePath, FREE_IMAGE_FORMAT.FIF_JPEG)
                };

                var imagePath2 = Path.Combine(Directory.GetCurrentDirectory(), @"..\seedImages\pump2.jpg");
                var esImage2   = new EsImage
                {
                    ImageMimeType = "image/jpeg",
                    ImageData     = Util.Util.ImageToByteArray(imagePath, FREE_IMAGE_FORMAT.FIF_JPEG),
                    Thumbnail     = Util.Util.ThumbNailByteArray(imagePath, FREE_IMAGE_FORMAT.FIF_JPEG)
                };

                var componentTypes = new[]
                {
                    new ComponentType
                    {
                        ComponentName = "Pumpe",
                        AdminComment  = "",
                        ComponentInfo = "",
                        Datasheet     = "Datasheet",
                        Status        = ComponentTypeStatus.Available,
                        Location      = "Kontoret",
                        Manufacturer  = "Skolen",
                        WikiLink      = "https://da.wikipedia.org/wiki/Pumpe",
                        ImageUrl      = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Drehkolbenpumpe.jpg/220px-Drehkolbenpumpe.jpg",
                        Image         = esImage
                    },
                    new ComponentType
                    {
                        ComponentName = "Pumpe2",
                        AdminComment  = "",
                        ComponentInfo = "",
                        Datasheet     = "Datasheet",
                        Status        = ComponentTypeStatus.Available,
                        Location      = "Kontoret",
                        Manufacturer  = "Skolen",
                        WikiLink      = "https://da.wikipedia.org/wiki/Pumpe",
                        ImageUrl      = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Drehkolbenpumpe.jpg/220px-Drehkolbenpumpe.jpg",
                        Image         = esImage2
                    }
                };

                ComponentTypes.AddRange(componentTypes);
                SaveChanges();


                var components = new Component[]
                {
                    new Component
                    {
                        AdminComment             = "Pumpe",
                        ComponentNumber          = 1,
                        SerialNo                 = "123456789",
                        Status                   = ComponentStatus.Available,
                        UserComment              = "Lånt i 1 dag",
                        CurrentLoanInformationId = null
                    },
                    new Component
                    {
                        AdminComment             = "Pumpe",
                        ComponentNumber          = 2,
                        SerialNo                 = "234567891",
                        Status                   = ComponentStatus.ReservedAdmin,
                        UserComment              = "Lånt i 2 dage",
                        CurrentLoanInformationId = null
                    },
                    new Component
                    {
                        AdminComment             = "Pumpe",
                        ComponentNumber          = 3,
                        SerialNo                 = "345678912",
                        Status                   = ComponentStatus.Available,
                        UserComment              = "Lånt i 3 dage",
                        CurrentLoanInformationId = null
                    },
                    new Component
                    {
                        AdminComment             = "Pumpe",
                        ComponentNumber          = 4,
                        SerialNo                 = "456789123",
                        Status                   = ComponentStatus.Defect,
                        UserComment              = "I stykker",
                        CurrentLoanInformationId = null
                    },
                    new Component
                    {
                        AdminComment             = "Pumpe",
                        ComponentNumber          = 5,
                        SerialNo                 = "567891234",
                        Status                   = ComponentStatus.Available,
                        UserComment              = "Lånt i 5 dage",
                        CurrentLoanInformationId = null
                    }
                };

                var currentComponentType = ComponentTypes.FirstOrDefault();
                foreach (var component in components)
                {
                    currentComponentType.Components.Add(component);
                }
                SaveChanges();

                var categories = new[]
                {
                    new Category
                    {
                        Name = "Motordrevet"
                    },
                    new Category
                    {
                        Name = "Elektronik"
                    }
                };

                Categories.AddRange(categories);
                SaveChanges();

                var componentTypeCategoies = new[]
                {
                    new ComponentTypeCategory
                    {
                        ComponentType = ComponentTypes.FirstOrDefault(),
                        Category      = Categories.FirstOrDefault()
                    }
                };

                ComponentTypeCategory.AddRange(componentTypeCategoies);
                SaveChanges();
            }
        }
コード例 #2
0
        public MockInventorySection()
        {
            SectionNames.AddRange(new []
            {
                "Heating System",
                "Floor Finish",
                "Energy Supply"
            });
            SectionName = SectionNames[0];

            EquipmentCategories.AddRange(new[]
            {
                "D302001 BOILERS",
                "D301002 GAS SUPPLY SYSTEM - General",
                "NORTH BAY - C302001 TILE FLOOR FINISHES - General",
                "WEST BAY - C302001 TILE FLOOR FINISHES - General"
            });
            EquipmentCategory = EquipmentCategories[0];

            // TODO: Change this into an enumeration
            ComponentTypes.AddRange(new[]
            {
                "Permanent",
                "Temporary"
            });
            ComponentType = ComponentTypes[0];

            Quantity = "2.00";

            YearPc = "2007";

            SectionComments.Add(new CommentBase
            {
                EntryUser = new Person {
                    FirstName = "Jane", LastName = "Doe"
                },
                EntryTime   = new DateTime(2018, 1, 18, 18, 19, 55),
                CommentText = "This unit was in a locked room and not visible.\n" +
                              "(Text box large enough for STAMP on line 1 and at least 3 lines of actual comment.)\n" +
                              "(Line 3)"
            });

            Date = DateTime.Now.ToShortDateString();

            foreach (EnumRatingType rating in Enum.GetValues(typeof(EnumRatingType)))
            {
                switch (rating)
                {
                case EnumRatingType.GPlus:
                case EnumRatingType.G:
                case EnumRatingType.GMinus:
                case EnumRatingType.APlus:
                case EnumRatingType.A:
                case EnumRatingType.AMinus:
                case EnumRatingType.RPlus:
                case EnumRatingType.R:
                case EnumRatingType.RMinus:
                    Dcrs.Add(rating.Description());
                    PcRatings.Add(rating.Description());
                    break;

                case EnumRatingType.None:
                    break;

                // 4/19: G:IS51 - Change DCR and P/C Rating amber colors to Yellow. Text becomes Y+, Y, Y-.
                // 4/30: G:IS51 - Nope. Ditch the Yellow. Keep the Amber.
                case EnumRatingType.YPlus:
                case EnumRatingType.Y:
                case EnumRatingType.YMinus:
                    break;

#if DEBUG
                default:
                    throw new ArgumentOutOfRangeException();
#endif
                }
            }
            Dcr      = Dcrs     [1];
            PcRating = PcRatings[1];

            Images.AddRange(new[]
            {
                new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/th5.jpg")),
                new BitmapImage(new Uri(@"pack://application:,,,/Images/th6.jpg"))
            });

            YearInstalledRenewed = "2007";
        }