using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using IReaper.Category;
namespace IReaper.CourseData{
public class CourseCategoryVector:CourseVectorBase
{
private Dictionary<string, CourseCollection> technology;
private Dictionary<string, CourseCollection> series;
private Dictionary<string, CourseCollection> product;
private Dictionary<float, CourseCollection> rate;
private Dictionary<string, CourseCollection> teacher;
private Dictionary<System.DateTime, CourseCollection> time;
private Dictionary<string, CourseCollection> level;
StringCollection collevel, coltechnology, colseries, colspekaer, colproduct;
List<float> colrate;
List<DateTime> listdate;
public CourseCategoryVector(CourseCollection courses):base(courses)
{
//Level
collevel = new StringCollection();
this.level = new Dictionary<string, CourseCollection>();
//Technology
coltechnology = new StringCollection();
this.technology = new Dictionary<string, CourseCollection>();
//Series
colseries = new StringCollection();
this.series = new Dictionary<string, CourseCollection>();
//Speaker
colspekaer = new StringCollection();
this.teacher = new Dictionary<string, CourseCollection>();
//Product
colproduct = new StringCollection();
this.product = new Dictionary<string, CourseCollection>();
//Rate
colrate = new List<float>();
this.rate = new Dictionary<float, CourseCollection>();
//Date
listdate = new List<DateTime>();
this.time = new Dictionary<DateTime, CourseCollection>();
//
}
/// <summary>
///
/// </summary>
internal Dictionary<string, CourseCollection> Technology
{
get
{
return technology;
}
}
/// <summary>
///
/// </summary>
internal Dictionary<string, CourseCollection> Series
{
get
{
return series;
}
}
/// <summary>
///
/// </summary>
internal Dictionary<string, CourseCollection> Product
{
get
{
return product;
}
}
/// <summary>
///
/// </summary>
internal Dictionary<float, CourseCollection> Rate
{
get
{
return rate;
}
}
/// <summary>
///
/// </summary>
internal Dictionary<string, CourseCollection> Speaker
{
get
{
return teacher;
}
}
/// <summary>
///
/// </summary>
internal Dictionary<string, CourseCollection> Level
{
get
{
return level;
}
}
/// <summary>
///
/// </summary>
internal Dictionary<DateTime, CourseCollection> Time
{
get
{
return time;
}
}
/// <summary>
///
/// </summary>
internal CourseCollection All
{
get
{
return all;
}
}
//
protected override void AddCourse(Course course)
{
//Level
if (!collevel.Contains(course.Level) && course.Level != null)
{
collevel.Add(course.Level);
this.level.Add(course.Level, this.all.GetTypedCoursesCollection());
if(node != null)
node.AddData(CourseAttributeTypeEnum.Level, course.Level, this.level[course.Level]);
}
//Technology
if (!coltechnology.Contains(course.Technology) && course.Technology != null)
{
coltechnology.Add(course.Technology);
this.technology.Add(course.Technology, this.all.GetTypedCoursesCollection());
if (node != null)
node.AddData(CourseAttributeTypeEnum.Technology, course.Technology, this.technology[course.Technology]);
}
//Series
if (!colseries.Contains(course.Series) && course.Series != null)
{
colseries.Add(course.Series);
this.series.Add(course.Series, this.all.GetTypedCoursesCollection());
if (node != null)
node.AddData(CourseAttributeTypeEnum.Series, course.Series, this.series[course.Series]);
}
//Speaker
if (!colspekaer.Contains(course.Speaker) && course.Speaker != null)
{
colspekaer.Add(course.Speaker);
this.teacher.Add(course.Speaker, this.all.GetTypedCoursesCollection());
if (node != null)
node.AddData(CourseAttributeTypeEnum.Speaker, course.Speaker, this.teacher[course.Speaker]);
}
//Product
if (!colproduct.Contains(course.Products) && course.Products != null)
{
colproduct.Add(course.Products);
this.product.Add(course.Products, this.all.GetTypedCoursesCollection());
if (node != null)
node.AddData(CourseAttributeTypeEnum.Product, course.Products, this.product[course.Products]);
}
//Rate
if (!colrate.Contains(course.Rate))
{
colrate.Add(course.Rate);
this.rate.Add(course.Rate, this.all.GetTypedCoursesCollection());
if (node != null)
node.AddData(CourseAttributeTypeEnum.Rating, course.Rate, this.rate[course.Rate]);
}
//Date
DateTime month = new DateTime(course.Time.Year, course.Time.Month, 1);
if (!listdate.Contains(month))
{
listdate.Add(month);
this.time.Add(month, this.all.GetTypedCoursesCollection());
if (node != null)
node.AddData(CourseAttributeTypeEnum.Time, month, this.time[month]);
}
//add data
this.product[course.Products].Add(course);
this.technology[course.Technology].Add(course);
this.series[course.Series].Add(course);
this.rate[course.Rate].Add(course);
this.level[course.Level].Add(course);
this.time[month].Add(course);
this.teacher[course.Speaker].Add(course);
}
/// <summary>
///
/// </summary>
/// <param name="course"></param>
protected override void RemoveCourse(Course course)
{
this.product[course.Products].Remove(course);
this.technology[course.Technology].Remove(course);
this.series[course.Series].Remove(course);
this.rate[course.Rate].Remove(course);
this.level[course.Level].Remove(course);
DateTime month = new DateTime(course.Time.Year, course.Time.Month, 1);
this.time[month].Remove(course);
this.teacher[course.Speaker].Remove(course);
if (this.product[course.Products].Count == 0)
{
this.product.Remove(course.Products);
this.colproduct.Remove(course.Products);
node.RemoveData(CourseAttributeTypeEnum.Product, course.Products);
}
if (this.series[course.Series].Count == 0)
{
this.series.Remove(course.Series);
this.colseries.Remove(course.Series);
node.RemoveData(CourseAttributeTypeEnum.Series, course.Series);
}
if (this.technology[course.Technology].Count == 0)
{
this.technology.Remove(course.Technology);
this.coltechnology.Remove(course.Technology);
node.RemoveData(CourseAttributeTypeEnum.Technology, course.Technology);
}
if (this.rate[course.Rate].Count == 0)
{
this.rate.Remove(course.Rate);
this.colrate.Remove(course.Rate);
node.RemoveData(CourseAttributeTypeEnum.Rating, course.Rate);
}
if (this.level[course.Level].Count == 0)
{
this.level.Remove(course.Level);
this.collevel.Remove(course.Level);
node.RemoveData(CourseAttributeTypeEnum.Level, course.Level);
}
if (this.time[month].Count == 0)
{
this.time.Remove(month);
this.listdate.Remove(month);
node.RemoveData(CourseAttributeTypeEnum.Time, month);
}
if (this.teacher[course.Speaker].Count == 0)
{
this.teacher.Remove(course.Speaker);
this.colspekaer.Remove(course.Speaker);
node.RemoveData(CourseAttributeTypeEnum.Speaker, course.Speaker);
}
}
}
}
|