public static void SaveBuilding(string type, bool hasWindows, bool isIndustrial, int id = 0)
        {
            Building building;
            var      sessionFactory = SessionFactory.CreateSessionFactory();


            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    if (id != 0)
                    {
                        building = new Building
                        {
                            Id           = id,
                            Type         = type,
                            HasWindows   = hasWindows,
                            IsIndustrial = isIndustrial
                        };
                    }
                    else
                    {
                        building = new Building
                        {
                            Type         = type,
                            HasWindows   = hasWindows,
                            IsIndustrial = isIndustrial
                        };
                    }
                    session.SaveOrUpdate(building);
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 2
0
        public static List <CityModel> GetCity()
        {
            var cityModelsList = new List <CityModel>();
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (session.BeginTransaction())
                {
                    var CityCreate = session.CreateCriteria(typeof(City))
                                     .List <City>();

                    foreach (var cit in CityCreate)
                    {
                        var temp = new CityModel()
                        {
                            Id           = cit.Id,
                            Name         = cit.Name,
                            Population   = cit.Population,
                            CountryModel = new CountryModel
                            {
                                Id = cit.Country.Id,
                            }
                        };

                        cityModelsList.Add(temp);
                    }

                    return(cityModelsList);
                }
            }
        }
Exemplo n.º 3
0
        public static void SaveCountry(string name, string continent, int id = 0)
        {
            Country country;

            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    if (id != 0)
                    {
                        country = new Country
                        {
                            Id        = id,
                            Name      = name,
                            Continent = continent
                        };
                    }
                    else
                    {
                        country = new Country
                        {
                            Name      = name,
                            Continent = continent
                        };
                    }
                    session.SaveOrUpdate(country);
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 4
0
        public static List <PlaceModel> GetPlace()
        {
            var placeModelsList = new List <PlaceModel>();
            var sessionFactory  = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (session.BeginTransaction())
                {
                    var PlaceCreate = session.CreateCriteria(typeof(Place))
                                      .List <Place>();

                    foreach (var pla in PlaceCreate)
                    {
                        var temp = new PlaceModel()
                        {
                            Id              = pla.Id,
                            Street          = pla.Street,
                            PlacePopulation = pla.PlacePopulation,
                            CityModel       = new CityModel {
                                Id = pla.City.Id
                            },
                            BuildingModel = new BuildingModel {
                                Id = pla.Building.Id
                            }
                        };

                        placeModelsList.Add(temp);
                    }

                    return(placeModelsList);
                }
            }
        }
Exemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var connectionString = this.Configuration.GetConnectionString("ConnectionString");

            var sessionFactory = SessionFactory.CreateSessionFactory(connectionString, typeof(Startup).Assembly);

            services.AddSingleton <ISessionFactory>(sessionFactory);
            services.AddScoped <ISession>(s => sessionFactory.OpenSession());
            services.AddScoped(typeof(ISession <>), typeof(UnitOfWork <>));
            services.AddScoped <IEstadoRepository, EstadoRepository>();
            services.AddScoped <IPessoaRepository, PessoaRepository>();
            services.AddScoped <ICovid19Repository, Covid19Repository>();

            services.AddMemoryCache();

            services.AddCors(c =>
            {
                c.AddDefaultPolicy(p =>
                {
                    p.AllowAnyOrigin();
                    p.AllowAnyHeader();
                    p.AllowAnyMethod();
                });
            });


            services.AddControllers();
            services.AddApplicationInsightsTelemetry();
        }
        public static void SavePresident()
        {
            var countryModelsList = new List <CountryModel>();
            var sessionFactory    = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    if (true)
                    {
                        var country = new Country
                        {
                            Id        = 1,
                            Name      = "Polska",
                            Continent = "Europa"
                        };



                        session.SaveOrUpdate(country);
                        transaction.Commit();
                    }
                }
            }
        }
Exemplo n.º 7
0
        public static void SavePresident(string name, int age, int id)
        {
            President president;

            var countryModelsList = new List <CountryModel>(); //co tu robi Country model ??
            var sessionFactory    = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    president = new President
                    {
                        Name    = name,
                        Age     = age,
                        Country = new Country()
                        {
                            Id = id
                        }
                    };


                    session.SaveOrUpdate(president);
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 8
0
        public ActionResult Install(string check)
        {
            SessionFactory CreateSession = new SessionFactory();
            CreateSession.CreateSessionFactory<PostMapping>();

            return RedirectToAction("Create");
        }
        public static List <PresidentModel> GetPresident()
        {
            var presidentModelsList = new List <PresidentModel>();
            var sessionFactory      = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (session.BeginTransaction())
                {
                    var PresidentCreate = session.CreateCriteria(typeof(President))
                                          .List <President>();

                    foreach (var con in PresidentCreate)
                    {
                        var temp = new PresidentModel()
                        {
                            Id   = con.Id,
                            Name = con.Name,
                            Age  = con.Age,
                        };

                        presidentModelsList.Add(temp);
                    }

                    return(presidentModelsList);
                }
            }
        }
