public List <ExreciseData> GetTodayExrecises(string user)
        {
            try {
                var list = new List <ExreciseData>();
                if (!File.Exists(SystemFileNames.EXRECISE_DAYS_FILE_PATH))
                {
                    File.AppendAllText(SystemFileNames.EXRECISE_DAYS_FILE_PATH, XML_CONTENT);
                }
                var doc = XDocument.Load(SystemFileNames.EXRECISE_DAYS_FILE_PATH);

                var date      = DateTime.Now.ToString("yyyy-MM-dd");
                var todayNode = doc.Root.Elements().FirstOrDefault(a => a.Attribute(ATT_REVIEW_DATE).Value.Equals(date));
                if (todayNode == null)
                {
                    todayNode = new XElement("Date", new XAttribute(ATT_REVIEW_DATE, date));
                    doc.Root.Add(todayNode);
                }

                foreach (var item in todayNode.Elements())
                {
                    var xuser = item.Attribute(ATT_USER).Value;
                    if (!user.Equals(xuser))
                    {
                        continue;
                    }
                    var data = new ExreciseData()
                    {
                        Book        = item.Attribute(ATT_BOOK).Value,
                        Module      = item.Attribute(ATT_MODULE).Value,
                        Unit        = item.Attribute(ATT_UNIT).Value,
                        ReviewCount = Convert.ToInt32(item.Attribute(ATT_REVIEW_COUNT).Value),
                        ReviewDate  = Convert.ToDateTime(item.Attribute(ATT_REVIEW_DATE).Value),
                        Level       = Convert.ToInt32(item.Attribute(ATT_LEVEL).Value),
                        BookTitle   = item.Attribute(ATT_BOOK_TITLE).Value,
                        User        = item.Attribute(ATT_USER).Value,
                        Guid        = item.Attribute(ATT_GUID).Value
                    };
                    list.Add(data);
                }
                return(list);
            }
            catch (Exception e) {
                mLog.Error($"Exception: {nameof(ExreciseHistoryService)}.{nameof(GetExrecises)} - {e}");
            }
            return(new List <ExreciseData>());
        }
 public List <ExreciseData> GetExrecises(string user)
 {
     try
     {
         var list = new List <ExreciseData>();
         if (!File.Exists(SystemFileNames.EXRECISE_FILE_PATH))
         {
             File.AppendAllText(SystemFileNames.EXRECISE_FILE_PATH, XML_CONTENT);
         }
         var doc = XDocument.Load(SystemFileNames.EXRECISE_FILE_PATH);
         foreach (var item in doc.Root.Elements())
         {
             var xuser = item.Attribute(ATT_USER).Value;
             if (!user.Equals(xuser))
             {
                 continue;
             }
             var data = new ExreciseData()
             {
                 Book        = item.Attribute(ATT_BOOK).Value,
                 Module      = item.Attribute(ATT_MODULE).Value,
                 Unit        = item.Attribute(ATT_UNIT).Value,
                 ReviewCount = Convert.ToInt32(item.Attribute(ATT_REVIEW_COUNT).Value),
                 ReviewDate  = Convert.ToDateTime(item.Attribute(ATT_REVIEW_DATE).Value),
                 Level       = Convert.ToInt32(item.Attribute(ATT_LEVEL).Value),
                 BookTitle   = item.Attribute(ATT_BOOK_TITLE).Value,
                 User        = item.Attribute(ATT_USER).Value
             };
             list.Add(data);
         }
         return(list);
     }
     catch (Exception e)
     {
         mLog.Error($"Exception: {nameof(ExreciseHistoryService)}.{nameof(GetExrecises)} - {e}");
     }
     return(new List <ExreciseData>());
 }
        public List <ExreciseData> GetDaysExrecises(string user)
        {
            var list = new List <ExreciseData>();

            if (!File.Exists(SystemFileNames.EXRECISE_DAYS_FILE_PATH))
            {
                File.AppendAllText(SystemFileNames.EXRECISE_DAYS_FILE_PATH, XML_CONTENT);
            }
            var doc = XDocument.Load(SystemFileNames.EXRECISE_DAYS_FILE_PATH);

            foreach (var dateNode in doc.Root.Elements())
            {
                foreach (var item in dateNode.Elements())
                {
                    var userName = item.Attribute(ATT_USER).Value;
                    if (user.Equals(userName))
                    {
                        var data = new ExreciseData()
                        {
                            Book        = item.Attribute(ATT_BOOK).Value,
                            Module      = item.Attribute(ATT_MODULE).Value,
                            Unit        = item.Attribute(ATT_UNIT).Value,
                            ReviewCount = Convert.ToInt32(item.Attribute(ATT_REVIEW_COUNT).Value),
                            ReviewDate  = Convert.ToDateTime(item.Attribute(ATT_REVIEW_DATE).Value),
                            Level       = Convert.ToInt32(item.Attribute(ATT_LEVEL).Value),
                            BookTitle   = item.Attribute(ATT_BOOK_TITLE).Value,
                            User        = item.Attribute(ATT_USER).Value,
                            Guid        = item.Attribute(ATT_GUID).Value
                        };

                        list.Add(data);
                    }
                }
            }
            return(list);
        }