Course.cs :  » Network-Clients » iReaper » IReaper » CourseData » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » iReaper 
iReaper » IReaper » CourseData » Course.cs
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
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.