Exemplo n.º 1
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(EvSelectionList Item)
        {
            this._Log = new System.Text.StringBuilder( );
            this.LogMethod("deleteItem method. ");

            //
            // Define the query parameters
            //
            SqlParameter [] commandParameters = new SqlParameter []
            {
                new SqlParameter(EvSelectionLists.PARM_GUID, SqlDbType.UniqueIdentifier),
                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.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.
Exemplo n.º 2
0
        }// End deleteYear method.

        // ==================================================================================
        /// <summary>
        /// This class updates the appliocation parameter records data object.
        /// </summary>
        /// <param name="Item">EdSelectionList object</param>
        /// <returns>EvEventCodes: an event code for update data object</returns>
        // ----------------------------------------------------------------------------------
        private int trimItemOptions(EvSelectionList Item)
        {
            this.LogMethod("trimOptions ");
            string hasOptions = String.Empty;
            int    count      = 0;

            this.LogDebug("Items.Count {0}.", Item.Items.Count);

            //
            // iterate through the options in the list.
            //
            for (int i = 0; i < Item.Items.Count; i++)
            {
                if (hasOptions.Contains(Item.Items [i].Value) == true)
                {
                    Item.Items.RemoveAt(i);
                    i--;
                    continue;
                }
                hasOptions += ";" + Item.Items [i].Value;
            }//END option item iteration loop.

            this.LogDebug("TRIMMED: Items.Count {0}.", Item.Items.Count);
            this.LogMethod("trimOptions ");
            return(count);
        }
Exemplo n.º 3
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
Exemplo n.º 4
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.
Exemplo n.º 5
0
        }// END getView method.

        // =====================================================================================
        /// <summary>
        /// This class returns a list of options based on the state and Guid values
        /// </summary>
        /// <param name="State">EvFormFieldSelectionList.SelectionListStates: The selection list state.</param>
        /// <param name="SelectByGuid">Boolean: True, if the selection is based on Guid.</param>
        /// <returns>List of EvOption: a list of option data objects</returns>
        /// <remarks>
        /// This method consists of the followings 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. Loop through the table and extract the data row to the option object.
        ///
        /// 4. Add the Option object values to the Options list.
        ///
        /// 5. Return the Options list.
        /// </remarks>
        //  ---------------------------------------------------------------------------------
        public List <EvOption> getList(
            EvSelectionList.SelectionListStates State,
            bool SelectByGuid)
        {
            this.LogMethod("getList method.");
            this._Log.AppendLine("State: " + State);
            this._Log.AppendLine("SelectByUid: " + SelectByGuid.ToString( ));

            //
            // Initialise the local variables
            //
            List <EvOption> list   = new List <EvOption> ( );
            EvOption        option = new EvOption( );

            list.Add(option);

            //
            // get the list of selectionLists
            //
            var selectionList = this.getView(State);

            //
            // Iterate through the results extracting the role information.
            //
            for (int count = 0; count < selectionList.Count; count++)
            {
                EvSelectionList item = selectionList [count];
                //
                // If SelectByGuid = True then optionId is to be the objects TestReport UID
                //
                if (SelectByGuid == true)
                {
                    option = new EvOption(item.Guid.ToString( ),
                                          String.Format("{0} - {1} ", item.ListId, item.Title));
                }

                //
                // If SelectByGuid = False then optionId is to be the objects ListId.
                //
                else
                {
                    option = new EvOption(item.ListId,
                                          String.Format("{0} - {1} ", item.ListId, item.Title));
                }

                list.Add(option);

                if (count > this.ClassParameters.MaxResultLength)
                {
                    break;
                }
            } //END interation loop.

            //
            // Return the ArrayList.
            //
            return(list);
        }//END getList class
