Beispiel #1
0
        }//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 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 updateItem method

    // =====================================================================================
    /// <summary>
    /// This class adds new items to the organization data table. 
    /// </summary>
    /// <param name="Organisation">EvOrganisation: Organisation object</param>
    /// <returns>EvEventCodes: an event code for adding result</returns>
    /// <remarks>
    /// This method consists of the following steps:
    /// 
    /// 1. Exit, if the Old organization's Guid is not empty.
    /// 
    /// 2. If the New Organization's Guid is null, create a new Guid.
    /// 
    /// 3. Define the sql query parmeter and execute the storeprocedure for adding items. 
    /// 
    /// 4. Return an event code for adding items.
    /// </remarks>
    // -------------------------------------------------------------------------------------
    public EvEventCodes addItem ( EdOrganisation Organisation )
    {
      //
      // Initialize the method status and the old organization object. 
      //
      this.LogMethod ( "addItem method. " );

      // 
      // If the Guid is null create a new guid.
      // 
      if ( Organisation.Guid == Guid.Empty )
      {
        Organisation.Guid = Guid.NewGuid ( );
      }

      // 
      // Define the query parameters
      // 
      SqlParameter [ ] cmdParms = GetParameters ( );
      SetParameters ( cmdParms, Organisation );

      //
      // Execute the update command.
      //
      if ( EvSqlMethods.StoreProcUpdate ( EdOrganisations.STORED_PROCEDURE_ADD_ITEM, cmdParms ) == 0 )
      {
        return EvEventCodes.Database_Record_Update_Error;
      }

      return EvEventCodes.Ok;

    }//END addItem method 
        }//END getRecordFieldList method.

        // =====================================================================================
        /// <summary>
        /// this method processes a form field type that is a numeric.
        /// </summary>
        /// <param name="Row">The DataRow containing the field</param>
        /// <param name="FormField"> Evado.Model.Forms.EvFormField object, containg the field data.</param>
        // -------------------------------------------------------------------------------------
        private void getCheckBoxValue(DataRow Row, Evado.Digital.Model.EdRecordField FormField)
        {
            LogMethod("getCheckBoxValue");
            //
            // Get the field value.
            //
            String columnId = EvSqlMethods.getString(Row, EdRecordValues.DB_VALUES_COLUMN_ID);
            bool   value    = EvSqlMethods.getBool(Row, EdRecordValues.DB_VALUES_NUMERIC);

            this.LogDebug(" columnId: " + columnId + ", value: " + value);

            if (value == false)
            {
                LogMethodEnd("getCheckBoxValue");
                return;
            }

            //
            // iterate through the list looking for a matching option value.
            //
            foreach (EvOption option in FormField.Design.OptionList)
            {
                if (option.Value == columnId)
                {
                    FormField.ItemValue += ";" + option.Value;
                }
            }

            LogMethodEnd("getCheckBoxValue");
        }//END getCheckBoxValue method
    }//END addItem method 

    // =====================================================================================
    /// <summary>
    /// This method deletes the items from organization data table. 
    /// </summary>
    /// <param name="organisation">EvOrganisation: an organisation data object</param>
    /// <returns>EvEventCodes: an event code for deleting results</returns>
    /// <remarks>
    /// This method consists of the following steps: 
    /// 
    /// 1. Exit if the orgnization identifier is in used in the trial organization. 
    /// 
    /// 2. Define the sql query parameters and execute the store procedure for deleting items
    /// 
    /// 3. Return the event code for deleting items. 
    /// </remarks>
    // -------------------------------------------------------------------------------------
    public EvEventCodes deleteItem ( EdOrganisation organisation )
    {
      //
      // Initialize the method status and a trial orgnaization object. 
      //
      this.LogMethod ( "deleteItem method. " );
      this.LogDebug ( "OrgId: " + organisation.OrgId );

      // 
      // Define the query parameters.
      // 
      SqlParameter [ ] cmdParms = new SqlParameter [ ] 
      {
        new SqlParameter(PARM_Guid, SqlDbType.UniqueIdentifier),
        new SqlParameter(PARM_UPDATED_BY, SqlDbType.NVarChar, 100),
        new SqlParameter(PARM_UPDATED_BY_USER_ID, SqlDbType.NVarChar, 100),
        new SqlParameter(PARM_UPDATE_DATE, SqlDbType.DateTime)
      };
      cmdParms [ 0 ].Value = organisation.Guid;
      cmdParms [ 1 ].Value = this.ClassParameters.UserProfile.UserId;
      cmdParms [ 2 ].Value = this.ClassParameters.UserProfile.CommonName;
      cmdParms [ 3 ].Value = DateTime.Now;

      //
      // Execute the update command.
      //
      if ( EvSqlMethods.StoreProcUpdate ( EdOrganisations.STORED_PROCEDURE_DELETE_ITEM, cmdParms ) == 0 )
      {
        return EvEventCodes.Database_Record_Update_Error;
      }

      return EvEventCodes.Ok;

    }//End deleteItem 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 getVersionedView method.

        #endregion

        #region Class Retrieval methods

        // ==================================================================================
        /// <summary>
        /// This class gets itmes of binary file data object.
        /// </summary>
        /// <param name="Guid">Guid: a binary global unique identifier</param>
        /// <returns>EvBinaryFileMetaData: a binary file data object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty binary file object if the Binary file's Guid is empty
        ///
        /// 2. Define the sql query parameter and the sql query string
        ///
        /// 3. Execute the sql query string with parameter and store the result on the datatable
        ///
        /// 4. Extract the first data row to the binary file object.
        ///
        /// 5. Return the Binary file object.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public EvBinaryFileMetaData GetFile(Guid Guid)
        {
            this.LogMethod("GetFile method. ");
            this.LogDebug("Guid: " + Guid);
            //
            // Define local variables
            //
            string sqlQueryString;
            EvBinaryFileMetaData binaryFile = new EvBinaryFileMetaData( );

            //
            // Check that the TrialObjectId is valid.
            //
            if (Guid == Guid.Empty)
            {
                return(binaryFile);
            }

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter cmdParms = new SqlParameter(EvBinaryFiles.PARM_GUID, SqlDbType.UniqueIdentifier);

            cmdParms.Value = Guid;

            //
            // Generate the SQL query string
            //
            sqlQueryString = SQL_VIEW_QUERY
                             + "\r\n WHERE (" + EvBinaryFiles.DB_GUID + " = " + EvBinaryFiles.PARM_GUID + ");";

            this.LogDebug(sqlQueryString);

            //
            // Execute the query against the database
            //
            using (DataTable table = EvSqlMethods.RunQuery(sqlQueryString, cmdParms))
            {
                //
                // If not rows the return
                //
                if (table.Rows.Count == 0)
                {
                    return(binaryFile);
                }

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

                binaryFile = this.readDataRow(row);
            }//END Using

            //
            // Return the TrialVisit data object.
            //
            this.LogMethodEnd("GetFile");
            return(binaryFile);
        }//END GetItem class.
