void Update()
 {
     if (!laboratoryGO && GameObject.FindGameObjectWithTag("Laboratory"))
     {
         laboratoryGO = GameObject.FindGameObjectWithTag("Laboratory");
         lab = (Laboratory)resources.buildings[laboratoryGO.GetComponent<IdManager>().buildingIndex];
         foundLab = true;
     }
 }
Example #2
0
        // GET: Laboratories/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Laboratory laboratory = db.Laboratories.Find(id);

            if (laboratory == null)
            {
                return(HttpNotFound());
            }
            return(View(laboratory));
        }
        public async Task <ActionResult> Create()
        {
            // var authorId = await GetAuthorId();
            //var lab = new Laboratory { AuthorId = authorId };
            var authorId = await GetAuthorId();

            var lab = new Laboratory {
                AuthorId = authorId
            };

            ViewBag.LabClasificationId = new SelectList(_db.LabClasifications, "LabClasificationId", "Name");

            return(View(lab));
        }
Example #4
0
        public IActionResult Add([FromForm] Models.Trbovlje.LaboratoryViewModel analayser)
        {
            if (!ModelState.IsValid)
            {
                return(View(analayser));
            }

            Laboratory dbLaboratory = new Laboratory();

            _mapper.Map(analayser, dbLaboratory);
            _dbContext.Laboratories.Add(dbLaboratory);
            _dbContext.SaveChanges();

            return(RedirectToAction("Index"));
        }
        internal Response addLab(Laboratory laboratory)
        {
            Response response = Response.Success;

            try
            {
                checkUpContext.Laboratories.Add(laboratory);
                checkUpContext.SaveChanges();
            }
            catch (Exception ex)
            {
                response = Response.Fail;
            }
            return(response);
        }
Example #6
0
        public void Update(Laboratory laboratory)
        {
            if (laboratory == null)
            {
                return;
            }
            var lab = DB.Laboratories.FirstOrDefault(u => u.ID == laboratory.ID);

            if (lab == null)
            {
                return;
            }
            DB.Entry(lab).CurrentValues.SetValues(laboratory);
            DB.SaveChanges();
        }
Example #7
0
        public void Delete(Laboratory laboratory)
        {
            if (laboratory == null)
            {
                return;
            }
            var lab = DB.Laboratories.FirstOrDefault(u => u.ID == laboratory.ID);

            if (lab == null)
            {
                return;
            }
            DB.Laboratories.Remove(lab);
            DB.SaveChanges();
        }
Example #8
0
 ///<summary>Inserts one Laboratory into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Laboratory laboratory)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(laboratory, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             laboratory.LaboratoryNum = DbHelper.GetNextOracleKey("laboratory", "LaboratoryNum");                  //Cacheless method
         }
         return(InsertNoCache(laboratory, true));
     }
 }
        public void ShouldCreateAnimalWithGivenNameAndType()
        {
            //Given
            StubCommandInterface stubbedCli = new StubCommandInterface();
            Laboratory           laboratory = new Laboratory(stubbedCli);
            AnimalTypeEnum       testType   = AnimalTypeEnum.Cat;
            string testName     = "Tom";
            string expectedInfo = $"Created {testType} with name {testName}.";

            //When
            laboratory.Create(testType, testName);

            //Then
            Assert.That(stubbedCli.InfoMessages, Does.Contain(expectedInfo));
        }
Example #10
0
 ///<summary>Returns true if Update(Laboratory,Laboratory) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(Laboratory laboratory, Laboratory oldLaboratory)
 {
     if (laboratory.Description != oldLaboratory.Description)
     {
         return(true);
     }
     if (laboratory.Phone != oldLaboratory.Phone)
     {
         return(true);
     }
     if (laboratory.Notes != oldLaboratory.Notes)
     {
         return(true);
     }
     if (laboratory.Slip != oldLaboratory.Slip)
     {
         return(true);
     }
     if (laboratory.Address != oldLaboratory.Address)
     {
         return(true);
     }
     if (laboratory.City != oldLaboratory.City)
     {
         return(true);
     }
     if (laboratory.State != oldLaboratory.State)
     {
         return(true);
     }
     if (laboratory.Zip != oldLaboratory.Zip)
     {
         return(true);
     }
     if (laboratory.Email != oldLaboratory.Email)
     {
         return(true);
     }
     if (laboratory.WirelessPhone != oldLaboratory.WirelessPhone)
     {
         return(true);
     }
     if (laboratory.IsHidden != oldLaboratory.IsHidden)
     {
         return(true);
     }
     return(false);
 }
