Esempio n. 1
0
        }//END GetParameters class

        // =====================================================================================
        /// <summary>
        /// This method assigns the SubjectRecord object's values to the array of sql parameters.
        /// </summary>
        /// <param name="cmdParms">SqlParameter: An array of sql parameters.</param>
        /// <param name="Record">EvSubjectRecord: A milestone record object</param>
        /// <remarks>
        /// This method consists of the following step:
        ///
        /// 1. Bind the milestone record object's values to the array of sql parameters.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private void SetParameters(SqlParameter [] cmdParms, EvAncillaryRecord Record)
        {
            //
            // Bind the milestone record object's values to the array of sql parameters.
            //
            cmdParms [0].Value  = Record.Guid;
            cmdParms [1].Value  = Record.ProjectId;
            cmdParms [2].Value  = Record.SubjectId;
            cmdParms [3].Value  = Record.RecordId;
            cmdParms [4].Value  = Record.RecordDate;
            cmdParms [5].Value  = Record.Subject;
            cmdParms [6].Value  = Record.Record;
            cmdParms [7].Value  = Record.BinaryLength;
            cmdParms [8].Value  = Record.BinaryObject;
            cmdParms [9].Value  = Record.BinaryType;
            cmdParms [10].Value = Record.BinaryExtension;
            cmdParms [11].Value = Record.XmlData;
            cmdParms [12].Value = Record.Researcher;
            cmdParms [13].Value = Record.ResearcherUserId;
            cmdParms [14].Value = Record.ResearcherDate;
            cmdParms [15].Value = Record.Reviewer;
            cmdParms [16].Value = Record.ReviewerUserId;
            cmdParms [17].Value = Record.ReviewDate;
            cmdParms [18].Value = Record.Approver;
            cmdParms [19].Value = Record.ApproverUserId;
            cmdParms [20].Value = Record.ApprovalDate;
            cmdParms [21].Value = Record.State;
            cmdParms [22].Value = Record.UpdatedByUserId;
            cmdParms [23].Value = Record.UserCommonName;
            cmdParms [24].Value = DateTime.Now;
            cmdParms [25].Value = Record.BookedOutBy;
            cmdParms [26].Value = Evado.Model.EvStatics.SerialiseObject <List <EdUserSignoff> > (Record.Signoffs);
        }//END SetParameters class.
        }//END addRecord method.

        // =====================================================================================
        /// <summary>
        /// This class updates items to FirstSubject record ResultData table.
        /// </summary>
        /// <param name="AncillaryRecord">EvSubjectRecord: a subjecyt record object</param>
        /// <returns>EvEventCodes: an event code for adding items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for updating items to milestone record ResultData table.
        ///
        /// 2. Return an event code for updating items.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private EvEventCodes updateItem(EvAncillaryRecord AncillaryRecord)
        {
            //
            // Define the local variables.
            //
            EvEventCodes iReturn = EvEventCodes.Ok;

            this._DebugLog.AppendLine("Evado.Digital.Bll.AncillaryRecords.UpdateItem method.");

            //
            // Update the state information in the trial Report.
            //
            this.updateState(AncillaryRecord);

            //
            // Update the trial record.
            //
            iReturn = this._dalSubjectRecords.updateItem(AncillaryRecord);
            this._DebugLog.AppendLine(this._dalSubjectRecords.Log);

            if (iReturn < EvEventCodes.Ok)
            {
                return(iReturn);
            }

            //
            // Return the update status.
            //
            return(iReturn);
        }//END updateItem method.
