Esempio n. 1
0
        // (Konrad) We are not going to process warnings here.
#else
        /// <summary>
        /// Adds Warnings to a collection in database. If warnings exist it updates their status.
        /// </summary>
        public static void ProcessWarnings(ActionType action, Document doc, string centralPath)
        {
            var current = doc.GetWarnings().Select(x => new WarningItem(x, doc)).ToList();

            switch (action)
            {
            case ActionType.CheckIn:
                if (!ServerUtilities.Post(current, "warnings/add", out ResponseCreated unused1))
                {
                    Log.AppendLog(LogMessageType.ERROR, "Failed to publish Views Data.");
                }
                break;

            case ActionType.Synch:
                var newW = AppCommand.Warnings.Values
                           .Where(x => !string.IsNullOrEmpty(x.CreatedBy) && current.Any(y => y.UniqueId == x.UniqueId)).ToList();
                var existingW = current.Except(newW).Select(x => x.UniqueId);

                var payload = new WarningData(Environment.UserName, centralPath, newW, existingW);
                if (!ServerUtilities.Post(payload, "warnings/update", out ResponseCreated unused))
                {
                    Log.AppendLog(LogMessageType.ERROR, "Failed to publish Views Data.");
                }
                else
                {
                    CollectWarnings(doc);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(action), action, null);
            }
        }
Esempio n. 2
0
    /// <summary>
    /// Spawns a warning message.
    /// </summary>
    /// <param name="warning">The warning prefab to spawn</param>
    /// <returns>The warning that was spawned</returns>
    public Warning SpawnWarning(WarningData warning)
    {
        Warning temp = (Warning)Instantiate(warning.Prefab, warning.Data.Location, Quaternion.identity);

        temp.Duration         = warning.Duration;
        temp.FadeInDuration   = warning.FadeInDuration;
        temp.FadeOutDuration  = warning.FadeOutDuration;
        temp.transform.parent = field.transform;
        return(temp);
    }
Esempio n. 3
0
        public int PostWarningData(WarningData data)
        {
            int           ret           = -1;
            string        conString     = WebConfigurationManager.ConnectionStrings["Database1"].ToString();
            SqlConnection sqlConnection = new SqlConnection(conString);

            try
            {
                sqlConnection.Open();

                SqlCommand cmd = new SqlCommand
                {
                    Connection  = sqlConnection,
                    CommandText = "update DeviceData set ZeroFaultTime = 0 where ID = @para1"
                };
                cmd.Parameters.Add("@para1", SqlDbType.Int).Value = data.DeviceID;

                cmd.ExecuteNonQuery();

                cmd = new SqlCommand
                {
                    Connection  = sqlConnection,
                    CommandText = "INSERT INTO WarningData(DeviceID, WarningID, OccurTime)VALUES(@para1, @para2, @para3) SELECT @@IDENTITY"
                };
                cmd.Parameters.Add("@para1", SqlDbType.Int).Value      = data.DeviceID;
                cmd.Parameters.Add("@para2", SqlDbType.Int).Value      = data.WarningID;
                cmd.Parameters.Add("@para3", SqlDbType.DateTime).Value = data.OccurTime;

                ret = Convert.ToInt32(cmd.ExecuteScalar().ToString());

                sqlConnection.Close();
            }
            catch (Exception ex)
            {
                sqlConnection.Close();
            }

            return(ret);
        }
