コード例 #1
0
 private void checkIfCanHibernate()
 {
     if (!PowerHelper.CanHibernate())
     {
         chkShowHibernate.Visibility = Visibility.Collapsed;
     }
 }
コード例 #2
0
ファイル: SuperMan.aspx.cs プロジェクト: sx81128/AppInOneBPM
    protected void Button1_Click(object sender, EventArgs e)
    {
        SYS_USER ucond = new SYS_USER();

        ucond.USER_NAME = "test";
        ucond.PASS      = StringHelperExd.StringToMD5("123456");
        SYS_USER val = BLLTable <SYS_USER> .Factory(conn).GetRowData(new SYS_USER(), ucond);

        if (val != null)
        {
            PowerHelper.SetCurLoginUser(val);
            if (Request["ckPass"] == null)
            {
                if (Request["preUrl"] != null)
                {
                    Response.Redirect(Request["preUrl"]);
                }
                else
                {
                    Response.Redirect("Index.aspx");
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 'yes';}else{window.returnValue = 'yes';};window.close();", true);
            }
        }
        else
        {
            AgileFrame.Core.ScriptHelper.Alert(Page, "用户名或密码错误!请重新输入。");
        }
    }
コード例 #3
0
        public void WiggleCursor()
        {
            FirstMessage();

            var x = 0;
            var y = 0;
            var counterPreventPowerSave = 0;

            while (true)
            {
                Console.WriteLine("Sleep... x={0} y={1}", x, y);
                Cursor.Position = new Point(x, y);

                x += 50;
                y += 50;

                if (x > 500)
                {
                    x = 0;
                    y = 0;
                    Console.Clear();
                    FirstMessage();
                }

                if (counterPreventPowerSave % 500 == 0)
                {
                    PowerHelper.PreventPowerSave();
                    Console.WriteLine("XXXXXXXXXXXXXX Ran PreventPowerSave...");
                }
                counterPreventPowerSave++;

                Thread.Sleep(EpochConstants.ONE_SECOND_IN_MILLISECONDS);
            }
        }
コード例 #4
0
ファイル: RodGenerator.cs プロジェクト: DnDGen/TreasureGen
        public Item GenerateRandom(string power)
        {
            var rodPowers     = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, ItemTypeConstants.Rod);
            var adjustedPower = PowerHelper.AdjustPower(power, rodPowers);

            var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, adjustedPower, ItemTypeConstants.Rod);
            var result    = typeAndAmountPercentileSelector.SelectFrom(tablename);

            return(GenerateRod(result.Type, result.Amount));
        }
コード例 #5
0
        public BenchmarkHandler(ComputeDevice device, Queue <Algorithm> algorithms, IBenchmarkForm form,
                                BenchmarkPerformanceType performance)
        {
            Device = device;
            _benchmarkAlgorithmQueue = algorithms;
            _benchmarkForm           = form;
            _performanceType         = performance;

            _benchmarkAlgorithmsCount = _benchmarkAlgorithmQueue.Count;
            _powerHelper = new PowerHelper(device);
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: welcometochristown/UsbEvent
        private void btnStop_Click(object sender, EventArgs e)
        {
            btnStart.Enabled      = true;
            btnStop.Enabled       = false;
            listDevices.BackColor = Color.White;

            listener.StopListening();
            toolStripStatusLabel1.Text = "Stopped";

            PowerHelper.ResetSystemDefault();
        }
コード例 #7
0
 private void SetHibernateVisibility()
 {
     if (Settings.Instance.ShowHibernate && PowerHelper.CanHibernate())
     {
         miHibernate.Visibility = Visibility.Visible;
     }
     else
     {
         miHibernate.Visibility = Visibility.Collapsed;
     }
 }
コード例 #8
0
        public BenchmarkHandler2(ComputeDevice device, Queue <Algorithm> algorithms, IBenchmarkForm form,
                                 BenchmarkPerformanceType performance)
        {
            _stopBenchmark           = new CancellationTokenSource();
            Device                   = device;
            _benchmarkAlgorithmQueue = algorithms;
            _benchmarkForm           = form;
            _performanceType         = performance;

            _benchmarkAlgorithmsCount = _benchmarkAlgorithmQueue.Count;
            _powerHelper = new PowerHelper(device);
        }
コード例 #9
0
ファイル: PotionGenerator.cs プロジェクト: DnDGen/TreasureGen
        public Item Generate(string power, string itemName, params string[] traits)
        {
            var possiblePowers = collectionSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, itemName);
            var adjustedPower  = PowerHelper.AdjustPower(power, possiblePowers);

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, adjustedPower, ItemTypeConstants.Potion);
            var results   = typeAndAmountPercentileSelector.SelectAllFrom(tableName);
            var matches   = results.Where(r => NameMatches(r.Type, itemName));
            var result    = collectionSelector.SelectRandomFrom(matches);

            return(GeneratePotion(result.Type, result.Amount, traits));
        }
