|
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Project.Practice.DB.Configuration;
namespace Project.Practice.DB
{
[ConfigurationElementType(typeof(DBData))]
public class DBProvider : IDBProvider
{
protected string m_UserId = string.Empty;
protected string m_Password = string.Empty;
protected string m_Server = string.Empty;
protected string m_DirectoryPath = string.Empty;
private bool m_Disposed = false;
public DBProvider() { }
public DBProvider(string userId, string password, string server, string directoryPath)
{
m_UserId = userId;
m_Password = password;
m_Server = server;
m_DirectoryPath = directoryPath;
}
#region IFTPProvider Interface
bool IDBProvider.UploadFile(string filePath)
{
//Using configurable parameter one can connect to military zone server and can upload file
//credential to access Server to upload file
//m_UserID,m_password,m_Server get this values from DBprovider
//which in turns set from web.config custom configuration section.
return true;
}
#endregion
#region IDisposable Interface
/// <summary>
/// Dispose method releases all resources for this instance.
/// </summary>
/// <remarks>Calling GC.SupressFinalize to
/// take this object off the finalization queue
/// and prevent finalization code for this object
/// from executing a second time
/// </remarks>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Private method used to actually dispose of resources.
/// </summary>
/// <param name="disposing">bool</param>
/// <remarks> Dispose(bool disposing) executes in two distinct scenarios.
/// If disposing equals true, the method has been called directly
/// or indirectly by a user's code. Managed and unmanaged resources
/// can be disposed.
/// If disposing equals false, the method has been called by the
/// runtime from inside the finalizer and you should not reference
/// other objects. Only unmanaged resources can be disposed.
///</remarks>
protected virtual void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if (!this.m_Disposed)
{
// If disposing equals true, dispose all managed resources.
if (disposing)
{
// Dispose managed resources.
}
//
// Call the appropriate methods to clean up unmanaged resources here.
// If disposed is false, only the following code is executed.
//
if (Environment.HasShutdownStarted == false)
Trace.WriteLine("FTPProvider finalizer called.");
}
m_Disposed = true;
}
/// <summary>
/// Finalizer for <see cref="FTPProvider"/>
/// </summary>
/// <remarks>This destructor will run only if the Dispose method does not get called.</remarks>
~DBProvider()
{
Dispose(false);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.