Beispiel #8
0
        }//END SetParameters class.

        #endregion

        #region ExternalSelectionList Reader

        // =====================================================================================
        /// <summary>
        /// This class extracts the content of the reader to the formfield selectionlist object.
        /// </summary>
        /// <param name="Row">DataRow: a data Reader containing the query results</param>
        /// <returns>EvFormFieldSelectionList: a formfield selectionlist object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Extract the compatible data row values to the formfield selectionlist object.
        ///
        /// 2. Return the Formfield selectionlist object.
        /// </remarks>
        //  ---------------------------------------------------------------------------------
        private EvSelectionList readDataRow(DataRow Row)
        {
            //
            // Initialise the formfield selectionlist object.
            //
            EvSelectionList Item = new EvSelectionList( );

            //
            // Extract the compatible data row values to the formfield selectionlist object items.
            //
            Item.Guid        = EvSqlMethods.getGuid(Row, EvSelectionLists.DB_GUID);
            Item.ListId      = EvSqlMethods.getString(Row, EvSelectionLists.DB_LIST_ID);
            Item.Title       = EvSqlMethods.getString(Row, EvSelectionLists.DB_TITLE);
            Item.Description = EvSqlMethods.getString(Row, EvSelectionLists.DB_DESCRIPTION);
            Item.Version     = EvSqlMethods.getInteger(Row, EvSelectionLists.DB_VERSION);

            string xmlCodeItem = EvSqlMethods.getString(Row, EvSelectionLists.DB_ITEM_LIST);

            if (xmlCodeItem != String.Empty)
            {
                Item.Items = Evado.Digital.Model.EvcStatics.DeserialiseObject <List <EvSelectionList.Item> > (xmlCodeItem);
            }
            Item.State = Evado.Model.EvStatics.parseEnumValue <EvSelectionList.SelectionListStates> (
                EvSqlMethods.getString(Row, EvSelectionLists.DB_STATE));
            Item.UpdatedByUserId = EvSqlMethods.getString(Row, EvSelectionLists.DB_UPDATED_BY_USER_ID);
            Item.UpdatedBy       = EvSqlMethods.getString(Row, EvSelectionLists.DB_UPDATED_BY);
            Item.UpdatedDate    += EvSqlMethods.getDateTime(Row, EvSelectionLists.DB_UPDATED_DATE);

            //
            // Return item
            //
            return(Item);
        }//END readDataRow method.
