示例#1
0
            /// <summary>
            /// Execute the operation.
            /// </summary>
            /// <param name="client">Voting client to execute against.</param>
            public override void Execute(VotingClient client)
            {
                try
                {
                  Text = LibraryResources.ClientCreateSharePartPrepareAuthority;
                  Progress = 0d;
                  SubText = string.Empty;
                  SubProgress = 0d;

                  var parameters = client.proxy.FetchParameters(this.votingId, this.authorityCertificate);

                  client.CreateAuthority(this.authorityCertificate);
                  client.authorityEntity.Prepare(parameters.Key, parameters.Value);

                  Text = LibraryResources.ClientCreateSharePartFetchAuthorityList;
                  Progress = 0.15d;

                  var authorityList = client.proxy.FetchAuthorityList(this.votingId);

                  client.authorityEntity.SetAuthorities(authorityList);

                  Text = LibraryResources.ClientCreateSharePartSaveAuthority;
                  Progress = 0.3d;

                  client.SaveAuthority(this.authorityFileName);

                  Text = LibraryResources.ClientCreateSharePartCreateShareParts;
                  Progress = 0.55d;

                  var sharePart = client.authorityEntity.GetShares();

                  Text = LibraryResources.ClientCreateSharePartPushShareParts;
                  Progress = 0.75d;

                  client.proxy.PushShares(this.votingId, sharePart);

                  Text = LibraryResources.ClientCreateSharePartGetVotingStatus;
                  Progress = 0.9d;

                  var material = client.proxy.FetchVotingMaterial(this.votingId);
                  List<Guid> authoritieDone;
                  VotingStatus status = client.proxy.FetchVotingStatus(this.votingId, out authoritieDone);
                  var votingDescriptor = new VotingDescriptor(material.Parameters.Value, status, authoritieDone, material.CastEnvelopeCount);

                  Progress = 1d;

                  this.callBack(votingDescriptor, null);
                }
                catch (Exception exception)
                {
                  this.callBack(null, exception);
                }
            }
示例#2
0
            /// <summary>
            /// Execute the operation.
            /// </summary>
            /// <param name="client">Voting client to execute against.</param>
            public override void Execute(VotingClient client)
            {
                try
                {
                  Text = LibraryResources.ClientCheckSharesLoadAuthority;
                  Progress = 0d;
                  SubText = string.Empty;
                  SubProgress = 0d;

                  client.LoadAuthority(this.authorityFileName, this.authorityCertificate);

                  Text = LibraryResources.ClientCheckSharesFetchShares;
                  Progress = 0.2d;

                  var allShareParts = client.proxy.FetchAllShares(this.votingId);

                  Text = LibraryResources.ClientCheckSharesVerifyShares;
                  Progress = 0.4d;

                  var signedShareResponse = client.authorityEntity.VerifyShares(allShareParts);

                  Text = LibraryResources.ClientCheckSharesSaveAuthority;
                  Progress = 0.5d;

                  Signed<BadShareProof> signedBadShareProof = client.authorityEntity.CreateBadShareProof(allShareParts);
                  signedBadShareProof.Save(Path.Combine(Path.GetDirectoryName(this.authorityFileName), signedBadShareProof.Value.FileName(signedBadShareProof.Certificate.Id)));

                  client.SaveAuthority(this.authorityFileName);

                  Text = LibraryResources.ClientCheckSharesPushShareResponse;
                  Progress = 0.6d;

                  client.proxy.PushShareResponse(this.votingId, signedShareResponse);

                  Text = LibraryResources.ClientCheckSharesGetVotingStatus;
                  Progress = 0.8d;

                  var material = client.proxy.FetchVotingMaterial(this.votingId);
                  List<Guid> authoritiesDone;
                  VotingStatus status = client.proxy.FetchVotingStatus(this.votingId, out authoritiesDone);
                  var votingDescriptor = new VotingDescriptor(material.Parameters.Value, status, authoritiesDone, material.CastEnvelopeCount);

                  Progress = 1d;

                  this.callBack(votingDescriptor, signedShareResponse.Value.AcceptShares, signedBadShareProof, null);
                }
                catch (Exception exception)
                {
                  this.callBack(null, false, null, exception);
                }
            }