コード例 #1
0
        private static void LoadLevels()
        {
            Continuum.Data.DimensionRepo repo = new Continuum.Data.DimensionRepo();

            Console.WriteLine("Creating Levels...");

            var levels = repo.CapabilityLevels();

            var reader = GetReader(LEVELS_FILE);

            while (!reader.EndOfStream)
            {
                string[] fields = reader.ReadLine().Trim().Split(';');
                string   level  = fields[0];
                if (!levels.Any(i => i.DisplayName == level))
                {
                    Console.WriteLine(string.Format("{0}", level));
                    repo.CreateLevel(level, fields[0]);
                }
            }

            repo.SaveChanges();

            Console.WriteLine("...complete.");
        }
コード例 #2
0
        private static void LoadCapabilities()
        {
            List <ImportRow> rows = new List <ImportRow>();

            Continuum.Data.DimensionRepo dimensionRepo = new Continuum.Data.DimensionRepo();

            Console.WriteLine("Creating Capabilites...");

            int linecount = 0;

            var reader = GetReader(CAPABILITIES_FILE);

            while (!reader.EndOfStream)
            {
                bool skipLine = false;
                linecount++;

                string   importLine = reader.ReadLine();
                string[] fields     = importLine.Split(';');
                if (fields.Length == EXPECTED_FIELD_COUNT)
                {
                    var row = ExtractFields(fields);
                    if (row.IsValid())
                    {
                        var dimension = dimensionRepo.GetDimensionByName(row.Dimension);
                        if (dimension != null)
                        {
                            var level = dimensionRepo.CapabilityLevels().Where(i => i.DisplayName == row.Level).FirstOrDefault();
                            if (level != null)
                            {
                                rows.Add(row);

                                Continuum.Data.Capability capability = null;

                                capability = dimensionRepo.FindCapabilityById(row.TempId);

                                if (capability == null)
                                {
                                    Console.WriteLine(string.Format("Creating {0}\t{1}", row.Dimension, row.Description));
                                    capability = new Continuum.Data.Capability()
                                    {
                                        Active      = false,
                                        Description = row.Description,
                                        Dimension   = dimension,
                                        Level       = level
                                    };
                                    dimension.Capabilities.Add(capability);
                                }
                                else
                                {
                                    Console.WriteLine(string.Format("Loading {0}\t{1}", row.Dimension, row.Description));
                                }

                                row.Capability = capability;
                            }
                            else
                            {
                                skipLine = true;
                            }
                        }
                        else
                        {
                            skipLine = true;
                        }
                    }
                    else
                    {
                        skipLine = true;
                    }
                }
                else
                {
                    skipLine = true;
                }

                if (skipLine)
                {
                    Console.WriteLine(String.Format("WARNING: Skipping line {0} due to incorrect line format or data issue.", linecount));
                    Console.WriteLine("WARNING: " + importLine);
                }
            }

            dimensionRepo.SaveChanges();

            Console.WriteLine("...complete.");

            LinkCapabilities(dimensionRepo, rows);
        }