Beispiel #9
0
        }//END getList class

        #endregion

        #region Retrieval Queries

        // =====================================================================================
        /// <summary>
        /// This class retrieves the formfield selection list based on Guid value
        /// </summary>
        /// <param name="ListGuid">Guid: The Global unique identifier</param>
        /// <returns>EvFormFieldSelectionList: The formfield selection list object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty selection list if the list's Guid is empty.
        ///
        /// 2. Define the sql query string and sql query parameters.
        ///
        /// 3. Execute the sql query string and store the results on data table.
        ///
        /// 4. Extract the first row to the formfield selection list object.
        ///
        /// 5. Return the formfield selection list data object.
        /// </remarks>
        //  ---------------------------------------------------------------------------------
        public EvSelectionList getItem(Guid ListGuid)
        {
            this.LogMethod("getItem");
            this._Log.AppendLine("ListGuid: " + ListGuid);
            //
            // Initialise the local variables
            //
            EvSelectionList item           = new EvSelectionList( );
            String          sqlQueryString = String.Empty;

            //
            // If TestReport UID is null return empty checlist object.
            //
            if (ListGuid == Guid.Empty)
            {
                return(item);
            }

            //
            // Initialise the query parameters.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(EvSelectionLists.PARM_GUID, SqlDbType.UniqueIdentifier),
            };
            cmdParms [0].Value = ListGuid;

            //
            // Generate the Selection query string.
            //
            sqlQueryString = SQL_VIEW_QUERY + " WHERE " + EvSelectionLists.DB_GUID + " = " + EvSelectionLists.PARM_GUID + ";";

            this.LogDebug(sqlQueryString);

            //
            // Execute the query against the database
            //
            using (DataTable table = EvSqlMethods.RunQuery(sqlQueryString, cmdParms))
            {
                //
                // If not rows the return
                //
                if (table.Rows.Count == 0)
                {
                    return(item);
                }

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

                item = this.readDataRow(row);
            }//END Using

            //
            // Return Checklsit data object.
            //
            return(item);
        }//END EvFormFieldSelectionList method
Beispiel #10
0
        }//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
Beispiel #11
0
        }// 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 SetLetterParameters.

        #endregion

        #region Data Reader methods

        // =====================================================================================
        /// <summary>
        /// This method reads the content of the data row object containing a query result
        /// into an form record comment object.
        /// </summary>
        /// <param name="Row">DataRow: a data row object</param>
        /// <returns>EvFormRecordComment: a form record comment object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Extract the compatible data row values to the comment object.
        ///
        /// 2. Return the form record comment object.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EdFormRecordComment readDataRow(DataRow Row)
        {
            //
            // Initialise the comment object.
            //
            EdFormRecordComment comment = new EdFormRecordComment( );

            //
            // Extract the data object values.
            //
            comment.RecordGuid      = EvSqlMethods.getGuid(Row, "FRC_RECORD_GUID");
            comment.RecordFieldGuid = EvSqlMethods.getGuid(Row, "FRC_RECORD_FIELD_GUID");

            comment.AuthorType =
                Evado.Model.EvStatics.parseEnumValue <EdFormRecordComment.AuthorTypeCodes> (
                    EvSqlMethods.getString(Row, "FRC_AUTHOR_TYPE"));

            comment.Content = EvSqlMethods.getString(Row, "FRC_Content");

            comment.UserId         = EvSqlMethods.getString(Row, "FRC_USER_ID");
            comment.UserCommonName = EvSqlMethods.getString(Row, "FRC_USER_COMMON_NAME");
            comment.CommentDate    = EvSqlMethods.getDateTime(Row, "FRC_COMMENT_DATE");
            comment.NewComment     = false;

            //
            // Return the object.
            //
            return(comment);
        }// End readRow method.
        // =====================================================================================
        /// <summary>
        /// This class reads the content of the data reader object into FormField business object.
        /// </summary>
        /// <param name="Row">DataRow: an sql data query row</param>
        /// <returns>EvFormField: a form field object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Update formfield object with the compatible data row items.
        ///
        /// 2. If the formfield typeId is table, iterate through the formfield table and set the validation rules
        ///
        /// 3. If the selection validation options are missing, add them.
        ///
        /// 4. If it is an external coding visitSchedule then add the relevant coding visitSchedule items.
        ///
        /// 5. Resolve the numeric 'NA' to negative infinity issue.
        ///
        /// 6. Update the instrument type to current enumeration.
        ///
        /// 7. If formfield typeId is either analogue scale or horizontal radio buttons,
        /// select the design by coding value
        ///
        /// 8. Return the formfield object.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        private Evado.Digital.Model.EdRecordSection getRowData(DataRow Row)
        {
            //
            // Initialise xmltable string and a return formfield object.
            //
            string xmlTable = String.Empty;

            Evado.Digital.Model.EdRecordSection formSection = new  Evado.Digital.Model.EdRecordSection( );

            //
            // Update formfield object with the compatible data row items.
            //
            formSection.LayoutGuid      = EvSqlMethods.getGuid(Row, EdRecordSections.DB_LAYOUT_GUID);
            formSection.No              = EvSqlMethods.getInteger(Row, EdRecordSections.DB_NUMBER);;
            formSection.Title           = EvSqlMethods.getString(Row, EdRecordSections.DB_NAME);
            formSection.Order           = EvSqlMethods.getInteger(Row, EdRecordSections.DB_ORDER);
            formSection.FieldId         = EvSqlMethods.getString(Row, EdRecordSections.DB_FIELD_NAME);
            formSection.Instructions    = EvSqlMethods.getString(Row, EdRecordSections.DB_INSTRUCTIONS);
            formSection.FieldValue      = EvSqlMethods.getString(Row, EdRecordSections.DB_FIELD_VALUE);
            formSection.OnMatchVisible  = EvSqlMethods.getBool(Row, EdRecordSections.DB_ON_MATCH_VISIBLE);
            formSection.OnOpenVisible   = EvSqlMethods.getBool(Row, EdRecordSections.DB_VISIBLE);
            formSection.ReadAccessRoles = EvSqlMethods.getString(Row, EdRecordSections.DB_DEFAULT_DISPLAY_ROLES);
            formSection.EditAccessRoles = EvSqlMethods.getString(Row, EdRecordSections.DB_DEFAULT_EDIT_ROLES);
            formSection.PercentWidth    = EvSqlMethods.getInteger(Row, EdRecordSections.DB_PERCENT_WIDTH);

            return(formSection);
        }//END getRowData method.
