Esempio n. 1
0
        static void Main()
        {
            var app = new ApplicationService();

            var training = new TrainingCreator(app);
            var location = new LocationCreator(app);
            var trainer  = new TrainerCreator(app);
            var company  = new CompanyCreator(app);
            var student  = new StudentCreator(app);
            var contact  = new ContactCreator(app, company);
            var session  = new SessionCreator(app, training, trainer, location, student, company);

            var reader    = new MsAccessReader("c:\\temp\\Database1.mdb");
            var lineCount = 1;

            foreach (DataRow row in reader.GetRows("Formation"))
            {
                Console.Write($"Traitement de la ligne {lineCount++}\r");
                training.Create(row["Formation"].ToString());
                location.Create(row["Lieu"].ToString());
                trainer.Create(row["Formateur"].ToString());
                company.Create(row["Societe"].ToString(), row["Adresse"].ToString(), row["CP"].ToString(), row["Ville"].ToString());
                student.Create(row["Stagiaire"].ToString());
                contact.Create(row["Contact"].ToString(), row["Email"].ToString(), row["Telephone"].ToString(), row["Societe"].ToString());
                session.Create(DateTime.Parse(row["DateFormation"].ToString()), int.Parse(row["NbJour"].ToString()), row["Formation"].ToString(), row["Formateur"].ToString(), row["Lieu"].ToString(), row["Stagiaire"].ToString(), row["Societe"].ToString());
            }

            /*    DisableAll("Formations", training.GetAll(), id => app.Command<DisableTraining>().Execute(id));
             *  DisableAll("Lieux", location.GetAll(), id => app.Command<DisableLocation>().Execute(id));
             *  DisableAll("Formateur", trainer.GetAll(), id => app.Command<DisableTrainer>().Execute(id));*/

            Console.WriteLine("\r\nImport terminé !");
            Console.ReadKey();
        }
Esempio n. 2
0
        public void Generate(LocationCreator lc)
        {
            int sizeX = (int)Math.Ceiling((double)lc.sizeX / sizeBlock) * sizeBlock;
            int sizeZ = (int)Math.Ceiling((double)lc.sizeZ / sizeBlock) * sizeBlock;

            var Init = new bool[sizeX + 1, sizeZ + 1];
            var Land = new int[sizeX + 1, sizeZ + 1];

            for (int i = 0; i < sizeX; i += sizeBlock)
            {
                for (int j = 0; j < sizeZ; j += sizeBlock)
                {
                    Init[i, j] = true;
                    Land[i, j] = lc.rand.Next(-sizeBlock, sizeBlock);
                }
            }

            DiamondSquareAlgo.Generate(sizeBlock, sizeX, sizeZ, lc.rand, Init, Land);

            for (int i = 0; i <= lc.sizeX; i++)
            {
                for (int j = 0; j <= lc.sizeZ; j++)
                {
                    lc.Land[i, j] = Land[i, j];
                }
            }
        }
 public CacheManager(ILocationCache level1Cache, ILocationCache level2Cache, LocationCreator locationCreator, ILogger <CacheManager> logger)
 {
     this.level1Cache     = level1Cache;
     this.level2Cache     = level2Cache;
     this.locationCreator = locationCreator;
     this.logger          = logger;
 }
        public ManagerLoggingTests()
        {
            var serviceProvider = ConfigureDi.BuildDi();

            fakeLocationCacheFactory = serviceProvider.GetRequiredService <FakeLocationCacheFactory>();
            locationCache            = fakeLocationCacheFactory.Create();
            locationCreator          = Setup.ConfigureDi.Services.GetRequiredService <LocationCreator>();
        }
        public MemoryLoggingTests()
        {
            logger = Setup.ConfigureDi.Services.GetRequiredService <FakeLogger <LocationCacheMemory> >();
            var diskStoragePath = System.Guid.NewGuid().ToString() + ".json";

            locationCacheMemory = new LocationCacheMemory(logger);
            locationCreator     = Setup.ConfigureDi.Services.GetRequiredService <LocationCreator>();
        }
Esempio n. 6
0
 //Сгладить высоты
 public void Smooth(LocationCreator lc)
 {
     for (int x = 0; x < lc.sizeX; x++)
     {
         for (int z = 0; z < lc.sizeZ; z++)
         {
             lc.Land[x, z] = (lc.Land[x, z] + lc.Land[x + 1, z] + lc.Land[x, z + 1] + lc.Land[x + 1, z + 1]) / 4;
         }
     }
 }
Esempio n. 7
0
        //Нижняя граница рандома
        private float GetMin(LocationCreator lc, int x, int z)
        {
            var dx = (float)x / lc.sizeX * (minp.GetLength(0) - 1);
            var dz = (float)z / lc.sizeZ * (minp.GetLength(1) - 1);
            int x1 = (int)dx;
            int z1 = (int)dz;

            dx -= x1;
            dz -= z1;
            var r1 = minp[x1, z1] * (1 - dx) + minp[x1 + 1, z1] * dx;
            var r2 = minp[x1, z1 + 1] * (1 - dx) + minp[x1 + 1, z1 + 1] * dx;

            return(r1 * (1 - dz) + r2 * dz);
        }
