예제 #1
0
 private void ValidateGuardianOnCreate(Guardian guardian)
 {
     ValidateGuardianIdIsNotNull(guardian);
     ValidateGuardianId(guardian.Id);
     ValidateGuardianRequiredFields(guardian);
     ValidateGuardianAuditFieldsOnCreate(guardian);
 }
예제 #2
0
        private void CreateGuard(GuardianType guardianType, GuardianBehaviour guardianBehaviour)
        {
            var guard = _simulation.ActorSystem.ActorOf(props: Guardian.Props(actorPaths: ActorPaths, time: 0, debug: _debugAgents), name: guardianType.ToString() + "Guard");

            _simulation.SimulationContext.Tell(message: BasicInstruction.Initialize.Create(target: guard, message: guardianBehaviour));
            ActorPaths.AddGuardian(guardianType: guardianType, actorRef: guard);
        }
예제 #3
0
        public static void Generate(WeakAura wa)
        {
            var feral    = new Feral();
            var guardian = new Guardian();
            var resto    = new RestorationDruid();

            feral.Typhoon.Talent = 7;
            guardian.IncapacitatingRoar.Talent = 8;
            resto.UrsolsVortex.Talent          = 9;

            // todo: Lunar Inspiration
            var builder = new SpecBuilder(ClassSpec.Feral);

            builder.AddRightBar(
                feral.Barkskin.Buff(),
                feral.Renewal,
                feral.Typhoon,
                guardian.IncapacitatingRoar.DeBuff(),
                resto.UrsolsVortex.DeBuff(),
                feral.Rebirth,
                feral.Maim.DeBuff(),
                feral.MightyBash.DeBuff(),
                feral.MassEntanglement.DeBuff(),
                feral.Cyclone.DeBuff(),
                // druid.EntanglingRoot1,
                // druid.Hibernate,
                // Glow if target Enraged?
                // druid.Soothe,
                // Glow if target -or- Player is Corrupted?
                // druid.RemoveCorruption,
                feral.HeartOfTheWild.Buff()
                ).AddCoreRotation(
                feral.Thrash.DoT().Passive(),
                feral.Rip.DoT().Passive(),
                feral.TigersFury.Buff(),
                feral.Rake.DoT().Passive()
                ).AddCoreCooldowns(
                feral.Berserk.Buff(),
                feral.BrutalSlash.BigStacks(),
                feral.FeralFrenzy.DeBuff()
                // Incarnation,
                ).AddBottomBar(
                feral.Dash.Buff(),
                // boomkin.TigerDash,
                feral.WildCharge,
                feral.StampedingRoar.Buff(),
                guardian.SkullBash
                ).AddTopBar(
                feral.PredatorySwiftness.Passive(),
                feral.OmenOfClarity.Passive().BigStacks().Buff(),
                feral.Bloodtalons.Passive().Buff(),
                feral.SavageRoar.Buff().Passive(),
                feral.ScentOfBlood.Buff().BigStacks(),
                feral.InfectedWounds.DeBuff().Passive()
                ).AddAlerts(
                feral.CatForm.MissingBuff().Passive(),
                feral.MoonkinForm.Buff().Passive(),
                feral.BearForm.Buff().Passive()
                ).Build(wa);
        }
예제 #4
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Guardian outGuardian = new Guardian();

            if (!isNew)
            {
                outGuardian = InGuardian;
            }

            outGuardian.FirstName = txtFirstName.Text;
            outGuardian.LastName  = txtLastName.Text;
            outGuardian.FullName  = txtFirstName.Text + " " + txtLastName.Text;
            outGuardian.Location  = txtLocation.Text;

            if (isNew)
            {
                // Update to Database
                GuardianDataService.AddGuardian(outGuardian);
            }
            else
            {
                // Go get the one of interest, then overwrite.

                // Update to Database
                GuardianDataService.SaveGuardian(outGuardian);
            }

            // Go Back
            On_BackRequested();
        }
예제 #5
0
 private void doneButton_Click(object sender, RoutedEventArgs e)
 {
     if
     (
         this.streetNumber != null &&
         this.streetName != null &&
         this.zip != null &&
         this.city != null &&
         this.state != null
     )
     {
         Guardian newGuardian = new Guardian {
             userId = this.userID, streetNumber = this.streetNumber, streetName = this.streetName, city = this.city, state = this.state, zip = this.zip
         };
         db.Guardians.InsertOnSubmit(newGuardian);
         db.SubmitChanges();
         if (home != null)
         {
             db.ExecuteCommand("INSERT INTO Guardian_Phone VALUES ({0},{1},{2})", newGuardian.guardianId, home, "Home Phone");
             db.SubmitChanges();
         }
         else if (cell != null)
         {
             db.ExecuteCommand("INSERT INTO Guardian_Phone VALUES ({0},{1},{2})", newGuardian.guardianId, cell, "Cell Phone");
             db.SubmitChanges();
         }
         MessageBox.Show("Guardian was added successfully!");
         Window.GetWindow(this).Close();
     }
     else
     {
         MessageBox.Show("Missing Value");
     }
 }
