コード例 #1
0
ファイル: CategoryProcessor.cs プロジェクト: bietiekay/YAPS
        public bool AddCategory(String CategoryName)
        {
            try
            {
                if (!CategoryExists(CategoryName))
                {
                    Category newCategory = new Category();

                    newCategory.Name = CategoryName;
                    newCategory.isAutomatic = true;

                    lock (Categories)
                    {
                        Categories.Add(newCategory);
                    }
                    // SavetheSettings
                    internal_http_server_object.Configuration.SaveSettings();
                    return true;
                }
                else
                    return false;
            }
            catch (Exception e)
            {
                ConsoleOutputLogger.WriteLine("AddCategory: " + e.Message);
                return false;
            }
        }
コード例 #2
0
ファイル: CategoryProcessor.cs プロジェクト: bietiekay/YAPS
 /// <summary>
 /// checks if a recording is in that category or not
 /// </summary>
 /// <param name="recording">Recording to check</param>
 /// <param name="category">if it's in this category</param>
 /// <returns>true if it is, false if not</returns>
 public bool isRecordingInCategory(Recording recording, Category category)
 {
     if (CategoryExists(category.Name))
     {
         // check each category if it applies
         foreach (String SearchTerm in category.SearchTerms)
         {
             if (recording.Recording_Name.Contains(SearchTerm))
             {
                 return true;
             }
         }
         return false;
     }
     else
         return false;
 }
コード例 #3
0
ファイル: CategoryProcessor.cs プロジェクト: bietiekay/YAPS
 public Category GetCategory(String CategoryName)
 {
     try
     {
         if (CategoryExists(CategoryName))
         {
             Category newCategory = new Category();
             // find the object...
             lock (Categories)
             {
                 foreach (Category category in Categories)
                 {
                     if (category.Name == CategoryName)
                     {
                         newCategory = category;
                         break;
                     }
                 }
                 // found it, now remove it...
             }
             return newCategory;
         }
         else
             return null;
     }
     catch (Exception e)
     {
         ConsoleOutputLogger.WriteLine("GetCategory: " + e.Message);
         return null;
     }
 }
コード例 #4
0
ファイル: CategoryProcessor.cs プロジェクト: bietiekay/YAPS
 public bool DelCategory(String CategoryName)
 {
     try
     {
         if (CategoryExists(CategoryName))
         {
             Category newCategory = new Category();
             // find the object...
             lock (Categories)
             {
                 foreach (Category category in Categories)
                 {
                     if (category.Name == CategoryName)
                     {
                         newCategory = category;
                         break;
                     }
                 }
                 // found it, now remove it...
                 Categories.Remove(newCategory);
             }
             // SavetheSettings
             internal_http_server_object.Configuration.SaveSettings();
             return true;
         }
         else
             return false;
     }
     catch (Exception e)
     {
         ConsoleOutputLogger.WriteLine("AddCategory: " + e.Message);
         return false;
     }
 }
