コード例 #1
0
ファイル: VotingDialog.cs プロジェクト: dbrgn/pi-vote
        public void Display(CircleController controller, VoterCertificate voterCertificate, VotingDescriptor2 voting)
        {
            this.controller = controller;
              this.voterCertificate = voterCertificate;
              this.voting = voting;

              this.votingControl.Display(voting);

              if (this.voterCertificate == null)
              {
            this.voteButton.Text = Resources.VotingDialogConfirm;
              }
              else
              {
            this.voteButton.Text = Resources.VotingDialogVote;
              }

              this.cancelButton.Enabled = true;
              this.nextButton.Enabled = this.votingControl.CanNext;
              this.previousButton.Enabled = this.votingControl.CanPrevious;
              this.voteButton.Enabled = this.voterCertificate == null || this.votingControl.Valid;
        }
コード例 #2
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public void Download(VotingDescriptor2 voting)
        {
            Begin();
              Status.VotingClient.ActivateVoter();
              Status.VotingClient.DownloadVoting(voting.Id, Status.DataPath, DownloadVotingComplete);

              if (!WaitForCompletion())
              {
            throw this.exception;
              }
        }
コード例 #3
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public void Delete(VotingDescriptor2 voting, AdminCertificate adminCertificate)
        {
            var command = new DeleteVotingRequest.Command(voting.Id);
              var signedCommand = new Signed<DeleteVotingRequest.Command>(command, adminCertificate);

              Begin();
              Status.VotingClient.DeleteVoting(signedCommand, DeleteVotingComplete);

              if (!WaitForCompletion())
              {
            throw this.exception;
              }
        }
コード例 #4
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public VotingDescriptor Decipher(Certificate certificate, VotingDescriptor2 voting)
        {
            string fileName = string.Format("{0}@{1}.pi-auth", certificate.Id.ToString(), voting.Id.ToString());
              string filePath = Path.Combine(Status.DataPath, fileName);

              if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(certificate, GuiResources.UnlockActionAuthorityDecipher))
              {
            try
            {
              this.userCanceled = false;
              Begin();
              Status.VotingClient.CreateDeciphers(voting.Id, (AuthorityCertificate)certificate, filePath, AskForPartiallyDecipher, CreateDeciphersComplete);

              if (!WaitForCompletion() && !this.userCanceled)
              {
            throw this.exception;
              }
            }
            finally
            {
              certificate.Lock();
            }

            return this.votingDescriptor;
              }
              else
              {
            return voting;
              }
        }
コード例 #5
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public VotingResult Tally(VotingDescriptor2 voting, out IDictionary<Guid, VoteReceiptStatus> voteReceiptsStatus)
        {
            Begin();
              Status.VotingClient.ActivateVoter();
              Status.VotingClient.GetResult(voting.Id, LoadVoteReceipts(voting.Id), Config.InitialCheckProofCount, GetResultComplete);

              if (!WaitForCompletion())
              {
            throw this.exception;
              }

              voteReceiptsStatus = this.voteReceiptsStatus;
              return this.votingResult;
        }
コード例 #6
0
ファイル: VotingListControl.cs プロジェクト: dbrgn/pi-vote
 private void Control_VotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     OnVotingAction(type, voting);
 }
コード例 #7
0
ファイル: Master.cs プロジェクト: dbrgn/pi-vote
        private void GoVote(VotingDescriptor2 voting)
        {
            var certificate = Controller.GetVoterCertificateThatCanVote(voting);

              if (certificate != null)
              {
            Vote.VotingDialog.ShowVoting(Controller, certificate, voting);

            RefreshVotings();
              }
        }
コード例 #8
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
 public IEnumerable<VoterCertificate> GetVoterCertificates(VotingDescriptor2 voting)
 {
     return this.certificates.Keys
     .Where(certificate => certificate is VoterCertificate &&
       ((VoterCertificate)certificate).GroupId == voting.GroupId)
       .Select(certificate => certificate as VoterCertificate);
 }