Exemplo n.º 6
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
Exemplo n.º 7
0
        }//END getList method

        #endregion

        #region Retrieve ExternalSelectionList object methods

        // =====================================================================================
        /// <summary>
        /// This class retrieves the formfield selectionList object based on ListGuid.
        /// </summary>
        /// <param name="ListGuid">Guid: a list's global unique identifier</param>
        /// <returns>EvFormFieldSelectionList: a formfield selectionList object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for retrieving a formfield selectionList object based on ListGuid
        ///
        /// 2. Return a formfield selectionList object
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvSelectionList getItem(Guid ListGuid)
        {
            this.LogMethod("getItem");
            this.LogDebug("ListGuid: " + ListGuid);
            //
            // Initialise the method variables and objects.
            //
            EvSelectionList item = this._dal_SelectionLists.getItem(ListGuid);

            this.LogClass(this._dal_SelectionLists.Log);

            return(item);
        }//END getItem method
Exemplo n.º 8
0
        }//END getItem method

        // ===================================================================================
        /// <summary>
        /// This class retrieves the formfield selectionList object based on ListId.
        /// </summary>
        /// <param name="ListId">string: a list identifier</param>
        /// <returns>EvFormFieldSelectionList: a formfield selectionList object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for retrieving a formfield selectionList object based on ListId
        ///
        /// 2. Return a formfield selectionList object
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvSelectionList getItem(string ListId)
        {
            this.LogMethod("getItem");
            this.LogDebug("ListId: " + ListId);

            //
            // Execute the DAL method to retrieve the ExternalSelectionList object and process the
            // result.
            //
            EvSelectionList Item = this._dal_SelectionLists.getItem(ListId, true);

            this.LogClass(this._dal_SelectionLists.Log);

            return(Item);
        }//END getItem method
Exemplo n.º 9
0
        }//END saveItem class

        // =====================================================================================
        /// <summary>
        /// This class updates the state of formfield selectionlist object
        /// </summary>
        /// <param name="Item">EvFormFieldSelectionList: a formfield selectionlist object</param>
        /// <remarks>
        /// This method consists of the following step:
        ///
        /// 1. Update the formfield selectionlist object's items and its state based on its action codes.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        private void updateState(EvSelectionList Item)
        {
            this.LogMethod("updateState.");
            this.LogDebug("Action: " + Item.Action);

            //
            // If action is save then minor version increment version and add UpdatedBy entry
            //
            switch (Item.Action)
            {
            case EvSelectionList.SaveActions.Draft:
            {
                this.LogDebug("Draft list");

                Item.State = EvSelectionList.SelectionListStates.Draft;

                return;
            }

            case EvSelectionList.SaveActions.Issue_List:
            {
                Item.State = EvSelectionList.SelectionListStates.Draft;
                Item.Version++;

                return;
            }

            case EvSelectionList.SaveActions.Withdraw_List:
            {
                Item.State = EvSelectionList.SelectionListStates.Withdrawn;
                Item.Version++;

                return;
            }
            } //End switch statement
        }     //END updateState method.
Exemplo n.º 10
0
        }//END GetParameters class

        // ==================================================================================
        /// <summary>
        /// This class sets the values to the parameters array.
        /// </summary>
        /// <param name="parms">SqlParameter: an array of sql parameters</param>
        /// <param name="Item">EvFormFieldSelectionList: a formfield selectionlist object</param>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Add new DB row Guid, if item's Guid is empty
        ///
        /// 2. Update the items values from formfield selectionlist object to the array of sql parameters.
        /// </remarks>
        //  ---------------------------------------------------------------------------------
        private void SetParameters(SqlParameter [] parms, EvSelectionList Item)
        {
            //
            // Add new DB row Guid, if item's Guid is empty
            //
            if (Item.Guid == Guid.Empty)
            {
                Item.Guid = Guid.NewGuid( );
            }

            //
            // Update the items values from formfield selectionlist object to the array of sql parameters.
            //
            parms [0].Value = Item.Guid;
            parms [1].Value = Item.ListId;
            parms [2].Value = Item.State;
            parms [3].Value = Item.Title;
            parms [4].Value = Item.Description;
            parms [5].Value = Evado.Model.EvStatics.SerialiseObject <List <EvSelectionList.Item> > (Item.Items);
            parms [6].Value = Item.Version;
            parms [7].Value = this.ClassParameters.UserProfile.UserId;
            parms [8].Value = this.ClassParameters.UserProfile.CommonName;
            parms [9].Value = DateTime.Now;
        }//END SetParameters class.
