Ejemplo n.º 1
0
 private void ASCIIWriteShip(IDNumber ctrlIdx, Ship ship, char character, ConsoleColor colorText, ConsoleColor colorBack)
 {
     foreach (Coordinates coord in ship.Locations)
     {
         ModifyASCII(ctrlIdx, coord.X, coord.Y, character, colorText, colorBack);
     }
 }
Ejemplo n.º 2
0
        public IDNumber NextTurn()
        {
            if (turns.Count == 1)
            {
                CurrentTurnPlayer = turns[0];
                return(CurrentTurnPlayer);
            }
            int currentTurnIdx;

            for (currentTurnIdx = 0; currentTurnIdx < turns.Count; currentTurnIdx++)
            {
                if (turns[currentTurnIdx] == CurrentTurnPlayer)
                {
                    break;
                }
            }
            for (int i = 1; i < turns.Count; i++)
            {
                IDNumber plr = turns[(currentTurnIdx + i) % turns.Count];
                if (Match.Teams[DeadTeam].Members.Contains(plr))
                {
                    continue;
                }
                return(plr);
            }
            return(CurrentTurnPlayer);
        }
Ejemplo n.º 3
0
        public List <IDNumber> SelectIDNumber(IDNumber parameter)
        {
            List <IDNumber> list = new List <IDNumber>();

            try
            {
                var query = from a in _dataContext.IDNumbers
                            .WhereIf(parameter.SlNo != 0, q => q.SlNo == parameter.SlNo)
                            .WhereIf(!String.IsNullOrEmpty(parameter.IDNo), q => q.IDNo == parameter.IDNo)
                            .WhereIf(!String.IsNullOrEmpty(parameter.IDTypeId), q => q.IDTypeId == parameter.IDTypeId)
                            .WhereIf(!String.IsNullOrEmpty(parameter.CompanyId), q => q.CompanyId == parameter.CompanyId)
                            .WhereIf(!String.IsNullOrEmpty(parameter.LocationId), q => q.LocationId == parameter.LocationId)
                            .WhereIf(!String.IsNullOrEmpty(parameter.EntryBy), q => q.EntryBy == parameter.EntryBy)
                            .WhereIf(parameter.DateOfEntry.HasValue, q => q.DateOfEntry == parameter.DateOfEntry.Value)
                            .WhereIf(parameter.IDYear.HasValue, q => q.IDYear == parameter.IDYear.Value)
                            orderby a.IDNo ascending
                            select a;
                list = query.ToList <IDNumber>();
            }
            catch (SqlException ex)
            {
                _ErrorHandler.ONSERRORProcessing(ex);
            }
            return(list);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates the entity based on the state of the parent that it will be added to.
 /// </summary>
 /// <param name="parent"></param>
 public Entity(Entity parent)
 {
     this.parent = parent;
     if (parent == null)
     {
         parentTimer = new Stopwatch();
         evQueue     = new Queue <EntityEventInvokeQueueItem>();
         id          = 0;
     }
     else
     {
         Type myType         = GetType();
         var  parentChildren = parent.children;
         if (!parentChildren.ContainsKey(myType))
         {
             parentChildren.Add(myType, new List <Entity>());
         }
         List <Entity> children = parentChildren[myType];
         id = FindID(children);
         children.Add(this);
         evQueue     = parent.evQueue;
         parentTimer = parent.parentTimer;
         OnEvent    += parent.NotifyEvent;
     }
 }
Ejemplo n.º 5
0
 public bool ShotValid(IDNumber shooter, Shot shot)
 {
     return(shot != null &&
            shot.Coordinates < Match.CompiledConfig.FieldSize &&
            shot.Coordinates >= new Coordinates(0, 0) &&
            shooter != shot.Receiver &&
            !Match.Fields[shooter].Shots.Contains(shot) &&
            !Match.Teams[DeadTeam].Members.Contains(shot.Receiver));
 }
Ejemplo n.º 6
0
        public ClassicGame(IDNumber roundID, ActiveMatch match)
            : base(roundID, match)
        {
            FormTeams();
            turns             = RandomizeTurns();
            shipsPlaced       = false;
            CurrentTurnPlayer = NextTurn();

            AddEventAction(typeof(MatchAddPlayerEvent), PlayerInit);
        }
Ejemplo n.º 7
0
        public PersonalInfoPage UseParametersID()
        {
            SelectElement id = new SelectElement(IDType);

            id.SelectByValue(idValue);
            IDNumber.SendKeys(idnumber);
            SelectElement idstate = new SelectElement(IDState);

            idstate.SelectByValue(idStateValue);
            return(this);
        }
Ejemplo n.º 8
0
 public override string ToString()
 {
     if (Name != null)
     {
         return(Name);
     }
     else
     {
         return(IDNumber.ToString());
     }
 }
Ejemplo n.º 9
0
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (value != null)
     {
         PersonViewModel vm = (PersonViewModel)validationContext.ObjectInstance;
         if (!IDNumber.IsRecognised(vm.MilitaryIDNumber))
         {
             return(new ValidationResult(this.ErrorMessage));
         }
     }
     return(ValidationResult.Success);
 }