Exemplo n.º 10
0
        public static void SaveCity(string name, int population, int id = 0)
        {
            City city;
            var  countryModelsList = new List <CountryModel>();
            var  sessionFactory    = SessionFactory.CreateSessionFactory();


            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    if (id != 0)
                    {
                        city = new City
                        {
                            Id         = id,
                            Name       = name,
                            Population = population,
                            Country    = new Country {
                                Id = id
                            }
                        };
                    }
                    else
                    {
                        city = new City
                        {
                            Name = name,
                        };
                    }
                    session.SaveOrUpdate(city);
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 11
0
        private void EditCustomer(int customerID)
        {
            grpNewCustomer.Visible             = true;
            CreateNewCustomerLinkLabel.Visible = false;

            var session = SessionFactory.CreateSessionFactory().GetCurrentSession();
            var query   = from cust in session.Query <Model.Customer>()
                          where cust.CustomerId == customerID
                          select cust;

            if (query.Any())
            {
                var customer = query.Single();
                testCustomer  = customer;
                otherCustomer = customer;
                customerBindingSource.DataSource = customer;
                grpNewCustomer.Text = "Editing customer " + customer.FullName;

                /*
                 *
                 * txtCustomersNewCity.Text = customer.City;
                 * cbxCustomersNewState.Text = customer.State;
                 * cbxNewCustomerTitle.Text = customer.Title;
                 * txtCustomersNewFirstName.Text = customer.FirstName;
                 * txtCustomersNewLastName.Text = customer.LastName;
                 * txtCustomersNewStreetAddress.Text = customer.StreetAddress;
                 * txtCustomersNewZip.Text = customer.ZipCode.Code;
                 * txtCustomersNewPhone.Text = customer.PhoneNumber;
                 * txtBoxNewCustomersPassword.Text = customer.Password;
                 * txtBoxNewCustomerConfirmedPassword.Text = customer.Password;
                 */
            }
        }
Exemplo n.º 12
0
        private void txtBoxCustomerZipCode_Leave(object sender, EventArgs e)
        {
            if (isValidZipCode(txtCustomersNewZip.Text))
            {
                string zipCodeString = txtCustomersNewZip.Text.ToString();
                var    session       = SessionFactory.CreateSessionFactory().GetCurrentSession();
                var    query         = from zip in session.Query <Model.ZipCode>()
                                       where zip.Code.Equals(zipCodeString)
                                       select zip;


                if (query.Any())
                {
                    var zipCode = query.Single();
                    txtCustomersNewCity.Text  = zipCode.City;
                    cbxCustomersNewState.Text = zipCode.State;
                    saveZipCode = false;
                }
                else
                {
                    NewZipCodeForm zipCodeForm = new NewZipCodeForm(txtCustomersNewZip.Text.ToString());
                    zipCodeForm.ShowDialog();
                    txtCustomersNewCity.Text  = zipCodeForm.city;
                    cbxCustomersNewState.Text = zipCodeForm.state;
                    saveZipCode = true;
                }
            }

            newCustomerTextField_TextChanged(sender, e);
            txtReportZipCode_Leave(sender, e);
        }
Exemplo n.º 13
0
        public RentalForm(Customer chosenCustomer, bool isAll)
        {
            InitializeComponent();
            var session = SessionFactory.CreateSessionFactory().GetCurrentSession();

            if (isAll)
            {
                var query = from rent in session.Query <Model.Rental>()
                            join rentVideo in session.Query <Model.Video>() on rent.Video.VideoId equals rentVideo.VideoId
                            join rentMovie in session.Query <Model.Movie>() on rentVideo.Movie.MovieId equals rentMovie.MovieId
                            where rental.Customer.CustomerId == chosenCustomer.CustomerId
                            select new { rentMovie.Title, rental.RentalDate, rental.DueDate, rental.ReturnDate };
                dGVRentalForm.DataSource = query.ToList();
            }
            else
            {
                var query = from rent in session.Query <Model.Rental>()
                            join rentVideo in session.Query <Model.Video>() on rent.Video.VideoId equals rentVideo.VideoId
                            join rentMovie in session.Query <Model.Movie>() on rentVideo.Movie.MovieId equals rentMovie.MovieId
                            where rental.Customer.CustomerId == chosenCustomer.CustomerId && (rental.ReturnDate == null)
                            select new { rentMovie.Title, rental.RentalDate, rental.DueDate, rental.ReturnDate };
                dGVRentalForm.DataSource = query.ToList();
            }


            dGVRentalForm.Columns[0].HeaderText = "Movie Title";
            dGVRentalForm.Columns[1].HeaderText = "Rental Date";
            dGVRentalForm.Columns[2].HeaderText = "Due Date";
            dGVRentalForm.Columns[3].HeaderText = "Return Date";
        }
Exemplo n.º 14
0
        public static List <BuildingModel> GetBuilding()
        {
            var buildingModelsList = new List <BuildingModel>();
            var sessionFactory     = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (session.BeginTransaction())
                {
                    var BuildingCreate = session.CreateCriteria(typeof(Building))
                                         .List <Building>();

                    foreach (var bui in BuildingCreate)
                    {
                        var temp = new BuildingModel()
                        {
                            Id           = bui.Id,
                            Type         = bui.Type,
                            HasWindows   = bui.HasWindows,
                            IsIndustrial = bui.IsIndustrial,
                        };

                        buildingModelsList.Add(temp);
                    }

                    return(buildingModelsList);
                }
            }
        }