Exemplo n.º 11
0
        }//END getItem method

        #endregion

        #region Update ExternalSelectionList object methods

        // ===================================================================================
        /// <summary>
        /// This class saves items to the Formfield selectionlist ResultData table
        /// </summary>
        /// <param name="SelectionList">EvFormFieldSelectionList: a formfield selection list object</param>
        /// <returns>EvEventCodes: an event code for saving items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the ListId or UserCommonName is empty
        ///
        /// 2. Loop through the selectionlist object and remove the empty items.
        ///
        /// 3. Execute the method for deleting items, if the action code is delete.
        ///
        /// 4. Execute the method for adding items, if the Uid is not defined.
        ///
        /// 5. Else, execute the method for updating items.
        ///
        /// 6. Return an event code of method execution.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes SaveItem(EvSelectionList SelectionList)
        {
            this._Log = new System.Text.StringBuilder( );
            this.LogMethod("saveItem");
            //
            // Initialise the local variables
            //
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Exit, if the ListId or UserCommonName is empty
            //
            if (SelectionList.ListId == String.Empty)
            {
                return(EvEventCodes.Data_InvalidId_Error);
            }
            if (SelectionList.State == EvSelectionList.SelectionListStates.Null)
            {
                SelectionList.State = EvSelectionList.SelectionListStates.Draft;
            }

            //
            // Remove empty items.
            //
            SelectionList.RemoveEmptyItems( );

            //
            // delete selection list .
            //
            if (SelectionList.Action == EvSelectionList.SaveActions.Delete_Object)
            {
                this.LogDebug("Delete SelectionList ");

                iReturn = this._dal_SelectionLists.DeleteItem(SelectionList);
                this.LogClass(this._dal_SelectionLists.Log);
                return(iReturn);
            }

            //
            // Update the SelectionList state based on the SelectionList object Action property.
            //
            this.updateState(SelectionList);
            this.LogDebug(" Record State: " + SelectionList.State);

            //
            // If the unique identifier is null then add this object as a new
            // SelectionList object.
            //
            this.LogDebug("Save Object to Database.");

            if (SelectionList.Guid == Guid.Empty) // Add new record
            {
                this.LogDebug("Add SelectionList to database");
                iReturn = this._dal_SelectionLists.addItem(SelectionList);

                this.LogClass(this._dal_SelectionLists.Log);

                return(iReturn);
            }

            //
            // If the checklist being approved then withdraw the pervious issues checklist
            //
            if (SelectionList.Action == EvSelectionList.SaveActions.Issue_List)
            {
                this.LogDebug("Withdraw the existing checklist");
                iReturn = this._dal_SelectionLists.WithdrawIssuedList(SelectionList);
                this.LogClass(this._dal_SelectionLists.Log);

                SelectionList.State = EvSelectionList.SelectionListStates.Issued;
            }

            //
            // Update the checklist object.
            //
            this.LogDebug("Update SelectionList ");

            iReturn = this._dal_SelectionLists.updateItem(SelectionList);       // Update ExternalSelectionList properties.
            this.LogClass(this._dal_SelectionLists.Log);
            return(iReturn);
        }//END saveItem class