コード例 #10
0
ファイル: webrepass.aspx.cs プロジェクト: sx81128/AppInOneBPM
 protected void Page_Load(object sender, EventArgs e)
 {
     txtName.Text = userBase.UserName;
     if (Request["out"] != null)
     {
         Session.RemoveAll();
     }
     if (PowerHelper.IsTimeOut())
     {
         Response.Redirect("Login.aspx");
     }
 }
コード例 #11
0
        public BenchmarkHandler(ComputeDevice device, Queue <Algorithm> algorithms, BenchmarkPerformanceType performance, bool startMiningAfterBenchmark = false)
        {
            _stopBenchmark             = new CancellationTokenSource();
            _startMiningAfterBenchmark = startMiningAfterBenchmark;
            Device = device;
            // dirty quick fix
            Device.State             = DeviceState.Benchmarking;
            _benchmarkAlgorithmQueue = algorithms;
            _performanceType         = performance;

            _benchmarkAlgorithmsCount = _benchmarkAlgorithmQueue.Count;
            _powerHelper = new PowerHelper(device);
        }
コード例 #12
0
ファイル: StaffGenerator.cs プロジェクト: DnDGen/TreasureGen
        public Item Generate(string power, string itemName, params string[] traits)
        {
            var staffName     = GetStaffName(itemName);
            var powers        = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, staffName);
            var adjustedPower = PowerHelper.AdjustPower(power, powers);

            var tablename  = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, adjustedPower, ItemTypeConstants.Staff);
            var selections = typeAndAmountPercentileSelector.SelectAllFrom(tablename);
            var matches    = selections.Where(s => s.Type == staffName).ToList();

            var selection = collectionsSelector.SelectRandomFrom(matches);

            return(GenerateStaff(selection.Type, selection.Amount, traits));
        }
コード例 #13
0
        private void MrDuckStayAwake_Checked(object sender, RoutedEventArgs e)
        {
            if (MrDuckStayAwakeCheck.IsChecked)
            {
                MrDuckSettings.Default.IsMrDuckStayAwake = false;
                PowerHelper.ResetSystemDefault();
            }
            else
            {
                MrDuckSettings.Default.IsMrDuckStayAwake = true;
                PowerHelper.ForceSystemAwake();
            }

            MrDuckSettings.Default.Save();
        }
コード例 #14
0
ファイル: RodGenerator.cs プロジェクト: DnDGen/TreasureGen
        public Item Generate(string power, string itemName, params string[] traits)
        {
            var rodName = GetRodName(itemName);

            var powers        = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, rodName);
            var adjustedPower = PowerHelper.AdjustPower(power, powers);

            var tablename = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, adjustedPower, ItemTypeConstants.Rod);
            var results   = typeAndAmountPercentileSelector.SelectAllFrom(tablename);
            var matches   = results.Where(r => r.Type == rodName).ToList();

            var match = collectionsSelector.SelectRandomFrom(matches);

            return(GenerateRod(match.Type, match.Amount, traits));
        }