예제 #6
0
 public static TestGuardian BuildTestGuardianFromDataBase(string guardianId, string patientId)
 {
     if ((guardianId != "") && (patientId != ""))
     {
         string findIdRealationTypeString =
             "SELECT TOP(1) * FROM mm_Person2Person WHERE IdPerson = '" + patientId + "' AND IdPersonRelated = '" + guardianId + "'";
         using (SqlConnection connection = Global.GetSqlConnection())
         {
             SqlCommand IdInstitution = new SqlCommand(findIdRealationTypeString, connection);
             Guardian g = new Guardian();
             using (SqlDataReader IdRelationTypeReader = IdInstitution.ExecuteReader())
             {
                 while (IdRelationTypeReader.Read())
                 {
                     g.IdRelationType = Convert.ToByte(IdRelationTypeReader["IdRelationType"]);
                     if (Convert.ToString(IdRelationTypeReader["UnderlyingDocument"]) != "")
                         g.UnderlyingDocument = Convert.ToString(IdRelationTypeReader["UnderlyingDocument"]);
                     else
                         g.UnderlyingDocument = null;
                 }
             }
             TestGuardian guard = new TestGuardian(g);
             guard.person = TestPerson.BuildPersonFromDataBaseData(guardianId);
             return guard;
         }
     }
     return null;
 }
예제 #7
0
        public async Task ShouldThrowValidationExceptionOnModifyWhenGuardianIdIsInvalidAndLogItAsync()
        {
            //given
            Guid           invalidGuardianId = Guid.Empty;
            DateTimeOffset dateTime          = GetRandomDateTime();
            Guardian       randomGuardian    = CreateRandomGuardian(dateTime);
            Guardian       invalidGuardian   = randomGuardian;

            invalidGuardian.Id = invalidGuardianId;

            var invalidGuardianException = new InvalidGuardianException(
                parameterName: nameof(Guardian.Id),
                parameterValue: invalidGuardian.Id);

            var expectedGuardianValidationException =
                new GuardianValidationException(invalidGuardianException);

            //when
            ValueTask <Guardian> modifyGuardianTask =
                this.guardianService.ModifyGuardianAsync(invalidGuardian);

            //then
            await Assert.ThrowsAsync <GuardianValidationException>(() =>
                                                                   modifyGuardianTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedGuardianValidationException))),
                                          Times.Once);

            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
        public async void ShouldThrowValidationExceptionOnAddWhenGuardianIsNullAndLogItAsync()
        {
            // given
            Guardian randomGuardian        = default;
            Guardian nullGuardian          = randomGuardian;
            var      nullGuardianException = new NullGuardianException();

            var expectedGuardianValidationException =
                new GuardianValidationException(nullGuardianException);

            // when
            ValueTask <Guardian> createGuardianTask =
                this.guardianService.CreateGuardianAsync(nullGuardian);

            // then
            await Assert.ThrowsAsync <GuardianValidationException>(() =>
                                                                   createGuardianTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedGuardianValidationException))),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.InsertGuardianAsync(It.IsAny <Guardian>()),
                                          Times.Never);

            this.dateTimeBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
        }
        private void AddGuardianButton_Click(object sender, RoutedEventArgs e)
        {//todo split to functions somehow?
            string firstName = FirstNameTextBox.Text;
            string lastName  = LastNameTextBox.Text;
            string phone     = PhoneTextBox.Text;
            string city      = ((ComboBoxItem)CityComboBox.SelectedItem).Content.ToString();

            List <String> errorsList =
                Guardian.FindGuardianValidationErrors(firstName, lastName, phone);

            if (errorsList.Count() == 0)//if there are no errors
            {
                Guardian guardian = new Guardian(firstName, lastName, phone, city);
                AddGuardian(guardian);
            }
            else
            {
                //show dialog with information which data were incorrect
                var errorString         = String.Join("\n", errorsList.ToArray());
                MessageBoxResult result = System.Windows.MessageBox.Show(errorString,
                                                                         ErrorText,
                                                                         MessageBoxButton.OK,
                                                                         MessageBoxImage.Error);
            }
        }
 private void AddGuardian(Guardian guardian)
 {
     dataManager.AddGuardianToStudent(student, guardian);
     studentDetailsWindow.UpdateGuardiansList();
     studentDetailsWindow.IsEnabled = true;
     Close();
 }
