No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

FileStatsParser.cs

Description du code

FileStatsParser.cs est un fichier du projet BrolFileStats.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/brolfilestats/.

Projet BrolFileStats :

Statistiques en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5. using System.ComponentModel;
  6. using be.gaudry.model.file;
  7. using be.gaudry.view.controls;
  8. using be.gaudry.model;
  9.  
  10. namespace be.gaudry.explorer.filestats.model
  11. {
  12. public class FileStatsParser : AbstractFileParser
  13. {
  14. #region declarations and constructors
  15. private Stat stat;
  16. private FILE_SEARCHTYPE searchType;
  17. private bool keySensitive, firstLevel;
  18. private Dictionary<string, DateTime> dateLaps;
  19.  
  20. public FileStatsParser()
  21. : base()
  22. {
  23. firstLevel = true;
  24. dateLaps = new Dictionary<string,DateTime>();
  25. dateLaps.Add("5 ans", DateTime.Now.AddYears(-5));
  26. dateLaps.Add("Un an", DateTime.Now.AddYears(-1));
  27. dateLaps.Add("6 mois", DateTime.Now.AddMonths(-6));
  28. dateLaps.Add("Un mois", DateTime.Now.AddMonths(-1));
  29. dateLaps.Add("15 jours", DateTime.Now.AddDays(-15));
  30. dateLaps.Add("Une semaine", DateTime.Now.AddDays(-7));
  31. dateLaps.Add("Aujourd'hui", DateTime.Now);
  32. }
  33. #endregion
  34.  
  35. #region properties
  36. public Stat Stat
  37. {
  38. get { return stat; }
  39. set { stat = value; }
  40. }
  41. public FILE_SEARCHTYPE SearchType
  42. {
  43. get { return searchType; }
  44. set { searchType = value; }
  45. }
  46. public bool KeySensitive
  47. {
  48. get { return keySensitive; }
  49. set { keySensitive = value; }
  50. }
  51. /// <summary>
  52. /// Set true to show only first level summary
  53. /// </summary>
  54. public bool FirstLevel
  55. {
  56. get { return firstLevel; }
  57. set { firstLevel = value; }
  58. }
  59. public List<string> DateLaps
  60. {
  61. get { return new List<string>(dateLaps.Keys); }
  62. }
  63. #endregion
  64.  
  65. #region method to implement
  66. /// <summary>
  67. /// Do something on each file
  68. /// </summary>
  69. /// <param name="bgw">BackgroundWorker to perform cancel if needed, and report progress</param>
  70. /// <param name="e">DoWorkEventArgs to perform cancel if needed, and report progress</param>
  71. /// <param name="fi">FileInfo to check</param>
  72. /// <param name="percent">(int) Progress percentage</param>
  73. /// <param name="subDirDeep">Deep of the directory in comparison with start directory</param>
  74. /// <returns>
  75. /// true if we must stop the parsing of current directory (ie. if we have a vob file, we don't check the other files in this directory)
  76. /// false otherwise
  77. ///</returns>
  78. protected override bool performOnFile(BackgroundWorker bgw, DoWorkEventArgs e, FileInfo fi, int percent, int subDirDeep)
  79. {
  80. switch (searchType)
  81. {
  82. case FILE_SEARCHTYPE.Extension:
  83. stat.increase((keySensitive) ? fi.Extension : fi.Extension.ToUpper());
  84. break;
  85. case FILE_SEARCHTYPE.Count:
  86. stat.increase(fi.DirectoryName);
  87. break;
  88. case FILE_SEARCHTYPE.LastAccess:
  89. DateTime dt = fi.LastAccessTime;
  90. foreach(KeyValuePair<string, DateTime> kvp in dateLaps)
  91. {
  92. if (dt <= kvp.Value)
  93. {
  94. stat.increase(kvp.Key);
  95. return false;
  96. }
  97. }
  98. break;
  99. case FILE_SEARCHTYPE.Attribute:
  100.  
  101. stat.increase(fi.Attributes.ToString());
  102. break;
  103. case FILE_SEARCHTYPE.FileSize:
  104. stat.increase(fi.FullName, fi.Length);
  105. break;
  106. case FILE_SEARCHTYPE.DirSize:
  107. string directoryName = fi.DirectoryName;
  108. if (fi.Directory.FullName.Equals(startPath))
  109. {
  110. break;
  111. }
  112. if (firstLevel)
  113. {
  114. for (int i = 2; i <= subDirDeep; i++)
  115. {
  116. directoryName = FileHelper.getParentDir(directoryName);
  117. }
  118. }
  119. stat.increase(directoryName, fi.Length);
  120. break;
  121. }
  122. return false;
  123. }
  124. #endregion
  125. }
  126. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/brolfilestats/model/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1714431530 30/04/2024 00:58:50
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/brolfilestats/model/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csFileStatsParser.cs4.61 Ko31/10/2018 18:32:22-refusé-
Afficher le fichier .cs|.csFILE_SEARCHTYPE.cs1.48 Ko31/10/2018 18:32:22-refusé-

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.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-brolfilestats-source-rf-model/FileStatsParser.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.