コード例 #15
0
        public Item Generate(string power, string itemName, params string[] traits)
        {
            var possiblePowers = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.PowerGroups, itemName);
            var adjustedPower  = PowerHelper.AdjustPower(power, possiblePowers);

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, adjustedPower, ItemTypeConstants.WondrousItem);
            var results   = typeAndAmountPercentileSelector.SelectAllFrom(tableName);
            var matches   = results.Where(r => r.Type == itemName);

            var result = collectionsSelector.SelectRandomFrom(matches);
            var item   = BuildWondrousItem(itemName, traits);

            item.Magic.Bonus = result.Amount;

            return(item);
        }
コード例 #16
0
        private async Task BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop)
        {
            using (var powerHelper = new PowerHelper(algo.ComputeDevice))
            {
                BenchmarkManager.AddToStatusCheck(algo.ComputeDevice, algo);
                var plugin     = algo.PluginContainer;
                var miner      = plugin.CreateMiner();
                var miningPair = new MinerPlugin.MiningPair
                {
                    Device    = algo.ComputeDevice.BaseDevice,
                    Algorithm = algo.Algorithm
                };
                // check ethlargement
                var miningPairs = new List <MinerPlugin.MiningPair> {
                    miningPair
                };
                EthlargementIntegratedPlugin.Instance.Start(miningPairs);
                miner.InitMiningPairs(miningPairs);
                // fill service since the benchmark might be online. DemoUser.BTC must be used
                miner.InitMiningLocationAndUsername(StratumService.SelectedServiceLocation, DemoUser.BTC);
                powerHelper.Start();
                algo.ComputeDevice.State = DeviceState.Benchmarking;
                var result = await miner.StartBenchmark(stop, PerformanceType);

                //EthlargementIntegratedPlugin.Instance.Stop(miningPairs); // TODO check stopping
                var power = powerHelper.Stop();
                if (result.Success || result.AlgorithmTypeSpeeds?.Count > 0)
                {
                    var ids    = result.AlgorithmTypeSpeeds.Select(ats => ats.AlgorithmType).ToList();
                    var speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.Speed).ToList();
                    algo.Speeds     = speeds;
                    algo.PowerUsage = power;
                    // set status to empty string it will return speed
                    BenchmarkManager.SetCurrentStatus(algo.ComputeDevice, algo, "");
                    ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice);
                }
                else
                {
                    // mark it as failed
                    algo.LastBenchmarkingFailed = true;
                    // add new failed list
                    _benchmarkFailedAlgo.Add(algo.AlgorithmName);
                    algo.SetError(result.ErrorMessage);
                    BenchmarkManager.SetCurrentStatus(algo.ComputeDevice, algo, result.ErrorMessage);
                }
            }
        }
コード例 #17
0
ファイル: TestGo.aspx.cs プロジェクト: sx81128/AppInOneBPM
    protected void Page_Load(object sender, EventArgs e)
    {
        SYS_USER ucond = new SYS_USER();

        ucond.USER_ID = decimal.Parse(Request["SID"]);
        SYS_USER val = BLLTable <SYS_USER> .Factory(conn).GetRowData(new SYS_USER(), ucond);

        if (val != null)
        {
            PowerHelper.SetCurLoginUser(val);
            Response.Redirect(Request["url"]);
        }
        else
        {
            AgileFrame.Core.ScriptHelper.Alert(Page, "用户名或密码错误!请重新输入。");
        }
    }