Beispiel #14
0
        }//End WithdrawIssuedList method.

        // =====================================================================================
        /// <summary>
        /// This class deletes items from formfield selection list table.
        /// </summary>
        /// <param name="Item">EvFormFieldSelectionList: a formfield selection list object</param>
        /// <returns>EvEventCodes: an event code for deleting items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define the sql query parameters and execute the storeprocedure for deleting the items.
        ///
        /// 2. Return an event code for deleting the items.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes deleteItem(EdPageLayout Item)
        {
            this.LogMethod("deleteItem method. ");

            //
            // Define the query parameters
            //
            SqlParameter [] commandParameters = new SqlParameter []
            {
                new SqlParameter(EdPageLayouts.PARM_GUID, SqlDbType.UniqueIdentifier),
                new SqlParameter(EdPageLayouts.PARM_UPDATED_BY_USER_ID, SqlDbType.NVarChar, 100),
                new SqlParameter(EdPageLayouts.PARM_UPDATED_BY, SqlDbType.NVarChar, 100),
                new SqlParameter(EdPageLayouts.PARM_UPDATED_DATE, SqlDbType.DateTime)
            };
            commandParameters [0].Value = Item.Guid;
            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_DeleteItem, commandParameters) == 0)
            {
                return(EvEventCodes.Database_Record_Update_Error);
            }

            return(EvEventCodes.Ok);
        }// End deleteYear method.
Beispiel #15
0
        }//END setUpdateChangeParameters.

        // +++++++++++++++++++++++++ END QUERY PARAMETERS SECTION ++++++++++++++++++++++++++++++
        #endregion

        #region data change reader

        // =====================================================================================
        /// <summary>
        /// This class reads the content of the data reader object into Change business object.
        /// </summary>
        /// <param name="Row">DataRow: a data row object</param>
        /// <returns>EvDataChange: a data change object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Extract the data row values to the data change object.
        ///
        /// 2. Encrypt the data change if it is not encrypted.
        ///
        /// 3. Return the data change object.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        private EvDataChange getRowData(DataRow Row)
        {
            //
            // Initialise the data change object
            //
            EvDataChange dataChange = new EvDataChange( );

            //
            // Extract the data row values to the data change object.
            //
            dataChange.Guid       = EvSqlMethods.getGuid(Row, "DC_Guid");
            dataChange.RecordGuid = EvSqlMethods.getGuid(Row, "DC_RecordGuid");
            dataChange.Uid        = EvSqlMethods.getLong(Row, "DC_Uid");
            dataChange.RecordUid  = EvSqlMethods.getLong(Row, "DC_RecordUid");
            dataChange.TableName  =
                Evado.Model.EvStatics.parseEnumValue <EvDataChange.DataChangeTableNames> (
                    EvSqlMethods.getString(Row, "DC_TableName"));
            string encrypted = EvSqlMethods.getString(Row, "DC_DataChange");

            dataChange.UserId    = EvSqlMethods.getString(Row, "DC_UserId");
            dataChange.DateStamp = EvSqlMethods.getDateTime(Row, "DC_DateStamp");

            //
            // Check that the encrypted string exists.
            //
            if (encrypted != String.Empty)
            {
                dataChange = this.decryptData(encrypted, dataChange.Guid);

                //
                // Check that items exist.
                //
                if (dataChange != null)
                {
                    //
                    // If the data change items exist process them.
                    //
                    if (dataChange.Items.Count > 0)
                    {
                        //
                        // Iterate through the data change items updating the html coding
                        //
                        for (int count = 0; count < dataChange.Items.Count; count++)
                        {
                            dataChange.Items [count].InitialValue =
                                dataChange.Items [count].InitialValue.Replace("&amp;gt;", "&amp;gt; ");

                            dataChange.Items [count].NewValue =
                                dataChange.Items [count].NewValue.Replace("&amp;gt;", "&amp;gt; ");
                        } //END iterate through the item values correcting html coding.
                    }     //END data change items exist.
                }         //END items exit
            }             //END encrypted date exists

            //
            // Return the newField .
            //
            return(dataChange);
        }//END getRowData method.