Exemplo n.º 12
0
        // ==================================================================================
        /// <summary>
        /// This class updates the appliocation parameter records data object.
        /// </summary>
        /// <param name="Item">EdSelectionList object</param>
        /// <returns>EvEventCodes: an event code for update data object</returns>
        // ----------------------------------------------------------------------------------
        private EvEventCodes updateOptions(EvSelectionList Item)
        {
            this.LogMethod("updateOptions ");
            this.LogValue("ListId: {0}.", Item.ListId);
            this.LogValue("Item.Items.Count: {0}.", Item.Items.Count);
            //
            // Initialize the Sql update query string.
            //
            System.Text.StringBuilder SqlUpdateQuery = new System.Text.StringBuilder( );

            if (Item.Items.Count == 0)
            {
                this.LogValue("No options in the list");

                this.LogMethodEnd("updateOptions ");
                return(EvEventCodes.Ok);
            }

            //
            // Delete the milestone activities for this milestone.
            //
            SqlUpdateQuery.AppendLine("/** DELETE ALL OF OBJECT PARAMETERS FOR THE OBJECT **/");
            SqlUpdateQuery.AppendLine(" DELETE FROM ED_SELECTION_LIST_OPTIONS ");
            SqlUpdateQuery.AppendLine(" WHERE  (EDSL_LIST_ID = '" + Item.ListId + "') ; \r\n");

            for (int count = 0; count < Item.Items.Count; count++)
            {
                EvSelectionList.Item selectionItem = Item.Items [count];
                //
                // Skip the non selected forms
                //
                if (selectionItem == null)
                {
                    continue;
                }

                this.LogDebug("Value: {0}, Description: {1}, Category: {1} ", selectionItem.Value, selectionItem.Description, selectionItem.Category);

                SqlUpdateQuery.AppendLine("Insert Into ED_SELECTION_LIST_OPTIONS ");
                SqlUpdateQuery.AppendLine("( EDSL_LIST_ID, EDS0_NO, EDS0_VALUE, EDSO_DESCRIPTION, EDSO_CATEGORY )  ");
                SqlUpdateQuery.AppendLine("values  ");
                SqlUpdateQuery.AppendLine("('" + Item.ListId + "', ");
                SqlUpdateQuery.AppendLine(" " + selectionItem.No + ", ");
                SqlUpdateQuery.AppendLine("'" + selectionItem.Value + "', ");
                SqlUpdateQuery.AppendLine("'" + selectionItem.Description + "', ");
                SqlUpdateQuery.AppendLine(" '" + selectionItem.Category + "' ); \r\n");
            }//END form list iteration loop.


            if (EvSqlMethods.QueryUpdate(SqlUpdateQuery.ToString( ), null) == 0)
            {
                this.LogValue("Update failed");
                this.LogMethodEnd("updateOptions ");
                return(EvEventCodes.Database_Record_Update_Error);
            }

            this.LogValue("Update completed");
            //
            // Return code
            //
            this.LogMethodEnd("updateOptions ");
            return(EvEventCodes.Ok);
        }//END updateOptions class