Esempio n. 3
0
        }//END getList method.

        #endregion

        #region Retrieval Queries

        // =====================================================================================
        /// <summary>
        /// This method retrieves the SubjectRecord data table based on Record's Guid
        /// </summary>
        /// <param name="RecordGuid">Guid: A Subject Record's Global Unique identifier</param>
        /// <returns>EvSubjectRecord: A Subject data object</returns>
        /// <remarks>
        /// This method consists of following steps:
        ///
        /// 1. Return an empty SubjectRecord object, if the Guid is empty.
        ///
        /// 2. Define the sql query parameters and sql query string.
        ///
        /// 3. Execute the sql query string and store the results on datatable.
        ///
        /// 4. Return an empty SubjectRecord object, if the table has no value.
        ///
        /// 5. Else, extract the first data row to the SubjectRecord object.
        ///
        /// 6. Return the SubjectRecord object.
        /// </remarks>
        //  ------------------------------------------------------------------------------------
        public EvAncillaryRecord getRecord(Guid RecordGuid)
        {
            this.LogMethod("getRecord");
            this.LogValue("RecordGuid: " + RecordGuid.ToString( ));
            //
            // Define the local variables.
            //
            EvAncillaryRecord record = new EvAncillaryRecord( );

            //
            // Validate whether the Subject Record object's Guid is not empty.
            //
            if (RecordGuid == Guid.Empty)
            {
                return(record);
            }

            //
            // Set the query parameter values.
            //
            SqlParameter cmdParms = new SqlParameter(PARM_Guid, SqlDbType.UniqueIdentifier);

            cmdParms.Value = RecordGuid;

            //
            // Generate the SQL query string
            //
            _sqlQueryString = _sqlQuery_View + " WHERE (TSR_Guid = @Guid) ;";

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // If no rows found, return an EvsubjectRecord object.
                //
                if (table.Rows.Count == 0)
                {
                    return(record);
                }

                //
                // Extract the table row
                //
                DataRow row = table.Rows [0];

                //
                // Fill the EvsubjectRecord object.
                //
                record = this.readRowData(row);
            }//END Using statement

            //
            // Return an object containing an EvsubjectRecord object.
            //
            return(record);
        }//END getRecord method
Esempio n. 4
0
        }//END getRecord method

        // =====================================================================================
        /// <summary>
        /// This method retrieves the SubjectRecord data table based on RecordId
        /// </summary>
        /// <param name="RecordId">string: A Record identifier</param>
        /// <returns>An object containing an EvSubjectRecord object.</returns>
        /// <returns>EvSubjectRecord: A Subject data object</returns>
        /// <remarks>
        /// This method consists of following steps:
        ///
        /// 1. Return an empty SubjectRecord object, if the RecordId is empty.
        ///
        /// 2. Define the sql query parameters and sql query string.
        ///
        /// 3. Execute the sql query string and store the results on datatable.
        ///
        /// 4. Return an empty SubjectRecord object, if the table has no value.
        ///
        /// 5. Else, extract the first data row to the SubjectRecord object.
        ///
        /// 6. Return the SubjectRecord object.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public EvAncillaryRecord getRecord(string RecordId)
        {
            this.LogMethod("getRecord");
            this.LogValue(" RecordId: " + RecordId);
            //
            // Define the object.
            //
            EvAncillaryRecord record = new EvAncillaryRecord( );

            //
            // If Record does not exist, return an object containing EvSubjectRecord object.
            //
            if (RecordId == String.Empty)
            {
                return(record);
            }

            //
            // Define the parameters for the query
            //
            SqlParameter cmdParms = new SqlParameter(PARM_RecordId, SqlDbType.NVarChar, 17);

            cmdParms.Value = RecordId;

            _sqlQueryString = _sqlQuery_View + " WHERE ( RecordId = @RecordId );";

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // If not rows the return, an object containing EvSubjectRecord object.
                //
                if (table.Rows.Count == 0)
                {
                    return(record);
                }

                //
                // Extract the table row
                //
                DataRow row = table.Rows [0];

                //
                // Fill the EvSubjectRecord object.
                //
                record = this.readRowData(row);
            }//END Using statement

            //
            // Return an object containing an EvSubjectRecord object.
            //
            return(record);
        }//END getRecord method
Esempio n. 5
0
        } //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.