예제 #11
0
        public IHttpActionResult GetGuardian(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            Guardian guardian = db.Guardian.Find(id);

            if (guardian == null)
            {
                return(NotFound());
            }

            var guardianReturnValue = new
            {
                guardian.guardianFirstName,
                guardian.guardianLastName,
                guardian.guardianContactNumber,
                guardian.guardianContactEmail,
                guardian.guardianID
            };

            return(Ok(guardianReturnValue));
        }
예제 #12
0
 ///<summary>Inserts one Guardian into the database.  Returns the new priKey.</summary>
 internal static long Insert(Guardian guardian)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         guardian.GuardianNum=DbHelper.GetNextOracleKey("guardian","GuardianNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(guardian,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     guardian.GuardianNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(guardian,false);
     }
 }
예제 #13
0
        public ValueTask <Guardian> CreateGuardianAsync(Guardian guardian) =>
        TryCatch(async() =>
        {
            ValidateGuardianOnCreate(guardian);

            return(await this.storageBroker.InsertGuardianAsync(guardian));
        });
        public async Task <ActionResult> Edit([Bind(Include = "User_ID,Email,Password,Prefix,First_Name,Surname,User_Type")] Guardian guardian)
        {
            if (ModelState.IsValid)
            {
                var body = "";
                //if password reset selected
                if (Request.Form["reset"] != null)
                {
                    guardian.Password = null;
                    body = "<p>Hi {0}, </p><p>The password for the email address: {1} has been reset.</p><p>Please go to the eStar site and register a new password. </p><p>Account details:<ul><li>Name: {2} {0} {3}</li><li>User: {4}</li></ul></p><p>Thank you.</p><p>eStar</p>";
                }
                else
                {
                    body = "<p>Hi {0}, </p><p>The following changes have been made to the account: {1} with eStar.</p><p>Account details:<ul><li>Name: {2} {0} {3}</li><li>User: {4}</li></ul></p><p>Thank you.</p><p>eStar</p>";
                }

                db.Entry(guardian).State = EntityState.Modified;
                db.SaveChanges();

                //send email
                string messageBody = string.Format(body, guardian.First_Name, guardian.Email, guardian.Prefix, guardian.Surname, guardian.User_Type);
                string to          = "*****@*****.**"; //change to guardian.Email when finished testing
                string from        = "*****@*****.**";
                string subject     = "eStar Account Changes";

                await SendMessage(to, from, messageBody, subject);

                return(RedirectToAction("Index"));
            }
            return(View(guardian));
        }
예제 #15
0
        public async void ShouldThrowValidationExceptionOnModifyWhenUpdatedDateIsSameAsCreatedDateAndLogItAsync()
        {
            // given
            DateTimeOffset dateTime       = GetRandomDateTime();
            Guardian       randomGuardian = CreateRandomGuardian(dateTime);
            Guardian       inputGuardian  = randomGuardian;

            var invalidGuardianInputException = new InvalidGuardianException(
                parameterName: nameof(Guardian.UpdatedDate),
                parameterValue: inputGuardian.UpdatedDate);

            var expectedGuardianValidationException =
                new GuardianValidationException(invalidGuardianInputException);

            // when
            ValueTask <Guardian> modifyGuardianTask =
                this.guardianService.ModifyGuardianAsync(inputGuardian);

            // then
            await Assert.ThrowsAsync <GuardianValidationException>(() =>
                                                                   modifyGuardianTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedGuardianValidationException))),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectGuardianByIdAsync(It.IsAny <Guid>()),
                                          Times.Never);

            this.dateTimeBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
        }
예제 #16
0
 ///<summary>Inserts one Guardian into the database.  Returns the new priKey.</summary>
 public static long Insert(Guardian guardian)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         guardian.GuardianNum = DbHelper.GetNextOracleKey("guardian", "GuardianNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(guardian, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     guardian.GuardianNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(guardian, false));
     }
 }