Esempio n. 4
0
        public static void AddAllRecord(List <HydrologicalRecord> list, List <OldData> listOldData, ref List <WarningData> listRiverWarningData, ref List <WarningData> listResWarningData)
        {
            int count = 0;

            using (var db = new PMSS.SqlDataAccess.Models.HydroModel())
            {
                foreach (HydrologicalRecord record in list)
                {
                    if (!Double.IsNaN(record.L) && !Double.IsNaN(record.Wl1) && record.L > record.Wl1 && record.Wl1 > 1)
                    {
                        WarningData d = new WarningData();
                        d.Uid  = record.Station.Uid;
                        d.Time = record.Time;
                        d.L    = record.L;
                        d.WL1  = record.Wl1;
                        if (record.Station.Type.Equals("河道站"))
                        {
                            listRiverWarningData.Add(d);
                        }

                        if (record.Station.Type.Equals("水库站"))
                        {
                            listResWarningData.Add(d);
                        }
                    }
                    var exsit = from c in listOldData
                                where c.Uid == record.Station.Uid
                                where c.Time == record.Time
                                select c;

                    if (!exsit.Any())
                    {
                        PMSS.SqlDataAccess.Models.hydrologicaldata data = new PMSS.SqlDataAccess.Models.hydrologicaldata();
                        data.StationId = record.Station.Uid;
                        if (Double.IsNaN(record.L))
                        {
                            data.L = null;
                        }
                        else
                        {
                            data.L = record.L;
                        }

                        if (Double.IsNaN(record.Q))
                        {
                            data.Q = null;
                        }
                        else
                        {
                            data.Q = record.Q;
                        }

                        if (Double.IsNaN(record.Wl1))
                        {
                            data.WL1 = null;
                        }
                        else
                        {
                            data.WL1 = record.Wl1;
                        }

                        if (Double.IsNaN(record.Wl2))
                        {
                            data.WL2 = null;
                        }
                        else
                        {
                            data.WL2 = record.Wl2;
                        }

                        data.Time   = record.Time;
                        data.IsSign = record.isKey;
                        db.hydrologicaldata.Add(data);
                        count++;
                    }
                }
                db.SaveChanges();
            }

            LogHelper.WriteLog(typeof(DBHydro), "数据库新增水情数据" + count + "条!");
        }
Esempio n. 5
0
        public static List <OldData> UpdateKeyReservoir(List <ReservoirHydrology> list, List <OldData> listOldData, ref List <WarningData> listWarningData)
        {
            List <OldData> newData           = new List <OldData>();
            int            keyReservoirCount = 0;

            using (var db = new PMSS.SqlDataAccess.Models.HydroModel())
            {
                foreach (ReservoirHydrology reservoir in list)
                {
                    var exsitStation = from c in db.hydrologicalstation
                                       where c.Name == reservoir.StationName
                                       where c.Type == "水库站"
                                       select new
                    {
                        StationId = c.UID
                    };                      //查找该站点的ID号

                    if (exsitStation.Any()) //存在该站点
                    {
                        string sid = exsitStation.FirstOrDefault().StationId;
                        newData.Add(new OldData(sid, reservoir.Time));
                        if (reservoir.WaterLevel > 0 && reservoir.WarningWaterLevel > 1 && reservoir.WaterLevel > (reservoir.WarningWaterLevel - 20))  //超警数据
                        {
                            WarningData d = new WarningData();
                            d.Uid  = sid;
                            d.Time = reservoir.Time;
                            d.L    = reservoir.WaterLevel;
                            d.WL1  = reservoir.WarningWaterLevel;
                            listWarningData.Add(d);
                        }
                        var exsitRecord = from c in listOldData
                                          where c.Uid == sid
                                          where c.Time == reservoir.Time
                                          select c;
                        if (!exsitRecord.Any())  //不存在相同记录
                        {
                            PMSS.SqlDataAccess.Models.hydrologicaldata data = new PMSS.SqlDataAccess.Models.hydrologicaldata();
                            data.StationId = sid;
                            data.L         = reservoir.WaterLevel; //水位
                            data.Q         = reservoir.Pondage;    //蓄水量
                            data.WL1       = reservoir.WarningWaterLevel;
                            data.Time      = reservoir.Time;
                            data.IsSign    = true;
                            db.hydrologicaldata.Add(data);
                            keyReservoirCount++;
                        }
                        else
                        {
                            //if (exsitRecord.FirstOrDefault().IsSign == false)  //若存在数据为非重点数据,更新为重点数据
                            //{
                            //    exsitRecord.FirstOrDefault().IsSign = true;
                            //    //int id = exsitRecord.FirstOrDefault().RecordId;
                            //    //LogHelper.WriteLog(typeof(DBHydro), "数据库将ID为" + id + "的水库水情数据更新为重点数据!");
                            //    updateKeyCount++;
                            //}
                        }
                    }
                    else  //不存在该站点
                    {
                        //增加站点数据
                        PMSS.SqlDataAccess.Models.hydrologicalstation station = new PMSS.SqlDataAccess.Models.hydrologicalstation();
                        station.Name    = reservoir.StationName;
                        station.UID     = "zdsk" + (reservoir.StationName + reservoir.RiverName + reservoir.StationAddress).GetHashCode().ToString();
                        station.River   = reservoir.RiverName;
                        station.Address = reservoir.StationAddress;
                        station.Type    = "水库站";
                        db.hydrologicalstation.Add(station);

                        //增加水情数据
                        PMSS.SqlDataAccess.Models.hydrologicaldata data = new PMSS.SqlDataAccess.Models.hydrologicaldata();
                        data.StationId = reservoir.StationName;
                        data.L         = reservoir.WaterLevel; //水位
                        data.Q         = reservoir.Pondage;    //蓄水量
                        data.WL1       = reservoir.WarningWaterLevel;
                        data.Time      = reservoir.Time;
                        data.IsSign    = true;
                        db.hydrologicaldata.Add(data);
                        keyReservoirCount++;
                        newData.Add(new OldData(station.UID, reservoir.Time));

                        if (reservoir.WaterLevel > 0 && reservoir.WarningWaterLevel > 1 && reservoir.WaterLevel > (reservoir.WarningWaterLevel - 20))  //超警数据
                        {
                            WarningData d = new WarningData();
                            d.Uid  = station.UID;
                            d.Time = reservoir.Time;
                            d.L    = reservoir.WaterLevel;
                            d.WL1  = reservoir.WarningWaterLevel;
                            listWarningData.Add(d);
                        }
                    }
                }
                db.SaveChanges();
                LogHelper.WriteLog(typeof(DBHydro), "数据库新增重点水库水情数据" + keyReservoirCount + "条!");
            }

            return(newData);
        }
