/// <summary>
        /// Check for invalid file extension, returns auto generated file name
        /// </summary>
        /// <param name="pFileName">Original file name</param>
        /// <returns>auto generated file name</returns>
        public string ValidateFile(string pFileName)
        {
            string strFileName = String.Empty;

            if (!String.IsNullOrEmpty(pFileName) &&
                !pFileName.ToLower().EndsWith(".exe") &&
                !pFileName.ToLower().EndsWith(".dll"))
            {
                strFileName += IDGenerator.GetStringGUID();
                if (pFileName.LastIndexOf(".") > 0)
                {
                    strFileName += pFileName.Substring(pFileName.LastIndexOf(".") - 1);
                }
            }
            return(strFileName);
        }
        /// <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);
        }
示例#3
0
        /// <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);
        }