예제 #17
0
    /* IEnumerator CheckDistanceGround()
     * {
     *   yield return new WaitForSeconds(0.1f);
     *   while (!this.canLauchAxe)
     *   {
     *       bool check = true;
     *       yield return new WaitForEndOfFrame();
     *       RaycastHit hit;
     *       Ray ray = new Ray(this.transform.position, Vector3.down);
     *
     *       if (Physics.Raycast(ray, out hit, 500f, this.groundLayerMask) && check)
     *       {
     *           if (hit.transform != null)
     *           {
     *               float dist = Vector3.Distance(this.transform.position, hit.point);
     *               if (dist > this.distYGround)
     *               {
     *                   float newDist = this.transform.position.y - (dist - this.distYGround);
     *                   this.transform.position = new Vector3(this.transform.position.x, newDist, this.transform.position.z);
     *               }
     *               else if (dist < this.distYGround)
     *               {
     *                   float newDist = this.transform.position.y + (this.distYGround - dist);
     *                   this.transform.position = new Vector3(this.transform.position.x, newDist, this.transform.position.z);
     *               }
     *           }
     *
     *           check = false;
     *
     *       }
     *   }
     *   yield break;
     * }*/

    public void isCanLaunchAxe(bool canLaunch, Quaternion orientation)
    {
        this.axeOrientation = orientation;
        this.canLauchAxe    = canLaunch;

        if (!this.canLauchAxe)
        {
            StartCoroutine(this.CheckObject());

            this.myTrail.enabled = true;

            this.rigid.isKinematic = false;

            this.transform.parent = null;

            this.transform.eulerAngles = new Vector3(0, 0, 0);

            this.transform.position = this.myHandParent.transform.position;

            //StartCoroutine(this.CheckDistanceGround());
        }
        else if (this.canLauchAxe)
        {
            this.myTrail.enabled = false;
            this.myTrail.Clear();
            this.rigid.isKinematic       = true;
            this.transform.parent        = myHandParent.transform;
            this.transform.localPosition = Vector3.zero;
            this.lastGuardian            = null;
            StartCoroutine(CouldownLaunchAxe());
            //this.transform.localRotation = axeInitRotate;
        }
    }
        public async Task <GuardianResponse> UpdateAsync(int guardianId, Guardian guardian)
        {
            if (string.IsNullOrWhiteSpace(guardian.FirstName) || string.IsNullOrWhiteSpace(guardian.LastName))
            {
                return(new GuardianResponse("Guardian's FirstName or LastName is incorrect"));
            }

            var existingGuardian = await _guardianRepository.FindByIdAsync(guardianId);

            if (existingGuardian == null)
            {
                return(new GuardianResponse("Guardian not found"));
            }

            existingGuardian.Username  = guardian.Username;
            existingGuardian.Email     = guardian.Email;
            existingGuardian.FirstName = guardian.FirstName;
            existingGuardian.LastName  = guardian.LastName;
            existingGuardian.Gender    = guardian.Gender;
            existingGuardian.Adress    = guardian.Adress;

            try
            {
                _guardianRepository.Update(existingGuardian);
                await _unitOfWork.CompleteAsync();

                return(new GuardianResponse(existingGuardian));
            }
            catch (Exception ex)
            {
                return(new GuardianResponse($"An error ocurred while updating the guardian: {ex.Message}"));
            }
        }
