示例#1
0
        private void SubmitMobileMinerStats()
        {
            //are remote monitoring enabled?
            if (!applicationConfiguration.MobileMinerMonitoring)
                return;

            //is MobileMiner configured?
            if (string.IsNullOrEmpty(applicationConfiguration.MobileMinerApplicationKey) ||
                string.IsNullOrEmpty(applicationConfiguration.MobileMinerEmailAddress))
                return;

            List<MultiMiner.MobileMiner.Api.MiningStatistics> statisticsList = new List<MobileMiner.Api.MiningStatistics>();

            foreach (MinerProcess minerProcess in miningEngine.MinerProcesses)
            {
                List<DeviceInformationResponse> deviceInformationList = GetDeviceInfoFromProcess(minerProcess);

                if (deviceInformationList == null) //handled failure getting API info
                {
                    continue;
                }

                foreach (DeviceInformationResponse deviceInformation in deviceInformationList)
                {
                    MultiMiner.MobileMiner.Api.MiningStatistics miningStatistics = new MobileMiner.Api.MiningStatistics();

                    miningStatistics.MinerName = "MultiMiner";
                    miningStatistics.CoinName = GetCoinNameForApiContext(minerProcess.ApiContext);
                    CryptoCoin coin = engineConfiguration.CoinConfigurations.Single(c => c.Coin.Name.Equals(miningStatistics.CoinName)).Coin;
                    miningStatistics.CoinSymbol = coin.Symbol;

                    if (coin.Algorithm == CoinAlgorithm.Scrypt)
                        miningStatistics.Algorithm = "scrypt";
                    else if (coin.Algorithm == CoinAlgorithm.SHA256)
                        miningStatistics.Algorithm = "SHA-256";

                    PopulateMiningStatsFromDeviceInfo(miningStatistics, deviceInformation);

                    statisticsList.Add(miningStatistics);
                }
            }

            if (statisticsList.Count > 0)
            {
                if (mobileMinerAsync)
                {
                    if (submitMiningStatisticsDelegate == null)
                        submitMiningStatisticsDelegate = SubmitMiningStatistics;

                    submitMiningStatisticsDelegate.BeginInvoke(statisticsList, null, null);
                }
                else
                {
                    SubmitMiningStatistics(statisticsList);
                }
            }
        }
示例#2
0
        private void SubmitMobileMinerStatistics()
        {
            //are remote monitoring enabled?
            if (!applicationConfiguration.MobileMinerMonitoring)
                return;

            //is MobileMiner configured?
            if (string.IsNullOrEmpty(applicationConfiguration.MobileMinerApplicationKey) ||
                string.IsNullOrEmpty(applicationConfiguration.MobileMinerEmailAddress))
                return;

            List<MultiMiner.MobileMiner.Api.MiningStatistics> statisticsList = new List<MobileMiner.Api.MiningStatistics>();

            foreach (MinerProcess minerProcess in miningEngine.MinerProcesses)
            {
                List<DeviceInformationResponse> deviceInformationList = GetDeviceInfoFromProcess(minerProcess);

                if (deviceInformationList == null) //handled failure getting API info
                    continue;

                //starting with bfgminer 3.7 we need the DEVDETAILS response to tie things from DEVS up with -d? details
                List<DeviceDetailsResponse> processDevices = GetProcessDevices(minerProcess, deviceInformationList);

                foreach (DeviceInformationResponse deviceInformation in deviceInformationList)
                {
                    MultiMiner.MobileMiner.Api.MiningStatistics miningStatistics = new MobileMiner.Api.MiningStatistics();

                    PopulateMiningStatistics(miningStatistics, deviceInformation, GetCoinNameForApiContext(minerProcess.ApiContext));

                    DeviceDetailsResponse deviceDetails = processDevices.SingleOrDefault(d => d.Name.Equals(deviceInformation.Name, StringComparison.OrdinalIgnoreCase)
                        && (d.ID == deviceInformation.ID));
                    int deviceIndex = GetItemIndexForDeviceDetails(deviceDetails);
                    Device device = devices[deviceIndex];

                    miningStatistics.FullName = device.Name;
                    miningStatistics.PoolName = GetPoolNameByIndex(deviceInformation.PoolIndex, deviceIndex);

                    statisticsList.Add(miningStatistics);
                }
            }

            if (statisticsList.Count > 0)
            {
                if (submitMiningStatisticsDelegate == null)
                    submitMiningStatisticsDelegate = SubmitMiningStatistics;

                submitMiningStatisticsDelegate.BeginInvoke(statisticsList, null, null);
            }
        }
示例#3
0
        private void SubmitMobileMinerStats()
        {
            //are remote monitoring enabled?
            if (!applicationConfiguration.MobileMinerMonitoring)
                return;

            //is MobileMiner configured?
            if (string.IsNullOrEmpty(applicationConfiguration.MobileMinerApplicationKey) ||
                string.IsNullOrEmpty(applicationConfiguration.MobileMinerEmailAddress))
                return;

            List<MultiMiner.MobileMiner.Api.MiningStatistics> statisticsList = new List<MobileMiner.Api.MiningStatistics>();

            foreach (MinerProcess minerProcess in miningEngine.MinerProcesses)
            {
                List<MultiMiner.Xgminer.Api.DeviceInformation> deviceInformationList = GetDeviceInformationFromMinerProcess(minerProcess);

                if (deviceInformationList == null) //handled failure getting API info
                {
                    continue;
                }

                foreach (MultiMiner.Xgminer.Api.DeviceInformation deviceInformation in deviceInformationList)
                {
                    MultiMiner.MobileMiner.Api.MiningStatistics miningStatistics = new MobileMiner.Api.MiningStatistics();

                    miningStatistics.MinerName = "MultiMiner";
                    miningStatistics.CoinName = GetCoinNameForApiContext(minerProcess.ApiContext);
                    CryptoCoin coin = knownCoins.Single(c => c.Name.Equals(miningStatistics.CoinName));
                    miningStatistics.CoinSymbol = coin.Symbol;

                    if (coin.Algorithm == CoinAlgorithm.Scrypt)
                        miningStatistics.Algorithm = "scrypt";
                    else if (coin.Algorithm == CoinAlgorithm.SHA256)
                        miningStatistics.Algorithm = "SHA-256";

                    PopulateMiningStatsFromDeviceInfo(miningStatistics, deviceInformation);

                    statisticsList.Add(miningStatistics);
                }
            }

            if (statisticsList.Count > 0)
            {
                try
                {
                    MobileMiner.Api.ApiContext.SubmitMiningStatistics(mobileMinerUrl, mobileMinerApiKey,
                        applicationConfiguration.MobileMinerEmailAddress, applicationConfiguration.MobileMinerApplicationKey,
                        Environment.MachineName, statisticsList);
                }
                catch (WebException ex)
                {
                    //could be error 400, invalid app key, error 500, internal error, Unable to connect, endpoint down
                    HttpWebResponse response = ex.Response as HttpWebResponse;
                    if (response != null)
                    {
                        if (response.StatusCode == HttpStatusCode.Forbidden)
                        {
                            this.applicationConfiguration.MobileMinerMonitoring = false;
                            this.applicationConfiguration.SaveApplicationConfiguration();
                            MessageBox.Show("Your MobileMiner credentials are incorrect. Please check your MobileMiner settings in the Settings dialog." +
                                Environment.NewLine + Environment.NewLine +
                                "MobileMiner remote monitoring will now be disabled.", "Invalid Credentails", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            ShowApplicationSettings();
                        }
                    }
                }
            }
        }