コード例 #18
0
ファイル: SuperMan.aspx.cs プロジェクト: sx81128/AppInOneBPM
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (password.Value == "" || username.Value == "")
        {
            AgileFrame.Core.ScriptHelper.Alert(Page, "用户名和密码不能为空。");
            return;
        }

        SYS_USER ucond = new SYS_USER();

        ucond.USER_NAME = username.Value;
        ucond.PASS      = StringHelperExd.StringToMD5(password.Value);
        SYS_USER val = BLLTable <SYS_USER> .Factory(conn).GetRowData(new SYS_USER(), ucond);

        if (val != null)
        {
            bool tostaff = PowerHelper.SetCurLoginUser(val);
            if (tostaff == true)
            {
                if (Request["ckPass"] == null)
                {
                    if (Request["preUrl"] != null)
                    {
                        Response.Redirect(Request["preUrl"]);
                    }
                    else
                    {
                        Response.Redirect("Index.aspx");
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 'yes';}else{window.returnValue = 'yes';};window.close();", true);
                }
            }
            else
            {
                AgileFrame.Core.ScriptHelper.Alert(Page, "您的用户未与员工信息关联,请联系管理员处理。");
            }
        }
        else
        {
            AgileFrame.Core.ScriptHelper.Alert(Page, "用户名或密码错误!请重新输入。");
        }
    }
コード例 #19
0
        private void StartUp()
        {
            // stay awake
            if (!MrDuckSettings.Default.IsMrDuckStayAwake)
            {
                MrDuckStayAwakeCheck.IsChecked = true;
                PowerHelper.ForceSystemAwake();
            }

            // muted duck
            if (!MrDuckSettings.Default.IsMrDuckMuted)
            {
                MrDuckMutedCheck.IsChecked = true;
            }

            // dispatch timer for Fake worker
            _timer          = new DispatcherTimer();
            _timer.Tick    += new EventHandler(MoveMouse_Tick);
            _timer.Interval = new TimeSpan(0, 0, 1); // every 1 sec
        }
コード例 #20
0
        private void setupMenu()
        {
            if (EnvironmentHelper.IsWindows10OrBetter && !EnvironmentHelper.IsAppRunningAsShell)
            {
                // show Windows 10 features
                miOpenUWPSettings.Visibility = Visibility.Visible;
            }

#if !DEBUG
            // I didnt like the Exit Cairo option available when Cairo was set as Shell
            if (EnvironmentHelper.IsAppRunningAsShell)
            {
                miExitCairo.Visibility = Visibility.Collapsed;
            }
#endif

            // Fix for concurrent seperators
            Type previousType = null;
            foreach (UIElement item in CairoMenu.Items)
            {
                if (item.Visibility == Visibility.Visible)
                {
                    Type currentType = item.GetType();
                    if (previousType == typeof(Separator) && currentType == typeof(Separator))
                    {
                        ((Separator)item).Visibility = Visibility.Collapsed;
                    }

                    previousType = currentType;
                }
            }

            // Show power options depending on system support
            SetHibernateVisibility();

            if (!PowerHelper.CanSleep())
            {
                miSleep.Visibility = Visibility.Collapsed;
            }
        }
コード例 #21
0
ファイル: Main.cs プロジェクト: welcometochristown/UsbEvent
        private void btnStart_Click(object sender, EventArgs e)
        {
            btnStart.Enabled      = false;
            listDevices.BackColor = Color.LightYellow;
            btnStop.Enabled       = true;

            try
            {
                listener.StartListening();
                toolStripStatusLabel1.Text = "Listening...";

                if (chkKeepWSAlive.Checked)
                {
                    PowerHelper.ForceSystemAwake();
                }
            }catch (Exception)
            {
                btnStart.Enabled      = true;
                btnStop.Enabled       = false;
                listDevices.BackColor = Color.White;
            }
        }
コード例 #22
0
        public void AdjustPowerCorrectly(string requested, string expected, params string[] available)
        {
            var power = PowerHelper.AdjustPower(requested, available);

            Assert.That(power, Is.EqualTo(expected));
        }
コード例 #23
0
 private void SysSleep(object sender, RoutedEventArgs e)
 {
     PowerHelper.Sleep();
 }
コード例 #24
0
 private void SysHibernate(object sender, RoutedEventArgs e)
 {
     PowerHelper.Hibernate();
 }
コード例 #25
0
ファイル: KeepAlive.cs プロジェクト: eodeluga/KeepAlive
 static void Main(string[] args)
 {
     PowerHelper.ForceSystemAwake();
 }
