public VotingContainer(VotingMaterial material, List<Certificate> authorities, List<Guid> authoritiesDone, VotingStatus status, int envelopeCount) { Material = material; Authorities = authorities; AuthoritiesDone = authoritiesDone; Status = status; EnvelopeCount = envelopeCount; }
/// <summary> /// Creates a new voting descriptor from offline files. /// </summary> /// <param name="offlinePath">Path to the offline files.</param> public VotingDescriptor(string offlinePath) { string materialFileName = Path.Combine(offlinePath, Files.VotingMaterialFileName); if (!File.Exists(materialFileName)) throw new ArgumentException("Offline voting material file not found."); DirectoryInfo offlineDirectory = new DirectoryInfo(offlinePath); VotingMaterial material = Serializable.Load<VotingMaterial>(materialFileName); VotingParameters parameters = material.Parameters.Value; this.offlinePath = offlinePath; this.id = parameters.VotingId; this.title = parameters.Title; this.descripton = parameters.Description; this.url = parameters.Url; this.status = VotingStatus.Offline; this.authoritiesDone = null; this.voteFrom = parameters.VotingBeginDate; this.voteUntil = parameters.VotingEndDate; this.authorityCount = parameters.AuthorityCount; this.envelopeCount = offlineDirectory.GetFiles(Files.EnvelopeFilePattern).Count(); this.questions = new List<QuestionDescriptor>(); this.questions.AddRange(parameters.Questions.Select(question => new QuestionDescriptor(question))); this.groupId = parameters.GroupId; this.authoritiesDone = new List<Guid>(); for (int authorityIndex = 1; authorityIndex < parameters.AuthorityCount + 1; authorityIndex++) { string partialDecipherFileName = Path.Combine(offlinePath, string.Format(Files.PartialDecipherFileString, authorityIndex)); if (File.Exists(partialDecipherFileName)) { var partialDecipher = Serializable.Load<Signed<PartialDecipherList>>(partialDecipherFileName); this.authoritiesDone.Add(partialDecipher.Certificate.Id); } } }
/// <summary> /// Create a new voting descriptor. /// </summary> /// <param name="parameters">Parameters of voting to describe.</param> /// <param name="status">Status of the voting.</param> /// <param name="authoritiesDone">List of authorities that have completed the current step if applicable.</param> public VotingDescriptor(VotingParameters parameters, VotingStatus status, List<Guid> authoritiesDone, int envelopeCount) { this.id = parameters.VotingId; this.title = parameters.Title; this.descripton = parameters.Description; this.url = parameters.Url; this.status = status; this.authoritiesDone = authoritiesDone; this.voteFrom = parameters.VotingBeginDate; this.voteUntil = parameters.VotingEndDate; this.authorityCount = status == VotingStatus.Deciphering ? parameters.Thereshold + 1 : parameters.AuthorityCount; this.envelopeCount = envelopeCount; this.questions = new List<QuestionDescriptor>(); this.questions.AddRange(parameters.Questions.Select(question => new QuestionDescriptor(question))); this.groupId = parameters.GroupId; }
/// <summary> /// Create a new voting procedure. /// </summary> /// <param name="logger">Logs messages to file.</param> /// <param name="DataAccess.DbConnection">Connection to the database.</param> /// <param name="parameters">Voting parameters.</param> /// <param name="rootCertificate">Certificate storage.</param> /// <param name="status">Voting status.</param> public VotingServerEntity( VotingRpcServer server, Signed<VotingParameters> signedParameters, ICertificateStorage certificateStorage, ServerCertificate serverCertificate, VotingStatus status) { if (server == null) throw new ArgumentNullException("server"); if (signedParameters == null) throw new ArgumentNullException("signedParameters"); if (serverCertificate == null) throw new ArgumentNullException("serverCertificate"); Server = server; this.lastProcessTime = DateTime.Now; this.certificateStorage = certificateStorage; this.serverCertificate = serverCertificate; this.signedParameters = signedParameters; this.parameters = this.signedParameters.Value; this.status = status; }
/// <summary> /// Deserializes binary data to object. /// </summary> /// <param name="context">Context for deserialization</param> protected override void Deserialize(DeserializeContext context, byte version) { base.Deserialize(context, version); VotingStatus = (VotingStatus)context.ReadInt32(); this.AuthoritiesDone = context.ReadGuidList(); }
public VotingStatusResponse(Guid requestId, VotingStatus votingStatus, List<Guid> authoritiesDone) : base(requestId) { VotingStatus = votingStatus; AuthoritiesDone = authoritiesDone; }
private ICollection <VotingDto> GetVotingWithStatus(ICollection <Voting> allVoting, VotingStatus status) { return(_mapper.Map <ICollection <VotingDto> >(allVoting.Where(voting => voting.GetVotingStatus() == status))); }
/// <summary> /// Deserializes binary data to object. /// </summary> /// <param name="context">Context for deserialization</param> protected override void Deserialize(DeserializeContext context, byte version) { base.Deserialize(context, version); Material = context.ReadObject<VotingMaterial>(); Authorities = context.ReadObjectList<Certificate>(); AuthoritiesDone = context.ReadGuidList(); Status = (VotingStatus)context.ReadInt32(); EnvelopeCount = context.ReadInt32(); }