Esempio n. 1
0
 public void GearMap_Simple_Test()
 {
     UnitOfWork unitOfWork = new UnitOfWork(NHibernateHelper.SessionFactory);
     Repository repo = new Repository(unitOfWork.Session);
     List<Gear> list = repo.GetAll<Gear>().ToList();
     Assert.AreEqual(6, list.Count);
     unitOfWork.Rollback();
 }
Esempio n. 2
0
 public void SourceDataTypeMap_TufmanFM_GearPS_ReturnsLogsheetDataType()
 {
     UnitOfWork unitOfWork = new UnitOfWork(NHibernateHelper.SessionFactory);
     Repository repo = new Repository(unitOfWork.Session);
     List<SourceDataType> sourceDataTypes = repo.Find<SourceDataType>(x => x.Gear.Code == "S" && x.Source.Id == 12).ToList();
     repo.GetAll<Gear>();
     Assert.IsNotNull(sourceDataTypes);
     Assert.IsTrue(sourceDataTypes.Count == 1);
     Assert.IsTrue(sourceDataTypes[0].DataType.Id==1);
 }
Esempio n. 3
0
        protected MvcApplication()
        {
            // This configures the unit or work to be on a per request basis.

            BeginRequest += delegate
            {
                UnitOfWork = new UnitOfWork(_sessionFactory);
            };
            EndRequest += delegate
            {
                if (UnitOfWork != null)
                {
                    // Notice that we are rolling back unless
                    //    an explicit call to commit was made elsewhere.
                    //
                    UnitOfWork.Dispose();
                }
            };
        }
Esempio n. 4
0
        public PillboxViewModel GetVessels()
        {
            List<System.Collections.DictionaryEntry> vesselList;

            ISessionFactory sessionFactory = DynamicNHibernateHelper.CreateSessionFactory(String.Format("Server={0};Database={1};Trusted_Connection=True", Source.Server, Source.Database));
            UnitOfWork unit = new UnitOfWork(sessionFactory);
            Repository repo = new Repository(unit.Session);
            IQuery query;
            string tablename;

            PillboxViewModel pillBox = new PillboxViewModel();
            pillBox.ModuleName = "Vessels";
            pillBox.HasImages = false;

            // gets the list of vessels from the trips table
            switch (Gear.Code)
            {
                case "P":
                    tablename = "TripsPL";
                    break;
                case "S":
                    tablename = "TripsPS";

                    break;
                default:    // make LL the default
                    tablename = "TripsLL";
                    break;
            }
            query = unit.Session.CreateQuery("Select distinct v.vessel_id,v.vessel_name from " + tablename + " as t inner join t.vessels as v order by v.vessel_name");
            vesselList = (from object[] x in query.List()
                        select new System.Collections.DictionaryEntry { Key = x[0], Value = x[1] }).ToList();

            foreach (System.Collections.DictionaryEntry vessel in vesselList)
                pillBox.PillboxValues.Add(vessel.Key.ToString(), vessel.Value.ToString());

            pillBox.GroupingList = new List<SelectListItem>();
            pillBox.GroupingList.Add(new SelectListItem() { Value = "AllVessels", Text = "All vessels combined" });
            pillBox.GroupingList.Add(new SelectListItem() { Value = "Vessel", Text = "Vessel" });
            return pillBox;
        }
Esempio n. 5
0
        public PillboxViewModel GetSpecies()
        {
            List<System.Collections.DictionaryEntry> speciesList;

            ISessionFactory sessionFactory = DynamicNHibernateHelper.CreateSessionFactory(String.Format("Server={0};Database={1};Trusted_Connection=True", Source.Server, Source.Database));
            UnitOfWork unit = new UnitOfWork(sessionFactory);
            Repository repo = new Repository(unit.Session);
            IQuery query;
            string tablename;

            PillboxViewModel pillBox = new PillboxViewModel();
            pillBox.ModuleName = "Species";
            pillBox.HasImages = false;

            //pillBox.PillboxValues.Add("ALB", "Albacore (ALB)");
            //pillBox.PillboxValues.Add("BET", "Bigeye (BET)");
            //pillBox.PillboxValues.Add("SKJ", "Skipjack (SKJ)");
            //pillBox.PillboxValues.Add("YFT", "Yellowfin (YFT)");

            switch (Gear.Code)
            {
                case "P":
                    tablename = "CatchPL";
                    break;
                case "S":
                    tablename = "CatchPS";
                    break;
                default:    // make LL the default
                    tablename = "CatchLL";
                    break;
            }
            //speciesList = repo.GetAll<CatchLL>().Select(x => new System.Collections.DictionaryEntry { Key = x.species.sp_code, Value = x.species.sp_name }).Distinct().OrderBy(x => x.Value).ToList();
            query = unit.Session.CreateQuery("Select distinct s.sp_code,s.sp_name from " + tablename + " as c inner join c.species as s order by s.sp_name");
            speciesList = (from object[] x in query.List()
                        select new System.Collections.DictionaryEntry { Key = x[0], Value = x[1] }).ToList();

            foreach (System.Collections.DictionaryEntry species in speciesList)
                pillBox.PillboxValues.Add(species.Key.ToString(), species.Value.ToString());

            pillBox.GroupingList = new List<SelectListItem>();
            pillBox.GroupingList.Add(new SelectListItem() { Value = "AllSpecies", Text = "All species combined" });
            pillBox.GroupingList.Add(new SelectListItem() { Value = "Species", Text = "Species" });
            return (pillBox);
        }
Esempio n. 6
0
        public PillboxViewModel GetFlags()
        {
            List<System.Collections.DictionaryEntry> flagList;

            ISessionFactory sessionFactory = DynamicNHibernateHelper.CreateSessionFactory(String.Format("Server={0};Database={1};Trusted_Connection=True", Source.Server, Source.Database));
            UnitOfWork unit = new UnitOfWork(sessionFactory);
            Repository repo = new Repository(unit.Session);
            IQuery query;
            string tablename;

            PillboxViewModel pillBox = new PillboxViewModel();
            pillBox.ModuleName = "VesselFlag";
            pillBox.HasImages = true;
            pillBox.ImagePath = "~/Content/images/flags/";

            // gets the list of flags from the trips table
            switch (Gear.Code)
            {
                case "P":
                    //flagList = repo.GetAll<TripsPL>().Select(x => new System.Collections.DictionaryEntry { Key = x.vessels.flag_code, Value = x.vessels.flag_country.country_name }).Distinct().OrderBy(x => x.Value).ToList();
                    tablename = "TripsPL";
                    break;
                case "S":
                    tablename = "TripsPS";

                    break;
                default:    // make LL the default
                    tablename = "TripsLL";
                    break;
            }
            query = unit.Session.CreateQuery("Select distinct c.country_code,c.country_name from " + tablename + " as t inner join t.vessels as v inner join v.flag_country c order by c.country_name");
            flagList = (from object[] x in query.List()
                        select new System.Collections.DictionaryEntry { Key = x[0], Value = x[1] }).ToList();

            foreach (System.Collections.DictionaryEntry flag in flagList)
                pillBox.PillboxValues.Add(flag.Key.ToString(),flag.Value.ToString());

            pillBox.GroupingList = new List<SelectListItem>();
            pillBox.GroupingList.Add(new SelectListItem() { Value = "AllFlag", Text = "All flags combined" });
            pillBox.GroupingList.Add(new SelectListItem() { Value = "Flag", Text = "Flag" });
            return pillBox;
        }