コード例 #1
0
        static object GetSysInfo(string buildType)
        {
            var sysInfo = new
            {
                SysAppId   = ConfigItems.SystemAppId,
                SysAppCode = ConfigItems.SystemAppCode,
                SysAppName = ConfigItems.SystemAppName,
                HardInfo   = HardInfo.ToString(),
                BuildType  = buildType
            };

            return(sysInfo);
        }
コード例 #2
0
        //-------------------------------------------------------------------------
        // 負荷情報更新
        //-------------------------------------------------------------------------
        public HardInfo SetHardInfo(ref PerformanceCounter iCounter, ref ToolStripStatusLabel iCpuLabel, ref ToolStripStatusLabel iBatLabel)
        {
            // CPU負荷
            float  val = iCounter.NextValue();
            string str = String.Format("CPU:{0,3:f0}%", val);

            iCpuLabel.Text      = str;
            iCpuLabel.ForeColor = (val > 90) ? Color.Red : Color.Black;

            // バッテリー残量
            PowerStatus ps = SystemInformation.PowerStatus;

            HardInfo info = HardInfo.HARD_INFO_NONE;

            //電源に接続されているか
            switch (ps.PowerLineStatus)
            {
            case PowerLineStatus.Online:
                iBatLabel.Text    = "";
                iBatLabel.Visible = false;
                mPrevBat          = 100;
                break;

            case PowerLineStatus.Offline:
                float bat_thres = Properties.Settings.Default.rest_batt;           // 20%以下で通知

                iBatLabel.Visible = true;
                float bat = ps.BatteryLifePercent * 100;
                iBatLabel.Text      = String.Format("電池:{0,3}%", bat);
                iBatLabel.ForeColor = (bat < 10) ? Color.Red : Color.Black;
                if (Properties.Settings.Default.talk_bat)
                {
                    if (mPrevBat > bat_thres && bat <= bat_thres)
                    {
                        info = HardInfo.HARD_INFO_BAT_LOW;
                    }
                }
                mPrevBat = bat;
                break;

            case PowerLineStatus.Unknown:
                iBatLabel.Text    = "";
                iBatLabel.Visible = false;
                break;
            }

            return(info);
        }
コード例 #3
0
ファイル: ProgramBase.cs プロジェクト: ewin66/WindNight.NetFx
 /// <summary>
 ///     Adds default services to the container.
 /// </summary>
 /// <param name="hostBuilder">The <see cref="T:Microsoft.Extensions.Hosting.IHostBuilder" /> to configure.</param>
 /// <param name="buildType"> Release|Debug </param>
 /// <param name="configureDelegate">
 ///     The delegate for configuring the <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> that
 ///     will be used
 ///     to construct the <see cref="T:System.IServiceProvider" />.
 /// </param>
 /// <returns>The same instance of the <see cref="T:Microsoft.Extensions.Hosting.IHostBuilder" /> for chaining.</returns>
 public static IHostBuilder?ConfigureServiceDefaults(this IHostBuilder hostBuilder, string buildType,
                                                     Action <HostBuilderContext, IServiceCollection>?configureDelegate = null)
 {
     return(hostBuilder?.ConfigureServices((context, services) =>
     {
         HardInfo.InitHardInfo();
         services.AddOptions();
         services.AddHttpContextAccessor();
         var configuration = context.Configuration;
         services.TryAddSingleton(configuration);
         configureDelegate?.Invoke(context, services);
         Ioc.Instance.InitServiceProvider(services.BuildServiceProvider());
         if (Ioc.GetService <IConfigService>() == null)
         {
             services.AddSingleton <IConfigService, DefaultConfigService>();
             Ioc.Instance.InitServiceProvider(services.BuildServiceProvider());
         }
         LogHelper.LogRegisterInfo(buildType, false);
     }));
 }