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; }
public void Download(VotingDescriptor2 voting) { Begin(); Status.VotingClient.ActivateVoter(); Status.VotingClient.DownloadVoting(voting.Id, Status.DataPath, DownloadVotingComplete); if (!WaitForCompletion()) { throw this.exception; } }
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; } }
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; } }
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; }
private void Control_VotingAction(VotingActionType type, VotingDescriptor2 voting) { OnVotingAction(type, voting); }
private void GoVote(VotingDescriptor2 voting) { var certificate = Controller.GetVoterCertificateThatCanVote(voting); if (certificate != null) { Vote.VotingDialog.ShowVoting(Controller, certificate, voting); RefreshVotings(); } }
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); }
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(); } }
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(); }
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(); }
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); } }
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(); } } }
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(); }
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; } }
public VoterCertificate GetVoterCertificate(VotingDescriptor2 voting) { return this.certificates.Keys .Where(certificate => certificate is VoterCertificate && ((VoterCertificate)certificate).GroupId == voting.GroupId) .FirstOrDefault() as VoterCertificate; }
private void ScheduledVotingListControl_VotingAction(VotingActionType type, VotingDescriptor2 voting) { OnVotingAction(type, voting); }
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; }
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; } }
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; } }
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; }
private void OnVotingAction(VotingActionType type, VotingDescriptor2 voting) { if (VotingAction != null) { VotingAction(type, voting); } }
public static DialogResult ShowVoting(CircleController controller, VoterCertificate voterCertificate, VotingDescriptor2 voting) { VotingDialog dialog = new VotingDialog(); dialog.Display(controller, voterCertificate, voting); return dialog.ShowDialog(); }