Exemplo n.º 13
0
        }// END getItem method

        #endregion

        #region SelectionList Update queries

        // =====================================================================================
        /// <summary>
        /// This class updates items on formfield selection list table.
        /// </summary>
        /// <param name="Item">EvFormFieldSelectionList: a formfield selection list object</param>
        /// <returns>EvEventCodes: an event code for updating items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the Old list's Guid is empty.
        ///
        /// 2. Add items to datachange object if they exist after comparing with the old list.
        ///
        /// 3. Define the sql parameters and execute the storeprocedure for updating items.
        ///
        /// 4. Add the datachange values to the backup datachanges object.
        ///
        /// 5. Return the event code for updating the items.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes updateItem(EvSelectionList Item)
        {
            this._Log = new System.Text.StringBuilder( );
            this.LogMethod("updateItem");

            //
            // Get the previous value
            //
            EvSelectionList oldItem = getItem(Item.Guid);

            if (oldItem.Guid == Guid.Empty)
            {
                return(EvEventCodes.Identifier_Global_Unique_Identifier_Error);
            }

            //
            // trime the item options.
            //
            this.trimItemOptions(Item);

            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            // Compare the objects.
            //
            EvDataChanges dataChanges = new EvDataChanges( );
            EvDataChange  dataChange  = new EvDataChange( );

            dataChange.TableName  = EvDataChange.DataChangeTableNames.EdSelectionList;
            dataChange.TrialId    = String.Empty;
            dataChange.RecordUid  = -1;
            dataChange.RecordGuid = Item.Guid;
            dataChange.UserId     = Item.UpdatedByUserId;
            dataChange.DateStamp  = DateTime.Now;

            //
            // Add items to datachange object if they exist.
            //
            if (Item.ListId != oldItem.ListId)
            {
                dataChange.AddItem("ListId", oldItem.ListId, Item.ListId);
            }
            if (Item.Title != oldItem.Title)
            {
                dataChange.AddItem("Title", oldItem.Title, Item.Title);
            }
            if (Item.Description != oldItem.Description)
            {
                dataChange.AddItem("Description", oldItem.Description, Item.Description);
            }
            if (Item.Version != oldItem.Version)
            {
                dataChange.AddItem("Version", oldItem.Version, Item.Version);
            }
            if (Item.State != oldItem.State)
            {
                dataChange.AddItem("State", oldItem.State.ToString( ), Item.State.ToString( ));
            }

            string oldCodeItem =
                Evado.Digital.Model.EvcStatics.SerialiseObject <List <EvSelectionList.Item> > (Item.Items);

            string newCodeItem =
                Evado.Digital.Model.EvcStatics.SerialiseObject <List <EvSelectionList.Item> > (Item.Items);

            if (newCodeItem != oldCodeItem)
            {
                dataChange.AddItem("Items", oldCodeItem, newCodeItem);
            }
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

            //
            // Define the query parameters
            //
            SqlParameter [] commandParameters = GetParameters( );
            SetParameters(commandParameters, Item);

            //
            // Execute the update command.
            //
            if (EvSqlMethods.StoreProcUpdate(_STORED_PROCEDURE_UpdateItem, commandParameters) == 0)
            {
                return(EvEventCodes.Database_Record_Update_Error);
            }
            //
            // Add the change record
            //
            dataChanges.AddItem(dataChange);

            //
            // Update the option list
            //
            this.updateOptions(Item);

            return(EvEventCodes.Ok);
        }//END updateItem class
Exemplo n.º 14
0
        }//END EvFormFieldSelectionList method

        // ====================================================================================
        /// <summary>
        /// This class retrieves the formfield selection list based on ListId and Issued condition
        /// </summary>
        /// <param name="ListId">string: the selection list identifier</param>
        /// <param name="Issued">Boolean: true, if the selection list is issued.</param>
        /// <returns>EvFormFieldSelectionList: a formfield selection list object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty selection list if the list's identifier 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(
            string ListId,
            bool Issued)
        {
            this.LogMethod("getItem, ListId = " + ListId);
            //
            // Initialise the local variables
            //
            EvSelectionList item           = new EvSelectionList( );
            String          sqlQueryString = String.Empty;

            //
            // If the ListId is null then return empty Ethics object.
            //
            if (ListId == string.Empty)
            {
                return(item);
            }

            //
            // Initialise the query parameters.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(EvSelectionLists.PARM_LIST_ID, SqlDbType.NVarChar, 10),
            };
            cmdParms [0].Value = ListId;

            //
            // Generate the Selection query string.
            //
            sqlQueryString = SQL_VIEW_QUERY + " WHERE (" + EvSelectionLists.DB_LIST_ID + " = " + EvSelectionLists.PARM_LIST_ID + ") "
                             + " AND  (" + EvSelectionLists.DB_DELETED + " = 0 )";

            if (Issued == true)
            {
                sqlQueryString += " AND (" + EvSelectionLists.DB_STATE + " = '" + EvSelectionList.SelectionListStates.Issued + "'); ";
            }

            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 the TestReport data object.
            //
            return(item);
        }// END getItem method
