// ================================================================================== /// <summary> /// This methods performs a MarkDown text substitution in the Content text passed into the /// method and returns text with the relevant text substitutions. /// </summary> /// <param name="Content">String: MarkDown text containing the values to be substituted</param> /// <param name="SubjectMilestone">EvMilestone: the subject milestone</param> /// <returns>Markdown String</returns> // --------------------------------------------------------------------------------- public String substituteDataValue( String Content, EdRecord CommonRecord, String ConsentUrl) { String content = this.substituteDataValue(Content); // // retreive the Questionnaire URL from the config and add Guid to it. // if (ConsentUrl != String.Empty) { ConsentUrl += CommonRecord.Guid.ToString( ); content = content.Replace(EvcStatics.TEXT_SUBSITUTION_CONSENT_URL, ConsentUrl.Trim( )); } // // Return the substituted text content. // return(content); }
}//END saveRecord method. #endregion #region Form Record state update // ===================================================================================== /// <summary> /// This class updates the form Record state and approve records for the FirstSubject. /// </summary> /// <param name="Entity">EvForm: a form object.</param> /// <param name="HadEditAccess">EvRole: a user role object</param> /// <remarks> /// This method consists of the following steps: /// /// 1. Update the authenticated user, if it exists. /// /// 2. Update the form state based on the associated form object's values. /// /// 3. Execute the associated methods for processing sign off object. /// /// </remarks> // ---------------------------------------------------------------------------------- private void updateFormState ( EdRecord Entity ) { this.LogMethod ( "updateState method. " ); this.LogValue ( "RecordId: " + Entity.RecordId ); this.LogValue ( "Action: " + Entity.SaveAction ); // // Initialise the methods variables and objects. // // // Save the trial record to the database. // // If state is null set it to created. // if ( Entity.State == EdRecordObjectStates.Null ) { Entity.State = EdRecordObjectStates.Empty_Record; } // // If the Author edits the record reset the review and approval states. // if ( ( Entity.FormAccessRole == EdRecord.FormAccessRoles.Record_Author ) && ( Entity.SaveAction == EdRecord.SaveActionCodes.Save_Record ) && ( Entity.State == EdRecordObjectStates.Submitted_Record ) ) { this.setDraftRecordStatus ( Entity ); return; }//END reset record status // // Perform author signoff of the record and save it to the database. // if ( ( Entity.FormAccessRole == EdRecord.FormAccessRoles.Record_Author ) && ( Entity.SaveAction == EdRecord.SaveActionCodes.Submit_Record ) ) { this.LogValue ( "Author submitting a record." ); this.submitRecordSignoff ( Entity ); } // // Perform withdrawn of the trial record and save it to the database. // if ( Entity.SaveAction == EdRecord.SaveActionCodes.Withdrawn_Record && ( Entity.State == EdRecordObjectStates.Empty_Record || Entity.State == EdRecordObjectStates.Draft_Record || Entity.State == EdRecordObjectStates.Completed_Record ) ) { this.LogValue ( " Withdrawn Record." ); Entity.State = EdRecordObjectStates.Withdrawn; return; } }//END updateState method.
}//END getHeaderForm method #region Header methods // ================================================================================== /// <summary> /// This method creates the export ResultData header. /// </summary> /// <param name="HeaderRecord">EvForm: a form object</param> /// <param name="ExportFreeText">Boolean: true, if the free text fields are exported</param> /// <returns>String: the export record header string</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Loop through the form object items. /// /// 2. Switch the formfield QueryType and append the formfield values to the header. /// /// 3. Return the header string. /// </remarks> // ---------------------------------------------------------------------------------- private int createExportRecordHeader( EdRecord HeaderRecord, bool ExportFreeText) { this.LogMethod("createExportRecordHeader method "); this._OutputDataColumnCount = 7; // // Output the header static fields // System.Text.StringBuilder sbHeader = new System.Text.StringBuilder( ); sbHeader.Append(";" + StaticHeaderColumns.RecordId); sbHeader.Append(";" + StaticHeaderColumns.RecordDate); // // Output the form field header information // foreach (EdRecordField formField in HeaderRecord.Fields) { this.LogDebug("FieldId: " + formField.FieldId + ", Type: " + formField.TypeId); if (formField.isReadOnly == true) { continue; } // // Select the field QueryType to create the correct header. // switch (formField.TypeId) { case EvDataTypes.Table: case EvDataTypes.Special_Matrix: { sbHeader.Append(this.ExportTableHeader(formField)); break; } case EvDataTypes.Check_Box_List: { sbHeader.Append(this.ExportCheckBoxHeader(formField)); break; } case EvDataTypes.Free_Text: { if (ExportFreeText == true) { sbHeader.Append(";" + formField.FieldId); } break; } default: { sbHeader.Append(";" + formField.FieldId); break; } } //END switch } //END iteration loop // // Output the right hand static fields // sbHeader.Append(";" + StaticHeaderColumns.Comments); sbHeader.Append(";" + StaticHeaderColumns.AuthoredBy); sbHeader.Append(";" + StaticHeaderColumns.AuthoredDate); sbHeader.Append(";" + StaticHeaderColumns.ReviewedBy); sbHeader.Append(";" + StaticHeaderColumns.ReviewedDate); sbHeader.Append(";" + StaticHeaderColumns.MonitoredBy); sbHeader.Append(";" + StaticHeaderColumns.MonitorDate); sbHeader.Append(";" + StaticHeaderColumns.LockedBy); sbHeader.Append(";" + StaticHeaderColumns.LockedDate); this._ExportColumnHeader = sbHeader.ToString( ).Split(';'); this.LogMethodEnd("createExportRecordHeader"); return(this._ExportColumnHeader.Length); }//END getExportDataHeader method.
}//END exportProjectRecords method //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #endregion #region export methods // ===================================================================================== /// <summary> /// This method creates the content for the common record export file as a CSV file. /// </summary> /// <param name="FormRecordList">List of EvForm: a list of form objects</param> /// <param name="UserProfile">Evado.Digital.Model.EdUserProfile: The user profile.</param> /// <param name="IncludeFreeTextData">Boolean: True, if the free text fields are exported.</param> /// <param name="IncludeDraftRecords">Boolean: True, if the initialised records are included</param> /// <returns>String: an export file string. </returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the form objects list is empty. /// /// 2. Loop through the form list and the associated form field list. /// /// 3. Add the formfield list's values to the output string. /// /// 4. Return the output string. /// </remarks> // ---------------------------------------------------------------------------------- public String createExportFile( System.Collections.Generic.List <EdRecord> FormRecordList, Evado.Digital.Model.EdUserProfile UserProfile, bool IncludeFreeTextData, bool IncludeDraftRecords) { this.LogMethod("createExportFile method "); this.LogDebug("IncludeFreeTextData:" + IncludeFreeTextData); this.LogDebug("IncludeDraftRecords:" + IncludeDraftRecords); try { // // Initialise the methods variables and objects. // EdRecord headerForm = new EdRecord( ); System.Text.StringBuilder stCsvData = new System.Text.StringBuilder( ); // // Only process the common records if more than one exists. // if (FormRecordList.Count == 0) { this.LogDebug("FormRecordList count is zero."); this.EventCode = EvEventCodes.Data_Export_Empty_Record_List; this.LogMethodEnd("createExportFile"); return(stCsvData.ToString( )); } // // Using the last record get a form header i.e. the latest version. // headerForm = FormRecordList [(FormRecordList.Count - 1)]; // // Create the report header // stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Form Type: " + EvStatics.getEnumStringValue(headerForm.TypeId))); stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("FormId: " + headerForm.LayoutId)); stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Form Title: " + headerForm.Title)); stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Exported on: " + DateTime.Now.ToString("dd MMM yyyy HH:mm") + " By " + UserProfile.CommonName)); this.LogDebug("Form Type: " + headerForm.Design.TypeId); this.LogDebug("FormId: " + headerForm.LayoutId); this.LogDebug("Form Title: " + headerForm.Title); this.LogDebug("Exported on: " + DateTime.Now.ToString("dd MMM yyyy HH:mm") + " By " + UserProfile.CommonName); // // Ouput the ResultData header. // this._OutputDataColumnCount = this.createExportRecordHeader(headerForm, IncludeFreeTextData); // // Append the CSV data header row. // stCsvData.AppendLine(this.ConvertToCsv(this._ExportColumnHeader)); this.LogDebug("Commence export record data."); // // Iterate through the datagrid processing each letter in the grid // foreach (EdRecord record in FormRecordList) { this._ExportColumnRow = new string [this._OutputDataColumnCount]; // // IF the item is a valid record output it. // if (record.State == EdRecordObjectStates.Withdrawn) { this.LogDebug("RecordID: " + record.RecordId + " >> Withdrawn or querid record."); continue; } if (record.State == EdRecordObjectStates.Draft_Record && IncludeDraftRecords == false) { this.LogDebug("RecordID: " + record.RecordId + " >> Initialised record."); continue; } this.LogDebug("RecordID: " + record.RecordId); this.LogDebug("Field Count: " + record.Fields.Count); // // Output the record left hand static fields. // this._ExportColumnRow [0] = record.RecordId; this._ExportColumnRow [1] = record.stRecordDate; // // Output the record fields // foreach (EdRecordField recordField in record.Fields) { this.LogDebug("FieldId: " + recordField.FieldId); this.LogDebug("field Type: " + recordField.TypeId); this.LogDebug("Field Guid: " + recordField.Guid); this.LogDebug("ItemValue: " + recordField.ItemValue); this.LogDebug("ItemText: " + recordField.ItemText); if (recordField.isReadOnly == true) { continue; } // // Export form field // if (recordField.Guid == Guid.Empty) { continue; } // // select the field type to export. // switch (recordField.TypeId) { case EvDataTypes.Special_Matrix: case EvDataTypes.Table: { this.ExportTableData(recordField); break; } case EvDataTypes.Check_Box_List: { this.ExportCheckBoxData(recordField); break; } default: { this.getExportRecordFieldData( recordField, IncludeFreeTextData); break; } } //END switch statement } //END field iteration loop. this.LogDebug("Comment.Count: " + record.CommentList.Count); String stComments = String.Empty; foreach (EdFormRecordComment comment in record.CommentList) { stComments += comment.Content + " by " + comment.UserCommonName + " on " + comment.CommentDate.ToString("dd-MMM-yy HH:mm") + " "; } // // record footer information // this.exportColumnValue(StaticHeaderColumns.Comments, stComments); // // Convert the output row into a CSV row. // stCsvData.AppendLine(this.ConvertToCsv(this._ExportColumnRow)); }//END record list iteration loop this.LogDebug("ExportFile length: " + stCsvData.Length); this.LogMethodEnd("createExportFile"); // // Return the new record. // return(stCsvData.ToString( )); } //End Try catch (Exception Ex) { this.EventCode = EvEventCodes.Data_Export_Exception_Event; this.LogException(Ex); } // End catch. this.LogMethodEnd("createExportFile"); return(String.Empty); }//END createExportFile class
} //END onLoadForm method // ================================================================================== /// <summary> /// /// This method is executed when the field is updated. The array of fields is /// passed to the script to provide access to the other field values. /// /// </summary> /// <param name="FileName">FileName object</param> /// <param name="Form">Form object</param> /// <returns>New computed OnUpdateForm value.</returns> // --------------------------------------------------------------------------------- private EvEventCodes onUpdatePage(string FileName, EdRecord Form) { this._debugLog.AppendLine(Evado.Digital.Model.EvcStatics.CONST_METHOD_START + "Evado.UniForm.Clinical.EvServerPageScript.onUpdatePage"); try { // // Define local variables. // bool bResult = true; // // Read in the script file to be used. // EvEventCodes iReturn = getScript(FileName); if (iReturn != EvEventCodes.Ok) { this._debugLog.AppendLine("Script not found."); // // stReturn ScriptNotFound indicating that the script has not been loaded. // return(iReturn); } // // Load the script into memory and flash compile it for use. // AsmHelper scriptAsm = new AsmHelper(CSScript.LoadCode(this._Script, null, true)); // // Execute the script method // bResult = (bool)scriptAsm.Invoke("ServerPageScript.onUpdatePage", Form); // // Displose of the script object. // scriptAsm.Dispose( ); this._debugLog.AppendLine("ScriptMessage: " + Form.ScriptMessage); // // Set the return error status. // if (bResult == false) { // // stReturn ReturnError: indicating that the script exited permaturely. // return(EvEventCodes.CsFormScript_Method_Return_Value_Error); } // // stReturn the updates script result. // return(EvEventCodes.Ok); } catch (Exception Ex) { // // Append the exception to the status variable. // this._debugLog.AppendLine("Evado.UniForm.Clinical.EvServerPageScript.onUpdatePage exception:"); this._debugLog.AppendLine(Evado.Digital.Model.EvcStatics.getException(Ex)); // // stReturn MethodException : indicating that the script raised an Error Exception. // return(EvEventCodes.CsFormScript_Method_Exception_Error); } //END catch } //END onUpdateForm method
// ===================================================================================== /// <summary> /// This class updates the fields on formfield table using field list, RecordUid and usercommon name. /// </summary> /// <param name="FormRecord">EvForm object</param> /// <returns>EvEventCodes: an event code for updating fields</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Iterate through the formfields object. /// /// 2. If Guid is empty, add new field. /// /// 3. Return the event code for updating items. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes UpdateFields( EdRecord FormRecord) { this.LogMethod("UpdateFields method "); this.LogDebug("RecordFieldList.Count: " + FormRecord.Fields.Count); this.LogDebug("SubmitRecord: " + FormRecord.State); // // Initialize the method debug log and the return event code. // List <SqlParameter> ParmList = new List <SqlParameter> ( ); StringBuilder SqlUpdateStatement = new StringBuilder( ); // // Define the record Guid value for the update queies // SqlParameter prm = new SqlParameter(EdRecordValues.PARM_RECORD_GUID, SqlDbType.UniqueIdentifier); prm.Value = FormRecord.Guid; ParmList.Add(prm); // // Delete the sections // SqlUpdateStatement.AppendLine("DELETE FROM ED_RECORD_VALUES " + "WHERE " + EdRecordValues.DB_RECORD_GUID + "= " + EdRecordValues.PARM_RECORD_GUID + "; \r\n\r\n"); // // Iterate through the formfields object. // foreach (EdRecordField field in FormRecord.Fields) { if (field == null) { //this.LogDebugValue ( "FIELD NULL" ); continue; } // // If the field guid is empty create a new one. // if (field.Guid == Guid.Empty) { field.Guid = Guid.NewGuid( ); } this.LogDebug("field.FormFieldGuid: " + field.FieldGuid); this.LogDebug("field.Guid: " + field.Guid); // // Create the list of update queries and parameters. // this.GenerateUpdateQueryStatements( SqlUpdateStatement, ParmList, field); this._ValueCount++; }//END FormField Update Iteration. this.LogDebug(SqlUpdateStatement.ToString( )); // // Convert the list to an array of SqlPararmeters. // SqlParameter [] parms = new SqlParameter [ParmList.Count]; for (int i = 0; i < ParmList.Count; i++) { parms [i] = ParmList [i]; } this.LogDebug(EvSqlMethods.getParameterSqlText(parms)); // // Execute the update command. // try { if (EvSqlMethods.QueryUpdate(SqlUpdateStatement.ToString( ), parms) == 0) { return(EvEventCodes.Database_Record_Update_Error); } } catch (Exception Ex) { this.LogDebug(Evado.Model.EvStatics.getException(Ex)); } return(EvEventCodes.Ok); }//END UpdateFields method
}//END processNotAvailableValues method #endregion #region Record field list Queries // ===================================================================================== /// <summary> /// This class returns a list of formfield object retrieved by the record Guid. /// </summary> /// <param name="Record">EvForm: (Mandatory) The record object.</param> /// <param name="IncludeComments">bool: true = include field comments.</param> /// <returns>List of EvFormField: a formfield object.</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Return an empty formfield object if the record's Guid is empty /// /// 2. Define the sql query parameters and sql query string /// /// 3. Execute the sql query string with parameters and store the results on data table. /// /// 4. Iterate through the table and extract the data row to the formfield object. /// /// 5. Add object result to the formfields list. /// /// 6. Return the formfields list. /// </remarks> // ------------------------------------------------------------------------------------- public List <EdRecordField> getRecordFieldList( EdRecord Record) { this.LogMethod("getRecordFieldList method. "); this.LogDebug("Record.Guid: " + Record.Guid); // // Initialise the methods variables and objects. // List <EdRecordField> recordFieldList = new List <EdRecordField> ( ); EdRecordField recordField = new EdRecordField( ); Guid previousValueGuid = Guid.Empty; // // Validate whether the record Guid is not empty. // if (Record.Guid == Guid.Empty) { return(recordFieldList); } // // Define the SQL query parameters. // SqlParameter [] cmdParms = new SqlParameter [] { new SqlParameter(PARM_RECORD_GUID, SqlDbType.UniqueIdentifier), }; cmdParms [0].Value = Record.Guid; // // Define the query string. // _Sql_QueryString = SQL_QUERY_VALUES_VIEW + " WHERE ( " + EdRecordValues.DB_RECORD_GUID + " =" + EdRecordValues.PARM_RECORD_GUID + ") " + "ORDER BY " + EdRecordFields.DB_ORDER + "; "; this.LogDebug(_Sql_QueryString); // // Execute the query against the database. // using (DataTable table = EvSqlMethods.RunQuery(_Sql_QueryString, cmdParms)) { if (table.Rows.Count == 0) { return(recordFieldList); } // // 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]; Guid recordValueGuid = EvSqlMethods.getGuid(row, EdRecordValues.DB_VALUES_GUID); this.LogDebug("previousValueGuid: {0}, recordValueGuid: {1}.", previousValueGuid, recordValueGuid); // // Empty fields are skipped. // if (recordValueGuid == Guid.Empty) { this.LogDebug("Skip the value Guid is empty."); continue; } // If the field guid has changed then it is a new field. // So add the previous field then get the data for the new field. // if (previousValueGuid != recordValueGuid) { this.LogDebug("Change of recordValueGuid."); // // Add the last field to the list. // if (recordField.Guid != Guid.Empty) { this.LogDebug("Add field to record field list."); recordFieldList.Add(recordField); } // // Get the object data from the row. // recordField = this.getRowData(row); // // skip all non summary field if summary fields is selected. // if (Record.Design.LinkContentSetting != EdRecord.LinkContentSetting.First_Text_Field && Record.SelectOnlySummaryFields == true && recordField.Design.IsSummaryField == false) { this.LogDebug("{0} is a summary field so SKIPPED.", recordField.FieldId); continue; } // // skip all non summary field if summary fields is selected. // if (Record.Design.LinkContentSetting != EdRecord.LinkContentSetting.First_Text_Field && count > 1) { this.LogDebug("{0} first field retrieved so SKIPPED.", recordField.FieldId); continue; } // // Update the lst field guid to enable the other field values to be collected. // previousValueGuid = recordField.Guid; }//END create new field object. this.LogDebug("Read in value data."); switch (recordField.TypeId) { case Evado.Model.EvDataTypes.Special_Matrix: case Evado.Model.EvDataTypes.Table: { this.getTableCellValue(row, recordField); break; } case Evado.Model.EvDataTypes.Check_Box_List: { this.getCheckBoxValue(row, recordField); break; } case Evado.Model.EvDataTypes.Numeric: { recordField.ItemValue = EvSqlMethods.getString(row, EdRecordValues.DB_VALUES_NUMERIC); this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemValue); break; } case Evado.Model.EvDataTypes.Boolean: case Evado.Model.EvDataTypes.Yes_No: { bool bValue = EvSqlMethods.getBool(row, EdRecordValues.DB_VALUES_NUMERIC); this.LogDebug("bValue: {0}.", bValue); recordField.ItemValue = "No"; if (bValue == true) { recordField.ItemValue = "Yes"; } this.LogDebug("recordField.ItemValue: {0} bool.", recordField.ItemValue); break; } case Evado.Model.EvDataTypes.Date: { var dtValue = EvSqlMethods.getDateTime(row, EdRecordValues.DB_VALUES_DATE); recordField.ItemValue = EvStatics.getDateAsString(dtValue); this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemValue); break; } case Evado.Model.EvDataTypes.Free_Text: { recordField.ItemText = EvSqlMethods.getString(row, EdRecordValues.DB_VALUES_TEXT); this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemText); break; } default: { if (recordField.isReadOnly == true) { break; } recordField.ItemValue = EvSqlMethods.getString(row, EdRecordValues.DB_VALUES_STRING); this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemValue); break; } } } //ENR record iteration loop. } //ENd using statement // // Add the last field to the list. // if (recordField.Guid != Guid.Empty) { recordFieldList.Add(recordField); } // // Return the formfields list. // return(recordFieldList); }//END getRecordFieldList method.
}//END SaveItem method // ===================================================================================== /// <summary> /// This class updates the form state and approve records for the trial. /// </summary> /// <param name="Layout">EvForm: a form object</param> /// <remarks> /// This method consists of the following steps: /// /// 1. Update the Authenticated userId if it exists. /// /// 2. Update the form object's values and its state based on the form actions: review, approved, withdrawn or draft. /// </remarks> // ------------------------------------------------------------------------------------- private void updateState(EdRecord Layout) { this.LogMethod("updateState."); this.LogValue("Action: " + Layout.SaveAction); // // Initialise the local variables // // // If the form has an authenticated signoff pass the user id to the // to the DAL layer and DB. // string AuthenticatedUserId = this.ClassParameters.UserProfile.UserId; // // Set the form to reviewed. // if (Layout.SaveAction == EdRecord.SaveActionCodes.Layout_Update) { this.LogValue("Layout updated"); Layout.Design.Version += 0.01F; return; } // // Set the form to reviewed. // if (Layout.SaveAction == EdRecord.SaveActionCodes.Layout_Saved) { this.LogValue("Saving Form"); Layout.State = EdRecordObjectStates.Form_Draft; Layout.Design.Version += 0.01F; return; } // // Set the form to reviewed. // if (Layout.SaveAction == EdRecord.SaveActionCodes.Layout_Reviewed) { this.LogValue("Reviewing Form"); Layout.State = EdRecordObjectStates.Form_Reviewed; return; } if (Layout.SaveAction == EdRecord.SaveActionCodes.Layout_Approved) { this.LogValue("Issuing Form"); Layout.State = EdRecordObjectStates.Form_Issued; int version = (int)Layout.Design.Version; Layout.Design.Version = version + 1.00F; return; } if (Layout.SaveAction == EdRecord.SaveActionCodes.Layout_Withdrawn) { Layout.State = EdRecordObjectStates.Withdrawn; return; } // // If none of the above occur, save the record // this.LogValue("Saving Form. State:" + Layout.State); if (Layout.State == EdRecordObjectStates.Null) { Layout.State = EdRecordObjectStates.Form_Draft; } Layout.Design.Version += 0.01F; return; }//END updateState method.
}// Close GetIssuedItem method #endregion #region Update form object methods // =================================================================================== /// <summary> /// This class saves items to form ResultData table /// </summary> /// <param name="Layout">EvForm: a form object</param> /// <returns>EvEventCodes: an event code for saving items</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the UserCommonName or VisitId or FormId is empty. /// /// 2. Execute the method for deleting items, if the action code is delete /// /// 3. Execute the method for adding items, if the form Uid is empty. /// /// 4. Else, execute the method for updating items /// /// 5. Return an event code of the method execution. /// </remarks> // ------------------------------------------------------------------------------------- public EvEventCodes SaveItem(EdRecord Layout) { this.LogMethod("saveForm"); this.LogValue("Action: " + Layout.SaveAction); // // Initialise the local variables // EdEntityFields formFields = new EdEntityFields(this.ClassParameters); EvEventCodes iReturn = EvEventCodes.Ok; if (Layout.LayoutId == String.Empty) { this.LogValue("Empty FormId"); return(EvEventCodes.Identifier_Form_Id_Error); } // // If the Action is DELETE and the state is draft. // if (Layout.SaveAction == EdRecord.SaveActionCodes.Layout_Deleted && Layout.State == EdRecordObjectStates.Form_Draft) { iReturn = this._Dal_RecordLayouts.DeleteItem(Layout); if (iReturn != EvEventCodes.Ok) { return(iReturn); } // // Withdraw the TestReport items associated with this TestReport. // iReturn = formFields.DeleteFields(Layout); return(iReturn); } // // Update the form state based on the form object Action property. // this.updateState(Layout); this.LogValue("Form State: " + Layout.State); // // If the trial is in use and not being re-issued then it cannot be withdrawn. // // Check if trial has been used. If so return an error. // if (Layout.State == EdRecordObjectStates.Withdrawn) { }//END trial state is withdrawn. // // If the unique identifier is null then add this object as a new // form object. // this.LogValue("Save Form to Database."); if (Layout.Guid == Guid.Empty) // Add new form { this.LogValue("Add Form to database"); // // Add the trial to the database. // iReturn = this._Dal_RecordLayouts.AddItem(Layout); this.LogClass(this._Dal_RecordLayouts.Log); // // Return the DAL DebugLog. // return(iReturn); }//END Add new trial. // // If the trial being approved then withdraw the pervious issues trial // if (Layout.SaveAction == EdRecord.SaveActionCodes.Layout_Approved) { this.LogValue("Withdraw the form"); // // Update the trial to withdraw is from use. // iReturn = this._Dal_RecordLayouts.WithdrawIssuedForm(Layout); this.LogClass(this._Dal_RecordLayouts.Log); } // // Update the trial object. // this.LogValue("Update Form "); // // Update the trial int the database. // iReturn = this._Dal_RecordLayouts.UpdateItem(Layout); this.LogClass(this._Dal_RecordLayouts.Log); // // Return the DAL DebugLog. // return(iReturn); }//END SaveItem method
}//END getListObject method. // ============================================================================== /// <summary> /// This method creates the record view pageMenuGroup containing a list of commands to /// open the form record. /// </summary> /// <param name="PageObject">Evado.Model.Uniform.Page object to add the pageMenuGroup to.</param> // ------------------------------------------------------------------------------ private void getList_SelectionGroup ( Evado.UniForm.Model.Page PageObject ) { this.LogMethod ( "getList_SelectionGroup" ); this.LogDebug ( "IssuedEntityLayouts.Count {0}. ", this.AdapterObjects.IssuedEntityLayouts.Count ); // // Initialise the methods variables and objects. // Evado.UniForm.Model.Group pageGroup = new Evado.UniForm.Model.Group ( ); List<EvOption> optionList; Evado.UniForm.Model.Field selectionField; if ( this._HideSelectionGroup == true ) { this.LogMethodEnd ( "getList_SelectionGroup" ); return; } // // Create the new pageMenuGroup for record selection. // pageGroup = PageObject.AddGroup ( EdLabels.Entities_Selection_Group_Title, Evado.UniForm.Model.EditAccess.Enabled ); pageGroup.GroupType = Evado.UniForm.Model.GroupTypes.Default; pageGroup.Layout = Evado.UniForm.Model.GroupLayouts.Full_Width; pageGroup.AddParameter ( Evado.UniForm.Model.GroupParameterList.Offline_Hide_Group, true ); // // Add the record state selection option // optionList = new List<EvOption> ( ); optionList.Add ( new EvOption ( ) ); foreach ( EdRecord layout in this.AdapterObjects.IssuedEntityLayouts ) { optionList.Add ( new EvOption ( layout.LayoutId, String.Format ( "{0} - {1}", layout.LayoutId, layout.Title ) ) ); } selectionField = pageGroup.createSelectionListField ( EdRecord.FieldNames.Layout_Id, EdLabels.Label_Form_Id, this.Session.Selected_EntityLayoutId, optionList ); selectionField.Layout = EuAdapter.DefaultFieldLayout; selectionField.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 ); // // Add the record state selection option // optionList = EdRecord.getRecordStates ( false ); selectionField = pageGroup.createSelectionListField ( EdRecord.FieldNames.Status.ToString ( ), EdLabels.Record_State_Selection, this.Session.EntityStateSelection, optionList ); selectionField.Layout = EuAdapter.DefaultFieldLayout; selectionField.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 ); // // Add the selection groupCommand // Evado.UniForm.Model.Command selectionCommand = pageGroup.addCommand ( EdLabels.Select_Records_Command_Title, EuAdapter.ADAPTER_ID, EuAdapterClasses.Entities.ToString ( ), Evado.UniForm.Model.ApplicationMethods.Custom_Method ); selectionCommand.setCustomMethod ( Evado.UniForm.Model.ApplicationMethods.List_of_Objects ); }//ENd getList_SelectionGroup method
}//END getEntity_Summary_ListGroup method // ============================================================================== /// <summary> /// This method appends the milestone groupCommand to the page milestone list pageMenuGroup /// </summary> /// <param name="Entity">EvForm object</param> /// <param name="PageGroup"> Evado.UniForm.Model.Group</param> // ----------------------------------------------------------------------------- private void getGroupSummaryListGroup ( EdRecord Entity, Evado.UniForm.Model.Page PageObject ) { this.LogMethod ( "getGroupSummaryListGroup" ); this.LogDebug ( "Entity.EntityId: " + Entity.EntityId ); this.LogDebug ( "LinkContentSetting: " + Entity.Design.LinkContentSetting ); this.LogDebug ( "DefaultPageLayout: " + Entity.Design.DefaultPageLayout ); // // Initialise the methods variables and objects. // Evado.UniForm.Model.Group pageGroup = new Evado.UniForm.Model.Group ( ); Evado.UniForm.Model.Field groupField = new Evado.UniForm.Model.Field ( ); Evado.UniForm.Model.Command groupCommand = new Evado.UniForm.Model.Command ( ); // // Create the record display pageMenuGroup. // pageGroup = PageObject.AddGroup ( String.Empty ); pageGroup.CmdLayout = Evado.UniForm.Model.GroupCommandListLayouts.Horizontal_Orientation; pageGroup.Layout = Evado.UniForm.Model.GroupLayouts.Dynamic; pageGroup.AddParameter ( Evado.UniForm.Model.GroupParameterList.Percent_Width, 25 ); foreach ( EdRecordField field in Entity.Fields ) { this.LogDebug ( "fid {0} - {1} V: {2}. ", field.FieldId, field.TypeId, field.ItemValue ); if ( field.Design.IsSummaryField == false && field.TypeId != EvDataTypes.Image && field.TypeId != EvDataTypes.Text && field.TypeId != EvDataTypes.Numeric && field.TypeId != EvDataTypes.Telephone_Number && field.TypeId != EvDataTypes.Selection_List && field.TypeId != EvDataTypes.Radio_Button_List && field.TypeId != EvDataTypes.Check_Box_List && field.TypeId != EvDataTypes.External_Selection_List && field.TypeId != EvDataTypes.External_RadioButton_List && field.TypeId != EvDataTypes.External_CheckBox_List ) { continue; } // // skip all empty items. // if ( field.ItemValue == String.Empty || field.ItemValue.Contains ( "E+37" ) == true || field.ItemValue.Contains ( "E-35" ) == true ) { continue; } this.LogDebug ( "FieldId {0}, value {1} ", field.FieldId, field.ItemValue ); // // Define the layout. // Evado.UniForm.Model.FieldLayoutCodes layout = Evado.UniForm.Model.FieldLayoutCodes.Left_Justified; switch ( field.TypeId ) { case EvDataTypes.Image: { groupField = pageGroup.createImageField ( String.Empty, field.Title, field.ItemValue, 125, 0 ); groupField.EditAccess = Evado.UniForm.Model.EditAccess.Disabled; groupField.Layout = layout; continue; } case EvDataTypes.Selection_List: case EvDataTypes.Check_Box_List: case EvDataTypes.Radio_Button_List: case EvDataTypes.Horizontal_Radio_Buttons: case EvDataTypes.External_Selection_List: case EvDataTypes.External_RadioButton_List: case EvDataTypes.External_CheckBox_List: { var value = this.getSelectionDescription ( field, field.ItemValue ); groupField = pageGroup.createReadOnlyTextField ( String.Empty, field.Title, value ); groupField.EditAccess = Evado.UniForm.Model.EditAccess.Disabled; groupField.Layout = layout; continue; } default: { groupField = pageGroup.createReadOnlyTextField ( String.Empty, field.Title, field.ItemValue ); groupField.EditAccess = Evado.UniForm.Model.EditAccess.Disabled; groupField.Layout = layout; continue; } }//END type switch statement. }//END field iteration loop // // Define the pageMenuGroup groupCommand. // groupCommand = pageGroup.addCommand ( Entity.Title, EuAdapter.ADAPTER_ID, EuAdapterClasses.Entities, Evado.UniForm.Model.ApplicationMethods.Get_Object ); groupCommand.Id = Entity.Guid; groupCommand.SetGuid ( Entity.Guid ); // // Define the link groupCommand. // EdRecordField commandField = Entity.getFirstHttpLinkField ( ); if ( commandField != null ) { this.LogDebug ( "FieldId {0}, value {1} ", commandField.FieldId, commandField.ItemValue ); if ( commandField.ItemValue != String.Empty ) { string title = commandField.Title; string url = commandField.ItemValue; if ( url.Contains ( "^" ) == true ) { string [ ] arValue = commandField.ItemValue.Split ( '^' ); url = arValue [ 0 ]; title = arValue [ 1 ]; } groupCommand = pageGroup.addCommand ( title, EuAdapter.ADAPTER_ID, EuAdapterClasses.Entities, Evado.UniForm.Model.ApplicationMethods.Get_Object ); groupCommand.Type = Evado.UniForm.Model.CommandTypes.Http_Link; groupCommand.AddParameter ( Evado.UniForm.Model.CommandParameters.Link_Url, url ); } } this.LogMethodEnd ( "getGroupSummaryListGroup" ); }//END getGroupListCommand method
}//END GetView method. #endregion #region FormFields Update queries // ================================================================================== /// <summary> /// This class update items on EV_FORM_SECTION table using retrieving form section items values. /// </summary> /// <param name="Form">EvForm: a form section object</param> /// <returns>EvEventCodes: an event code for updating items on formfield object</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Dekete the data for the old Guid. /// /// 2. Insert the modified data for the new Guid. /// </remarks> // ---------------------------------------------------------------------------------- public EvEventCodes UpdateItem(EdRecord Form) { this.LogMethod("updateItem method. "); this.LogDebug("Section Count: " + Form.Design.FormSections.Count); // // Initialize the debug status and the local variables // StringBuilder sbSQL_AddQuery = new StringBuilder( ); List <SqlParameter> parmList = new List <SqlParameter> ( ); if (Form.Guid == Guid.Empty) { return(EvEventCodes.Identifier_Global_Unique_Identifier_Error); } // // if sections doe not exist exit. // if (Form.Design.FormSections.Count == 0) { return(EvEventCodes.Ok); } // // Delete the sections // sbSQL_AddQuery.AppendLine("DELETE FROM ED_RECORD_SECTIONS " + "WHERE " + EdRecordSections.DB_LAYOUT_GUID + " = " + EdRecordSections.PARM_FORM_GUID + "; \r\n"); SqlParameter prm = new SqlParameter(EdRecordSections.PARM_FORM_GUID, SqlDbType.UniqueIdentifier); prm.Value = Form.Guid; parmList.Add(prm); for (int count = 0; count < Form.Design.FormSections.Count; count++) { EdRecordSection section = Form.Design.FormSections [count]; // // skip empty sections // if (section.Title == String.Empty) { continue; } // // Set the order if 0 // if (section.Order == 0) { section.Order = count + 3; } // // define the section parameters. // prm = new SqlParameter(EdRecordSections.PARM_NUMBER + "_" + count, SqlDbType.Int); prm.Value = section.No; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_ORDER + "_" + count, SqlDbType.Int); prm.Value = section.Order; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_NAME + "_" + count, SqlDbType.VarChar, 30); prm.Value = section.Title; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_INSTRUCTIONS + "_" + count, SqlDbType.NText); prm.Value = section.Instructions; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_FIELD_NAME + "_" + count, SqlDbType.NVarChar, 20); prm.Value = section.FieldId; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_FIELD_VALUE + "_" + count, SqlDbType.NVarChar, 50); prm.Value = section.FieldValue; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_ON_MATCH_VISIBLE + "_" + count, SqlDbType.Bit); prm.Value = section.OnMatchVisible; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_VISIBLE + "_" + count, SqlDbType.Bit); prm.Value = section.OnOpenVisible; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_DEFAULT_DISPLAY_ROLES + "_" + count, SqlDbType.NVarChar, 250); prm.Value = section.ReadAccessRoles; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_DEFAULT_EDIT_ROLES + "_" + count, SqlDbType.NVarChar, 250); prm.Value = section.EditAccessRoles; parmList.Add(prm); prm = new SqlParameter(EdRecordSections.PARM_PERCENT_WIDTH + "_" + count, SqlDbType.Int); prm.Value = section.EditAccessRoles; parmList.Add(prm); // // Create the add query . // sbSQL_AddQuery.AppendLine(" INSERT INTO ED_RECORD_SECTIONS " + "(" + EdRecordSections.DB_LAYOUT_GUID + ", " + EdRecordSections.DB_NUMBER + ", " + EdRecordSections.DB_ORDER + ", " + EdRecordSections.DB_NAME + ", " + EdRecordSections.DB_INSTRUCTIONS + ", " + EdRecordSections.DB_FIELD_NAME + ", " + EdRecordSections.DB_FIELD_VALUE + ", " + EdRecordSections.DB_ON_MATCH_VISIBLE + ", " + EdRecordSections.DB_VISIBLE + ", " + EdRecordSections.DB_DEFAULT_DISPLAY_ROLES + ", " + EdRecordSections.DB_DEFAULT_EDIT_ROLES + ", " + EdRecordSections.DB_PERCENT_WIDTH + " ) \r\n" + "VALUES (" + " " + EdRecordSections.PARM_FORM_GUID + ", " + EdRecordSections.PARM_NUMBER + "_" + count + ", " + EdRecordSections.PARM_ORDER + "_" + count + ", " + EdRecordSections.PARM_NAME + "_" + count + ", " + EdRecordSections.PARM_INSTRUCTIONS + "_" + count + ", " + EdRecordSections.PARM_FIELD_NAME + "_" + count + ", " + EdRecordSections.PARM_FIELD_VALUE + "_" + count + ", " + EdRecordSections.PARM_ON_MATCH_VISIBLE + "_" + count + ", " + EdRecordSections.PARM_VISIBLE + "_" + count + ", " + EdRecordSections.PARM_DEFAULT_DISPLAY_ROLES + "_" + count + ", " + EdRecordSections.PARM_DEFAULT_EDIT_ROLES + "_" + count + ", " + EdRecordSections.PARM_PERCENT_WIDTH + "_" + count + " ); \r\n"); } if (parmList.Count > 1) { // // Convert the list to an array of SqlPararmeters. // SqlParameter [] parms = new SqlParameter [parmList.Count]; for (int i = 0; i < parmList.Count; i++) { parms [i] = parmList [i]; } // // Extract the parameters // this.LogDebug(sbSQL_AddQuery.ToString( )); this.LogDebug(EvSqlMethods.getParameterSqlText(parms)); // // Execute the update command. // try { if (EvSqlMethods.QueryUpdate(sbSQL_AddQuery.ToString( ), parms) == 0) { return(EvEventCodes.Database_Record_Update_Error); } } catch (Exception Ex) { this.LogDebug(Evado.Model.EvStatics.getException(Ex)); } } //END parameter list greater then 1 return(EvEventCodes.Ok); } //END UpdateItem method
}//END createRecord method // ===================================================================================== /// <summary> /// This class saves form records to the database. /// </summary> /// <param name="FormRecord">EvRForm: The trial form record object</param> /// <param name="HadEditAccess">EvRole: a user role object</param> /// <returns>EvEventCodes: an event code for saving form records</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the form object's identifiers are empty. /// /// 2. If a review query has been raised, process the query. /// /// 3. Execute the method for updating form's state, closing form's alert and processing formfields /// /// 4. Return an event code of method execution. /// </remarks> // ---------------------------------------------------------------------------------- public EvEventCodes saveRecord ( EdRecord FormRecord, bool HadEditAccess ) { this.LogMethod ( "saveItem " ); this.LogValue ( "FormRecord.Guid: " + FormRecord.Guid ); this.LogValue ( "FormGuid: " + FormRecord.LayoutGuid ); this.LogValue ( "Action: " + FormRecord.SaveAction ); this.LogValue ( "UserRole.Edit: " + HadEditAccess ); // // Define the local variables. // EvEventCodes iReturn = EvEventCodes.Ok; // // Check that the ResultData object has valid identifiers to add it to the database. // if ( FormRecord.Guid == Guid.Empty ) { this.LogValue ( "Record Guid is empty" ); return EvEventCodes.Identifier_Global_Unique_Identifier_Error; } if ( FormRecord.LayoutGuid == Guid.Empty ) { this.LogValue ( "Form ID is empty" ); return EvEventCodes.Identifier_Form_Id_Error; } // // Update the state information in the trial Report. // this.updateFormState ( FormRecord, HadEditAccess ); this.LogValue ( "Status: " + FormRecord.State ); // // Update the instrument newField states. // this.processFormFields ( FormRecord ); // // Update the trial record. // iReturn = this._DalRecords.updateRecord ( FormRecord ); this.LogClass ( this._DalRecords.Log ); // // error encountered return eror. // if ( iReturn < EvEventCodes.Ok ) { return iReturn; } // // Return the update status. // return iReturn; }//END saveRecord method.
}//END unlockItem method #endregion #region Form Record update methods // ===================================================================================== /// <summary> /// This class creates new form record to database. /// </summary> /// <param name="Record">EvForm: The form object</param> /// <returns>EvForm: a form object</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Exit, if the form object's identifier values are empty. /// /// 2. If the form QueryType is 'Updateable' then create a new copy of the record. /// else create a new empty record. /// /// 3. Return the form object. /// </remarks> // ---------------------------------------------------------------------------------- public EdRecord CreateRecord ( EdRecord Record ) { this.LogMethod ( "createRecord method." ); this.LogDebug ( "LayoutId: " + Record.LayoutId ); // // Instantiate the local variables // EdRecord record = new EdRecord ( ); if ( Record.LayoutId == String.Empty ) { this.LogValue ( " FormId Empty " ); record.EventCode = EvEventCodes.Identifier_Form_Id_Error; this.LogMethodEnd ( "createRecord" ); return record; } // // Retrieve the specified form to determine the form QueryType. // EdRecord form = this._DalForms.GetLayout (Record.LayoutId, true ); this.LogDebugClass ( this._DalForms.Log ); this.LogDebug ( "form Id: " + form.LayoutId ); this.LogDebug ( "form title: " + form.Title ); this.LogDebug ( "form TypeId: " + form.Design.TypeId ); // // If the form QueryType is 'Updateable' then create a new copy of the record. // else create a new empty record. // if ( form.Design.TypeId == EdRecordTypes.Updatable_Record ) { // // Create a new copy of the record. // this.LogDebug ( "UPDATEABLE RECORD: Create New Record." ); record = this._DalRecords.createNewUpdateableRecord ( Record ); this.LogClass ( this._DalRecords.Log ); this.LogDebug ( "Record Event Code: " + record.EventCode + " > " + Evado.Model.EvStatics.enumValueToString ( record.EventCode ) ); // // Return the new record. // this.LogMethodEnd ( "createRecord" ); return record; }//END Updateable form QueryType. // // Create a new trial Report to the database // this.LogDebug ( "Create New Record." ); record = this._DalRecords.createRecord ( Record ); this.LogClass ( this._DalRecords.Log ); this.LogDebug ( "Record Event Code: " + Evado.Model.EvStatics.enumValueToString ( record.EventCode ) ); // // Return the new record. // this.LogMethodEnd ( "createRecord" ); return record; }//END createRecord method