コード例 #1
0
        /// <summary>
        /// log when music file is loaded from directory
        /// </summary>
        /// <param name="music">Music [object]</param>
        /// <param name="exception">Exception.toString or empty string</param>
        public void LoadFromDirectoryLog(Musics music)
        {
            logFile.Write($"{DateTime.Now};");
            logFile.Write($"{Events.LoadFromDirectory};");
            logFile.Write($"Success;");
            logFile.Write($"{Path.GetDirectoryName(music.MusicFile.FileName)};");
            logFile.Write($"{Path.GetFileName(music.MusicFile.FileName)};");
            PropertyInfo[] props = typeof(TagHandler).GetProperties();
            string         prop  = string.Empty;

            foreach (var propName in Enum.GetValues(typeof(Musics.PropertiesForUser)))
            {
                foreach (PropertyInfo p in props)
                {
                    if (propName.ToString() == p.Name)
                    {
                        prop = p.GetValue(music.OriginalTags).ToString();
                        prop = prop.Replace(";", ",");
                        prop = prop.Replace("\"", "'");
                        logFile.Write($"=\"{prop}\";");
                    }
                }
            }
            logFile.WriteLine();
        }
コード例 #2
0
        /// <summary>
        /// log tags that are choosen from old, ACR and API tags
        /// </summary>
        /// <param name="music">Music [object]</param>
        /// <param name="compareTags">list with all changed tags</param>
        public void ArbitrateNewTagsLog(Musics music, List <string> compareTags)
        {
            logFile.Write($"{DateTime.Now};");
            logFile.Write($"{Events.ArbitrateNewTags};");
            logFile.Write($"=\"");
            foreach (string change in compareTags)
            {
                logFile.Write($"-{change}-");
            }
            logFile.Write($"\";");
            logFile.Write($"{Path.GetDirectoryName(music.MusicFile.FileName)};");
            logFile.Write($"{Path.GetFileName(music.MusicFile.FileName)};");
            PropertyInfo[] props = typeof(TagHandler).GetProperties();
            string         prop  = string.Empty;

            foreach (var propName in Enum.GetValues(typeof(Musics.PropertiesForUser)))
            {
                foreach (PropertyInfo p in props)
                {
                    if (propName.ToString() == p.Name)
                    {
                        prop = p.GetValue(music.NewTags).ToString();
                        prop = prop.Replace(";", ",");
                        prop = prop.Replace("\"", "'");
                        logFile.Write($"=\"{prop}\";");
                    }
                }
            }
            logFile.WriteLine();
        }
コード例 #3
0
        /// <summary>
        /// log file when copied
        /// </summary>
        /// <param name="music">Music [object]</param>
        /// <param name="newPath">new path of the file with new name</param>
        public void CopyFileLog(Musics music, string oldPath)
        {
            logFile.Write($"{DateTime.Now};");
            logFile.Write($"{Events.CopyFile};");
            logFile.Write($"{oldPath};");
            logFile.Write($"{Path.GetDirectoryName(music.MusicFile.FileName)};");
            logFile.Write($"{Path.GetFileName(music.MusicFile.FileName)};");
            PropertyInfo[] props = typeof(TagHandler).GetProperties();
            string         prop  = string.Empty;

            foreach (var propName in Enum.GetValues(typeof(Musics.PropertiesForUser)))
            {
                foreach (PropertyInfo p in props)
                {
                    if (propName.ToString() == p.Name)
                    {
                        try
                        {
                            prop = p.GetValue(music.MusicFile.TagHandler).ToString();
                        } catch (Exception)
                        {
                            prop = String.Empty;
                        }
                        prop = prop.Replace(";", ",");
                        prop = prop.Replace("\"", "'");
                        logFile.Write($"=\"{prop}\";");
                    }
                }
            }
            logFile.WriteLine();
        }
コード例 #4
0
        /// <summary>
        /// log tags coming from ACR
        /// </summary>
        /// <param name="music">Music [object]</param>
        /// <param name="statusCode">Status code of the API message</param>
        /// <param name="metadata">Metadata from ACR</param>
        public void ReadfromACRLog(Musics music, int statusCode, string metadata)
        {
            logFile.Write($"{DateTime.Now};");
            logFile.Write($"{Events.ReadFromACR};");
            logFile.Write($"{statusCode} - {metadata};");
            logFile.Write($"{Path.GetDirectoryName(music.MusicFile.FileName)};");
            logFile.Write($"{Path.GetFileName(music.MusicFile.FileName)};");
            PropertyInfo[] props = typeof(TagHandler).GetProperties();
            string         prop  = string.Empty;

            foreach (var propName in Enum.GetValues(typeof(Musics.PropertiesForUser)))
            {
                foreach (PropertyInfo p in props)
                {
                    if (propName.ToString() == p.Name)
                    {
                        prop = p.GetValue(music.AcrTags).ToString();
                        prop = prop.Replace(";", ",");
                        prop = prop.Replace("\"", "'");
                        logFile.Write($"=\"{prop}\";");
                    }
                }
            }
            logFile.WriteLine();
        }