예제 #1
0
        /// <summary>
        /// Save the file's content
        /// </summary>
        /// <returns></returns>
        public Globals.ResultType Save()
        {
            try
            {
                // Validation
                if (this.File == null || this.File.Exists == false || this.File.Permissions.CanRead == false)
                {
                    return(Globals.ResultType.Failure);
                }

                // Save File Content
                Globals.ResultType saveResult = this.File.Write(this.Value);

                // Validation
                if (saveResult == Globals.ResultType.Failure)
                {
                    return(Globals.ResultType.Failure);
                }

                return(Globals.ResultType.Success);
            }
            catch (Exception ex)
            {
                // To Be Implemented: Throw Custom Exception...
                Console.WriteLine(ex.ToString());
                return(Globals.ResultType.Failure);
            }
        }
예제 #2
0
        /// <summary>
        /// Returns an IDataReader
        /// </summary>
        /// <param name="strQuery">Query to be executed</param>
        /// <param name="strError">Error string containing any Error message encountered</param>
        /// <returns></returns>
        public IDataReader GetDataReader(string strQuery, ref string strError)
        {
            // Attempt To Connect
            Globals.ResultType connectResultType = this.TryConnect(ref strError);

            // Validation
            if (connectResultType == Globals.ResultType.Failure || strError != "")
            {
                return(null);
            }

            // Get Current Database Connection
            IDbConnection connection = this.GetConnection();

            // Open Database Connection
            connection.Open();

            // Create DataBase Command
            IDbCommand command = connection.CreateCommand();

            // Set Command Text
            command.CommandText = strQuery;

            // Execute Reader
            IDataReader reader = command.ExecuteReader();

            return(reader);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strSvnBranchDirectoryUrl"></param>
        /// <param name="strSvnTagDirectoryUrl"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        internal Globals.ResultType CopyDirectory(string strSvnBranchDirectoryUrl, string strSvnTagDirectoryUrl, ref string strError)
        {
            try
            {
                // Validation
                if (strSvnTagDirectoryUrl == "")
                {
                    return(Globals.ResultType.Failure);
                }

                // Create Tag
                bool boolTagCreated = this.Connection.Copy(strSvnBranchDirectoryUrl, strSvnTagDirectoryUrl);

                // Validation
                if (boolTagCreated == false || strError != "")
                {
                    return(Globals.ResultType.Failure);
                }

                Globals.ResultType copyResultType = (boolTagCreated == true) ? Globals.ResultType.Success : Globals.ResultType.Failure;

                return(copyResultType);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();
                Console.WriteLine(strError);

                return(Globals.ResultType.Failure);
            }
        }
예제 #4
0
        /// <summary>
        /// Create a new directory
        /// </summary>
        /// <param name="fileSystemRights">Type of file system rights to be set on the new directory</param>
        /// <param name="boolAllowEveryone">Flag to include Everyone permissions on the new directory</param>
        /// <returns></returns>
        public Globals.ResultType Create(System.Security.AccessControl.FileSystemRights fileSystemRights, bool boolAllowEveryone = false)
        {
            try
            {
                // Create Directory
                System.IO.DirectoryInfo directoryInfo = System.IO.Directory.CreateDirectory(this.FilePath);

                // Validation
                if (directoryInfo == null || directoryInfo.Exists == false)
                {
                    return(Globals.ResultType.Failure);
                }

                // Set Directory Permissions
                Globals.ResultType createResultType = this.SetPermissions(fileSystemRights, System.Security.AccessControl.AccessControlType.Allow);

                // Validation
                if (createResultType == Globals.ResultType.Failure)
                {
                    return(Globals.ResultType.Failure);
                }

                return(Globals.ResultType.Success);
            }
            catch (Exception ex)
            {
                // To Be Implemented: Throw Custom Exception...
                Console.WriteLine(ex.ToString());
                return(Globals.ResultType.Failure);
            }
        }
예제 #5
0
        public static Globals.ResultType SetDefaultNullDataTableValuesOfType <T>(DataTable dt, object objDefaultValue, ref string strError)
        {
            // Validation - Ensure DataTable Is Not Null And Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataTableIsMutable(dt, ref strError);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(Globals.ResultType.Failure);
            }

            try
            {
                // Loop Table Rows
                foreach (DataRow dr in dt.Rows)
                {
                    // Attempt Set Default Values
                    Globals.ResultType resultType = SetDefaultNullDataRowValuesOfType <T>(dr, objDefaultValue, ref strError);

                    // Validation
                    if (resultType == Globals.ResultType.Failure || strError != "")
                    {
                        return(Globals.ResultType.Failure);
                    }
                }
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(Globals.ResultType.Failure);
            }

            return(Globals.ResultType.Success);
        }