Exemplo n.º 15
0
        public static List <CountryModel> GetCountry()
        {
            var countryModelsList = new List <CountryModel>();
            var sessionFactory    = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (session.BeginTransaction())
                {
                    var CountryCreate = session.CreateCriteria(typeof(Country))
                                        .List <Country>();

                    foreach (var con in CountryCreate)
                    {
                        var temp = new CountryModel()
                        {
                            Id        = con.Id,
                            Name      = con.Name,
                            Continent = con.Continent,
                        };

                        countryModelsList.Add(temp);
                    }

                    return(countryModelsList);
                }
            }
        }
        public BotServiceSessionFactory(ILogger logger)
        {
            var types = new List <Type>();

            types.AddRange(typeof(GameMapping).Assembly.GetTypes());

            _sessionFactory = SessionFactory <CallSessionContext> .CreateSessionFactory("systemDb", types, logger);
        }
Exemplo n.º 17
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ISessionFactory session = SessionFactory.CreateSessionFactory(); //NOT SURE. Ask McFall

            Application.Run(new LoginForm());
        }
Exemplo n.º 18
0
        //private Config(System.IO.Stream stream)
        //{
        //    throw new NotImplementedException("Error en Engine.Config.Config(System.IO.Stream stream). HZ: este metodo se usa para cargar la configuracion desde un XML. Reemplazar por el DAL");
        //table = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
        //tagStack = new System.Collections.ArrayList();

        //try
        //{
        //    //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
        //    XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
        //    //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
        //    //UPGRADE_TODO: Constructor 'java.io.InputStreamReader.InputStreamReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioInputStreamReaderInputStreamReader_javaioInputStream_javalangString'"
        //    System.IO.StreamReader r = new System.IO.StreamReader(stream, System.Text.Encoding.GetEncoding("iso-8859-1"));
        //    parser.setContentHandler(this);
        //    parser.parse(new XmlSourceSupport(r));
        //}
        ////UPGRADE_ISSUE: Class 'javax.xml.parsers.ParserConfigurationException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxxmlparsersParserConfigurationException'"
        //catch (javax.xml.parsers.ParserConfigurationException err)
        //{
        //    System.Console.Out.WriteLine("Error while parsing XML in fixtures.xml file");
        //    SupportClass.WriteStackTrace(err, Console.Error);
        //}
        ////UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
        //catch (System.Xml.XmlException err)
        //{
        //    System.Console.Out.WriteLine("Error while parsing XML in league.xml");
        //    SupportClass.WriteStackTrace(err, Console.Error);
        //}
        //catch (System.IO.IOException err)
        //{
        //    System.Console.Out.WriteLine("Error while reading file league.xml");
        //    SupportClass.WriteStackTrace(err, Console.Error);
        //}
        //setDefaults();
        //}

        private Config()
        {
            //throw new NotImplementedException("Error en Engine.Config.Config(string fileName). HZ: este metodo se usa para cargar la configuracion desde un XML. Reemplazar por el DAL");
            //table = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
            //tagStack = new System.Collections.ArrayList();

            //try
            //{
            //    //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            //    XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
            //    //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
            //    //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            //    System.IO.StreamReader r = new System.IO.StreamReader(fileName, System.Text.Encoding.Default);
            //    parser.setContentHandler(this);
            //    parser.parse(new XmlSourceSupport(r));
            //}
            ////UPGRADE_ISSUE: Class 'javax.xml.parsers.ParserConfigurationException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxxmlparsersParserConfigurationException'"
            //catch (javax.xml.parsers.ParserConfigurationException err)
            //{
            //    System.Console.Out.WriteLine("Error while parsing XML in fixtures.xml file");
            //    SupportClass.WriteStackTrace(err, Console.Error);
            //}
            ////UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            //catch (System.Xml.XmlException err)
            //{
            //    System.Console.Out.WriteLine("Error while parsing XML in league.xml");
            //    SupportClass.WriteStackTrace(err, Console.Error);
            //}
            //catch (System.IO.IOException err)
            //{
            //    System.Console.Out.WriteLine("Error while reading file league.xml");
            //    SupportClass.WriteStackTrace(err, Console.Error);
            //}
            //setDefaults();

            var sessionFactory = SessionFactory.CreateSessionFactory();

            // Cargo la configuracion de la liga (reemplaza a Config.loadConfig("league.xml") y
            // lo respectivo a buscar valores de configuracion
            // TODO: aca le asigno la liga de incide 0, hay que ver como quedaría, si se puede hacer la
            // liga activa, etc.
            IList <League> Ligas;

            using (var session = sessionFactory.OpenSession())
            {
                // retreive all stores and display them
                using (session.BeginTransaction())
                {
                    Ligas          = session.CreateCriteria(typeof(League)).List <League>();
                    _LigaSingleton = Ligas[0];

                    //foreach (var liga in Ligas)
                    //{
                    //    WriteStorePretty(liga);
                    //}
                }
            }
        }
