Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalJSONCache"/> class.
        /// </summary>
        /// <param name="filename">The filename.</param>
        public LocalJSONCache(string filename)
        {
            if (filename.EndsWith(".json") == false)
            {
                filename += ".json";
            }

            this.filename = filename;

            lock (@lock)
            {
                bool ok;
                do
                {
                    FileExtras.CreateFile(filename);
                    using (var fs = new FileStream(filename, FileMode.Open))
                    {
                        try
                        {
                            Storage = DictionaryExtras.Deserialize(fs) ?? new Dictionary <string, object>();
                            ok      = true;
                        }
                        catch (Exception)
                        {
                            ok = false;
                            File.Delete(filename);
                        }
                    }
                } while (ok == false);
            }

            js = new JsonSerializer();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Ask the user if they want changes to be made. if yes, then make the changes, if no, return true, if cancel, return false
        /// </summary>
        /// <param name="newData">the copied mp3files taghandler</param>
        /// <param name="orig">the original mp3file</param>
        /// <param name="checkFirst"></param>
        /// <returns>return false if the user wants to cancel all changes, true in any other case</returns>
        public static bool queryUserMakeChangesAndContinue(TagHandlerUpdate newData, Mp3Lib.Mp3File orig, bool checkFirst)
        {
            usercheck UC = null;

            if (checkFirst)
            {
                if (areThereDifferences(orig, newData) == false)
                {
                    MessageBox.Show("No changes need to be made for this file");
                }
                else
                {
                    UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)),
                                       DictionaryExtras.DictToListOfListViewItems(newData.toDict()));
                    UC.ShowDialog();
                }

                if (UC == null || UC.cancelval)
                {
                    return(false);
                }
                if (UC.makeChanges == false)
                {
                    return(true);
                }
            }

            return(makeChangesAndContinue(newData, orig));
        }
Exemplo n.º 3
0
        public static bool areThereDifferences(Mp3File orig, TagHandlerUpdate newData)
        {
            var UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)),
                                   DictionaryExtras.DictToListOfListViewItems(newData.toDict()));

            if (UC.noChanges)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public List <Dictionary <string, object> > RunQuery(string table, string @where)
        {
            string q = $"select top 10 * from {table} {@where}";

            if (cache.ContainsKey(q))
            {
                return(cache[q]);
            }

            var tableValues = c.Database.DynamicSQlQueryToDict(q);

            tableValues.ForEach(s => DictionaryExtras.RemoveEmptyKeyValues(ref s));
            cache[q] = tableValues;
            return(tableValues);
        }