Esempio n. 1
0
        private bool EditPool(Pool pool)
        {
            var window = new ControlWindow("Edit pool", new EditPoolControl(pool))
            {
                Owner = this
            };

            if (window.ShowDialog() == true)
            {
                var result = window.Result;

                try
                {
                    Context.Entry(pool).State = EntityState.Modified;
                    Context.SaveChanges();
                }
                catch (Exception)
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        private Miner AddMiner()
        {
            var window = new ControlWindow("Add miner", new EditMinerControl(null))
            {
                Owner = this
            };

            Miner miner = null;

            if (window.ShowDialog() == true)
            {
                var result = window.Result;

                if (result == ControlWindowResult.OK)
                {
                    miner    = window.GetValue <Miner>();
                    miner.Id = Guid.NewGuid();

                    try
                    {
                        Context.Miners.Add(miner);
                        Context.SaveChanges();
                    }
                    catch (Exception)
                    {
                        return(null);
                    }
                }
            }

            return(miner);
        }
Esempio n. 3
0
        private Pool AddPool()
        {
            var window = new ControlWindow("Add pool", new EditPoolControl(null))
            {
                Owner = this
            };

            Pool pool = null;

            if (window.ShowDialog() == true)
            {
                var result = window.Result;

                if (result == ControlWindowResult.OK)
                {
                    pool    = window.GetValue <Pool>();
                    pool.Id = Guid.NewGuid();

                    try
                    {
                        Context.Pools.Add(pool);
                        Context.SaveChanges();
                    }
                    catch (Exception)
                    {
                        return(null);
                    }
                }
            }

            return(pool);
        }
Esempio n. 4
0
        private void SetProxy()
        {
            var window = new ControlWindow("Set proxy", new EditProxyControl(Proxy))
            {
                Owner = this
            };

            Proxy proxy = null;

            if (window.ShowDialog() == true)
            {
                var result = window.Result;

                if (result == ControlWindowResult.OK)
                {
                    proxy = window.GetValue <Proxy>();

                    if (Proxy == null)
                    {
                        proxy.Id = Guid.NewGuid();
                        Context.Proxies.Add(proxy);
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(proxy.Url) && !string.IsNullOrWhiteSpace(proxy.Username) && !string.IsNullOrWhiteSpace(proxy.Password))
                        {
                            Proxy.Password = proxy.Password;
                            Proxy.Username = proxy.Username;
                            Proxy.Url      = proxy.Url;

                            Context.Entry(Proxy).State = EntityState.Modified;
                        }
                        else
                        {
                            Context.Proxies.Remove(Proxy);
                            proxy = null;
                        }
                    }
                }

                Proxy = proxy;
                Context.SaveChanges();
            }
        }