AccessStatsDao.cs
Description du code
AccessStatsDao.cs est un fichier du projet BiblioBrol.Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/src/.
Projet BiblioBrol :
Gestion de media en CSharp.
Pour plus d'infos, vous pouvez consulter la brève analyse.
Code source ou contenu du fichier
Code c# (AccessStatsDao.cs) (248 lignes)
using System; using System.Collections.Generic; using System.Text; using System.Data.Common; using System.Data; using be.gaudry.observer; using be.gaudry.model; namespace be.gaudry.bibliobrol.model.dao.msaccess { class AccessStatsDao : Observable, IStatsDao { #region singleton static AccessStatsDao instance = null; private String conStr; private DbProviderFactory dbpf; AccessStatsDao() { dbpf = ((AccessFactory)AccessFactory.Instance).getDbpf(); conStr = ((AccessFactory)AccessFactory.Instance).getConnectionString(); } public static AccessStatsDao Instance { get { lock (padlock) { if (instance == null) { } return instance; } } } #endregion #region IStatsDao Membres public Counter loadCounters() { DbConnection dbCon = dbpf.CreateConnection(); DbDataAdapter dbDa = dbpf.CreateDataAdapter(); dbDa.SelectCommand = dbCon.CreateCommand(); dbCon.ConnectionString = conStr; try { dbCon.Open(); dbDa.SelectCommand.CommandText = "SELECT COUNT(id) AS [nb] FROM person"; counter.PersonsCount = (int)dbDa.SelectCommand.ExecuteScalar(); dbDa.SelectCommand.CommandText = "SELECT COUNT(personId) AS [nb] FROM [user]"; counter.UsersCount = (int)dbDa.SelectCommand.ExecuteScalar(); dbDa.SelectCommand.CommandText = "SELECT COUNT(id) AS [nb] FROM borrow"; counter.BorrowsCount = (int)dbDa.SelectCommand.ExecuteScalar(); dbDa.SelectCommand.CommandText = "SELECT COUNT(id) AS [nb] FROM item"; counter.BrolCount = (int)dbDa.SelectCommand.ExecuteScalar(); dbCon.Close(); } catch (Exception e) { } finally { if (dbCon.State != ConnectionState.Closed) dbCon.Close(); } return counter; } public Stat loadActorRoles() { DbConnection dbCon = dbpf.CreateConnection(); DbDataAdapter dbDa = dbpf.CreateDataAdapter(); dbDa.SelectCommand = dbCon.CreateCommand(); dbCon.ConnectionString = conStr; StringBuilder str = new StringBuilder("SELECT COUNT(actor.roleId) AS [actors], role.roleName AS [role_name]"); str.Append(" FROM role INNER JOIN actor ON role.[id] = actor.[roleId]"); str.Append(" GROUP BY role.roleName, actor.roleId"); str.Append(" ORDER BY COUNT(actor.roleId) DESC"); /*StringBuilder str = new StringBuilder("SELECT COUNT(actor.personId) AS [actors], [firstName]+\" \"+[lastName] AS [actor_name]"); str.Append(" FROM person INNER JOIN actor ON person.[id] = actor.[personId]"); str.Append(" GROUP BY person.lastName, person.firstName, actor.roleId"); str.Append(" ORDER BY COUNT(actor.personId) DESC");*/ dbDa.SelectCommand.CommandText = str.ToString(); notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this)); try { dbDa.Fill(brolDt); } catch (System.Data.OleDb.OleDbException e) { notify(new Notification(Notification.VERBOSE.criticalError, "Chargement des rôles pour les statistiques", e, this)); } dbCon.Close(); foreach (DataRow dr in brolDt.Rows) { stat.increase((String)dr["role_name"],(int)dr["actors"]); } return stat; } public Stat loadCurrentBorrows() { DbConnection dbCon = dbpf.CreateConnection(); DbDataAdapter dbDa = dbpf.CreateDataAdapter(); dbDa.SelectCommand = dbCon.CreateCommand(); dbCon.ConnectionString = conStr; StringBuilder str = new StringBuilder("SELECT COUNT(borrow.id) AS [borrows], [firstName]+\" \"+[lastName] AS [borrower]"); str.Append(" FROM person INNER JOIN borrow ON person.[id] = borrow.[personId]"); str.Append(" GROUP BY person.lastName, person.firstName, borrow.endDate"); str.Append(" HAVING (((Count(borrow.id))>0) AND ((borrow.endDate) Is Null))"); str.Append(" ORDER BY COUNT(borrow.id) DESC"); dbDa.SelectCommand.CommandText = str.ToString(); notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this)); try { dbDa.Fill(brolDt); } catch (System.Data.OleDb.OleDbException e) { notify(new Notification(Notification.VERBOSE.criticalError, "Chargement des emprunts en cours pour les statistiques", e, this)); } dbCon.Close(); foreach (DataRow dr in brolDt.Rows) { stat.increase((String)dr["borrower"], (int)dr["borrows"]); } return stat; } public Stat loadAllBorrows() { DbConnection dbCon = dbpf.CreateConnection(); DbDataAdapter dbDa = dbpf.CreateDataAdapter(); dbDa.SelectCommand = dbCon.CreateCommand(); dbCon.ConnectionString = conStr; /* SELECT Count(borrow.id) AS borrows, [firstName]+" "+[lastName] AS borrower FROM person INNER JOIN borrow ON person.id = borrow.personId GROUP BY [firstName]+" "+[lastName] HAVING (((Count(borrow.id))>0)) ORDER BY Count(borrow.id) DESC; */ StringBuilder str = new StringBuilder("SELECT COUNT(borrow.id) AS [borrows],[firstName]+\" \"+[lastName] AS [borrower]"); str.Append(" FROM person INNER JOIN borrow ON person.[id] = borrow.[personId]"); str.Append(" GROUP BY [firstName]+\" \"+[lastName]"); str.Append(" HAVING COUNT(borrow.id)>0"); str.Append(" ORDER BY COUNT(borrow.id) DESC"); dbDa.SelectCommand.CommandText = str.ToString(); notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this)); try { dbDa.Fill(brolDt); } catch (System.Data.OleDb.OleDbException e) { notify(new Notification(Notification.VERBOSE.criticalError, "Chargement des emprunts pour les statistiques", e, this)); } dbCon.Close(); foreach (DataRow dr in brolDt.Rows) { stat.increase((String)dr["borrower"], (int)dr["borrows"]); } return stat; } public Stat loadBrolTypes() { DbConnection dbCon = dbpf.CreateConnection(); DbDataAdapter dbDa = dbpf.CreateDataAdapter(); dbDa.SelectCommand = dbCon.CreateCommand(); dbCon.ConnectionString = conStr; str.Append(" FROM type LEFT JOIN item ON type.id = item.typeId"); str.Append(" GROUP BY type.name"); str.Append(" ORDER BY COUNT(item.id) DESC;"); dbDa.SelectCommand.CommandText = str.ToString(); notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this)); try { dbDa.Fill(brolDt); } catch (System.Data.OleDb.OleDbException e) { notify(new Notification(Notification.VERBOSE.criticalError, "Chargement des types d'ouvrages pour les statistiques", e, this)); } dbCon.Close(); foreach (DataRow dr in brolDt.Rows) { stat.increase((String)dr["name"], (int)dr["items"]); } return stat; } public Stat loadMediaBrolTypes() { DbConnection dbCon = dbpf.CreateConnection(); DbDataAdapter dbDa = dbpf.CreateDataAdapter(); dbDa.SelectCommand = dbCon.CreateCommand(); dbCon.ConnectionString = conStr; str.Append(" FROM type LEFT JOIN (item LEFT JOIN itemBiblio ON item.id = itemBiblio.itemId) ON type.id = item.typeId"); str.Append(" GROUP BY type.name"); str.Append(" ORDER BY COUNT(itemBiblio.id) DESC;"); dbDa.SelectCommand.CommandText = str.ToString(); notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this)); try { dbDa.Fill(brolDt); } catch (System.Data.OleDb.OleDbException e) { notify(new Notification(Notification.VERBOSE.criticalError, "Chargement des types d'exemplaires pour les statistiques", e, this)); } dbCon.Close(); foreach (DataRow dr in brolDt.Rows) { stat.increase((String)dr["name"], (int)dr["items"]); } return stat; } #endregion } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1734908585 23/12/2024 00:03:05 |
| _ | utils | 0 octets | 1541007203 31/10/2018 18:33:23 |
Utilisation de l'explorateur de code
- Navigation :
- Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
- Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
- La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
- Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
- Affichage :
- Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
- Actions :
- Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 16/10/2009, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/cs-bibliobrol-source-rf-model/dao/msaccess//AccessStatsDao.cs.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.