Example #11
0
        public async Task InitPlayer(User user, string cityName)
        {
            var game = await _dbContext.Games.Include(g => g.Players).OrderByDescending(g => g.Id).FirstOrDefaultAsync();

            if (game == null)
            {
                //If there aren't any game being played currently , then create a new game.
                game = new Game {
                    FirstConnectedPlayersTS = DateTime.Now, Turn = 0, Players = new List <Player>()
                };
            }

            var incident = await _dbContext.Incidents.Where(i => i.Type == IncidentTypes.NothingHappened).SingleOrDefaultAsync();

            Player player = new Player {
                UserId = user.Id, Points = 0, GameId = game.Id, IncidentId = incident.Id
            };

            game.Players.Add(player);
            var newPlayer = await InsertPlayer(player);

            City city = new City {
                Name = cityName, PlayerId = newPlayer.Id
            };
            await _cityService.InsertCity(city, newPlayer);

            Army army = new Army {
                PlayerId = newPlayer.Id, ScoutXP = 0, AttackXP = 0, DefenseXP = 0
            };
            var newArmy = await _armyService.InsertArmy(army, newPlayer);

            Stock stock = new Stock {
                PlayerId = newPlayer.Id, CoralAmount = 0, PearlAmount = 0
            };
            await _stockService.InsertStock(stock, newPlayer);

            await _stockService.GiveInitialMoneyAsync(stock);

            Laboratory laboratory = new Laboratory {
                PlayerId = newPlayer.Id
            };
            await _laboratoryService.InsertLaboratory(laboratory, newPlayer);

            Squad squad = new Squad {
                ArmyId = newArmy.Id
            };
            await _squadService.InsertSquad(squad, newArmy, city.Id);
        }
Example #12
0
        public void LaboratoryTest_withID()
        {
            // Arrange
            Laboratory entry = new Laboratory("_xxx");

            // Act
            // Assert
            Assert.IsNotNull(entry);
            Assert.IsNotNull(entry.Reader);

            Assert.AreEqual("_xxx", entry.ID);
            Assert.IsNull(entry.Name);
            Assert.IsNull(entry.Details);
            Assert.IsNull(entry.Status);
            Assert.IsNull(entry.LastUpdated);
        }
Example #13
0
        private void buttonInsert_Click(object sender, EventArgs e)
        {
            Laboratory laboratory = new Laboratory()
            {
                Name    = textBoxLABName.Text,
                Gender  = comboBoxLABGender.Text,
                Email   = textBoxLABEmail.Text,
                Tel     = textBoxLABTel.Text,
                Address = textBoxLABAddress.Text,
                testfor = comboBoxLABTEST.Text
            };
            DatabaseOps insetlab = new DatabaseOps();

            insetlab.insert(laboratory);
            display();
        }
Example #14
0
        public ActionResult DeleteLaboratoryConfirmed(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Laboratory b = db.Laboratories.Find(id);

            if (b == null)
            {
                return(HttpNotFound());
            }
            db.Laboratories.Remove(b);
            db.SaveChanges();
            return(RedirectToAction("Laboratories"));
        }
Example #15
0
        public int GetLaboratoryPoints(Laboratory laboratory)
        {
            var laboratoryPoints = 0;

            var laboratoryInnovations = laboratory.LaboratoryInnovations.ToList();

            foreach (var laboratoryInnovation in laboratoryInnovations)
            {
                if (laboratoryInnovation.Researched)
                {
                    laboratoryPoints += INNOVATION_POINTS;
                }
            }

            return(laboratoryPoints);
        }
        public void CreateLaboratory()
        {
            using (ApplicationDbContext context = new ApplicationDbContext())
            {
                Laboratory lab = new Laboratory();
                lab.LabolatoryName = "KLabs";
                lab.LaboratoryId   = "01";
                lab.City           = "Rzeszow";
                lab.Country        = "Poland";
                lab.ZipCode        = "35084";
                lab.Street         = "Poznanska 2";

                context.Laboratories.Add(lab);
                context.SaveChanges();
            }
        }