コード例 #26
0
        public void WiggleCursor()
        {
            var increment = 3;
            var counter   = 0;
            var counterPreventPowerSave = 0;

            var screenCoordinate = _cursorService
                                   .GetScreenCoordinate();

            _cursorService
            .SetPosition(screenCoordinate.CenterX, screenCoordinate.CenterY);

            var currentScreenCoordinate = new CurrentScreenCoordinate
            {
                Up    = screenCoordinate.CenterY,
                Right = screenCoordinate.CenterX,
                Down  = screenCoordinate.CenterY,
                Left  = screenCoordinate.CenterX
            };

            while (true)
            {
                if (Enum.TryParse(counter.ToString(), out CursorMoveEnums cursorMoveEnum))
                {
                    if (cursorMoveEnum.Equals(CursorMoveEnums.Up))
                    {
                        currentScreenCoordinate.Up += increment;

                        _cursorService
                        .SetPosition(screenCoordinate.CenterX, currentScreenCoordinate.Up);

                        Console.WriteLine("up: {0}", currentScreenCoordinate.Up);
                    }
                    if (cursorMoveEnum.Equals(CursorMoveEnums.Right))
                    {
                        currentScreenCoordinate.Right += increment;

                        _cursorService
                        .SetPosition(currentScreenCoordinate.Right, screenCoordinate.CenterY);

                        Console.WriteLine("right: {0}", currentScreenCoordinate.Right);
                    }
                    if (cursorMoveEnum.Equals(CursorMoveEnums.Down))
                    {
                        currentScreenCoordinate.Down -= increment;

                        _cursorService
                        .SetPosition(screenCoordinate.CenterX, currentScreenCoordinate.Down);

                        Console.WriteLine("down: {0}", currentScreenCoordinate.Down);
                    }
                    if (cursorMoveEnum.Equals(CursorMoveEnums.Left))
                    {
                        currentScreenCoordinate.Left -= increment;

                        _cursorService
                        .SetPosition(currentScreenCoordinate.Left, screenCoordinate.CenterY);

                        Console.WriteLine("left: {0}", currentScreenCoordinate.Left);
                    }
                }

                if (currentScreenCoordinate.Up >= screenCoordinate.MaximumY)
                {
                    currentScreenCoordinate = new CurrentScreenCoordinate
                    {
                        Up    = screenCoordinate.CenterY,
                        Right = screenCoordinate.CenterX,
                        Down  = screenCoordinate.CenterY,
                        Left  = screenCoordinate.CenterX
                    };
                }

                Thread.Sleep(EpochConstants.TWENTY_MILLISECONDS);
                counter++;

                if (counter >= 4)
                {
                    counter = 0;
                }

                if (counterPreventPowerSave % 1000 == 0)
                {
                    PowerHelper.PreventPowerSave();
                    Console.WriteLine("XXXXXXXXXXXXXX Ran PreventPowerSave...");
                }
                counterPreventPowerSave++;
            }
        }
コード例 #27
0
 public void AdjustPower_ThrowsExceptionWhenNoAvailablePowers()
 {
     Assert.That(() => PowerHelper.AdjustPower("my power", new List <string>()),
                 Throws.ArgumentException.With.Message.EqualTo("No available powers from which to adjust the requested power: my power"));
 }