Beispiel #16
0
        }//END GroupExists method

        #endregion

        #region Retreival methods

        // =====================================================================================
        /// <summary>
        /// This class gets Menus data object by its unique object identifier.
        /// </summary>
        /// <param name="MenuGuid">Guid: (Mandatory)a global unique object identifier.</param>
        /// <returns>EvMenuItem: a menu data object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty MenuItem object, if the Guid is empty.
        ///
        /// 2. Define the SQL query parameters and a query string.
        ///
        /// 3. Execute the query string and store the results on datatable.
        ///
        /// 4. Return an empty MenuItem object if the table has no value.
        ///
        /// 5. Else, Extract the table row to the MenuItem object.
        ///
        /// 6. Return the MenuItem object.
        ///
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EvMenuItem getItem(Guid MenuGuid)
        {
            this.LogMethod("getItem");
            this.LogDebug("MenuGuid: " + MenuGuid);
            //
            // Initialize a debug log and a menu item object
            //
            Evado.Digital.Model.EvMenuItem menuItem = new  Evado.Digital.Model.EvMenuItem( );

            //
            // Check that there is a valid unique identifier.
            //
            if (MenuGuid == Guid.Empty)
            {
                return(menuItem);
            }

            //
            // Define the query parameters.
            //
            SqlParameter cmdParms = new SqlParameter(PARM_GUID, SqlDbType.UniqueIdentifier);

            cmdParms.Value = MenuGuid;

            //
            // Define the query string.
            //
            _sqlQueryString = _sqlQuery_View + " WHERE (Mnu_Guid = @Guid ); ";

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

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

                //
                // Process the results.
                //
                menuItem = this.getRowData(row);
            }//END Using statement

            //
            // Pass back the data object.
            //
            return(menuItem);
        }//END getItem class
        }//END getRowData method.

        // =====================================================================================
        /// <summary>
        /// This method processes form field table or matrix object.
        /// </summary>
        /// <param name="Row">DataRow: a sql data row object</param>
        /// <param name="Field">EvFormField: a formfield object</param>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Validate whether the formfield type is matrix and table.
        ///
        /// 2. if the Itemtext value is empty then initialise it with the EvFormField table value.
        ///
        /// 3. Deserialize the formfield item text to the formfield table.
        ///
        /// 4. Empty the formfield itemtext so it will not cause problems when XML styling the record object.
        ///
        /// 5. Iterate through the table for setting the validation objects.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        private void processTableRowObject(
            DataRow Row,
            EdRecordField Field)
        {
            //this.LogMethod ( "processTableRowObject method " );
            //this.LogDebugValue ( "FieldId: " + Field.FieldId );
            //this.LogDebugValue ( "Table Length: " + Field.ItemText.Length );
            //
            // Validate whether the formfield type is matrix and table.
            //
            if (Field.TypeId != Evado.Model.EvDataTypes.Special_Matrix &&
                Field.TypeId != Evado.Model.EvDataTypes.Table)
            {
                //this.LogMethodEnd ( "processTableRowObject" );
                return;
            }

            //
            // if the Itemtext value is empty then initialise it with the EvFormField table value.
            //
            if (Field.ItemText == String.Empty)
            {
                //this.LogDebugValue ( "Reset table value to form default." );
                Field.ItemText = EvSqlMethods.getString(Row, EdRecordFields.DB_TABLE);
            }
            //
            // Deserialize the formfield item text to the formfield table.
            //
            Field.Table = Evado.Digital.Model.EvcStatics.DeserialiseObject <EdRecordTable> (Field.ItemText);

            //
            // Empty the formfield itemtext so it will not cause problems when XML styling the record object.
            //
            Field.ItemText = String.Empty;

            //
            // Iterate through the table for setting the validation objects.
            //
            for (int i = 0; i < Field.Table.ColumnCount; i++)
            {
                //
                // Addressing the 'NA' to negative infinity issue for non-numeric fields.
                //
                // Iterate through the table data converting the relevant cell values to NA.
                //
                for (int j = 0; j < Field.Table.Rows.Count; j++)
                {
                    String cell = Field.Table.Rows [j].Column [i];

                    if (Field.Table.Header [i].TypeId != EvDataTypes.Numeric)
                    {
                        Field.Table.Rows [j].Column [i] = Evado.Model.EvStatics.convertNumNullToTextNull(cell);
                    }

                    //this.LogDebugValue ( "R:" + j  + ", C:" + i + ", V: " + cell );
                } //END column iteration loop
            }     //END newField iteration loop
        }         //END processTableRowObject method