Example #17
0
        public IActionResult CreateIncomingOrderLab()
        {
            Laboratory            laboratory      = new Laboratory();
            DataSet               dataset         = GetTypeOfMaterialDB(2);
            List <SelectListItem> selectListItems = new List <SelectListItem>();

            foreach (DataRow item in dataset.Tables[0].Rows)
            {
                selectListItems.Add(new SelectListItem {
                    Value = item["TypeOfMaterial"].ToString(), Text = item["TypeOfMaterial"].ToString()
                });
            }
            ViewBag.TypeList = selectListItems;

            return(View(laboratory));
        }
Example #18
0
        public async Task <LaboratoryForUpdateDto> UpdateLaboratory(Laboratory laboratory)
        {
            var currentLaboratory = await _laboratoriesRepo.GetLaboratoryById(laboratory.Id);

            currentLaboratory.Name       = laboratory.Name;
            currentLaboratory.StartDate  = laboratory.StartDate.LocalDateTime;
            currentLaboratory.EndDate    = laboratory.EndDate.LocalDateTime;
            currentLaboratory.TeacherId  = laboratory.TeacherId;
            currentLaboratory.SubGroupId = laboratory.SubGroupId;
            currentLaboratory.ClassId    = laboratory.ClassId;
            currentLaboratory.CourseId   = laboratory.CourseId;

            var mappedCourse = _mapper.Map <LaboratoryForUpdateDto>(currentLaboratory);

            return(mappedCourse);
        }
 public ActionResult Create(int?id)
 {
     if (id.HasValue)
     {
         Laboratory laboratory = this.services.LaboratoryService.GetById(id.Value);
         if (laboratory != null)
         {
             return(View(new LaboratoryViewModel().ToViewModel(laboratory)));
         }
         else
         {
             return(Json(new { Msg = "Preencha todos os campos", Erro = true }));
         }
     }
     return(View(new LaboratoryViewModel()));
 }
Example #20
0
        private void ImportBlood()
        {
            List <string> data = File.ReadLines(@"F:\ЯндексДиск\работяга\Четвёртый курс\Второй семак\WSR\WSR_Laboratory\ImportData\blood.txt").ToList();

            data.ForEach((item) =>
            {
                string[] itemData = item.Split('\t');
                blood blood       = new blood();
                blood.id_patient  = int.Parse(itemData[1]);
                blood.barcode     = decimal.Parse(itemData[2]);
                blood.date_create = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(itemData[3].Replace("-", ""))).DateTime;
                blood.id_status   = 1;
                Laboratory.GetContext().blood.Add(blood);
            });

            Laboratory.GetContext().SaveChanges();
        }
Example #21
0
        private void ImportBloodService()
        {
            List <string> data = File.ReadLines(@"F:\ЯндексДиск\работяга\Четвёртый курс\Второй семак\WSR\WSR_Laboratory\ImportData\blood_service.txt").ToList();

            data.ForEach((item) =>
            {
                string[] itemData = item.Split('\t');

                string AnalyzerName = itemData[6];
                analyzer analyzer   = Laboratory.GetContext().analyzer.Where(p => p.name == AnalyzerName).FirstOrDefault();
                if (analyzer == null)
                {
                    analyzer      = new analyzer();
                    analyzer.name = AnalyzerName;
                    Laboratory.GetContext().analyzer.Add(analyzer);
                    Laboratory.GetContext().SaveChanges();
                }

                blood_service blood_service = new blood_service();
                decimal service_code        = decimal.Parse(itemData[1]);
                blood_service.service       = Laboratory.GetContext().service.Where(p => p.code == service_code).FirstOrDefault();
                int IdBlood = int.Parse(itemData[0]);
                blood blood = Laboratory.GetContext().blood.Where(p => p.id_blood == IdBlood).FirstOrDefault();
                if (blood == null)
                {
                    return;
                }
                blood_service.blood         = blood;
                blood_service.result        = decimal.Parse(itemData[2]);
                blood_service.date_finished = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(itemData[3])).DateTime;
                blood_service.accepted      = bool.Parse(itemData[4]);
                blood_service.id_status     = itemData[5] == "Finished" ? 1 : 2;
                int UserId             = int.Parse(itemData[7]);
                blood_service.employee = Laboratory.GetContext().employee.Where(p => p.id_user == UserId).FirstOrDefault();
                Laboratory.GetContext().blood_service.Add(blood_service);

                analyzer_blood_service analyzer_Blood = new analyzer_blood_service();
                analyzer_Blood.analyzer       = analyzer;
                analyzer_Blood.blood_service  = blood_service;
                analyzer_Blood.date_reception = blood.date_create;
                analyzer_Blood.date_finished  = blood_service.date_finished;
                Laboratory.GetContext().analyzer_blood_service.Add(analyzer_Blood);
            });

            Laboratory.GetContext().SaveChanges();
        }