Esempio n. 6
0
        }//END SetParameters class.

        #endregion

        #region ancillary record Reader

        // =====================================================================================
        /// <summary>
        /// This method extracts the data row values to the Subject Record object.
        /// </summary>
        /// <param name="Row">DataRow: A data row object</param>
        /// <returns>EvSubjectRecord: A milestone record object.</returns>
        /// <remarks>
        /// This method consists of following steps:
        ///
        /// 1. Extract the compatible data row values to the Subject record object.
        ///
        /// 2. Return the milestone record object.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private EvAncillaryRecord readRowData(DataRow Row)
        {
            //
            // Initialise the method variables and objects.
            //
            EvAncillaryRecord record = new EvAncillaryRecord( );

            //
            // Extract the data object values.
            //
            record.Guid       = EvSqlMethods.getGuid(Row, "TSR_Guid");
            record.ProjectId  = EvSqlMethods.getString(Row, "TrialId");
            record.SubjectId  = EvSqlMethods.getString(Row, "SubjectId");
            record.RecordId   = EvSqlMethods.getString(Row, "RecordId");
            record.RecordDate = EvSqlMethods.getDateTime(Row, "TSR_RecordDate");
            record.Subject    = EvSqlMethods.getString(Row, "TSR_Subject");
            record.Record     = EvSqlMethods.getString(Row, "TSR_Record");

            //
            // Perform binary object management
            //
            record.BinaryLength = EvSqlMethods.getInteger(Row, "TSR_BinaryLength");

            if (record.BinaryLength > 0)
            {
                record.BinaryObject    = EvSqlMethods.getBytes(Row, "TSR_BinaryObject");
                record.BinaryType      = EvSqlMethods.getString(Row, "TSR_BinaryType");
                record.BinaryExtension = EvSqlMethods.getString(Row, "TSR_BinaryExtension");
            }

            record.XmlData         = EvSqlMethods.getString(Row, "TSR_XmlData");
            record.Researcher      = EvSqlMethods.getString(Row, "TSR_Researcher");
            record.ResearcherDate  = EvSqlMethods.getDateTime(Row, "TSR_ResearcherDate");
            record.Reviewer        = EvSqlMethods.getString(Row, "TSR_Reviewer");
            record.ReviewDate      = EvSqlMethods.getDateTime(Row, "TSR_ReviewDate");
            record.Approver        = EvSqlMethods.getString(Row, "TSR_Approver");
            record.ApprovalDate    = EvSqlMethods.getDateTime(Row, "TSR_ApprovalDate");
            record.State           = Evado.Model.EvStatics.parseEnumValue <EdRecordObjectStates> (EvSqlMethods.getString(Row, "TSR_State"));
            record.UpdatedByUserId = EvSqlMethods.getString(Row, "TSR_UpdatedByUserId");
            record.UpdatedBy       = EvSqlMethods.getString(Row, "TSR_UpdatedBy");
            record.UpdatedDate     = EvSqlMethods.getDateTime(Row, "TSR_UpdateDate");
            record.BookedOutBy     = EvSqlMethods.getString(Row, "TSR_BookedOutBy");
            record.Signoffs        = Evado.Model.EvStatics.DeserialiseObject <List <EdUserSignoff> > (EvSqlMethods.getString(Row, "TSR_Signoffs"));

            //
            // Return an object containing EvSubjectRecord object.
            //
            return(record);
        }//END getRowData
        }//END lockItem method

        // =====================================================================================
        /// <summary>
        /// This class unlocks items to a single user update
        /// </summary>
        /// <param name="AncillaryRecord">EvSubjectRecord: a subjecyt record object</param>
        /// <returns>EvEventCodes: an event code for adding items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for unlocking items
        ///
        /// 2. Return an event code for unlocking items.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public EvEventCodes unlockItem(EvAncillaryRecord AncillaryRecord)
        {
            //
            // Initialise method variables
            //
            this._DebugLog.AppendLine("Evado.Digital.Bll.AncillaryRecords.unlockItem method. ");
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Update the trial record.
            //
            iReturn = this._dalSubjectRecords.UnlockItem(AncillaryRecord);
            this._DebugLog.AppendLine(this._dalSubjectRecords.Log);
            return(iReturn);
        }//END unlockItem method
Esempio n. 8
0
        } //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.
