}//END addItem method. // ================================================================================== /// <summary> /// This class adds a record to the binary file table. /// </summary> /// <param name="BinaryFile">EvBinaryFileMetaData: a binary file object</param> /// <returns>EvEventCodes: an event code for adding items to the binary file table</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Define sql query parameters and execute the storeprocedure for adding items. /// /// 2. Return the event code for adding new items. /// </remarks> // ---------------------------------------------------------------------------------- public EvEventCodes updateItem(EvBinaryFileMetaData BinaryFile) { // // Initialize a method debug status. // this.LogMethod("updateItem"); // // Define the SQL query parameters and load the query values. // SqlParameter [] _cmdParms = getItemsParameters( ); SetParameters(_cmdParms, BinaryFile); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_storedProcedureUpdateItem, _cmdParms) == 0) { this.LogMethodEnd("updateItem"); return(EvEventCodes.Database_Record_Update_Error); } this.LogMethodEnd("updateItem"); return(EvEventCodes.Ok); }//END addItem method.
}//END addItem class // ===================================================================================== /// <summary> /// This class withdraw issued formfield selection list. /// </summary> /// <param name="Item">EvFormFieldSelectionList: a formfield selection list object</param> /// <returns>EvEventCodes: an event code for withdrawing issued list</returns> /// <remarks> /// This class consists of the following steps: /// /// 1. Define the sql query parameters and execute the storeprocedure for withdrawing items. /// /// 2. Return an event code for withdrawing items. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes WithdrawIssuedList(EvSelectionList Item) { this._Log = new System.Text.StringBuilder( ); this.LogMethod("WithdrawIssuedList method. "); // // Define the query parameters // SqlParameter [] commandParameters = new SqlParameter [] { new SqlParameter(EvSelectionLists.PARM_LIST_ID, SqlDbType.NVarChar, 20), new SqlParameter(EvSelectionLists.PARM_UPDATED_BY_USER_ID, SqlDbType.NVarChar, 100), new SqlParameter(EvSelectionLists.PARM_UPDATED_BY, SqlDbType.NVarChar, 100), new SqlParameter(EvSelectionLists.PARM_UPDATED_DATE, SqlDbType.DateTime) }; commandParameters [0].Value = Item.ListId; commandParameters [1].Value = this.ClassParameters.UserProfile.UserId; commandParameters [2].Value = this.ClassParameters.UserProfile.CommonName; commandParameters [3].Value = DateTime.Now; // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_WithdrawItem, commandParameters) == 0) { return(EvEventCodes.Database_Record_Update_Error); } return(EvEventCodes.Ok); }//End WithdrawIssuedList method.
}//END GetItem class. #endregion #region Class update methods // ================================================================================== /// <summary> /// This class adds a record to the binary file table. /// </summary> /// <param name="BinaryFile">EvBinaryFileMetaData: a binary file object</param> /// <returns>EvEventCodes: an event code for adding items to the binary file table</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Define sql query parameters and execute the storeprocedure for adding items. /// /// 2. Return the event code for adding new items. /// </remarks> // ---------------------------------------------------------------------------------- public EvEventCodes addItem(EvBinaryFileMetaData BinaryFile) { this.LogMethod("addItem method. "); this.LogDebug(" BinaryFile.Version: " + BinaryFile.Version); this.LogDebug(" BinaryFile.FileEncrypted: " + BinaryFile.FileEncrypted); this.LogDebug(" BinaryFile.FileExists: " + BinaryFile.FileExists); this.LogDebug(" BinaryFile.Comments: " + BinaryFile.Comments); this.LogDebug(" BinaryFile.Language: " + BinaryFile.Language); // // Initialize a method debug status. // BinaryFile.FileExists = true; // // Define the SQL query parameters and load the query values. // SqlParameter [] _cmdParms = getItemsParameters( ); SetParameters(_cmdParms, BinaryFile); this.LogDebug(EvSqlMethods.ListParameters(_cmdParms)); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_storedProcedureAddItem, _cmdParms) == 0) { this.LogMethodEnd("addItem"); return(EvEventCodes.Database_Record_Update_Error); } this.LogMethodEnd("addItem"); return(EvEventCodes.Ok); }//END addItem method.
}//END addItem class // ================================================================================== /// <summary> /// This class deletes items from MenuItem table. /// </summary> /// <param name="MenuItem">EvMenuItem: a menu item object</param> /// <returns>Evado.Model.EvEventCodes: a delete item code</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the Guid is empty. /// /// 2. Define the SQL query parameters and load the query values. /// /// 3. Execute the update command. /// /// 4. Return update item code /// </remarks> // ---------------------------------------------------------------------------------- public Evado.Model.EvEventCodes deleteItem(Evado.Digital.Model.EvMenuItem MenuItem) { this.LogMethod("addItem method"); this.LogDebug("Guid: " + MenuItem.Guid); // // Initialize a debug log // // // Validate whether the menu guid exists // if (MenuItem.Guid == Guid.Empty) { return(Evado.Model.EvEventCodes.Data_InvalidId_Error); } // // Define the query parameters. // SqlParameter [] _cmdParms = new SqlParameter [] { new SqlParameter(PARM_GUID, SqlDbType.UniqueIdentifier) }; _cmdParms [0].Value = MenuItem.Guid; // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_storedProcedureDeleteItem, _cmdParms) == 0) { return(Evado.Model.EvEventCodes.Database_Record_Update_Error); } return(Evado.Model.EvEventCodes.Ok); }//END deleteItem class
}// Close method getMenus. #endregion #region MenuItem Update methods // ================================================================================== /// <summary> /// This class updates Menus data object in the database using it unique object identifier. /// </summary> /// <param name="MenuItem">EvMenuItem: menus data object</param> /// <returns>Evado.Model.EvEventCodes: an update item code</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the title is not defined. /// /// 2. Define the SQL query parameters and load the query values. /// /// 3. Execute the update command. /// /// 4. Return update item code /// </remarks> // ---------------------------------------------------------------------------------- public Evado.Model.EvEventCodes updateItem(Evado.Digital.Model.EvMenuItem MenuItem) { this.LogMethod("updateItem method. "); // // Initialize a debug log // // // Validate whether the menu title exists // if (MenuItem.Title == String.Empty) { return(Evado.Model.EvEventCodes.Data_InvalidId_Error); } // // Define the SQL query parameters and load the query values. // SqlParameter [] _cmdParms = GetParameters( ); SetParameters(_cmdParms, MenuItem); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_storedProcedureUpdateItem, _cmdParms) == 0) { return(Evado.Model.EvEventCodes.Database_Record_Update_Error); } return(Evado.Model.EvEventCodes.Ok); }//END updateItem method
}//END updateItem class // ===================================================================================== /// <summary> /// This class adds new items to the formfield selection list table. /// </summary> /// <param name="Item">EvFormFieldSelectionList: a formfield selection list object</param> /// <returns>EvEventCodes: an event code for adding items</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit if the List's identifier is empty or duplicated /// /// 2. Create new DB row Guid /// /// 3. Define the sql query parameters and execute the sql storeprocedure for adding items. /// /// 4. Return the event code fore adding new items. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes addItem(EvSelectionList Item) { this._Log = new System.Text.StringBuilder( ); this.LogMethod("addItem method. "); this.LogDebug("ListId: '" + Item.ListId); this.LogDebug("Version: '" + Item.Version + "'"); String sqlQueryString = String.Empty; //---------------------- Check for duplicate TestReport identifiers. ------------------ var oldSelectionList = this.getItem(Item.ListId, false); // // returned list has a guid there is a duplicate. // if (oldSelectionList.Guid != Guid.Empty) { this.LogDebug("Duplication list found."); return(EvEventCodes.Data_Duplicate_Id_Error); } // // trime the item options. // this.trimItemOptions(Item); // // Create the Guid // Item.Guid = Guid.NewGuid( ); // // Define the query parameters // SqlParameter [] commandParameters = GetParameters( ); SetParameters(commandParameters, Item); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_AddItem, commandParameters) == 0) { return(EvEventCodes.Database_Record_Update_Error); } // // Update the option list // this.updateOptions(Item); // // Return the event code for adding new items. // return(EvEventCodes.Ok); }//END addItem class
} //END addItem method. // ===================================================================================== /// <summary> /// This method updates items to Subject Record data table. /// </summary> /// <param name="AncillaryRecord">EvAncillaryRecord: An ancillary record object object.</param> /// <returns>EvEventCodes: An event code for updating items</returns> /// <remarks> /// This method consists of following steps: /// /// 1. Exit, if the VisitId or SubjectId is empty. /// /// 2. Add items to datachange object, if they do not exist on the old milestone record object. /// /// 3. Define the sql query parameters and execute the storeprocedure for updating items. /// /// 4. Exit, if the storeprocedure runs fail. /// /// 5. Add the datachange object's values to the backup datachanges object. /// /// 6. Return an event code for updating items. /// </remarks> // ---------------------------------------------------------------------------------- public EvEventCodes updateItem(EvAncillaryRecord AncillaryRecord) { this.LogMethod("updateItem."); this.LogValue("RecordId: " + AncillaryRecord.RecordId); this.LogValue("ProjectId: " + AncillaryRecord.ProjectId); this.LogValue("SubjectId: " + AncillaryRecord.SubjectId); this.LogValue("State: " + AncillaryRecord.State); // // Initialise the methods variables and objects. // EvDataChanges dataChanges = new EvDataChanges( ); // // Get an existing object to verify the record exists. // EvAncillaryRecord oldItem = getRecord(AncillaryRecord.Guid); if (oldItem.Guid == Guid.Empty) { return(EvEventCodes.Data_InvalidId_Error); } // // Compare the objects. // EvDataChange dataChange = SetDataChange(AncillaryRecord); // // Define the SQL query parameters and load the query values. // SqlParameter [] _cmdParms = GetParameters( ); SetParameters(_cmdParms, AncillaryRecord); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_UpdateItem, _cmdParms) == 0) { return(EvEventCodes.Database_Record_Update_Error); } // // Add the data change to the database. // dataChanges.AddItem(dataChange); // // Return an enumerated value EventCode status. // return(EvEventCodes.Ok); }//END updateItem method.
} // Close GetView method. // ++++++++++++++++++++++++++++++ END VIEW QUERY SECTION +++++++++++++++++++++++++++++++ #endregion #region DataChange Update queries // ===================================================================================== /// <summary> /// This class adds a data change object to the database. /// </summary> /// <param name="DataChange">EvDataChange: a datachange object</param> /// <returns>EvEventCodes: an event code for adding items to data change table.</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Loop through the datachange object items and validate whether the items are not empty /// /// 2. Define the sql query parameters /// /// 3. Execute the storeprocedure for adding new items to datachange table. /// /// 4. Return the event code for adding items. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes AddItem(EvDataChange DataChange) { // // Initialize the method status and a no-items variable // this.LogMethod("addItem method."); this.LogDebug("ProjectId: " + DataChange.TrialId); this.LogDebug("TypeId: " + DataChange.TableName); this.LogDebug("UserId: " + DataChange.UserId); this.LogDebug("DataChange.Items.Count count: " + DataChange.Items.Count); bool NoItems = true; // // Loop through the datachange object and validate whether the items are not empty. // foreach (EvDataChangeItem item in DataChange.Items) { if (item.ItemId != String.Empty) { NoItems = false; } }//END Foreach interation loop. // // IF not newField then exit without saving. // if (NoItems == true) { this.LogDebug(" No Items found."); return(EvEventCodes.Ok); } // // Define the SQL query parameters and load the query values. // SqlParameter [] _cmdParms = GetParameters( ); setParameters(_cmdParms, DataChange); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_AddItem, _cmdParms) == 0) { return(EvEventCodes.Database_Record_Update_Error); } return(EvEventCodes.Ok); }//END AddItem class.
} //END lockItem method. // ===================================================================================== /// <summary> /// This method unlocks the EvSubjectRecord object. /// </summary> /// <param name="Item">EvAncillaryRecord: An ancillary record object object.</param> /// <returns>EvEventCodes: An event code for locking items</returns> /// <remarks> /// This method consists of following steps. /// /// 1. Exit, if the item's Uid is not defined. /// /// 2. Define the sql query parameters and execute the storeprocedure for unlocking items. /// /// 3. Exit, if the storeprocedure runs fail. /// /// 4. Return an event code for unlocking items. /// </remarks> // ---------------------------------------------------------------------------------- public EvEventCodes UnlockItem(EvAncillaryRecord Item) { // // Initialise the method variables // this.LogMethod("unlockItem method "); this.LogValue("Guid: " + Item.Guid); this.LogValue("UserCommonName: " + Item.UserCommonName); int RecordsUpdated = 0; // // Validate whether the Guid is defined. // if (Item.Guid == Guid.Empty) { return(EvEventCodes.Identifier_Global_Unique_Identifier_Error); } // // Define the SQL query parameters and load the query values. // SqlParameter [] cmdParms = new SqlParameter [] { new SqlParameter(PARM_Guid, SqlDbType.UniqueIdentifier), new SqlParameter(PARM_UpdatedByUserId, SqlDbType.NVarChar, 100), new SqlParameter(PARM_UpdatedBy, SqlDbType.NVarChar, 100), new SqlParameter(PARM_UpdateDate, SqlDbType.DateTime), }; cmdParms [0].Value = Item.Guid; cmdParms [1].Value = Item.UpdatedByUserId; cmdParms [2].Value = Item.UserCommonName; cmdParms [3].Value = DateTime.Now; // // Execute the update command. // if ((RecordsUpdated = EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_UnlockItem, cmdParms)) == 0) { this.LogDebug(" RecordsUpdated " + RecordsUpdated + " "); return(EvEventCodes.Database_Record_Update_Error); } this.LogDebug(" RecordsUpdated " + RecordsUpdated + " "); // // Return an enumerated value EventCode status. // return(EvEventCodes.Ok); }//END UnlockItem method.
}//END getRecord method #endregion #region Ancilliary Record Update queries // ===================================================================================== /// <summary> /// This method adds items to the Subject Record data table. /// </summary> /// <param name="AncillaryRecord">EvSubjectRecord: A Subject Record object</param> /// <returns>EvEventCodes: An event code for adding items</returns> /// <remarks> /// This method consists of follwoing steps: /// /// 1. Create new DB row Guid, if it is empty. /// /// 2. Define the sql query parameters and execute the storeprocedure for adding items. /// /// 3. Exit, if the storeprocedure runs fail. /// /// 4. Return an event code for adding items. /// </remarks> // ---------------------------------------------------------------------------------- public EvEventCodes addItem(EvAncillaryRecord AncillaryRecord) { this.LogMethod("addItem."); this.LogValue("RecordId: " + AncillaryRecord.RecordId); this.LogValue("ProjectId: " + AncillaryRecord.ProjectId); this.LogValue("SubjectId: " + AncillaryRecord.SubjectId); // // Initialise the methods variables and objects. // EvDataChanges dataChanges = new EvDataChanges( ); Guid newGuid = Guid.NewGuid( ); AncillaryRecord.RecordId = String.Empty; // // If the SubjectRecord Guid is empty then create a new Guid. // if (AncillaryRecord.Guid == Guid.Empty) { AncillaryRecord.Guid = newGuid; } // // Compare the objects. // EvDataChange dataChange = SetDataChange(AncillaryRecord); // // Define the SQL query parameters and load the query values. // SqlParameter [] _cmdParms = GetParameters( ); SetParameters(_cmdParms, AncillaryRecord); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_AddItem, _cmdParms) == 0) { return(EvEventCodes.Database_Record_Update_Error); } // // Return an enumerated value EventCode status. // return(EvEventCodes.Ok); } //END addItem method.
} // Close getReport method. #endregion #region Update Data methods // ===================================================================================== /// <summary> /// This class adds items to the Report table based on the selected report object. /// /// Author: Ross Anderson /// Date: 12/10/2005 /// </summary> /// <param name="Report">EvReport: a report data object</param> /// <returns>EvEventCodes: an event code for adding items</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the VisitId or User Common Name is empty. /// /// 2. Define the sql query parameter and execute the storeprocedure for adding items. /// /// 3. Exit, if the storeprocedure runs fail /// /// 4. Else, return the event code for adding items. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes addReport(EdReport Report) { this.LogMethod("addReport. "); this.LogDebug("Guid: " + Report.Guid); this.LogDebug("ReportId: " + Report.ReportId); this.LogDebug("ReportTitle: " + Report.ReportTitle); this.LogDebug("ReportSubTitle: " + Report.ReportSubTitle); this.LogDebug("ReportCommonName: " + Report.UserCommonName); // // Define the local variables. // string _sqlQueryString = String.Empty; if (Report.UserCommonName == String.Empty) { this.LogDebug("CommonUser missing. "); return(EvEventCodes.Identifier_User_Common_Name_Error); } // // set the FormUid for the Report. // Report.Guid = Guid.NewGuid( ); // // Define the SQL query parameters and load the query values. // SqlParameter [] cmdParms = getReportsParameters( ); SetParameters(cmdParms, Report); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_AddReport, cmdParms) == 0) { this.LogMethodEnd("addReport."); return(EvEventCodes.Database_Record_Update_Error); } this.LogMethodEnd("addReport."); return(EvEventCodes.Ok); } // Close method addReport
}//END getItem class #endregion #region Add EvEvent section // ===================================================================================== /// <summary> /// This method adds an ApplicationEvent data object to the database. /// </summary> /// <param name="ApplicationEvent">EvApplicationEvent: an application event data object</param> /// <returns>EvEventCodes: a code of an event</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Initialize the status string /// /// 2. Check that the user identifier is valid /// /// 3. Remove the domain name from user identifier /// /// 4. Define the SQL query parameters and load the query values. /// /// 5. Execute the update command. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes addEvent( EvApplicationEvent ApplicationEvent) { this.LogMethod("addEvent method. "); this.LogDebugValue("EventId: " + ApplicationEvent.EventId); // // Check that the user identifier is valid // if (ApplicationEvent.EventId > 1) { return(EvEventCodes.Data_InvalidId_Error); } // // Remove the domain name from user identifier // if (ApplicationEvent.UserId != null) { //ApplicationEvent.UserName = EvStatics.removeDomainName ( ApplicationEvent.UserName ); } // // Define the SQL query parameters and load the query values. // SqlParameter [] _cmdParms = GetParameters( ); SetParameters(_cmdParms, ApplicationEvent); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_AddItem, _cmdParms) == 0) { this.LogMethodEnd("addEvent"); return(EvEventCodes.Database_Record_Update_Error); } this.LogMethodEnd("addEvent"); return(EvEventCodes.Ok); } // Close method addTestReport
}// END getItem method #endregion #region SelectionList Update queries // ===================================================================================== /// <summary> /// This class updates items on formfield selection list table. /// </summary> /// <param name="Item">EvFormFieldSelectionList: a formfield selection list object</param> /// <returns>EvEventCodes: an event code for updating items</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the Old list's Guid is empty. /// /// 2. Add items to datachange object if they exist after comparing with the old list. /// /// 3. Define the sql parameters and execute the storeprocedure for updating items. /// /// 4. Add the datachange values to the backup datachanges object. /// /// 5. Return the event code for updating the items. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes updateItem(EvSelectionList Item) { this._Log = new System.Text.StringBuilder( ); this.LogMethod("updateItem"); // // Get the previous value // EvSelectionList oldItem = getItem(Item.Guid); if (oldItem.Guid == Guid.Empty) { return(EvEventCodes.Identifier_Global_Unique_Identifier_Error); } // // trime the item options. // this.trimItemOptions(Item); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Compare the objects. // EvDataChanges dataChanges = new EvDataChanges( ); EvDataChange dataChange = new EvDataChange( ); dataChange.TableName = EvDataChange.DataChangeTableNames.EdSelectionList; dataChange.TrialId = String.Empty; dataChange.RecordUid = -1; dataChange.RecordGuid = Item.Guid; dataChange.UserId = Item.UpdatedByUserId; dataChange.DateStamp = DateTime.Now; // // Add items to datachange object if they exist. // if (Item.ListId != oldItem.ListId) { dataChange.AddItem("ListId", oldItem.ListId, Item.ListId); } if (Item.Title != oldItem.Title) { dataChange.AddItem("Title", oldItem.Title, Item.Title); } if (Item.Description != oldItem.Description) { dataChange.AddItem("Description", oldItem.Description, Item.Description); } if (Item.Version != oldItem.Version) { dataChange.AddItem("Version", oldItem.Version, Item.Version); } if (Item.State != oldItem.State) { dataChange.AddItem("State", oldItem.State.ToString( ), Item.State.ToString( )); } string oldCodeItem = Evado.Digital.Model.EvcStatics.SerialiseObject <List <EvSelectionList.Item> > (Item.Items); string newCodeItem = Evado.Digital.Model.EvcStatics.SerialiseObject <List <EvSelectionList.Item> > (Item.Items); if (newCodeItem != oldCodeItem) { dataChange.AddItem("Items", oldCodeItem, newCodeItem); } // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Define the query parameters // SqlParameter [] commandParameters = GetParameters( ); SetParameters(commandParameters, Item); // // Execute the update command. // if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_UpdateItem, commandParameters) == 0) { return(EvEventCodes.Database_Record_Update_Error); } // // Add the change record // dataChanges.AddItem(dataChange); // // Update the option list // this.updateOptions(Item); return(EvEventCodes.Ok); }//END updateItem class