예제 #6
0
        /// <summary>
        /// Archive a list of files
        /// </summary>
        /// <param name="fileObjectList">Files to archive</param>
        /// <param name="directoryObject">Directory to create archive file in</param>
        /// <param name="strArchiveName">Directory to create archive file in</param>
        /// <param name="compressionLevel">File compression level</param>
        /// <param name="fileMode">File mode. Default is to create a new archive file or add to an existing archive</param>
        /// <returns></returns>
        public static Globals.ResultType Archive(this List <FileObject> fileObjectList, DirectoryObject directoryObject, string strArchiveName,
                                                 CompressionLevel compressionLevel, FileMode fileMode = FileMode.OpenOrCreate)
        {
            try
            {
                // Loop Files
                foreach (FileObject fileObject in fileObjectList)
                {
                    // Archive File
                    Globals.ResultType archiveFileResultType = fileObject.Archive(compressionLevel, fileMode);

                    // Validation
                    if (archiveFileResultType == Globals.ResultType.Failure)
                    {
                        return(Globals.ResultType.Failure);
                    }
                }

                return(Globals.ResultType.Success);
            }
            catch (Exception ex)
            {
                // To Be Implemented: Throw Custom Exception...
                Console.WriteLine(ex.ToString());
                return(Globals.ResultType.Failure);
            }
        }
예제 #7
0
        public static Globals.ResultType SetDefaultNullDataRowColumnValues(DataRow dr, string strColumnName, object objDefaultValue, ref string strError)
        {
            // Validation - Ensure DataRow Content Exists Or Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataRowIsMutable(dr, ref strError);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(Globals.ResultType.Failure);
            }

            // Validation - Check DataRow Has Column
            bool boolTableHasColumn = CheckDataTableHasColumn(dr.Table, strColumnName, ref strError);

            if (boolTableHasColumn == false)
            {
                return(Globals.ResultType.Failure);
            }

            try
            {
                // Reset Null Value With Specified Default Value
                dr.ItemArray[dr.Table.Columns.IndexOf(strColumnName)] = objDefaultValue;
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(Globals.ResultType.Failure);
            }

            return(Globals.ResultType.Success);
        }
예제 #8
0
        /// <summary>
        /// Copy a file to a different directory
        /// </summary>
        /// <param name="fileObjectList">File list to be copied</param>
        /// <param name="directoryObject">Directory to be copied to</param>
        /// <param name="boolOverWrite">Whether or not to overwrite any existing file of the same name</param>
        /// <param name="boolDeleteOriginal">Optional: Delete the original file being copied</param>
        /// <param name="boolReLoadFilesFromDestinationDirectory">Optional: Flag to reload file objects information from the destination directory</param>
        /// <returns></returns>
        public static Globals.ResultType Copy(this List <FileObject> fileObjectList, DirectoryObject directoryObject, bool boolOverWrite, bool boolDeleteOriginal = false, bool boolReLoadFilesFromDestinationDirectory = false)
        {
            try
            {
                Globals.ResultType copyResult = Globals.ResultType.Success;

                // Loop Files
                foreach (FileObject fileObject in fileObjectList)
                {
                    // Copy File
                    Globals.ResultType copyFileResult = fileObject.Copy(directoryObject, fileObject.FullName, boolOverWrite, boolDeleteOriginal);

                    // Validation
                    if (boolReLoadFilesFromDestinationDirectory == true)
                    {
                        // Refresh File Object
                        fileObject.Refresh();
                    }

                    // Validation
                    copyResult = (copyFileResult == Globals.ResultType.Failure) ? Globals.ResultType.Failure : Globals.ResultType.Success;
                }

                return(copyResult);
            }
            catch (Exception ex)
            {
                // To Be Implemented: Throw Custom Exception...
                Console.WriteLine(ex.ToString());
                return(Globals.ResultType.Failure);
            }
        }