Esempio n. 9
0
        }//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.
        }//END getList method.

        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region trial FirstSubject retrieval queries

        // =====================================================================================
        /// <summary>
        /// This class retrieves the milestone record object based on Guid
        /// </summary>
        /// <param name="RecordGuid">Guid: Global unique identifier</param>
        /// <returns>EvSubjectRecord: a milestone record object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for retrieving the milestone record object based on Guid.
        ///
        /// 2. Return the milestone record object.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public EvAncillaryRecord getRecord(Guid RecordGuid)
        {
            this._DebugLog.AppendLine("Evado.Digital.Bll.AncillaryRecords.SubjectRecords:getRecord method. ");
            this._DebugLog.AppendLine("RecordGuid: " + RecordGuid);

            //
            // Initialise the method variables and objects.
            //
            EvAncillaryRecord item = this._dalSubjectRecords.getRecord(RecordGuid);

            this._DebugLog.AppendLine(this._dalSubjectRecords.Log);

            //
            // Return newField
            //
            return(item);
        }//END getRecord method
        }//END getRecord method

        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region trial FirstSubject Save methods

        // =====================================================================================
        /// <summary>
        /// This class processes the save items on FirstSubject record ResultData table
        /// </summary>
        /// <param name="AncillaryRecord">EvSubjectRecord: a milestone record object</param>
        /// <returns>EvEventCodes: an event code for processing the save items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the VisitId or SubjectId or Guid is empty.
        ///
        /// 2. Execute the method for adding items, if the action code is new
        ///
        /// 3. Else, execute the method for updating items.
        ///
        /// 4. Return an event code of method execution.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public EvEventCodes saveItem(EvAncillaryRecord AncillaryRecord)
        {
            //
            // Instantiate the local variables
            //
            this._DebugLog.AppendLine("Evado.Digital.Bll.AncillaryRecords.saveItem method. ");
            this._DebugLog.AppendLine("Guid: " + AncillaryRecord.Guid);
            this._DebugLog.AppendLine("ProjectId: " + AncillaryRecord.ProjectId);
            this._DebugLog.AppendLine("SubjectId: " + AncillaryRecord.SubjectId);
            this._DebugLog.AppendLine("Action: " + AncillaryRecord.Action);

            //
            // Exit, if the VisitId or SubjectId or Guid is empty.
            //
            if (AncillaryRecord.ProjectId == String.Empty)
            {
                return(EvEventCodes.Identifier_Project_Id_Error);
            }

            if (AncillaryRecord.SubjectId == String.Empty)
            {
                return(EvEventCodes.Identifier_Subject_Id_Error);
            }

            //
            // Add a new trial Report to the database
            //
            if (AncillaryRecord.Action == EvAncillaryRecords.ACTION_NEW ||
                AncillaryRecord.Guid == Guid.Empty)
            {
                this._DebugLog.AppendLine("Add New Record.");
                return(addRecord(AncillaryRecord));
            }

            //
            // If there is NO Xml content then update the trial Report properties.
            //
            this._DebugLog.AppendLine("Update Record.");
            return(updateItem(AncillaryRecord));
        } // Close method saveSubjectRecord
        } // Close method saveSubjectRecord

        // =====================================================================================
        /// <summary>
        /// This class adds new items on FirstSubject record ResultData table.
        /// </summary>
        /// <param name="AncillaryRecord">EvSubjectRecord: a subjecyt record object</param>
        /// <returns>EvEventCodes: an event code for adding items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for adding items to milestone record ResultData table.
        ///
        /// 2. Return an event code for adding items.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private EvEventCodes addRecord(EvAncillaryRecord AncillaryRecord)
        {
            this._DebugLog.AppendLine("Evado.Digital.Bll.AncillaryRecords. AddRecord method");
            //
            // Define local variables.
            //
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Update the state information in the trial Report.
            //
            this.updateState(AncillaryRecord);

            //
            // Add the new trial record to the database.
            //
            iReturn = this._dalSubjectRecords.addItem(AncillaryRecord);
            this._DebugLog.AppendLine(this._dalSubjectRecords.Log);

            //
            // Return the update status.
            //
            return(iReturn);
        }//END addRecord method.
