コード例 #1
0
 public bool IsInstanceIdExists(string machineName, MinerClient.InstanceTypes instanceType, int val)
 {
     return(this.ClientList.Any(client =>
     {
         return client.MachineFullName == machineName && client.InstanceTypeEnum == instanceType && client.InstanceId == val;
     }
                                ));
 }
コード例 #2
0
        private void StepThree_DownloadPackage()
        {
            logger.Trace("Start StepThree_DownloadPackage.");

            string version = this.cbxMinerClientVersions.Text;

            if (string.IsNullOrEmpty(version))
            {
                MessageBox.Show("请选择一个版本");
                logger.Warning("Need to select one version to proceed.");

                return;
            }

            string instanceType = cbxMinerInstanceType.Text;

            selectedMinerClientType = (MinerClient.InstanceTypes)(this.cbxMinerInstanceType.SelectedIndex + 1);

            logger.Information($"Selected version: { version }.");
            logger.Information($"Selected instance type: { selectedMinerClientType }.");

            foreach (MinerClient client in createdClients)
            {
                client.Version          = version;
                client.InstanceType     = this.cbxMinerInstanceType.Text;
                client.InstanceTypeEnum = selectedMinerClientType;
            }

            winMinerBinary = new WinMinerReleaseBinary(version);

            BackgroundWork <int> .CreateWork(
                this,
                () => {
                ShowProgressIndicator("正在下载安装包......", btnStepThreeNext, btnStepThreeBack);
            },
                () => {
                winMinerBinary.DownloadPackage();
                return(0);
            },
                (taskResult) => {
                if (taskResult.HasError)
                {
                    HideProgressIndicator();
                    MessageBox.Show("下载过程出现错误: " + taskResult.Exception.Message);
                    logger.Error("Got error while downloading package: " + taskResult.Exception.ToString());
                }
                else
                {
                    StepThree_ExtractPackage();
                }
            }
                ).Execute();
        }
コード例 #3
0
        /// <summary>
        /// When changing instanceType for 2+ clients on the same machine, it might has a situation that they will have the same instanceId,
        /// So in this step the MinerManager would detect the conflicts then assign new instanceId when necessary.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="returnedInstanceId"></param>
        /// <returns></returns>
        private int AssignInstanceId(string machineName, MinerClient.InstanceTypes instanceType, int newInstanceId)
        {
            int    assignedInstanceId = newInstanceId;
            string key = machineName + instanceType.ToString() + assignedInstanceId.ToString();

            MinerManager manager = MinerManager.GetInstance();

            while (this.newInstanceIdDictionary.ContainsKey(key) ||
                   manager.IsInstanceIdExists(machineName, instanceType, assignedInstanceId))
            {
                assignedInstanceId++;
                key = machineName + instanceType.ToString() + assignedInstanceId.ToString();
            }

            this.newInstanceIdDictionary[key] = true;
            return(assignedInstanceId);
        }