예제 #9
0
        public int ExecuteNonQuery(OdbcCommand cmd, ref string strError)
        {
            try
            {
                // Ensure Connected
                Globals.ResultType connectedResult = this.TryConnect(ref strError);

                // Validation
                if (connectedResult == Globals.ResultType.Failure || strError != "")
                {
                    return(-1);
                }

                // Execute Non Query
                int intRowsAffected = cmd.ExecuteNonQuery();

                // Return Number Of Rows Affected
                return(intRowsAffected);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(-1);
            }
        }
예제 #10
0
        public static Globals.ResultType SetDefaultNullDataRowValuesOfType <T>(DataRow dr, object objDefaultValue, ref string strError)
        {
            // Validation - Ensure DataRow Content Exists Or Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataRowIsMutable(dr, ref strError);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(Globals.ResultType.Failure);
            }

            try
            {
                // Reset Null Values Of Type <T> With Specified Default Value
                dr.ItemArray = dr.ItemArray.Select((obj, intIndex) => (obj == null || obj == DBNull.Value &&
                                                                       dr.ItemArray[intIndex].GetType().IsAssignableFrom(typeof(T)) == true)
                    ? objDefaultValue
                    : obj)
                               .ToArray();
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(Globals.ResultType.Failure);
            }

            return(Globals.ResultType.Success);
        }
예제 #11
0
        /// <summary>
        /// Create a OdbcDataReader from a Odbc command
        /// </summary>
        /// <param name="cmd">Odbc command to be executed</param>
        /// <param name="strError">Error string containing any Error message encountered</param>
        /// <param name="behavior">Provides a description of the results of the query and its effect on the database</param>
        /// <returns></returns>
        public OdbcDataReader ExecuteReader(OdbcCommand cmd, ref string strError, CommandBehavior behavior = CommandBehavior.Default)
        {
            try
            {
                // Ensure Connected
                Globals.ResultType connectedResult = this.TryConnect(ref strError);

                // Validation
                if (connectedResult == Globals.ResultType.Failure || strError != "")
                {
                    return(null);
                }

                // Create Data Reader
                OdbcDataReader reader = cmd.ExecuteReader(behavior);

                // Return Number Of Rows Affected
                return(reader);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(null);
            }
        }
예제 #12
0
        public static int GetDataTableNullValueCount(DataTable dt, ref string strError)
        {
            // Validation - Ensure DataTable Content Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataTableIsMutable(dt, ref strError, false);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(-1);
            }

            int intTotalCount = 0;

            // Loop All Rows
            foreach (DataRow dr in dt.Rows)
            {
                // Get Row Null Value Count
                int intRowNullCount = GetDataRowNullValueCount(dr, ref strError);

                // Validation
                if (intRowNullCount == -1 || strError != "")
                {
                    return(-1);
                }

                intTotalCount += intRowNullCount;
            }

            return(intTotalCount);
        }
예제 #13
0
        /// <summary>
        /// Create a new file
        /// </summary>
        /// <param name="strFileContent"></param>
        /// <returns></returns>
        public Globals.ResultType Create(string strFileContent)
        {
            Globals.ResultType createResult = this.Write(strFileContent);

            // Refresh File Object
            this.Refresh();

            return(createResult);
        }