Esempio n. 8
0
        public override IEnumerable <Progress> Generate()
        {
            ClearBlocks();

            Location location = MakeLocation();

            location.Relievos.RemoveAll(r => r == null);

            var lc = new LocationCreator(location);

            lc.GenerateReliev();
            lc.GenerateVoxelSideX1 = GenerateVoxelSideX1;
            lc.GenerateVoxelSideZ0 = GenerateVoxelSideZ0;

            lc.BloorVoxels();

            if (MakeMeshMergeVertices)
            {
                MyMesh.bOptimize            = true;
                MyQuadMesh.bOptimizeEd      = true;
                MyQuadMesh.bOptimize2       = false;
                MyQuadMesh.bOptimize3       = false;
                MyMesh.bOptimizeIgnoreColor = true;
            }
            else
            {
                MyMesh.bOptimize            = true;
                MyQuadMesh.bOptimizeEd      = false;
                MyQuadMesh.bOptimize2       = true;
                MyQuadMesh.bOptimize3       = true;
                MyMesh.bOptimizeIgnoreColor = false;
            }

            foreach (var s in lc.MakeBlocks())
            {
                yield return(s);
            }

            level = lc.MakeLevelInfo();

            foreach (var s in OnGetLevelData())
            {
                yield return(s);
            }

            MakeHeightColorMaps(lc);

            yield return(new Progress(1));
        }
Esempio n. 9
0
        public Color[,] colorsMap;        //карта цветов

        public void MakeHeightColorMaps(LocationCreator lc)
        {
            heightsMap = new int[lc.sizeX, lc.sizeZ];
            for (int i = 0; i < lc.sizeX; i++)
            {
                for (int j = 0; j < lc.sizeZ; j++)
                {
                    heightsMap[i, j] = lc.Land[lc.sizeX - i - 1, lc.sizeZ - j - 1];
                }
            }

            var defaultColor = new MyColor();

            colorsMap = new Color[lc.sizeX, lc.sizeZ];
            for (int i = 0; i < lc.sizeX; i++)
            {
                for (int j = 0; j < lc.sizeZ; j++)
                {
                    var c = lc.UpColors[lc.sizeX - i - 1, lc.sizeZ - j - 1] ?? lc.Colors[lc.sizeX - i - 1, lc.sizeZ - j - 1] ?? defaultColor;
                    colorsMap[i, j] = new Color(c.R / 255f, c.G / 255f, c.B / 255f);
                }
            }
        }
Esempio n. 10
0
        public override void Init(LocationCreator lc)
        {
            if (MainBiomeUp == null)
            {
                MainBiomeUp = MainBiome;
            }

            Generate(lc);

            for (int i = 0; i < SmoothCount; i++)
            {
                Smooth(lc);
            }

            if (minp == null || maxp == null)
            {
                int minv = int.MaxValue;
                int maxv = int.MinValue;
                for (int x = 0; x < lc.sizeX; x++)
                {
                    for (int y = 0; y < lc.sizeZ; y++)
                    {
                        minv = Math.Min(minv, lc.Land[x, y]);
                        maxv = Math.Max(maxv, lc.Land[x, y]);
                    }
                }

                for (int x = 0; x < lc.sizeX; x++)
                {
                    for (int y = 0; y < lc.sizeZ; y++)
                    {
                        lc.Land[x, y] = (lc.Land[x, y] - minv) * (maxH - minH) / (maxv - minv) + minH;
                    }
                }
            }
            else
            {
                for (int x = 0; x < lc.sizeX; x++)
                {
                    for (int y = 0; y < lc.sizeZ; y++)
                    {
                        try
                        {
                            var minv = GetMin(lc, x, y);
                            var maxv = GetMax(lc, x, y);
                            lc.Land[x, y] = (int)((lc.Land[x, y] + sizeBlock) / (2f * sizeBlock) * (maxv - minv) + minv);
                        }
                        catch (Exception)
                        {
                            lc.Land[x, y] = -10;
                        }
                    }
                }
            }

            if (delH > 1)
            {
                for (int x = 0; x < lc.sizeX; x++)
                {
                    for (int y = 0; y < lc.sizeZ; y++)
                    {
                        lc.Land[x, y] = lc.Land[x / delH * delH, y / delH * delH] / delH * delH;
                    }
                }
            }

            for (int x = 0; x < lc.sizeX; x++)
            {
                for (int z = 0; z < lc.sizeZ; z++)
                {
                    var y = lc.Land[x, z];
                    lc.Colors[x, z]   = MainBiome.GetColor(y);
                    lc.UpColors[x, z] = MainBiomeUp.GetColor(y);
                }
            }
        }
Esempio n. 11
0
 //Вызывается после инициализации
 public virtual void AfterInit(LocationCreator locationCreator)
 {
 }
Esempio n. 12
0
 //Вызывается при инициализации
 public abstract void Init(LocationCreator locationCreator);