public void ProcessRequest(HttpContext context)
        {
            string    keyword  = string.Empty;
            DataTable courseDT = new DataTable();

            context.Response.ContentType = "text/plain";
            context.Response.Expires     = -1;
            IList <CourseDTO> tasksList = new List <CourseDTO>();
            CourseBCService   _bc       = new CourseBCService();

            if (context.Request.QueryString.Count >= 1)
            {
                keyword  = context.Request.QueryString["Keyword"];
                courseDT = _bc.getCoursesByFreetext(keyword);
            }
            else
            {
                courseDT = _bc.getAllCourses();
            }
            CastDataTable2TaskList(courseDT, tasksList, _bc);

            System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
                new System.Web.Script.Serialization.JavaScriptSerializer();
            string sJSON = oSerializer.Serialize(tasksList);

            context.Response.Write(sJSON);
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = -1;
            IList <JSonFormatCourses.CourseDTO> tasksList = new List <JSonFormatCourses.CourseDTO>();
            // from mobile it will pass in the FULL or the real search key. if it's null means invalid will return null list.
            String category = String.IsNullOrEmpty(context.Request.QueryString["category"]) ? "Invalid" : context.Request.QueryString["category"];
            String location = String.IsNullOrEmpty(context.Request.QueryString["location"]) ? "Invalid" : context.Request.QueryString["location"];
            String orderby  = String.IsNullOrEmpty(context.Request.QueryString["orderby"]) ? "NoSort" : context.Request.QueryString["orderby"];// will be date or title


            CourseBCService _bc      = new CourseBCService();
            DataTable       courseDT = _bc.getCoursesByParameter(category, location, orderby);

            JSonFormatCourses jfc = new JSonFormatCourses();

            jfc.CastDataTable2TaskList(courseDT, tasksList, _bc);


            System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
                new System.Web.Script.Serialization.JavaScriptSerializer();
            string sJSON = oSerializer.Serialize(tasksList);

            context.Response.Write(sJSON);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = -1;
            IList <CalendarDTO> tasksList = new List <CalendarDTO>();
            CourseBCService     _bc       = new CourseBCService();
            BIZCourseDataSet    eventDS   = (BIZCourseDataSet)_bc.getAllCourseEvents();

            foreach (BIZCourseDataSet.T_BIZ002_COURSE_EVENTRow eventRow in eventDS.T_BIZ002_COURSE_EVENT.Rows)
            {
                tasksList.Add(new CalendarDTO
                {
                    id    = 1,
                    title = eventRow.SCHEDULE,
                    start = ConvertToDateString(eventRow.START_DTTM),
                    end   = ConvertToDateString(eventRow.END_DTTM),
                    url   = ""
                });
            }


            System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
                new System.Web.Script.Serialization.JavaScriptSerializer();
            string sJSON = oSerializer.Serialize(tasksList);

            context.Response.Write(sJSON);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = -1;
            IList <CourseDTO> courseList = new List <CourseDTO>();

            CourseBCService _bc      = new CourseBCService();
            DataTable       courseDT = _bc.getNewCourses();

            foreach (DataRow item in courseDT.Rows)
            {
                if (item["COURSEID"] == null || String.IsNullOrEmpty(item["COURSEID"].ToString()))
                {
                    continue;
                }
                CourseDTO course = new CourseDTO
                {
                    CourseID     = item["COURSEID"].ToString(),
                    CourseName   = item["COURSE_NAME"].ToString(),
                    CourseDetail = item["COURSE_DETAIL"].ToString(),
                    CourseRegURL = item["COURSE_REG_URL"].ToString()
                };

                courseList.Add(course);
            }

            System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
                new System.Web.Script.Serialization.JavaScriptSerializer();
            string sJSON = oSerializer.Serialize(courseList);

            context.Response.Write(sJSON);
        }
        public void CastDataTable2TaskList(DataTable courseDT, IList <CourseDTO> tasksList, CourseBCService _bc)
        {
            foreach (DataRow item in courseDT.Rows)
            {
                if (item["COURSEID"] == null || String.IsNullOrEmpty(item["COURSEID"].ToString()))
                {
                    continue;
                }
                CourseDTO course = new CourseDTO
                {
                    CourseID     = item["COURSEID"].ToString(),
                    CourseName   = item["COURSE_NAME"].ToString(),
                    CourseDetail = item["COURSE_DETAIL"].ToString(),
                    CourseRegURL = item["COURSE_REG_URL"].ToString()
                };

                BIZCourseDataSet eventDS = (BIZCourseDataSet)_bc.getCourseDSEventByCourseId(item["COURSEID"].ToString());

                List <EventDTO> eventList = new List <EventDTO>();
                foreach (BIZCourseDataSet.T_BIZ002_COURSE_EVENTRow eventRow in eventDS.T_BIZ002_COURSE_EVENT.Rows)
                {
                    if (!String.IsNullOrEmpty(eventRow.COURSEEVENTID))
                    {
                        EventDTO eventTO = new EventDTO
                        {
                            Id        = eventRow.COURSEEVENTID,
                            Schedule  = eventRow.SCHEDULE,
                            Location  = eventRow.LOCATION,
                            Startdttm = ConvertToDateString(eventRow.START_DTTM),
                            Enddttm   = ConvertToDateString(eventRow.END_DTTM),
                        };
                        eventList.Add(eventTO);
                    }
                }
                course.EventList = eventList;
                tasksList.Add(course);
            }
        }