コード例 #1
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void ToggleDynamicIntensityRemotely(Instance instance, bool enabled)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         service.ToggleDynamicIntensity(GetSendingSignature(instance), enabled);
         UpdateViewFromRemoteInTheFuture(2);
     });
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void StopMiningRemotely(Instance instance)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         service.StopMining(GetSendingSignature(instance));
         UpdateViewFromRemoteInTheFuture(5);
     });
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void ToggleDevicesRemotely(Instance instance, IEnumerable<DeviceDescriptor> devices, bool enabled)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         List<DeviceDescriptor> descriptors = CloneDescriptors(devices);
         service.ToggleDevices(GetSendingSignature(instance), descriptors, enabled);
         UpdateViewFromRemoteInTheFuture(2);
     });
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void SetConfigurationRemotely(
     Instance instance, 
     Remoting.Server.Data.Transfer.Configuration.Application application,
     Remoting.Server.Data.Transfer.Configuration.Engine engine,
     Remoting.Server.Data.Transfer.Configuration.Path path,
     Remoting.Server.Data.Transfer.Configuration.Perks perks)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         service.SetApplicationConfiguration(
             GetSendingSignature(instance),
             application,
             engine,
             path,
             perks);
     });
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void SetDevicesToCoinRemotely(Instance instance, IEnumerable<DeviceDescriptor> devices, string coinSymbol)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         List<DeviceDescriptor> descriptors = CloneDescriptors(devices);
         service.SetDevicesToCoin(GetSendingSignature(instance), descriptors, coinSymbol);
         UpdateViewFromRemoteInTheFuture(2);
     });
 }
コード例 #6
0
ファイル: InstancesControl.cs プロジェクト: nvirus/MultiMiner
 private static string GetMachineName(Instance instance)
 {
     string result = instance.MachineName;
     bool isThisPc = result.Equals(Environment.MachineName);
     if (isThisPc)
         result = ThisPCText;
     return result;
 }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void SetAllDevicesToCoinRemotely(Instance instance, string coinSymbol)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         service.SetAllDevicesToCoin(GetSendingSignature(instance), coinSymbol);
         UpdateViewFromRemoteInTheFuture(2);
     });
 }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
        private static IRemotingService GetServiceChannelForInstance(Instance instance)
        {
            EndpointAddress address = new EndpointAddress(new Uri(String.Format("net.tcp://{0}:{1}/RemotingService", instance.IpAddress, Config.RemotingPort)));
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            ChannelFactory<IRemotingService> factory = new ChannelFactory<IRemotingService>(binding, address);
            IRemotingService serviceChannel = factory.CreateChannel();
            return serviceChannel;
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void PerformRemoteCommand(Instance instance, Action<IRemotingService> action)
 {
     using (new HourGlass())
     {
         try
         {
             IRemotingService serviceChannel = GetServiceChannelForInstance(instance);
             action(serviceChannel);
         }
         catch (SystemException ex)
         {
             if ((ex is CommunicationException) || (ex is TimeoutException))
                 ShowMultiMinerRemotingError(ex);
             else
                 throw;
         }
     }
 }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private string GetSendingSignature(Instance destination)
 {
     string signature = String.Format("{0}{1}{2}{3}{4}{5}{6}",
         Environment.MachineName,
         this.fingerprint,
         destination.MachineName,
         destination.Fingerprint,
         remotingPepper,
         workGroupName,
         perksConfiguration.RemotingPassword);
     return GetStringHash(signature);
 }
コード例 #11
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
        private void instancesControl1_SelectedInstanceChanged(object sender, Instance instance)
        {
            bool isThisPc = instance.MachineName.Equals(Environment.MachineName);

            if (!isThisPc)
                GetRemoteApplicationModels(instance);

            //don't set flags until remote VM is fetched
            if (isThisPc)
                this.selectedRemoteInstance = null;
            else
                this.selectedRemoteInstance = instance;

            updatingListView = true;
            try
            {
                RefreshListViewFromViewModel();
                AutoSizeListViewColumns();

                deviceListView.CheckBoxes = (deviceListView.View != View.Tile);
            }
            finally
            {
                updatingListView = false;
            }

            RefreshIncomeSummary();
            UpdateMiningButtons();
            RefreshCoinPopupMenu();
            SetHasChanges(GetViewModelToView().HasChanges);
            RefreshStatusBarFromViewModel();
        }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
        private void GetRemoteApplicationModels(Instance instance)
        {
            PerformRemoteCommand(instance, (service) =>
            {
                IEnumerable<Remoting.Server.Data.Transfer.Device> devices;
                IEnumerable<CryptoCoin> configurations;
                bool mining, hasChanges, dynamicIntensity;

                //set some safe defaults in case the call fails
                this.remoteViewModel = new MainFormViewModel();

                service.GetApplicationModels(GetSendingSignature(instance), out devices, out configurations, out mining, out hasChanges, out dynamicIntensity);

                this.remoteInstanceMining = mining;
                this.remoteViewModel.HasChanges = hasChanges;
                this.remoteViewModel.DynamicIntensity = dynamicIntensity;
                SaveDeviceTransferObjects(devices);
                SaveCoinTransferObjects(configurations);
            });
        }
コード例 #13
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void GetRemoteApplicationConfiguration(Instance instance)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         service.GetApplicationConfiguration(
             GetSendingSignature(instance),
             out remoteApplicationConfig,
             out remoteEngineConfig,
             out remotePathConfig,
             out remotePerksConfig);
     });
 }