예제 #19
0
        public ActionResult Verify(FormCollection form)
        {
            var svc = ServiceLocator.Resolve <IModelService>("Internal");

            if (Session["_TenantID"] == null)
            {
                return(Json(new { success = false, msg = "" }, JsonRequestBehavior.AllowGet));
            }
            var newPwd = form["NewPwd"];

            if (string.IsNullOrWhiteSpace(newPwd))
            {
                return(Json(new { success = false, msg = "密码错误" }, JsonRequestBehavior.AllowGet));
            }
            var tenant =
                svc.SelectOrEmpty(new TenantQuery()
            {
                IDs = new[] { (long)Session["_TenantID"] }
            }).FirstOrDefault();

            tenant.Password      = newPwd.Hash();
            Session["_TenantID"] = null;
            svc.Update(tenant);
            if (Session["VerifyID"] != null)
            {
                Guardian.Invoke(() => svc.Delete(new EmailVerify()
                {
                    ID = (long?)Session["VerifyID"]
                }));
                Session["VerifyID"] = null;
            }
            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
예제 #20
0
        private async Task <Guardian> PostGuardianAsync()
        {
            Guardian randomGuardian = CreateRandomGuardian();
            Guardian inputGuardian  = randomGuardian;

            return(await this.otripleSApiBroker.PostGuardianAsync(inputGuardian));
        }
예제 #21
0
 static public TestGuardian BuildTestGuardianFromDataBase(string guardianId, string patientId)
 {
     if ((guardianId != "") && (patientId != ""))
     {
         string findIdRealationTypeString =
             "SELECT TOP(1) * FROM mm_Person2Person WHERE IdPerson = '" + patientId + "' AND IdPersonRelated = '" + guardianId + "'";
         using (SqlConnection connection = Global.GetSqlConnection())
         {
             SqlCommand IdInstitution = new SqlCommand(findIdRealationTypeString, connection);
             Guardian   g             = new Guardian();
             using (SqlDataReader IdRelationTypeReader = IdInstitution.ExecuteReader())
             {
                 while (IdRelationTypeReader.Read())
                 {
                     g.IdRelationType = Convert.ToByte(IdRelationTypeReader["IdRelationType"]);
                     if (Convert.ToString(IdRelationTypeReader["UnderlyingDocument"]) != "")
                     {
                         g.UnderlyingDocument = Convert.ToString(IdRelationTypeReader["UnderlyingDocument"]);
                     }
                     else
                     {
                         g.UnderlyingDocument = null;
                     }
                 }
             }
             TestGuardian guard = new TestGuardian(g);
             guard.person = TestPerson.BuildPersonFromDataBaseData(guardianId);
             return(guard);
         }
     }
     return(null);
 }
예제 #22
0
        public async Task ShouldPutStudentGuardianAsync()
        {
            // given
            Student inputStudent = await PostStudentAsync();

            Guardian inputGuardian = await PostGuardianAsync();

            StudentGuardian randomStudentGuardian = CreateRandomStudentGuardian(inputStudent.Id, inputGuardian.Id);
            StudentGuardian inputStudentGuardian  = randomStudentGuardian;

            await this.otripleSApiBroker.PostStudentGuardianAsync(inputStudentGuardian);

            StudentGuardian modifiedStudentGuardian = randomStudentGuardian.DeepClone();

            modifiedStudentGuardian.UpdatedDate = DateTimeOffset.UtcNow;

            // when
            await this.otripleSApiBroker.PutStudentGuardianAsync(modifiedStudentGuardian);

            StudentGuardian actualStudentGuardian =
                await this.otripleSApiBroker.GetStudentGuardianAsync(
                    randomStudentGuardian.StudentId,
                    randomStudentGuardian.GuardianId);

            // then
            actualStudentGuardian.Should().BeEquivalentTo(modifiedStudentGuardian);

            await this.otripleSApiBroker.DeleteStudentGuardianAsync(actualStudentGuardian.StudentId,
                                                                    actualStudentGuardian.GuardianId);

            await this.otripleSApiBroker.DeleteGuardianByIdAsync(actualStudentGuardian.GuardianId);

            await this.otripleSApiBroker.DeleteStudentByIdAsync(actualStudentGuardian.StudentId);
        }
예제 #23
0
        public async Task ShouldThrowValidationExceptionOnModifyWhenGuardianIsNullAndLogItAsync()
        {
            //given
            Guardian invalidGuardian       = null;
            var      nullGuardianException = new NullGuardianException();

            var expectedGuardianValidationException =
                new GuardianValidationException(nullGuardianException);

            //when
            ValueTask <Guardian> modifyGuardianTask =
                this.guardianService.ModifyGuardianAsync(invalidGuardian);

            //then
            await Assert.ThrowsAsync <GuardianValidationException>(() =>
                                                                   modifyGuardianTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(expectedGuardianValidationException))),
                                          Times.Once);

            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
예제 #24
0
    private void Respawn()
    {
        IsDie = false;

        if (this.destroyAllPillierwhenIDie)
        {
            foreach (var pillier in this.myPillier)
            {
                //BoltNetwork.Destroy(pillier.gameObject);
                pillier.ActiveDestroy();
            }
            this.myPillier = new List <Pillier>();

            foreach (var seedOk in this.seedReadyImagesViseur)
            {
                seedOk.color = this.colorReady;
            }

            foreach (var seedOk in this.seedReadyUI)
            {
                seedOk.color = this.colorReady;
            }

            this.maskPanel.sizeDelta = new Vector2(this.maskPanel.rect.width, this.maxHeightMask);

            this.currentPillier            = 0;
            this.seedReadyImage.color      = Color.green;
            this.currentCooldownLaunchSeed = Time.time + 1;
            this.IsCooldown = false;
        }

        if (entity.IsOwner)
        {
            state.MyColor = lastColor;
            respawnAudioMe.start();
        }
        else
        {
            respawnAudioOther.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform.position));
            respawnAudioOther.start();
        }

        this.lastGuardianWhoHitMe = null;
        var spawnPosition = RespawnPoint();

        this.health = this.lastHealth;

        this.transform.position = spawnPosition;

        this.scoreAdditionel = 0;
        StopAllCoroutines();

        GameObject go = Instantiate(respawnParticulePrefab, this.feetPosition.position, Quaternion.identity);

        go.transform.SetParent(this.transform);
        go.transform.rotation = Quaternion.AngleAxis(-90, Vector3.right);
        Destroy(go, 2.5f);

        //respawnParticulePrefab
    }
