/// <summary> /// Method called from across the data access layer to log errors /// encountered in the /// </summary> /// <param name="exceptionDTO"></param> public static void PublishException(CustomException exceptionDTO) { //Create the delegate ErrorDelegate dgtErrors = new ErrorDelegate(SaveErrorMessage); //Call the beginInvoke function IAsyncResult tag = dgtErrors.BeginInvoke(exceptionDTO, null, null); //Calling endInvoke dgtErrors.EndInvoke(tag); }
/// <summary> /// Call stored procedure to save the exception log. /// </summary> /// <param name="exceptionDTO">CustomException</param> private static void SaveErrorMessage(CustomException exceptionDTO) { Database dbException = DatabaseFactory.CreateDatabase(); DbCommand cmdException = dbException.GetStoredProcCommand("usp_SaveExceptionlog"); //default to "E" for error if (exceptionDTO.ErrorTypeCode == "") { exceptionDTO.ErrorTypeCode = "E"; } dbException.AddInParameter(cmdException, "ErrorMessage", DbType.String, exceptionDTO.ErrorMessage); dbException.AddInParameter(cmdException, "ClassName", DbType.String, exceptionDTO.ClassName); dbException.AddInParameter(cmdException, "MethodName", DbType.String, exceptionDTO.MethodName); dbException.AddInParameter(cmdException, "OtherInformation", DbType.String, exceptionDTO.OtherInformation); dbException.AddInParameter(cmdException, "ErrorTypeCode", DbType.String, exceptionDTO.ErrorTypeCode); dbException.ExecuteNonQuery(cmdException); }
/// <summary> /// This method is used to save groups. /// </summary> /// <param name="sessionKey">string</param> /// <param name="groupid">string</param> /// <param name="langid">string</param> /// <param name="title">string</param> /// <param name="audiofilePath">string</param> /// <param name="isEdit">string</param> /// <returns>string</returns> public string SaveTrainingVideo(string sessionKey, string videoid, string subjectid, string langid, string title, string videofilePath, string pointsearned, string audiourl) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveVideo"); if (videoid != "0") { db.AddInParameter(dbCommand, "@VideoID", DbType.Int32, Int32.Parse(videoid)); } else { db.AddInParameter(dbCommand, "@VideoID", DbType.Int32, null); } if (!string.IsNullOrEmpty(subjectid)) { db.AddInParameter(dbCommand, "@SubjectID", DbType.Int32, Int32.Parse(subjectid)); } else { db.AddInParameter(dbCommand, "@SubjectID", DbType.Int32, null); } if (!string.IsNullOrEmpty(langid)) { db.AddInParameter(dbCommand, "@LangID", DbType.Int32, Int32.Parse(langid)); } else { db.AddInParameter(dbCommand, "@LangID", DbType.Int32, null); } db.AddInParameter(dbCommand, "@Title", DbType.String, title); db.AddInParameter(dbCommand, "@VideoURL", DbType.String, videofilePath); db.AddInParameter(dbCommand, "@PointsEarned", DbType.Int32, Int32.Parse(pointsearned)); db.AddInParameter(dbCommand, "@AudioURL", DbType.String, audiourl); if (videoid == "0") { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) obj.ResultCode = "SUCCESS"; else obj.ResultCode = "ERROR"; obj.ResultObjectID = pId; obj.ResultObjectRecordCount = pId; if (obj.ResultObjectRecordCount <= 0) { obj.ResultMessage = "Unable to save training video."; } } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message; CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveGroups", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Delete tasks. /// </summary> /// <param name="sessionKey">string</param> /// <param name="taskid">string</param> /// <returns>string</returns> public string GetTask(string sessionKey, string personid, string taskid, string duedate, string tasktypeid) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); int count = 0; bool isValid = true; List<SteviArt.Common.DTO.Task> lsttasks = new List<SteviArt.Common.DTO.Task>(); if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } //ResponseObjectForAnything responseObject = GetUserFromSession(sessionKey); //List<Person> person = (List<Person>)Serializer.JSONStringToObject<List<Person>>(responseObject.ResultObjectJSON); if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetTask"); if (!string.IsNullOrEmpty(personid)) { db.AddInParameter(dbCommand, "@TaskID", DbType.Int32, Int32.Parse(taskid)); } else { db.AddInParameter(dbCommand, "@TaskID", DbType.Int32, null); } if (!string.IsNullOrEmpty(personid)) { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, personid); } else { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, null); } if (!string.IsNullOrEmpty(duedate)) { db.AddInParameter(dbCommand, "@DueDate", DbType.DateTime, Convert.ToDateTime(duedate)); } else { db.AddInParameter(dbCommand, "@DueDate", DbType.Int32, null); } if (!string.IsNullOrEmpty(tasktypeid)) { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, Int32.Parse(tasktypeid)); } else { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, null); } DataSet dsTask = db.ExecuteDataSet(dbCommand); if (dsTask.Tables.Count > 0) { DataTable tTask = new DataTable(); foreach (DataRow dr in tTask.Rows) { SteviArt.Common.DTO.Task task = new SteviArt.Common.DTO.Task(); if (dr["TaskID"] != DBNull.Value) { task.TaskID = Int32.Parse(dr["TaskID"].ToString()); } if (dr["TaskTypeID"] != DBNull.Value) { task.TaskTypeID = Int32.Parse(dr["TaskTypeID"].ToString()); } if (dr["langid"] != DBNull.Value) { task.langid = Int32.Parse(dr["langid"].ToString()); } if (dr["IsCompleted"] != DBNull.Value) { task.IsCompleted = Convert.ToBoolean(dr["IsCompleted"].ToString()); } if (dr["LastCompletionDate"] != DBNull.Value) { task.LastCompletionDate = Convert.ToDateTime(dr["LastCompletionDate"].ToString()); } if (dr["DueDate"] != DBNull.Value) { task.DueDate = Convert.ToDateTime(dr["DueDate"].ToString()); } if (dr["CreatedDate"] != DBNull.Value) { task.CreatedDate = Convert.ToDateTime(dr["CreatedDate"].ToString()); } if (dr["Title"] != DBNull.Value) { task.Title = dr["Title"].ToString(); } if (dr["AssignedToPersonID"] != DBNull.Value) { task.AssignedToPersonID = Int32.Parse(dr["AssignedToPersonID"].ToString()); } if (dr["PercentComplete"] != DBNull.Value) { task.PercentComplete = Convert.ToDecimal(dr["PercentComplete"].ToString()); } if (dr["AudioURL"] != DBNull.Value) { task.AudioURL = dr["AudioURL"].ToString(); } lsttasks.Add(task); count++; } } obj.ResultCode = "SUCCESS"; obj.ResultObjectJSON = Serializer.ObjectToJSON(lsttasks); obj.ResultObjectRecordCount = count; if (obj.ResultObjectRecordCount == 0) { obj.ResultMessage = "No records found."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetTask", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Save task types. /// </summary> /// <param name="sessionKey">string</param> /// <param name="tasktypeid">string</param> /// <param name="pointsearned">string</param> /// <param name="goalpathiconurl">string</param> /// <param name="langid">string</param> /// <param name="title">string</param> /// <param name="description">string</param> /// <param name="audiourl">string</param> /// <returns>string</returns> public string SaveTaskType(string sessionKey, string tasktypeid, string pointsearned, string goalpathiconurl, string langid, string title, string audiourl, string minquota) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveTaskType"); if (tasktypeid != "0") { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, Int32.Parse(tasktypeid)); } else { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, null); } if (!string.IsNullOrEmpty(pointsearned)) { db.AddInParameter(dbCommand, "@PointsEarned", DbType.Int32, Int32.Parse(pointsearned)); } else { db.AddInParameter(dbCommand, "@PointsEarned", DbType.Int32, null); } db.AddInParameter(dbCommand, "@IconURL", DbType.String, goalpathiconurl); if (!string.IsNullOrEmpty(langid)) { db.AddInParameter(dbCommand, "@langid", DbType.Int32, Int32.Parse(langid)); } else { db.AddInParameter(dbCommand, "@langid", DbType.Int32, null); } db.AddInParameter(dbCommand, "@Title", DbType.String, title); db.AddInParameter(dbCommand, "@AudioURL", DbType.String, audiourl); if (!string.IsNullOrEmpty(pointsearned)) { db.AddInParameter(dbCommand, "@MinQuota", DbType.Int32, Int32.Parse(minquota)); } else { db.AddInParameter(dbCommand, "@MinQuota", DbType.Int32, null); } if (tasktypeid == "0") { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) { obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Task types have been saved successfully."; } else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Task types have been saved successfully."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveTaskType", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
//public string GetPersonFeedbackType(string sessionKey) //{ // string retValue = string.Empty; // int count = 0; // List<PersonFeedback> lstfeedbacktype = new List<PersonFeedback>(); // 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_GetPersonFeedbackType"); // DataSet dsHelpContent = db.ExecuteDataSet(dbCommand); // if (dsHelpContent.Tables.Count > 0) // { // DataTable tHelpContent = dsHelpContent.Tables[0]; // foreach (DataRow dr in tHelpContent.Rows) // { // PersonFeedback feedback = new PersonFeedback(); // if (dr["PersonFeedbackID"] != DBNull.Value) { feedback.PersonFeedbackID = Int32.Parse(dr["PersonFeedbackID"].ToString()); } // if (dr["Title"] != DBNull.Value) { feedback. = dr["Title"].ToString(); } // if (dr["PointsEarned"] != DBNull.Value) { feedback.PointsEarned = Int32.Parse(dr["PointsEarned"].ToString()); } // lstfeedbacktype.Add(feedback); // count++; // } // } // responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstfeedbacktype); // 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(), "GetFeedbacktype", System.DateTime.Now); // ExceptionManager.PublishException(exc); // } // } // return Serializer.ObjectToJSON(responseObject); //} /// <summary> /// Get video questions and answers based on /// video ID. /// </summary> /// <param name="sessionKey">string</param> /// <param name="videoid">string</param> /// <param name="langid">string</param> /// <returns></returns> public string GetHelpVideoQuizes(string sessionKey, string videoid, string langid) { string retValue = string.Empty; int count = 0; QuestionObject questionobject = new QuestionObject(); List<HelpVideoQuiz> lstquestions = new List<HelpVideoQuiz>(); List<HelpVideoAnswers> lstanswers = new List<HelpVideoAnswers>(); 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_GetHelpVideoQuestions"); if (!string.IsNullOrEmpty(videoid)) { db.AddInParameter(dbCommand, "@VideoID", DbType.String, videoid); } else { db.AddInParameter(dbCommand, "@VideoID", DbType.String, null); } if (!string.IsNullOrEmpty(langid)) { db.AddInParameter(dbCommand, "@langid", DbType.String, langid); } else { db.AddInParameter(dbCommand, "@langid", DbType.String, null); } DataSet dsHelpContent = db.ExecuteDataSet(dbCommand); if (dsHelpContent.Tables.Count > 0) { DataTable tHelpContent = dsHelpContent.Tables[0]; foreach (DataRow dr in tHelpContent.Rows) { HelpVideoQuiz helpquiz = new HelpVideoQuiz(); if (dr["HelpVideoQuizID"] != DBNull.Value) { helpquiz.HelpVideoQuizID = Int32.Parse(dr["HelpVideoQuizID"].ToString()); } if (dr["HelpVideoID"] != DBNull.Value) { helpquiz.HelpVideoID = Int32.Parse(dr["HelpVideoID"].ToString()); } if (dr["QuestionText"] != DBNull.Value) { helpquiz.QuestionText = dr["QuestionText"].ToString(); } if (dr["AudioURL"] != DBNull.Value) { helpquiz.AudioURL = dr["AudioURL"].ToString(); } if (dr["CorrectAnswerID"] != DBNull.Value) { helpquiz.CorrectAnswerID = Int32.Parse(dr["CorrectAnswerID"].ToString()); } if (dr["Points"] != DBNull.Value) { helpquiz.Points = Int32.Parse(dr["Points"].ToString()); } lstquestions.Add(helpquiz); count++; } questionobject.Questions = lstquestions; } if (dsHelpContent.Tables.Count > 1) { DataTable tHelpContent = dsHelpContent.Tables[1]; foreach (DataRow dr in tHelpContent.Rows) { HelpVideoAnswers helpanswers = new HelpVideoAnswers(); if (dr["HelpVideoQuizAnswerID"] != DBNull.Value) { helpanswers.HelpVideoQuizAnswerID = Int32.Parse(dr["HelpVideoQuizAnswerID"].ToString()); } if (dr["AnswerTitle"] != DBNull.Value) { helpanswers.AnswerTitle = dr["AnswerTitle"].ToString(); } if (dr["AnswerAudioFileURL"] != DBNull.Value) { helpanswers.AnswerAudioFileURL = dr["AnswerAudioFileURL"].ToString(); } lstanswers.Add(helpanswers); } questionobject.Answers = lstanswers; } responseObject.ResultObjectJSON = Serializer.ObjectToJSON(questionobject); 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(), "GetQuestions", System.DateTime.Now); ExceptionManager.PublishException(exc); } } return Serializer.ObjectToJSON(questionobject); }
/// <summary> /// Get all supported languages. /// </summary> /// <returns>string</returns> public string GetLanguages(bool isAll) { string retValue = string.Empty; List<Language> lstlang = new List<Language>(); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); int count = 0; try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetLanguages"); db.AddInParameter(dbCommand, "@isAll", DbType.Boolean, isAll); DataSet dsLang = db.ExecuteDataSet(dbCommand); if (dsLang.Tables.Count > 0) { DataTable tState = dsLang.Tables[0]; foreach (DataRow dr in tState.Rows) { Language lang = new Language(); if (dr["langid"] != DBNull.Value) { lang.langid = Int32.Parse(dr["langid"].ToString()); } if (dr["alias"] != DBNull.Value) { lang.alias = dr["alias"].ToString(); } if (dr["isenabled"] != DBNull.Value) { lang.isenabled = Convert.ToBoolean(dr["isenabled"].ToString()); } lstlang.Add(lang); count++; } responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstlang); 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(), "GetStates", System.DateTime.Now); ExceptionManager.PublishException(exc); } return Serializer.ObjectToJSON(responseObject); }
/// <summary> /// Delete questions /// </summary> /// <param name="sessionKey">string</param> /// <param name="questionid">string</param> /// <returns>string</returns> public string DeleteVideoQuestions(string sessionKey, string questionid) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_DeleteQuestion"); db.AddInParameter(dbCommand, "@QuestionID", DbType.Int32, Int32.Parse(questionid)); db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Questions have been deleted successfully."; } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "DeleteContentVideo", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Get groups. /// </summary> /// <param name="sessionKey">string</param> /// <param name="groupid">string</param> /// <returns>string</returns> public string GetGroups(string sessionKey, string groupid) { string retValue = string.Empty; List<Group> lstgroup = new List<Group>(); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); bool isValid = true; int count = 0; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetGroups"); db.AddInParameter(dbCommand, "@GroupID", DbType.Int32, groupid); DataSet dsStates = db.ExecuteDataSet(dbCommand); if (dsStates.Tables.Count > 0) { DataTable tState = dsStates.Tables[0]; foreach (DataRow dr in tState.Rows) { Group group = new Group(); if (dr["GroupID"] != DBNull.Value) { group.GroupID = Int32.Parse(dr["GroupID"].ToString()); } if (dr["langid"] != DBNull.Value) { group.langid = Int32.Parse(dr["langid"].ToString()); } if (dr["Title"] != DBNull.Value) { group.Title = dr["Title"].ToString(); } if (dr["AudioURL"] != DBNull.Value) { group.AudioURL = dr["AudioURL"].ToString(); } if (dr["IconURL"] != DBNull.Value) { group.IconURL = dr["IconURL"].ToString(); } lstgroup.Add(group); count++; } responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstgroup); 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(), "GetDeaprtments", System.DateTime.Now); ExceptionManager.PublishException(exc); } } return Serializer.ObjectToJSON(responseObject); }
/// <summary> /// Save department method. /// </summary> /// <param name="sessionKey">string</param> /// <param name="departmentid">string</param> /// <param name="langid">string</param> /// <param name="title">string</param> /// <param name="audiofilePath">string</param> /// <returns>string</returns> public string SaveDepartment(string sessionKey, string departmentid, string langid, string title, string audiofilePath, string iconpathurl, string isenabled, string filename) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveDepartment"); if (!string.IsNullOrEmpty(departmentid)) { db.AddInParameter(dbCommand, "@DepartmentID", DbType.Int32, Int32.Parse(departmentid)); } else { db.AddInParameter(dbCommand, "@DepartmentID", DbType.Int32, null); } if (!string.IsNullOrEmpty(langid)) { db.AddInParameter(dbCommand, "@langid", DbType.Int32, Int32.Parse(langid)); } else { db.AddInParameter(dbCommand, "@langid", DbType.Int32, null); } db.AddInParameter(dbCommand, "@Title", DbType.String, title); db.AddInParameter(dbCommand, "@AudioURL", DbType.String, audiofilePath); db.AddInParameter(dbCommand, "@IconURL", DbType.String, iconpathurl); db.AddInParameter(dbCommand, "@IsEnabled", DbType.Boolean, Convert.ToBoolean(isenabled)); db.AddInParameter(dbCommand, "@FileName", DbType.Boolean, filename); if (departmentid == null) { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) { obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Department have been saved successfully."; } else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Department have been saved successfully."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveGroups", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Save department method. /// </summary> /// <param name="sessionKey">string</param> /// <param name="departmentid">string</param> /// <param name="langid">string</param> /// <param name="title">string</param> /// <param name="audiofilePath">string</param> /// <returns>string</returns> public string SaveLanguage(string sessionKey, string langid, bool isenabled) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveLanguage"); if (langid != "0") { db.AddInParameter(dbCommand, "@langid", DbType.Int32, Int32.Parse(langid)); } else { db.AddInParameter(dbCommand, "@langid", DbType.Int32, null); } db.AddInParameter(dbCommand, "@isenabled", DbType.Boolean, isenabled); db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Language have been saved successfully."; } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveLanguages", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// This method checks if the session for the user is still valid or not. /// </summary> /// <param name="sessionKey">string</param> /// <returns>bool</returns> public bool IsValidSession(string sessionKey) { bool IsValid = false; try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_IsValidSession"); db.AddInParameter(dbCommand, "@Sessionkey", DbType.String, sessionKey); using (IDataReader dr = db.ExecuteReader(dbCommand)) { while (dr.Read()) { if (dr["IsValid"] != DBNull.Value) { if (Int32.Parse(dr["IsValid"].ToString()) > 0) { IsValid = true; } } } } } catch (Exception ex) { CustomException exc = new CustomException(ex.ToString(), this.ToString(), "IsValidSession", System.DateTime.Now); ExceptionManager.PublishException(exc); } return IsValid; }
/// <summary> /// Assign videos to contents /// </summary> /// <param name="sessionKey">string</param> /// <param name="helpcontentid">string</param> /// <param name="videoid">string</param> /// <param name="videourl">string</param> /// <returns>string</returns> public string SaveContentVideo(string sessionKey, string helpcontentid, string videoid, string videourl) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveContentVideo"); if (!string.IsNullOrEmpty(helpcontentid)) { db.AddInParameter(dbCommand, "@HelpContentID", DbType.Int32, Int32.Parse(helpcontentid)); } else { db.AddInParameter(dbCommand, "@HelpContentID", DbType.Int32, null); } if (!string.IsNullOrEmpty(videoid)) { db.AddInParameter(dbCommand, "@VideoID", DbType.Int32, Int32.Parse(videoid)); } else { db.AddInParameter(dbCommand, "@SubjectID", DbType.Int32, null); } db.AddInParameter(dbCommand, "@VideoURL", DbType.String, videourl); if (helpcontentid == null) { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) { obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Video been saved successfully."; } else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Video has been saved successfully."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveGroups", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Get session key by email ID /// </summary> /// <param name="emailID">string</param> /// <returns>string</returns> public ResponseObjectForAnything GetUserFromSession(string sessionKey) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); bool isValid = true; List<Person> lstPerson = new List<Person>(); int count = 0; if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetUserFromSession"); db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionKey); DataSet dsPerson = db.ExecuteDataSet(dbCommand); if (dsPerson.Tables.Count > 0) { DataTable tPerson = dsPerson.Tables[0]; foreach (DataRow dr in tPerson.Rows) { Person person = new Person(); if (dr["PersonID"] != DBNull.Value) { person.PersonID = Int32.Parse(dr["PersonID"].ToString()); } if (dr["PersonTypeID"] != DBNull.Value) { person.PersonTypeID = Int32.Parse(dr["PersonTypeID"].ToString()); } if (dr["PreferredLanguageID"] != DBNull.Value) { person.PreferredLanguageID = Int32.Parse(dr["PreferredLanguageID"].ToString()); } if (dr["FirstName"] != DBNull.Value) { person.FirstName = dr["FirstName"].ToString(); } if (dr["LastName"] != DBNull.Value) { person.LastName = dr["LastName"].ToString(); } if (dr["Username"] != DBNull.Value) { person.Username = dr["Username"].ToString(); } if (dr["Email"] != DBNull.Value) { person.Email = dr["Email"].ToString(); } if (dr["CountryID"] != DBNull.Value) { person.CountryID = Int32.Parse(dr["CountryID"].ToString()); } if (dr["StateID"] != DBNull.Value) { person.StateID = Int32.Parse(dr["StateID"].ToString()); } if (dr["ProfilePicPath"] != DBNull.Value) { person.ProfilePicPath = dr["ProfilePicPath"].ToString(); } if (dr["PersonGroupID"] != DBNull.Value) { person.PersonGroupID = Int32.Parse(dr["PersonGroupID"].ToString()); } if (dr["GroupName"] != DBNull.Value) { person.GroupName = dr["GroupName"].ToString(); } if (dr["PersonType"] != DBNull.Value) { person.PersonType = dr["PersonType"].ToString(); } if (dr["PointsEarned"] != DBNull.Value) { person.PointsEarned = Int32.Parse(dr["PointsEarned"].ToString()); } if (dr["AvgFeedback"] != DBNull.Value) { person.AvgFeedback = Convert.ToDecimal(dr["AvgFeedback"].ToString()); } lstPerson.Add(person); count++; } } obj.ResultCode = "SUCCESS"; obj.ResultObjectJSON = Serializer.ObjectToJSON(lstPerson); obj.ResultObjectRecordCount = count; if (obj.ResultObjectRecordCount == 0) { obj.ResultMessage = "Invalid session."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetUserFromSession", System.DateTime.Now); ExceptionManager.PublishException(exc); } } return obj; }
/// <summary> /// Delete tasks. /// </summary> /// <param name="sessionKey">string</param> /// <param name="taskid">string</param> /// <returns>string</returns> public string GetTrainingVideos(string sessionKey, string videoid, string subjectid) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); int count = 0; bool isValid = true; List<SteviArt.Common.DTO.TrainingVideo> lsttasks = new List<SteviArt.Common.DTO.TrainingVideo>(); if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetTrainingVideo"); if (!string.IsNullOrEmpty(videoid)) { db.AddInParameter(dbCommand, "@VideoID", DbType.Int32, Int32.Parse(videoid)); } else { db.AddInParameter(dbCommand, "@VideoID", DbType.Int32, null); } if (!string.IsNullOrEmpty(subjectid)) { db.AddInParameter(dbCommand, "@SubjectID", DbType.Int32, subjectid); } else { db.AddInParameter(dbCommand, "@SubjectID", DbType.Int32, null); } DataSet dsTask = db.ExecuteDataSet(dbCommand); if (dsTask.Tables.Count > 0) { DataTable tTask = dsTask.Tables[0]; foreach (DataRow dr in tTask.Rows) { SteviArt.Common.DTO.TrainingVideo task = new SteviArt.Common.DTO.TrainingVideo(); if (dr["TrainingVideoID"] != DBNull.Value) { task.TrainingVideoID = Int32.Parse(dr["TrainingVideoID"].ToString()); } if (dr["SubjectID"] != DBNull.Value) { task.SubjectID = Int32.Parse(dr["SubjectID"].ToString()); } if (dr["langid"] != DBNull.Value) { task.langid = Int32.Parse(dr["langid"].ToString()); } if (dr["VideoTitle"] != DBNull.Value) { task.VideoTitle = dr["VideoTitle"].ToString(); } if (dr["VideoURL"] != DBNull.Value) { task.VideoURL = dr["VideoURL"].ToString(); } if (dr["PointsEarned"] != DBNull.Value) { task.PointsEarned = Int32.Parse(dr["PointsEarned"].ToString()); } if (dr["AudioURL"] != DBNull.Value) { task.AudioURL = dr["AudioURL"].ToString(); } lsttasks.Add(task); count++; } } obj.ResultCode = "SUCCESS"; obj.ResultObjectJSON = Serializer.ObjectToJSON(lsttasks); obj.ResultObjectRecordCount = count; if (obj.ResultObjectRecordCount == 0) { obj.ResultMessage = "No records found."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetTask", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Get task types. /// </summary> /// <param name="sessionKey">string</param> /// <param name="taskid">string</param> /// <returns>string</returns> public string GetTaskType(string sessionKey, string taskypeid) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); bool isValid = true; List<TaskType> lsttasktypes = new List<TaskType>(); if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } int count = 0; if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetTaskType"); if (!string.IsNullOrEmpty(taskypeid)) { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, Int32.Parse(taskypeid)); } else { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, null); } DataSet dsTaskType = db.ExecuteDataSet(dbCommand); if(dsTaskType.Tables.Count > 0) { DataTable tTaskType = dsTaskType.Tables[0]; foreach(DataRow dr in tTaskType.Rows) { TaskType tasktype = new TaskType(); if (dr["TaskTypeID"] != DBNull.Value) { tasktype.TaskTypeID = Int32.Parse(dr["TaskTypeID"].ToString()); } if (dr["langid"] != DBNull.Value) { tasktype.langid = Int32.Parse(dr["langid"].ToString()); } if (dr["PointsEarned"] != DBNull.Value) { tasktype.PointsEarned = Int32.Parse(dr["PointsEarned"].ToString()); } if (dr["Title"] != DBNull.Value) { tasktype.Title = dr["Title"].ToString(); } if (dr["IconURL"] != DBNull.Value) { tasktype.IconURL = dr["IconURL"].ToString(); } if (dr["AudioURL"] != DBNull.Value) { tasktype.AudioURL = dr["AudioURL"].ToString(); } if (dr["MinQuota"] != DBNull.Value) { tasktype.MinQuota = Int32.Parse(dr["MinQuota"].ToString()); } lsttasktypes.Add(tasktype); count++; } } obj.ResultObjectJSON = Serializer.ObjectToJSON(lsttasktypes); obj.ResultCode = "SUCCESS"; obj.ResultObjectRecordCount = count; if (obj.ResultObjectRecordCount <= 0) { obj.ResultMessage = "No records found."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetTaskType", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Save video question and answers. /// </summary> /// <param name="sessionKey">string</param> /// <param name="videoid">string</param> /// <param name="questiontext">string</param> /// <param name="langid">string</param> /// <param name="answers">string</param> /// <param name="correctanswer">string</param> /// <param name="points">string</param> /// <returns>string</returns> public string SaveVideoQuestions(string sessionKey, string questionid, string videoid, string questiontext, string langid, string correctanswer, string audioURL, string points) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveVideoQuestions"); if (!string.IsNullOrEmpty(videoid)) { db.AddInParameter(dbCommand, "@QuestionID", DbType.Int32, Int32.Parse(questionid)); } else { db.AddInParameter(dbCommand, "@QuestionID", DbType.Int32, null); } if (!string.IsNullOrEmpty(videoid)) { db.AddInParameter(dbCommand, "@VideoID", DbType.Int32, Int32.Parse(videoid)); } else { db.AddInParameter(dbCommand, "@VideoID", DbType.Int32, null); } if (!string.IsNullOrEmpty(langid)) { db.AddInParameter(dbCommand, "@LangID", DbType.Int32, Int32.Parse(langid)); } else { db.AddInParameter(dbCommand, "@LangID", DbType.Int32, null); } db.AddInParameter(dbCommand, "@QuestionText", DbType.String, questiontext); db.AddInParameter(dbCommand, "@AudioURL", DbType.String, audioURL); db.AddInParameter(dbCommand, "@CorrectAnswer", DbType.String, correctanswer); db.AddInParameter(dbCommand, "@Points", DbType.Int32, Int32.Parse(points)); if (videoid == null) { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) { obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Questions have been saved successfully."; } else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Questions have been saved successfully."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveGroups", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Get persons list. /// </summary> /// <param name="sessionKey">string</param> /// <param name="personId">string</param> /// <param name="personTypeId">string</param> /// <param name="persongroupid">string</param> /// <param name="langid">string</param> /// <param name="firstname">string</param> /// <param name="lastname">string</param> /// <param name="username">string</param> /// <param name="password">string</param> /// <param name="email">string</param> /// <param name="countryid">string</param> /// <param name="stateid">string</param> /// <param name="telhome">string</param> /// <param name="telwork">string</param> /// <param name="telmobile">string</param> /// <param name="profilepicture">string</param> /// <param name="personcode">string</param> /// <param name="jobtitle">string</param> /// <returns>string</returns> public string SavePerson(string sessionKey, string personId, string personTypeId, string persongroupid, string langid, string firstname, string lastname, string username, string password, string email, string profilepicture, string audioURL, string devicetoken) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SavePerson"); db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionKey); if (personId != "0") { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, Int32.Parse(personId)); } else { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, null); } if (personTypeId != "0") { db.AddInParameter(dbCommand, "@PersonTypeID", DbType.Int32, Int32.Parse(personTypeId)); } else { db.AddInParameter(dbCommand, "@PersonTypeID", DbType.Int32, null); } if (persongroupid != "0") { db.AddInParameter(dbCommand, "@PersonGroupID", DbType.Int32, Int32.Parse(persongroupid)); } else { db.AddInParameter(dbCommand, "@PersonGroupID", DbType.Int32, null); } db.AddInParameter(dbCommand, "@PreferredLanguageID", DbType.Int32, Int32.Parse(langid)); db.AddInParameter(dbCommand, "@FirstName", DbType.String, firstname); db.AddInParameter(dbCommand, "@LastName", DbType.String, lastname); db.AddInParameter(dbCommand, "@Username", DbType.String, username); db.AddInParameter(dbCommand, "@Password", DbType.String, CalculateMD5Hash(password)); db.AddInParameter(dbCommand, "@Email", DbType.String, email); db.AddInParameter(dbCommand, "@ProfilePictureURL", DbType.String, profilepicture); db.AddInParameter(dbCommand, "@AudioURL", DbType.String, audioURL); db.AddInParameter(dbCommand, "@RegisteredToken", DbType.String, devicetoken); if (personId == "0") { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) obj.ResultCode = "SUCCESS"; else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SavePerson", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// This method creates the session for logged in user /// and returns all information needed to show on app /// and website landing page. /// </summary> /// <param name="userName">string</param> /// <param name="password">string</param> /// <param name="deviceToken">string</param> /// <returns>SessionResponseObject</returns> public string CreateSession(string emailID, string password, string deviceToken) { ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); SessionResponseObject sessionObject = new SessionResponseObject(); int count = 0; try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_CreateSession"); db.AddInParameter(dbCommand, "@Username", DbType.String, emailID); string password1 = BitConverter.ToString(SHA1.Create().ComputeHash(Encoding.Default.GetBytes(password + ""))).Replace("-", ""); db.AddInParameter(dbCommand, "@Password", DbType.String, BitConverter.ToString(SHA1.Create().ComputeHash(Encoding.Default.GetBytes(password + ""))).Replace("-", "")); db.AddInParameter(dbCommand, "@DeviceToken", DbType.String, deviceToken); DataSet dsAuth = db.ExecuteDataSet(dbCommand); if (dsAuth.Tables.Count > 0) { DataTable tUser = dsAuth.Tables[0]; Session session = new Session(); if (tUser.Rows.Count > 0) { if (tUser.Rows[0]["SessionKey"] != DBNull.Value) { session.SessionKey = tUser.Rows[0]["SessionKey"].ToString(); } if (tUser.Rows[0]["SessionID"] != DBNull.Value) { session.ID = Int32.Parse(tUser.Rows[0]["SessionID"].ToString()); } count++; } sessionObject.session = session; } if (dsAuth.Tables.Count > 1) { DataTable tUser = dsAuth.Tables[1]; Person person = new Person(); if (tUser.Rows.Count > 0) { if (tUser.Rows[0]["PersonID"] != DBNull.Value) { person.PersonID = Int32.Parse(tUser.Rows[0]["PersonID"].ToString()); } if (tUser.Rows[0]["PersonTypeID"] != DBNull.Value) { person.PersonTypeID = Int32.Parse(tUser.Rows[0]["PersonTypeID"].ToString()); } if (tUser.Rows[0]["PreferredLanguageID"] != DBNull.Value) { person.PreferredLanguageID = Int32.Parse(tUser.Rows[0]["PreferredLanguageID"].ToString()); } if (tUser.Rows[0]["FirstName"] != DBNull.Value) { person.FirstName = tUser.Rows[0]["FirstName"].ToString(); } if (tUser.Rows[0]["LastName"] != DBNull.Value) { person.LastName = tUser.Rows[0]["LastName"].ToString(); } if (tUser.Rows[0]["Username"] != DBNull.Value) { person.Username = tUser.Rows[0]["Username"].ToString(); } if (tUser.Rows[0]["ProfilePicPath"] != DBNull.Value) { person.ProfilePicPath = tUser.Rows[0]["ProfilePicPath"].ToString(); } if (tUser.Rows[0]["Email"] != DBNull.Value) { person.Email = tUser.Rows[0]["Email"].ToString(); } } sessionObject.person = person; } string sessionresponse = Serializer.ObjectToJSON(sessionObject); responseObject.ResultObjectJSON = sessionresponse; responseObject.ResultCode = "SUCCESS"; responseObject.ResultObjectRecordCount = count; if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "Invalid Email Id or Password"; } } catch (Exception exception) { sessionObject.ResultCode = "ERROR"; sessionObject.ResultMessage = "Invalid Email Id or Password"; CustomException exc = new CustomException(exception.ToString(), this.ToString(), "CreateSession", System.DateTime.Now); ExceptionManager.PublishException(exc); } return Serializer.ObjectToJSON(responseObject); }
/// <summary> /// Save person completed quiz. /// </summary> /// <param name="sessionKey">string</param> /// <param name="personcompletedquizid">string</param> /// <param name="helpvideoquizid">string</param> /// <param name="personid">string</param> /// <param name="completeddate">string</param> /// <returns>string</returns> public string SavePersonCompletedQuiz(string sessionKey, string personcompletedquizid, string helpvideoquizid, string personid, string completeddate) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SavePersonCompletedQuiz"); if (!string.IsNullOrEmpty(personcompletedquizid)) { db.AddInParameter(dbCommand, "@PersonCompletedQuizID", DbType.Int32, Int32.Parse(personcompletedquizid)); } else { db.AddInParameter(dbCommand, "@PersonCompletedQuizID", DbType.Int32, null); } if (!string.IsNullOrEmpty(helpvideoquizid)) { db.AddInParameter(dbCommand, "@HelpVideoQuizID", DbType.Int32, Int32.Parse(helpvideoquizid)); } else { db.AddInParameter(dbCommand, "@HelpVideoQuizID", DbType.Int32, null); } if (!string.IsNullOrEmpty(personid)) { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, Int32.Parse(personid)); } else { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, null); } if (!string.IsNullOrEmpty(completeddate)) { db.AddInParameter(dbCommand, "@CompletedDate", DbType.Int32, Convert.ToDateTime(completeddate)); } else { db.AddInParameter(dbCommand, "@CompletedDate", DbType.Int32, null); } if (personcompletedquizid == null) { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) { obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Completed quiz details have been saved successfully."; } else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Completed quiz details have been saved successfully."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SavePersonFeedback", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Get country list. /// </summary> /// <returns></returns> public string GetCountries() { string retValue = string.Empty; List<Country> lstcountry = new List<Country>(); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); int count = 0; try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetCountries"); DataSet dsCountries = db.ExecuteDataSet(dbCommand); if (dsCountries.Tables.Count > 0) { DataTable tCountry = dsCountries.Tables[0]; foreach (DataRow dr in tCountry.Rows) { Country country = new Country(); if (dr["CountryID"] != DBNull.Value) { country.CountryID = Int32.Parse(dr["CountryID"].ToString()); } if (dr["CountryName"] != DBNull.Value) { country.CountryName = dr["CountryName"].ToString(); } lstcountry.Add(country); count++; } responseObject.ResultCode = "SUCCESS"; responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstcountry); responseObject.ResultObjectRecordCount = count; if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No records found"; } } } catch (Exception ex) { CustomException exc = new CustomException(ex.ToString(), this.ToString(), "IsValidSession", System.DateTime.Now); ExceptionManager.PublishException(exc); } return Serializer.ObjectToJSON(responseObject); }
/// <summary> /// Save person types (roles) /// </summary> /// <param name="sessionKey">string</param> /// <param name="persontypeid">string</param> /// <param name="persontype">string</param> /// <returns>string</returns> public string SavePersonType(string sessionKey, string persontypeid, string persontype) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SavePersonType"); if (!string.IsNullOrEmpty(persontypeid)) { db.AddInParameter(dbCommand, "@PersonTypeID", DbType.Int32, Int32.Parse(persontypeid)); } else { db.AddInParameter(dbCommand, "@PersonTypeID", DbType.Int32, null); } db.AddInParameter(dbCommand, "@PersonType", DbType.String, persontype); if (persontypeid == null) { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) obj.ResultCode = "SUCCESS"; else obj.ResultCode = "ERROR"; obj.ResultObjectID = pId; obj.ResultObjectRecordCount = pId; if (obj.ResultObjectRecordCount <= 0) { obj.ResultMessage = "Unable to save group."; } } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SavePersonType", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <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); }
/// <summary> /// Log the error with class name and method name. /// </summary> /// <param name="LogText">string</param> /// <param name="ClassName">string</param> /// <param name="MethodName">string</param> private static void LogThis(String LogText, String ClassName, String MethodName) { CustomException log = new CustomException(LogText, ClassName, MethodName, System.DateTime.Now, "L"); SaveErrorMessage(log); }
/// <summary> /// Get video questions and answers based on /// video ID. /// </summary> /// <param name="sessionKey">string</param> /// <param name="videoid">string</param> /// <param name="langid">string</param> /// <returns></returns> public string GetHelpVideos(string sessionKey, string videoid) { string retValue = string.Empty; int count = 0; List<HelpVideo> lstvideos = 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_GetHelpVideos"); if (!string.IsNullOrEmpty(videoid)) { db.AddInParameter(dbCommand, "@VideoID", DbType.String, videoid); } else { db.AddInParameter(dbCommand, "@VideoID", DbType.String, null); } DataSet dsHelpContent = db.ExecuteDataSet(dbCommand); if (dsHelpContent.Tables.Count > 0) { DataTable tHelpContent = dsHelpContent.Tables[0]; foreach (DataRow dr in tHelpContent.Rows) { HelpVideo video = new HelpVideo(); if (dr["HelpVideoID"] != DBNull.Value) { video.HelpVideoID = Int32.Parse(dr["HelpVideoID"].ToString()); } if (dr["HelpModuleID"] != DBNull.Value) { video.HelpModuleID = Int32.Parse(dr["HelpModuleID"].ToString()); } if (dr["HelpModuleName"] != DBNull.Value) { video.HelpModuleName = dr["HelpModuleName"].ToString(); } if (dr["AudioURL"] != DBNull.Value) { video.AudioURL = dr["AudioURL"].ToString(); } if (dr["VideoTitle"] != DBNull.Value) { video.VideoTitle = dr["VideoTitle"].ToString(); } if (dr["VideoURL"] != DBNull.Value) { video.VideoURL = dr["VideoURL"].ToString(); } lstvideos.Add(video); count++; } } responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstvideos); 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(), "GetQuestions", System.DateTime.Now); ExceptionManager.PublishException(exc); } } return Serializer.ObjectToJSON(responseObject); }
/// <summary> /// Get state list. /// </summary> /// <returns></returns> public string GetStates(string countryid) { string retValue = string.Empty; List<State> lststate = new List<State>(); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); int count = 0; try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetStates"); db.AddInParameter(dbCommand, "@CountryID", DbType.Int32, Int32.Parse(countryid)); DataSet dsStates = db.ExecuteDataSet(dbCommand); if (dsStates.Tables.Count > 0) { DataTable tState = dsStates.Tables[0]; foreach (DataRow dr in tState.Rows) { State state = new State(); if (dr["StateID"] != DBNull.Value) { state.StateID = Int32.Parse(dr["StateID"].ToString()); } if (dr["StateName"] != DBNull.Value) { state.StateName = dr["StateName"].ToString(); } lststate.Add(state); count++; } } responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lststate); 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(), "GetStates", System.DateTime.Now); ExceptionManager.PublishException(exc); } return Serializer.ObjectToJSON(responseObject); }
public string SavePrivateProject(string sessionKey, string privateprojectid, string personid, string isenabled, string videofilename, string photourl, string approvalstatusid) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (approvalstatusid == "0") { approvalstatusid = "4"; } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SavePrivateProject"); if (privateprojectid != "0") { db.AddInParameter(dbCommand, "@PrivateProjectID", DbType.Int32, Int32.Parse(privateprojectid)); } else { db.AddInParameter(dbCommand, "@PrivateProjectID", DbType.Int32, null); } if (!string.IsNullOrEmpty(personid)) { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, Int32.Parse(personid)); } else { db.AddInParameter(dbCommand, "@PersonID", DbType.Int32, null); } if (!string.IsNullOrEmpty(approvalstatusid)) { db.AddInParameter(dbCommand, "@ApprovalStatusID", DbType.Int32, Int32.Parse(approvalstatusid)); } else { db.AddInParameter(dbCommand, "@ApprovalStatusID", DbType.Int32, null); } if (!string.IsNullOrEmpty(isenabled)) { db.AddInParameter(dbCommand, "@IsEnabled", DbType.Boolean, Convert.ToBoolean(isenabled)); } else { db.AddInParameter(dbCommand, "@IsEnabled", DbType.Boolean, null); } db.AddInParameter(dbCommand, "@VideoFileName", DbType.String, videofilename); db.AddInParameter(dbCommand, "@VideoURL", DbType.String, photourl); if (privateprojectid == string.Empty || privateprojectid == "0") { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) { obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Private Project have been enabled successfully."; } else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Private Project have been saved successfully."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SavePersonFeedback", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <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); }
/// <summary> /// save tasks /// </summary> /// <param name="sessionKey"></param> /// <param name="helpcotentid"></param> /// <param name="subjectid"></param> /// <param name="langid"></param> /// <param name="title"></param> /// <param name="htmlcontent"></param> /// <param name="audioURL"></param> /// <returns></returns> public string SaveTask(string sessionKey, string taskid, string tasktypeid, string iscompleted, string lastcompletiondate, string duedate, string assignedtopersonid, string isnotifiedafterassigned, string assignedbypersonid, string percentcomplete, string langid, string title, string audiourl, string numbercompleted) { string retValue = string.Empty; ResponseObjectForAnything obj = new ResponseObjectForAnything(); Int32 pId = -1; bool isValid = true; if (!string.IsNullOrEmpty(sessionKey)) { isValid = IsValidSession(sessionKey); } if (isValid) { try { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveTask"); if (!string.IsNullOrEmpty(taskid)) { db.AddInParameter(dbCommand, "@TaskID", DbType.Int32, Int32.Parse(taskid)); } else { db.AddInParameter(dbCommand, "@TaskID", DbType.Int32, null); } if (!string.IsNullOrEmpty(tasktypeid)) { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, Int32.Parse(tasktypeid)); } else { db.AddInParameter(dbCommand, "@TaskTypeID", DbType.Int32, null); } if (!string.IsNullOrEmpty(iscompleted)) { db.AddInParameter(dbCommand, "@IsCompleted", DbType.Boolean, Convert.ToBoolean(iscompleted)); } else { db.AddInParameter(dbCommand, "@IsCompleted", DbType.Boolean, null); } if (!string.IsNullOrEmpty(lastcompletiondate)) { db.AddInParameter(dbCommand, "@LastCompletionDate", DbType.DateTime, DateTime.ParseExact(lastcompletiondate,"yyyy-MM-dd", DateTimeFormatInfo.CurrentInfo)); } else { db.AddInParameter(dbCommand, "@LastCompletionDate", DbType.DateTime, null); } if (!string.IsNullOrEmpty(duedate)) { db.AddInParameter(dbCommand, "@DueDate", DbType.DateTime, Convert.ToDateTime(duedate)); } else { db.AddInParameter(dbCommand, "@DueDate", DbType.DateTime, null); } if (!string.IsNullOrEmpty(assignedtopersonid)) { db.AddInParameter(dbCommand, "@AssignedToPersonID", DbType.Int32, Int32.Parse(assignedtopersonid)); } else { db.AddInParameter(dbCommand, "@AssignedToPersonID", DbType.Int32, null); } if (!string.IsNullOrEmpty(isnotifiedafterassigned)) { db.AddInParameter(dbCommand, "@IsNotifiedAfterAssigned", DbType.Boolean, Convert.ToBoolean(isnotifiedafterassigned)); } else { db.AddInParameter(dbCommand, "@IsNotifiedAfterAssigned", DbType.Boolean, false); } if (!string.IsNullOrEmpty(assignedbypersonid)) { db.AddInParameter(dbCommand, "@AssignedByPersonID", DbType.Int32, Int32.Parse(assignedbypersonid)); } else { db.AddInParameter(dbCommand, "@AssignedByPersonID", DbType.Int32, null); } if (!string.IsNullOrEmpty(numbercompleted)) { db.AddInParameter(dbCommand, "@NumberCompleted", DbType.Int32, Int32.Parse(numbercompleted)); } else { db.AddInParameter(dbCommand, "@NumberCompleted", DbType.Boolean, 0); } if (!string.IsNullOrEmpty(langid)) { db.AddInParameter(dbCommand, "@langid", DbType.Int32, Int32.Parse(langid)); } else { db.AddInParameter(dbCommand, "@langid", DbType.Boolean, null); } db.AddInParameter(dbCommand, "@Title", DbType.String, title); db.AddInParameter(dbCommand, "@AudioURL", DbType.String, audiourl); if (taskid == null) { pId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString()); obj.ResultObjectID = pId; if (pId > 0) { obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Task has been saved successfully."; } else obj.ResultCode = "ERROR"; } else { db.ExecuteNonQuery(dbCommand); obj.ResultCode = "SUCCESS"; obj.ResultMessage = "Task has been saved successfully."; } } catch (Exception ex) { obj.ResultCode = "ERROR"; obj.ResultMessage = ex.Message.ToString(); CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveGroups", System.DateTime.Now); ExceptionManager.PublishException(exc); } } retValue = Serializer.ObjectToJSON(obj); return retValue; }
/// <summary> /// Get department list. /// </summary> /// <param name="sessionKey">string</param> /// <param name="departmentid">string</param> /// <returns>string</returns> public string GetPrivateProject(string sessionKey, string privateprojectid, string approvalstatusid) { string retValue = string.Empty; List<PrivateProject> lstdepartment = new List<PrivateProject>(); 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_GetPrivateProject"); if (!string.IsNullOrEmpty(privateprojectid)) { db.AddInParameter(dbCommand, "@PrivateProjectID", DbType.Int32, Int32.Parse(privateprojectid)); } else { db.AddInParameter(dbCommand, "@PrivateProjectID", DbType.Int32, null); } if (!string.IsNullOrEmpty(approvalstatusid)) { db.AddInParameter(dbCommand, "@ApprovalStatusID", DbType.Int32, Int32.Parse(approvalstatusid)); } else { db.AddInParameter(dbCommand, "@ApprovalStatusID", DbType.Int32, null); } DataSet dsStates = db.ExecuteDataSet(dbCommand); if (dsStates.Tables.Count > 0) { DataTable tState = dsStates.Tables[0]; foreach (DataRow dr in tState.Rows) { PrivateProject department = new PrivateProject(); if (dr["PrivateProjectID"] != DBNull.Value) { department.PrivateProjectID = Int32.Parse(dr["PrivateProjectID"].ToString()); } if (dr["PersonID"] != DBNull.Value) { department.PersonID = Int32.Parse(dr["PersonID"].ToString()); } if (dr["ApprovalStatusID"] != DBNull.Value) { department.ApprovalStatusID = Int32.Parse(dr["ApprovalStatusID"].ToString()); } if (dr["ApprovalStatusName"] != DBNull.Value) { department.ApprovalStatusName = dr["ApprovalStatusName"].ToString(); } if (dr["VideoFileName"] != DBNull.Value) { department.VideoFileName = dr["VideoFileName"].ToString(); } if (dr["PhotoURL"] != DBNull.Value) { department.PhotoURL = dr["PhotoURL"].ToString(); } if (dr["CreatedDate"] != DBNull.Value) { department.CreatedDate = Convert.ToDateTime(dr["CreatedDate"].ToString()); } if (dr["IsEnabled"] != DBNull.Value) { department.IsEnabled = Convert.ToBoolean(dr["IsEnabled"].ToString()); } lstdepartment.Add(department); 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); }