Example #22
0
        static void Main(string[] args)
        {
            List <Person>  schoolEmployees = new List <Person>();
            List <Student> students        = new List <Student>();

            Laboratory lab   = new Laboratory("Optica");
            Admin      admin = new Admin("Бог", "Vseya", "Rusi", new DateTime(1, 1, 1), 10000, lab);

            salaryGiver += admin.getSalary;
            schoolEmployees.Add(admin);

            Teacher teacher = new Teacher("Vera", "Muhoedova", "Dmitievna", new DateTime(1945, 3, 3), "Econom fac.", 20);

            salaryGiver += teacher.getSalary;
            schoolEmployees.Add(teacher);

            Position position = new Position("управлюзий", 1000);
            Manager  manager  = new Manager("OLeg", "Zososov", "Piramidovich", new DateTime(1987, 12, 31), "Econom fac.", position);

            salaryGiver += manager.getSalary;
            schoolEmployees.Add(manager);

            Student student1 = new Student("Daniil", "Litvinenko", "Dmitrievich", new DateTime(2001, 05, 31), "IKT", "K3121");

            students.Add(student1);
            Student student2 = new Student("FEEf", "ninayuuuu", "Javavich", new DateTime(2000, 12, 12), "FIKT", "RE3112");

            students.Add(student2);


            foreach (Person p in schoolEmployees)
            {
                p.Print();
                Console.WriteLine();
            }

            foreach (Student s in students)
            {
                s.Print();
                Console.WriteLine();
            }

            Console.WriteLine("press any button for selary");
            Console.ReadLine();
            getSalaryAll();
        }
Example #23
0
        public void RetrieveBasicInformationTest_withInvalidID_BasicInfoOnly()
        {
            // Arrange
            Laboratory entry = new Laboratory("_aaa");

            // Act
            int count = entry.RetrieveBasicInformation(true);

            // Assert
            Assert.AreEqual(0, count);

            Assert.AreEqual("_aaa", entry.ID);
            Assert.IsNull(entry.Name);
            Assert.IsNull(entry.Details);
            Assert.IsNull(entry.Status);
            Assert.IsNull(entry.LastUpdated);
        }
Example #24
0
        public void RetrieveTest_withValidID_BasicInfoOnly()
        {
            // Arrange
            Laboratory entry = new Laboratory("_xxx");

            // Act
            int count = entry.Retrieve(true);

            // Assert
            Assert.AreEqual(1, count);

            Assert.AreEqual("_xxx", entry.ID);
            Assert.AreEqual("Laboratory Name X", entry.Name);
            Assert.AreEqual("Laboratory Details X", entry.Details);
            Assert.AreEqual("_xxx", entry.Status.ID);
            Assert.AreEqual("Laboratory LastUpdated X", entry.LastUpdated);
        }
