コード例 #1
0
 public static int DeleteMarkerByID(int PK)
 {
     using (DataAccessClass.DataAccessClass TheDatabase = new DataAccessClass.DataAccessClass())
     {
         return(TheDatabase.DeleteZombieByID(PK));
     }
 }
コード例 #2
0
        public void TestInsert()
        {
            DataAccessClass.DataAccessClass TheDataBase = new DataAccessClass.DataAccessClass();

            //Create a Zombie
            DataObjects.Zombie Z1 = new DataObjects.Zombie(45.5, -81.5, 110, 2020, 01, 18, DataObjects.Zombie.ZType.Slow, "Fred the Zombie", 0);
            //Send it to the database
            DataObjects.Zombie Z2 = TheDataBase.InsertZombie(Z1);
            //Get another back from the database.
            DataObjects.Zombie Z3 = TheDataBase.GetZombieByID(Z2.ZombieSerialNumber);
            //That means down to the database and back works.
            Assert.IsTrue(Z2 == Z3);
        }
コード例 #3
0
        public static String[] GetAllMarkersByDateRange(String StartDate, String EndDate)
        {
            DataObjects.Toolset Tools      = new DataObjects.Toolset();
            NodaTime.LocalDate  ZStartDate = Tools.StringToNodaDate(StartDate);
            NodaTime.LocalDate  ZEndDate   = Tools.StringToNodaDate(EndDate);
            using (DataAccessClass.DataAccessClass TheDatabase = new DataAccessClass.DataAccessClass())
            {
                MasterZombieList = TheDatabase.GetAllZombiesByDateRange(ZStartDate, ZEndDate);
            }
            String[] ZombieArray = Tools.ConvertZombieListToStringArray(MasterZombieList);

            return(ZombieArray);
        }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //So lets build the parts we need. Now for the term using...
         using (DataAccessClass.DataAccessClass TheDatabase = new DataAccessClass.DataAccessClass())
         {
             MasterZombieList = TheDatabase.GetAllZombies();
             BindLocationList();
             //When this using ends. This object dies. No loose database connections
         }
     }
     catch (Exception E)
     {
         //Right now we are going to swallow errors. But we will soon
         //log errors and help ourusers if somethinggoes wrong.
         //We DO NOT WANT TO SHOW ERRORS TO THE USER!
     }
 }
コード例 #5
0
        public void TestUpdate()
        {
            DataAccessClass.DataAccessClass TheDataBase = new DataAccessClass.DataAccessClass();

            //Create a Zombie
            DataObjects.Zombie Z1 = new DataObjects.Zombie(-45.5, 81.5, 210, 2019, 02, 02, DataObjects.Zombie.ZType.Fast, "Martin VanNostrum", 0);
            //Send it to the database
            DataObjects.Zombie Z2 = TheDataBase.InsertZombie(Z1);

            //Lets make some changes to the zombie.
            Z2.ContactName = "Lana Kane";

            //And send it to the database as update.
            DataObjects.Zombie Z3 = TheDataBase.UpdateZombieByID(Z2);

            //Get another back from the database.
            DataObjects.Zombie Z4 = TheDataBase.GetZombieByID(Z3.ZombieSerialNumber);
            //That means down to the database and back works.
            Assert.IsTrue(Z3 == Z4);
        }
コード例 #6
0
        public static int CreateMarker(String Name, Double Elevation, String Date, int Serial, String ContactType, Double Lat, Double Long)
        {
            //We are going to have to some syntax acrobatics to get the Zombie in the database.
            //Lets try to figure the date out

            DataObjects.Toolset Tools = new DataObjects.Toolset();

            NodaTime.LocalDate           D   = Tools.StringToNodaDate(Date);
            GeoEngine_Workspace.Location Loc = new GeoEngine_Workspace.Location(Lat, Long, Elevation);
            Loc.SetDate(D.Year, D.Month, D.Day);

            DataObjects.Zombie Z = new DataObjects.Zombie(Loc, Name, DataObjects.Zombie.ZType.Slow);
            Z.SetZType(ContactType);
            DataObjects.Zombie ReturnZombie = new DataObjects.Zombie();
            using (DataAccessClass.DataAccessClass TheDatabase = new DataAccessClass.DataAccessClass())
            {
                ReturnZombie = TheDatabase.InsertZombie(Z);
            }
            return(ReturnZombie.ZombieSerialNumber);
        }
