Click here to Skip to main content
12,754,391 members (35,159 online)
Click here to Skip to main content

Stats

41K views
4K downloads
57 bookmarked
Posted 15 Oct 2009

BSEtunes

, 24 Apr 2010 CPOL
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
BSE.Platten
BSE.Platten.vssscc
mssccprj.scc
vssver2.scc
BSE.CoverFlow.WPFLib
BSE.CoverFlow.WPFLib.csproj.user
BSE.CoverFlow.WPFLib.csproj.vspscc
mssccprj.scc
vssver2.scc
Images
close.png
exit.png
next.png
next_disabled.png
Note.jpg
pause.png
PlayButton.png
previous.png
previous_disabled.png
stop.png
vssver2.scc
Properties
vssver2.scc
Resources
vssver2.scc
BSE.Platten.Admin
BSE.Platten.Admin.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
Album16.gif
BSEadmin.ico
cdimport.png
cdrip.png
cd_hoeren.png
clearsearch.png
DataContainer_MoveFirsHS.png
DataContainer_MoveLastHS.png
DataContainer_MoveNextHS.png
DataContainer_MovePreviousHS.png
DataContainer_NewRecordHS.png
diskinfo.png
DRIVEDSC.png
DRIVENET.png
Edit_UndoHS.png
exportimage.png
findfile.png
FindHS.png
freedb.png
Genre16.png
Image.png
InsertPictureHS.png
Interpret16.png
OptionsHS.png
PieChart3DHS.png
PieChartHS.png
ProtectFormHS.png
RefreshDocViewHS.png
saveHS.png
search.png
song.png
system.png
tagger.png
tools_16.png
vssver2.scc
BSE.Platten.Admin.WinApp
BSE.Platten.Admin.WinApp.csproj.user
BSE.Platten.Admin.WinApp.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
BSEadmin.ico
vssver2.scc
BSE.Platten.Audio
bse.ico
BSE.Platten.Audio.csproj.vspscc
mssccprj.scc
vssver2.scc
Options
vssver2.scc
Player
vssver2.scc
Properties
vssver2.scc
Resources
FillDownHS.png
FillLeftHS.png
Folder256.png
FolderFind.png
FolderOpen256.png
GoLtrHS.png
MoveNext.png
MovePrevious.png
OptionsHS.png
PauseHS.png
PlayHS.png
Slider.gif
Start.png
StopHS.png
vssver2.scc
WinControls
vssver2.scc
WMFSDK
vssver2.scc
BSE.Platten.BO
BSE.Platten.BO.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.Common
BSE.Platten.Common.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
BSEsplash.png
DRIVEDSC.png
DRIVENET.png
Network.png
splash.png
vssver2.scc
BSE.Platten.Covers
BSE.Platten.Covers.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.FreeDb
BSE.Platten.FreeDb.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
OpenCD.png
vssver2.scc
BSE.Platten.Ripper
BSE.Platten.Ripper.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
OpenCD.png
OptionsHS.png
vssver2.scc
BSE.Platten.Statistik
BSE.Platten.Statistik.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.Tunes
BSE.Platten.Tunes.csproj.user
BSE.Platten.Tunes.csproj.vspscc
mssccprj.scc
vssver2.scc
Filters
vssver2.scc
Properties
vssver2.scc
Resources
About.png
Album16.gif
AudioCD.png
AudioFile.png
AutoList.png
broadcast.png
BSE.png
BSEAbout.png
BSEsplash.png
BSEtunes.ico
BSE_16.png
cd_hoeren.png
coverflow.png
DataContainer_MoveNextHS.png
delete.gif
diskinfo.png
Filter2HS.png
FindHS.png
Folder256.png
FolderOpen256.png
Genre16.gif
Interpret16.gif
keinBild.gif
NewPlaylist16.gif
OptionsHS.png
PauseHS.png
RefreshDocViewHS.png
Removabledrive.png
saveHS.png
search.png
shuffle.png
Shuffle_icon.png
song.png
splash1.png
StopHS.png
TaskHS.png
TrackInfo.gif
vssver2.scc
wiedergabe16.gif
BSEadminSetup
BSEadminSetup.vdproj
BSEadminSetup.vdproj.vspscc
mssccprj.scc
vssver2.scc
Debug
Release
BSEtunesSetup
BSEtunesSetup.vdproj
BSEtunesSetup.vdproj.vspscc
mssccprj.scc
vssver2.scc
Debug
Release
dll
BSE.CDDrives.DLL
BSE.Charts.DLL
BSE.Configuration.DLL
BSE.RemovableDrives.DLL
BSE.Shell.DLL
BSE.Windows.Forms.DLL
Lame
lame_enc.dll
vssver2.scc
lame-3.97
BSE.CoverFlow.WPFLib.csproj.user
close.png
exit.png
next.png
next_disabled.png
Note.jpg
pause.png
PlayButton.png
previous.png
previous_disabled.png
stop.png
vssver2.scc
vssver2.scc
vssver2.scc
BSE.Platten.Admin.csproj.user
vssver2.scc
Album16.gif
BSEadmin.ico
cdimport.png
cdrip.png
cd_hoeren.png
clearsearch.png
DataContainer_MoveFirsHS.png
DataContainer_MoveLastHS.png
DataContainer_MoveNextHS.png
DataContainer_MovePreviousHS.png
DataContainer_NewRecordHS.png
diskinfo.png
DRIVEDSC.png
DRIVENET.png
Edit_UndoHS.png
exportimage.png
findfile.png
FindHS.png
freedb.png
Genre16.png
Image.png
InsertPictureHS.png
Interpret16.png
OptionsHS.png
PieChart3DHS.png
PieChartHS.png
ProtectFormHS.png
RefreshDocViewHS.png
saveHS.png
search.png
song.png
system.png
tagger.png
tools_16.png
vssver2.scc
BSE.Platten.Admin.WinApp.csproj.user
vssver2.scc
BSEadmin.ico
vssver2.scc
bse.ico
BSE.Platten.Audio.csproj.user
vssver2.scc
vssver2.scc
vssver2.scc
FillDownHS.png
FillLeftHS.png
Folder256.png
FolderFind.png
FolderOpen256.png
GoLtrHS.png
MoveNext.png
MovePrevious.png
OptionsHS.png
PauseHS.png
PlayHS.png
Slider.gif
Start.png
StopHS.png
vssver2.scc
vssver2.scc
vssver2.scc
BSE.Platten.BO.csproj.user
vssver2.scc
BSE.Platten.Common.csproj.user
vssver2.scc
BSEsplash.png
DRIVEDSC.png
DRIVENET.png
Network.png
splash.png
vssver2.scc
BSE.Platten.Covers.csproj.user
vssver2.scc
BSE.Platten.FreeDb.csproj.user
vssver2.scc
OpenCD.png
vssver2.scc
AudioWriter
vssver2.scc
BSE.Platten.Ripper.csproj.user
Lame
vssver2.scc
vssver2.scc
OpenCD.png
OptionsHS.png
vssver2.scc
BSE.Platten.Statistik.csproj.user
vssver2.scc
BSE.Platten.Tunes.csproj.user
vssver2.scc
vssver2.scc
About.png
Album16.gif
AudioCD.png
AudioFile.png
AutoList.png
broadcast.png
BSE.png
BSEAbout.png
BSEsplash.png
BSEtunes.ico
BSE_16.png
cd_hoeren.png
coverflow.png
DataContainer_MoveNextHS.png
delete.gif
diskinfo.png
Filter2HS.png
FindHS.png
Folder256.png
FolderOpen256.png
Genre16.gif
Interpret16.gif
keinBild.gif
NewPlaylist16.gif
OptionsHS.png
PauseHS.png
RefreshDocViewHS.png
Removabledrive.png
saveHS.png
search.png
shuffle.png
Shuffle_icon.png
song.png
splash1.png
StopHS.png
TaskHS.png
TrackInfo.gif
vssver2.scc
wiedergabe16.gif
BSEadminSetup.vdproj
BSEtunesSetup.vdproj
BSE.CDDrives.DLL
BSE.Charts.DLL
BSE.Configuration.DLL
BSE.RemovableDrives.DLL
BSE.Shell.DLL
BSE.ThreadedShell.DLL
BSE.Windows.Forms.DLL
lame_enc.dll
MySQL.chm
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using BSE.Charts;