Esempio n. 13
0
        }//END updateItem method.

        // =====================================================================================
        /// <summary>
        ///  This method sets the data change values for the object and returns the data change
        ///  object.
        /// </summary>
        /// <param name="AncillaryRecord">EvSubjectRecord: A Subject Record object.</param>
        /// <returns>EvDataChange: A DataChange object.</returns>
        /// <remarks>
        /// This method consists of following steps.
        ///
        /// 1. Add items to datachange object if they do not exist on the old Subject Record object.
        ///
        /// 2. Return the datachange object.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private EvDataChange SetDataChange(EvAncillaryRecord AncillaryRecord)
        {
            //
            // Initialise the methods variables and objects.
            //
            EvDataChange dataChange = new EvDataChange( );

            //
            // Retrieve the existing record object for comparision
            //
            EvAncillaryRecord oldRecord = this.getRecord(AncillaryRecord.Guid);

            //
            // Set the chanage objects values.
            //
            dataChange.TableName  = EvDataChange.DataChangeTableNames.EvAncilliaryRecords;
            dataChange.RecordGuid = AncillaryRecord.Guid;
            dataChange.TrialId    = AncillaryRecord.ProjectId;
            dataChange.SubjectId  = AncillaryRecord.SubjectId;
            dataChange.RecordId   = AncillaryRecord.RecordId;
            dataChange.UserId     = AncillaryRecord.UpdatedByUserId;
            dataChange.DateStamp  = DateTime.Now;
            dataChange.RecordGuid = AncillaryRecord.Guid;

            //
            // Add items to datachange object, if they do not exist on the old SubjectRecord object.
            //
            if (AncillaryRecord.ProjectId != oldRecord.ProjectId)
            {
                dataChange.AddItem("TrialId", oldRecord.ProjectId, AncillaryRecord.ProjectId);
            }
            if (AncillaryRecord.SubjectId != oldRecord.SubjectId)
            {
                dataChange.AddItem("SubjectId", oldRecord.SubjectId, AncillaryRecord.SubjectId);
            }
            if (AncillaryRecord.RecordId != oldRecord.RecordId)
            {
                dataChange.AddItem("RecordId", oldRecord.RecordId, AncillaryRecord.RecordId);
            }
            if (AncillaryRecord.Subject != oldRecord.Subject)
            {
                dataChange.AddItem("Subject", oldRecord.Subject, AncillaryRecord.Subject);
            }
            if (AncillaryRecord.Record != oldRecord.Record)
            {
                dataChange.AddItem("Record", oldRecord.Record, AncillaryRecord.Record);
            }
            if (AncillaryRecord.BinaryLength != oldRecord.BinaryLength)
            {
                dataChange.AddItem("BinaryLength", oldRecord.BinaryLength.ToString( ), AncillaryRecord.BinaryLength.ToString( ));
            }
            if (AncillaryRecord.BinaryType != oldRecord.BinaryType)
            {
                dataChange.AddItem("BinaryType", oldRecord.BinaryType, AncillaryRecord.BinaryType);
            }
            if (AncillaryRecord.Researcher != oldRecord.Researcher)
            {
                dataChange.AddItem("Researcher", oldRecord.Researcher, AncillaryRecord.Researcher);
            }
            if (AncillaryRecord.ResearcherUserId != oldRecord.ResearcherUserId)
            {
                dataChange.AddItem("ResearcherUserId", oldRecord.ResearcherUserId, AncillaryRecord.ResearcherUserId);
            }
            if (AncillaryRecord.ResearcherDate != oldRecord.ResearcherDate)
            {
                dataChange.AddItem("ResearcherDate", oldRecord.ResearcherDate.ToString("yyyy MMM dd HH:mm:ss"),
                                   AncillaryRecord.ResearcherDate.ToString("yyyy MMM dd HH:mm:ss"));
            }
            if (AncillaryRecord.Reviewer != oldRecord.Reviewer)
            {
                dataChange.AddItem("Reviewer", oldRecord.Reviewer, AncillaryRecord.Reviewer);
            }
            if (AncillaryRecord.ReviewerUserId != oldRecord.ReviewerUserId)
            {
                dataChange.AddItem("ReviewerUserId", oldRecord.ReviewerUserId, AncillaryRecord.ReviewerUserId);
            }
            if (AncillaryRecord.ReviewDate != oldRecord.ReviewDate)
            {
                dataChange.AddItem("ReviewDate", oldRecord.ReviewDate.ToString("yyyy MMM dd HH:mm:ss"),
                                   AncillaryRecord.ReviewDate.ToString("yyyy MMM dd HH:mm:ss"));
            }
            if (AncillaryRecord.Approver != oldRecord.Approver)
            {
                dataChange.AddItem("Approver", oldRecord.Approver, AncillaryRecord.Approver);
            }
            if (AncillaryRecord.ApproverUserId != oldRecord.ApproverUserId)
            {
                dataChange.AddItem("ApproverUserId", oldRecord.ApproverUserId, AncillaryRecord.ApproverUserId);
            }
            if (AncillaryRecord.ApprovalDate != oldRecord.ApprovalDate)
            {
                dataChange.AddItem("ApprovalDate", oldRecord.ApprovalDate.ToString("yyyy MMM dd HH:mm:ss"),
                                   AncillaryRecord.ApprovalDate.ToString("yyyy MMM dd HH:mm:ss"));
            }

            //
            // Return the data change object containing an EvDataChange object.
            //
            return(dataChange);
        }//END SetDataChange method