コード例 #7
0
        /// <summary>
        /// Date        Coder       Vers        Notes
        /// 2020-01-17  Clay        1.0         Initial
        /// 2020-01-21  Clay        1.1         Refactored to always keep at least 20
        ///                                     records in the DB.
        ///
        /// </summary>
        /// <returns></returns>
        private static bool TestCode()
        {
            DataAccessClass.DataAccessClass TheDataBase = new DataAccessClass.DataAccessClass();

            List <DataObjects.Zombie> CurrentData = TheDataBase.GetAllZombies();

            if (CurrentData.Count < 200)
            {
                DataAccessClass.TestDataGenerator GenerateData = new DataAccessClass.TestDataGenerator(200, new NodaTime.LocalDate(2019, 01, 05), new NodaTime.LocalDate(2020, 01, 10));
                List <DataObjects.Zombie>         TestData     = GenerateData.GenerateTestData();
                foreach (DataObjects.Zombie Z in TestData)
                {
                    TheDataBase.InsertZombie(Z);
                }
            }

            List <DataObjects.TrackObject> TrackLists = new List <DataObjects.TrackObject>();

            TrackLists = TheDataBase.GetTrackByID(1);



            //Create a Zombie
            DataObjects.Zombie Z10 = new DataObjects.Zombie(45.5, -81.5, 110, 2020, 01, 18, DataObjects.Zombie.ZType.Slow, "Fred the Zombie", 0);
            //Send it to the database
            DataObjects.Zombie Z20 = TheDataBase.InsertZombie(Z10);
            //Get another back from the database.
            DataObjects.Zombie Z30 = TheDataBase.GetZombieByID(Z20.ZombieSerialNumber);
            if (Z20 == Z30)
            {
                int x = 0;
            }



            //Now I need to organize some tests before I go any further...
            //So I can build some tests.

            //Test down to the database.
            DataAccessClass.DataAccessClass TheDatabase = new DataAccessClass.DataAccessClass();

            //Lets add a Zombie to the database
            DataObjects.Zombie Z0 = new DataObjects.Zombie(23.5, 34.989, 100, 1990, 02, 13, DataObjects.Zombie.ZType.Medium, "Charles");
            DataObjects.Zombie Z1 = TheDatabase.InsertZombie(Z0);

            //Now are these two zombies the same. Aside from the SerialNumber they should
            //be. That would be an important test that system works. If only there was an
            //easy way to compare zombies. We cant use this code. It will not work..yet.

            //if(Z0 == Z1)
            //{
            //    Console.WriteLine("Insert functioning properly.")
            //}

            //So lets get all the zombies.
            List <DataObjects.Zombie> TheZombieList = TheDatabase.GetAllZombies();

            //Lets get a zombie by its Primary Key.
            if (TheZombieList.Count >= 1)
            {
                DataObjects.Zombie TestZombie = TheDatabase.GetZombieByID(TheZombieList[0].ZombieSerialNumber);
            }

            //Lets update a zombie and then compare what we get using the GetZombieByID again.
            Z1.ContactType = DataObjects.Zombie.ZType.Fast;
            Z1.ContactName = "Simon Pegg";

            DataObjects.Zombie Z2 = TheDatabase.UpdateZombieByID(Z1);

            DataObjects.Zombie Z3 = TheDatabase.GetZombieByID(Z2.ZombieSerialNumber);

            //And we have to delete a Zombie by its pk.
            int ZombieAlive = TheDatabase.DeleteZombieByID(Z2.ZombieSerialNumber);


            GeoEngine_Workspace.Location L = new GeoEngine_Workspace.Location();
            Z0.MakeNoise();
            Console.ReadLine();

            DataObjects.Zombie Z4 = new DataObjects.Zombie();
            Z2.ContactType = DataObjects.Zombie.ZType.Fast;

            if (Z2.ContactType == DataObjects.Zombie.ZType.Fast)
            {
                Console.WriteLine("Fast");
            }
            return(true);
        }