Exemplo n.º 15
0
        }//END readDataRow method.

        #endregion

        #region SelectionList Queries

        // =====================================================================================
        /// <summary>
        /// This class returns the list of formfield selectionlist object using state and orderBy values
        /// </summary>
        /// <param name="State">EvFormFieldSelectionList.SelectionListStates: an enumeration state</param>
        /// <returns>List of EvFormFieldSelectionList: a list of formfield selectionlist object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define the sql query parameter and sql query string
        ///
        /// 2. Execute the sql query string with parameters and store the results on datatable.
        ///
        /// 3. Iterate through the table and extract datarow to the formfield selectionlist object
        ///
        /// 4. Add the object values to the Formfield selection list.
        ///
        /// 5. Return the Formfield selection list.
        /// </remarks>
        //  ---------------------------------------------------------------------------------
        public List <EvSelectionList> getView(
            EvSelectionList.SelectionListStates State)
        {
            //
            // Initialize the method status and a return list of formfield selectionlist object
            //
            this.LogMethod("getView method.");
            this._Log.AppendLine("State: " + State);

            List <EvSelectionList> view = new List <EvSelectionList> ( );
            String sqlQueryString       = String.Empty;

            //
            // Define the sql query parameter and load the query values.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(EvSelectionLists.PARM_STATE, SqlDbType.VarChar, 20)
            };
            cmdParms [0].Value = State.ToString( );

            //
            // Define the sql query string.
            //
            sqlQueryString = SQL_VIEW_QUERY;
            if (State != EvSelectionList.SelectionListStates.Null)
            {
                sqlQueryString += " WHERE ( " + EvSelectionLists.DB_STATE + " = " + EvSelectionLists.PARM_STATE + " ) "
                                  + " AND  (" + EvSelectionLists.DB_DELETED + " = 0 )"
                                  + " ORDER BY " + EvSelectionLists.DB_LIST_ID + ";";
            }
            else
            {
                sqlQueryString += " WHERE (  " + EvSelectionLists.DB_STATE + " <> '" + EvSelectionList.SelectionListStates.Withdrawn + "' ) "
                                  + " AND  (" + EvSelectionLists.DB_DELETED + " = 0 )"
                                  + " ORDER BY " + EvSelectionLists.DB_LIST_ID + ";";
            }


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

                    EvSelectionList selectionList = this.readDataRow(row);

                    //
                    // Append the value to the visit
                    //
                    view.Add(selectionList);
                } //END interation loop.
            }     //END using statement

            this.LogDebug(" view count: " + view.Count.ToString( ));
            //
            // return the Array object.
            //
            return(view);
        }// END getView method.