Example #25
0
        public async Task <ActionResult> Edit(Laboratory laboratory)
        {
            if (!ModelState.IsValid)
            {
                return(View(laboratory));
            }
            var authorId = await GetAuthorId();

            if (laboratory.AuthorId != authorId)
            {
                return(View("Error"));
            }
            _db.Entry(laboratory).State = EntityState.Modified;
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #26
0
        public async Task <ActionResult> Create(Laboratory laboratory)
        {
            if (!ModelState.IsValid)
            {
                return(View(laboratory));
            }
            var authorId = await GetAuthorId();

            if (laboratory.AuthorId != authorId)
            {
                return(View("Error"));
            }
            _db.Laboratories.Add(laboratory);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #27
0
        public void RetrieveTest_withInvalidID_AdditonalInfo()
        {
            // Arrange
            Laboratory entry = new Laboratory("_aaa");

            // Act
            int count = entry.Retrieve(false);

            // Assert
            Assert.AreEqual(0, count);

            Assert.AreEqual("_aaa", entry.ID);
            Assert.IsNull(entry.Name);
            Assert.IsNull(entry.Details);
            Assert.IsNull(entry.Status);
            Assert.IsNull(entry.LastUpdated);
        }
Example #28
0
        ///<summary>Inserts one Laboratory into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(Laboratory laboratory, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO laboratory (";

            if (!useExistingPK && isRandomKeys)
            {
                laboratory.LaboratoryNum = ReplicationServers.GetKeyNoCache("laboratory", "LaboratoryNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "LaboratoryNum,";
            }
            command += "Description,Phone,Notes,Slip,Address,City,State,Zip,Email,WirelessPhone,IsHidden) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(laboratory.LaboratoryNum) + ",";
            }
            command +=
                "'" + POut.String(laboratory.Description) + "',"
                + "'" + POut.String(laboratory.Phone) + "',"
                + DbHelper.ParamChar + "paramNotes,"
                + POut.Long(laboratory.Slip) + ","
                + "'" + POut.String(laboratory.Address) + "',"
                + "'" + POut.String(laboratory.City) + "',"
                + "'" + POut.String(laboratory.State) + "',"
                + "'" + POut.String(laboratory.Zip) + "',"
                + "'" + POut.String(laboratory.Email) + "',"
                + "'" + POut.String(laboratory.WirelessPhone) + "',"
                + POut.Bool(laboratory.IsHidden) + ")";
            if (laboratory.Notes == null)
            {
                laboratory.Notes = "";
            }
            OdSqlParameter paramNotes = new OdSqlParameter("paramNotes", OdDbType.Text, POut.StringParam(laboratory.Notes));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNotes);
            }
            else
            {
                laboratory.LaboratoryNum = Db.NonQ(command, true, "LaboratoryNum", "laboratory", paramNotes);
            }
            return(laboratory.LaboratoryNum);
        }
Example #29
0
 public void Insert(Laboratory laboratory)
 {
     try
     {
         SqlConnection con = DataBaseConnection("open");
         SqlCommand    sqlcommand;
         string        databaseCommand = " INSERT INTO laboratory (name,capacity,type,id_Faculty) values (" + "'" + laboratory.Name + "'" + "," + "" + laboratory.Capacity + "" + "," + "'" + laboratory.Type + "'" + "," + "'" + laboratory.FacultyId + "'" + ")";
         sqlcommand = new SqlCommand(databaseCommand, con);
         sqlcommand.ExecuteNonQuery();
         sqlcommand.Dispose();
         DataBaseConnection("close");
     }
     catch (SqlException sqlException)
     {
         Console.WriteLine("Database error:" + sqlException.ToString());
     }
 }
Example #30
0
        public void RetrieveBasicInformationTest_withValidID_AdditionalInfo()
        {
            // Arrange
            Laboratory entry = new Laboratory("_xxx");

            // Act
            int count = entry.RetrieveBasicInformation(false);

            // Assert
            Assert.AreEqual(1, count);

            Assert.AreEqual("_xxx", entry.ID);
            Assert.AreEqual("Laboratory Name X", entry.Name);
            Assert.AreEqual("Laboratory Details X", entry.Details);
            Assert.AreEqual("_xxx", entry.Status.ID);
            Assert.AreEqual("Laboratory LastUpdated X", entry.LastUpdated);
        }