Esempio n. 6
0
        public static List <OldData> UpdateBigReservoir(List <ReservoirHydrology> list, List <OldData> listOldData, ref List <WarningData> listWarningData)
        {
            List <OldData> newData        = new List <OldData>();
            int            reservoirCount = 0;

            using (var db = new PMSS.SqlDataAccess.Models.HydroModel())
            {
                foreach (ReservoirHydrology reservoir in list)
                {
                    var exsitStation = from c in db.hydrologicalstation
                                       where c.Name == reservoir.StationName
                                       where c.River == reservoir.RiverName
                                       where c.Type == "水库站"
                                       select new
                    {
                        StationId = c.UID
                    };                      //查找该站点的ID号

                    if (exsitStation.Any()) //存在该站点
                    {
                        string sid = exsitStation.FirstOrDefault().StationId;
                        newData.Add(new OldData(sid, reservoir.Time));
                        if (reservoir.WaterLevel > 0 && reservoir.WarningWaterLevel > 1 && reservoir.WaterLevel > (reservoir.WarningWaterLevel - 0.5))  //超警数据
                        {
                            WarningData d = new WarningData();
                            d.Uid  = sid;
                            d.Time = reservoir.Time;
                            d.L    = reservoir.WaterLevel;
                            d.WL1  = reservoir.WarningWaterLevel;
                            listWarningData.Add(d);
                        }
                        var exsitRecord = from c in listOldData
                                          where c.Uid == sid
                                          where c.Time == reservoir.Time
                                          select c;
                        if (!exsitRecord.Any())  //不存在相同记录
                        {
                            PMSS.SqlDataAccess.Models.hydrologicaldata data = new PMSS.SqlDataAccess.Models.hydrologicaldata();
                            data.StationId = sid;
                            data.L         = reservoir.WaterLevel; //水位
                            data.Q         = reservoir.Pondage;    //流量
                            data.WL1       = reservoir.WarningWaterLevel;
                            data.Time      = reservoir.Time;
                            data.IsSign    = false;
                            db.hydrologicaldata.Add(data);
                            reservoirCount++;
                        }
                    }
                    else  //不存在该站点
                    {
                        if (reservoir.StationName.Equals("石门"))
                        {
                            continue;
                        }
                        //增加站点数据
                        PMSS.SqlDataAccess.Models.hydrologicalstation station = new PMSS.SqlDataAccess.Models.hydrologicalstation();
                        station.Name = reservoir.StationName;

                        station.River = reservoir.RiverName;
                        station.UID   = "sk" + (reservoir.StationName + reservoir.RiverName + reservoir.Basin + reservoir.AdministrativeRegion).GetHashCode().ToString();
                        station.Basin = reservoir.Basin;
                        station.AdministrativeRegion = reservoir.AdministrativeRegion;
                        station.Address = reservoir.StationAddress;
                        station.Type    = "水库站";
                        db.hydrologicalstation.Add(station);

                        //增加水情数据
                        PMSS.SqlDataAccess.Models.hydrologicaldata data = new PMSS.SqlDataAccess.Models.hydrologicaldata();
                        data.StationId = reservoir.StationName;
                        data.L         = reservoir.WaterLevel; //水位
                        data.Q         = reservoir.Pondage;    //流量
                        data.WL1       = reservoir.WarningWaterLevel;
                        data.Time      = reservoir.Time;
                        data.IsSign    = false;
                        db.hydrologicaldata.Add(data);
                        reservoirCount++;
                        newData.Add(new OldData(station.UID, reservoir.Time));
                        if (reservoir.WaterLevel > 0 && reservoir.WarningWaterLevel > 1 && reservoir.WaterLevel > (reservoir.WarningWaterLevel - 0.5))  //超警数据
                        {
                            WarningData d = new WarningData();
                            d.Uid  = station.UID;
                            d.Time = reservoir.Time;
                            d.L    = reservoir.WaterLevel;
                            d.WL1  = reservoir.WarningWaterLevel;
                            listWarningData.Add(d);
                        }
                    }
                }
                db.SaveChanges();
                LogHelper.WriteLog(typeof(DBHydro), "数据库新增大型水库水情数据" + reservoirCount + "条!");
            }

            return(newData);
        }