예제 #14
0
        /// <summary>
        /// Rollback a transaction
        /// </summary>
        /// <param name="strError">Error string containing any Error message encountered</param>
        /// <param name="strTransactionName">Transaction Name</param>
        /// <returns></returns>
        public virtual Globals.ResultType RollbackTransaction(ref string strError, string strTransactionName = "")
        {
            strTransactionName = (strTransactionName.Trim() == "") ? "GENERIC_TRANSACTION" : strTransactionName;
            String strQuery = "ROLLBACK TRANSACTION " + strTransactionName;

            // Execute Transaction
            Globals.ResultType resultType = this.ExecuteTransaction(strQuery, ref strError);

            return(resultType);
        }
예제 #15
0
        /// <summary>
        /// Deletes files from a directory
        /// </summary>
        /// <param name="boolRecurse">Flag that determines whether files are retrieved recursively including files from sub-directories</param>
        /// <returns></returns>
        public Globals.ResultType DeleteFiles(bool boolRecurse)
        {
            // Get Files
            FileObjectList listFiles = this.GetFiles(boolRecurse);

            // Delete Files
            Globals.ResultType deleteResult = listFiles.Delete();

            return(deleteResult);
        }
예제 #16
0
        private void Test()
        {
            DirectoryObject directory = new DirectoryObject("C:\\")
                                        .SubDirectory("Users")
                                        .SubDirectory("Jon")
                                        .SubDirectory("Desktop");

            //Console.WriteLine("Search Parameters - Pattern: " + searchInfo.SearchPattern + " | " +  searchInfo.MinimumDate.ToShortDateString() + " | " + "Max Size: " + searchInfo.MaximumSize);

            FileObject file = directory.File("TestRights.txt");

            Globals.ResultType archiveResult = file.Archive(System.IO.Compression.CompressionLevel.NoCompression);
        }
예제 #17
0
        public static DataColumn[] GetDataTablePrimaryKeys(DataTable dt, ref string strError)
        {
            // Validation - Ensure DataTable Content Exists Or Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataTableIsMutable(dt, ref strError, false);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(null);
            }

            DataColumn[] listPrimaryKeys = dt.PrimaryKey;

            return(listPrimaryKeys);
        }
예제 #18
0
        public static int GetDataRowNullValueCount(DataRow dr, ref string strError)
        {
            // Validation - Ensure DataRow Content Exists Or Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataRowIsMutable(dr, ref strError);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(-1);
            }

            // Get Row Null Value Count
            int intRowNullCount = dr.ItemArray.Where(obj => obj == null || obj == DBNull.Value).Count();

            return(intRowNullCount);
        }
예제 #19
0
        /// <summary>
        /// Copies a file directory recursively to a destination directory
        /// </summary>
        /// <param name="destinationDirectoryObject">Destination path for directory to be copied to</param>
        /// <param name="directoryToCopy">Directory to be copied</param>
        /// <returns></returns>
        private Globals.ResultType Copy(DirectoryObject destinationDirectoryObject, DirectoryObject directoryToCopy)
        {
            try
            {
                // Get New Path
                string strNewDirectory = Path.Combine(destinationDirectoryObject.FilePath, directoryToCopy.Name);

                // Get Directory
                DirectoryObject directory = new DirectoryObject(strNewDirectory);

                // Validation
                if (directory.Exists == false)
                {
                    // Create Directory
                    Globals.ResultType createResult = directory.Create(System.Security.AccessControl.FileSystemRights.Write);

                    // Validation
                    if (createResult == Globals.ResultType.Failure)
                    {
                        return(Globals.ResultType.Failure);
                    }
                }

                // Copy All Files To New Directory
                this.Files.ForEach(file => file.Copy(directory, true));

                // Loop SubDirectories
                foreach (DirectoryObject childDirectory in directoryToCopy.SubDirectories)
                {
                    // Copy Directory
                    Globals.ResultType copyResult = directoryToCopy.Copy(directory, childDirectory);

                    // Validation
                    if (copyResult == Globals.ResultType.Failure)
                    {
                        return(Globals.ResultType.Failure);
                    }
                }

                return(Globals.ResultType.Success);
            }
            catch (Exception ex)
            {
                // To Be Implemented: Throw Custom Exception...
                Console.WriteLine(ex.ToString());
                return(Globals.ResultType.Failure);
            }
        }