Exemplo n.º 19
0
        public UnitOfWork()
        {
            var sessionFactory = new SessionFactory();

            if (Session == null)
            {
                Session = sessionFactory.CreateSessionFactory().OpenSession();
            }
        }
Exemplo n.º 20
0
        public Model Load(int id)
        {
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    return(session.Query <Model>().Single(m => m.Id == id));
                }
        }
Exemplo n.º 21
0
        public static void DeleteAllCoutry(int id)
        {
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (session.BeginTransaction())
                {
                    var CityCreate      = session.CreateCriteria(typeof(City)).List <City>();
                    var CountryCreate   = session.CreateCriteria(typeof(Country)).List <Country>();
                    var PresidentCreate = session.CreateCriteria(typeof(President)).List <President>();
                    var PlaceCreate     = session.CreateCriteria(typeof(Place)).List <Place>();
                    var BuildingCreate  = session.CreateCriteria(typeof(Building)).List <Building>();


                    IEnumerable <City> ListIdCity = CityCreate.Where(x => x.Country.Id == id);

                    foreach (var c in ListIdCity)
                    {
                        IEnumerable <Place> ListaIdPlace = PlaceCreate.Where(x => x.City.Id == c.Id);

                        foreach (var d in ListaIdPlace)
                        {
                            foreach (var e in BuildingCreate)
                            {
                                if (d.Building.Id == e.Id)
                                {
                                    session.Delete(e);
                                }
                            }
                            session.Delete(d);
                        }

                        session.Delete(c);
                    }
                    foreach (var p in PresidentCreate)
                    {
                        if (p.Id == id)
                        {
                            session.Delete(p);
                        }
                    }
                    foreach (var e in CountryCreate)
                    {
                        if (e.Id == id)
                        {
                            session.Delete(e);
                        }
                    }

                    session.Transaction.Commit();
                }
            }
        }
Exemplo n.º 22
0
        public void Delete(MeasurementPoint measurementPoint)
        {
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    session.Delete(measurementPoint);
                    transaction.Commit();
                }
        }
