Esempio n. 1
0
        /// <summary>
        /// Checks the sign in, sign out times and compare them to shift start/end time.
        /// </summary>
        private void CheckTimeAndCalcHours()
        {
            if (Meeting != null || (Meeting == null && StartShift.ShiftName == "Normal sign in") || (Meeting == null && IsSpecialTask == true))
            {
                // Activity is a meeting, shiftless or a special task
            }
            else
            {
                if (InTime.DayOfYear < DateTime.Now.DayOfYear)
                {
                    // User signs out late on another day
                    this.RequireNotification = true;
                    this.NotificationReason  = NotifyReason.LateSignOut;
                }
                else if (ActualOutTime.TimeOfDay < StartShift.StartTime)
                {
                    // User signs out before shift start
                    this.OutTime = DateTime.Today + StartShift.StartTime;
                }
                else if (ActualOutTime.TimeOfDay < EndShift.EndTime)
                {
                    // User signs out early
                    this.RequireNotification = true;
                    this.NotificationReason  = NotifyReason.EarlySignOut;
                    this.OutTime             = ActualOutTime;
                }

                // Calculate break if total work hours exceed set settings
                // Gets the settings for BreakDuration and NeedBreakDuration
                Client.Instance.GlobalSettings.Settings.TryGetValue("BreakDuration", out string _breakDuration);
                Client.Instance.GlobalSettings.Settings.TryGetValue("NeedBreakDuration", out string _needBreakDuration);

                int      breakDuration     = 30;
                int      needBreakDuration = 6;
                TimeSpan _approvedHours    = InTime - OutTime;

                if (_breakDuration != null && _needBreakDuration != null)
                {
                    int.TryParse(_breakDuration, out breakDuration);
                    int.TryParse(_needBreakDuration, out needBreakDuration);
                }

                // Checks if the total minutes worked is over the needBreakDuration. If it exceeds,
                // calculates the deduction needed and calculates the final hours approved.
                if (_approvedHours.TotalHours >= needBreakDuration)
                {
                    int removeTimes = (int)(_approvedHours.TotalHours / needBreakDuration);

                    for (int i = 0; i <= removeTimes; i++)
                    {
                        _approvedHours.Subtract(new TimeSpan(0, breakDuration, 0));
                    }
                }

                ApprovedHours = _approvedHours.TotalHours;
            }
        }
Esempio n. 2
0
 static object ReasonToSymbol(NotifyReason reason)
 {
     switch (reason)
       {
     case NotifyReason.ProcedureEnter: return SymbolTable.StringToObject("proc-enter");
     case NotifyReason.ProcedureExit: return SymbolTable.StringToObject("proc-exit");
     case NotifyReason.ExpressionIn: return SymbolTable.StringToObject("expr-in");
     case NotifyReason.ExpressionOut: return SymbolTable.StringToObject("expr-out");
     case NotifyReason.ExpressionInTail: return SymbolTable.StringToObject("expr-in-tail");
     default:
       throw new ArgumentException("Invalid reason");
       }
 }
