/// <summary> /// private method to support both Add and Edit content module tracking transactions. /// </summary> /// <param name="pEntContModTracking"></param> /// <param name="pUpdateMode"></param> /// <returns>ContentModuleTracking object</returns> private ContentModuleTrackingUpdateResult Update(ContentModuleTracking pEntContModTracking, string pStrUpdateMode) { _sqlObject = new SQLObject(); sqlcmd = new SqlCommand(); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.CommandText = Schema.ContentModuleTracking.PROC_UPDATE_CONTENT_MODULE_TRACKING; _strConnString = _sqlObject.GetClientDBConnString(pEntContModTracking.ClientId); //if (pStrUpdateMode == Schema.Common.VAL_INSERT_MODE) //{ // sqlpara = new SqlParameter(Schema.Common.PARA_UPDATE_MODE, Schema.Common.VAL_INSERT_MODE); //} //else // sqlpara = new SqlParameter(Schema.Common.PARA_UPDATE_MODE, Schema.Common.VAL_UPDATE_MODE); //sqlcmd.Parameters.Add(sqlpara); if (string.IsNullOrEmpty(pEntContModTracking.ID)) { pEntContModTracking.ID = pEntContModTracking.LearnerId + IDGenerator.GetUniqueKey(16); } sqlpara = new SqlParameter(Schema.Common.PARA_CONTENTTRACKID, pEntContModTracking.ID); sqlcmd.Parameters.Add(sqlpara); sqlpara = new SqlParameter(Schema.ContentModule.PARA_CONTENT_MODULE_ID, pEntContModTracking.ContentModuleId); sqlcmd.Parameters.Add(sqlpara); //sqlpara = new SqlParameter(Schema.Common.PARA_IS_BULK_MARK_COMPLETED, pEntContModTracking.IsBulkMarkCompleted); //sqlcmd.Parameters.Add(sqlpara); sqlpara = new SqlParameter(Schema.Learner.PARA_LEARNERID, pEntContModTracking.UserID); sqlcmd.Parameters.Add(sqlpara); //if (!string.IsNullOrEmpty(pEntContModTracking.SessionId)) //{ // sqlcmd.Parameters.Add(new SqlParameter(Schema.Learner.PARA_SESSION_ID, pEntContModTracking.SessionId)); //} //sqlcmd.Parameters.Add(new SqlParameter(Schema.ContentModuleTracking.PARA_EXTEND_EXPIRATION_MINUTES, pEntContModTracking.ExtendExpirationMinutes)); //sqlcmd.Parameters.Add(new SqlParameter(Schema.ContentModuleTracking.PARA_CHECK_EXPIRED_SESSION, pEntContModTracking.CheckExpiredSession)); if (DateTime.MinValue.CompareTo(pEntContModTracking.DateOfStart) < 0) { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_DATE_OF_START, pEntContModTracking.DateOfStart); } else { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_DATE_OF_START, null); } sqlcmd.Parameters.Add(sqlpara); if (pEntContModTracking.DateOfCompletion != null) { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_DATE_OF_COMPLETION, pEntContModTracking.DateOfCompletion); } else { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_DATE_OF_COMPLETION, null); } sqlcmd.Parameters.Add(sqlpara); sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_TOTAL_NO_OF_PAGES, pEntContModTracking.TotalNoOfPages); sqlcmd.Parameters.Add(sqlpara); sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_NO_OF_PAGES_COMPLETED, pEntContModTracking.NoOfPagesCompleted); sqlcmd.Parameters.Add(sqlpara); sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_COMPLETION_STATUS, pEntContModTracking.CompletionStatus.ToString()); sqlcmd.Parameters.Add(sqlpara); if (!string.IsNullOrEmpty(pEntContModTracking.Score)) { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_SCORE, pEntContModTracking.Score); } else { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_SCORE, null); } sqlcmd.Parameters.Add(sqlpara); if (!string.IsNullOrEmpty(pEntContModTracking.UserDataXML)) { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_USER_DATA_XML, pEntContModTracking.UserDataXML); } else { sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_USER_DATA_XML, null); } sqlcmd.Parameters.Add(sqlpara); //if (!string.IsNullOrEmpty(pEntContModTracking.Score)) // sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_SCORE, pEntContModTracking.Score); //else // sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_SCORE, null); //sqlcmd.Parameters.Add(sqlpara); //if (!string.IsNullOrEmpty(pEntContModTracking.MarkedCompletedById)) // sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_MARKED_COMPLETED_BY_ID, pEntContModTracking.MarkedCompletedById); //else // sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_MARKED_COMPLETED_BY_ID, null); //sqlcmd.Parameters.Add(sqlpara); //if (!string.IsNullOrEmpty(pEntContModTracking.ScannedCertificationFileName)) // sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_SCANNED_CERTIFICATION_FILE_NAME, pEntContModTracking.ScannedCertificationFileName); //else // sqlpara = new SqlParameter(Schema.ContentModuleTracking.PARA_SCANNED_CERTIFICATION_FILE_NAME, null); //sqlcmd.Parameters.Add(sqlpara); //sqlcmd.Parameters.AddWithValue(Schema.ContentModuleTracking.PARA_ACTIVITY_NAME, null); //sqlcmd.Parameters.AddWithValue(Schema.ContentModuleTracking.PARA_USER_FIRST_LAST_NAME, null); //sqlcmd.Parameters.AddWithValue(Schema.ContentModuleTracking.PARA_REVIEWER_COMMENTS, pEntContModTracking.ReviewComments); //sqlcmd.Parameters.AddWithValue(Schema.ContentModuleTracking.PARA_REGION_VIEW_INFO, pEntContModTracking.RegionViewInfo); //sqlcmd.Parameters.AddWithValue(Schema.ContentModuleTracking.PARA_IS_FOR_ADMIN_PREVIEW, pEntContModTracking.IsForAdminPreview); ContentModuleTrackingUpdateResult result = null; using (SqlConnection conn = new SqlConnection(_strConnString)) { conn.Open(); sqlcmd.Connection = conn; using (var reader = sqlcmd.ExecuteReader()) { if (reader.HasRows) { reader.Read(); result = new ContentModuleTrackingUpdateResult(); //reader.SetValueForColumn<string>("PreviousCompletionStatus", s => result.PreviousCompletionStatus = s); //reader.SetValueForColumn<string>("CurrentCompletionStatus", s => result.CurrentCompletionStatus = s); //reader.SetValueForColumn<string>("LearnerId", s => result.LearnerId = s); } } } return(result); }
/// <summary> /// Bulk Update /// </summary> /// <param name="pEntListTracking"></param> /// <param name="pIsBulkMarkCompleted"></param> /// <returns></returns> public List <ContentModuleTracking> BulkUpdate(List <ContentModuleTracking> pEntListTracking, bool pIsBulkMarkCompleted) { _sqlObject = new SQLObject(); List <ContentModuleTracking> entListTracking = new List <ContentModuleTracking>(); int iBatchSize = 0; SqlCommand _sqlcmd = null; SqlConnection _sqlcon = null; SqlDataAdapter _sqladapter = null; try { if (pEntListTracking.Count > 0) { _dtable = new DataTable(); _dtable.Columns.Add(Schema.ContentModuleTracking.COL_ATTEMPT_ID); _dtable.Columns.Add(Schema.ContentModule.COL_CONTENT_MODULE_ID); _dtable.Columns.Add(Schema.Learner.COL_USER_ID); _dtable.Columns.Add(Schema.ContentModuleTracking.COL_DATE_OF_COMPLETION); _dtable.Columns.Add(Schema.ContentModuleTracking.COL_MARKED_COMPLETED_BY_ID); _dtable.Columns.Add(Schema.ContentModuleTracking.COL_COMPLETION_STATUS); _dtable.Columns.Add(Schema.ContentModuleTracking.COL_REVIEWER_COMMENTS); _dtable.Columns.Add(Schema.ContentModuleTracking.COL_SCANNED_CERTIFICATION_FILE_NAME); _dtable.Columns.Add(Schema.Common.COL_IS_BULK_MARK_COMPLETED); foreach (ContentModuleTracking entAttempt in pEntListTracking) { DataRow drow = _dtable.NewRow(); if (String.IsNullOrEmpty(_strConnString)) { _strConnString = _sqlObject.GetClientDBConnString(entAttempt.ClientId); } if (string.IsNullOrEmpty(entAttempt.ID)) { entAttempt.ID = IDGenerator.GetStringGUID(); } drow[Schema.ContentModuleTracking.COL_ATTEMPT_ID] = entAttempt.ID; drow[Schema.ContentModule.COL_CONTENT_MODULE_ID] = entAttempt.ContentModuleId; drow[Schema.Learner.COL_USER_ID] = entAttempt.UserID; drow[Schema.ContentModuleTracking.COL_DATE_OF_COMPLETION] = entAttempt.DateOfCompletion; drow[Schema.ContentModuleTracking.COL_MARKED_COMPLETED_BY_ID] = entAttempt.MarkedCompletedById; drow[Schema.ContentModuleTracking.COL_COMPLETION_STATUS] = entAttempt.CompletionStatus.ToString(); drow[Schema.ContentModuleTracking.COL_REVIEWER_COMMENTS] = entAttempt.ReviewComments; drow[Schema.ContentModuleTracking.COL_SCANNED_CERTIFICATION_FILE_NAME] = entAttempt.ScannedCertificationFileName; drow[Schema.Common.COL_IS_BULK_MARK_COMPLETED] = entAttempt.IsBulkMarkCompleted; iBatchSize = iBatchSize + 1; _dtable.Rows.Add(drow); entListTracking.Add(entAttempt); } if (_dtable.Rows.Count > 0) { _sqlcmd = new SqlCommand(); _sqlcmd.CommandText = Schema.ContentModuleTracking.PROC_UPDATE_MARK_COMPLETED; _sqlcmd.CommandType = CommandType.StoredProcedure; _sqlcon = new SqlConnection(_strConnString); _sqlcmd.Connection = _sqlcon; _sqlcmd.Parameters.Add(Schema.ContentModuleTracking.PARA_ATTEMPT_ID, SqlDbType.VarChar, 100, Schema.ContentModuleTracking.COL_ATTEMPT_ID); _sqlcmd.Parameters.Add(Schema.ContentModule.PARA_CONTENT_MODULE_ID, SqlDbType.VarChar, 100, Schema.ContentModule.COL_CONTENT_MODULE_ID); _sqlcmd.Parameters.Add(Schema.Learner.PARA_USER_ID, SqlDbType.VarChar, 100, Schema.Learner.COL_USER_ID); _sqlcmd.Parameters.Add(Schema.ContentModuleTracking.PARA_COMPLETED_DATE, SqlDbType.DateTime, 20, Schema.ContentModuleTracking.COL_DATE_OF_COMPLETION); _sqlcmd.Parameters.Add(Schema.ContentModuleTracking.PARA_MARKED_COMPLETED_BY_ID, SqlDbType.VarChar, 100, Schema.ContentModuleTracking.COL_MARKED_COMPLETED_BY_ID); _sqlcmd.Parameters.Add(Schema.ContentModuleTracking.PARA_COMPLETION_STATUS, SqlDbType.NVarChar, 100, Schema.ContentModuleTracking.COL_COMPLETION_STATUS); _sqlcmd.Parameters.Add(Schema.ContentModuleTracking.PARA_REVIEWER_COMMENTS, SqlDbType.NVarChar, 2000, Schema.ContentModuleTracking.COL_REVIEWER_COMMENTS); _sqlcmd.Parameters.Add(Schema.ContentModuleTracking.PARA_SCANNED_CERTIFICATION_FILE_NAME, SqlDbType.VarChar, 500, Schema.ContentModuleTracking.COL_SCANNED_CERTIFICATION_FILE_NAME); _sqlcmd.Parameters.Add(Schema.Common.PARA_IS_BULK_MARK_COMPLETED, SqlDbType.Bit, 1, Schema.Common.COL_IS_BULK_MARK_COMPLETED); _sqladapter = new SqlDataAdapter(); _sqladapter.InsertCommand = _sqlcmd; _sqladapter.InsertCommand.CommandTimeout = 0; _sqladapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None; _sqladapter.UpdateBatchSize = iBatchSize; _sqladapter.Update(_dtable); _sqladapter.Dispose(); } } } catch (Exception expCommon) { //_expCustom = new CustomException(_strMessageId, CustomException.WhoCallsMe(), ExceptionSeverityLevel.Critical, expCommon, true); //throw _expCustom; } return(entListTracking); }
/// <summary> /// Update /// </summary> /// <param name="pEntCourseConfiguration"></param> /// <param name="pUpdateMode"></param> /// <returns></returns> private CourseConfiguration Update(CourseConfiguration pEntCourseConfiguration, string pUpdateMode) { int iRows = 0; _sqlObject = new SQLObject(); _sqlcmd = new SqlCommand(); _sqlcmd.CommandText = Schema.CourseConfiguration.PROC_UPDATE_COURSE_CONFIGURATION; try { _strConnString = _sqlObject.GetClientDBConnString(pEntCourseConfiguration.ClientId); if (pUpdateMode == Schema.Common.VAL_INSERT_MODE) { _sqlpara = new SqlParameter(Schema.Common.PARA_UPDATE_MODE, Schema.Common.VAL_INSERT_MODE); pEntCourseConfiguration.ID = IDGenerator.GetStringGUID(); } else { _sqlpara = new SqlParameter(Schema.Common.PARA_UPDATE_MODE, Schema.Common.VAL_UPDATE_MODE); } _sqlcmd.Parameters.Add(_sqlpara); // Allowresize Parameter _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_ALLOW_RESIZE, pEntCourseConfiguration.AllowResize); _sqlcmd.Parameters.Add(_sqlpara); // AllowResize paramater _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_ALLOW_SCROLL, pEntCourseConfiguration.AllowScroll); _sqlcmd.Parameters.Add(_sqlpara); // Avpath paramater if (!string.IsNullOrEmpty(pEntCourseConfiguration.AVPath)) { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_AV_PATH, pEntCourseConfiguration.AVPath); } else { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_AV_PATH, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); // ClientID paramater if (!string.IsNullOrEmpty(pEntCourseConfiguration.ClientId)) { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_CLIENT_ID, pEntCourseConfiguration.ClientId); } else { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_CLIENT_ID, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); // Course launch New Window paramater _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_LAUNCH_NEW_WINDOW, pEntCourseConfiguration.CourseLaunchNewWindow); _sqlcmd.Parameters.Add(_sqlpara); // Course Launch Same Window paramater _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_LAUNCH_SAME_WINDOW, pEntCourseConfiguration.CourseLaunchSameWindow); _sqlcmd.Parameters.Add(_sqlpara); // Course Window Height paramater if (pEntCourseConfiguration.CourseWindowHeight != 0) { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_WINDOW_HEIGHT, pEntCourseConfiguration.CourseWindowHeight); } else { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_WINDOW_HEIGHT, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); // Course Window Width paramater if (pEntCourseConfiguration.CourseWindowWidth != 0) { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_WINDOW_WIDTH, pEntCourseConfiguration.CourseWindowWidth); } else { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_WINDOW_WIDTH, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); // Is Course Session No Expiry paramater _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_IS_COURSE_SESSION_NO_EXPIRY, pEntCourseConfiguration.IsCourseSessionNoExpiry); _sqlcmd.Parameters.Add(_sqlpara); // Mastery Score paramater if (pEntCourseConfiguration.MasteryScore != 0) { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_MASTERY_SCORE, pEntCourseConfiguration.MasteryScore); } else { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_MASTERY_SCORE, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); // Max File upload Size paramater if (pEntCourseConfiguration.MaxFileUploadSizeMB != 0) { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_MAX_FILE_UPLOAD_SIZE_MB, pEntCourseConfiguration.MaxFileUploadSizeMB); } else { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_MAX_FILE_UPLOAD_SIZE_MB, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); // Course Question Response Tracking paramater _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_QUESTION_RESPONSE_TRACKING, pEntCourseConfiguration.QuestionResponseTracking); _sqlcmd.Parameters.Add(_sqlpara); // Course Launch Same Window paramater _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_SCORE_TRACKING, pEntCourseConfiguration.ScoreTracking); _sqlcmd.Parameters.Add(_sqlpara); // Last Modified by ID paramater if (!string.IsNullOrEmpty(pEntCourseConfiguration.LastModifiedById)) { _sqlpara = new SqlParameter(Schema.Common.PARA_MODIFIED_BY, pEntCourseConfiguration.LastModifiedById); } else { _sqlpara = new SqlParameter(Schema.Common.PARA_MODIFIED_BY, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); // Course Configuration ID paramater if (!string.IsNullOrEmpty(pEntCourseConfiguration.ID)) { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_CONFIGURATION_ID, pEntCourseConfiguration.ID); } else { _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_COURSE_CONFIGURATION_ID, System.DBNull.Value); } _sqlcmd.Parameters.Add(_sqlpara); //-aw 6/15/2011 Added course protocol _sqlpara = new SqlParameter(Schema.CourseConfiguration.PARA_PROTOCOL, pEntCourseConfiguration.Protocol); _sqlcmd.Parameters.Add(_sqlpara); iRows = _sqlObject.ExecuteNonQuery(_sqlcmd, _strConnString); } catch (Exception expCommon) { //expCommon = new CustomException(_strMessageId, CustomException.WhoCallsMe(), ExceptionSeverityLevel.Critical, expCommon, true); throw expCommon; } return(pEntCourseConfiguration); }