Ejemplo n.º 1
0
        } //END GetView method.

        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region Retrieve Query methods

        // =====================================================================================
        /// <summary>
        /// This method gets the information for a device.
        /// </summary>
        /// <param name="DeviceId">String: A device Id of a device </param>
        /// <returns>Object: A device object. </returns>
        /// <remarks>
        /// This method consists of following steps. </remarks>
        ///
        /// 1. Define local variables.
        ///
        /// 2. Check the whether device id is valid or not. If DeviceId is equal to an empty string, return a Device object.
        ///
        /// 3. Define the SQL query parameters and load the query values.
        ///
        /// 4. Generate the SQL query string.
        ///
        /// 5. Execute the query against the database.
        ///
        /// 6. If no rows found, return a device object.
        ///
        /// 7. Extract the table row.
        ///
        /// 8. Fill the Device object.
        ///
        /// 9. Return the Device data object.
        ///
        // -------------------------------------------------------------------------------------
        public Device GetItem(String DeviceId)
        {
            this._DebugLog += "Evado.Digital.WebService.Dal.Services.GetItem. method DeviceId: " + DeviceId;
            //
            // Define local variables
            //
            string sqlQueryString;
            Device userRegistration = new Device( );

            //
            // Check the whether device id is valid or not. If DeviceId is equal to an empty string, return a Device object.
            //
            if (DeviceId == String.Empty)
            {
                this._DebugLog += "\r\nUser Id null";
                return(userRegistration);
            }

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter cmdParms = new SqlParameter(PARM_DEVICE_ID, SqlDbType.Char, 100);

            cmdParms.Value = DeviceId;
            //
            // Generate the SQL query string
            //
            sqlQueryString  = _sqlQuery_View + " WHERE (DEVICE_ID = @DEVICE_ID);";
            this._DebugLog += "\r\n" + sqlQueryString;

            //
            // Execute the query against the database
            //
            using (DataTable table = EvSqlMethods.RunQuery(sqlQueryString, cmdParms))
            {
                //
                // If no rows found, return a device object
                //
                if (table.Rows.Count == 0)
                {
                    this._DebugLog += "\r\n Query result empty.";
                    return(userRegistration);
                }

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

                //
                // Fill the Device object.
                //
                userRegistration = this.readRow(row);

                this._DebugLog += "\r\nUserRegistration.DeviceId: " + userRegistration.DeviceId;
            }//END Using

            //
            // Return the Device data object.
            //
            return(userRegistration);
        }//END GetItem method
Ejemplo n.º 2
0
        }//END GetItem method

        // =====================================================================================
        /// <summary>
        /// This method gets the information for a device.
        /// </summary>
        /// <param name="Identifier">GUID: An Identifier for a device</param>
        /// <returns>Object: A Device Data object</returns>
        /// <remarks>
        /// This method consists of following steps.
        ///
        /// 1. Define local variables.
        ///
        /// 2. Check that the identifier Id is valid or not. if identifier is equal to a empty GUID, return a device object.
        ///
        /// 3. Define the SQL query parameters and load the query values.
        ///
        /// 4. Generate the SQL query string.
        ///
        /// 5. Execute the query against the database.
        ///
        /// 6. If no rows found, return a device object.
        ///
        /// 7. Extract the table row.
        ///
        /// 8. Fill the role object.
        ///
        /// 9. Return the device data object.
        ///
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Device GetItem(Guid Identifier)
        {
            this._DebugLog += "Evado.Digital.WebService.Dal.Services.GetItem method Identifier: " + Identifier;
            //
            // Define local variables
            //
            string sqlQueryString;
            Device userProfile = new Device( );

            //
            // Check that the identifier Id is valid or not. if identifier is equal to a empty GUID, return a device object.
            //
            if (Identifier == Guid.Empty)
            {
                return(userProfile);
            }

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

            cmdParms.Value = Identifier;

            //
            // Generate the SQL query string
            //
            sqlQueryString = _sqlQuery_View + " WHERE (ULD_IDENTIFIER = @IDENTIFIER);";

            this._DebugLog = "\r\n" + sqlQueryString;

            //
            // Execute the query against the database
            //
            using (DataTable table = EvSqlMethods.RunQuery(sqlQueryString, cmdParms))
            {
                //
                // If no rows found, return a device object
                //
                if (table.Rows.Count == 0)
                {
                    return(userProfile);
                }

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

                //
                // Fill the role object.
                //
                userProfile = this.readRow(row);
            }//END Using


            //
            // Return the device data object.
            //
            return(userProfile);
        }//END GetItem method
Ejemplo n.º 3
0
        }// End readRow method.

        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region Device Query methods

        // =====================================================================================
        /// <summary>
        /// This method gets a list of a device object from a database.
        /// </summary>
        /// <param name="DeviceName">String: A device name</param>
        /// <param name="DeviceOS">String: A device OS</param>
        /// <param name="UserId">String: A user id for a user</param>
        /// <returns>List: A list of a device object.</returns>
        /// <remarks>
        /// This method consists of following steps.
        ///
        /// 1. Define the local variables.
        ///
        /// 2. Define the SQL query parameters and load the query values.
        ///
        /// 3. Generate the SQL query string.
        ///
        /// 4. Add the filter parameters if needed.
        ///
        /// 5. Execute the query against the database.
        ///
        /// 6. Iterate through the results extracting the role information.
        ///
        /// 7. Extract the table row.
        ///
        /// 8. Return the ArrayList containing the User data object.
        ///
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public List <Device> GetView(String DeviceName, String DeviceOS, String UserId)
        {
            this._DebugLog = "Evado.Digital.WebService.Dal.Services.GetView method. "
                             + " DeviceName: " + DeviceName
                             + " DeviceOS: " + DeviceOS;

            //
            // Define the local variables
            //
            string        sqlQueryString;
            List <Device> view = new List <Device>( );

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(PARM_DEVICE_NAME, SqlDbType.NVarChar, 100),
                new SqlParameter(PARM_DEVICE_OS, SqlDbType.NVarChar, 100),
                new SqlParameter(PARM_USER_ID, SqlDbType.NVarChar, 100),
            };
            cmdParms [0].Value = DeviceName;
            cmdParms [1].Value = DeviceOS;
            cmdParms [2].Value = UserId;

            //
            // Generate the SQL query string
            //
            sqlQueryString = _sqlQuery_View;

            //
            // Add the filter parameters if needed.
            //
            if (DeviceName != String.Empty)
            {
                sqlQueryString += " WHERE ULD_DEVICE_NAME = @DEVICE_NAME ";

                if (DeviceOS != String.Empty)
                {
                    sqlQueryString += " WHERE ULD_DEVICE_OS = @DEVICE_OS ";
                }
                sqlQueryString += " ORDER BY USER_ID";
            }
            else
            {
                sqlQueryString += " WHERE USER_ID = @USER_ID ";

                sqlQueryString += " ORDER BY ULD_DEVICE_NAME";
            }


            this._DebugLog += "\r\n" + sqlQueryString;
            this._DebugLog += "\r\nSQLHelper Status: " + EvSqlMethods.Status;

            //
            // 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];

                    Device profile = this.readRow(row);

                    view.Add(profile);
                }//END count iteration
            }
            this._DebugLog += "\r\n View count: " + view.Count.ToString( );

            //
            // Return the ArrayList containing the User data object.
            //
            return(view);
        } //END GetView method.