Exemple #1
0
        public static IEnumerable<DBFormatting> GetAll(bool includeDisabled)
        {
            if (cache == null || Settings.isConfig)
            {
                try
                {
                    // make sure the table is created - create a dummy object
                    DBFormatting dummy = new DBFormatting();

                    // retrieve all fields in the table
                    String sqlQuery = "select * from " + cTableName;
                    if (!includeDisabled)
                    {
                        sqlQuery += " where " + cEnabled + " = 1";
                    }
                    sqlQuery += " order by " + cIndex;

                    SQLiteResultSet results = DBTVSeries.Execute(sqlQuery);
                    if (results.Rows.Count > 0)
                    {
                        cache = new DBFormatting[results.Rows.Count];
                        for (int index = 0; index < results.Rows.Count; index++)
                        {
                            cache[index] = new DBFormatting();
                            cache[index].Read(ref results, index);                            
                        }
                    }
                    MPTVSeriesLog.Write("Found and loaded " + results.Rows.Count + " User Formatting Rules",MPTVSeriesLog.LogLevel.Debug);
                    if (results.Rows.Count == 0) cache = new DBFormatting[0];
                    
                }
                catch (Exception ex)
                {
                    MPTVSeriesLog.Write("Error in DBFormatting.Get (" + ex.Message + ").");
                }
            }
            if(cache != null)
                for (int i = 0; i < cache.Length; i++) yield return cache[i];

        }
Exemple #2
0
        /// <summary>
        /// Read Formatting Rules and Import into Database
        /// </summary>
        /// <param name="doc"></param>
        private static void GetFormattingRules(XmlDocument doc) {
            XmlNode node = null;

            node = doc.DocumentElement.SelectSingleNode("/settings/formatting");
            if (node != null && node.Attributes.GetNamedItem("import").Value.ToLower() == "true") {
                MPTVSeriesLog.Write("Loading Skin Formatting Rules", MPTVSeriesLog.LogLevel.Normal);

                DBFormatting.ClearAll();
                long id = 0;
                foreach (string rule in node.InnerText.Split('\n')) {
                    string[] seperators = new string[] { "<Enabled>", "<Format>", "<FormatAs>" };
                    string[] properties = rule.Trim('\r').Split(seperators, StringSplitOptions.RemoveEmptyEntries);
                    if (properties.Length == 3) {
                        DBFormatting dbf = new DBFormatting(id);
                        dbf[DBFormatting.cEnabled] = properties[0];
                        dbf[DBFormatting.cReplace] = properties[1];
                        dbf[DBFormatting.cWith] = properties[2];

                        dbf.Commit();
                        id++;
                    }
                }
                ImportFormatting = true;
            }
        }
Exemple #3
0
 public static void Clear(int Index)
 {
     DBFormatting dummy = new DBFormatting(Index);
     Clear(dummy, new SQLCondition(dummy, DBFormatting.cIndex, Index, SQLConditionType.Equal));
     cache = null;
 }