namespace BSE.Platten.Statistik
{
	/// <summary>
	/// Zusammenfassung f�r CCalculateStatistic.
	/// </summary>
	public class CCalculateStatistic
	{
        #region Delegates

        private delegate void DelegateGetSpielzeit(string[][] aSpielzeit);
        private delegate void DelegateGetStatistik(string[][] aStatistik);
        private delegate void DelegateGetChart(ChartItem[] chartItems);

        #endregion

        #region EventsPublic

        public event System.EventHandler CancelCalculating;
		public event System.EventHandler CompleteCalculating;

		#endregion

		#region FieldsPrivate
		
		private System.Windows.Forms.Cursor m_cursor;
		private System.Windows.Forms.ListView m_lstvSpielzeit;
		private System.Windows.Forms.ListView m_lstvStatistik;
		private Chart m_chart;
		private bool m_cancelCalculating;
		private System.Threading.Thread m_threadCalculateStatistic;
		private System.Timers.Timer m_timer = new System.Timers.Timer();
		private System.Data.DataSet m_dataSetStatisticInformations;

		#endregion

		#region MethodsPublic

		public CCalculateStatistic(
			System.Data.DataSet dataSetStatisticInformations,
			System.Windows.Forms.ListView lstvSpielzeit,
			System.Windows.Forms.ListView lstvStatistik,
			Chart chart,
			System.Windows.Forms.Cursor cursor
			)
		{
			this.m_dataSetStatisticInformations = dataSetStatisticInformations;
            if (this.m_dataSetStatisticInformations != null)
            {
                this.m_lstvSpielzeit = lstvSpielzeit;
                this.m_lstvStatistik = lstvStatistik;
                this.m_chart = chart;
                this.m_cursor = cursor;

                this.m_threadCalculateStatistic =
                    new System.Threading.Thread(
                    new System.Threading.ThreadStart(this.CalculateStatistik));

                this.m_threadCalculateStatistic.Start();

                this.m_timer.Elapsed += new System.Timers.ElapsedEventHandler(this.Timer_Elapsed);
                this.m_timer.Enabled = true;
                this.m_timer.Start();
            }
		}