Esempio n. 14
0
        }//END getRecord method

        // =====================================================================================
        /// <summary>
        /// This method retrieves the SubjectRecord data table based on RecordId and state value.
        /// </summary>
        /// <param name="RecordId">string: A Record identifier</param>
        /// <param name="State">string: a milestone record's state</param>
        /// <returns>An object containing an EvSubjectRecord object.</returns>
        /// <returns>EvSubjectRecord: A Subject data object</returns>
        /// <remarks>
        /// This method consists of following steps:
        ///
        /// 1. Return an empty SubjectRecord object, if the RecordId is empty.
        ///
        /// 2. Define the sql query parameters and sql query string.
        ///
        /// 3. Execute the sql query string and store the results on datatable.
        ///
        /// 4. Return an empty SubjectRecord object, if the table has no value.
        ///
        /// 5. Else, extract the first data row to the SubjectRecord object.
        ///
        /// 6. Return the SubjectRecord object.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public EvAncillaryRecord getRecord(string RecordId, string State)
        {
            this.LogMethod("getRecord");
            this.LogValue("RecordId: " + RecordId);
            this.LogValue("State: " + State);
            //
            // Define the local variables.
            //
            EvAncillaryRecord record = new EvAncillaryRecord( );

            //
            // If Record does not exist, return an object containing EvSubjectRecord object.
            //
            if (RecordId == String.Empty)
            {
                return(record);
            }

            //
            // Define the parameters for the query.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(PARM_RecordId, SqlDbType.NVarChar, 20),
                new SqlParameter(PARM_State, SqlDbType.Char, 5),
            };
            cmdParms [0].Value = RecordId;
            cmdParms [1].Value = State;

            _sqlQueryString = _sqlQuery_View + " WHERE ( RecordId = @RecordId )"
                              + " AND ( TSR_State = @State );";

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // If no rows found, return an object containing an EvSubjectRecord object.
                //
                if (table.Rows.Count == 0)
                {
                    return(record);
                }

                //
                // Extract the table row.
                //
                DataRow row = table.Rows [0];

                //
                // Fill the EvSubjectRecord object.
                //
                record = this.readRowData(row);
            }//END Using statement

            //
            // Return an object containing an EvSubjectRecord object.
            //
            return(record);
        }//END getRecord method