예제 #25
0
파일: Human.cs 프로젝트: sword36/town
        private void initBehaviourModel(string prof)
        {
            switch (prof)
            {
            case "craftsman":
                Behaviour = new Craftsman(this, ProfLevels[prof]);
                break;

            case "farmer":
                Behaviour = new Farmer(this, ProfLevels[prof]);
                break;

            case "guardian":
                Behaviour = new Guardian(this, ProfLevels[prof]);
                break;

            case "thief":
                Behaviour = new Thief(this, ProfLevels[prof]);
                break;

            case "trader":
                Behaviour = new Trader(this, ProfLevels[prof]);
                break;

            default: throw new Exception("Wrong proffession");
            }

            Log.Add("citizens:Human " + Name + " behaviour: " + prof);
        }
예제 #26
0
 private void ValidateStorageGuardian(Guardian storageGuardian, Guid guardianId)
 {
     if (storageGuardian == null)
     {
         throw new NotFoundGuardianException(guardianId);
     }
 }
예제 #27
0
        public bool UpdateClientGuardian(Guardian guardianData)
        {
            try
            {
                using (var dbModel = InitiateDbContext())
                {
                    var entity = dbModel.Guardians.Find(guardianData.Id);

                    if (entity == null)
                    {
                        return(false);
                    }

                    dbModel.Entry <Guardian>(entity).CurrentValues.SetValues(guardianData);
                    dbModel.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                throw;
            }
        }
예제 #28
0
 private void ValidateGuardianIdIsNotNull(Guardian guardian)
 {
     if (guardian == default)
     {
         throw new NullGuardianException();
     }
 }
예제 #29
0
		///<summary>Inserts one Guardian into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(Guardian guardian,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				guardian.GuardianNum=ReplicationServers.GetKey("guardian","GuardianNum");
			}
			string command="INSERT INTO guardian (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="GuardianNum,";
			}
			command+="PatNumChild,PatNumGuardian,Relationship,IsGuardian) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(guardian.GuardianNum)+",";
			}
			command+=
				     POut.Long  (guardian.PatNumChild)+","
				+    POut.Long  (guardian.PatNumGuardian)+","
				+    POut.Int   ((int)guardian.Relationship)+","
				+    POut.Bool  (guardian.IsGuardian)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				guardian.GuardianNum=Db.NonQ(command,true);
			}
			return guardian.GuardianNum;
		}
예제 #30
0
 public FormGuardianEdit(Guardian guardianCur, Family fam)
 {
     InitializeComponent();
     Lan.F(this);
     _guardianCur = guardianCur;
     _fam         = fam;
 }
        public async Task ShouldRetrieveGuardianByIdAsync()
        {
            // given
            DateTimeOffset dateTime         = GetRandomDateTime();
            Guardian       randomGuardian   = CreateRandomGuardian(dateTime);
            Guid           inputGuardianId  = randomGuardian.Id;
            Guardian       inputGuardian    = randomGuardian;
            Guardian       storageGuardian  = inputGuardian;
            Guardian       expectedGuardian = storageGuardian;

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectGuardianByIdAsync(inputGuardianId))
            .ReturnsAsync(storageGuardian);

            // when
            Guardian actualGuardian =
                await this.guardianService.RetrieveGuardianByIdAsync(inputGuardianId);

            // then
            actualGuardian.Should().BeEquivalentTo(expectedGuardian);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectGuardianByIdAsync(inputGuardianId),
                                          Times.Once);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
예제 #32
0
        ///<summary>Inserts one Guardian into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(Guardian guardian, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                guardian.GuardianNum = ReplicationServers.GetKey("guardian", "GuardianNum");
            }
            string command = "INSERT INTO guardian (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "GuardianNum,";
            }
            command += "PatNumChild,PatNumGuardian,Relationship,IsGuardian) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(guardian.GuardianNum) + ",";
            }
            command +=
                POut.Long(guardian.PatNumChild) + ","
                + POut.Long(guardian.PatNumGuardian) + ","
                + POut.Int((int)guardian.Relationship) + ","
                + POut.Bool(guardian.IsGuardian) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                guardian.GuardianNum = Db.NonQ(command, true);
            }
            return(guardian.GuardianNum);
        }
