コード例 #1
0
        public bool AddMinerScript(IMinerProgram program, IMiner miner)
        {
            bool toSave = false;

            foreach (MinerData item in Miners)
            {
                if (item.Id == miner.Id)
                {
                    //identified the miner
                    foreach (MinerScript script in item.MinerScripts)
                    {
                        if (script.ProgramType == program.Type)
                        {
                            script.BATfile   = program.BATFILE;
                            script.BATCopied = program.BATCopied;
                            script.AutomaticScriptGeneration = program.AutomaticScriptGeneration;
                            script.MiningIntensity           = program.MiningIntensity;
                            toSave = true;
                        }
                    }
                    if (toSave == false)
                    {
                        MinerScript script = new MinerScript();
                        script.ProgramType = program.Type;
                        script.BATfile     = program.BATFILE;
                        script.BATCopied   = program.BATCopied;
                        script.AutomaticScriptGeneration = program.AutomaticScriptGeneration;
                        script.MiningIntensity           = program.MiningIntensity;

                        item.MinerScripts.Add(script);
                        toSave = true;
                    }
                }
            }
            return(toSave);
        }
コード例 #2
0
        public bool AddMiner(IMiner miner)
        {
            bool toSave = false;

            ICoinConfigurer mainCoinConfigurer = miner.MainCoin.SettingsScreen;
            ICoinConfigurer dualCoinConfigurer = null;

            if (miner.DualMining)
            {
                dualCoinConfigurer = miner.DualCoin.SettingsScreen;
            }

            MinerData newMiner = new MinerData();

            newMiner.Id        = miner.Id;
            newMiner.Name      = miner.Name;
            newMiner.Algorithm = miner.MainCoin.Algorithm.Name;
            //newMiner.BATFileName ="";
            newMiner.MainCoin            = miner.MainCoin.Name;
            newMiner.MainCoinPool        = mainCoinConfigurer.Pool;
            newMiner.MainCoinWallet      = mainCoinConfigurer.Wallet;
            newMiner.MainCoinPassword    = mainCoinConfigurer.Password;
            newMiner.MainCoinPoolAccount = mainCoinConfigurer.PoolAccount;
            newMiner.DualMining          = miner.DualMining;
            newMiner.MinerGpuType        = miner.MinerGpuType;
            newMiner.HashRate            = miner.HashRate;

            if (miner.DualMining)
            {
                newMiner.DualCoin            = miner.DualCoin.Name;
                newMiner.DualCoinPool        = dualCoinConfigurer.Pool;
                newMiner.DualCoinWallet      = dualCoinConfigurer.Wallet;
                newMiner.DualCoinPoolAccount = dualCoinConfigurer.PoolAccount;
            }
            //minerprograms
            foreach (IMinerProgram item in miner.MinerPrograms)
            {
                MinerScript script = new MinerScript();
                script.BATfile     = item.BATFILE;
                script.ProgramType = item.Type;
                script.AutomaticScriptGeneration = item.AutomaticScriptGeneration;
                script.MiningIntensity           = item.MiningIntensity;

                newMiner.MinerScripts.Add(script);
            }

            //if a similar type is alredy present, them remove it
            List <int> removeIds = new List <int>();
            int        i         = 0;

            foreach (MinerData item in Miners)
            {
                if (item.Id == miner.Id)
                {
                    removeIds.Add(i);
                }
                i++;
            }
            foreach (int j in removeIds)
            {
                Miners.RemoveAt(j);
            }
            Miners.Add(newMiner);
            toSave = true;

            return(toSave);
        }