コード例 #9
0
ファイル: Master.cs プロジェクト: dbrgn/pi-vote
        private void GoShare(VotingDescriptor2 voting)
        {
            var certificate = Controller.GetAuthorityCertificate(voting);

              if (certificate != null)
              {
            Status.TextStatusDialog.ShowInfo(Controller, this);

            try
            {
              Controller.CreateShares(certificate, voting);
              var votings = Controller.GetVotingList();
              this.votingListsControl.Set(Controller, votings);
            }
            catch (Exception exception)
            {
              Error.ErrorDialog.ShowError(exception);
            }

            Status.TextStatusDialog.HideInfo();
              }
        }
コード例 #10
0
ファイル: Master.cs プロジェクト: dbrgn/pi-vote
        private void GoTally(VotingDescriptor2 voting)
        {
            Status.TextStatusDialog.ShowInfo(Controller, this);

              try
              {
            IDictionary<Guid, VoteReceiptStatus> voteReceiptStatus;
            var votingResult = Controller.Tally(voting, out voteReceiptStatus);
            Result.ResultDisplayDialog.ShowResult(votingResult, voteReceiptStatus);
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
              }

              Status.TextStatusDialog.HideInfo();
        }
コード例 #11
0
ファイル: Master.cs プロジェクト: dbrgn/pi-vote
        private void GoDownload(VotingDescriptor2 voting)
        {
            Status.TextStatusDialog.ShowInfo(Controller, this);

              try
              {
            Controller.Download(voting);

            var votings = Controller.GetVotingList();
            this.votingListsControl.Set(Controller, votings);
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
              }

              Status.TextStatusDialog.HideInfo();
        }
コード例 #12
0
ファイル: Master.cs プロジェクト: dbrgn/pi-vote
        private void GoDeleteStored(VotingDescriptor2 voting)
        {
            try
              {
            if (!voting.OfflinePath.IsNullOrEmpty() &&
            Directory.Exists(voting.OfflinePath))
            {
              Directory.Delete(voting.OfflinePath, true);

              RefreshVotings();
            }
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
              }
        }
コード例 #13
0
ファイル: Master.cs プロジェクト: dbrgn/pi-vote
        private void GoDelete(VotingDescriptor2 voting)
        {
            Status.TextStatusDialog.ShowInfo(Controller, this);

              var adminCertificate = Controller.GetAdminCertificate();

              if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(adminCertificate, GuiResources.UnlockActionDelete))
              {
            try
            {
              if (adminCertificate != null)
              {
            Controller.Delete(voting, adminCertificate);

            var votings = Controller.GetVotingList();
            this.votingListsControl.Set(Controller, votings);
              }
            }
            catch (Exception exception)
            {
              Error.ErrorDialog.ShowError(exception);
            }
            finally
            {
              adminCertificate.Lock();
              Status.TextStatusDialog.HideInfo();
            }
              }
        }
コード例 #14
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public AuthorityCertificate GetAuthorityCertificate(VotingDescriptor2 voting)
        {
            var certificates = GetAuthorityCertificates(voting.VoteFrom);

              return certificates.Where(certificate => voting.Authorities.Any(authority => authority.IsIdentic(certificate)) &&
                          !voting.AuthoritiesDone.Contains(certificate.Id))
                          .FirstOrDefault();
        }
コード例 #15
0
ファイル: Master.cs プロジェクト: dbrgn/pi-vote
 private void VotingListsControl_VotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     switch (type)
       {
     case VotingActionType.Type1:
       switch (voting.Status)
       {
     case VotingStatus.New:
       GoShare(voting);
       break;
     case VotingStatus.Sharing:
       GoCheck(voting);
       break;
     case VotingStatus.Voting:
       GoVote(voting);
       break;
     case VotingStatus.Deciphering:
       GoDecipher(voting);
       break;
     case VotingStatus.Finished:
     case VotingStatus.Offline:
       GoTally(voting);
       break;
       }
       break;
     case VotingActionType.Type2:
       switch (voting.Status)
       {
     case VotingStatus.New:
     case VotingStatus.Sharing:
     case VotingStatus.Ready:
       GoDelete(voting);
       break;
     case VotingStatus.Offline:
       GoDeleteStored(voting);
       break;
     case VotingStatus.Finished:
       GoDownload(voting);
       break;
       }
       break;
       }
 }
コード例 #16
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
 public VoterCertificate GetVoterCertificate(VotingDescriptor2 voting)
 {
     return this.certificates.Keys
     .Where(certificate => certificate is VoterCertificate &&
       ((VoterCertificate)certificate).GroupId == voting.GroupId)
       .FirstOrDefault() as VoterCertificate;
 }