예제 #33
0
        public async Task ShouldPostStudentGuardianAsync()
        {
            // given
            Student persistedStudent = await PostStudentAsync();

            Guardian persistedGuardian = await PostGuardianAsync();

            StudentGuardian randomStudentGuardian = CreateRandomStudentGuardian(
                persistedStudent.Id,
                persistedGuardian.Id);

            StudentGuardian inputStudentGuardian    = randomStudentGuardian;
            StudentGuardian expectedStudentGuardian = inputStudentGuardian;

            // when
            StudentGuardian persistedStudentGuardian =
                await this.otripleSApiBroker.PostStudentGuardianAsync(inputStudentGuardian);

            StudentGuardian actualStudentGuardian =
                await this.otripleSApiBroker.GetStudentGuardianAsync(persistedStudentGuardian.StudentId, persistedStudentGuardian.GuardianId);

            // then
            actualStudentGuardian.Should().BeEquivalentTo(expectedStudentGuardian);

            await this.otripleSApiBroker.DeleteStudentGuardianAsync(actualStudentGuardian.StudentId,
                                                                    actualStudentGuardian.GuardianId);

            await this.otripleSApiBroker.DeleteGuardianByIdAsync(actualStudentGuardian.GuardianId);

            await this.otripleSApiBroker.DeleteStudentByIdAsync(actualStudentGuardian.StudentId);
        }
예제 #34
0
 public TestGuardian(Guardian g)
 {
     if (g != null)
     {
         guardian = g;
         if (g.Person != null)
             person = new TestPerson(g.Person);
     }
 }
예제 #35
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Guardian> TableToList(DataTable table){
			List<Guardian> retVal=new List<Guardian>();
			Guardian guardian;
			for(int i=0;i<table.Rows.Count;i++) {
				guardian=new Guardian();
				guardian.GuardianNum   = PIn.Long  (table.Rows[i]["GuardianNum"].ToString());
				guardian.PatNumChild   = PIn.Long  (table.Rows[i]["PatNumChild"].ToString());
				guardian.PatNumGuardian= PIn.Long  (table.Rows[i]["PatNumGuardian"].ToString());
				guardian.Relationship  = (GuardianRelationship)PIn.Int(table.Rows[i]["Relationship"].ToString());
				guardian.IsGuardian    = PIn.Bool  (table.Rows[i]["IsGuardian"].ToString());
				retVal.Add(guardian);
			}
			return retVal;
		}
예제 #36
0
        protected Guardian CheckGuardianExists(ISession session, string guardianKey)
        {
            Guardian guardian = null;
            try { 
            guardian = session.CreateCriteria(typeof(Guardian))
               .List<Guardian>().FirstOrDefault(x => x.Member.MemberKey.Equals(guardianKey));

            }
            catch (NullReferenceException) { }

            if (guardian != null) return guardian;

            var member = session.CreateCriteria(typeof(Member))
                .List<Member>().FirstOrDefault(x => x.MemberKey.Equals(guardianKey));

            if (member == null) return null;

            guardian = new Guardian {Member = member};
            guardian.Init();

            return guardian;
        }
예제 #37
0
파일: Data.cs 프로젝트: nbIxMaN/EMKT
        private static Guardian SetGuardian()
        {
            Guardian guardian = new Guardian
            {
                IdRelationType = 1,
                UnderlyingDocument = "реквизиты",
                Person = new PersonWithIdentity
                {
                    Sex = 1,
                    Birthdate = new DateTime(1980, 11, 17),
                    IdPersonMis = DateTime.Now.ToString()+ "." + DateTime.Now.Millisecond.ToString(),
                    Documents = new List<IdentityDocument>
                    {
                        DocumentData.GuardianPassport,
                        //DocumentData.SNILS
                    },
                    HumanName = new HumanName
                    {
                        FamilyName = "Жданник",
                        GivenName = "Игорь",
                        MiddleName = "Михаилович",
                    }
                }
            };

            return guardian;
        }
        public bool AddGuardians(List<DLGuardian> guardianList)
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    try
                    {
                        var memberType = new MemberType
                        {
                            Name = "Guardian"
                        };

                        memberType.Init();
                        SetAudit(memberType);
                        session.SaveOrUpdate(memberType);

                        foreach (var dlGuardian in guardianList)
                        {
                            var member = session.CreateCriteria(typeof (Member))
                                .List<Member>().FirstOrDefault(x => x.LegacyId.Equals(dlGuardian.LegacyMemberId));

                            member.AddMemberType(memberType);
                            SetAudit(member);
                            session.SaveOrUpdate(member);

                            var guardian = new Guardian
                            {
                                Member = member
                            };

                            guardian.Init();
                            SetAudit(guardian);
                            session.SaveOrUpdate(guardian);
                        }

                        transaction.Commit();
                        return true;
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogLevel.Error, ex, string.Empty, null);
                        transaction.Rollback();
                        return false;
                    }
                }
            }
        }