Beispiel #18
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
        }//END getRowData method.

        #endregion

        #region Form Field Queries

        // =====================================================================================
        /// <summary>
        /// This class returns a list of formfield items retrieving by form Guid
        /// </summary>
        /// <param name="FormGuid">Guid: (Mandatory) The form GUID.</param>
        /// <returns>List of EvFormField: a list of FormField items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define the sql query parameters and a sql query string.
        ///
        /// 2. Execute the sql query string with parameters and store the results on data table.
        ///
        /// 3. Iterate through the table and extract data row to the formfield data object.
        ///
        /// 4. Add the object values to the Formfield list.
        ///
        /// 5. Return the FormFields list.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public List <EdRecordSection> getSectionList(Guid FormGuid)
        {
            this.LogMethod("GetView method");
            this.LogDebug("FormGuid: " + FormGuid);
            //
            // Initialize the debug log and a return list of formfield
            //
            List <EdRecordSection> sectionList = new List <EdRecordSection> ( );

            //
            // Define the SQL query parameters.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(PARM_FORM_GUID, SqlDbType.UniqueIdentifier),
            };
            cmdParms [0].Value = FormGuid;

            //
            // Define the query string.
            //
            _sqlQueryString = _sqlQueryView + " WHERE ( " + DB_LAYOUT_GUID + "  = " + PARM_FORM_GUID + ") "
                              + "ORDER BY " + DB_ORDER + "; ";


            this.LogDebug(_sqlQueryString);

            //
            // Scroll through the results
            //
            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];

                    EdRecordSection section = this.getRowData(row);

                    section.Order = count * 2 + 1;

                    sectionList.Add(section);
                }
            }
            this.LogDebug("Count: " + sectionList.Count.ToString( ));

            //
            // Pass back the result arrray.
            //
            return(sectionList);
        }//END GetView method.
Beispiel #20
0
        }//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
Beispiel #21
0
        } // Close getView method.

        #endregion

        #region Data Object Retrieval methods

        // =====================================================================================
        /// <summary>
        /// This class retrieve the Report data table based on Guid value.
        /// </summary>
        /// <param name="Guid">Guid: A report's global unique identifier</param>
        /// <returns>EvReport: a report data object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define the sql query parameters and sql query string.
        ///
        /// 2. Execute the sql query string and store the results on data table.
        ///
        /// 3. Extract the first row data to the report object.
        ///
        /// 4. Return the Report data object.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EdReport getReport(Guid Guid)
        {
            this.LogMethod("getReport. ");
            this.LogDebug("Guid: " + Guid);

            //
            // Define the local variables
            //
            string   _sqlQueryString;
            EdReport report = new EdReport( );

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(_parmGuid, SqlDbType.UniqueIdentifier),
            };
            cmdParms [0].Value = Guid;

            //
            // Generate the SQL query string
            //
            _sqlQueryString = _sqlQuery_View + "WHERE (RS_Guid = @Guid); ";
            this.LogDebug(_sqlQueryString);

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

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

                //
                // Fill the Report object.
                //
                report = this.readRow(row);
            }//END Using

            //
            // Return the Report data object.
            //
            this.LogMethodEnd("getReport.");
            return(report);
        } // Close getReport method.
Beispiel #22
0
        }//END getItemById method.

        #endregion

        #region AdapterConfig Update queries

        // =====================================================================================
        /// <summary>
        /// This method updates items to the SiteProfile data table.
        /// </summary>
        /// <param name="AdapterParameters">EvSiteProfile: A site Profile data object.</param>
        /// <returns>EvEventCodes: an event code for updating items.</returns>
        /// <remarks>
        /// This method consists of following steps.
        ///
        /// 1. Add items to datachange object if they do not exist in Old SiteProfile object.
        ///
        /// 2. Define the sql query parameters and execute the storeprocedure for updating items
        ///
        /// 3. Exit, if the storeprocedure runs fail.
        ///
        /// 4. Add datachange object's values to the backup datachanges object.
        ///
        /// 5. Else, return an event code for updating items.
        /// </remarks>
        //  ------------------------------------------------------------------------------------
        public EvEventCodes updateItem(Evado.Digital.Model.EdAdapterSettings AdapterParameters)
        {
            this.LogMethod("updateItem method ");
            //
            // Create the data change object.
            //
            EvDataChanges dataChanges = new EvDataChanges( );
            EvDataChange  dataChange  = this.createDataChange(AdapterParameters);

            /*
             * foreach ( EvObjectParameter prm in ApplicationSettings.Parameters )
             * {
             * this.LogDebug ( "Name: {0}, Value: {1}", prm.Name, prm.Value );
             * }
             */

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter [] cmdParms = GetParameters( );
            SetParameters(cmdParms, AdapterParameters);

            try
            {
                //
                // Execute the update command.
                //
                if (EvSqlMethods.StoreProcUpdate(SQL_PROCEDURE_UPDATE, cmdParms) == 0)
                {
                    return(EvEventCodes.Database_Record_Update_Error);
                }

                //
                // Add the data change object if items have changed.
                //
                if (dataChange.Items.Count > 0)
                {
                    dataChanges.AddItem(dataChange);
                }
            }
            catch (Exception ex)
            {
                this.LogValue(Evado.Digital.Model.EvcStatics.getException(ex));
            }

            //
            // Save the application parameters.
            //
            this.UpdateObjectParameters(AdapterParameters.Parameters, AdapterParameters.Guid);

            //
            // Return an enumerated value EventCode status.
            //
            this.LogMethodEnd("updateItem");
            return(EvEventCodes.Ok);
        } //END updateItem method.
