Annotation of /trunk/ModularRex/NHibernate/NHibernateRexLegacyData.cs
Parent Directory
|
Revision Log
Revision 243 - (view) (download)
| 1 : | tuco | 80 | using System; |
| 2 : | using System.Reflection; | ||
| 3 : | using System.Collections.Generic; | ||
| 4 : | using System.Text; | ||
| 5 : | using OpenMetaverse; | ||
| 6 : | using log4net; | ||
| 7 : | using NHibernate; | ||
| 8 : | using NHibernate.Criterion; | ||
| 9 : | using OpenSim.Framework; | ||
| 10 : | using Environment = NHibernate.Cfg.Environment; | ||
| 11 : | using ModularRex.RexFramework; | ||
| 12 : | |||
| 13 : | mikkopa | 179 | namespace ModularRex.NHibernate |
| 14 : | tuco | 80 | { |
| 15 : | public class NHibernateRexLegacyData | ||
| 16 : | { | ||
| 17 : | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 18 : | public bool Inizialized = false; | ||
| 19 : | |||
| 20 : | public NHibernateManager manager; | ||
| 21 : | |||
| 22 : | public void Initialise(string connect) | ||
| 23 : | { | ||
| 24 : | m_log.InfoFormat("[NHIBERNATE] Initializing NHibernateRexLegacyData"); | ||
| 25 : | Assembly assembly = GetType().Assembly; | ||
| 26 : | manager = new NHibernateManager(connect, "RexLegacyData", assembly); | ||
| 27 : | Inizialized = true; | ||
| 28 : | } | ||
| 29 : | |||
| 30 : | /// <summary> | ||
| 31 : | /// Retrives all objects from the old rex tables | ||
| 32 : | /// </summary> | ||
| 33 : | /// <returns>All objects as a list, if none found or error while processing returns null</returns> | ||
| 34 : | public List<RexLegacyPrimData> LoadAllRexPrimData() | ||
| 35 : | { | ||
| 36 : | try | ||
| 37 : | { | ||
| 38 : | RexLegacyPrimData obj = new RexLegacyPrimData(); | ||
| 39 : | ICriteria criteria = manager.GetSession().CreateCriteria(typeof(RexLegacyPrimData)); | ||
| 40 : | |||
| 41 : | List<RexLegacyPrimData> rexprimdata = (List<RexLegacyPrimData>)criteria.List<RexLegacyPrimData>(); | ||
| 42 : | return rexprimdata; | ||
| 43 : | } | ||
| 44 : | catch (Exception e) | ||
| 45 : | { | ||
| 46 : | m_log.WarnFormat("[NHIBERNATE]: Failed loading legacy RexPrimData. Exception {0} ", e); | ||
| 47 : | return new List<RexLegacyPrimData>(); | ||
| 48 : | } | ||
| 49 : | } | ||
| 50 : | |||
| 51 : | public List<RexLegacyPrimMaterialData> LoadAllRexPrimMaterialData() | ||
| 52 : | { | ||
| 53 : | try | ||
| 54 : | { | ||
| 55 : | RexLegacyPrimMaterialData obj = new RexLegacyPrimMaterialData(); | ||
| 56 : | ICriteria criteria = manager.GetSession().CreateCriteria(typeof(RexLegacyPrimMaterialData)); | ||
| 57 : | |||
| 58 : | List<RexLegacyPrimMaterialData> rexprimmaterialdata = (List<RexLegacyPrimMaterialData>)criteria.List<RexLegacyPrimMaterialData>(); | ||
| 59 : | return rexprimmaterialdata; | ||
| 60 : | } | ||
| 61 : | catch (Exception e) | ||
| 62 : | { | ||
| 63 : | m_log.WarnFormat("[NHIBERNATE]: Failed loading legacy RexPrimMaterialData. Exception {0} ", e); | ||
| 64 : | return new List<RexLegacyPrimMaterialData>(); | ||
| 65 : | } | ||
| 66 : | } | ||
| 67 : | } | ||
| 68 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

