using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Runtime.Serialization;
using IReaper.FileData;
using IReaper.Properties;
using System.ComponentModel;
/*
* Technology,Series,Production
*/
namespace IReaper.CourseData{
public delegate void CourseUpdatedEventHandler(Course course);
/// <summary>
///
/// </summary>
[Serializable]
public class Course
{
#region fileds
/// <summary>
/// CourseFileData
/// </summary>
float rate;
string speaker;
string headline;
string courseurl;
string id;
string level;
string description;
string technology;
string products;
string series;
string title;
string resume;
[NonSerialized]
volatile CourseFileData code;
[NonSerialized]
volatile CourseFileData video;
[NonSerialized]
volatile CourseFileData ppt;
[NonSerialized]
volatile CourseFileData qa;
[NonSerialized]
volatile CourseFileData wmv;
[NonSerialized]
volatile CourseFileData mp4;
[NonSerialized]
volatile CourseFileData mp3;
DateTime time;
#endregion
#region constructor
/// <summary>
///
/// </summary>
public Course()
{
speaker = StringResources.OTHER;
headline = StringResources.OTHER;
courseurl = StringResources.OTHER;
id = StringResources.OTHER;
level = StringResources.OTHER;
description = StringResources.OTHER;
technology = StringResources.OTHER;
products = StringResources.OTHER;
series = StringResources.OTHER;
title = StringResources.OTHER;
}
#endregion
#region override
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return this.headline;
}
#endregion
#region static
public static event CourseUpdatedEventHandler OnCourseUpdated;
/// <summary>
///
/// </summary>
public void InvokeCourseUpdate()
{
if (OnCourseUpdated != null)
{
OnCourseUpdated(this);
}
}
/// <summary>
/// "."
/// </summary>
/// <param name="oldName"></param>
/// <returns></returns>
static string ValidPathName(string oldName)
{
//
string rootpath = Settings.Default.RootPath;
//
char[] invalide = Path.GetInvalidFileNameChars();
//
char[] validePathArray = new char[oldName.Length];
for (int i = 0; i < oldName.Length; i++)
{
char c = oldName[i];
if (Array.IndexOf<char>(invalide, c) >= 0)
validePathArray[i] = '.';
else
validePathArray[i] = oldName[i];
}
return new string(validePathArray);
}
public static bool CanRemove(Course course)
{
bool code = CourseFileData.IsCourseFileRemovable(course.code);
bool ppt = CourseFileData.IsCourseFileRemovable(course.ppt);
bool video = CourseFileData.IsCourseFileRemovable(course.video);
bool qa = CourseFileData.IsCourseFileRemovable(course.qa);
bool mp3 = CourseFileData.IsCourseFileRemovable(course.mp3);
bool mp4 = CourseFileData.IsCourseFileRemovable(course.mp4);
bool wmv = CourseFileData.IsCourseFileRemovable(course.wmv);
return code | ppt | video | qa | mp3 | mp4 | wmv;
}
/// <summary>
///
/// </summary>
/// <param name="course"></param>
/// <returns></returns>
public static bool CanOpen(Course course)
{
bool code = CourseFileData.IsCourseFileFinished(course.code);
bool ppt = CourseFileData.IsCourseFileFinished(course.ppt);
bool video = CourseFileData.IsCourseFileFinished(course.video);
bool qa = CourseFileData.IsCourseFileFinished(course.qa);
bool mp3 = CourseFileData.IsCourseFileFinished(course.mp3);
bool mp4 = CourseFileData.IsCourseFileFinished(course.mp4);
bool wmv = CourseFileData.IsCourseFileFinished(course.wmv);
return code | ppt | video | qa | mp3 | mp4 | wmv;
}
/// <summary>
///
/// </summary>
/// <param name="course"></param>
/// <returns></returns>
public static bool CanDownload(Course course)
{
/*
* 1.
* 2.
*/
bool code = CourseFileData.IsCourseFileRunnable(course.code);
bool ppt = CourseFileData.IsCourseFileRunnable(course.ppt);
bool video = CourseFileData.IsCourseFileRunnable(course.video);
bool qa = CourseFileData.IsCourseFileRunnable(course.qa);
bool mp3 = CourseFileData.IsCourseFileRunnable(course.mp3);
bool mp4 = CourseFileData.IsCourseFileRunnable(course.mp4);
bool wmv = CourseFileData.IsCourseFileRunnable(course.wmv);
return code | ppt | video | qa | mp3 | mp4 | wmv;
}
/// <summary>
///
/// </summary>
/// <param name="course"></param>
/// <returns></returns>
public static bool IsNewCourse(Course course)
{
bool code = !CourseFileData.IsCourseFileAvailable(course.code);
bool ppt = !CourseFileData.IsCourseFileAvailable(course.ppt);
bool video = !CourseFileData.IsCourseFileAvailable(course.video);
bool qa = !CourseFileData.IsCourseFileAvailable(course.qa);
bool mp3 = !CourseFileData.IsCourseFileAvailable(course.mp3);
bool mp4 = !CourseFileData.IsCourseFileAvailable(course.mp4);
bool wmv = !CourseFileData.IsCourseFileAvailable(course.wmv);
return code & ppt & video & qa & mp3 & wmv & mp4;
}
#endregion
#region Attributes
/// <summary>
///
/// </summary>
public float Rate
{
get { return rate; }
set { rate = value; }
}
/// <summary>
///
/// </summary>
public string Speaker
{
get { return speaker; }
set { speaker = value; }
}
/// <summary>
///
/// </summary>
public string Resume
{
get { return resume; }
set { resume = value; }
}
/// <summary>
///
/// </summary>
public string Headline
{
get { return headline; }
set { headline = ValidPathName(value); }
}
/// <summary>
///
/// </summary>
public string CourseUrl
{
get { return courseurl; }
set { courseurl = value; }
}
/// <summary>
/// ID
/// </summary>
public string Id
{
get { return id; }
set { id = value; }
}
/// <summary>
/// 200300400
/// </summary>
public string Level
{
get { return level; }
set { level = value; }
}
/// <summary>
///
/// </summary>
public DateTime Time
{
get { return time; }
set { time = value; }
}
/// <summary>
///
/// </summary>
public string Description
{
get { return description; }
set { description = value; }
}
/// <summary>
///
/// </summary>
public string Title
{
get { return title; }
set { title = value; }
}
/// <summary>
///
/// </summary>
public string Series
{
get { return series; }
set { series = value; }
}
/// <summary>
///
/// </summary>
public string Products
{
get { return products; }
set { products = value; }
}
/// <summary>
///
/// </summary>
public string Technology
{
get { return technology; }
set
{
technology = value;
#if DEBUG
System.Diagnostics.Debug.Assert(value != null);
#endif
}
}
/// <summary>
/// PPT
/// </summary>
public CourseFileData PPT
{
get { return ppt; }
set
{
ppt = value;
#if DEBUG
System.Diagnostics.Debug.Assert(value != null);
#endif
}
}
/// <summary>
/// Video
/// </summary>
public CourseFileData Video
{
get { return video; }
set { video = value; }
}
/// <summary>
/// Code
/// </summary>
public CourseFileData Code
{
get { return code; }
set { code = value; }
}
/// <summary>
/// Q&A
/// </summary>
public CourseFileData QA
{
get { return qa; }
set { qa = value; }
}
public CourseFileData WMV
{
get { return wmv; }
set { wmv = value; }
}
public CourseFileData MP3
{
get { return mp3; }
set { mp3 = value; }
}
public CourseFileData MP4
{
get { return mp4; }
set { mp4 = value; }
}
#endregion
}
}
|