NoChangeImporterDao.cs

Description du code

NoChangeImporterDao.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.Text;
  4. using System.Runtime.Serialization.Formatters.Binary;
  5. using System.IO;
  6. using System.Collections;
  7. using System.Data.Common;
  8. using System.Data;
  9. using System.Drawing;
  10. using be.gaudry.observer;
  11. using be.gaudry.model;
  12.  
  13. namespace be.gaudry.bibliobrol.model.dao.mysql
  14. {
  15. public sealed class NoChangeImporterDao : Observable, IImporterDao
  16. {
  17. private String conStr;
  18.  
  19. #region singleton
  20. static NoChangeImporterDao instance = null;
  21. static readonly object padlock = new object();
  22. private DbProviderFactory dbpf;
  23. NoChangeImporterDao()
  24. {
  25. notify(new Notification(Notification.VERBOSE.debug, "AccessImporterDao singleton call", this));
  26. dbpf = ((MySQLFactory)MySQLFactory.Instance).getDbpf();
  27. conStr = ((MySQLFactory)MySQLFactory.Instance).getConnectionString();
  28. }
  29. public static NoChangeImporterDao Instance
  30. {
  31. get
  32. {
  33. lock (padlock)
  34. {
  35. if (instance == null)
  36. {
  37. instance = new NoChangeImporterDao();
  38. }
  39. return instance;
  40. }
  41. }
  42. }
  43. #endregion
  44.  
  45. #region IImporter Members
  46. /// <summary>
  47. /// Deserialize images
  48. /// </summary>
  49. /// <param name="path">(String) path of binary import file</param>
  50. /// <returns>A list of images</returns>
  51. public List<Image> importImages(string path)
  52. {
  53. FileStream fs = null;
  54. try
  55. {
  56. fs = new FileStream(path, FileMode.Open, FileAccess.Read);
  57. List<Image> images = (List<Image>)new BinaryFormatter().Deserialize(fs);
  58. return images;
  59. }
  60. catch (FileNotFoundException)
  61. {
  62. notify(new Notification(Notification.VERBOSE.criticalError, "Importation des images", String.Format("Fichier {0} non trouvé.", path), this));
  63. return new List<Image>();
  64. }
  65. catch (Exception e)
  66. {
  67. notify(new Notification(Notification.VERBOSE.criticalError, "Importation des images", e, this));
  68. return new List<Image>();
  69. }
  70. finally
  71. {
  72. fs.Close();
  73. }
  74. }
  75.  
  76. /// <summary>
  77. /// Deserialize mediabrols
  78. /// Search existings mediabrols which not match exactly with new list items (don't check id's).
  79. /// </summary>
  80. /// <param name="path">(String) path of binary import file</param>
  81. public void importBinaryMediaBrol(string path)
  82. {
  83. DateTime startDateTime = DateTime.Now;
  84.  
  85. FileStream fs = null;
  86. Object deserializedList = null;
  87. int count = 0;
  88. try
  89. {
  90. fs = new FileStream(path, FileMode.Open, FileAccess.Read);
  91. deserializedList = new BinaryFormatter().Deserialize(fs);
  92. count = castList(deserializedList);
  93. }
  94. catch (FileNotFoundException)
  95. {
  96. notify(new Notification(Notification.VERBOSE.criticalError, "Importation", String.Format("Fichier {0} non trouvé.",path), this));
  97. return;
  98. }
  99. catch (Exception e)
  100. {
  101. notify(new Notification(Notification.VERBOSE.criticalError, "Importation", e, this));
  102. return;
  103. }
  104. finally
  105. {
  106. if (fs != null) fs.Close();
  107.  
  108. notify(new Notification(Notification.VERBOSE.internalNotification, "lastBrol", String.Format("Fin des {0} chargements", count), this));
  109. notify(new Notification(Notification.VERBOSE.internalNotification, "End", String.Format("Fin de tous les traitements ({0})", Units.getDelay(startDateTime)), this));
  110. }
  111. }
  112. #endregion
  113.  
  114. #region private methods
  115. /// <summary>
  116. /// Test if deserialized object matches with a list of brols or a list of mediabrols
  117. /// And call appropriate method to import items
  118. /// </summary>
  119. /// <param name="deserializedList"></param>
  120. private int castList(object deserializedList)
  121. {
  122. int count;
  123. if (deserializedList is List<Brol>)
  124. {
  125. //first attempt : is it a list of brols ?
  126. List<Brol> importedList = (List<Brol>)deserializedList;
  127. count = importedList.Count;
  128. notify(new Notification(Notification.VERBOSE.internalNotification, "count", count.ToString(), this));
  129. importBrols(importedList);
  130. }
  131. else if (deserializedList is List<MediaBrol>)
  132. {
  133. //second attempt : is it a list of mediabrols ?
  134. List<MediaBrol> importedList = (List<MediaBrol>)deserializedList;
  135. count = importedList.Count;
  136. notify(new Notification(Notification.VERBOSE.internalNotification, "count", count.ToString(), this));
  137. importMediabrols(importedList);
  138. }
  139. else
  140. {
  141. count = 0;
  142. notify(new Notification(Notification.VERBOSE.error, "Importation", "Le fichier importé ne comporte ni ouvrage, ni exemplaire. Il est possible qu'il soit corrompu." , this));
  143. }
  144. return count;
  145. }
  146.  
  147. private void saveConflicts(List<IBrol> conflictList)
  148. {
  149. if (conflictList.Count > 0)
  150. {
  151. DateTime dt = DateTime.Now;
  152. StringBuilder saveConflictPath = new StringBuilder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
  153. saveConflictPath.Append(System.IO.Path.DirectorySeparatorChar);
  154. saveConflictPath.Append("brolConflict");
  155. saveConflictPath.Append(dt.Year);
  156. if (dt.Month < 10) saveConflictPath.Append("0");
  157. saveConflictPath.Append(dt.Month);
  158. if (dt.Day < 10) saveConflictPath.Append("0");
  159. saveConflictPath.Append(dt.Day);
  160. if (dt.Minute < 10) saveConflictPath.Append("0");
  161. saveConflictPath.Append(dt.Minute);
  162. saveConflictPath.Append(".bed");
  163. StringBuilder str = new StringBuilder(String.Format(
  164. "{0} éléments semblent déjà présents dans l'application. Vous pouvez toutefois importer ces éléments depuis le fichier suivant : {1}\n\nListe des éléments de ce fichier :\n\n",
  165. conflictList.Count,
  166. saveConflictPath.ToString()));
  167. if(conflictList[0].GetType().Equals(typeof(Brol)))
  168. {
  169. foreach (Brol brol in conflictList)
  170. str.AppendLine(brol.Title);
  171. }
  172. else if(conflictList[0].GetType().Equals(typeof(MediaBrol)))
  173. {
  174. foreach (MediaBrol mediabrol in conflictList)
  175. str.AppendLine(mediabrol.Brol.Title);
  176. }
  177. //exportation of conflicts list
  178. BinaryFormatter bf = new BinaryFormatter();
  179. FileStream fs = NoChangeExporterDao.Instance.getFileStream(saveConflictPath.ToString(), FileMode.OpenOrCreate, FileAccess.Write);
  180. if (fs == null)
  181. {
  182. notify(new Notification(Notification.VERBOSE.criticalError, "Exportation des conflits", "Impossible de trouver un flux de sortie", this));
  183. str.AppendLine("ERREUR : Impossible de trouver un flux de sortie");
  184. }
  185. else
  186. {
  187. try
  188. {
  189. bf.Serialize(fs, conflictList);
  190. notify(new Notification(Notification.VERBOSE.internalNotification, "Exportation des conflits", String.Format("Les éléments en conflits ont été sauvés sous {0}",saveConflictPath.ToString()), this));
  191. }
  192. catch (Exception eSer)
  193. {
  194. notify(new Notification(Notification.VERBOSE.criticalError, "Exportation", eSer, this));
  195. str.AppendLine(eSer.Message);
  196. }
  197. finally
  198. {
  199. fs.Close();
  200. }
  201. }
  202. notify(new Notification(Notification.VERBOSE.opsResult, "Exportation", str.ToString(), this));
  203. }
  204. }
  205.  
  206. /// <summary>
  207. /// Check imported mediabrols.
  208. /// If a mediabrol don't exists, insert it.
  209. /// If an actor or a categorie don't exists, insert it.
  210. /// </summary>
  211. /// <param name="importedList">Deserialized mediabrols</param>
  212. private void importMediabrols(List<MediaBrol> importedList)
  213. {
  214. notify(new Notification(Notification.VERBOSE.internalNotification, "Mediabrols",
  215. "Le fichier contient des exemplaires. Cette méthode n'est pour l'instant implémentée que pour des ouvrages.", this));
  216. }
  217. /// <summary>
  218. /// Check imported brols.
  219. /// If a brol don't exists, insert it.
  220. /// If an actor or a categorie don't exists, insert it.
  221. /// </summary>
  222. /// <param name="importedList">Deserialized brols</param>
  223. private void importBrols(List<Brol> importedList)
  224. {
  225. int foundId;
  226. List<IBrol> conflicts = new List<IBrol>();
  227. DbConnection dbCon = dbpf.CreateConnection();
  228. DbDataAdapter dbDa = dbpf.CreateDataAdapter();
  229. dbCon.ConnectionString = conStr;
  230. dbDa.SelectCommand = dbCon.CreateCommand();
  231. //todo : getTypesHashtable with , dbCon, dbDa
  232. Hashtable types = getTypesHashtable();
  233. //todo : getCategoriesHashtable with , dbCon, dbDa
  234. Hashtable categories = getCategoriesHashtable(dbCon, dbDa);
  235. //todo : getPersonsHashtable with , dbCon, dbDa
  236. Hashtable persons = getPersonsHashtable();
  237.  
  238. // load all persons and categories form bibliobrol to adapt ids
  239. // and check if we need to insert new item
  240.  
  241. //Check imported brols
  242. dbCon.Open();
  243. foreach (Brol importedBrol in importedList)
  244. {
  245. foundId = 0;
  246. notify(new Notification(Notification.VERBOSE.internalNotification, "count2", "5", this));
  247. //test if type exists
  248. if (types.ContainsKey(importedBrol.BrolType.Name.ToUpper()))
  249. importedBrol.BrolType.Id = (int)types[importedBrol.BrolType.Name.ToUpper()];
  250. else
  251. {
  252. //add type if not exists
  253. //modify brol type id
  254. importedBrol.BrolType.Id = NoChangeConfigDao.Instance.insertBrolType(importedBrol.BrolType, dbCon, dbDa);
  255. //insert into existing
  256. types.Add(importedBrol.BrolType.Name.ToUpper(), importedBrol.BrolType.Id);
  257. notify(new Notification(Notification.VERBOSE.internalNotification, "Ajout d'un type", String.Format("Ajout du type {0} dans l'application"), this));
  258. }
  259. notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 1", this));
  260. //test if brol exists
  261. dbDa.SelectCommand.CommandText = String.Format("SELECT id FROM item WHERE UCASE(itemTitle)='{0}'", MySQLUtils.escapeAndTrim(importedBrol.Title.ToUpper()));
  262. notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this));
  263. try
  264. {
  265. foundId = (int)dbDa.SelectCommand.ExecuteScalar();
  266. notify(new Notification(Notification.VERBOSE.debug, "foundId : " + foundId + " for " + importedBrol.Title, "", this));
  267. }
  268. catch (Exception){}
  269.  
  270. notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 2", this));
  271. if (foundId > 0)
  272. {
  273. //conflict
  274. notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 3", this));
  275. //importedBrol.Id = foundId;
  276. notify(new Notification(Notification.VERBOSE.internalNotification, "Conflit", String.Format("L'élément {0} semble en conflit avec un élément existant.", importedBrol.Title), this));
  277. notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 4", this));
  278. conflicts.Add(importedBrol);}
  279. else
  280. {
  281. insertImportedBrol(importedBrol, dbCon, dbDa, types, categories, persons);
  282. notify(new Notification(Notification.VERBOSE.internalNotification, "Import", String.Format("L'élément {0} est correstement importé.", importedBrol.Title), this));
  283. }
  284. notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 5", this));
  285. notify(new Notification(Notification.VERBOSE.internalNotification, "brolEnd", "", this));
  286. }
  287. dbCon.Close();
  288. saveConflicts(conflicts);
  289. }
  290. /// <summary>
  291. /// Insert a new brol from import file
  292. /// </summary>
  293. /// <param name="importedBrol"></param>
  294. /// <param name="dbCon"></param>
  295. /// <param name="dbDa"></param>
  296. /// <param name="types"></param>
  297. /// <param name="categories"></param>
  298. /// <param name="persons"></param>
  299. /// <returns></returns>
  300. private int insertImportedBrol(Brol importedBrol, DbConnection dbCon, DbDataAdapter dbDa, Hashtable types, Hashtable categories, Hashtable persons)
  301. {
  302. if (dbDa.InsertCommand == null)
  303. dbDa.InsertCommand = dbCon.CreateCommand();
  304. String key;
  305. importedBrol.Id = -1;//we need to set this value to insert as new item (!!!! otherwise we UPDATE AN EXISTING ITEM !!!)
  306. foreach (BrolCategory cat in importedBrol.Categories)
  307. {
  308. key = cat.Name.ToUpper()+importedBrol.BrolType.Id;
  309. //exists into bibliobrol
  310. if (categories.Contains(key))
  311. {
  312. cat.Id = (int)categories[key];
  313. }
  314. else
  315. {
  316. cat.Status = STATUS.toAppAdd;
  317. //insert new category into bibliobrol and set new id
  318. cat.Id = NoChangeConfigDao.Instance.insertCategory(cat, importedBrol.BrolType, dbCon, dbDa);
  319. notify(new Notification(Notification.VERBOSE.internalNotification, "Ajout", String.Format("La catégorie {0} est ajoutée.", cat.Name), this));
  320. categories.Add(key, cat.Id);
  321. }
  322. cat.Status = STATUS.toAdd;
  323. }
  324. notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 3", this));
  325.  
  326. foreach (Actor actor in importedBrol.Actors)
  327. {
  328. key = getPersonKey(actor);
  329. //exists into bibliobrol
  330. if (persons.Contains(key))
  331. {
  332. actor.Id = (int)persons[key];
  333. }
  334. else
  335. {
  336. //todo : if person img exists, prompt to delete it (it is probably an img from another actor)
  337. actor.Status = STATUS.toAppAdd;
  338. actor.Id = -1;//to force insertion
  339.  
  340. actor.Id = NoChangePersonDao.Instance.insertPerson(actor, dbCon, dbDa, new StringBuilder());
  341. notify(new Notification(Notification.VERBOSE.internalNotification, "Ajout", String.Format("La personne {0} est ajoutée.", actor.Display), this));
  342. persons.Add(key, actor.Id);
  343. }
  344. actor.Status = STATUS.toAdd;
  345. }
  346. notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 4", this));
  347. return NoChangeBrolDao.Instance.insertBrol(importedBrol, dbCon, dbDa, true);
  348. }
  349.  
  350. /// <summary>
  351. /// Check imported brols.
  352. /// If a brol don't exists, insert it.
  353. /// If an actor or a categorie don't exists, insert it.
  354. /// </summary>
  355. /// <param name="importedList">Deserialized mediabrols</param>
  356. /// <returns>(List IBrol)List of conflict brols</returns>
  357. private List<IBrol> importConflictBrols(List<IBrol> importedList)
  358. {
  359. /*Brol existingBrol;
  360.   List<Brol> existingBrols = null;
  361.   int[] brolIds = new int[1];
  362.   StringBuilder str = new StringBuilder("Résultat de l'importation");
  363.   Hashtable categories = getCategoriesHashtable();
  364.   Hashtable persons = getPersonsHashtable();
  365.   DbConnection dbCon = dbpf.CreateConnection();
  366.   DbDataAdapter dbDa = dbpf.CreateDataAdapter();
  367.   dbCon.ConnectionString = conStr;
  368.   dbDa.SelectCommand = dbCon.CreateCommand();
  369.  
  370.   // load all persons and categories form bibliobrol to adapt ids
  371.   // and check if we need to insert new item
  372.  
  373.   //todo : loadpersons with , dbCon, dbDa
  374.   //todo : loadCategories with , dbCon, dbDa
  375.  
  376.   //Check imported brols
  377.   String key;//key to test
  378.   foreach (Brol importedBrol in importedList)
  379.   {
  380.   notify(new Notification(Notification.VERBOSE.internalNotification, "count2", "6", this));
  381.   notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 1", this));
  382.   //load brol if exists
  383.   //ds = new DataSet();
  384.   dbDa.SelectCommand.CommandText = String.Format("SELECT id FROM item WHERE UCASE(itemTitle)='{0}'", importedBrol.Title.Trim().ToUpper().Replace("'", "''"));
  385.   notify(new Notification(Notification.VERBOSE.advancedOperation, dbDa.SelectCommand.CommandText, this));
  386.   dbCon.Open();
  387.   try
  388.   {
  389.   brolIds[0] = (int)dbDa.SelectCommand.ExecuteScalar();
  390.   existingBrols = AccessExporterDao.Instance.loadSelectedBrols(brolIds, dbCon, dbDa, false);
  391.   }
  392.   catch (Exception) { }
  393.   dbCon.Close();
  394.  
  395.   notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 2", this));
  396.   if (existingBrols != null && existingBrols.Count > 0)
  397.   {
  398.   existingBrol = existingBrols[0];
  399.   }
  400.   else
  401.   {
  402.   existingBrol = new Brol();
  403.   existingBrol.Title = importedBrol.Title;
  404.   }
  405.   foreach (BrolCategory cat in importedBrol.Categories)
  406.   {
  407.   key = cat.Name.ToUpper() + existingBrol.BrolType.Id;
  408.   //exists into bibliobrol
  409.   if (categories.Contains(key))
  410.   {
  411.   cat.Id = (int)categories[key];
  412.  
  413.   //check with found Brol item
  414.   cat.Status = STATUS.none;
  415.   foreach (BrolCategory tempCat in existingBrol.Categories)
  416.   {
  417.   if (tempCat.Id == cat.Id)
  418.   {
  419.   cat.Status = STATUS.toAdd;
  420.   break;
  421.   }
  422.   }
  423.   //cat exists into bibliobrol, but not into existing brol
  424.   if (cat.Status.Equals(STATUS.toAdd))
  425.   {
  426.   existingBrol.addCategory(cat);
  427.   }
  428.   }
  429.   //don't exists into bibliobrol (and don't exists into existing brol)
  430.   else
  431.   {
  432.   cat.Status = STATUS.toAppAdd;
  433.   //insert new category into bibliobrol
  434.   cat.Id = AccessConfigDao.Instance.insertCategory(cat, existingBrol.BrolType, dbCon, dbDa);
  435.   cat.Status = STATUS.toAdd;
  436.   categories.Add(key, cat.Id);
  437.   existingBrol.addCategory(cat);
  438.   }
  439.   }
  440.   notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 3", this));
  441.  
  442.   foreach (Actor actor in importedBrol.Actors)
  443.   {
  444.   key = getPersonKey(actor);
  445.   //exists into bibliobrol
  446.   if (persons.Contains(key))
  447.   {
  448.   actor.Id = (int)persons[key];
  449.  
  450.   //check with found Brol item
  451.   STATUS = STATUS.none;
  452.   foreach (Actor tempActor in existingBrol.Actors)
  453.   {
  454.   if (tempActor.Id == actor.Id)
  455.   {
  456.   STATUS = STATUS.toAdd;
  457.   break;
  458.   }
  459.   }
  460.   //person exists into bibliobrol, but actor not exists into current loaded brol
  461.   if (STATUS.Equals(STATUS.toAdd))
  462.   {
  463.   existingBrol.addActor(actor);
  464.   }
  465.   }
  466.   //don't exists into bibliobrol (and don't exists into existing brol)
  467.   else
  468.   {
  469.   STATUS = STATUS.toAppAdd;
  470.   //insert new category into bibliobrol
  471.   actor.Id = AccessPersonDao.Instance.insertPerson(actor.getPerson(), dbCon, dbDa, str);
  472.   STATUS = STATUS.toAdd;
  473.   persons.Add(key, actor.Id);
  474.   existingBrol.addActor(actor);
  475.   }
  476.   }
  477.   notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 4", this));
  478.   if (String.Empty.Equals(existingBrol.Comment) && !String.Empty.Equals(importedBrol.Comment))
  479.   {
  480.   existingBrol.Comment = importedBrol.Comment;
  481.   }
  482.   if (String.Empty.Equals(existingBrol.Synopsis) && !String.Empty.Equals(importedBrol.Synopsis))
  483.   {
  484.   existingBrol.Synopsis = importedBrol.Synopsis;
  485.   }
  486.   if ((new DateTime(0L)).Equals(existingBrol.Date) && !(new DateTime(0L)).Equals(importedBrol.Date))
  487.   {
  488.   existingBrol.Date = importedBrol.Date;
  489.   }
  490.   if (existingBrol.Cotation < 1 && importedBrol.Cotation > 0)
  491.   {
  492.   existingBrol.Cotation = importedBrol.Cotation;
  493.   }
  494.   notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 5", this));
  495.   if (existingBrol.Id < 0)
  496.   {
  497.   AccessBrolDao.Instance.insertBrol(existingBrol, dbCon, dbDa, false);
  498.   }
  499.   else
  500.   {
  501.   AccessBrolDao.Instance.updateBrol(existingBrol, dbCon, dbDa, false, str);
  502.   }
  503.   notify(new Notification(Notification.VERBOSE.internalNotification, "pb2", "step 6", this));
  504.   str.AppendLine(String.Format("Ouvrage {0} : {1}", existingBrol.Id, existingBrol.Title));
  505.   notify(new Notification(Notification.VERBOSE.internalNotification, "brolEnd", "", this));
  506.  
  507.   }*/
  508. return null;
  509. }
  510. /// <summary>
  511. /// Get a Hashtable with all categories ids.
  512. /// key : name.toUpper()+typeId
  513. /// value : id
  514. /// </summary>
  515. /// <returns>Hashtable with categories ids</returns>
  516. private Hashtable getCategoriesHashtable(DbConnection dbCon, DbDataAdapter dbDa)
  517. {
  518. Hashtable categories = new Hashtable();
  519. DataTable catsDt = new DataTable();
  520. dbDa.SelectCommand.CommandText = "SELECT id, typeId, name FROM category";
  521. notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this));
  522. try
  523. {
  524. dbDa.Fill(catsDt);
  525. foreach (DataRow row in catsDt.Rows)
  526. {
  527. if (!(row["id"] is DBNull) && !(row["name"] is DBNull))
  528. {
  529. categories.Add(((String)row["name"]).ToUpper()+(int)row["typeId"], (int)row["id"]);
  530. }
  531. }
  532. }
  533. catch (Exception e)
  534. {
  535. notify(new Notification(Notification.VERBOSE.advancedOperation, "Chargement des catégories", e, this));
  536. }
  537. /*foreach (BrolCategory c in AccessBrolDao.Instance.loadCategories(-2))
  538.   {
  539.   categories.Add(c.Name.ToUpper(), c.Id);
  540.   }*/
  541. return categories;
  542. }
  543.  
  544. /// <summary>
  545. /// Get a Hashtable with all persons ids.
  546. /// key : see String getPersonKey(Person person) method
  547. /// value : id
  548. /// </summary>
  549. /// <returns>Hashtable with persons ids</returns>
  550. private Hashtable getPersonsHashtable()
  551. {
  552. Hashtable persons = new Hashtable();
  553. foreach (Person person in NoChangePersonDao.Instance.loadPersons())
  554. {
  555. persons.Add(getPersonKey(person), person.Id);
  556. }
  557. return persons;
  558. }
  559. /// <summary>
  560. /// Get a Hashtable with all types ids.
  561. /// key : type name
  562. /// value : id
  563. /// </summary>
  564. /// <returns>Hashtable with persons ids</returns>
  565. private Hashtable getTypesHashtable()
  566. {
  567. Hashtable types = new Hashtable();
  568. foreach (BrolType type in NoChangeConfigDao.Instance.loadBrolTypes())
  569. {
  570. types.Add(type.Name.ToUpper(), type.Id);
  571. }
  572. return types;
  573. }
  574. /// <summary>
  575. /// Get a key for a person : FirstName.ToUpper() + LastName.ToUpper();
  576. /// </summary>
  577. /// <param name="person">(Person) from which we need a key</param>
  578. /// <returns>(String)person key</returns>
  579. private String getPersonKey(Person person)
  580. {
  581. return person.FirstName.ToUpper() + person.LastName.ToUpper();
  582. }
  583.  
  584. #endregion
  585. }
  586. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/src/model/dao/mysql/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1734931580 23/12/2024 06:26:20
| _utils0 octets1541007203 31/10/2018 18:33:23
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/src/model/dao/mysql/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csNoChangeImporterDao.cs27.14 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeExporterDao.cs33.69 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeSerieDao.cs6.22 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csMySQLFactory.cs3.75 Ko31/10/2018 18:33:17-refusé-
Afficher le fichier .cs|.csNoChangeConfigDao.cs12.25 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangePersonDao.cs59.9 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeTaskDao.cs8.92 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeBrolDao.cs58.25 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csMySQLStatsDao.cs10.63 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csMySQLMediaBrolDao.cs50.51 Ko31/10/2018 18:33:18-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.

Version en cache

23/12/2024 06:26:20 Cette version de la page est en cache (à la date du 23/12/2024 06:26:20) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.

Document créé le 16/10/2009, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/cs-bibliobrol-source-rf-model/dao/mysql/NoChangeImporterDao.cs.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.