Beispiel #23
0
        }//END SetParameters method

        #endregion

        #region Aplication Profile  Reader

        // =====================================================================================
        /// <summary>
        /// This method extracts the data reader values to the Site profile object.
        /// </summary>
        /// <param name="Row">DataRow object.</param>
        /// <returns>EvSiteProfile: A site profile data object.</returns>
        /// <remarks>
        /// This method consists of following steps.
        ///
        /// 1. Extract the compatible data reader object's values to the Site Profile Object.
        ///
        /// 2. Return a Site Profile Object.
        ///
        /// </remarks>
        //  ------------------------------------------------------------------------------------
        public Evado.Digital.Model.EdAdapterSettings getReaderData(DataRow Row)
        {
            //this.LogMethod ( "getReaderData method. " );
            //
            // Initialise method variables and objects.
            //
            Evado.Digital.Model.EdAdapterSettings applicationSettings = new  Evado.Digital.Model.EdAdapterSettings( );

            //
            // Load the query results into the EvProfile object.
            //
            applicationSettings.Guid = EvSqlMethods.getGuid(Row, EdAdapterConfig.DB_FIELD_GUID);

            applicationSettings.ApplicationId = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_APPLICATION_ID);

            applicationSettings.HomePageHeaderText = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_HOME_PAGE_HEADER);

            applicationSettings.HelpUrl = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_HELP_URL);

            applicationSettings.MaximumSelectionListLength = EvSqlMethods.getInteger(Row, EdAdapterConfig.DB_FIELD_MAX_SELECTION_LENGTH);

            applicationSettings.SmtpServer = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_SMTP_SERVER);

            applicationSettings.SmtpServerPort = EvSqlMethods.getInteger(Row, EdAdapterConfig.DB_FIELD_SMTP_PORT);

            applicationSettings.SmtpUserId = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_SMTP_USER_ID);

            applicationSettings.SmtpPassword = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_SMTP_PASSWORD);

            applicationSettings.EmailAlertTestAddress = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_ALERT_EMAIL_ADDRESS);

            //applicationSettings.ap = EvSqlMethods.getString ( Row, EdAdapterSettings.DB_FIELD_APPLICATION_URL );

            applicationSettings.State = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_STATE);

            applicationSettings.Title = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_TITLE);

            applicationSettings.HttpReference = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_HTTP_REFERENCE);

            applicationSettings.Description = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_DESCRIPTION);

            applicationSettings.UserRoles = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_ROLES);

            applicationSettings.UpdatedBy = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_UPDATE_USER);

            applicationSettings.UpdatedByUserId = EvSqlMethods.getString(Row, EdAdapterConfig.DB_FIELD_UPDATE_USER_ID);

            if (applicationSettings.DemoAccountExpiryDays == 0)
            {
                applicationSettings.DemoAccountExpiryDays = 28;
            }
            //
            // Return the object.
            //
            return(applicationSettings);
        }//END getReaderData method
