Example #1
0
        /// <summary>
        /// Get All or specific Help Content 
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="helpcontentid">string</param>
        /// <returns>string</returns>
        public string GetHelpContent(string sessionKey, string helpsubjectid, string helpcontentid)
        {
            string retValue = string.Empty;
            int count = 0;
            ContentObject contentobject = new ContentObject();
            List<HelpContent> lsthelpcontent = new List<HelpContent>();
            List<HelpSubject> lsthelpsubject = new List<HelpSubject>();
            List<HelpVideo> lsthelpvideo = new List<HelpVideo>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();

            bool isValid = true;
            if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); }

            if (isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetHelpContent");

                    if (!string.IsNullOrEmpty(helpsubjectid)) { db.AddInParameter(dbCommand, "@HelpSubjectID", DbType.String, helpsubjectid); }
                    else { db.AddInParameter(dbCommand, "@HelpSubjectID", DbType.String, null); }

                    if (!string.IsNullOrEmpty(helpcontentid)) { db.AddInParameter(dbCommand, "@HelpContentID", DbType.String, helpcontentid); }
                    else { db.AddInParameter(dbCommand, "@HelpContentID", DbType.String, null); }

                    DataSet dsHelpContent = db.ExecuteDataSet(dbCommand);

                    if (dsHelpContent.Tables.Count > 0)
                    {
                        DataTable tHelpContent = dsHelpContent.Tables[0];

                        foreach (DataRow dr in tHelpContent.Rows)
                        {
                            HelpSubject helpsubject = new HelpSubject();
                            if (dr["HelpSubjectID"] != DBNull.Value) { helpsubject.HelpSubjectID = Int32.Parse(dr["HelpSubjectID"].ToString()); }
                            if (dr["Title"] != DBNull.Value) { helpsubject.Title = dr["Title"].ToString(); }
                            if (dr["AudioURL"] != DBNull.Value) { helpsubject.AudioURL = dr["AudioURL"].ToString(); }
                            lsthelpsubject.Add(helpsubject);
                            count++;
                        }
                        contentobject.HelpSubjects = lsthelpsubject;
                    }
                    if (dsHelpContent.Tables.Count > 1)
                    {
                        DataTable tHelpContent = dsHelpContent.Tables[1];

                        foreach (DataRow dr in tHelpContent.Rows)
                        {
                            HelpContent helpcontent = new HelpContent();
                            if (dr["HelpContentID"] != DBNull.Value) { helpcontent.HelpContentID = Int32.Parse(dr["HelpContentID"].ToString()); }
                            if (dr["HelpSubjectID"] != DBNull.Value) { helpcontent.HelpSubjectID = Int32.Parse(dr["HelpSubjectID"].ToString()); }
                            if (dr["HelpContentTitle"] != DBNull.Value) { helpcontent.HelpContentTitle = dr["HelpContentTitle"].ToString(); }
                            if (dr["TitleAudioURL"] != DBNull.Value) { helpcontent.TitleAudioURL = dr["TitleAudioURL"].ToString(); }
                            if (dr["HTMLContent"] != DBNull.Value) { helpcontent.HTMLContent = dr["HTMLContent"].ToString(); }
                            if (dr["HTMLContentAudioURL"] != DBNull.Value) { helpcontent.HTMLContentAudioURL = dr["HTMLContentAudioURL"].ToString(); }
                            lsthelpcontent.Add(helpcontent);
                        }
                        contentobject.HelpContents = lsthelpcontent;
                    }
                    if (dsHelpContent.Tables.Count > 2)
                    {
                        DataTable tHelpVideo = dsHelpContent.Tables[2];

                        foreach (DataRow dr in tHelpVideo.Rows)
                        {
                            HelpVideo helpvideo = new HelpVideo();
                            if (dr["HelpVideoID"] != DBNull.Value) { helpvideo.HelpVideoID = Int32.Parse(dr["HelpVideoID"].ToString()); }
                            //if (dr["HelpContentID"] != DBNull.Value) { helpvideo.HelpContentID = Int32.Parse(dr["HelpContentID"].ToString()); }
                            if (dr["VideoURL"] != DBNull.Value) { helpvideo.VideoURL = dr["VideoURL"].ToString(); }
                            lsthelpvideo.Add(helpvideo);
                        }
                        contentobject.HelpVideos = lsthelpvideo;
                    }
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(contentobject);
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectRecordCount = count;
                    if (responseObject.ResultObjectRecordCount <= 0) { responseObject.ResultMessage = "No records found."; }
                }
                catch (Exception ex)
                {
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetHelpContent", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return Serializer.ObjectToJSON(contentobject);
        }
Example #2
0
        /// <summary>
        /// Get department list.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="subjectid">string</param>
        /// <returns>string</returns>
        public string GetSubjects(string sessionKey, string subjectid)
        {
            string retValue = string.Empty;
            List<HelpSubject> lstdepartment = new List<HelpSubject>();
            ResponseObjectForAnything obj = new ResponseObjectForAnything();
            int count = 0;
            bool isValid = true;
            if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); }

            if (isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetHelpSubject");
                    if (!string.IsNullOrEmpty(subjectid)) { db.AddInParameter(dbCommand, "@SubjectID", DbType.Int32, Convert.ToInt32(subjectid)); }
                    else { db.AddInParameter(dbCommand, "@SubjectID", DbType.Int32, null); }

                    DataSet dsStates = db.ExecuteDataSet(dbCommand);

                    if (dsStates.Tables.Count > 0)
                    {
                        DataTable tState = dsStates.Tables[0];

                        foreach (DataRow dr in tState.Rows)
                        {
                            HelpSubject subject = new HelpSubject();
                            if (dr["HelpSubjectID"] != DBNull.Value) { subject.HelpSubjectID = Int32.Parse(dr["HelpSubjectID"].ToString()); }
                            if (dr["langid"] != DBNull.Value) { subject.langid = Int32.Parse(dr["langid"].ToString()); }
                            if (dr["Title"] != DBNull.Value) { subject.Title = dr["Title"].ToString(); }
                            if (dr["AudioURL"] != DBNull.Value) { subject.AudioURL = dr["AudioURL"].ToString(); }
                            if (dr["alias"] != DBNull.Value) { subject.alias = dr["alias"].ToString(); }
                            if (dr["IconURL"] != DBNull.Value) { subject.IconURL = dr["IconURL"].ToString(); }
                            lstdepartment.Add(subject);
                            count++;
                        }
                        obj.ResultObjectJSON = Serializer.ObjectToJSON(lstdepartment);
                        obj.ResultCode = "SUCCESS";
                        obj.ResultObjectRecordCount = count;
                        if (obj.ResultObjectRecordCount <= 0) { obj.ResultMessage = "No records found."; }
                    }
                }
                catch (Exception ex)
                {
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetDepartments", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return Serializer.ObjectToJSON(obj);
        }