Пример #1
0
        private void MoveSeries()
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Moving Series");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                MoveSeries             move     = new MoveSeries();
                DicomCommandStatusType status   = DicomCommandStatusType.Success;
                ProgressDialog         progress = new ProgressDialog();

                move.PatientId = textBoxId.Text.Replace(@"\", @"\\").Replace("'", @"''");
                move.PatientToMerge.Add(new MergePatientSequence(_Patient.Id));
                move.SeriesInstanceUID = _Series.InstanceUID;
                move.Reason            = dlgReason.Reason;
                move.Operator          = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                move.Description       = "Move Series";

                Thread thread = new Thread(() =>
                {
                    try
                    {
                        status = _naction.SendNActionRequest <MoveSeries>(_scp, move, NActionScu.MoveSeries,
                                                                          NActionScu.PatientUpdateInstance);
                    }
                    catch (Exception e)
                    {
                        ApplicationUtils.ShowException(this, e);
                        status = DicomCommandStatusType.Failure;
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Moving Series";
                progress.ProgressInfo = "Performing series move to patient: " + textBoxFirstname.Text + " " + textBoxLastname.Text + ".";
                progress.ShowDialog(this);

                if (status == DicomCommandStatusType.Success)
                {
                    _Action = ActionType.Merge;
                    TaskDialogHelper.ShowMessageBox(this, "Move Series", "The series has been successfully move.", GetMergeInfo(),
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string message = "The series was not move.\r\nError - " + _naction.GetErrorMessage();

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The series was not move.\r\nSeries not found on server.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Move Series Error", "The series was not moved.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Choosed the winner based on the power matrix. 
        /// In the case of a draw. An empty Guid is returned.
        /// </summary>
        /// <param name="user1Moves"></param>
        /// <param name="user2Moves"></param>
        /// <returns></returns>
        public Guid? ProcessWinner(MoveSeries user1Moves, MoveSeries user2Moves)
        {
            int matrixScore = user1Moves.Moves.Cast<int>()
                .Zip(user2Moves.Moves.Cast<int>(), Tuple.Create)
                .Sum(x => _powerMatrix[x.Item1, x.Item2]);

            if (matrixScore > 0) return user1Moves.PlayerId;
            if (matrixScore < 0) return user2Moves.PlayerId;
            return null;
        }
        public void ProcessWinner_Player2Wins()
        {
            //Arrange
            var moves1 = new MoveSeries(new List<MoveType> { MoveType.Kick, MoveType.Punch, MoveType.Block }, _player1);
            var moves2 = new MoveSeries(new List<MoveType> { MoveType.Punch, MoveType.Block, MoveType.Block }, _player2);

            //Act
            Guid? winner = _target.ProcessWinner(moves1, moves2);

            //Assert
            Assert.AreEqual(_player2, winner);
        }
        public void ProcessWinner_EqualMoveSeries_ReturnNullIndicatingDraw()
        {
            //Arrange
            var moves1 = new MoveSeries(new List<MoveType>{ MoveType.Kick, MoveType.Punch, MoveType.Block }, _player1);
            var moves2 = new MoveSeries(new List<MoveType>{ MoveType.Kick, MoveType.Punch, MoveType.Block }, _player2);

            //Act
            Guid? winner =_target.ProcessWinner(moves1, moves2);

            //Assert
            Assert.IsNull(winner);
        }
Пример #5
0
 public Player2MovesPlayed(Guid roundId, MoveSeries moves, Guid playerId)
 {
     RoundId = roundId;
     Moves = moves;
     PlayerId = playerId;
 }