コード例 #17
0
ファイル: VotingListsControl.cs プロジェクト: dbrgn/pi-vote
 private void ScheduledVotingListControl_VotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     OnVotingAction(type, voting);
 }
コード例 #18
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public VoterCertificate GetVoterCertificateThatCanVote(VotingDescriptor2 voting)
        {
            var receipts = LoadVoteReceipts(voting.Id);

              return this.certificates.Keys
            .Where(certificate => certificate is VoterCertificate &&
              certificate.Validate(Status.CertificateStorage) == CertificateValidationResult.Valid &&
              ((VoterCertificate)certificate).GroupId == voting.GroupId &&
              !receipts.Any(receipt => receipt.Value.VoterId.Equals(certificate.Id)))
              .FirstOrDefault() as VoterCertificate;
        }
コード例 #19
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public VotingDescriptor CheckShares(Certificate certificate, VotingDescriptor2 voting)
        {
            string fileName = string.Format("{0}@{1}.pi-auth", certificate.Id.ToString(), voting.Id.ToString());
              string filePath = Path.Combine(Status.DataPath, fileName);

              if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(certificate, GuiResources.UnlockActionAuthorityCheckShares))
              {
            try
            {
              Begin();
              Status.VotingClient.CheckShares(voting.Id, (AuthorityCertificate)certificate, filePath, CheckSharesComplete);

              if (WaitForCompletion())
              {
            if (this.acceptShares)
            {
              MessageForm.Show(Resources.ControllerCheckSharesOk, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
              MessageForm.Show(Resources.ControllerCheckSharesFailed, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
              }
              else
              {
            throw this.exception;
              }
            }
            finally
            {
              certificate.Lock();
            }

            return this.votingDescriptor;
              }
              else
              {
            return voting;
              }
        }
コード例 #20
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public void Vote(VoterCertificate voterCertificate, VotingDescriptor2 voting, IEnumerable<IEnumerable<bool>> vota)
        {
            Begin();
              Status.VotingClient.ActivateVoter();
              Status.VotingClient.Vote(this.votings[voting.Id].Material, voterCertificate, vota, VoteComplete);

              if (WaitForCompletion())
              {
            this.voteReceipt.Save(
              Path.Combine(Status.DataPath,
              Files.VoteReceiptFileName(voterCertificate.Id, voting.Id)));
            MessageForm.Show(Resources.ControllerVoteCast, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
              }
              else
              {
            throw this.exception;
              }
        }
コード例 #21
0
ファイル: CircleController.cs プロジェクト: dbrgn/pi-vote
        public VotingDescriptor CreateShares(Certificate certificate, VotingDescriptor2 voting)
        {
            string fileName = string.Format("{0}@{1}.pi-auth", certificate.Id.ToString(), voting.Id.ToString());
              string filePath = Path.Combine(Status.DataPath, fileName);

              if (Circle.Vote.VotingDialog.ShowVoting(this, null, voting) == DialogResult.OK)
              {
            if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(certificate, GuiResources.UnlockActionAuthorityCreateShares))
            {
              try
              {
            Begin();
            Status.VotingClient.CreateSharePart(voting.Id, (AuthorityCertificate)certificate, filePath, CreateSharesCompleteCallBack);

            if (!WaitForCompletion())
            {
              throw this.exception;
            }
              }
              finally
              {
            certificate.Lock();
              }

              return this.votingDescriptor;
            }
              }

              return voting;
        }
コード例 #22
0
ファイル: VotingListControl.cs プロジェクト: dbrgn/pi-vote
 private void OnVotingAction(VotingActionType type, VotingDescriptor2 voting)
 {
     if (VotingAction != null)
       {
     VotingAction(type, voting);
       }
 }
コード例 #23
0
ファイル: VotingDialog.cs プロジェクト: dbrgn/pi-vote
 public static DialogResult ShowVoting(CircleController controller, VoterCertificate voterCertificate, VotingDescriptor2 voting)
 {
     VotingDialog dialog = new VotingDialog();
       dialog.Display(controller, voterCertificate, voting);
       return dialog.ShowDialog();
 }