		public System.Threading.Thread Thread()
		{
			return this.m_threadCalculateStatistic;
		}

		public void CancelCalculate()
		{
            if (this.m_cancelCalculating == false)
            {
                this.m_cancelCalculating = true;
                if (this.m_threadCalculateStatistic.ThreadState == System.Threading.ThreadState.Running)
                {
                    if (this.m_timer != null)
                    {
                        this.m_timer.Stop();
                    }
                    this.m_threadCalculateStatistic.Abort();
                }
                if (CancelCalculating != null)
                {
                    CancelCalculating(this, new System.EventArgs());
                }
            }
		}

		#endregion

		#region MethodsProtected
		#endregion

		#region MethodsPrivate

		private void CalculateStatistik()
		{
			this.m_cursor = Cursors.WaitCursor;
			int iSpielzeitSecond = 0;
			double iSpielzeitMinute = 0;
			double iSpielzeitHour = 0;
			double iSpielzeitDay = 0;
			double iSpielzeitWeek = 0;
			double iSpielzeitYear = 0;

			if (this.m_dataSetStatisticInformations.Tables["Spielzeit"].Rows[0]["Spielzeit"] != System.DBNull.Value)
			{
				iSpielzeitSecond = (int)this.m_dataSetStatisticInformations.Tables["Spielzeit"].Rows[0]["Spielzeit"];
				iSpielzeitMinute = Convert.ToDouble(iSpielzeitSecond) / 60;
				iSpielzeitHour = Convert.ToDouble(iSpielzeitSecond) / 60 / 60;
				iSpielzeitDay = Convert.ToDouble(iSpielzeitSecond) / 60 / 60 / 24;
				iSpielzeitWeek = Convert.ToDouble(iSpielzeitSecond) / 60 / 60 / 24 / 7;
				iSpielzeitYear = Convert.ToDouble(iSpielzeitSecond) / 60 / 60 / 24 / 365;
			}
			string[][]  arraySpielzeit = new string[6][];
            arraySpielzeit[0] = new String[] { "Die Spielzeit betr�gt:", iSpielzeitSecond.ToString("F"), "Sekunden" };
            arraySpielzeit[1] = new String[] { string.Empty, iSpielzeitMinute.ToString("F"), "Minuten" };
            arraySpielzeit[2] = new String[] { string.Empty, iSpielzeitHour.ToString("F"), "Stunden" };
            arraySpielzeit[3] = new String[] { string.Empty, iSpielzeitDay.ToString("F"), "Tage" };
            arraySpielzeit[4] = new String[] { string.Empty, iSpielzeitWeek.ToString("F"), "Wochen" };
            arraySpielzeit[5] = new String[] { string.Empty, iSpielzeitYear.ToString("F"), "Jahre" };

            this.m_lstvSpielzeit.Invoke(new DelegateGetSpielzeit(GetSpielzeit), new Object[] { arraySpielzeit });

			int iCountPlatten = (int)this.m_dataSetStatisticInformations.Tables["CountPlatten"].Rows[0]["CountPlatten"];
			int iCountRecordedPlatten = (int)this.m_dataSetStatisticInformations.Tables["CountRecordedPlatten"].Rows[0]["CountRecordedPlatten"];
			int iCountTracks = (int)this.m_dataSetStatisticInformations.Tables["CountTracks"].Rows[0]["CountTracks"];

			string[][]  arrayStatistik = new string[3][];
			arrayStatistik[0] = new String[]
                {"Im System befinden sich",iCountPlatten.ToString(),"Platten"};
			arrayStatistik[1] = new String[]
                {"davon sind",iCountRecordedPlatten.ToString(),"aufgenommen"};
			arrayStatistik[2] = new String[]
                {"das sind",iCountTracks.ToString(),"mp3 Lieder"};

            this.m_lstvStatistik.Invoke(new DelegateGetSpielzeit(GetStatistik), new Object[] { arrayStatistik });

            DataRowCollection dataRows = this.m_dataSetStatisticInformations.Tables["TitelGroupByMedium"].Rows;
            ChartItem[] chartItems = new ChartItem[dataRows.Count];
            int iCounter = 0;
            foreach (DataRow dataRow in dataRows)
            {
                ChartItem chartItem = new ChartItem();
                chartItem.Text = dataRow["Medium"].ToString();
                chartItem.Value = float.Parse(dataRow["Count"].ToString());
                chartItems[iCounter] = chartItem;
                iCounter++;
            }
            this.m_chart.Invoke(new DelegateGetChart(GetChart), new Object[] { chartItems });
			
			this.m_cursor = Cursors.Default;
		}