Esempio n. 3
0
        static object ReasonToSymbol(NotifyReason reason)
        {
            switch (reason)
            {
            case NotifyReason.ProcedureEnter: return(SymbolTable.StringToObject("proc-enter"));

            case NotifyReason.ProcedureExit: return(SymbolTable.StringToObject("proc-exit"));

            case NotifyReason.ExpressionIn: return(SymbolTable.StringToObject("expr-in"));

            case NotifyReason.ExpressionOut: return(SymbolTable.StringToObject("expr-out"));

            case NotifyReason.ExpressionInTail: return(SymbolTable.StringToObject("expr-in-tail"));

            default:
                throw new ArgumentException("Invalid reason");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Prepares the new meeting activity using data already on Client and passed parameters
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="locationId"></param>
        /// <param name="meeting"></param>
        public void PrepareNewActivity(Meeting meeting)
        {
            UserID        = Client.Instance.UserState.User.UserID;
            LocationID    = Client.Instance.LocationId;
            HasLoggedIn   = true;
            PartOfRoster  = false;
            IsSpecialTask = false;
            Meeting       = meeting;

            if (meeting.StartTime >= DateTime.Now.TimeOfDay)
            {
                RequireNotification = false;
                string d = DateTime.Today.ToShortDateString() + " " + meeting.StartTime.ToString();
                DateTime.TryParse(d, out DateTime _inTime);
                InTime = _inTime;
            }
            else
            {
                RequireNotification = true;
                NotificationReason  = NotifyReason.LateSignIn;
                InTime = DateTime.Now;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Prepares the new work activity using data already on Client and passed parameters
        /// </summary>
        /// <param name="startShift"></param>
        /// <param name="endShift"></param>
        /// <param name="specialTask"></param>
        /// <param name="partOfRoster"></param>
        public void PrepareNewActivity(Shift startShift, Shift endShift, bool specialTask, bool partOfRoster)
        {
            UserID        = Client.Instance.UserState.User.UserID;
            LocationID    = Client.Instance.LocationId;
            StartShift    = startShift;
            EndShift      = endShift;
            HasLoggedIn   = true;
            PartOfRoster  = partOfRoster;
            IsSpecialTask = specialTask;

            if (startShift.StartTime >= DateTime.Now.TimeOfDay)
            {
                RequireNotification = false;
                string d = DateTime.Today.ToShortDateString() + " " + startShift.StartTime.ToString();
                DateTime.TryParse(d, out DateTime inTime);
                InTime = inTime;
            }
            else
            {
                RequireNotification = true;
                NotificationReason  = NotifyReason.LateSignIn;
                InTime = DateTime.Now;
            }
        }
Esempio n. 6
0
 public void Notify(NotifyReason reason, string filename, SourceSpan span)
 {
     callback.Call(ReasonToSymbol(reason), filename ?? Builtins.FALSE, span.Start.Line, span.Start.Column, span.End.Line, span.End.Column);
 }
 public Countdown(int hours, int minutes, int seconds, NotifyReason reason)
 {
     countDown = new TimeSpan(hours, minutes, seconds);
     reasonOfCountdown = reason;
 }
Esempio n. 8
0
 public void Notify(NotifyReason reason, string filename, SourceSpan span)
 {
     callback.Call(ReasonToSymbol(reason), filename ?? Builtins.FALSE, span.Start.Line, span.Start.Column, span.End.Line, span.End.Column);
 }
Esempio n. 9
0
 public AddressNotification(Address address, TissueType tissueType, NotifyReason reason)
 {
     Address    = address;
     TissueType = tissueType;
     Reason     = reason;
 }
Esempio n. 10
0
        private void Game_OnNotify(NotifyReason reason, CellState[] cells)
        {
            switch (reason)
            {
            // game setup
            case NotifyReason.PiecePlaced:
                if (cells == null || cells.Length != 1)
                {
                    throw new Exception("Invalid cells sent to notify");
                }
                AddOverlay(string.Format("Placed a {0}", cells[0].Piece.ToString().Replace("_", "")));
                break;

            case NotifyReason.InvalidCellSelected:
                AddOverlay("Cannot place a piece on this cell, try again");
                break;

            // choose an opponent's piece to win the battle
            case NotifyReason.PickOpponent:
                OHighlightAwayPieces = true;
                AddOverlay("Choose an opponent's piece. If you guess correctly you win the battle.");
                break;

            // battle
            case NotifyReason.BattleLost:
            case NotifyReason.BattleWon:
            case NotifyReason.BattleTied:
                if (cells == null || cells.Length != 2)
                {
                    throw new Exception("Invalid cells sent to notify");
                }

                // track human or opponenet move
                if (cells[0].Player == Player.Red)
                {
                    OPlayerMoveFrom = cells[0];
                }
                else
                {
                    OOpponentMoveFrom = cells[0];
                }

                // clear the battles if human
                if (cells[0].Player == Player.Red)
                {
                    OBattles.Clear();
                }

                // indicate that a cell should be marked for a battle
                OBattles.Add(new Tuple <bool, CellState>(reason == NotifyReason.BattleWon, cells[1]));

                // turn off highlighting if needed to guess
                OHighlightAwayPieces = false;

                // update the UI
                ForceVisible.Add(cells[1]);
                GetCellAndUpdate(cells[1].Row, cells[1].Col);

                // update, but do not change the current text
                AddOverlay(OPreviousText);
                break;

            // piece moved
            case NotifyReason.PieceMove:
                if (cells == null || cells.Length != 2)
                {
                    throw new Exception("Invalid cells sent to notify");
                }
                // track human or opponenet move
                if (cells[0].Player == Player.Red)
                {
                    OPlayerMoveFrom = cells[0];
                }
                else
                {
                    OOpponentMoveFrom = cells[0];
                }

                // clear the battles if human
                if (cells[0].Player == Player.Red)
                {
                    // clear
                    OBattles.Clear();

                    // update the force visible cells
                    var update = ForceVisible.ToArray();
                    ForceVisible.Clear();
                    foreach (var cell in update)
                    {
                        GetCellAndUpdate(cell.Row, cell.Col);
                    }
                }
                else
                {
                    // check if one of the force visible cells has moved
                    CellState update = default(CellState);
                    foreach (var cell in ForceVisible)
                    {
                        if (cell.Row == cells[0].Row && cell.Col == cells[0].Col)
                        {
                            update = cell;
                        }
                    }
                    if (!update.Equals(default(CellState)))
                    {
                        // found it, so delete and move it
                        ForceVisible.Remove(update);
                        ForceVisible.Add(cells[1]);
                    }
                }

                // update, but do not change the current text
                AddOverlay(OPreviousText);
                break;

            // indicate that it is time to pick a piece to play
            case NotifyReason.YourTurn:
                // todo
                AddOverlay("It is your turn");
                break;

            case NotifyReason.InvalidMove:
                AddOverlay("That move is invalid. Choose another piece.");
                break;

            // check for the win
            case NotifyReason.StaleMate:
                AddOverlay("Stale mate. No winner.");
                break;

            case NotifyReason.PlayerWins:
                AddOverlay("You win!");
                break;

            case NotifyReason.OpponentWins:
                AddOverlay("Opponent wins.");
                break;

            case NotifyReason.GameOver:
                AddOverlay(OPreviousText);
                break;

            // nothing
            case NotifyReason.AllPiecesAreInPlay:
            case NotifyReason.CorrectlyGuessedPiece:
            case NotifyReason.IncorrectlyGuessedPiece:
            case NotifyReason.ChooseOpponent:
            case NotifyReason.PlayerPiecesSet:
            case NotifyReason.TheirTurn:
                break;

            default:
                throw new Exception("Inavlid Notify reason : " + reason);
            }
        }
Esempio n. 11
0
		public AddressNotification(Address address, TissueType tissueType, NotifyReason reason)
		{
			Address = address;
			TissueType = tissueType;
			Reason = reason;
		}