コード例 #28
0
        } = BenchmarkPerformanceType.Standard;                                                             // TODO TEMP

        private async Task <object> BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop)
        {
            if (algo == null)
            {
                Logger.Error("BenchmarkingComputeDeviceHandler.BenchmarkNextAlgorithm", $"TakeNextAlgorithm returned null");
                return(false);
            }

            // TODO here you got shity state
            var miningLocation = StratumService.Instance.SelectedOrFallbackServiceLocationCode().miningLocationCode;

            // TODO hidden issue here if our market is not available we will not be able to execute benchmarks
            // unable to benchmark service locations are not operational
            if (miningLocation == null)
            {
                return(false);
            }


            bool ret         = false;
            var  miningPairs = new List <MiningPair> {
                algo.ToMiningPair()
            };

            try
            {
                algo.IsBenchmarking = true;
                using (var powerHelper = new PowerHelper(algo.ComputeDevice))
                {
                    var plugin = algo.PluginContainer;
                    var miner  = plugin.CreateMiner();

                    // check ethlargement
                    EthlargementIntegratedPlugin.Instance.Start(miningPairs);
                    miner.InitMiningPairs(miningPairs);
                    // fill service since the benchmark might be online. DemoUser.BTC must be used
                    miner.InitMiningLocationAndUsername(miningLocation, DemoUser.BTC);
                    powerHelper.Start();
                    algo.ComputeDevice.State = DeviceState.Benchmarking;
                    var result = await miner.StartBenchmark(stop, PerformanceType);

                    EthlargementIntegratedPlugin.Instance.Stop(miningPairs);
                    if (stop.IsCancellationRequested)
                    {
                        return(false);
                    }

                    algo.IsReBenchmark = false;
                    var power = powerHelper.Stop();
                    ret = result.Success || result.AlgorithmTypeSpeeds?.Count > 0;
                    if (ret)
                    {
                        algo.Speeds     = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList();
                        algo.PowerUsage = power;
                        ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice);
                    }
                    else
                    {
                        // mark it as failed
                        algo.LastBenchmarkingFailed = true;
                        algo.SetBenchmarkError(result.ErrorMessage);
                    }
                }
            }
            finally
            {
                EthlargementIntegratedPlugin.Instance.Stop(miningPairs);
                algo.ClearBenchmarkPending();
                algo.IsBenchmarking = false;
            }

            return(ret);
        }
コード例 #29
0
        } = BenchmarkPerformanceType.Standard;                                                             // TODO TEMP

        private async Task <object> BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop)
        {
            if (algo == null)
            {
                Logger.Error("BenchmarkingComputeDeviceHandler.BenchmarkNextAlgorithm", $"TakeNextAlgorithm returned null");
                return(false);
            }

            bool ret         = false;
            var  miningPairs = new List <MiningPair> {
                algo.ToMiningPair()
            };

            try
            {
                algo.IsBenchmarking = true;
                using (var powerHelper = new PowerHelper(algo.ComputeDevice))
                {
                    var plugin = algo.PluginContainer;
                    var miner  = plugin.CreateMiner();

                    GPUProfileManager.Instance.Start(miningPairs);
                    miner.InitMiningPairs(miningPairs);
                    // fill service since the benchmark might be online. DemoUser.BTC must be used
                    miner.InitMiningLocationAndUsername("auto", DemoUser.BTC);
                    powerHelper.Start();
                    algo.ComputeDevice.State = DeviceState.Benchmarking;
                    var result = await miner.StartBenchmark(stop, BenchmarkManagerState.Instance.SelectedBenchmarkType);

                    GPUProfileManager.Instance.Stop(miningPairs);
                    if (stop.IsCancellationRequested)
                    {
                        return(false);
                    }

                    algo.IsReBenchmark = false;
                    var power = powerHelper.Stop();
                    ret = result.Success || result.AlgorithmTypeSpeeds?.Count > 0;
                    if (ret)
                    {
                        algo.Speeds     = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList();
                        algo.PowerUsage = power;
                        ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice);
                    }
                    else
                    {
                        // mark it as failed
                        algo.LastBenchmarkingFailed = true;
                        algo.SetBenchmarkError(result.ErrorMessage);
                    }
                }
            }
            finally
            {
                GPUProfileManager.Instance.Stop(miningPairs);
                algo.ClearBenchmarkPending();
                algo.IsBenchmarking = false;
            }

            return(ret);
        }
コード例 #30
0
 protected override void OnClosing(CancelEventArgs e)
 {
     PowerHelper.ResetSystemDefault();
     base.OnClosing(e);
 }