コード例 #5
0
ファイル: TemplateProcessor.cs プロジェクト: bietiekay/YAPS
        /// <summary>
        /// this generates the Record Listing HTML Sourcecode
        /// </summary>
        /// <returns>Record Listing Sourcecode</returns>
        String Template_Recorded_Listing(Category FilterCategory, bool SortAscending, String LineTemplate, String Username)
        {
            StringBuilder Output = new StringBuilder();
            /*
            // start the table
            Output.Append("	<table id=\"TABLE2\" width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">	<tr>		<td style=\"background-image: url(images/Table_Headerbar_Tile.png); background-repeat: repeat-x; height: 21px; text-align: center; width: 79px;\">            <strong>playcount</strong></td>	    <td style=\"background-image: url(images/Table_Headerbar_Tile.png); width: 169px; background-repeat: repeat-x; height: 21px; text-align: center\">            ");

            #region SortRecordedAt
            // this is the recorded-at sort button...
            // TODO: at this time this only respects the Filtercategory functionality...add more/general

            if (SortAscending)
                Output.Append("<a href=\"/recordings.html?SortDescending");
            else
                Output.Append("<a href=\"/recordings.html?SortAscending");

            if (FilterCategory != null)
                Output.Append("&CategoryFilter="+HttpUtility.UrlEncode(FilterCategory.Name));

            Output.Append("\"><strong>recorded at</strong></a>");
            #endregion

            Output.Append("</td>	    <td style=\"background-image: url(images/Table_Headerbar_Tile.png); width: 75px; background-repeat: repeat-x; height: 21px; text-align: center\">            <strong>duration</strong></td>	    <td style=\"background-image: url(images/Table_Headerbar_Tile.png); background-repeat: repeat-x; height: 21px; text-align: center; width: 64px;\">            <strong>channel</strong></td>	    <td style=\"background-image: url(images/Table_Headerbar_Tile.png); background-repeat: repeat-x; height: 21px; text-align: center; width: 278px;\">            <strong>name</strong></td>	    <td style=\"background-image: url(images/Table_Headerbar_Tile.png); background-repeat: repeat-x; height: 21px; text-align: center; width: 129px;\">            <strong>category</strong></td>  	    <td style=\"background-image: url(images/Table_Headerbar_Tile.png); background-repeat: repeat-x; height: 21px; text-align: center; width: 79px;\">        </td>	</tr>	");
            // OLD Output.Append("<table width=\"90%\"><tr style=\"background-color: #93939a;\"><td align=\"center\">Time</td><td align=\"center\">Sender</td><td align=\"center\">Name</td></tr>");
            */
            if (FilterCategory == null)
            {
                // when we don't filter anything
                if (internal_vcrscheduler.doneRecordings.Count > 0)
                {
                    List<Recording> sortedDoneRecordingList;
                    ConsoleOutputLogger.WriteLine("[DEBUG] -6");
                    lock (internal_vcrscheduler.doneRecordings.SyncRoot)
                    {
                        // TODO: add ascending/descending setting + reimplement the sorting algorithm
                        sortedDoneRecordingList = Sorter.SortRecordingTable(internal_vcrscheduler.doneRecordings, SortAscending);
                    }

                    foreach (Recording recording_entry in sortedDoneRecordingList)
                    {
                        Output = RenderOneLine_Template_Recorded_Listing(Output, recording_entry, LineTemplate, Username);
                    }
                }
            }
            else
            {
                // when we should filter...
                if (internal_vcrscheduler.doneRecordings.Count > 0)
                {
                    List<Recording> sortedDoneRecordingList;
                    ConsoleOutputLogger.WriteLine("[DEBUG] -7");

                    lock (internal_vcrscheduler.doneRecordings.SyncRoot)
                    {
                        // TODO: add ascending/descending setting + reimplement the sorting algorithm
                        sortedDoneRecordingList = Sorter.SortRecordingTable(internal_vcrscheduler.doneRecordings, SortAscending);
                    }

                    foreach (Recording recording_entry in sortedDoneRecordingList)
                    {
                        if (internal_vcrscheduler.Category_Processor.isRecordingInCategory(recording_entry,FilterCategory))
                            Output = RenderOneLine_Template_Recorded_Listing(Output, recording_entry, LineTemplate, Username);
                    }
                }

            }
            // close the table html tag
            //Output.Append("</table>");

            if ((internal_vcrscheduler.Recordings.Count == 0) && (internal_vcrscheduler.doneRecordings.Count == 0))
            {
                Output.Remove(0, Output.Length);
                Output.Append("No Recordings...");
            }

            return Output.ToString();
        }
コード例 #6
0
ファイル: TemplateProcessor.cs プロジェクト: bietiekay/YAPS
        String Template_All_Category_Searchterms(Category tempCategory)
        {
            StringBuilder Output = new StringBuilder();

            foreach (String searchterm in tempCategory.SearchTerms)
            {
                Output.Append("<option value=\"" + searchterm+ "\">" + searchterm+ "</option>");
            }
            return Output.ToString();
        }