Example #1
0
 /// <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>
 public VotingServerEntity(
     VotingRpcServer server,
     Signed<VotingParameters> signedParameters,
     ICertificateStorage certificateStorage,
     ServerCertificate serverCertificate)
     : this(server, signedParameters, certificateStorage, serverCertificate, VotingStatus.New)
 {
     this.lastProcessTime = DateTime.Now;
 }
Example #2
0
        public void DatabaseTest()
        {
            VotingRpcServer votingServer = new VotingRpcServer();

              votingServer.Idle();

              var ids = votingServer.FetchVotingIds();

              votingServer.Logger.Close();
        }
Example #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("PiVote TCP RPC Server");

              AssemblyName programName = Assembly.GetExecutingAssembly().GetName();
              AssemblyName libraryName = typeof(VotingRpcServer).Assembly.GetName();

              Console.WriteLine("Program version {0}", programName.Version.ToString());
              Console.WriteLine("Library version {0}", libraryName.Version.ToString());
              Console.WriteLine();

              if (args.Length >= 1 && args[0] == "wait")
              {
            Console.Write("Waiting to start...");
            Thread.Sleep(10000);
            Console.WriteLine("Go");
              }

              RpcServer = new VotingRpcServer();
              TcpServer = new TcpRpcServer(RpcServer);

              try
              {
            TcpServer.Start();
              }
              catch (Exception exception)
              {
            TcpServer.Logger.Log(LogLevel.Error, "Start failed with exception {0}", exception.Message);

            Console.WriteLine();
            Console.WriteLine(exception.ToString());
              }

              try
              {
            while (true)
            {
              Thread.Sleep(1000);
            }
              }
              catch (Exception exception)
              {
            TcpServer.Logger.Log(LogLevel.Error, "Server failed with exception {0}. Trying to restart it.", exception.Message);

            Process.Start(Environment.GetCommandLineArgs()[0], "wait");
            Environment.FailFast("Server failed");
              }
        }
Example #4
0
        /// <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;
        }