Ejemplo n.º 10
0
 public virtual void UnsetControllerFromTeam(IDNumber ctrl, IDNumber team)
 {
     if (!controllers.ContainsKey(ctrl))
     {
         throw new ArgumentException("Controller ID number " + ctrl + " does not exist in the current match.");
     }
     if (!Teams.ContainsKey(team))
     {
         throw new ArgumentException("Team ID number " + team + " does not exist in the current match.");
     }
     ApplyEvent(new PlayerTeamUnassignEvent(ctrl, team));
 }
 /// <summary>
 /// <see cref="IController.OpponentDestroyed()"/>
 /// </summary>
 public void OpponentDestroyed(IDNumber destroyedID)
 {
     try
     {
         aborter.MonBegin();
         controller.OpponentDestroyed(destroyedID);
         aborter.MonEnd();
     }
     catch (ThreadAbortException ex)
     {
         Thread.ResetAbort();
         throw new ControllerTimeoutException("OpponentDestroyed", this);
     }
 }
Ejemplo n.º 12
0
        private bool CheckIDLength()
        {
            var id       = IDNumber.ToString();
            var idLength = id.Length;

            if (idLength == 5)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 13
0
        public bool ShipsValid(IDNumber player)
        {
            bool result = Match.Fields[player].Ships != null &&
                          Match.Fields[player].Ships.EqualLengthsAs(Match.CompiledConfig.StartingShips) &&
                          Match.Fields[player].Ships.ShipsPlaced &&
                          Match.Fields[player].Ships.GetConflictingShips().Count == 0;

            foreach (var ship in Match.Fields[player].Ships)
            {
                ship.IsValid(Match.CompiledConfig.FieldSize);
            }

            return(result);
        }
Ejemplo n.º 14
0
        public IList <Person> GetPersonsWithUnmatchedMilitaryID()
        {
            IList <Person> persons       = this.personRepo.GetAll().Where(x => !x.Archive && !string.IsNullOrEmpty(x.MilitaryIDNumber)).ToList();
            IList <Person> unmatchedList = new List <Person>();

            foreach (Person p in persons)
            {
                if (!IDNumber.IsRecognised(p.MilitaryIDNumber))
                {
                    unmatchedList.Add(p);
                }
            }
            return(unmatchedList);
        }
Ejemplo n.º 15
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            using (var _context = new ApplicationDbContext())
            {
                try
                {
                    string idNo = Request.Form["idno"];

                    var      yearPart = Convert.ToInt32(idNo.Substring(0, 2));
                    var      Year     = yearPart <= 20 ? 2000 + yearPart : 1900 + yearPart;
                    var      Month    = Convert.ToInt32(idNo.Substring(2, 2));
                    var      Day      = Convert.ToInt32(idNo.Substring(4, 2));
                    IDNumber idNumber = new IDNumber();

                    idNumber.IDNo        = idNo;
                    idNumber.DateOfBirth = new DateTime(Year, Month, Day);
                    idNumber.Gender      = Convert.ToInt32(idNo.Substring(6, 1)) < 5 ? "F" : "M";
                    idNumber.SACitizen   = idNo.Substring(10, 1) == "0";

                    var prevIDNumber = _context.IDNumbers.Where(i => i.IDNo == idNumber.IDNo);

                    if (prevIDNumber.Count() == 0)
                    {
                        idNumber.Counter = 1;
                        _context.IDNumbers.Add(idNumber);
                        _context.SaveChanges();
                    }
                    else
                    {
                        var counter = _context.IDNumbers.Where(i => i.IDNo == idNumber.IDNo).FirstOrDefault().Counter;
                        idNumber.Counter = counter + 1;
                        SqlCommand cmd = new SqlCommand("UpdateCounter", conn);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@IDNumber", idNo);
                        cmd.Parameters.AddWithValue("@Counter", counter + 1);
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }

                    var holidayList = APICall(idNo, Year, Month, Day);
                    DisplayInfo(holidayList, idNumber);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 16
0
 private void PlayerLose(IDNumber plr)
 {
     Match.Teams[DeadTeam].Members.Add(plr);
     turns.Remove(plr);
     ApplyEvent(new PlayerLostEvent(plr));
     try
     {
         Match.Controllers[plr].RoundLost();
     }
     catch (ControllerTimeoutException ex)
     {
         ApplyEvent(new PlayerTimeoutEvent(plr, ex));
     }
     CurrentTurnPlayer = NextTurn();
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Inserts the ID number.
        /// </summary>
        /// <param name="_IDNumber">The _ ID number.</param>
        /// <returns></returns>
        public ONSResult InsertIDNumber(IDNumber _IDNumber)
        {
            ONSResult _ONSResultSave = new ONSResult();

            try
            {
                using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required, DBHelper.TransactionOptions))
                {
                    _ONSResultSave = ApplicationState.DAClient.InsertIDNumber(_IDNumber);
                    transaction.Complete();
                }
            }
            catch (Exception ex)
            {
                ErrorHandler _ErrorHandler = new ErrorHandler();
                _ErrorHandler.ONSERRORProcessing(ex);
            }
            return(_ONSResultSave);
        }
Ejemplo n.º 18
0
        public ONSResult InsertIDNumber(IDNumber parameter)
        {
            ONSResult _ONSResultInsert = new ONSResult();

            try
            {
                _dataContext.IDNumbers.InsertOnSubmit(parameter);
                _dataContext.SubmitChanges();

                _ONSResultInsert.ID        = parameter.SlNo.ToString();
                _ONSResultInsert.IsSuccess = true;
                _ONSResultInsert.Message   = "IDNumber inserted successfully.";
            }
            catch (Exception ex)
            {
                _ONSResultInsert.IsSuccess = false;
                _ONSResultInsert.Message   = ex.Message;
                _ErrorHandler.ONSERRORProcessing(ex);
            }
            return(_ONSResultInsert);
        }
Ejemplo n.º 19
0
 protected void DisplayInfo(List <Holiday> lstHoliday, IDNumber idNumber)
 {
     try
     {
         dvResults.Visible   = true;
         lblIDNumber.Text    = idNumber.IDNo;
         lblDateOfBirth.Text = idNumber.DateOfBirth.HasValue ? idNumber.DateOfBirth.Value.ToShortDateString() : string.Empty;
         lblGender.Text      = idNumber.Gender == "M" ? "Male" : "Female";
         lblSACitizen.Text   = idNumber.SACitizen ? "Yes" : "No";
         lblCounter.Text     = idNumber.Counter.ToString();
         gvIDInfo.DataSource = lstHoliday;
         gvIDInfo.DataBind();
     }
     catch (Exception ex)
     {
         dvResults.Visible = false;
         throw ex;
     }
     finally
     {
     }
 }
Ejemplo n.º 20
0
 void FSerch(int id)
 {
     try
     {
         MContext mc = new MContext();
         if (mc.SKUs.Any(x => x.ID == id))
         {
             SKU     s    = mc.SKUs.First(x => x.ID == id);
             InfoSKU asku = new InfoSKU(s);
             asku.ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Товар с таким ID не найден");
         }
     }
     catch
     {
         MessageBox.Show("Введен не корректный ID");
         IDNumber.Clear();
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// This method is called when an opponent controller has had all their ships destroyed, and is no longer
 /// active in the game.
 /// </summary>
 /// <param name="destroyedID"></param>
 public override void OpponentDestroyed(IDNumber destroyedID)
 {
     base.OpponentDestroyed(destroyedID);
 }
Ejemplo n.º 22
0
 public void Type_IDNumber()
 {
     IDNumber.SendKeys(Parameters.GetData <string>("idnumber"));
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Passes the <paramref name="round"/> to the base constructor
 /// </summary>
 /// <param name="round"></param>
 public RoundEndEvent(Match match, IDNumber roundNumber)
     : base(match)
 {
     Round = roundNumber;
 }
Ejemplo n.º 24
0
 public override int GetHashCode()
 {
     return(IDNumber.GetHashCode());
 }
Ejemplo n.º 25
0
 public bool Equals(IIntake other)
 {
     return(IDNumber.Equals(other.IDNumber) & well.Equals(other.well));
 }
 /// <summary>
 /// Stores the information provided by the <paramref name="exception"/> and bases the <see cref="Event.Message"/>
 /// from it.
 /// </summary>
 /// <param name="exception">The <see cref="ControllerTimeoutException"/> generated by a <see cref="Player"/>.</param>
 public PlayerTimeoutEvent(IDNumber playerID, ControllerTimeoutException exception)
     : base(playerID)
 {
     TimeTaken = 500;
     Method    = exception.MethodName;
 }
Ejemplo n.º 27
0
 private void PlayerTimedOut(IDNumber plr, ControllerTimeoutException ex)
 {
     ApplyEvent(new PlayerTimeoutEvent(plr, ex));
     PlayerLose(plr);
 }
Ejemplo n.º 28
0
        public ONSResult UpdateIDNumber(IDNumber parameter)
        {
            ONSResult _ONSResultInsert = new ONSResult();

            try
            {
                List <IDNumber> list  = new List <IDNumber>();
                var             query = from a in _dataContext.IDNumbers
                                        where a.SlNo == parameter.SlNo
                                        select a;
                list = query.ToList <IDNumber>();

                if (list.Count == 1)
                {
                    IDNumber obj = list[0];
                    if (parameter.SlNo != 0)
                    {
                        obj.SlNo = parameter.SlNo;
                    }
                    if (!String.IsNullOrEmpty(parameter.IDNo))
                    {
                        obj.IDNo = parameter.IDNo;
                    }
                    if (!String.IsNullOrEmpty(parameter.IDTypeId))
                    {
                        obj.IDTypeId = parameter.IDTypeId;
                    }
                    if (!String.IsNullOrEmpty(parameter.CompanyId))
                    {
                        obj.CompanyId = parameter.CompanyId;
                    }
                    if (!String.IsNullOrEmpty(parameter.LocationId))
                    {
                        obj.LocationId = parameter.LocationId;
                    }
                    if (!String.IsNullOrEmpty(parameter.EntryBy))
                    {
                        obj.EntryBy = parameter.EntryBy;
                    }
                    if (parameter.DateOfEntry.HasValue)
                    {
                        obj.DateOfEntry = parameter.DateOfEntry.Value;
                    }
                    if (parameter.IDYear.HasValue)
                    {
                        obj.IDYear = parameter.IDYear.Value;
                    }
                    _dataContext.SubmitChanges();
                }
                _ONSResultInsert.IsSuccess = true;
                _ONSResultInsert.Message   = "IDNumber updated successfully.";
            }
            catch (Exception ex)
            {
                _ONSResultInsert.IsSuccess = false;
                _ONSResultInsert.Message   = ex.Message;
                _ErrorHandler.ONSERRORProcessing(ex);
            }

            return(_ONSResultInsert);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Compares using the ID-number
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public int CompareTo(IIntake other)
 {
     return(IDNumber.CompareTo(other.IDNumber));
 }
Ejemplo n.º 30
0
 private void PlayerDead(IDNumber plr)
 {
     //Match.Teams[DeadTeam].Members.Add(plr);
     PlayerLose(plr);
 }