Exemplo n.º 16
0
        }//END saveItem method

        #endregion

        #region Class  update  methods

        // =====================================================================================
        /// <summary>
        /// This method updates user profile for token authentication process.
        /// </summary>
        /// <param name="TokenUser">Evado.Model.EusTokenUserProfile object</param>
        /// <param name="UserTypeList">EdSelectionList object containing the user category options.</param>
        /// <returns>EvEventCodes: an event code for saving items</returns>
        // -------------------------------------------------------------------------------------
        public EvEventCodes updateTokenUser(
            Evado.Model.EusTokenUserProfile TokenUser,
            EvSelectionList UserTypeList)
        {
            this.FlushLog( );
            this.LogMethod("updateTokenUser");
            this.LogDebug("TokenUser.UserId {0}", TokenUser.UserId);
            this.LogDebug("UserTypeList.Items Title: {0}, items {1}",
                          UserTypeList.Title, UserTypeList.Items.Count);
            //
            // Initialise the methods variables and objects.
            //
            EvEventCodes result = EvEventCodes.Ok;

            Evado.Digital.Model.EdUserProfile userProfile         = new EdUserProfile( );
            Evado.Digital.Model.EdUserProfile existingUserProfile = new EdUserProfile( );

            //
            // Import the user token data.
            //
            userProfile.ImportTokenProfile(TokenUser);

            //
            // Check that the user id is valid
            //
            if (userProfile.UserId == String.Empty)
            {
                this.LogEvent("UserId is empty");
                return(EvEventCodes.Token_User_Profile_UserId_Empty);
            }

            //
            // validate that the user does not already exist.
            //
            existingUserProfile = this._Dal_UserProfiles.GetItem(userProfile.Guid);

            this.LogDebug(" userProfile.Guid: '{0}', UserId '{1}'", userProfile.Guid, userProfile.UserId);
            this.LogDebug(" existingUserProfile.Guid: '{0}', UserId '{1}'", existingUserProfile.Guid, existingUserProfile.UserId);

            if (existingUserProfile.UserId != userProfile.UserId &&
                existingUserProfile.Guid != Guid.Empty)
            {
                this.LogDebug("UserId does NOT match the Token value.");
                this.LogMethodEnd("updateTokenUser");
                return(EvEventCodes.Token_User_Profile_UserId_Error);
            }

            //
            // If a new user exists the update their details as a subscribed user.
            //
            if (existingUserProfile.UserId == userProfile.UserId &&
                TokenUser.UserStatus == EusTokenUserProfile.UserStatusCodes.New_User)
            {
                this.LogDebug("Existing User to update details as a subscribed user.");
                TokenUser.UserStatus = EusTokenUserProfile.UserStatusCodes.Subscribed_User;
            }

            //
            // if the user does not have an organisation create one for them.
            //
            if (userProfile.OrgId == String.Empty)
            {
                userProfile.OrgId = existingUserProfile.OrgId;

                this.LogDebug("No Organisation so create one for the user.");
                this.AddTokenOrganisation(userProfile);
            }

            //
            // match the user category with the user type.
            //
            if (UserTypeList.Items.Count > 0)
            {
                this.LogDebug("Updating the use category");
                this.LogDebug("UserType {0}.", userProfile.UserType);
                foreach (EvSelectionList.Item item in UserTypeList.Items)
                {
                    this.LogDebug("Item C: {0}, V: {1}, D: {2}", item.Category, item.Value, item.Description);
                    if (userProfile.UserType == item.Value)
                    {
                        userProfile.UserCategory = item.Category;
                        break;
                    }
                }
            }
            this.LogDebug("UserCatetory {0}.", userProfile.UserCategory);

            //
            // if the role is empty set to the category as a default.
            //
            if (userProfile.Roles == String.Empty)
            {
                userProfile.Roles = userProfile.UserCategory;
            }

            //
            // based on the user status select the method of user update.
            //
            this.LogDebug("UserStatus {0}.", TokenUser.UserStatus);
            switch (TokenUser.UserStatus)
            {
            case EusTokenUserProfile.UserStatusCodes.New_User:
            {
                this.LogValue("Add User");
                result = this._Dal_UserProfiles.AddItem(userProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                this.LogMethodEnd("updateTokenUser");
                return(result);
            }

            case EusTokenUserProfile.UserStatusCodes.Subscribed_User:
            {
                this.LogValue("update User");
                result = this._Dal_UserProfiles.UpdateItem(userProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                this.LogMethodEnd("updateTokenUser");
                return(result);
            }

            default:
            {
                this.LogValue("Disable user access");

                userProfile.Roles        = String.Empty;
                userProfile.UserCategory = String.Empty;
                userProfile.UserType     = String.Empty;

                result = this._Dal_UserProfiles.UpdateItem(userProfile);
                this.LogDebug(this._Dal_UserProfiles.Log);

                this.LogMethodEnd("updateTokenUser");
                return(result);
            }
            }
        }//END updateTokenUser method