예제 #20
0
        public static bool CheckDataRowHasNullValues(DataRow dr, ref string strError)
        {
            // Validation - Ensure DataRow Content Exists Or Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataRowIsMutable(dr, ref strError);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(false);
            }

            // Get Null DataRow Value Count
            int intNullValueCount = GetDataRowNullValueCount(dr, ref strError);

            bool boolDataRowHasNullValue = intNullValueCount > 0;

            return(boolDataRowHasNullValue);
        }
예제 #21
0
        public static Globals.ResultType SetDefaultNullDataTableColumnValues(DataTable dt, string strColumnName, object objDefaultValue, ref string strError)
        {
            // Validation - Ensure DataTable Is Not Null And Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataTableIsMutable(dt, ref strError);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(Globals.ResultType.Failure);
            }

            // Validation - No Rows - Nothing To Do == Success
            if (dt.Rows.Count == 0)
            {
                return(Globals.ResultType.Success);
            }

            // Validation - Check DataTable Has Column
            bool boolTableHasColumn = CheckDataTableHasColumn(dt, strColumnName, ref strError);

            if (boolTableHasColumn == false)
            {
                return(Globals.ResultType.Failure);
            }

            try
            {
                // Loop Table Rows
                foreach (DataRow dr in dt.Rows)
                {
                    // Attempt Set Default Values
                    Globals.ResultType resultType = SetDefaultNullDataRowColumnValues(dr, strColumnName, objDefaultValue, ref strError);

                    // Validation
                    if (resultType == Globals.ResultType.Failure || strError != "")
                    {
                        return(Globals.ResultType.Failure);
                    }
                }
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(Globals.ResultType.Failure);
            }

            return(Globals.ResultType.Success);
        }
예제 #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strSvnBranchDirectoryUrl"></param>
        /// <param name="strSvnTagDirectoryUrl"></param>
        /// <param name="strNewTagFolderName"></param>
        /// <param name="strWorkingDirectory"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public Globals.ResultType CreateTag(string strSvnBranchDirectoryUrl, string strSvnTagDirectoryUrl, string strNewTagFolderName, string strWorkingDirectory, ref string strError)
        {
            try
            {
                // Validation
                if (strSvnTagDirectoryUrl == "" || strNewTagFolderName == "" || strWorkingDirectory == "")
                {
                    return(Globals.ResultType.Failure);
                }

                // Commit Branch
                Globals.ResultType commitDirectoryResultType = this.CommitDirectory(strWorkingDirectory, ref strError);

                // Validation
                if (commitDirectoryResultType == Globals.ResultType.Failure || strError != "")
                {
                    return(Globals.ResultType.Failure);
                }

                // Create New Tag Directory
                Globals.ResultType createDirectoryResultType = this.CreateDirectory(strSvnTagDirectoryUrl, strNewTagFolderName, ref strError);

                // Validation
                if (createDirectoryResultType == Globals.ResultType.Failure || strError != "")
                {
                    return(Globals.ResultType.Failure);
                }

                // Copy Branch to New Tag Folder
                Globals.ResultType copyDirectoryResultType = this.CopyDirectory(strSvnBranchDirectoryUrl, strSvnTagDirectoryUrl, ref strError);

                // Validation
                if (createDirectoryResultType == Globals.ResultType.Failure || strError != "")
                {
                    return(Globals.ResultType.Failure);
                }

                return(Globals.ResultType.Success);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();
                Console.WriteLine(strError);

                return(Globals.ResultType.Failure);
            }
        }