예제 #39
0
파일: Data.cs 프로젝트: knastya/Fhir-Proxy
        private static Guardian SetGuardian()
        {
            Guardian guardian = new Guardian
            {
                IdRelationType = 1,
                UnderlyingDocument = "реквизиты" + new Random().Next(100),
                Person = new PersonWithIdentity
                {
                    Sex = 1,
                    Birthdate = new DateTime(1973, 01, 07),
                    IdPersonMis = DateTime.Now.ToString(),
                    Documents = new IdentityDocument[]
                    {
                        DocumentData.Passport,
                        DocumentData.SNILS
                    },
                    HumanName = new HumanName
                    {
                        FamilyName = "Лукин" + new Random().Next(100),
                        GivenName = "Василий",
                        MiddleName = "Андреевич",
                    }
                }
            };

            return guardian;
        }
예제 #40
0
		///<summary>Updates one Guardian in the database.</summary>
		public static void Update(Guardian guardian){
			string command="UPDATE guardian SET "
				+"PatNumChild   =  "+POut.Long  (guardian.PatNumChild)+", "
				+"PatNumGuardian=  "+POut.Long  (guardian.PatNumGuardian)+", "
				+"Relationship  =  "+POut.Int   ((int)guardian.Relationship)+", "
				+"IsGuardian    =  "+POut.Bool  (guardian.IsGuardian)+" "
				+"WHERE GuardianNum = "+POut.Long(guardian.GuardianNum);
			Db.NonQ(command);
		}
예제 #41
0
		///<summary>Updates one Guardian 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.</summary>
		public static void Update(Guardian guardian,Guardian oldGuardian){
			string command="";
			if(guardian.PatNumChild != oldGuardian.PatNumChild) {
				if(command!=""){ command+=",";}
				command+="PatNumChild = "+POut.Long(guardian.PatNumChild)+"";
			}
			if(guardian.PatNumGuardian != oldGuardian.PatNumGuardian) {
				if(command!=""){ command+=",";}
				command+="PatNumGuardian = "+POut.Long(guardian.PatNumGuardian)+"";
			}
			if(guardian.Relationship != oldGuardian.Relationship) {
				if(command!=""){ command+=",";}
				command+="Relationship = "+POut.Int   ((int)guardian.Relationship)+"";
			}
			if(guardian.IsGuardian != oldGuardian.IsGuardian) {
				if(command!=""){ command+=",";}
				command+="IsGuardian = "+POut.Bool(guardian.IsGuardian)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE guardian SET "+command
				+" WHERE GuardianNum = "+POut.Long(guardian.GuardianNum);
			Db.NonQ(command);
		}
예제 #42
0
 private EMKServise.Guardian ConvertGuardian(Guardian c)
 {
     if ((object)c != null)
     {
         EMKServise.Guardian ed = new EMKServise.Guardian();
         ed.IdRelationType = c.IdRelationType;
         ed.Person = ConvertPersonWithIdentity(c.Person);
         if (c.UnderlyingDocument != "")
             ed.UnderlyingDocument = c.UnderlyingDocument;
         return ed;
     }
     else
         return null;
 }
        private void SetWards(ISession session, Guardian guardian, List<Ward> wards)
        {
            guardian.Wards.Clear();

            //add new ward list
            foreach (var ward in wards)
            {

                var juniorPlayer = session.CreateCriteria(typeof(Player))
                    .List<Player>()
                    .FirstOrDefault(x => x.Member.Id.Equals(ward.MemberId));

                if (juniorPlayer != null)
                {
                    guardian.AddWard(juniorPlayer);
                }
                else
                {
                    juniorPlayer = new Player();
                    var juniorMember = session.CreateCriteria(typeof(Member))
                        .List<Member>().FirstOrDefault(x => x.Id.Equals(ward.MemberId));

                    if (juniorMember == null)
                    {
                        juniorMember = new Member
                        {
                            Lastname = ward.Lastname,
                            Firstname = ward.Firstname,
                            Types = new List<MemberType>(),
                            MemberKey =
                                CustomStringHelper.BuildKey(new[] { ward.Lastname, ward.Firstname })
                        };
                        var juniorType = session.CreateCriteria(typeof(MemberType))
                            .List<MemberType>().FirstOrDefault(x => x.Name.Equals("Player"));
                        juniorMember.AddMemberType(juniorType);
                    }

                    juniorMember.Dob = ward.Dob;
                    SetAudit(juniorMember);
                    session.SaveOrUpdate(juniorMember);

                    juniorPlayer.Member = juniorMember;
                    juniorPlayer.Nickname = ward.Nickname;
                    juniorPlayer.PlayerType = (int)PlayerType.Junior;
                    juniorPlayer.Guardians = new List<Guardian>();
                    SetAudit(juniorPlayer);
                    session.SaveOrUpdate(juniorPlayer);
                    guardian.AddWard(juniorPlayer);
                }
            }
        }