Example #31
0
        // GET: Laboratories/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Laboratory laboratory = await db.Laboratories.FindAsync(id);

            if (laboratory == null)
            {
                return(HttpNotFound());
            }

            ViewBag.LaboratorySpecializations = await db.LaboratorySpecializations.ToListAsync();

            return(View(laboratory));
        }
        public void Candidate_One(Mock<ISciencePublisher> publisher,
            Mock<IScienceExperiment<string, string>> experiment, string candResult,
            Mock<IExperimentSteps<string, string>> steps, string name)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> candidate = () => candResult;

            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Candidate(name, candidate);

            //Verify
            steps.Verify(x => x.AddCandidate(name, candidate), Times.Once);
        }
        public void AreEqual(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            AreEqualDelegate<string> areEqual = (ctrl, cand) => ctrl == cand;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .AreEqual(areEqual);

            //Verify
            steps.VerifySet(x => x.AreEqual = areEqual, Times.Once);
        }
Example #34
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Laboratory> TableToList(DataTable table){
			List<Laboratory> retVal=new List<Laboratory>();
			Laboratory laboratory;
			for(int i=0;i<table.Rows.Count;i++) {
				laboratory=new Laboratory();
				laboratory.LaboratoryNum= PIn.Long  (table.Rows[i]["LaboratoryNum"].ToString());
				laboratory.Description  = PIn.String(table.Rows[i]["Description"].ToString());
				laboratory.Phone        = PIn.String(table.Rows[i]["Phone"].ToString());
				laboratory.Notes        = PIn.String(table.Rows[i]["Notes"].ToString());
				laboratory.Slip         = PIn.Long  (table.Rows[i]["Slip"].ToString());
				laboratory.Address      = PIn.String(table.Rows[i]["Address"].ToString());
				laboratory.City         = PIn.String(table.Rows[i]["City"].ToString());
				laboratory.State        = PIn.String(table.Rows[i]["State"].ToString());
				laboratory.Zip          = PIn.String(table.Rows[i]["Zip"].ToString());
				laboratory.Email        = PIn.String(table.Rows[i]["Email"].ToString());
				laboratory.WirelessPhone= PIn.String(table.Rows[i]["WirelessPhone"].ToString());
				retVal.Add(laboratory);
			}
			return retVal;
		}
Example #35
0
		///<summary>Inserts one Laboratory into the database.  Returns the new priKey.</summary>
		public static long Insert(Laboratory laboratory){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				laboratory.LaboratoryNum=DbHelper.GetNextOracleKey("laboratory","LaboratoryNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(laboratory,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							laboratory.LaboratoryNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(laboratory,false);
			}
		}
Example #36
0
 public void BuildLaboratory(Aura aura)
 {
     Laboratory = new Laboratory(this, aura, 0);
 }
        public void Teardown(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            bool raised = false;
            EventHandler<ExperimentEventArgs> teardown = (sender, e) => raised = true;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .Teardown(teardown);
            steps.Raise(x => x.TeardownEvent += null, new ExperimentEventArgs());

            //Verify
            Assert.True(raised);
        }
        public void SetContext(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            Func<object> setContext = () => true;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .SetContext(setContext);

            //Verify
            steps.VerifySet(x => x.SetContext = setContext, Times.Once);
        }
        public void Prepare(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            PrepareDelegate<string, string> prepare = (val) => val;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .Prepare(prepare);

            //Verify
            steps.VerifySet(x => x.Prepare = prepare, Times.Once);
        }
Example #40
0
		///<summary>Inserts one Laboratory into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(Laboratory laboratory,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				laboratory.LaboratoryNum=ReplicationServers.GetKey("laboratory","LaboratoryNum");
			}
			string command="INSERT INTO laboratory (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="LaboratoryNum,";
			}
			command+="Description,Phone,Notes,Slip,Address,City,State,Zip,Email,WirelessPhone) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(laboratory.LaboratoryNum)+",";
			}
			command+=
				 "'"+POut.String(laboratory.Description)+"',"
				+"'"+POut.String(laboratory.Phone)+"',"
				+"'"+POut.String(laboratory.Notes)+"',"
				+    POut.Long  (laboratory.Slip)+","
				+"'"+POut.String(laboratory.Address)+"',"
				+"'"+POut.String(laboratory.City)+"',"
				+"'"+POut.String(laboratory.State)+"',"
				+"'"+POut.String(laboratory.Zip)+"',"
				+"'"+POut.String(laboratory.Email)+"',"
				+"'"+POut.String(laboratory.WirelessPhone)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				laboratory.LaboratoryNum=Db.NonQ(command,true);
			}
			return laboratory.LaboratoryNum;
		}