コード例 #14
0
ファイル: InstancesControl.cs プロジェクト: nvirus/MultiMiner
        public void RegisterInstance(Instance instance)
        {
            string nodeText = instance.MachineName;
            bool isThisPc = instance.MachineName.Equals(Environment.MachineName);

            TreeNode node;

            if (isThisPc)
            {
                nodeText = ThisPCText;
                node = treeView1.Nodes[0].Nodes.Insert(0, instance.IpAddress, nodeText);
            }
            else
            {
                node = treeView1.Nodes[0].Nodes.Add(instance.IpAddress, nodeText);
            }

            if (isThisPc)
            {
                node.Tag = 1;
                node.ImageIndex = 4;
                node.SelectedImageIndex = 4;
            }
            else
            {
                node.Tag = null;
                node.ImageIndex = 1;
                node.SelectedImageIndex = 1;
            }

            Instances.Add(instance);

            SortTree();

            treeView1.Nodes[0].ExpandAll();

            if (isThisPc)
                treeView1.SelectedNode = node;
        }
コード例 #15
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void CancelChangesRemotely(Instance instance)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         service.CancelChanges(GetSendingSignature(instance));
         UpdateViewFromRemoteInTheFuture(2);
     });
 }
コード例 #16
0
ファイル: MainForm.cs プロジェクト: RomanySaad/MultiMiner
 private void RestartMiningRemotely(Instance instance)
 {
     PerformRemoteCommand(instance, (service) =>
     {
         service.RestartMining(GetSendingSignature(instance));
     });
 }
コード例 #17
0
ファイル: Listener.cs プロジェクト: nvirus/MultiMiner
        private void ProcessReceived(IPEndPoint source, byte[] bytes)
        {
            //only response to discovery on the local network since we transfer fingerprints
            if ((source.AddressFamily != AddressFamily.InterNetwork) &&
                (source.AddressFamily != AddressFamily.InterNetworkV6))
                return;

            string jsonData = Encoding.ASCII.GetString(bytes);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Packet packet = serializer.Deserialize<Packet>(jsonData);

            if (packet.Verb.Equals(Verbs.Online))
            {
                string ipAddress = source.Address.ToString();
                if (!instances.Any(i => i.IpAddress.Equals(ipAddress)))
                {
                    Instance instance = new Instance { IpAddress = ipAddress, MachineName = packet.MachineName, Fingerprint = packet.Fingerprint };

                    //lock for thread-safety - collection may be modified
                    lock (instances)
                    {
                        instances.Add(instance);
                    }

                    Sender.Send(source.Address, Verbs.Online, fingerprint);

                    if (InstanceOnline != null)
                        InstanceOnline(this, new InstanceChangedArgs { Instance = instance });
                }
            }
            else if (packet.Verb.Equals(Verbs.Offline))
            {
                string ipAddress = source.Address.ToString();

                //lock for thread-safety - collection may be modified
                lock (instances)
                {
                    Instance instance = instances.SingleOrDefault(i => i.IpAddress.Equals(ipAddress));
                    if (instance != null)
                    {
                        instances.Remove(instance);

                        if (InstanceOffline != null)
                            InstanceOffline(this, new InstanceChangedArgs { Instance = instance });
                    }
                }
            }
        }
コード例 #18
0
ファイル: InstancesControl.cs プロジェクト: nvirus/MultiMiner
 public void UnregisterInstance(Instance instance)
 {
     treeView1.Nodes[0].Nodes.RemoveByKey(instance.IpAddress);
     Instances.Remove(instance);
     instanceMachines.Remove(instance);
     RefreshNetworkTotals();
 }