} // GetModule /// <summary> /// Create a new module. /// </summary> /// <returns>Module ID for the created module.</returns> /// <param name="courseID">Parent Course ID</param> /// <param name="name">name of the module</param> /// <param name="description">Description of the module</param> /// <param name="active">Active flag for the new module</param> /// <param name="createdByUserID">Currently logged on user creating the module</param> public int Create(int courseID, string name, string description, bool active, int createdByUserID) { using (StoredProcedure sp = new StoredProcedure("prcModule_Create", StoredProcedure.CreateInputParam("@courseID", SqlDbType.Int, courseID), StoredProcedure.CreateInputParam("@name", SqlDbType.NVarChar, 100, name), StoredProcedure.CreateInputParam("@description", SqlDbType.NVarChar, 1000, description), StoredProcedure.CreateInputParam("@active", SqlDbType.Bit, active), StoredProcedure.CreateInputParam("@userID", SqlDbType.Int, createdByUserID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intError; string strMessage; rdr.Read(); intError = rdr.GetInt32(0); strMessage = rdr.GetString(1); rdr.Close(); if (intError == 4) { throw new BusinessServiceException(ResourceManager.GetString("prcModule_Create.4")); } else { return(int.Parse(strMessage)); } } } // Create
} // Update /// <summary> /// Creates a course. /// </summary> /// <remarks> /// Assumptions: None /// Notes: /// Author: Gavin Buddis /// Date: 03/03/2004 /// Changes: /// </remarks> /// <param name="name">Name of the course</param> /// <param name="notes">Notes for this course</param> /// <param name="active">Is this course active</param> /// <param name="createdByUserID">Id of the user creatig this course</param> public int Create(string name, string notes, bool active, int createdByUserID) { int intCourseID = 0; SqlParameter paramKey = StoredProcedure.CreateOutputParam("@intCourseID", SqlDbType.Int, 4, intCourseID); using (StoredProcedure sp = new StoredProcedure("prcCourse_Create", paramKey, StoredProcedure.CreateInputParam("@name", SqlDbType.NVarChar, 100, name), StoredProcedure.CreateInputParam("@notes", SqlDbType.NVarChar, 1000, notes), StoredProcedure.CreateInputParam("@active", SqlDbType.Bit, active), StoredProcedure.CreateInputParam("@userID", SqlDbType.Int, createdByUserID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intErrorNumber; // Holds the error number return from the stored procedure. string strErrorMessage; // Holds the error message return from the stored procedure. //1. Get the response. rdr.Read(); intErrorNumber = rdr.GetInt32(0); strErrorMessage = rdr.GetString(1); //2. Close the reader. rdr.Close(); //4. Throw the required exception if error number is not 0. switch (intErrorNumber) { case 0: // Succeeded. { intCourseID = (int)paramKey.Value; return(intCourseID); } case 4: // Unique constraint. { throw new UniqueViolationException(String.Format(ResourceManager.GetString("prcCourse_Create.4"), name)); } case 5: // Parameter Exception. { throw new ParameterException(strErrorMessage); } case 6: // Permission Denied. { throw new PermissionDeniedException(strErrorMessage); } default: // Whatever is left. { throw new BusinessServiceException(strErrorMessage); } } } } // Create
} // Add /// <summary> /// This method updates an existing link within the salt database. /// </summary> /// <remarks> /// Assumptions:None /// Notes: /// Author: Peter Kneale, 03/03/04 /// Changes: /// </remarks> /// <param name="linkID">The id of the existing link</param> /// <param name="caption">The updated caption.</param> /// <param name="url">The updated URL.</param> /// <param name="showDisclaimer">Whether to show the disclaimed or not.</param> /// <param name="userID">The user ID of the user performing the update.</param> public void Update(SqlInt32 linkID, SqlString caption, SqlString url, SqlBoolean showDisclaimer, SqlInt32 userID, int linkOrder) { using (StoredProcedure sp = new StoredProcedure("prcLink_Update", StoredProcedure.CreateInputParam("@linkID", SqlDbType.Int, linkID), StoredProcedure.CreateInputParam("@caption", SqlDbType.NVarChar, 100, caption), StoredProcedure.CreateInputParam("@url", SqlDbType.NVarChar, 200, url), StoredProcedure.CreateInputParam("@showDisclaimer", SqlDbType.Bit, showDisclaimer), StoredProcedure.CreateInputParam("@userID", SqlDbType.Int, userID), StoredProcedure.CreateInputParam("@LinkOrder", SqlDbType.Int, linkOrder) )) { SqlDataReader rdr = sp.ExecuteReader(); int intErrorNumber; // Holds the error number return from the stored procedure. string strErrorMessage; // Holds the error message return from the stored procedure. //1. Get the response. rdr.Read(); intErrorNumber = rdr.GetInt32(0); strErrorMessage = rdr.GetString(1); //2. Close the reader. rdr.Close(); //4. Throw the required exception if error number is not 0. switch (intErrorNumber) { case 0: // Succeeded. { break; } case 1: { throw new RecordNotFoundException(ResourceManager.GetString("cmnRecordNotExist")); } case 4: // Unique constraint. { throw new UniqueViolationException(String.Format(ResourceManager.GetString("prcLink_Update.4"), caption)); } case 5: // Parameter Exception. { throw new ParameterException(strErrorMessage); } default: // Whatever is left. { throw new BusinessServiceException(strErrorMessage); } } } } // Update
} // DecrementModuleSequence /// <summary> /// Updates a course details. If the status is changed, there will be validation checking. /// </summary> /// <remarks> /// Assumptions: None /// Notes: /// Author: Gavin Buddis /// Date: 03/03/2004 /// Changes: /// </remarks> /// <param name="courseID">ID of the course</param> /// <param name="name">Course Name</param> /// <param name="notes">Course Notes</param> /// <param name="active">Is Course Active</param> /// <param name="updatedByUserID">User ID of user preforming the update</param> public void Update(int courseID, string name, string notes, bool active, int updatedByUserID) { using (StoredProcedure sp = new StoredProcedure("prcCourse_Update", StoredProcedure.CreateInputParam("@courseID", SqlDbType.Int, courseID), StoredProcedure.CreateInputParam("@name", SqlDbType.NVarChar, 100, name), StoredProcedure.CreateInputParam("@notes", SqlDbType.NVarChar, 1000, notes), StoredProcedure.CreateInputParam("@active", SqlDbType.Bit, active), StoredProcedure.CreateInputParam("@userID", SqlDbType.Int, updatedByUserID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intErrorNumber; // Holds the error number return from the stored procedure. string strErrorMessage; // Holds the error message return from the stored procedure. //1. Get the response. rdr.Read(); intErrorNumber = rdr.GetInt32(0); strErrorMessage = rdr.GetString(1); //2. Close the reader. rdr.Close(); //4. Throw the required exception if error number is not 0. switch (intErrorNumber) { case 0: // Succeeded. { break; } case 1: // PK not found. { throw new RecordNotFoundException(strErrorMessage); } case 4: // Unique constraint. { throw new UniqueViolationException(String.Format(ResourceManager.GetString("prcCourse_Create.4"), name)); } case 5: // Parameter Exception. { throw new ParameterException(strErrorMessage); } default: // Whatever is left. { throw new BusinessServiceException(strErrorMessage); } } } } // Update
} // GetList /// <summary> /// Update an organisations configuration value /// </summary> /// <param name="organisationID">organisations id</param> /// <param name="name">name of the key</param> /// <param name="value">value of the key</param> /// <param name="description">Description of key</param> public void Update(int organisationID, string name, string description, string value) { using (StoredProcedure sp = new StoredProcedure("prcOrganisationConfig_Update", StoredProcedure.CreateInputParam("@OrganisationID", SqlDbType.Int, organisationID), StoredProcedure.CreateInputParam("@Name", SqlDbType.NVarChar, name), StoredProcedure.CreateInputParam("@Description", SqlDbType.NVarChar, description), StoredProcedure.CreateInputParam("@Value", SqlDbType.NVarChar, value) )) { SqlDataReader rdr = sp.ExecuteReader(); int intErrorNumber; // Holds the error number return from the stored procedure. string strErrorMessage; // Holds the error message return from the stored procedure. //1. Get the response. rdr.Read(); intErrorNumber = rdr.GetInt32(0); strErrorMessage = rdr.GetString(1); //2. Close the reader. rdr.Close(); //4. Throw the required exception if error number is not 0. switch (intErrorNumber) { case 0: // Succeeded. { break; } case 2: { throw new FKViolationException(String.Format(ResourceManager.GetString("prcOrganisationConfig_Update.2"), organisationID.ToString())); } case 21: { throw new FKViolationException(String.Format(ResourceManager.GetString("prcOrganisationConfig_Update.21"), name)); } case 5: // Parameter Exception. { throw new ParameterException(strErrorMessage); } default: // Whatever is left. { throw new BusinessServiceException(strErrorMessage); } } } }
} // Create /// <summary> /// Updates a module details. If the status is changed, there will be validation checking. /// </summary> /// <param name="moduleID">Module ID whose details are being updated</param> /// <param name="name">Name for the updated module</param> /// <param name="description">Description for the updated module</param> /// <param name="active">Active flag for the updated module</param> /// <param name="updatedByUserID">Currently logged on user updating the module</param> public void Update(int moduleID, string name, string description, bool active, int updatedByUserID, string worksiteID, string lWorkSiteID, string qfWorkSiteID) { using (StoredProcedure sp = new StoredProcedure("prcModule_Update", StoredProcedure.CreateInputParam("@moduleID", SqlDbType.Int, moduleID), StoredProcedure.CreateInputParam("@name", SqlDbType.NVarChar, 100, name), StoredProcedure.CreateInputParam("@description", SqlDbType.NVarChar, 500, description), StoredProcedure.CreateInputParam("@active", SqlDbType.Bit, active), StoredProcedure.CreateInputParam("@updatedByUserID", SqlDbType.Int, updatedByUserID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intError; string strMessage; rdr.Read(); intError = rdr.GetInt32(0); strMessage = rdr.GetString(1); rdr.Close(); if (intError == 1) { throw new BusinessServiceException(ResourceManager.GetString("cmnRecordNotExist")); } if (intError == 4) { throw new BusinessServiceException(ResourceManager.GetString("prcModule_Update.4")); } //-- Update quiz and lesson worksite IDs string connectionString = ConfigurationSettings.AppSettings["ConnectionString"] + "password="******"password"] + ";"; System.Data.SqlClient.SqlParameter[] quizParams = { new SqlParameter("@ModuleID", moduleID), new SqlParameter("@WorksiteID", worksiteID) }; System.Data.SqlClient.SqlParameter[] lessonParams = { new SqlParameter("@ModuleID", moduleID), new SqlParameter("@LWorkSiteID", lWorkSiteID), new SqlParameter("@QFWorkSiteID", qfWorkSiteID) }; string sqlUpdateQuiz = "UPDATE tblQuiz set WorksiteID = @WorksiteID where ModuleID = @ModuleID and Active = 1"; string sqlUpdateLesson = "UPDATE tblLesson set LWorkSiteID = @LWorkSiteID, QFWorkSiteID = @QFWorkSiteID where ModuleID = @ModuleID and Active = 1"; Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(connectionString, System.Data.CommandType.Text, sqlUpdateQuiz, quizParams); Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(connectionString, System.Data.CommandType.Text, sqlUpdateLesson, lessonParams); } } // Update
} // AddClassificationType /// <summary> /// Updates a classification type for a specific organisation. /// </summary> /// <param name="name"> The name of the classification type.</param> /// <param name="classificationTypeID"> The ID of the classification type to be updated.</param> /// <param name="organisationID"> The ID of the organisation the the classification type belongs to.</param> /// <remarks> /// Assumptions: None /// Notes: /// Author: Peter Vranich /// Date: 18/02/0/2004 /// Changes: /// </remarks> public void UpdateClassificationType(SqlString name, SqlInt32 classificationTypeID, SqlInt32 organisationID) { using (StoredProcedure sp = new StoredProcedure("prcClassification_UpdateType", StoredProcedure.CreateInputParam("@name", SqlDbType.NVarChar, 50, name), StoredProcedure.CreateInputParam("@classificationTypeID", SqlDbType.Int, classificationTypeID), StoredProcedure.CreateInputParam("@organisationID", SqlDbType.Int, organisationID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intErrorNumber; // Holds the error number return from the stored procedure. string strErrorMessage; // Holds the error message return from the stored procedure. //1. Get the response. rdr.Read(); intErrorNumber = rdr.GetInt32(0); strErrorMessage = rdr.GetString(1); //2. Close the reader. rdr.Close(); //4. Throw the required exception if error number is not 0. switch (intErrorNumber) { case 0: // Succeeded. { break; } case 1: { throw new RecordNotFoundException(strErrorMessage); } case 4: // Unique constraint. { throw new UniqueViolationException(ResourceManager.GetString("prcClassification_UpdateType.1")); } case 5: // Parameter Exception. { throw new ParameterException(strErrorMessage); } default: // Whatever is left. { throw new BusinessServiceException(strErrorMessage); } } } } // UpdateClassificationType
private bool ScriptTask1Execute(ProcessExecutingContext context) { UserConnection userConnection = Get <UserConnection>("UserConnection"); string useOldProcessFeatureCode = "UseOldOpportunityManagementProcess"; bool useOldVersion = Get <bool>("UseOldOpportunityManagement"); bool forceUpdateUsageState = Get <bool>("ForceUpdateUsageState"); bool useOldVersionFeatureEnabled = userConnection.GetIsFeatureEnabled(useOldProcessFeatureCode); if (forceUpdateUsageState && useOldVersionFeatureEnabled != useOldVersion) { var newState = useOldVersion ? FeatureState.Enabled : FeatureState.Disabled; userConnection.SetFeatureState(useOldProcessFeatureCode, (int)newState); } global::Common.Logging.ILog _logger = global::Common.Logging.LogManager.GetLogger("Process"); StoredProcedure storedProcedure = new StoredProcedure(userConnection, "tsp_ActualizeOpportunityManagementProcess"); storedProcedure.WithParameter("fetchProcessesInfo", true); Dictionary <Guid, bool> processSchemasInfos = new Dictionary <Guid, bool>(); using (var executor = userConnection.EnsureDBConnection()) { using (var reader = storedProcedure.ExecuteReader(executor)) { while (reader.Read()) { var schemaName = reader.GetValue <string>("SchemaName"); var schemaId = reader.GetValue <Guid>("SchemaId"); var toBeEnabled = reader.GetValue <bool>("ToBeEnabled"); _logger.InfoFormat("Process {0}({1}) will be set to enabled state = {2}", schemaName, schemaId, toBeEnabled); processSchemasInfos[schemaId] = toBeEnabled; } } } var processSchemaManager = userConnection.ProcessSchemaManager; foreach (var processSchemaInfo in processSchemasInfos) { if (processSchemaInfo.Value) { processSchemaManager.EnableProcess(userConnection, processSchemaInfo.Key); } else { processSchemaManager.DisableProcess(userConnection, processSchemaInfo.Key); } } return(true); }
} // Update /// <summary> /// This method deletes an existing link within the salt database. /// </summary> /// <remarks> /// Assumptions:None /// Notes: /// Author: Peter Kneale, 03/03/04 /// Changes: /// </remarks> /// <param name="linkID">The ID of the link to delete</param> public void Delete(SqlInt32 linkID) { using (StoredProcedure sp = new StoredProcedure("prcLink_Delete", StoredProcedure.CreateInputParam("@linkID", SqlDbType.Int, linkID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intErrorNumber; // Holds the error number return from the stored procedure. string strErrorMessage; // Holds the error message return from the stored procedure. //1. Get the response. rdr.Read(); intErrorNumber = rdr.GetInt32(0); strErrorMessage = rdr.GetString(1); //2. Close the reader. rdr.Close(); //4. Throw the required exception if error number is not 0. switch (intErrorNumber) { case 0: // Succeeded. { break; } case 1: { throw new RecordNotFoundException(ResourceManager.GetString("prcLink_Delete.1")); } case 5: // Parameter Exception. { throw new ParameterException(strErrorMessage); } default: // Whatever is left. { throw new BusinessServiceException(strErrorMessage); } } } } // Delete
/// <summary> /// Performs search similar records using stored procedure. /// </summary> /// <param name="schemaName">Schema name.</param> /// <param name="recordId">Record unique identifier.</param> /// <param name="searchValues">Values to find similar records.</param> /// <returns></returns> public List <Guid> FindSimilarEntity(string schemaName, Guid recordId, XmlDocument searchValues) { List <Guid> similarRecords = new List <Guid>(); string tspName = string.Format(SimilarRecordsTspPattern, schemaName); var storedProcedure = new StoredProcedure(_userConnection, tspName); storedProcedure.WithParameter("recordId", recordId); storedProcedure.WithParameter("searchValues", searchValues.OuterXml); using (DBExecutor dbExecutor = _userConnection.EnsureDBConnection()) { using (var reader = storedProcedure.ExecuteReader(dbExecutor)) { while (reader.Read()) { Guid id = reader.GetColumnValue <Guid>("Id"); similarRecords.Add(id); } } } return(similarRecords); }
} // Update /// <summary> /// Updates a module's sequence value only. /// </summary> /// <param name="moduleID">Module ID whose sequence value is being updated</param> /// <param name="sequence">New sequence value for the module</param> /// <param name="updatedByUserID">Currently logged on user updating the module</param> public void UpdateSequence(int moduleID, int sequence, int updatedByUserID) { using (StoredProcedure sp = new StoredProcedure("prcModule_UpdateSequence", StoredProcedure.CreateInputParam("@moduleID", SqlDbType.Int, moduleID), StoredProcedure.CreateInputParam("@sequence", SqlDbType.Int, sequence), StoredProcedure.CreateInputParam("@updatedByUserID", SqlDbType.Int, updatedByUserID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intError; string strMessage; rdr.Read(); intError = rdr.GetInt32(0); strMessage = rdr.GetString(1); rdr.Close(); if (intError == 1) { throw new BusinessServiceException(ResourceManager.GetString("cmnRecordNotExist")); } } } // UpdateSequence
public static List<Seller> GetMacAll() { List<Seller> items = new List<Seller>(); using (StoredProcedure sp = new StoredProcedure("MacSeller_GetAll")) { var r = sp.ExecuteReader(); if (r != null) { while (r.Read()) { Seller item = new Seller { ID = Convert.ToInt32(r["ID"]), Name = Convert.ToString(r["Name"]) }; items.Add(item); } } } return items; }