예제 #23
0
        /// <summary>
        /// Execute a query and return a single scalar value of a specified type
        /// </summary>
        /// <typeparam name="T">Type of object to be returned</typeparam>
        /// <param name="strQuery">Query to be executed</param>
        /// <param name="strError">Error string containing any Error message encountered</param>
        /// <returns></returns>
        public override T ExecuteScalar <T>(string strQuery, ref string strError)
        {
            try
            {
                // Validation
                if (strQuery == "")
                {
                    return(default(T));
                }

                // Ensure Connected
                Globals.ResultType connectedResult = this.TryConnect(ref strError);

                // Validation
                if (connectedResult == Globals.ResultType.Failure || strError != "")
                {
                    return(default(T));
                }

                // Create SqlCommand
                OdbcCommand cmd = new OdbcCommand(strQuery, this.m_Connection);

                // Execute Scalar
                object obj = cmd.ExecuteScalar();

                // Create Object To Return
                T objReturn = (T)Activator.CreateInstance <T>();

                // Validation
                if (objReturn.GetType().IsAssignableFrom(obj.GetType()) == false)
                {
                    return(default(T));
                }

                // Set Return Object Value
                objReturn = (T)obj;

                return(objReturn);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(default(T));
            }
        }
예제 #24
0
        /// <summary>
        /// Move a file to a different directory
        /// </summary>
        /// <param name="fileObjectList">File list to be moved</param>
        /// <param name="directoryObject">Directory to be copied to</param>
        /// <returns></returns>
        public static Globals.ResultType Move(this List <FileObject> fileObjectList, DirectoryObject directoryObject)
        {
            Globals.ResultType moveResult = Globals.ResultType.Success;

            // Loop Files
            foreach (FileObject fileObject in fileObjectList)
            {
                // Copy File
                Globals.ResultType moveFileResult = fileObject.Move(directoryObject, fileObject.FullName);

                // Refresh File Object
                fileObject.Refresh();

                // Validation
                moveResult = (moveFileResult == Globals.ResultType.Failure) ? Globals.ResultType.Failure : Globals.ResultType.Success;
            }

            return(moveResult);
        }
예제 #25
0
        /// <summary>
        /// Attempt to connect to the database server if not already connected. Returns success if already connected. Method is useful for cases not knowing if already connected to the database server and reducing validation
        /// </summary>
        /// <param name="strError">Error string containing any Error message encountered</param>
        /// <returns></returns>
        public override Globals.ResultType TryConnect(ref string strError)
        {
            // Check Is Connected
            if (this.IsConnected == false || (this.m_Connection != null && this.m_Connection.State == ConnectionState.Closed))
            {
                // Connect to Server
                Globals.ResultType connectResult = this.Connect(ref strError);

                // Validation
                if (connectResult == Globals.ResultType.Failure || strError != "")
                {
                    strError += "Error: The connection to server '" + this.m_SybaseInfo.DatabaseServer + "' failed.";

                    return(Globals.ResultType.Failure);;
                }
            }

            return(Globals.ResultType.Success);
        }
예제 #26
0
        /// <summary>
        /// Query to be executed
        /// </summary>
        /// <param name="strQuery"></param>
        /// <param name="strError">Error string containing any Error message encountered</param>
        /// <param name="intDefaultTimeout">Optional: Number of seconds before timing out the Sql query</param>
        /// <returns></returns>
        public override DataTable GetDataTable(string strQuery, ref string strError, int intDefaultTimeout = 300)
        {
            try
            {
                // Validation
                if (strQuery == "")
                {
                    return(null);
                }

                // Ensure Connected
                Globals.ResultType connectedResult = this.TryConnect(ref strError);

                // Validation
                if (connectedResult == Globals.ResultType.Failure || strError != "")
                {
                    return(null);
                }

                // Create DataAdapter
                OdbcDataAdapter dataAdapter = new OdbcDataAdapter(strQuery, this.m_Connection);
                dataAdapter.SelectCommand.CommandTimeout = 300;
                DataSet ds = new DataSet();

                // Execute Select Query
                dataAdapter.Fill(ds);

                // Disconnect From Server
                this.m_Connection.Close();

                if (ds == null || ds.Tables.Count == 0)
                {
                    return(null);
                }

                return(ds.Tables[0]);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();
                return(null);
            }
        }
