Ejemplo n.º 1
0
        public void SaveChanges(Miner miner)
        {
            SaveChanges <Miner>(miner);

            for (int i = 0; i < Miners.Count; i++)
            {
                if (Miners[i].Identifier == miner.Identifier)
                {
                    Miners.RemoveAt(i);
                    Miners.Insert(i, miner);
                    return;
                }
            }
            Miners.Add(miner);
        }
Ejemplo n.º 2
0
        public bool RemoveMiner(IMiner miner)
        {
            bool       toSave    = false;
            List <int> removeIds = new List <int>();
            int        i         = 0;

            foreach (MinerData item in Miners)
            {
                if (item.Id == miner.Id)
                {
                    removeIds.Add(i);
                    toSave = true;
                }
                i++;
            }
            foreach (int j in removeIds)
            {
                Miners.RemoveAt(j);
            }
            return(toSave);
        }
Ejemplo n.º 3
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);
        }