Пример #1
0
        }//END addItem method.

        // ==================================================================================
        /// <summary>
        /// This class adds a record to the binary file table.
        /// </summary>
        /// <param name="BinaryFile">EvBinaryFileMetaData: a binary file object</param>
        /// <returns>EvEventCodes: an event code for adding items to the binary file table</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define sql query parameters and execute the storeprocedure for adding items.
        ///
        /// 2. Return the event code for adding new items.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public EvEventCodes updateItem(EvBinaryFileMetaData BinaryFile)
        {
            //
            // Initialize a method debug status.
            //
            this.LogMethod("updateItem");

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter [] _cmdParms = getItemsParameters( );
            SetParameters(_cmdParms, BinaryFile);

            //
            // Execute the update command.
            //
            if (EvSqlMethods.StoreProcUpdate(_storedProcedureUpdateItem, _cmdParms) == 0)
            {
                this.LogMethodEnd("updateItem");
                return(EvEventCodes.Database_Record_Update_Error);
            }

            this.LogMethodEnd("updateItem");
            return(EvEventCodes.Ok);
        }//END addItem method.
Пример #2
0
        }//END getVersionedView method.

        #endregion

        #region Class Retrieval methods

        // ==================================================================================
        /// <summary>
        /// This class gets itmes of binary file data object.
        /// </summary>
        /// <param name="Guid">Guid: a binary global unique identifier</param>
        /// <returns>EvBinaryFileMetaData: a binary file data object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty binary file object if the Binary file's Guid is empty
        ///
        /// 2. Define the sql query parameter and the sql query string
        ///
        /// 3. Execute the sql query string with parameter and store the result on the datatable
        ///
        /// 4. Extract the first data row to the binary file object.
        ///
        /// 5. Return the Binary file object.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public EvBinaryFileMetaData GetFile(Guid Guid)
        {
            this.LogMethod("GetFile method. ");
            this.LogDebug("Guid: " + Guid);
            //
            // Define local variables
            //
            string sqlQueryString;
            EvBinaryFileMetaData binaryFile = new EvBinaryFileMetaData( );

            //
            // Check that the TrialObjectId is valid.
            //
            if (Guid == Guid.Empty)
            {
                return(binaryFile);
            }

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

            cmdParms.Value = Guid;

            //
            // Generate the SQL query string
            //
            sqlQueryString = SQL_VIEW_QUERY
                             + "\r\n WHERE (" + EvBinaryFiles.DB_GUID + " = " + EvBinaryFiles.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(binaryFile);
                }

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

                binaryFile = this.readDataRow(row);
            }//END Using

            //
            // Return the TrialVisit data object.
            //
            this.LogMethodEnd("GetFile");
            return(binaryFile);
        }//END GetItem class.
Пример #3
0
        }//END GetItem class.

        #endregion

        #region Class update methods

        // ==================================================================================
        /// <summary>
        /// This class adds a record to the binary file table.
        /// </summary>
        /// <param name="BinaryFile">EvBinaryFileMetaData: a binary file object</param>
        /// <returns>EvEventCodes: an event code for adding items to the binary file table</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define sql query parameters and execute the storeprocedure for adding items.
        ///
        /// 2. Return the event code for adding new items.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public EvEventCodes addItem(EvBinaryFileMetaData BinaryFile)
        {
            this.LogMethod("addItem method. ");
            this.LogDebug(" BinaryFile.Version: " + BinaryFile.Version);
            this.LogDebug(" BinaryFile.FileEncrypted: " + BinaryFile.FileEncrypted);
            this.LogDebug(" BinaryFile.FileExists: " + BinaryFile.FileExists);
            this.LogDebug(" BinaryFile.Comments: " + BinaryFile.Comments);
            this.LogDebug(" BinaryFile.Language: " + BinaryFile.Language);
            //
            // Initialize a method debug status.
            //
            BinaryFile.FileExists = true;

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter [] _cmdParms = getItemsParameters( );
            SetParameters(_cmdParms, BinaryFile);

            this.LogDebug(EvSqlMethods.ListParameters(_cmdParms));

            //
            // Execute the update command.
            //
            if (EvSqlMethods.StoreProcUpdate(_storedProcedureAddItem, _cmdParms) == 0)
            {
                this.LogMethodEnd("addItem");
                return(EvEventCodes.Database_Record_Update_Error);
            }

            this.LogMethodEnd("addItem");
            return(EvEventCodes.Ok);
        }//END addItem method.
