Ejemplo n.º 1
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.
Ejemplo n.º 2
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.
Ejemplo n.º 3
0
        }//END EvFormFieldSelectionList 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(EdPageLayout Item)
        {
            this.LogMethod("updateItem");

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

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

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

            dataChange.TableName  = EvDataChange.DataChangeTableNames.EdPageLayouts;
            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.PageId != oldItem.PageId)
            {
                dataChange.AddItem("ListId", oldItem.PageId, Item.PageId);
            }
            if (Item.Title != oldItem.Title)
            {
                dataChange.AddItem("Title", oldItem.Title, Item.Title);
            }
            if (Item.UserTypes != oldItem.UserTypes)
            {
                dataChange.AddItem("UserType", oldItem.UserTypes, Item.UserTypes);
            }
            if (Item.State != oldItem.State)
            {
                dataChange.AddItem("State", oldItem.State, Item.State);
            }
            if (Item.HeaderContent != oldItem.HeaderContent)
            {
                dataChange.AddItem("HeaderContent", Item.HeaderContent, Item.HeaderContent);
            }
            if (Item.HeaderComponentList != oldItem.HeaderComponentList)
            {
                dataChange.AddItem("HeaderGroupList", oldItem.HeaderComponentList, Item.HeaderComponentList);
            }
            if (Item.LeftColumnContent != oldItem.LeftColumnContent)
            {
                dataChange.AddItem("LeftColumnContent", oldItem.LeftColumnContent, Item.LeftColumnContent);
            }
            if (Item.LeftColumnComponentList != oldItem.LeftColumnComponentList)
            {
                dataChange.AddItem("LeftColumnGroupList", oldItem.LeftColumnComponentList, Item.LeftColumnComponentList);
            }
            if (Item.LeftColumnWidth != oldItem.LeftColumnWidth)
            {
                dataChange.AddItem("LeftColumnCommandList", oldItem.LeftColumnWidth, Item.LeftColumnWidth);
            }

            if (Item.CenterColumnContent != oldItem.CenterColumnContent)
            {
                dataChange.AddItem("CenterColumnContent", oldItem.CenterColumnContent, Item.CenterColumnContent);
            }
            if (Item.LeftColumnComponentList != oldItem.LeftColumnComponentList)
            {
                dataChange.AddItem("LeftColumnGroupList", oldItem.LeftColumnComponentList, Item.LeftColumnComponentList);
            }

            if (Item.RightColumnContent != oldItem.RightColumnContent)
            {
                dataChange.AddItem("RightColumnContent", oldItem.RightColumnContent, Item.RightColumnContent);
            }
            if (Item.RightColumnComponentList != oldItem.RightColumnComponentList)
            {
                dataChange.AddItem("RightColumnGroupList", oldItem.RightColumnComponentList, Item.RightColumnComponentList);
            }
            if (Item.RightColumnWidth != oldItem.RightColumnWidth)
            {
                dataChange.AddItem("RightColumnCommandList", oldItem.RightColumnWidth, Item.RightColumnWidth);
            }

            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( ));
            }

            // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

            //
            // 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);
            }

            //
            // update the parameter object values.
            //
            this.UpdateObjectParameters(Item.Parameters, Item.Guid);

            //
            // Add the change record
            //
            dataChanges.AddItem(dataChange);

            return(EvEventCodes.Ok);
        }//END updateItem class
    }//END getItem method

    #endregion

    #region Update Organisation.

    // =====================================================================================
    /// <summary>
    /// This class updates items to the organization data object. 
    /// </summary>
    /// <param name="Organisation">EvOrganisation: an Organisation object</param>
    /// <returns>EvEventCodes: an event code for updating result</returns>
    /// <remarks>
    /// This method consists of the following steps: 
    /// 
    /// 1. Exit, if the Old Organization's Guid is empty or the New Organization's identfier is duplicated. 
    /// 
    /// 2. Create new orgnization's Guid if it is empty. 
    /// 
    /// 3. Add new items to datachange object if they do not exist. 
    /// 
    /// 4. Define the sql query parameters and execute the storeprocedure for updating 
    /// 
    /// 5. Add datachange object values to the backup datachanges object. 
    /// 
    /// 6. Return an event code for updating items. 
    /// </remarks>
    // -------------------------------------------------------------------------------------
    public EvEventCodes updateItem ( EdOrganisation Organisation )
    {
      //
      // Initialize the method status and an old organization object
      //
      this.LogMethod ( "updateItem method." );
      this.LogDebug ( "OrgId: " + Organisation.OrgId );

      EdOrganisation oldOrg = getItem ( Organisation.Guid );

      //
      // Validate whether the Old organization exists. 
      //
      if ( oldOrg.Guid == Guid.Empty )
      {
        this.LogDebug ( " Invalid Guid not object found." );
        return EvEventCodes.Data_InvalidId_Error;
      }

      // 
      // Validate whether the new Organization Identifier is unique.
      // 
      if ( oldOrg.OrgId != Organisation.OrgId )
      {
        EdOrganisation newOrg = getItem ( Organisation.OrgId );
        if ( newOrg.Guid != Guid.Empty )
        {
          this.LogDebug ( " DuplicateId error" );
          return EvEventCodes.Data_Duplicate_Id_Error;
        }
      }

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

      // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      // Compare the objects.
      // Initialize the datachange object and a backup datachanges object
      //
      EvDataChanges dataChanges = new EvDataChanges ( );
      EvDataChange dataChange = new EvDataChange ( );
      dataChange.TableName = EvDataChange.DataChangeTableNames.EvOrganisations;
      dataChange.RecordGuid = Organisation.Guid;
      dataChange.UserId = Organisation.UpdatedByUserId;
      dataChange.DateStamp = DateTime.Now;

      //
      // Add new items to the datachange object if they do not exist.
      //
      if ( Organisation.Name != oldOrg.Name )
      {
        dataChange.AddItem ( "Name", oldOrg.Name, Organisation.Name );
      }
      if ( Organisation.AddressStreet_1 != oldOrg.AddressStreet_1 )
      {
        dataChange.AddItem ( "Address_1", oldOrg.AddressStreet_1, Organisation.AddressStreet_1 );
      }
      if ( Organisation.AddressStreet_2 != oldOrg.AddressStreet_2 )
      {
        dataChange.AddItem ( "AddressStreet_2", oldOrg.AddressStreet_2, Organisation.AddressStreet_2 );
      }
      if ( Organisation.AddressCity != oldOrg.AddressCity )
      {
        dataChange.AddItem ( "AddressCity", oldOrg.AddressCity, Organisation.AddressCity );
      }
      if ( Organisation.AddressState != oldOrg.AddressState )
      {
        dataChange.AddItem ( "AddressState", oldOrg.AddressState, Organisation.AddressState );
      }
      if ( Organisation.AddressPostCode != oldOrg.AddressPostCode )
      {
        dataChange.AddItem ( "AddressPostCode", oldOrg.AddressPostCode, Organisation.AddressPostCode );
      }
      if ( Organisation.AddressCountry != oldOrg.AddressCountry )
      {
        dataChange.AddItem ( "AddressCountry", oldOrg.AddressCountry, Organisation.AddressCountry );
      }
      if ( Organisation.Telephone != oldOrg.Telephone )
      {
        dataChange.AddItem ( "Telephone", oldOrg.Telephone, Organisation.Telephone );
      }
      if ( Organisation.EmailAddress != oldOrg.EmailAddress )
      {
        dataChange.AddItem ( "EmailAddress", oldOrg.EmailAddress, Organisation.EmailAddress );
      }
      if ( Organisation.OrgType != oldOrg.OrgType )
      {
        dataChange.AddItem ( "OrgType", oldOrg.OrgType.ToString ( ), Organisation.OrgType.ToString ( ) );
      }

      // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      // 
      // Define the query parameters
      // 
      this.LogDebug ( " Setting Parameters." );
      SqlParameter [ ] cmdParms = GetParameters ( );
      SetParameters ( cmdParms, Organisation );

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

      // 
      // Save the datachanges to the database.
      // 
      dataChanges.AddItem ( dataChange );
      this.LogDebug ( "DataChange: " + dataChanges.Log );

      return EvEventCodes.Ok;

    }//END updateItem method
Ejemplo n.º 5
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