public void LoadCurrentInfo()
        {
            logger.Information("Start LoadCurrentInfo.");

            // Fill the rich object data to each object
            foreach (MinerMachine machine in managerInfo.Machines)
            {
                if (!string.IsNullOrEmpty(machine.CredentialId))
                {
                    MachineCredential credential = managerInfo.Credentials.FirstOrDefault(c => c.Id == machine.CredentialId);
                    if (credential == null)
                    {
                        throw new InvalidDataException($"LoadCurrentInfo error: cannot find CredentialId { machine.CredentialId } in ManagerInfo.");
                    }

                    machine.Credential = credential;
                }
            }

            foreach (MinerClient client in managerInfo.Clients)
            {
                MinerMachine machine = managerInfo.Machines.FirstOrDefault(m => m.FullName == client.MachineFullName);
                if (machine == null)
                {
                    throw new InvalidDataException($"LoadCurrentInfo error: cannot find machine with name { client.MachineFullName } in ManagerInfo.");
                }

                client.Machine = machine;
            }
        }
        public void AddClient(MinerClient client)
        {
            logger.Information("Start AddClient.");

            if (client == null)
            {
                logger.Error("New Client should not be null");
                throw new ArgumentNullException("New Client should not be null");
            }

            if (client.Machine == null)
            {
                logger.Error("New Client Machine should not be null");
                throw new ArgumentNullException("New Client Machine should not be null");
            }

            client.StatusChanged  += ClientStatusChanged;
            client.MachineFullName = client.Machine.FullName;

            MinerMachine      newMachine    = client.Machine;
            MachineCredential newCredential = newMachine.Credential;

            if (newCredential != null)
            {
                newMachine.CredentialId = managerInfo.AddOrUpdateCredential(newMachine.Credential);
            }

            managerInfo.AddOrUpdateMachine(newMachine);

            this.ClientList.Add(client);
            this.SaveCurrentInfo();
        }
 private void AddMachine(MinerMachine machine)
 {
     logger.Information("Start AddMachine.");
     if (machine == null)
     {
         logger.Error("Machine should not be null");
         throw new ArgumentNullException("Machine should not be null");
     }
 }
示例#4
0
        public MinerClient(MinerMachine machine, string deploymentFolder, string version = "", int instanceId = 0)
            : this()
        {
            this.MachineFullName = machine.FullName;
            this.Machine         = machine;

            this.DeploymentFolder = deploymentFolder.Trim().ToLower();
            this.Version          = version;
            this.InstanceId       = instanceId;

            this.CurrentDeploymentStatus = DeploymentStatus.Unknown;
            this.CurrentServiceStatus    = ServiceStatus.Unknown;
        }
示例#5
0
 public MachineConnectivity(MinerMachine machine)
 {
     this.Machine = machine;
 }