Пример #4
0
        }//END getItemsParameters class

        // ==================================================================================
        /// <summary>
        ///  This method fills the parameter array with values to be passed to the update
        ///  stored procedures.
        /// </summary>
        /// <param name="cmdParms">SqlParameter: an array of Database parameters</param>
        /// <param name="BinaryFile">EvBinaryFileMetaData: Values to bind to parameters</param>
        /// <remarks>
        /// This method consists of the following step:
        ///
        /// 1. Update values from a binary file object to the array of sql query parameter.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private void SetParameters(SqlParameter [] cmdParms, EvBinaryFileMetaData BinaryFile)
        {
            cmdParms [0].Value = BinaryFile.Guid;
            cmdParms [1].Value = BinaryFile.FileGuid;
            cmdParms [2].Value = BinaryFile.TrialGuid;
            cmdParms [3].Value = BinaryFile.GroupGuid;
            cmdParms [4].Value = BinaryFile.SubGroupGuid;

            cmdParms [5].Value = BinaryFile.Language;
            cmdParms [6].Value = BinaryFile.TrialId;
            cmdParms [7].Value = BinaryFile.GroupId;
            cmdParms [8].Value = BinaryFile.SubGroupId;
            cmdParms [9].Value = BinaryFile.FileId;

            cmdParms [10].Value = BinaryFile.Title;
            cmdParms [11].Value = BinaryFile.Comments;
            cmdParms [12].Value = BinaryFile.FileName;
            cmdParms [13].Value = BinaryFile.MimeType;
            cmdParms [14].Value = BinaryFile.Status;

            cmdParms [15].Value = BinaryFile.UploadDate;
            cmdParms [16].Value = BinaryFile.ReleaseDate;
            cmdParms [17].Value = BinaryFile.SupersededDate;
            cmdParms [18].Value = BinaryFile.Version;
            cmdParms [19].Value = BinaryFile.FileExists;

            cmdParms [20].Value = BinaryFile.FileEncrypted;
            cmdParms [21].Value = BinaryFile.UpdatedByUserId;
            cmdParms [22].Value = BinaryFile.UpdatedBy;
            cmdParms [23].Value = DateTime.Now;
        }//END SetParameters class.
Пример #5
0
        }//End GetVersionedFileList method.

        // =====================================================================================
        /// <summary>
        /// This class retrieves the Binary file based on it Guid
        /// </summary>
        /// <param name="BinaryGuid">Guid: A Binary global unique identifier</param>
        /// <returns>EvBinaryFileMetaData: the binary file ResultData object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for retrieving the Binary file ResultData objects.
        ///
        /// 2. Return the Binary file ResultData object.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvBinaryFileMetaData GetFile(Guid BinaryGuid)
        {
            this.LogMethod("GetFile method. ");
            this.LogDebug("BinaryGuid: " + BinaryGuid);

            //
            // Execute the method for retrieving the Binary File ResultData objects.
            //
            EvBinaryFileMetaData file = this._DalBinaryFiles.GetFile(BinaryGuid);

            this.LogClass(this._DalBinaryFiles.Log);

            this.LogMethodEnd("GetFile");
            return(file);
        }//End getItem method.
Пример #6
0
        }//END SetParameters class.

        #endregion

        #region Data Reader methods

        // ==================================================================================
        /// <summary>
        /// This method reads the content of the data row object containing a query result
        /// into an ActivityRecord object.
        /// </summary>
        /// <param name="Row">DataRow: a retrieving data row object</param>
        /// <returns>EvBinaryFileMetaData: a readed data row object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Extract the compatible data row values to the Binary file Meta data object
        ///
        /// 2. Return the Binary file Meta data object
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public EvBinaryFileMetaData readDataRow(DataRow Row)
        {
            //
            // Initialise the instrument objects and variables.
            //
            EvBinaryFileMetaData binaryFile = new EvBinaryFileMetaData( );

            //
            // Extract the data object values.
            //
            binaryFile.Guid         = EvSqlMethods.getGuid(Row, EvBinaryFiles.DB_GUID);
            binaryFile.FileGuid     = EvSqlMethods.getGuid(Row, EvBinaryFiles.DB_FILE_GUID);
            binaryFile.TrialGuid    = EvSqlMethods.getGuid(Row, EvBinaryFiles.DB_PROJECT_GUID);
            binaryFile.GroupGuid    = EvSqlMethods.getGuid(Row, EvBinaryFiles.DB_GROUP_GUID);
            binaryFile.SubGroupGuid = EvSqlMethods.getGuid(Row, EvBinaryFiles.DB_SUB_GROUP_GUID);

            binaryFile.Language   = EvSqlMethods.getString(Row, EvBinaryFiles.DB_LANGUAGE);
            binaryFile.TrialId    = EvSqlMethods.getString(Row, EvBinaryFiles.DB_TRIAL_ID);
            binaryFile.GroupId    = EvSqlMethods.getString(Row, EvBinaryFiles.DB_GROUP_ID);
            binaryFile.SubGroupId = EvSqlMethods.getString(Row, EvBinaryFiles.DB_SUB_GROUP_ID);
            binaryFile.FileId     = EvSqlMethods.getString(Row, EvBinaryFiles.DB_FILE_ID);
            binaryFile.Title      = EvSqlMethods.getString(Row, EvBinaryFiles.DB_FILE_TITLE);

            binaryFile.Comments = EvSqlMethods.getString(Row, EvBinaryFiles.DB_FILE_COMMENT);
            binaryFile.FileName = EvSqlMethods.getString(Row, EvBinaryFiles.DB_FILE_NAME);
            binaryFile.MimeType = EvSqlMethods.getString(Row, EvBinaryFiles.DB_MIME_TYPE);
            binaryFile.Status   = EvSqlMethods.getString <EvBinaryFileMetaData.FileStatus> (
                Row, EvBinaryFiles.DB_FILE_STATUS);
            binaryFile.UploadDate = EvSqlMethods.getDateTime(Row, EvBinaryFiles.DB_UPLOAD_DATE);

            binaryFile.ReleaseDate    = EvSqlMethods.getDateTime(Row, EvBinaryFiles.DB_RELEASE_DATE);
            binaryFile.SupersededDate = EvSqlMethods.getDateTime(Row, EvBinaryFiles.DB_SUPERSEDED_DATE);
            binaryFile.FileExists     = EvSqlMethods.getBool(Row, EvBinaryFiles.DB_FILE_EXISTS);
            binaryFile.FileEncrypted  = EvSqlMethods.getBool(Row, EvBinaryFiles.DB_FILE_ENCRYPTED);
            binaryFile.Version        = EvSqlMethods.getInteger(Row, EvBinaryFiles.DB_VERSION);

            binaryFile.UpdatedByUserId = EvSqlMethods.getString(Row, EvBinaryFiles.DB_UPDATED_BY_USER_ID);
            binaryFile.UpdatedBy       = EvSqlMethods.getString(Row, EvBinaryFiles.DB_UPDATED_BY);
            binaryFile.UpdatedByDate   = EvSqlMethods.getDateTime(Row, EvBinaryFiles.DB_UPDATED_DATE);

            //
            // Return the object.
            //
            return(binaryFile);
        }//End readDataRow method.
Пример #7
0
        }//END getView method.

        // ==================================================================================
        /// <summary>
        /// This class gets an list of last upload of versioned binary file objects.
        /// </summary>
        /// <param name="ProjectId">String: Project identifier (Mandatory)</param>
        /// <param name="GroupId">Stirng: FilingIndex Identifier (Mandatory)</param>
        /// <param name="SubGroupId">String: A sub group identifier</param>
        /// <param name="FileId">String: A file identifier</param>
        /// <returns>List of EvBinaryFileMetaData: a list contains binary file data objects.</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define the sql query parameters and the sql query string
        ///
        /// 2. Execute the sql query string with parameters and store the values on datatable.
        ///
        /// 3. Iterate through the table and extract the row data to a binary file object.
        ///
        /// 4. Find the last instance of the file (with the highest version).
        ///
        /// 5. Add the object values to the return binary file meta data list.
        ///
        /// 6. Return the list of binary file meta data
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public List <EvBinaryFileMetaData> GetVersionedFileList(
            String GroupId,
            String SubGroupId,
            String FileId)
        {
            this.LogMethod("GetVersionedFileList method. ");

            //
            // Initialize a method debug status, a internal sql query string and a return list of binary file data objects.
            //
            StringBuilder sqlQueryString         = new StringBuilder( );
            List <EvBinaryFileMetaData> fileList = new List <EvBinaryFileMetaData> ( );

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(EvBinaryFiles.PARM_GROUP_ID, SqlDbType.VarChar, 50),
                new SqlParameter(EvBinaryFiles.PARM_SUB_GROUP_ID, SqlDbType.VarChar, 50),
                new SqlParameter(EvBinaryFiles.PARM_FILE_ID, SqlDbType.VarChar, 100),
            };
            cmdParms [0].Value = GroupId;
            cmdParms [1].Value = SubGroupId;
            cmdParms [2].Value = FileId;

            //
            // Generate the SQL query string
            //
            sqlQueryString.AppendLine(SQL_VIEW_QUERY);
            sqlQueryString.AppendLine("WHERE (" + EvBinaryFiles.DB_FILE_ID + " = " + EvBinaryFiles.PARM_FILE_ID + ") ");
            sqlQueryString.AppendLine(" AND (" + EvBinaryFiles.DB_FILE_EXISTS + " = 1 ) ");

            if (GroupId == String.Empty)
            {
                sqlQueryString.AppendLine(" AND (" + EvBinaryFiles.DB_GROUP_ID + " = '' ) ");
            }
            else
            {
                sqlQueryString.AppendLine(" AND (" + EvBinaryFiles.DB_GROUP_ID + " = " + EvBinaryFiles.PARM_GROUP_ID + ") ");
            }

            if (SubGroupId == String.Empty)
            {
                sqlQueryString.AppendLine(" AND (" + EvBinaryFiles.DB_SUB_GROUP_ID + " = '' ) ");
            }
            else
            {
                sqlQueryString.AppendLine(" AND (" + EvBinaryFiles.DB_SUB_GROUP_ID + " = " + EvBinaryFiles.PARM_SUB_GROUP_ID + ") ");
            }

            sqlQueryString.AppendLine("ORDER BY "
                                      + EvBinaryFiles.DB_VERSION + ", "
                                      + EvBinaryFiles.DB_UPDATED_DATE + " ; ");

            this.LogDebug(sqlQueryString.ToString( ));

            //
            // Execute the query against the database
            //
            using (DataTable table = EvSqlMethods.RunQuery(sqlQueryString.ToString( ), cmdParms))
            {
                this.LogDebug("Rows.Count: " + table.Rows.Count);
                //
                // 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];

                    EvBinaryFileMetaData binaryFile = this.readDataRow(row);

                    fileList.Add(binaryFile);
                } //END interation loop.
            }     //END using method

            this.LogValue("fileList.Count: " + fileList.Count);
            //
            // Return the list containing the User data object.
            //
            this.LogMethodEnd("GetVersionedFileList");
            return(fileList);
        }//END getVersionedView method.