		private void GetSpielzeit(string[][] aSpielzeit)
		{
            if (aSpielzeit != null)
            {
                int iArrayLength;
                iArrayLength = aSpielzeit.Length;

                for (int i = 0; i < iArrayLength; i++)
                {
                    this.m_lstvSpielzeit.Items.Add(new ListViewItem(aSpielzeit[i]));
                    ListViewItem listViewItem = this.m_lstvSpielzeit.Items[i];
                    listViewItem.UseItemStyleForSubItems = false;
                    listViewItem.SubItems[1].ForeColor = Color.Red;
                }
            }
		}

		private void GetStatistik(string[][] aStatistik)
		{
			if (aStatistik  != null)
			{
				int iArrayLength;
				iArrayLength = aStatistik.Length;

				for (int i = 0; i < iArrayLength; i++)
				{
                    this.m_lstvStatistik.Items.Add(new ListViewItem(aStatistik[i]));
                    ListViewItem listViewItem = this.m_lstvStatistik.Items[i];
                    listViewItem.UseItemStyleForSubItems = false;
                    listViewItem.SubItems[1].ForeColor = Color.Red;
				}
			}
		}
        private void GetChart(ChartItem[] chartItems)
        {
            if (chartItems != null)
            {
                foreach (ChartItem chartItem in chartItems)
                {
                    this.m_chart.ChartItems.Add(chartItem);
                }
            }
        }

		private void Timer_Elapsed(object sender,System.Timers.ElapsedEventArgs e)
		{
			if (this.m_threadCalculateStatistic != null)
			{
				if (this.m_threadCalculateStatistic.ThreadState == System.Threading.ThreadState.Stopped)
				{
					this.m_timer.Stop();
                    if (this.CompleteCalculating != null)
                    {
                        this.CompleteCalculating(this, new System.EventArgs());
                    }
				}
			}
		}

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

Share

About the Author

Uwe Eichkorn
Switzerland Switzerland
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 24 Apr 2010
Article Copyright 2009 by Uwe Eichkorn
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid