Click here to Skip to main content
15,886,030 members
Articles / Desktop Programming / Windows Forms

BSEtunes

Rate me:
Please Sign up or sign in to vote.
4.67/5 (11 votes)
24 Apr 2010CPOL4 min read 64.6K   4.3K   58  
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
using System;
using System.IO;

using BSE.Configuration;

namespace BSE.Platten.Admin
{
	/// <summary>
	/// Zusammendfassende Beschreibung f�r CommonProperties.
	/// </summary>
	public class CEnvironment : BSE.Platten.BO.CEnvironment
	{
		
		#region FieldsPrivate
		
		private string m_strPassword;
		private string m_strUserName;
        private string m_strHost;
        private CConfiguration m_configuration;

		#endregion
		
		#region Properties
		
		public string UserName
		{
			set {this.m_strUserName = value;}
			get 
			{
				if (String.IsNullOrEmpty(this.m_strUserName) == true)
				{
					this.m_strUserName = System.Environment.UserName;
				}
				return this.m_strUserName;
			}
		}

		public string Password
		{
			set {this.m_strPassword = value;}
			get {return this.m_strPassword;}
		}

        public string Host
        {
            set { this.m_strHost = value; }
            get { return this.m_strHost; }
        }

		#endregion

		#region MethodsPublic

		public CEnvironment()
		{
		}

        public BSE.Configuration.CConfiguration GetConfiguration()
        {
            CConfiguration configuration = null;
            if (this.m_configuration == null)
            {
                throw new Exception("CConfiguration cannot be null");
            }
            else
            {
                configuration = this.m_configuration;
            }
            return configuration;
        }

        public CEnvironment(BSE.Configuration.CConfiguration configuration)
        {
            this.m_configuration = configuration;
        }

        public string GetDataBaseHost()
        {
            if (this.m_configuration == null)
            {
                throw new Exception("CConfiguration cannot be null");
            }
            return GetDataBaseHost(this.m_configuration);
        }

		public string GetDataBaseHost(BSE.Configuration.CConfiguration configuration)
		{
			string strMessage = "\r\nAchtung!\nTragen Sie bitte im Men�\nExtras -> Optionen\ndie Adresse des Datenbankservers ein.";
			string strDataBaseHost = string.Empty;
			try
			{
				BSE.Configuration.CVisualObject visualObject = new BSE.Configuration.CVisualObject();
				visualObject.Element = "databasehost";
				visualObject.Description = "Adresse des Datenbankservers";
				visualObject.VisualObjectType = BSE.Configuration.CVisualObjectType.OpenTextBox;
                visualObject.ErrorMessage = strMessage;

                strDataBaseHost = configuration.GetValue(BSE.Configuration.CConfiguration.VisualObjectsElementName,visualObject).ToString();
				
				return strDataBaseHost;
			}
			catch (BSE.Configuration.CConfigurationValueNotFoundException e)
			{
				throw e;
			}
			catch (Exception e)
			{
				throw e;
			}
		}

        public string GetConnectionString()
        {
            if (this.m_configuration == null)
            {
                throw new Exception("CConfiguration cannot be null");
            }
            return GetConnectionString(this.m_configuration);
        }

		public string GetConnectionString(BSE.Configuration.CConfiguration configuration)
		{
			string strConnectionString = string.Empty;
			if (String.IsNullOrEmpty(m_strPassword) == true)
			{
                //strConnectionString = string.Format("server={0};user id={1}; password={2}; Port={3}; database=platten; pooling=false;Allow Zero Datetime = True",
                strConnectionString = string.Format("server={0};user id={1}; password={2}; Port={3}; database=platten; pooling=false;",
                    GetDataBaseHost(configuration),
                    this.UserName,
                    "",
                    3307);
			}
			else
			{
                strConnectionString = string.Format("server={0};user id={1}; password={2}; Port={3}; database=platten; pooling=false",
                    this.Host,
                    this.UserName,
                    this.Password,
                    3307);
			}
			return strConnectionString;
		}
        public string GetAudioHomeDirectory()
        {
            if (this.m_configuration == null)
            {
                throw new Exception("CConfiguration cannot be null");
            }
            return GetAudioHomeDirectory(this.m_configuration);
        }
		public string GetAudioHomeDirectory(BSE.Configuration.CConfiguration configuration)
		{
			string strMessage = "\r\nAchtung!\nDas Programm weiss nicht, wo die mp3 Dateien liegen.\nTragen Sie Bitte im Men� Extras -> Optionen\n das Verzeichnis ein.";
			string strAudioHomeDirectory = string.Empty;
			try
			{
				BSE.Configuration.CVisualObject visualObject = new BSE.Configuration.CVisualObject();
				visualObject.Element = "dirmp3";
				visualObject.Description = "Audio Home- Verzeichnis";
				visualObject.VisualObjectType = BSE.Configuration.CVisualObjectType.OpenFolderBrowseDialog;
                visualObject.ErrorMessage = strMessage;
				
				strAudioHomeDirectory = configuration.GetValue(BSE.Configuration.CConfiguration.VisualObjectsElementName,visualObject).ToString();

				if (!strAudioHomeDirectory.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
				{
					strAudioHomeDirectory += System.IO.Path.DirectorySeparatorChar;
				}
				return strAudioHomeDirectory;
			}
			catch (BSE.Configuration.CConfigurationValueNotFoundException e)
			{
				throw e;
			}
			catch (Exception e)
			{
				throw e;
			}
		}
        public string GetPlayer()
        {
            if (this.m_configuration == null)
            {
                throw new Exception("CConfiguration cannot be null");
            }
            return GetPlayer(this.m_configuration);
        }
		public string GetPlayer(BSE.Configuration.CConfiguration configuration)
		{
			string strMessage = "\r\nAchtung!\nDas Programm weiss nicht, wo sich der Winamp Player befindet.\nSuchen Sie ihn Bitte im Men� Extras -> Optionen.";
			string strPlayer = string.Empty;
			try
			{
				BSE.Configuration.CVisualObject visualObject = new BSE.Configuration.CVisualObject();
				visualObject.Element = "player";
				visualObject.Description = "Winamp Player";
				visualObject.VisualObjectType = BSE.Configuration.CVisualObjectType.OpenFileDialog;
                visualObject.ErrorMessage = strMessage;

                strPlayer = configuration.GetValue(BSE.Configuration.CConfiguration.VisualObjectsElementName,visualObject).ToString();

				return strPlayer;
			}
			catch (BSE.Configuration.CConfigurationValueNotFoundException e)
			{
				throw e;
			}
			catch (Exception e)
			{
				throw e;
			}
		}

		#endregion

		#region MethodsPrivate

		#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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions