Exemplo n.º 1
0
        private User[] UserSeed(CNCLibContext context)
        {
            var userImport = new CsvImport <User>();
            var users      = userImport.Read(DefaultDataDir + @"\DefaultData\User.csv").ToArray();

            return(users);
        }
Exemplo n.º 2
0
        private static IList <T> ReadFromCsv <T>(string path) where T : new()
        {
            var csvImport = new CsvImport <T>();
            var items     = csvImport.Read(path).ToList();

            return(items);
        }
Exemplo n.º 3
0
        private void ConfigurationSeed(CNCLibContext context, bool isTest)
        {
            if (isTest)
            {
                var configurationImport = new CsvImport <Configuration>();
                var configurations      = configurationImport.Read(DefaultDataDir + @"\DefaultData\Configuration.csv").ToArray();

                context.Set <Configuration>().AddRange(configurations);
            }
        }
Exemplo n.º 4
0
        private void MachineSeed(CNCLibContext context, User[] users)
        {
            var machineImport = new CsvImport <Machine>();
            var machines      = machineImport.Read(DefaultDataDir + @"\DefaultData\Machine.csv").ToArray();

            var machineCommandImport = new CsvImport <MachineCommand>();
            var machineCommands      = machineCommandImport.Read(DefaultDataDir + @"\DefaultData\MachineCommand.csv").ToArray();

            var machineInitCommandImport = new CsvImport <MachineInitCommand>();
            var machineInitCommands      = machineInitCommandImport.Read(DefaultDataDir + @"\DefaultData\MachineInitCommand.csv").ToArray();

            foreach (var machineInitCommand in machineInitCommands)
            {
                machineInitCommand.Machine              = machines.First(m => m.MachineId == machineInitCommand.MachineId);
                machineInitCommand.MachineId            = 0;
                machineInitCommand.MachineInitCommandId = 0;
            }

            foreach (var machineCommand in machineCommands)
            {
                machineCommand.Machine          = machines.First(m => m.MachineId == machineCommand.MachineId);
                machineCommand.MachineId        = 0;
                machineCommand.MachineCommandId = 0;
            }

            foreach (var machine in machines)
            {
                machine.User      = users.FirstOrDefault(u => u.UserId == machine.UserId);
                machine.UserId    = null;
                machine.MachineId = 0;
            }

            foreach (var user in users)
            {
                user.UserId = 0;
            }

            context.Set <Machine>().AddRange(machines);
            context.Set <MachineCommand>().AddRange(machineCommands);
            context.Set <MachineInitCommand>().AddRange(machineInitCommands);
        }
Exemplo n.º 5
0
        private void ItemSeed(CNCLibContext context)
        {
            var itemImport = new CsvImport <Item>();
            var items      = itemImport.Read(DefaultDataDir + @"\DefaultData\Item.csv").ToArray();

            var itemPropertyImport = new CsvImport <ItemProperty>();
            var itemProperties     = itemPropertyImport.Read(DefaultDataDir + @"\DefaultData\ItemProperty.csv").ToArray();

            foreach (var itemProperty in itemProperties)
            {
                itemProperty.Item   = items.First(i => i.ItemId == itemProperty.ItemId);
                itemProperty.ItemId = 0;
            }

            foreach (var item in items)
            {
                item.ItemId = 0;
            }

            context.Set <Item>().AddRange(items);
            context.Set <ItemProperty>().AddRange(itemProperties);
        }