Esempio n. 1
0
        }//END GetParameters method

        // =====================================================================================
        /// <summary>
        /// This method assigns the SiteProfile object's values to the arrray of sql parameters.
        /// </summary>
        /// <param name="cmdParms">SqlParameter: An array of sql query parameters.</param>
        /// <param name="AdapterSettings">EvSiteProfile: A Site profile object.</param>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Bind the SiteProfile object's values to the array of sql query parameters.
        /// </remarks>
        //  ------------------------------------------------------------------------------------
        private void SetParameters(
            SqlParameter [] cmdParms,
            Evado.Digital.Model.EdAdapterSettings AdapterSettings)
        {
            cmdParms [0].Value = AdapterSettings.Guid;
            cmdParms [1].Value = "A";
            cmdParms [2].Value = AdapterSettings.HomePageHeaderText;
            cmdParms [3].Value = AdapterSettings.HelpUrl;
            cmdParms [4].Value = AdapterSettings.MaximumSelectionListLength;

            cmdParms [5].Value = AdapterSettings.SmtpServer;
            cmdParms [6].Value = AdapterSettings.SmtpServerPort;
            cmdParms [7].Value = AdapterSettings.SmtpUserId;
            cmdParms [8].Value = AdapterSettings.SmtpPassword;
            cmdParms [9].Value = AdapterSettings.EmailAlertTestAddress;

            cmdParms [10].Value = AdapterSettings.State;
            cmdParms [11].Value = AdapterSettings.Title;
            cmdParms [12].Value = AdapterSettings.HttpReference;
            cmdParms [13].Value = AdapterSettings.Description;
            cmdParms [14].Value = AdapterSettings.UserRoles;

            cmdParms [15].Value = this.ClassParameters.UserProfile.CommonName;
            cmdParms [16].Value = this.ClassParameters.UserProfile.UserId;
            cmdParms [17].Value = DateTime.Now;
        }//END SetParameters method
Esempio n. 2
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.
Esempio n. 3
0
        }//END SetParameters method

        #endregion

        #region Aplication Profile  Reader

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (applicationSettings.DemoAccountExpiryDays == 0)
            {
                applicationSettings.DemoAccountExpiryDays = 28;
            }
            //
            // Return the object.
            //
            return(applicationSettings);
        }//END getReaderData method
Esempio n. 4
0
        // =====================================================================================
        /// <summary>
        /// This class retrieves a Site Profile object based on SiteId
        /// </summary>
        /// <param name="ApplicationId">string: a site identifier</param>
        /// <returns>EvSiteProfile: a Site profile object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for retrieving a Site Properties object
        ///
        /// 2. Return a Site Properties object
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EdAdapterSettings getItem(string ApplicationId)
        {
            this.LogMethod("getItem Method.");
            this.LogDebug("ApplicationId: " + ApplicationId);

            Evado.Digital.Model.EdAdapterSettings adapterSettings = this._dll_AdapterSettings.getItem(ApplicationId);

            this.LogDebugClass(this._dll_AdapterSettings.Log);

            this.LogMethodEnd("getItem");
            return(adapterSettings);
        }//END getItemById class
Esempio n. 5
0
        }//END getItemById class

        // =====================================================================================
        /// <summary>
        /// This class saves items to SiteProfile ResultData table.
        /// </summary>
        /// <param name="Properties">EvSiteProfile: a site profile object</param>
        /// <returns>EvEventCodes: an event code for saving items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for updating items
        ///
        /// 2. Return an event code for updating items.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes updateItem(Evado.Digital.Model.EdAdapterSettings Properties)
        {
            this.LogMethod("Saving Record method");
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Update the _SiteProperties record.
            //
            iReturn = this._dll_AdapterSettings.updateItem(Properties);

            this.LogDebugClass(this._dll_AdapterSettings.Log);

            return(iReturn);
        }//END updateItem class
Esempio n. 6
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);
        }
Esempio n. 7
0
        }//END getReaderData method

        #endregion

        #region Retrieval Queries

        // =====================================================================================
        /// <summary>
        /// This method retrieves the SiteProfile data table based on SiteId.
        /// </summary>
        /// <param name="ApplicationId">String: A site identifier.</param>
        /// <returns>EvSiteProfile: a Site Profile data object.</returns>
        /// <remarks>
        /// This method consisits of following steps.
        ///
        /// 1. Return an empty SiteProfile object, if the SiteId is not defined.
        ///
        /// 2. Define the sql query parameters and sql query string.
        ///
        /// 3. Execute the sql query string and store the results on data reader.
        ///
        /// 4. Return an empty SiteProfile object, if the data reader object has no value.
        ///
        /// 5. Else, extract the data reader values to the SiteProfile object.
        ///
        /// 6. Return a SiteProfile Object.
        /// </remarks>
        //  ------------------------------------------------------------------------------------
        public Evado.Digital.Model.EdAdapterSettings getItem(string ApplicationId)
        {
            this.LogMethod("getItem method. ");

            //
            // Define the local variables and objects.
            //
            Evado.Digital.Model.EdAdapterSettings adapterParameters = new  Evado.Digital.Model.EdAdapterSettings( );
            String sqlQueryString = String.Empty;

            //
            // Check that there is a valid unique identifier.
            //
            if (ApplicationId == String.Empty)
            {
                return(adapterParameters);
            }

            //
            // Define the query parameters.
            //
            SqlParameter cmdParms = new SqlParameter(EdAdapterConfig.PARM_APPLICATION_ID, SqlDbType.NVarChar, 1);

            cmdParms.Value = ApplicationId;

            //
            // Generate the query string.
            //
            sqlQueryString = EdAdapterConfig.SQL_ADAPTER_SETTINGS_QUERY
                             + " WHERE (" + EdAdapterConfig.DB_FIELD_APPLICATION_ID + " = " + EdAdapterConfig.PARM_APPLICATION_ID + " ); ";

            this.LogDebug(sqlQueryString);

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(sqlQueryString, cmdParms))
            {
                //
                // If the reader is null, retrieve from the site profile table
                // and add record to the application profile table.
                if (table.Rows.Count == 0)
                {
                    return(adapterParameters);
                }

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

                adapterParameters = this.getReaderData(row);
            }

            adapterParameters.Parameters = this.LoadObjectParameters(adapterParameters.Guid);

            this.LogDebug("Parameter list count: " + adapterParameters.Parameters.Count);

            //
            // Return an object containing an EvSiteProfile data object.
            //
            this.LogMethodEnd("getItem");
            return(adapterParameters);
        }//END getItemById method.