예제 #1
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
예제 #2
0
        } //END updateItem method.

        //===================================================================================
        /// <summary>
        /// This method creates the data change object.
        ///
        /// </summary>
        /// <param name="ApplicationProperties">EvApplicationProfile Object.</param>
        /// <returns>EvDataChange</returns>
        //-----------------------------------------------------------------------------------
        private EvDataChange createDataChange(Evado.Digital.Model.EdAdapterSettings ApplicationProperties)
        {
            //
            // Initialise the methods variables and objects.
            //
            EvDataChange dataChange = new EvDataChange( );

            //
            // Get an item to be updated.
            //
            Evado.Digital.Model.EdAdapterSettings oldItem = this.getItem(ApplicationProperties.ApplicationId);

            //
            // Compare the changes.
            //
            EvDataChanges dataChanges = new EvDataChanges( );

            dataChange.TableName  = EvDataChange.DataChangeTableNames.EdAdapterSettings;
            dataChange.RecordUid  = 1;
            dataChange.RecordGuid = ApplicationProperties.Guid;
            dataChange.UserId     = this.ClassParameters.UserProfile.UserId;
            dataChange.DateStamp  = DateTime.Now;

            //
            // Add new items to datachanges if they do not exist in the Old Site Profile object.
            //
            if (ApplicationProperties.ApplicationId != oldItem.ApplicationId)
            {
                dataChange.AddItem("Id",
                                   oldItem.ApplicationId,
                                   ApplicationProperties.ApplicationId);
            }

            //
            // Add new items to datachanges if they do not exist in the Old Site Profile object.
            //


            dataChange.AddItem("MaximumSelectionListLength",
                               oldItem.MaximumSelectionListLength,
                               ApplicationProperties.MaximumSelectionListLength);


            dataChange.AddItem("SmtpServer",
                               oldItem.SmtpServer,
                               ApplicationProperties.SmtpServer);

            dataChange.AddItem("SmtpServerPort",
                               oldItem.SmtpServerPort,
                               ApplicationProperties.SmtpServerPort);

            dataChange.AddItem("SmtpUserId",
                               oldItem.SmtpUserId,
                               ApplicationProperties.SmtpUserId);

            dataChange.AddItem("EmailAlertTestAddress",
                               oldItem.EmailAlertTestAddress,
                               ApplicationProperties.EmailAlertTestAddress);

            //
            // Iterate through the parameters creating change object for each item.
            //
            for (int i = 0; i < ApplicationProperties.Parameters.Count; i++)
            {
                EvObjectParameter newParameter = ApplicationProperties.Parameters [i];
                //
                // Skip the non selected forms
                //
                if (newParameter == null)
                {
                    continue;
                }

                EvObjectParameter oldParameter = getParameter(oldItem.Parameters, newParameter.Name);

                if (oldParameter == null)
                {
                    dataChange.AddItem("APP_" + newParameter.Name,
                                       String.Empty,
                                       newParameter.Value);
                }
                else
                {
                    dataChange.AddItem("APP_" + newParameter.Name,
                                       oldParameter.Value,
                                       newParameter.Value);
                }
            }//END form list iteration loop.

            return(dataChange);
        }
예제 #3
0
        }//END updateItem method.

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

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

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

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

            //
            // Return the data change object containing an EvDataChange object.
            //
            return(dataChange);
        }//END SetDataChange method
    }//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
예제 #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