Пример #8
0
        }//End getItem method.

        // =====================================================================================
        /// <summary>
        /// This class saves items to the Binary file ResultData table.
        /// </summary>
        /// <param name="BinaryFile">EvBinaryFileMetaData: A Binary file ResultData object</param>
        /// <param name="Action">EvBinaryFileMetaData.ActionsCodes enumerated value</param>
        /// <returns>EvEventCodes: An event code for saving items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the Binary file object has no value.
        ///
        /// 2. Add items to the Binary file table.
        ///
        /// 3. Return the event code for adding items.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes SaveItem(
            EvBinaryFileMetaData BinaryFile,
            EvBinaryFileMetaData.ActionsCodes Action)
        {
            this.LogMethod("saveItem method. ");
            this.LogDebug("ProjectGuid: " + BinaryFile.TrialGuid);
            this.LogDebug("ProjectId: " + BinaryFile.TrialId);
            this.LogDebug("GroupGuid: " + BinaryFile.GroupGuid);
            this.LogDebug("GroupId: " + BinaryFile.GroupId);
            this.LogDebug("SubGroupGuid: " + BinaryFile.SubGroupGuid);
            this.LogDebug("SubGroupId: " + BinaryFile.SubGroupId);
            this.LogDebug("FileGuid: " + BinaryFile.FileGuid);
            this.LogDebug("FileId: " + BinaryFile.FileId);
            this.LogDebug("FileName: " + BinaryFile.FileName);
            this.LogDebug("MimeType: " + BinaryFile.MimeType);
            this.LogDebug("FileEncrypted: " + BinaryFile.FileEncrypted);

            //
            // Instantiate the local variables
            //
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Exit, if the Binary file ResultData object has no value.
            //
            if (BinaryFile.TrialGuid == Guid.Empty)
            {
                this.LogDebug("ERROR: TrialGuid Empty");

                return(EvEventCodes.Identifier_Project_Id_Error);
            }
            if (BinaryFile.TrialId == String.Empty)
            {
                this.LogDebug("ERROR: ProjectId Empty");

                return(EvEventCodes.Identifier_Project_Id_Error);
            }
            if (BinaryFile.FileName == String.Empty)
            {
                this.LogDebug("ERROR: FileName Empty");

                return(EvEventCodes.Data_Null_Data_Error);
            }

            //
            // If the binary file is empty update by adding a new record.
            //
            switch (Action)
            {
            case EvBinaryFileMetaData.ActionsCodes.Update:
            {
                this.LogDebug("Update BinaryFile");
                //
                // Execute the method for adding items
                //
                iReturn = this._DalBinaryFiles.updateItem(BinaryFile);
                this.LogClass(this._DalBinaryFiles.Log);

                return(iReturn);
            }

            case EvBinaryFileMetaData.ActionsCodes.Release:
            {
                this.LogDebug("Release BinaryFile");
                //
                // Update the status to released.
                //
                if (BinaryFile.Status == EvBinaryFileMetaData.FileStatus.Uploaded)
                {
                    BinaryFile.Status      = EvBinaryFileMetaData.FileStatus.Released;
                    BinaryFile.ReleaseDate = DateTime.Now;
                }

                //
                // Execute the method for adding items
                //
                iReturn = this._DalBinaryFiles.updateItem(BinaryFile);
                this.LogClass(this._DalBinaryFiles.Log);

                return(iReturn);
            }

            case EvBinaryFileMetaData.ActionsCodes.Add:
            default:
            {
                this.LogDebug("Add BinaryFile");
                BinaryFile.Status     = EvBinaryFileMetaData.FileStatus.Uploaded;
                BinaryFile.UploadDate = DateTime.Now;

                if (BinaryFile.FileGuid == Guid.Empty)
                {
                    BinaryFile.FileGuid = BinaryFile.Guid;
                }
                if (BinaryFile.FileId == String.Empty)
                {
                    BinaryFile.FileId = BinaryFile.FileName;
                }
                if (BinaryFile.Title == String.Empty)
                {
                    string title = BinaryFile.FileName;
                    int    index = title.LastIndexOf('.');
                    if (index >= 0)
                    {
                        title = title.Substring(0, index);
                    }
                    title            = title.Replace("-", " ");
                    BinaryFile.Title = title.Replace("  ", " ");
                }

                if (BinaryFile.Version == 0)
                {
                    BinaryFile.Version = 1;
                }
                else
                {
                    BinaryFile.Version++;
                }
                this.LogDebug(" BinaryFile.Version: " + BinaryFile.Version);
                this.LogDebug(" BinaryFile.FileEncrypted: " + BinaryFile.FileEncrypted);
                this.LogDebug(" BinaryFile.FileExists: " + BinaryFile.FileExists);
                this.LogDebug(" BinaryFile.Comments: " + BinaryFile.Comments);
                this.LogDebug(" BinaryFile.Language: " + BinaryFile.Language);


                //
                // Execute the method for adding items
                //
                iReturn = this._DalBinaryFiles.addItem(BinaryFile);
                this.LogClass(this._DalBinaryFiles.Log);

                return(iReturn);
            }
            }
        } // Close method updateIndex