Beispiel #24
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
Beispiel #25
0
        }//END getItem class

        // =====================================================================================
        /// <summary>
        /// This class gets Menus data object by its object identifier.
        /// </summary>
        /// <param name="Title">string: a name menu item</param>
        /// <returns>EvMenuItem: a menu item</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty MenuItem object, if the Name is empty
        ///
        /// 2. Define the SQL query parameters and a query string.
        ///
        /// 3. Execute the query string and store the results on datatable.
        ///
        /// 4. Return an empty MenuItem object if the table has no value.
        ///
        /// 5. Else, Extract the table row to the MenuItem object.
        ///
        /// 6. Return the MenuItem object.
        ///
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EvMenuItem getItem(string Title)
        {
            this.LogMethod("getItem");
            this.LogDebug("Title: " + Title);
            //
            // Initialize a debug log and a menu item object
            //
            Evado.Digital.Model.EvMenuItem menuItem = new  Evado.Digital.Model.EvMenuItem( );

            //
            // Check that there is a valid name.
            //
            if (Title == String.Empty)
            {
                return(menuItem);
            }

            //
            // Define the query parameters.
            //
            SqlParameter cmdParms = new SqlParameter(PARM_TITLE, SqlDbType.NVarChar, 20);

            cmdParms.Value = Title;

            //
            // Define the query string.
            //
            _sqlQueryString = _sqlQuery_View + " WHERE (Mnu_Title = @Title ); ";

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

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

                //
                // Process the results.
                //
                menuItem = this.getRowData(row);
            }//END Using statement

            return(menuItem);
        }// Close method getMenus.
        }//END getView method.

        #endregion

        #region Get Event section

        // =====================================================================================
        /// <summary>
        /// This class gets ApplicationEvent data object by its unique object identifier.
        /// </summary>
        /// <param name="EventGuid">String: (Mandatory) Unique identifier.</param>
        /// <returns>ApplicationEvent: an item of application event</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a status string and an application event object
        ///
        /// 2. Validate whether the Unique identifier is not zero
        ///
        /// 3. Define the query parameters and the query string
        ///
        /// 4. Execute the query string
        ///
        /// 5. Convert the value from data reader event object to application event business object,
        /// if value exists
        ///
        /// 6. Return the application event value
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvApplicationEvent getItem(
            Guid EventGuid)
        {
            this.LogMethod("getItem method. ");
            this.LogDebugValue("EventGuid: " + EventGuid);
            //
            // Initialize a status string and an application event object
            //
            EvApplicationEvent applicationEvent = new EvApplicationEvent( );

            //
            // Check that there is a valid unique identifier.
            //
            if (EventGuid == Guid.Empty)
            {
                return(applicationEvent);
            }

            //
            // Define the query parameters.
            //
            SqlParameter cmdParms = new SqlParameter(PARM_GUID, SqlDbType.UniqueIdentifier);

            cmdParms.Value = EventGuid;

            //
            // Define the query string.
            //
            _sqlQueryString = _sqlQuery_View
                              + " WHERE (" + DB_GUID + " = " + PARM_GUID + " ); ";

            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // If not rows the return
                //
                if (table.Rows.Count == 0)
                {
                    return(applicationEvent);
                }

                //
                // Extract the table row and store the data row to an activity object
                //
                DataRow row = table.Rows [0];

                applicationEvent = this.getReaderData(row);
            }

            //
            // Pass back the data object.
            //
            return(applicationEvent);
        }//END getItem class
    }//End readRow method.

    #endregion

    #region List Queries section

    // =====================================================================================
    /// <summary>
    /// This class returns a list of organization data object based on the passed parameters. 
    /// </summary>
    /// <param name="Type">EvOrganisation.OrganisationTypes: the organisation type.</param>
    /// <returns>List of EvOrganisation: a list of organization data object</returns>
    /// <remarks>
    /// This method consists of the following steps: 
    /// 
    /// 1. Set the IsTrue string to 0, if the selection type is not selected.
    /// 
    /// 2. Define the sql query string and execute the sql query string to a datatable
    /// 
    /// 3. Loop through the table and extract the row data to the organization object. 
    /// 
    /// 4. Add the organization object value to the Organizations list. 
    /// 
    /// 5. Return the organizations list. 
    /// </remarks>
    // -------------------------------------------------------------------------------------
    public int getOrganisationCount ( String Type )
    {
      //
      // Initialize the method status, a return organization list and an IsTrue string value
      //
      this.LogMethod ( "getOrganisationCount method. " );
      this.LogDebug ( "Type: " + Type );
      //
      // Initialise the methods variables and objects.
      //
      int OrgCount = 0;


      // 
      // Define the SQL query parameters and load the query values.
      // 
      SqlParameter [ ] cmdParms = new SqlParameter [ ] 
      {
        new SqlParameter ( EdOrganisations.PARM_ORG_TYPE, SqlDbType.NVarChar, 50 )
      };
      cmdParms [ 0 ].Value = Type;

      // 
      // Create the sql query string.
      // 
      sqlQueryString = SQL_SELECT_QUERY
        + "WHERE (" + EdOrganisations.DB_DELETED + " = 0) ";

      if ( Type != String.Empty )
      {
        sqlQueryString += " AND (" + EdOrganisations.DB_ORG_TYPE + " = " + EdOrganisations.PARM_ORG_TYPE + ") ";
      }

      sqlQueryString += " ORDER BY " + EdOrganisations.DB_ORG_ID + ";";

      this.LogDebug ( sqlQueryString );

      // 
      // Execute the query against the database
      //
      using ( DataTable table = EvSqlMethods.RunQuery ( sqlQueryString, cmdParms ) )
      {
        OrgCount = table.Rows.Count;
      }
      // 
      // Return the arraylist of organisations.
      // 
      this.LogMethodEnd ( "getOrganisationCount" );
      return OrgCount;

    }//End getOrganisationCount method.
Beispiel #28
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.
Beispiel #29
0
        } // 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.
Beispiel #30
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