Example #41
0
		///<summary>Updates one Laboratory in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(Laboratory laboratory,Laboratory oldLaboratory){
			string command="";
			if(laboratory.Description != oldLaboratory.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(laboratory.Description)+"'";
			}
			if(laboratory.Phone != oldLaboratory.Phone) {
				if(command!=""){ command+=",";}
				command+="Phone = '"+POut.String(laboratory.Phone)+"'";
			}
			if(laboratory.Notes != oldLaboratory.Notes) {
				if(command!=""){ command+=",";}
				command+="Notes = '"+POut.String(laboratory.Notes)+"'";
			}
			if(laboratory.Slip != oldLaboratory.Slip) {
				if(command!=""){ command+=",";}
				command+="Slip = "+POut.Long(laboratory.Slip)+"";
			}
			if(laboratory.Address != oldLaboratory.Address) {
				if(command!=""){ command+=",";}
				command+="Address = '"+POut.String(laboratory.Address)+"'";
			}
			if(laboratory.City != oldLaboratory.City) {
				if(command!=""){ command+=",";}
				command+="City = '"+POut.String(laboratory.City)+"'";
			}
			if(laboratory.State != oldLaboratory.State) {
				if(command!=""){ command+=",";}
				command+="State = '"+POut.String(laboratory.State)+"'";
			}
			if(laboratory.Zip != oldLaboratory.Zip) {
				if(command!=""){ command+=",";}
				command+="Zip = '"+POut.String(laboratory.Zip)+"'";
			}
			if(laboratory.Email != oldLaboratory.Email) {
				if(command!=""){ command+=",";}
				command+="Email = '"+POut.String(laboratory.Email)+"'";
			}
			if(laboratory.WirelessPhone != oldLaboratory.WirelessPhone) {
				if(command!=""){ command+=",";}
				command+="WirelessPhone = '"+POut.String(laboratory.WirelessPhone)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE laboratory SET "+command
				+" WHERE LaboratoryNum = "+POut.Long(laboratory.LaboratoryNum);
			Db.NonQ(command);
			return true;
		}
Example #42
0
		///<summary>Updates one Laboratory in the database.</summary>
		public static void Update(Laboratory laboratory){
			string command="UPDATE laboratory SET "
				+"Description  = '"+POut.String(laboratory.Description)+"', "
				+"Phone        = '"+POut.String(laboratory.Phone)+"', "
				+"Notes        = '"+POut.String(laboratory.Notes)+"', "
				+"Slip         =  "+POut.Long  (laboratory.Slip)+", "
				+"Address      = '"+POut.String(laboratory.Address)+"', "
				+"City         = '"+POut.String(laboratory.City)+"', "
				+"State        = '"+POut.String(laboratory.State)+"', "
				+"Zip          = '"+POut.String(laboratory.Zip)+"', "
				+"Email        = '"+POut.String(laboratory.Email)+"', "
				+"WirelessPhone= '"+POut.String(laboratory.WirelessPhone)+"' "
				+"WHERE LaboratoryNum = "+POut.Long(laboratory.LaboratoryNum);
			Db.NonQ(command);
		}
