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.

CreateStructureControl.cs

Description du code

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

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. using be.gaudry.observer;
  10. using System.Net;
  11. using be.gaudry.model;
  12. using be.gaudry.bibliobrol.config;
  13. using be.gaudry.bibliobrol.model.dao.config;
  14.  
  15. namespace be.gaudry.bibliobrol.view.controls
  16. {
  17. public partial class CreateStructureControl : UserControl
  18. {
  19. private String createStr, cancelStr, dbUrl, localFile;
  20. private int presteps;
  21.  
  22. private WebClient webClient;
  23. public CreateStructureControl()
  24. {
  25. createStr = "Créer la structure";
  26. cancelStr = "Annuler";
  27. dbUrl = "http://www.gaudry.be/bibliobrol/data.bdb";
  28. localFile = new AccessConfig().getAdaptedPath();
  29. presteps = 0;
  30. InitializeComponent();
  31. }
  32.  
  33. private void createStructure()
  34. {
  35. StringBuilder str = new StringBuilder();
  36. try
  37. {
  38. StaticObservable.hideErrors();
  39.  
  40. infoProgressLbl.Text = "Création des répertoires";
  41. str.AppendFormat("Création du répertoire {0}", Config.DataDirectory);
  42. DirectoryInfo di = Directory.CreateDirectory(Config.DataDirectory);
  43. str.Append(" : OK");
  44.  
  45. str.Append("\nCréation du sous-répertoire export");
  46. di.CreateSubdirectory("export");
  47. progressBar.Value = ++presteps;
  48. str.Append(" : OK");
  49.  
  50. str.Append("\nCréation du sous-répertoire images");
  51. di = di.CreateSubdirectory("images");
  52. progressBar.Value = ++presteps;
  53. str.Append(" : OK");
  54.  
  55. str.Append("\nCréation du sous-répertoire application");
  56. di.CreateSubdirectory("application");
  57. progressBar.Value = ++presteps;
  58. str.Append(" : OK");
  59.  
  60. str.Append("\nCréation du sous-répertoire ouvrages");
  61. di.CreateSubdirectory("ouvrages");
  62. progressBar.Value = ++presteps;
  63. str.Append(" : OK");
  64.  
  65. str.Append("\nCréation du sous-répertoire personnes");
  66. di.CreateSubdirectory("personnes");
  67. progressBar.Value = ++presteps;
  68. str.Append(" : OK");
  69.  
  70. infoProgressLbl.Text = "Création du fichier de configuration";
  71. str.Append("\nCréation du fichier de configuration");
  72. Config.save();
  73. progressBar.Value = ++presteps;
  74. str.Append(" : OK");
  75.  
  76. str.Append("\nTéléchargement du fichier de base de données");
  77. StaticObservable.showNewErrors();
  78. if (WebHelper.testUrl(dbUrl))
  79. {
  80. StaticObservable.notify(new Notification(Notification.VERBOSE.opsResult, str.ToString(), this));
  81. webClient = new WebClient();
  82. webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(progressBarCompleted);
  83. webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(increaseProgressBar);
  84. webClient.DownloadFileAsync(new Uri(dbUrl), localFile);
  85. str.Append(" : OK");
  86. StaticObservable.notify(new Notification(Notification.VERBOSE.opsResult, str.ToString(), this));
  87. }
  88. else
  89. {
  90. str.Append(" : ERREUR");
  91. cancelDownload();
  92. StaticObservable.notify(new Notification(
  93. Notification.VERBOSE.criticalError,
  94. new Exception(
  95. "Impossible de télécharger la base de données.\n\nSoit la connexion internet n'est pas active, soit le fichier n'est momentanément pas disponible sur l'infobrol.\n\nDétails de l'installation :\n" +
  96. str.ToString()
  97. ),
  98. this
  99. ));
  100. }
  101.  
  102. }
  103. catch (Exception e)
  104. {
  105. StaticObservable.notify(new Notification(
  106. Notification.VERBOSE.error,
  107. "Erreur lors de la création de la structure",
  108. str.ToString(),
  109. e,
  110. this));
  111. }
  112. }
  113.  
  114. private void createStructureBtn_Click(object sender, EventArgs e)
  115. {
  116. if (createStructureBtn.Text.Equals(createStr))
  117. {
  118. if (Directory.Exists(Config.DataDirectory))
  119. {
  120. DialogResult dr = MessageBox.Show(
  121. "Le répertoire semble déjà présent, il sera supprimé si la nouvelle structure est créée.\nEcraser l'ancien répertoire ?",
  122. "Création de la structure de travail de Bibliobrol",
  123. MessageBoxButtons.OKCancel,
  124. MessageBoxIcon.Exclamation,
  125. MessageBoxDefaultButton.Button1);
  126. if (DialogResult.OK != dr)
  127. {
  128. return;
  129. }
  130. Directory.Delete(Config.DataDirectory, true);
  131. }
  132. createStructureBtn.Text = cancelStr;
  133. progressBar.Visible = true;
  134. infoProgressLbl.Visible = true;
  135. createStructure();
  136. }
  137. else
  138. {
  139. cancelDownload();
  140. }
  141. }
  142.  
  143. private void cancelDownload()
  144. {
  145. createStructureBtn.Text = createStr;
  146. progressBar.Visible = false;
  147. infoProgressLbl.Visible = false;
  148. if (webClient != null)
  149. {
  150. webClient.CancelAsync();
  151. webClient.DownloadProgressChanged -= new DownloadProgressChangedEventHandler(increaseProgressBar);
  152. }
  153. }
  154.  
  155. private void increaseProgressBar(object sender, DownloadProgressChangedEventArgs e)
  156. {
  157. progressBar.Value = presteps + e.ProgressPercentage;
  158. infoProgressLbl.Text = " Téléchargement (" + e.ProgressPercentage + "%)";
  159. }
  160.  
  161. private void progressBarCompleted(object sender, AsyncCompletedEventArgs e)
  162. {
  163. progressBar.Value = 0;
  164. createStructureBtn.Text = createStr;
  165. progressBar.Visible = false;
  166. infoProgressLbl.Visible = false;
  167. if (e.Cancelled)
  168. {
  169. webClient = null;
  170. Directory.Delete(Config.DataDirectory, true);
  171. //File.Delete(localFile);
  172. }
  173. else
  174. {
  175. DialogResult dr = MessageBox.Show(
  176. "La création de la structure ne sera prise en compte qu'après un redémarrage de l'application BiblioBrol.\nRedémarrer maintenant ?",
  177. "Création de la structure de travail de Bibliobrol",
  178. MessageBoxButtons.YesNo,
  179. MessageBoxIcon.Exclamation,
  180. MessageBoxDefaultButton.Button1);
  181. if (DialogResult.Yes == dr)
  182. {
  183. Application.Restart();
  184. }
  185. }
  186. }
  187. }
  188. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/src/view/controls/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1727475851 28/09/2024 00:24:11
| _dao0 octets1541007199 31/10/2018 18:33:19
| _toolBars0 octets1541007200 31/10/2018 18:33:20
| _webInfo0 octets1541007201 31/10/2018 18:33:21
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/src/view/controls/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csPersonSelectControl.cs4.89 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csCreateStructureControl.cs7.49 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDBSelectControl.cs3.23 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csPersonInfoControl.Designer.cs13.13 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxDirControl.resx5.68 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .resx|.resxBrolInfoControl.resx6.06 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csBrolEditControl.cs25.36 Ko31/10/2018 18:32:55-refusé-
Afficher le fichier .cs|.csPersonEditControl.cs15.67 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csSearchControl.cs18.88 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxDBSelectControl.resx5.88 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csBrolInfoControl.Designer.cs22.81 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csInfoControl.cs2.04 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDirControl.Designer.cs5.83 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csSelectConsoleVerboseControl.cs5.49 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csPersonSelectedEventArgs.cs779 octets31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxSelectConsoleVerboseControl.resx5.68 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csTodoControl.cs13.73 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .cs|.csSelectConsoleVerboseControl.Designer.cs45.29 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csBrolEditControl.Designer.cs40.09 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDBSelectControl.Designer.cs6.71 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csPersonEditControl.Designer.cs27.54 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxPersonInfoControl.resx6.42 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csCreateStructureControl.Designer.cs5 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDirPathModifiedEventArgs.cs871 octets31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csInfoControl.Designer.cs3.18 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csBrolInfoControl.cs5.14 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .resx|.resxBrolEditControl.resx6.04 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csPersonInfoControl.cs2.22 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxInfoControl.resx5.68 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csDirControl.cs4.51 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .resx|.resxCreateStructureControl.resx6.44 Ko31/10/2018 18:32:56-refusé-
Afficher le fichier .cs|.csSerieEditControl.cs2.58 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxSerieEditControl.resx7.45 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxTodoControl.resx6.76 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .cs|.csTodoControl.Designer.cs28.27 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxSearchControl.resx6.43 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csPersonSelectControl.Designer.cs14.74 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csSearchControl.Designer.cs25.75 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .resx|.resxPersonEditControl.resx7.96 Ko31/10/2018 18:32:57-refusé-
Afficher le fichier .cs|.csSerieEditControl.Designer.cs6.65 Ko31/10/2018 18:32:58-refusé-
Afficher le fichier .resx|.resxPersonSelectControl.resx5.68 Ko31/10/2018 18:32:57-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 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-bibliobrol-source-rf-view/controls//CreateStructureControl.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.