예제 #27
0
        /// <summary>
        /// Copies directory files to a destination directory
        /// </summary>
        /// <param name="destinationDirectoryObject">Destination for directory files to be copied to</param>
        /// <param name="boolOverWrite">Flag for whether or not to overwrite any existing file in the destination directory</param>
        /// <param name="strFind">Search pattern to use retrieving files</param>
        /// <param name="boolRecurse">Flag that determines whether files are retrieved recursively including files from sub-directories</param>
        /// <param name="boolDeleteOriginal">Flag that determines whether to delete the original files</param>
        /// <returns></returns>
        public Globals.ResultType CopyFiles(DirectoryObject destinationDirectoryObject, bool boolOverWrite, string strFind, bool boolRecurse, bool boolDeleteOriginal = false)
        {
            // Get Files
            FileObjectList listFiles = this.GetFiles(strFind, boolRecurse);

            Globals.ResultType copyResult = Globals.ResultType.Success;

            // Loop Files
            foreach (FileObject file in listFiles)
            {
                // Copy File
                Globals.ResultType copyFileResult = file.Copy(destinationDirectoryObject, boolOverWrite, boolDeleteOriginal);

                // Validation
                copyResult = (copyFileResult != Globals.ResultType.Success) ? Globals.ResultType.Failure : Globals.ResultType.Success;
            }

            return(copyResult);
        }
예제 #28
0
        public static int GetDataTableColumnNullValueCount(DataTable dt, string strColumnName, ref string strError)
        {
            // Validation - Ensure DataTable Content Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataTableIsMutable(dt, ref strError, false);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return(-1);
            }

            // Validation - Check DataRow Has Column
            bool boolTableHasColumn = CheckDataTableHasColumn(dt, strColumnName, ref strError);

            if (boolTableHasColumn == false)
            {
                return(-1);
            }

            int intTotalNullValueCount = 0;

            try
            {
                // Loop All Rows
                foreach (DataRow dr in dt.Rows)
                {
                    // Get Column Field Object
                    object obj = dr.ItemArray[dr.Table.Columns.IndexOf(strColumnName)];

                    // Validation
                    bool boolObjectIsNull = (obj == null || obj == DBNull.Value);

                    intTotalNullValueCount += (boolObjectIsNull == true) ? 1 : 0;
                }

                return(intTotalNullValueCount);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();

                return(-1);
            }
        }
예제 #29
0
        public static string GetDataRowAsString(DataRow dr, string strDelimiter, string strDefaultNullValue, ref string strError)
        {
            // Validation - Ensure DataRow Content Exists Or Is Mutable
            Globals.ResultType ensureMutableResult = CheckDataRowIsMutable(dr, ref strError);
            if (ensureMutableResult == Globals.ResultType.Failure || strError != "")
            {
                return("");
            }

            // Set Default Row Null Values
            Globals.ResultType resultType = SetDefaultNullDataRowValues(dr, strDefaultNullValue, ref strError);
            if (resultType == Globals.ResultType.Failure || strError != "")
            {
                return("");
            }

            // Get DataRow Content As Delimited String
            string strValue = String.Join(strDelimiter, dr.ItemArray.Select(obj => obj.ToString()).ToArray());

            return(strValue);
        }
예제 #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strSvnDirectoryUrl"></param>
        /// <param name="dtRevisionDate"></param>
        /// <param name="strOutputDirectory"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        internal Globals.ResultType CheckoutProject(string strSvnDirectoryUrl, DateTime dtRevisionDate, string strOutputDirectory, ref string strError)
        {
            try
            {
                // Create Target URL
                SvnUriTarget uri = new SvnUriTarget(strSvnDirectoryUrl, dtRevisionDate);

                // Check Out Target URL
                bool boolCheckedOut = this.Connection.CheckOut(uri, strOutputDirectory);

                // Validation
                Globals.ResultType checkOutResultType = (boolCheckedOut == true) ? Globals.ResultType.Success : Globals.ResultType.Failure;

                return(checkOutResultType);
            }
            catch (Exception ex)
            {
                strError = ex.ToString();
                Console.WriteLine(strError);

                return(Globals.ResultType.Failure);
            }
        }