Esempio n. 7
0
        /// <summary>
        /// Event excuted with the timer.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private async void OnTimedEvent(Object source, ElapsedEventArgs e)
        {
            int fpsValue  = 0;
            int cpuValue  = PerfCounter.GetCpuPercentage();
            int gpuValue  = PerfCounter.GetGpuPercentage();
            int ramValue  = PerfCounter.GetRamPercentage();
            int gpuTValue = PerfCounter.GetGpuTemperature();
            int cpuTValue = PerfCounter.GetCpuTemperature();


            if (settings.UseMsiAfterburner && CheckGoodForLogging())
            {
                MSIAfterburnerNET.HM.HardwareMonitor MSIAfterburner = null;

                try
                {
                    MSIAfterburner = new MSIAfterburnerNET.HM.HardwareMonitor();
                }
                catch (Exception ex)
                {
                    logger.Warn("GameActivity - Fail initialize MSIAfterburnerNET");
#if DEBUG
                    Common.LogError(ex, "GameActivity [Ignored]", "Fail initialize MSIAfterburnerNET");
#endif
                }

                if (MSIAfterburner != null)
                {
                    try
                    {
                        fpsValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.FRAMERATE).Data;
                    }
                    catch (Exception ex)
                    {
                        logger.Warn("GameActivity - Fail get fpsValue");
#if DEBUG
                        Common.LogError(ex, "GameActivity [Ignored]", "Fail get fpsValue");
#endif
                    }

                    try
                    {
                        if (gpuValue == 0)
                        {
                            gpuValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.GPU_USAGE).Data;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Warn("GameActivity - Fail get gpuValue");
#if DEBUG
                        Common.LogError(ex, "GameActivity [Ignored]", "Fail get gpuValue");
#endif
                    }

                    try
                    {
                        if (gpuTValue == 0)
                        {
                            gpuTValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.GPU_TEMPERATURE).Data;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Warn("GameActivity - Fail get gpuTValue");
#if DEBUG
                        Common.LogError(ex, "GameActivity [Ignored]", "Fail get gpuTValue");
#endif
                    }

                    try
                    {
                        if (cpuTValue == 0)
                        {
                            cpuTValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.CPU_TEMPERATURE).Data;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Warn("GameActivity - Fail get cpuTValue");
#if DEBUG
                        Common.LogError(ex, "GameActivity [Ignored]", "Fail get cpuTValue");
#endif
                    }
                }
            }
            else if (settings.UseHWiNFO && CheckGoodForLogging())
            {
                HWiNFODumper HWinFO = null;
                List <HWiNFODumper.JsonObj> dataHWinfo = null;

                try
                {
                    HWinFO     = new HWiNFODumper();
                    dataHWinfo = HWinFO.ReadMem();
                }
                catch (Exception ex)
                {
                    logger.Warn("GameActivity - Fail initialize HWiNFODumper");
#if DEBUG
                    Common.LogError(ex, "GameActivity [Ignored]", "Fail initialize HWiNFODumper");
#endif
                }

                if (HWinFO != null && dataHWinfo != null)
                {
                    try
                    {
                        foreach (var sensorItems in dataHWinfo)
                        {
                            JObject sensorItemsOBJ = JObject.Parse(JsonConvert.SerializeObject(sensorItems));

                            string sensorsID = "0x" + ((uint)sensorItemsOBJ["szSensorSensorID"]).ToString("X");

                            // Find sensors fps
                            if (sensorsID.ToLower() == settings.HWiNFO_fps_sensorsID.ToLower())
                            {
                                // Find data fps
                                foreach (var items in sensorItemsOBJ["sensors"])
                                {
                                    JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                    string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                    if (dataID.ToLower() == settings.HWiNFO_fps_elementID.ToLower())
                                    {
                                        fpsValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                    }
                                }
                            }

                            // Find sensors gpu usage
                            if (sensorsID.ToLower() == settings.HWiNFO_gpu_sensorsID.ToLower())
                            {
                                // Find data gpu
                                foreach (var items in sensorItemsOBJ["sensors"])
                                {
                                    JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                    string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                    if (dataID.ToLower() == settings.HWiNFO_gpu_elementID.ToLower())
                                    {
                                        gpuValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                    }
                                }
                            }

                            // Find sensors gpu temp
                            if (sensorsID.ToLower() == settings.HWiNFO_gpuT_sensorsID.ToLower())
                            {
                                // Find data gpu
                                foreach (var items in sensorItemsOBJ["sensors"])
                                {
                                    JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                    string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                    if (dataID.ToLower() == settings.HWiNFO_gpuT_elementID.ToLower())
                                    {
                                        gpuTValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                    }
                                }
                            }

                            // Find sensors cpu temp
                            if (sensorsID.ToLower() == settings.HWiNFO_cpuT_sensorsID.ToLower())
                            {
                                // Find data gpu
                                foreach (var items in sensorItemsOBJ["sensors"])
                                {
                                    JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                    string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                    if (dataID.ToLower() == settings.HWiNFO_cpuT_elementID.ToLower())
                                    {
                                        cpuTValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Warn("GameActivity - Fail get HWiNFO");
#if DEBUG
                        Common.LogError(ex, "GameActivity [Ignored]", "Fail get HWiNFO");
#endif
                    }
                }
            }


            // Listing warnings
            bool WarningMinFps      = false;
            bool WarningMaxCpuTemp  = false;
            bool WarningMaxGpuTemp  = false;
            bool WarningMaxCpuUsage = false;
            bool WarningMaxGpuUsage = false;
            bool WarningMaxRamUsage = false;

            if (settings.EnableWarning)
            {
                if (settings.MinFps != 0 && settings.MinFps >= fpsValue)
                {
                    WarningMinFps = true;
                }
                if (settings.MaxCpuTemp != 0 && settings.MaxCpuTemp <= cpuTValue)
                {
                    WarningMaxCpuTemp = true;
                }
                if (settings.MaxGpuTemp != 0 && settings.MaxGpuTemp <= gpuTValue)
                {
                    WarningMaxGpuTemp = true;
                }
                if (settings.MaxCpuUsage != 0 && settings.MaxCpuUsage <= cpuValue)
                {
                    WarningMaxCpuUsage = true;
                }
                if (settings.MaxGpuUsage != 0 && settings.MaxGpuUsage <= gpuValue)
                {
                    WarningMaxGpuUsage = true;
                }
                if (settings.MaxRamUsage != 0 && settings.MaxRamUsage <= ramValue)
                {
                    WarningMaxRamUsage = true;
                }

                WarningData Message = new WarningData
                {
                    At      = resources.GetString("LOCGameActivityWarningAt") + " " + DateTime.Now.ToString("HH:mm"),
                    FpsData = new Data {
                        Name = resources.GetString("LOCGameActivityFps"), Value = fpsValue, IsWarm = WarningMinFps
                    },
                    CpuTempData = new Data {
                        Name = resources.GetString("LOCGameActivityCpuTemp"), Value = cpuTValue, IsWarm = WarningMaxCpuTemp
                    },
                    GpuTempData = new Data {
                        Name = resources.GetString("LOCGameActivityGpuTemp"), Value = gpuTValue, IsWarm = WarningMaxGpuTemp
                    },
                    CpuUsageData = new Data {
                        Name = resources.GetString("LOCGameActivityCpuUsage"), Value = cpuValue, IsWarm = WarningMaxCpuUsage
                    },
                    GpuUsageData = new Data {
                        Name = resources.GetString("LOCGameActivityGpuUsage"), Value = gpuValue, IsWarm = WarningMaxGpuUsage
                    },
                    RamUsageData = new Data {
                        Name = resources.GetString("LOCGameActivityRamUsage"), Value = ramValue, IsWarm = WarningMaxRamUsage
                    },
                };

                if (WarningMinFps || WarningMaxCpuTemp || WarningMaxGpuTemp || WarningMaxCpuUsage || WarningMaxGpuUsage)
                {
                    WarningsMessage.Add(Message);
                }
            }


            List <ActivityDetailsData> ActivitiesDetailsData = GameActivitiesLog.ItemsDetails.Get(GameActivitiesLog.GetLastSession());
            ActivitiesDetailsData.Add(new ActivityDetailsData
            {
                Datelog = DateTime.Now.ToUniversalTime(),
                FPS     = fpsValue,
                CPU     = cpuValue,
                CPUT    = cpuTValue,
                GPU     = gpuValue,
                GPUT    = gpuTValue,
                RAM     = ramValue
            });
        }
 public static void addWarning(string headline, string warningDescription, Code errorCode)
 {
     WarningData newWarning = new WarningData(headline, warningDescription, errorCode);
     warningQueue.Enqueue(newWarning);
 }
Esempio n. 9
0
    public static void addWarning(string headline, string warningDescription, Code errorCode)
    {
        WarningData newWarning = new WarningData(headline, warningDescription, errorCode);

        warningQueue.Enqueue(newWarning);
    }
Esempio n. 10
0
        /// <summary>
        /// Event excuted with the timer.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private async void OnTimedEvent(Object source, ElapsedEventArgs e)
        {
            int fpsValue  = 0;
            int cpuValue  = GetCpuPercentage();
            int gpuValue  = 0;
            int ramValue  = GetRamPercentage();
            int gpuTValue = 0;
            int cpuTValue = 0;


            if (settings.UseMsiAfterburner && CheckGoodForLogging())
            {
                var MSIAfterburner = new MSIAfterburnerNET.HM.HardwareMonitor();

                try
                {
                    fpsValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.FRAMERATE).Data;
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "GameActivity", "Fail get fpsValue");
                }

                try
                {
                    gpuValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.GPU_USAGE).Data;
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "GameActivity", "Fail get gpuValue");
                }

                try
                {
                    gpuTValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.GPU_TEMPERATURE).Data;
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "GameActivity", "Fail get gpuTValue");
                }

                try
                {
                    cpuTValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.CPU_TEMPERATURE).Data;
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "GameActivity", "Fail get cpuTValue");
                }
            }
            else if (settings.UseHWiNFO && CheckGoodForLogging())
            {
                HWiNFODumper HWinFO = new HWiNFODumper();
                List <HWiNFODumper.JsonObj> dataHWinfo = HWinFO.ReadMem();

                try
                {
                    foreach (var sensorItems in dataHWinfo)
                    {
                        JObject sensorItemsOBJ = JObject.Parse(JsonConvert.SerializeObject(sensorItems));

                        string sensorsID = "0x" + ((uint)sensorItemsOBJ["szSensorSensorID"]).ToString("X");

                        // Find sensors fps
                        if (sensorsID.ToLower() == settings.HWiNFO_fps_sensorsID.ToLower())
                        {
                            // Find data fps
                            foreach (var items in sensorItemsOBJ["sensors"])
                            {
                                JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_fps_elementID.ToLower());

                                if (dataID.ToLower() == settings.HWiNFO_fps_elementID.ToLower())
                                {
                                    fpsValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                }
                            }
                        }

                        // Find sensors gpu usage
                        if (sensorsID.ToLower() == settings.HWiNFO_gpu_sensorsID.ToLower())
                        {
                            // Find data gpu
                            foreach (var items in sensorItemsOBJ["sensors"])
                            {
                                JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_gpu_elementID.ToLower());

                                if (dataID.ToLower() == settings.HWiNFO_gpu_elementID.ToLower())
                                {
                                    gpuValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                }
                            }
                        }

                        // Find sensors gpu temp
                        if (sensorsID.ToLower() == settings.HWiNFO_gpuT_sensorsID.ToLower())
                        {
                            // Find data gpu
                            foreach (var items in sensorItemsOBJ["sensors"])
                            {
                                JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_gpu_elementID.ToLower());

                                if (dataID.ToLower() == settings.HWiNFO_gpuT_elementID.ToLower())
                                {
                                    gpuTValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                }
                            }
                        }

                        // Find sensors cpu temp
                        if (sensorsID.ToLower() == settings.HWiNFO_cpuT_sensorsID.ToLower())
                        {
                            // Find data gpu
                            foreach (var items in sensorItemsOBJ["sensors"])
                            {
                                JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items));
                                string  dataID  = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X");

                                //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_gpu_elementID.ToLower());

                                if (dataID.ToLower() == settings.HWiNFO_cpuT_elementID.ToLower())
                                {
                                    cpuTValue = (int)Math.Round((Double)itemOBJ["Value"]);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "GameActivity", "Fail get HWiNFO");
                }
            }


            // Listing warnings
            bool WarningMinFps      = false;
            bool WarningMaxCpuTemp  = false;
            bool WarningMaxGpuTemp  = false;
            bool WarningMaxCpuUsage = false;
            bool WarningMaxGpuUsage = false;
            bool WarningMaxRamUsage = false;

            if (settings.EnableWarning)
            {
                if (settings.MinFps != 0 && settings.MinFps >= fpsValue)
                {
                    WarningMinFps = true;
                }
                if (settings.MaxCpuTemp != 0 && settings.MaxCpuTemp <= cpuTValue)
                {
                    WarningMaxCpuTemp = true;
                }
                if (settings.MaxGpuTemp != 0 && settings.MaxGpuTemp <= gpuTValue)
                {
                    WarningMaxGpuTemp = true;
                }
                if (settings.MaxCpuUsage != 0 && settings.MaxCpuUsage <= cpuValue)
                {
                    WarningMaxCpuUsage = true;
                }
                if (settings.MaxGpuUsage != 0 && settings.MaxGpuUsage <= gpuValue)
                {
                    WarningMaxGpuUsage = true;
                }
                if (settings.MaxRamUsage != 0 && settings.MaxRamUsage <= ramValue)
                {
                    WarningMaxRamUsage = true;
                }

                WarningData Message = new WarningData
                {
                    At      = resources.GetString("LOCGameActivityWarningAt") + " " + DateTime.Now.ToString("HH:mm"),
                    FpsData = new Data {
                        Name = resources.GetString("LOCGameActivityFps"), Value = fpsValue, isWarm = WarningMinFps
                    },
                    CpuTempData = new Data {
                        Name = resources.GetString("LOCGameActivityCpuTemp"), Value = cpuTValue, isWarm = WarningMaxCpuTemp
                    },
                    GpuTempData = new Data {
                        Name = resources.GetString("LOCGameActivityGpuTemp"), Value = gpuTValue, isWarm = WarningMaxGpuTemp
                    },
                    CpuUsageData = new Data {
                        Name = resources.GetString("LOCGameActivityCpuUsage"), Value = cpuValue, isWarm = WarningMaxCpuUsage
                    },
                    GpuUsageData = new Data {
                        Name = resources.GetString("LOCGameActivityGpuUsage"), Value = gpuValue, isWarm = WarningMaxGpuUsage
                    },
                    RamUsageData = new Data {
                        Name = resources.GetString("LOCGameActivityRamUsage"), Value = ramValue, isWarm = WarningMaxRamUsage
                    },
                };

                if (WarningMinFps || WarningMaxCpuTemp || WarningMaxGpuTemp || WarningMaxCpuUsage || WarningMaxGpuUsage)
                {
                    WarningsMessage.Add(Message);
                }
            }



            JObject Data = new JObject();

            Data["datelog"] = DateTime.Now.ToUniversalTime().ToString("o");
            Data["fps"]     = fpsValue;
            Data["cpu"]     = cpuValue;
            Data["gpu"]     = gpuValue;
            Data["ram"]     = ramValue;
            Data["gpuT"]    = gpuTValue;
            Data["cpuT"]    = cpuTValue;

            LoggingData.Add(Data);
        }