Example #43
0
    public string buildingFlavorText(string building)
    {
        if (building == "House")
        {
            House x = new House();
            return x.flavorText;
        }

        else if (building == "Farm")
        {
            Farm x = new Farm();
            return x.flavorText;
        }

        else if (building == "Factory")
        {
            Factory x = new Factory();
            return x.flavorText;
        }

        else if (building == "Executive Building")
        {
            ExecutiveBuilding x = new ExecutiveBuilding();
            return x.flavorText;
        }

        else if (building == "Educational Building")
        {
            EducationalBuilding x = new EducationalBuilding();
            return x.flavorText;
        }

        else if (building == "Hospital")
        {
            Hospital x = new Hospital();
            return x.flavorText;
        }

        else if (building == "Laboratory")
        {
            Laboratory x = new Laboratory();
            return x.flavorText;
        }

        else if (building == "Police Station")
        {
            PoliceStation x = new PoliceStation();
            return x.flavorText;
        }

        else if (building == "Workplace")
        {
            Workplace x = new Workplace();
            return x.flavorText;
        }

        else if (building == "Public Space")
        {
            PublicSpace x = new PublicSpace();
            return x.flavorText;
        }

        else if (building == "World Trade Center")
        {
            WTC x = new WTC();
            return x.flavorText;
        }

        else if (building == "Military Outpost")
        {
            MilitaryOutpost x = new MilitaryOutpost();
            return x.flavorText;
        }

        else if (building == "Food Territory")
        {
            FoodTerritory x = new FoodTerritory();
            return x.flavorText;
        }

        else if (building == "Materials Territory")
        {
            MaterialsTerritory x = new MaterialsTerritory();
            return x.flavorText;
        }

        else if (building == "Citizens Territory")
        {
            CitizensTerritory x = new CitizensTerritory();
            return x.flavorText;
        }

        else
            return "";
    }
Example #44
0
        /// <summary>
        /// Creates a new card based on how many cards have already been made.
        /// </summary>
        /// <param name="card">
        /// The name of the card to be created.
        /// </param>
        /// <returns>
        /// The new created card.
        /// </returns>
        public static Card CreateCard(CardName card)
        {
            Contract.Requires(card != CardName.Backside & card != CardName.Empty);

            Contract.Ensures(Contract.Result<Card>().Name == card);

            Card c;
            switch (card)
            {
                case CardName.Copper:
                    c = new Copper();
                    break;
                case CardName.Silver:
                    c = new Silver();
                    break;
                case CardName.Gold:
                    c = new Gold();
                    break;
                case CardName.Curse:
                    c = new Curse();
                    break;
                case CardName.Estate:
                    c = new Estate();
                    break;
                case CardName.Duchy:
                    c = new Duchy();
                    break;
                case CardName.Province:
                    c = new Province();
                    break;
                case CardName.Gardens:
                    c = new Gardens();
                    break;
                case CardName.Cellar:
                    c = new Cellar();
                    break;
                case CardName.Chapel:
                    c = new Chapel();
                    break;
                case CardName.Chancellor:
                    c = new Chancellor();
                    break;
                case CardName.Village:
                    c = new Village();
                    break;
                case CardName.Woodcutter:
                    c = new Woodcutter();
                    break;
                case CardName.Workshop:
                    c = new Workshop();
                    break;
                case CardName.Feast:
                    c = new Feast();
                    break;
                case CardName.Moneylender:
                    c = new Moneylender();
                    break;
                case CardName.Remodel:
                    c = new Remodel();
                    break;
                case CardName.Smithy:
                    c = new Smithy();
                    break;
                case CardName.ThroneRoom:
                    c = new ThroneRoom();
                    break;
                case CardName.CouncilRoom:
                    c = new CouncilRoom();
                    break;
                case CardName.Festival:
                    c = new Festival();
                    break;
                case CardName.Laboratory:
                    c = new Laboratory();
                    break;
                case CardName.Library:
                    c = new Library();
                    break;
                case CardName.Market:
                    c = new Market();
                    break;
                case CardName.Mine:
                    c = new Mine();
                    break;
                case CardName.Adventurer:
                    c = new Adventurer();
                    break;
                case CardName.Bureaucrat:
                    c = new Bureaucrat();
                    break;
                case CardName.Militia:
                    c = new Militia();
                    break;
                case CardName.Spy:
                    c = new Spy();
                    break;
                case CardName.Thief:
                    c = new Thief();
                    break;
                case CardName.Witch:
                    c = new Witch();
                    break;
                case CardName.Moat:
                    c = new Moat();
                    break;
                default:
                    throw new NotImplementedException("Tried to create a card that was not implemented when CardFactory was last updated.");
            }

            c.Initialize(card, CardsMade[card]);
            CardsMade[card] += 1;
            createdCards.Add(c, true);
            return c;
        }
Example #45
0
 public void BuildLaboratory()
 {
     // TODO: flesh out laboratory specialization
     Laboratory = new Laboratory(this, Covenant.Aura, 0);
 }