public void CreateManyPlaces(int count)
        {
            Random r = new Random();
            ManagedSecurityContext sec = ManagedAccount.GetAdminSecurityContext(Session);

            // country
            TransitCountry t_country = new TransitCountry();

            t_country.Name = Guid.NewGuid().ToString();
            ManagedCountry country = new ManagedCountry(Session);

            country.CreateOrUpdate(t_country, sec);
            // state
            TransitState t_state = new TransitState();

            t_state.Name    = Guid.NewGuid().ToString();
            t_state.Country = t_country.Name;
            ManagedState state = new ManagedState(Session);

            state.CreateOrUpdate(t_state, sec);
            // city
            TransitCity t_city = new TransitCity();

            t_city.Name    = Guid.NewGuid().ToString();
            t_city.State   = t_state.Name;
            t_city.Country = t_country.Name;
            ManagedCity city = new ManagedCity(Session);

            city.CreateOrUpdate(t_city, sec);
            // place type
            TransitPlaceType t_placetype = new TransitPlaceType();

            t_placetype.Name = Guid.NewGuid().ToString();
            ManagedPlaceType placetype = new ManagedPlaceType(Session);

            placetype.CreateOrUpdate(t_placetype, sec);

            for (int i = 0; i < count; i++)
            {
                TransitPlace t_place = new TransitPlace();
                t_place.Name      = Guid.NewGuid().ToString();
                t_place.AccountId = sec.Account.Id;
                t_place.City      = t_city.Name;
                t_place.Country   = t_country.Name;
                t_place.State     = t_state.Name;
                t_place.Street    = string.Format("{0} {1} St.", r.Next(), Guid.NewGuid().ToString());
                t_place.Zip       = r.Next().ToString();
                t_place.Type      = t_placetype.Name;

                ManagedPlace place = new ManagedPlace(Session);
                place.CreateOrUpdate(t_place, sec);
            }
        }
Example #2
0
        public void CreateManyPlaces(int count)
        {
            Random r = new Random();
            ManagedSecurityContext sec = ManagedAccount.GetAdminSecurityContext(Session);

            // country
            TransitCountry t_country = new TransitCountry();
            t_country.Name = Guid.NewGuid().ToString();
            ManagedCountry country = new ManagedCountry(Session);
            country.CreateOrUpdate(t_country, sec);
            // state
            TransitState t_state = new TransitState();
            t_state.Name = Guid.NewGuid().ToString();
            t_state.Country = t_country.Name;
            ManagedState state = new ManagedState(Session);
            state.CreateOrUpdate(t_state, sec);
            // city
            TransitCity t_city = new TransitCity();
            t_city.Name = Guid.NewGuid().ToString();
            t_city.State = t_state.Name;
            t_city.Country = t_country.Name;
            ManagedCity city = new ManagedCity(Session);
            city.CreateOrUpdate(t_city, sec);
            // place type
            TransitPlaceType t_placetype = new TransitPlaceType();
            t_placetype.Name = Guid.NewGuid().ToString();
            ManagedPlaceType placetype = new ManagedPlaceType(Session);
            placetype.CreateOrUpdate(t_placetype, sec);

            for (int i = 0; i < count; i++)
            {
                TransitPlace t_place = new TransitPlace();
                t_place.Name = Guid.NewGuid().ToString();
                t_place.AccountId = sec.Account.Id;
                t_place.City = t_city.Name;
                t_place.Country = t_country.Name;
                t_place.State = t_state.Name;
                t_place.Street = string.Format("{0} {1} St.", r.Next(), Guid.NewGuid().ToString());
                t_place.Zip = r.Next().ToString();
                t_place.Type = t_placetype.Name;

                ManagedPlace place = new ManagedPlace(Session);
                place.CreateOrUpdate(t_place, sec);
            }
        }
Example #3
0
 public void MergePlaces(string ticket, int id, TransitPlace target)
 {
     using (SnCore.Data.Hibernate.Session.OpenConnection())
     {
         ISession session = SnCore.Data.Hibernate.Session.Current;
         ITransaction t = session.BeginTransaction();
         try
         {
             ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket);
             // update all contents of the target
             ManagedPlace m_target = new ManagedPlace(session);
             m_target.CreateOrUpdate(target, sec);
             // merge child items
             m_target.Merge(sec, id);
             SnCore.Data.Hibernate.Session.Flush();
             t.Commit();
         }
         catch
         {
             t.Rollback();
             throw;
         }
     }
 }