Esempio n. 15
0
        }//END getRowData

        #endregion

        #region List Queries

        // =====================================================================================
        /// <summary>
        /// This method returns a list of Subject record object based on TrialId, SubjectId, State and OrderBy value
        /// </summary>
        /// <param name="ProjectId">String: A Project identifier.</param>
        /// <param name="SubjectId">String: A Subject identifier</param>
        /// <param name="State">String: A string that defines the record state to the query.</param>
        /// <param name="OrderBy">String: A string that defines the sorting order of the result set.</param>
        /// <returns>List of EvSubjectRecord: A list containing SubjectRecord object.</returns>
        /// <remarks>
        /// This method consists of following steps.
        ///
        /// 1. Define the sql query parameters and sql query string.
        ///
        /// 2. Execute the sql query string and store the results on datatable.
        ///
        /// 3. Loop through the table and extract data row to the SubjectRecord object.
        ///
        /// 4. Add SubjectRecord object's values to the list of Subject Records
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public List <EvAncillaryRecord> getView(string ProjectId,
                                                string SubjectId, string State, string OrderBy)
        {
            this.LogMethod("getView, ");
            this.LogValue("ProjectId: " + ProjectId);
            this.LogValue("SubjectId: " + SubjectId);
            //
            // Define the local variable.
            //
            List <EvAncillaryRecord> view = new List <EvAncillaryRecord>( );

            //
            // Define the query parameters.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(PARM_TrialId, SqlDbType.NVarChar, 10),
                new SqlParameter(PARM_SubjectId, SqlDbType.NVarChar, 20),
                new SqlParameter(PARM_State, SqlDbType.VarChar, 20),
            };
            cmdParms [0].Value = ProjectId;
            cmdParms [1].Value = SubjectId;
            cmdParms [2].Value = State;

            //
            // Generate the SQL query string.
            //
            _sqlQueryString = _sqlQuery_View + " WHERE ( ( TrialId = @TrialId ) ";

            if (SubjectId.Length > 0)
            {
                _sqlQueryString += " AND ( SubjectId = @SubjectId ) ";
            }
            if (State.Length > 0)
            {
                _sqlQueryString += " AND (TSR_State = @State) ";
            }

            if (OrderBy.Length == 0)
            {
                _sqlQueryString += ") ORDER BY RecordId";
            }
            else
            {
                _sqlQueryString += ") ORDER BY " + OrderBy;
            }

            this.LogDebug(_sqlQueryString);

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // Iterate through the results extracting the role information.
                //
                for (int count = 0; count < table.Rows.Count; count++)
                {
                    //
                    // Extract the table row.
                    //
                    DataRow row = table.Rows [count];

                    EvAncillaryRecord record = this.readRowData(row);

                    view.Add(record);
                } //END count interation
            }     //END Using statement

            //
            // Return a list containing an EvSubjectRecord object.
            //
            return(view);
        }//END getView method.
        }//END unlockItem method

        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region Ancillary Record state update

        // =====================================================================================
        /// <summary>
        /// This class updates the Record state and approve records for the Record.
        /// </summary>
        /// <param name="AncillaryRecord">EvSubjectRecord: a milestone record object</param>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Update the Authenticated userId, if it exists.
        ///
        /// 2. Update the SubjectRecord object and userSignoff object
        /// based on the milestone record's state and action
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private void updateState(EvAncillaryRecord AncillaryRecord)
        {
            this._DebugLog.AppendLine("Evado.Digital.Bll.AncillaryRecords.updateState method. ");
            this._DebugLog.AppendLine("Action: " + AncillaryRecord.Action);

            //
            // Define the local variables.
            //
            string        dt          = DateTime.Now.ToString("MMM dd yyyy");
            EdUserSignoff userSignoff = new EdUserSignoff( );

            //
            // IF the signoff object is null then initialise it.
            //
            if (AncillaryRecord.Signoffs == null)
            {
                AncillaryRecord.Signoffs = new List <EdUserSignoff> ( );
            }

            //
            // If the instrument has an authenticated signoff pass the user id to the
            // to the DAL layer and DB.
            //
            string AuthenticatedUserId = String.Empty;

            if (AncillaryRecord.IsAuthenticatedSignature == true)
            {
                AuthenticatedUserId = AncillaryRecord.UpdatedByUserId;
            }

            //
            // Save the trial record to the database.
            //
            // If state is null set it to created.
            //
            if (AncillaryRecord.State == EdRecordObjectStates.Null)
            {
                AncillaryRecord.State = EdRecordObjectStates.Draft_Record;
            }

            //
            // If the record state is created then reset the approveal properties.
            //
            if (AncillaryRecord.State == EdRecordObjectStates.Draft_Record)
            {
                AncillaryRecord.Reviewer     = String.Empty;
                AncillaryRecord.ReviewDate   = Evado.Digital.Model.EvcStatics.CONST_DATE_NULL;
                AncillaryRecord.Approver     = String.Empty;
                AncillaryRecord.ApprovalDate = Evado.Digital.Model.EvcStatics.CONST_DATE_NULL;
            }

            //
            // Perform author signoff of the record and save it to the database.
            //
            if (AncillaryRecord.Action == EvAncillaryRecords.ACTION_SIGNED)
            {
                this._DebugLog.AppendLine("Researcher Signoff record.");
                AncillaryRecord.State            = EdRecordObjectStates.Submitted_Record;
                AncillaryRecord.Researcher       = AncillaryRecord.UserCommonName;
                AncillaryRecord.ResearcherUserId = AuthenticatedUserId;
                AncillaryRecord.ResearcherDate   = DateTime.Now;

                userSignoff.Type            = EdUserSignoff.TypeCode.Record_Author_Signoff;
                userSignoff.SignedOffUserId = AuthenticatedUserId;
                userSignoff.SignedOffBy     = AncillaryRecord.UserCommonName;
                userSignoff.SignOffDate     = AncillaryRecord.ResearcherDate;
                AncillaryRecord.Signoffs.Add(userSignoff);



                return;
            }

            //
            // Perform withdrawn of the trial record and save it to the database.
            //
            if (AncillaryRecord.Action == EvAncillaryRecords.ACTION_WITHDRAW &&
                AncillaryRecord.Reviewer == String.Empty &&
                AncillaryRecord.Approver == String.Empty)
            {
                this._DebugLog.AppendLine("Withdrawn Record.");
                AncillaryRecord.State = EdRecordObjectStates.Withdrawn;

                return;
            }
        }//END updateState method.