Exemplo n.º 23
0
 public List <SongAndArtist> Search(string term)
 {
     using (ISessionFactory factory = SessionFactory.CreateSessionFactory())
     {
         using (var session = factory.OpenSession())
         {
             var matches = session.ProcedureList <object, SongAndArtist>("Music_SearchNameAndArtist", new { term });
             return(matches.ToList());
         }
     }
 }
        public static IServiceCollection AddRepository(this IServiceCollection services)
        {
            var sessionFactory = SessionFactory.CreateSessionFactory(Assembly.GetExecutingAssembly());

            services.AddSingleton <ISessionFactory>(sessionFactory);
            services.AddScoped <ISession>(s => sessionFactory.OpenSession());
            services.AddScoped(typeof(ISession <>), typeof(UnitOfWork <>));

            services.AddScoped <IAccountRepository, AccountRepository>();

            return(services);
        }
Exemplo n.º 25
0
        public MainForm()
        {
            InitializeComponent();
            regExNonEmpty    = new Regex("^\\s+$");
            regExZipCode     = new Regex("^\\d{5}(-\\d{4})?$");
            regExPhoneNumber = new Regex(@"^[1-9]\d{2}-[1-9]\d{2}-\d{4}$");
            var session = SessionFactory.CreateSessionFactory().GetCurrentSession();
            var query   = from title in session.Query <Model.Title>()
                          select title;

            cbxNewCustomerTitle.Items.AddRange(query.ToArray());
        }
Exemplo n.º 26
0
        public void VerifyPostInspectionsExist()
        {
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    var postInspections = session.Query <PostInspection>().ToList();
                    Assert.That(postInspections, Is.Not.Empty);
                    Assert.That(postInspections.All(x => x.Inspectors.Any()), Is.True);
                }
        }
Exemplo n.º 27
0
        public List <Model> LoadAll()
        {
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    return(session.Query <Model>().ToList());
                }
            }
        }
Exemplo n.º 28
0
        private void btnSelectCustomerSelect_Click(object sender, EventArgs e)
        {
            var session = SessionFactory.CreateSessionFactory().GetCurrentSession();
            var query   = from cust in session.Query <Model.Customer>()
                          where customer.CustomerId == Convert.ToInt32(dataGridView.CurrentRow.Cells[5].Value)
                          select customer;

            if (query.Any())
            {
                SelectedCustomer = (Customer)query.Single();
                Close();
            }
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                var catalogParser = new QuikPix.Core.Catalog.Parser.CatalogParser(session);

                using (var transaction = session.BeginTransaction())
                {
                    var catalog = catalogParser.ParseCatalog("full_catalog.xml");

                    //var genre1 = new Genre("1", "Genre 1");
                    //var genre2 = new Genre("2", "Genre 2");
                    //var genre3 = new Genre("3", "Genre 3");
                    //var genre4 = new Genre("4", "Genre 4");

                    //genre1.ChildGenres.Add(genre3);
                    //genre1.ChildGenres.Add(genre4);

                    //genre2.ChildGenres.Add(genre3);

                    //genre3.ParentGenres.Add(genre1);
                    //genre3.ParentGenres.Add(genre2);

                    //genre4.ParentGenres.Add(genre1);

                    //session.SaveOrUpdate(genre1);
                    //session.SaveOrUpdate(genre2);
                    //session.SaveOrUpdate(genre3);
                    //session.SaveOrUpdate(genre4);

                    //foreach (var title in catalog)
                    //{
                    //    Console.WriteLine(title.RegularTitle + ": " + string.Join(",", title.Genres.Select(x => x.Label).ToArray()));
                    //    session.SaveOrUpdate(title);
                    //}
                    //session.SaveOrUpdate(catalog.First());
                    try
                    {
                        transaction.Commit();
                    } catch (Exception ex)  {
                        throw ex;
                    }
                }

                //var g1 = session.Get<Genre>("1");
                //var g2 = session.Get<Genre>("3");
            }
            //Console.ReadKey();
        }
        private void btnScanCustomerBarCodeSelect_Click(object sender, EventArgs e)
        {
            var session = SessionFactory.CreateSessionFactory().GetCurrentSession();
            var query   = from cust in session.Query <Model.Customer>()
                          where cust.CustomerId.Equals(customerID.ElementAt(cbxScanCode.SelectedIndex))
                          select cust
            ;

            if (query.Any())
            {
                SelectedCustomer = query.Single();
                Close();
            }
        }
Exemplo n.º 31
0
        public MeasurementPoint Load(Guid id)
        {
            var sessionFactory = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    return
                        (session
                         .Query <MeasurementPoint>()
                         .FetchMany(x => x.Forecasts)
                         .Single(m => m.Id == id));
                }
        }