private Site GetSite(UniversalSearchIndexData indexData) { var item = indexData.UniversalSearchItem; var entity = _session.Get(item.SystemType, item.Id) as SiteEntity; return(entity == null || entity.Site == null ? _session.Get <Site>(_site.Id) : _session.Get <Site>(entity.Site.Id)); }
public SupplementCycleDefinition Create(IStatelessSession newSession, Profile profile) { var steryd = newSession.Get <Suplement>(new Guid("F099FF98-BB78-4E99-AFA3-EE0355974CD9")); var cycleDefinition = new SupplementCycleDefinition(); cycleDefinition.Profile = profile; cycleDefinition.Name = string.Format("Pojedyńcza substancja ({0})", Metenolon); cycleDefinition.Language = "pl"; cycleDefinition.Profile = profile; cycleDefinition.Difficult = TrainingPlanDifficult.Professional; cycleDefinition.CanBeIllegal = true; cycleDefinition.Status = PublishStatus.Published; cycleDefinition.PublishDate = DateTime.UtcNow; cycleDefinition.Purpose = WorkoutPlanPurpose.Mass; cycleDefinition.CreationDate = DateTime.UtcNow; cycleDefinition.Comment = "Ponieważ metenolon enantat jest anabolikiem o bardzo łagodnym działaniu można zażywać go spokojnie przez 16 tygodni. W tym okresie nastąpi powolny, równomierny przyrost mięśni w dobrej jakości, bez znacznego gromadzenia się wody. Przyrost ten pozostaje z reguły po odstawieniu. Substancja ta posiada wprawdzie tylko niewielkie działania uboczne wynikające z androgenności, jednak z czasem stają się one odczuwalne. Są to tłusta cera, trądzik i włosy na ciele. Typowym głównym skutkiem ubocznym jest zwiększone wypadanie włosów na głowie. Nie trzeba stosować dodatkowo substancji blokujących receptory estrogenowe lub aromatazę. Ponieważ metenolon enantat wpływa na własną produkcję hormonów tylko w zwiększonych dawkach w terapii po cyklu stosowania wystarcza zupełnie stosowanie przez cztery tygodnie Clomifenu lub Tamoxifenu Citrat. Stosowanie należy rozpocząć po około 5 dniach po ostatniej iniekcji według znanego schematu. W celu utrzymania siły można zrezygnować z Efedryny lub Clenbuterolu. Zaleca się jedynie stosowanie witaminy C i kwasu acetylosalicylowego, aby stłumić wartości kortyzolu. W tej fazie można stosować również Kreatynę, ale przede wszystkim ze względu na efekt powiększający komórki. "; cycleDefinition.Url = "http://nabierz-masy.com/przyklady-zastosowania?start=8"; newSession.Insert(cycleDefinition); SupplementCycleWeek week = new SupplementCycleWeek(); week.CycleWeekStart = 1; week.CycleWeekEnd = 1; cycleDefinition.Weeks.Add(week); week.Definition = cycleDefinition; newSession.Insert(week); SupplementCycleDosage dosage = new SupplementCycleDosage(); dosage.Dosage = 600; dosage.DosageType = DosageType.MiliGrams; dosage.Repetitions = SupplementCycleDayRepetitions.OnceAWeek; dosage.Name = Metenolon; dosage.Supplement = steryd; dosage.TimeType = TimeType.NotSet; week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); week = new SupplementCycleWeek(); week.CycleWeekStart = 2; week.CycleWeekEnd = 16; cycleDefinition.Weeks.Add(week); week.Definition = cycleDefinition; newSession.Insert(week); dosage = new SupplementCycleDosage(); dosage.Dosage = 300; dosage.DosageType = DosageType.MiliGrams; dosage.Repetitions = SupplementCycleDayRepetitions.OnceAWeek; dosage.Name = Metenolon; dosage.Supplement = steryd; dosage.TimeType = TimeType.NotSet; week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); return(cycleDefinition); }
public BatchCreationResult Create(IEnumerable <BatchJob> jobs) { DateTime now = CurrentRequestData.Now; // we need to make sure that the site is loaded from the correct session var site = _statelessSession.Get <Site>(_site.Id); var batch = new Batch { BatchJobs = new List <BatchJob>(), BatchRuns = new List <BatchRun>(), Site = site, CreatedOn = now, UpdatedOn = now }; _statelessSession.Transact(session => session.Insert(batch)); _statelessSession.Transact(session => { foreach (BatchJob job in jobs) { job.CreatedOn = now; job.UpdatedOn = now; job.Site = site; job.Batch = batch; batch.BatchJobs.Add(job); session.Insert(job); } }); BatchRun batchRun = _createBatchRun.Create(batch); batch.BatchRuns.Add(batchRun); _statelessSession.Transact(session => session.Update(batch)); return(new BatchCreationResult(batch, batchRun)); }
public TestResult GetTeamMemberByID(int id) { Stopwatch watch = new Stopwatch(); watch.Start(); TestResult result = new TestResult(); using (IStatelessSession session = NHibernateHelper.OpenStatelessSession()) { NHibernateModel.TeamMember teamMember = session.Get <NHibernateModel.TeamMember>(id); _ = new TeamMember() { ID = teamMember.Id, DateOfBirth = teamMember.DateOfBirth, FirstName = teamMember.FirstName, LastName = teamMember.LastName, TeamID = teamMember.TeamID }; } watch.Stop(); result.MemberCount = 1; result.Time = watch.ElapsedMilliseconds; return(result); }
public SupplementCycleDefinition Create(IStatelessSession newSession, Profile profile) { var kreatyna = newSession.Get <Suplement>(new Guid("296004cf-4f0d-4fa9-8897-2349f3f411d3")); var cycleDefinition = new SupplementCycleDefinition(); cycleDefinition.Profile = profile; cycleDefinition.Name = string.Format("Kreatyna mono - 2 porcje w dni treningowe"); cycleDefinition.Language = "pl"; cycleDefinition.Profile = profile; cycleDefinition.Difficult = TrainingPlanDifficult.Advanced; cycleDefinition.CanBeIllegal = false; cycleDefinition.Status = PublishStatus.Published; cycleDefinition.PublishDate = DateTime.UtcNow; cycleDefinition.Purpose = WorkoutPlanPurpose.Mass; cycleDefinition.CreationDate = DateTime.UtcNow; cycleDefinition.Comment = "Kreatyna mono - 2 porcje w dni treningowe, 1 porcja w dni nietreningowe"; newSession.Insert(cycleDefinition); SupplementCycleWeek trainingWeek = new SupplementCycleWeek(); trainingWeek.CycleWeekStart = 1; trainingWeek.CycleWeekEnd = 6; cycleDefinition.Weeks.Add(trainingWeek); trainingWeek.Definition = cycleDefinition; newSession.Insert(trainingWeek); SupplementCycleDosage dosage = new SupplementCycleDosage(); dosage.Dosage = 5; dosage.DosageType = DosageType.Grams; dosage.Supplement = kreatyna; dosage.Repetitions = SupplementCycleDayRepetitions.StrengthTrainingDay; dosage.TimeType = TimeType.OnEmptyStomach; trainingWeek.Dosages.Add(dosage); dosage.Week = trainingWeek; newSession.Insert(dosage); dosage = new SupplementCycleDosage(); dosage.Dosage = 5; dosage.DosageType = DosageType.Grams; dosage.Repetitions = SupplementCycleDayRepetitions.StrengthTrainingDay; dosage.Supplement = kreatyna; dosage.TimeType = TimeType.BeforeSleep; trainingWeek.Dosages.Add(dosage); dosage.Week = trainingWeek; newSession.Insert(dosage); dosage = new SupplementCycleDosage(); dosage.Dosage = 5; dosage.DosageType = DosageType.Grams; dosage.Repetitions = SupplementCycleDayRepetitions.NonTrainingDay; dosage.Supplement = kreatyna; dosage.TimeType = TimeType.OnEmptyStomach; trainingWeek.Dosages.Add(dosage); dosage.Week = trainingWeek; newSession.Insert(dosage); return(cycleDefinition); }
public void Refresh() { Paper paper; using (IStatelessSession ss = sessions.OpenStatelessSession()) { using (ITransaction tx = ss.BeginTransaction()) { paper = new Paper {Color = "whtie"}; ss.Insert(paper); tx.Commit(); } } using (IStatelessSession ss = sessions.OpenStatelessSession()) { using (ITransaction tx = ss.BeginTransaction()) { var p2 = ss.Get<Paper>(paper.Id); p2.Color = "White"; ss.Update(p2); tx.Commit(); } } using (IStatelessSession ss = sessions.OpenStatelessSession()) { using (ITransaction tx = ss.BeginTransaction()) { Assert.AreEqual("whtie", paper.Color); ss.Refresh(paper); Assert.AreEqual("White", paper.Color); ss.Delete(paper); tx.Commit(); } } }
public string ProcessAddresses(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { var addressData = dataReader.GetAddressData(); var site = _session.Get <Site>(_site.Id); _session.Transact(session => { foreach (var data in addressData) { var address = new Address { Address1 = data.Address1, Address2 = data.Address2, City = data.City, Company = data.Company, CountryCode = data.CountryCode, FirstName = data.FirstName, LastName = data.LastName, PhoneNumber = data.PhoneNumber, PostalCode = data.PostalCode, StateProvince = data.StateProvince, }; address.AssignBaseProperties(site); session.Insert(address); nopImportContext.AddEntry(data.Id, address); } }); return(string.Format("{0} addresses added", addressData.Count)); }
public string ProcessTags(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { HashSet <TagData> tagDatas = dataReader.GetTags(); var site = _session.Get <Site>(_site.Id); Dictionary <string, Tag> tags = _session.QueryOver <Tag>() .List().ToDictionary(x => x.Name); _session.Transact(session => { foreach (TagData tagData in tagDatas) { string name = tagData.Name.Trim(); Tag tag; if (!tags.ContainsKey(name)) { tag = new Tag { Name = name }; tag.AssignBaseProperties(site); session.Insert(tag); } else { tag = tags[name]; } nopImportContext.AddEntry(tagData.Id, tag); } }); return(string.Format("{0} tags processed", tagDatas.Count)); }
public void CreateUpdateReadDelete() { Document doc; DateTime?initVersion; using (IStatelessSession ss = sessions.OpenStatelessSession()) { ITransaction tx; using (tx = ss.BeginTransaction()) { doc = new Document("blah blah blah", "Blahs"); ss.Insert(doc); Assert.IsNotNull(doc.LastModified); initVersion = doc.LastModified; Assert.IsTrue(initVersion.HasValue); tx.Commit(); } Thread.Sleep(100); // Only to be secure that next modification have a different version using (tx = ss.BeginTransaction()) { doc.Text = "blah blah blah .... blah"; ss.Update(doc); Assert.IsTrue(doc.LastModified.HasValue); Assert.AreNotEqual(initVersion, doc.LastModified); tx.Commit(); } using (tx = ss.BeginTransaction()) { doc.Text = "blah blah blah .... blah blay"; ss.Update(doc); tx.Commit(); } var doc2 = ss.Get <Document>("Blahs"); Assert.AreEqual("Blahs", doc2.Name); Assert.AreEqual(doc.Text, doc2.Text); doc2 = (Document)ss.CreateQuery("from Document where text is not null").UniqueResult(); Assert.AreEqual("Blahs", doc2.Name); Assert.AreEqual(doc.Text, doc2.Text); doc2 = (Document)ss.CreateSQLQuery("select * from Document").AddEntity(typeof(Document)).UniqueResult(); Assert.AreEqual("Blahs", doc2.Name); Assert.AreEqual(doc.Text, doc2.Text); doc2 = ss.CreateCriteria <Document>().UniqueResult <Document>(); Assert.AreEqual("Blahs", doc2.Name); Assert.AreEqual(doc.Text, doc2.Text); doc2 = (Document)ss.CreateCriteria(typeof(Document)).UniqueResult(); Assert.AreEqual("Blahs", doc2.Name); Assert.AreEqual(doc.Text, doc2.Text); using (tx = ss.BeginTransaction()) { ss.Delete(doc); tx.Commit(); } } }
public static Result <T, string[]> GetAsResult <T>(this IStatelessSession session, object id) { var t = session.Get <T>(id); return(t != null ? Result <T, string[]> .Succeeded(t) : Result <T, string[]> .Failed(new[] { $"{typeof(T).Name} with ID {id} does not exist" })); }
///// <summary> ///// Closes the gateway to the data store. ///// </summary> ///// <remarks>This method disconnects the session and closes it.</remarks> //private void Close() //{ // if (!_isSessionCreator) // { // throw new InvalidOperationException( // "A gateway that is sharing the session of another gateway cannot be closed directly."); // } // if (_session == null) // { // return; // } // //if (_transaction != null) // //{ // // RollbackTransaction(); // //} // //if (_session.IsConnected) // //{ // // _session.Disconnect(); // //} // //if (_session.IsOpen) // //{ // _session.Close(); // //} //} ///// <summary> ///// Saves the given entity in the data store. ///// </summary> ///// <param name="entity">The entity to save.</param> ///// /// <remarks>The entity is not actually saved until the transaction is committed.</remarks> //public void Save(object entity) //{ // if (!this.IsOpen) // { // throw new InvalidOperationException("Repository must be open before an entity can be saved."); // } // if (_transaction == null) // { // throw new InvalidOperationException("Saves must be done within a transaction."); // } // _session.Save(entity); //} ///// <summary> ///// Updates the given entity in the data store. ///// </summary> ///// <param name="entity">The entity to update.</param> ///// /// <remarks>The entity is not actually updated until the transaction is committed.</remarks> //public void Update(object entity) //{ // if (!this.IsOpen) // { // throw new InvalidOperationException("Repository must be open before an entity can be updated."); // } // if (_transaction == null) // { // throw new InvalidOperationException("Updates must be done within a transaction."); // } // _session.Update(entity); //} ///// <summary> ///// Deletes an entity from the data store. ///// </summary> ///// <param name="entity">The entity to delete.</param> //public void Delete(object entity) //{ // if (!this.IsOpen) // { // throw new InvalidOperationException("Repository must be open before an entity can be deleted."); // } // if (_transaction == null) // { // throw new InvalidOperationException("Deletes must be done within a transaction."); // } // _session.Delete(entity); //} ///// <summary> ///// Begins an NHibernate transaction. ///// </summary> ///// <param name="isolationLevel"></param> ///// <returns></returns> //public void BeginTransaction(System.Data.IsolationLevel isolationLevel) //{ // if (!this.IsOpen) // { // throw new InvalidOperationException( // "Repository must be open before a transaction can be started on the gateway."); // } // if (_transaction == null) // { // _transaction = _session.BeginTransaction(isolationLevel); // } // //return _transaction; //} ///// <summary> ///// Begins an NHibernate transaction. ///// </summary> //public void BeginTransaction() //{ // //if (!_isSessionCreator) // //{ // // throw new InvalidOperationException( // // "A gateway that is sharing the session of another gateway cannot start a transaction on the shared session."); // //} // if (!this.IsOpen) // { // throw new InvalidOperationException( // "Repository must be open before a transaction can be started on the gateway."); // } // if (_transaction == null) // { // _transaction = _session.BeginTransaction(); // } // //return _transaction; //} ///// <summary> ///// Commits an NHibernate transaction. ///// </summary> //public void CommitTransaction() //{ // //if (!_isSessionCreator) // //{ // // throw new InvalidOperationException( // // "A gateway that is sharing the session of another gateway cannot commit a transaction on the shared session."); // //} // if (!this.IsOpen) // { // throw new InvalidOperationException("Repository must be open before a transaction can be committed."); // } // if (_transaction == null) // { // throw new InvalidOperationException("Repository must have an open transaction in order to commit."); // } // // Do the commit then kill the transaction // _transaction.Commit(); // _transaction = null; //} ///// <summary> ///// Rolls back an NHibernate transaction. ///// </summary> //public void RollbackTransaction() //{ // //if (!_isSessionCreator) // //{ // // throw new InvalidOperationException( // // "A gateway that is sharing the session of another gateway cannot roll back a transaction on the shared session."); // //} // if (!this.IsOpen) // { // throw new InvalidOperationException("Repository must be open before a transaction can be rolled back."); // } // if (_transaction != null) // { // // Do the rollback then kill the transaction // try // { // _transaction.Rollback(); // } // catch (Exception ex) // { // // no more method. // ExceptionProcess.ProcessWithResume(ex); // } // _transaction = null; // } //} /// <summary> /// 根据Id查找实体 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="id"></param> /// <returns></returns> public T Get <T>(object id) { if (!this.IsOpen) { throw new InvalidOperationException("Repository must be open before retrive data."); } return(_session.Get <T>(id)); }
public T Get(K key, IStatelessSession session) { if (session == null || session.IsConnected == false || session.IsOpen == false) { session = this.SessionFactory.OpenStatelessSession(); } return(session.Get <T>(key)); }
public virtual Thing VerifyThing() { Assert.That(statelessSession.Get <Thing>(thingId), Is.Not.Null); Assert.That(statelessSession.Transaction, Is.Not.Null); Assert.That(session.Transaction, Is.Not.Null); // for testing we need to make sure it's not just in the FLC. session.Clear(); return(session.Load <Thing>(thingId)); }
public virtual void DeleteStateless(int orderId) { using (IStatelessSession session = sessManager.OpenStatelessSession("db2")) { NUnit.Framework.Assert.IsNotNull(session.Transaction); var order = (Order)session.Get(typeof(Order).FullName, orderId); session.Delete(order); } }
public SupplementCycleDefinition Create(IStatelessSession newSession, Profile profile) { var bcaa = newSession.Get <Suplement>(new Guid("34a141f4-3448-4552-9ab7-1b2537f7da1a")); var cycleDefinition = new SupplementCycleDefinition(); cycleDefinition.Profile = profile; cycleDefinition.Name = string.Format("BCAA - 3 porcje w dni treningowe kardio i jedną porcję w DNT"); cycleDefinition.Language = "pl"; cycleDefinition.Profile = profile; cycleDefinition.Difficult = TrainingPlanDifficult.Beginner; cycleDefinition.CanBeIllegal = false; cycleDefinition.Status = PublishStatus.Published; cycleDefinition.PublishDate = DateTime.UtcNow; cycleDefinition.Purpose = WorkoutPlanPurpose.Mass; cycleDefinition.CreationDate = DateTime.UtcNow; cycleDefinition.Comment = "1g na 10kg masy ciała w porcji (mamy 3 porcje w dni treningowe kardio i jedną porcje w DNT)"; newSession.Insert(cycleDefinition); SupplementCycleWeek week = new SupplementCycleWeek(); week.CycleWeekStart = 1; week.CycleWeekEnd = 4; cycleDefinition.Weeks.Add(week); week.Definition = cycleDefinition; newSession.Insert(week); SupplementCycleDosage dosage = Helper.CreateDosage(1, BCAA, bcaa, SupplementCycleDayRepetitions.CardioTrainingDay, DosageType.Grams, TimeType.OnEmptyStomach); dosage.DosageUnit = DosageUnit.ON10KgWight; week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); dosage = Helper.CreateDosage(1, BCAA, bcaa, SupplementCycleDayRepetitions.CardioTrainingDay, DosageType.Grams, TimeType.BeforeWorkout); dosage.DosageUnit = DosageUnit.ON10KgWight; week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); dosage = Helper.CreateDosage(1, BCAA, bcaa, SupplementCycleDayRepetitions.CardioTrainingDay, DosageType.Grams, TimeType.AfterWorkout); dosage.DosageUnit = DosageUnit.ON10KgWight; week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); dosage = Helper.CreateDosage(1, BCAA, bcaa, SupplementCycleDayRepetitions.NonTrainingDay, DosageType.Grams, TimeType.OnEmptyStomach); dosage.DosageUnit = DosageUnit.ON10KgWight; week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); return(cycleDefinition); }
public BatchRun Create(Batch batch) { if (batch == null) { return(null); } BatchJob jobAlias = null; var subQuery = QueryOver.Of <BatchRunResult>() .Where(result => result.Status != JobExecutionStatus.Failed && result.BatchJob.Id == jobAlias.Id) .Select(result => result.Id); var jobs = _statelessSession.QueryOver(() => jobAlias) .Where(job => job.Batch.Id == batch.Id) .WithSubquery.WhereNotExists(subQuery) .List(); // we need to make sure that the site is loaded from the correct session var site = _statelessSession.Get <Site>(batch.Site.Id); return(_statelessSession.Transact(session => { var now = CurrentRequestData.Now; var batchRun = new BatchRun { Batch = batch, BatchRunResults = new List <BatchRunResult>(), Site = site, CreatedOn = now, UpdatedOn = now }; session.Insert(batchRun); for (int index = 0; index < jobs.Count; index++) { BatchJob batchJob = jobs[index]; var batchRunResult = new BatchRunResult { BatchJob = batchJob, Status = JobExecutionStatus.Pending, ExecutionOrder = index, BatchRun = batchRun, Site = site, CreatedOn = now, UpdatedOn = now }; batchRun.BatchRunResults.Add(batchRunResult); session.Insert(batchRunResult); } return batchRun; })); }
public void LogPageView(PageViewInfo info) { User user = _getCurrentUser.Get(); var site = _session.Get <Site>(_site.Id); DateTime now = CurrentRequestData.Now; AnalyticsUser analyticsUser = GetCurrentUser(user == null ? info.User : user.Guid); bool userIsNew = analyticsUser == null; if (userIsNew) { analyticsUser = new AnalyticsUser { User = user, CreatedOn = now, UpdatedOn = now, }; analyticsUser.SetGuid(info.User); _session.Insert(analyticsUser); } AnalyticsSession analyticsSession = GetCurrentSession(info.Session); bool sessionIsNew = analyticsSession == null; if (sessionIsNew) { analyticsSession = new AnalyticsSession { AnalyticsUser = analyticsUser, IP = _request.GetCurrentIP(), UserAgent = _request.UserAgent, Site = site, CreatedOn = now, UpdatedOn = now, }; analyticsSession.SetGuid(info.Session); _session.Insert(analyticsSession); } var pageView = new AnalyticsPageView { Webpage = GetWebpage(info.Url), Url = info.Url, AnalyticsSession = analyticsSession, Site = site, CreatedOn = now, UpdatedOn = now, }; _session.Insert(pageView); }
public object Get(Type theType, object id, LockMode lockMode) { if (_isStateless) { return(_wrapStateless.Get(theType.FullName, id, lockMode)); } else { return(_wrap.Get(theType, id, lockMode)); } }
/// <summary> /// Finds an object instance by an unique ID using IStatelessSession. /// </summary> /// <param name="type">The AR subclass type</param> /// <param name="id">ID value</param> /// <returns>The object instance.</returns> public object FindByIdStateless(Type type, object id) { using (IStatelessSession session = GetStatelessSession()) { try { return(session.Get(type.FullName, id)); } catch (ObjectNotFoundException) { throw; } catch (Exception ex) { throw new DataException("Could not perform FindByIdStateless for " + type.Name, ex); } } }
/// <summary> /// Gets object of given type from database with given id. /// Uses stateless session for efficiency. /// </summary> /// <param name="type">Type of the object.</param> /// <param name="id">Id of the object.</param> /// <returns>The object or null if object was not found.</returns> public object Get(Type type, Object id) { using (IStatelessSession session = sessionFactory.OpenStatelessSession()) { object obj = null; try { obj = session.Get(type.FullName, id); } catch (Exception e) { m_log.ErrorFormat("[NHIBERNATE] {0} of id {1} loading threw exception: " + e.ToString(), type.Name, id); } return(obj); } }
private void readTrainingEntries(IStatelessSession session, TrainingPlanDay day, XElement dayNode) { int position = 0; foreach (var entryNode in dayNode.Element("Entries").Descendants("Entry")) { TrainingPlanEntry entry = new TrainingPlanEntry(); day.Entries.Add(entry); entry.Position = position; entry.Day = day; entry.GlobalId = readGuid(entryNode, "GlobalId").Value; entriesMap.Add(readGuid(entryNode, "GlobalId").Value, entry); entry.Comment = readValue(entryNode, "Comment"); entry.Exercise = session.Get <Exercise>(readGuid(entryNode, "ExerciseId").Value); if (entry.Exercise == null) { entry.Exercise = deletedExercise; } entry.RestSeconds = readInt(entryNode, "RestSeconds").Value; position++; foreach (var setNode in entryNode.Element("Sets").Descendants("Set")) { TrainingPlanSerie set = new TrainingPlanSerie(); entry.Sets.Add(set); set.Entry = entry; set.Comment = readValue(setNode, "Comment"); set.GlobalId = readGuid(setNode, "GlobalId").Value; set.RepetitionNumberMax = readInt(setNode, "RepetitionNumberMax"); set.RepetitionNumberMin = readInt(setNode, "RepetitionNumberMin"); if (readValue(setNode, "RepetitionsType") == "NotSet") { set.RepetitionsType = SetType.Normalna; } else { set.RepetitionsType = readEnum <SetType>(setNode, "RepetitionsType"); } set.DropSet = readEnum <DropSetType>(setNode, "DropSet"); } } }
public SupplementCycleDefinition Create(IStatelessSession newSession, Profile profile) { var bcaa = newSession.Get <Suplement>(new Guid("34a141f4-3448-4552-9ab7-1b2537f7da1a")); var cycleDefinition = new SupplementCycleDefinition(); cycleDefinition.Profile = profile; cycleDefinition.Name = string.Format("BCAA 3 razy dziennie"); cycleDefinition.Language = "pl"; cycleDefinition.Profile = profile; cycleDefinition.Difficult = TrainingPlanDifficult.Beginner; cycleDefinition.CanBeIllegal = false; cycleDefinition.Status = PublishStatus.Published; cycleDefinition.PublishDate = DateTime.UtcNow; cycleDefinition.Purpose = WorkoutPlanPurpose.Mass; cycleDefinition.CreationDate = DateTime.UtcNow; cycleDefinition.Comment = "3 razy dziennie po 5 kapsułek-przed śniadaniem, przed treningiem i po treningu. W dni nietreningowe bierzemy takie same dawki w porach, w których zwykle mamy trening."; newSession.Insert(cycleDefinition); SupplementCycleWeek week = new SupplementCycleWeek(); week.CycleWeekStart = 1; week.CycleWeekEnd = 4; cycleDefinition.Weeks.Add(week); week.Definition = cycleDefinition; newSession.Insert(week); SupplementCycleDosage dosage = Helper.CreateDosage(5, BCAA, bcaa, SupplementCycleDayRepetitions.EveryDay, DosageType.Tablets, TimeType.OnEmptyStomach); week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); dosage = Helper.CreateDosage(5, BCAA, bcaa, SupplementCycleDayRepetitions.EveryDay, DosageType.Tablets, TimeType.BeforeWorkout); week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); dosage = Helper.CreateDosage(5, BCAA, bcaa, SupplementCycleDayRepetitions.EveryDay, DosageType.Tablets, TimeType.AfterWorkout); week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); return(cycleDefinition); }
public void InitId() { Paper paper; using (IStatelessSession ss = sessions.OpenStatelessSession()) { ITransaction tx; using (tx = ss.BeginTransaction()) { paper = new Paper {Color = "White"}; ss.Insert(paper); Assert.IsTrue(paper.Id != 0); tx.Commit(); } using (tx = ss.BeginTransaction()) { ss.Delete(ss.Get<Paper>(paper.Id)); tx.Commit(); } } }
public string ProcessSpecifications(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { var productSpecificationDatas = dataReader.GetProductSpecifications(); var site = _session.Get <Site>(_site.Id); _session.Transact(session => { foreach (ProductSpecificationData productSpecificationData in productSpecificationDatas) { var specificationAttribute = new ProductSpecificationAttribute { Name = productSpecificationData.Name, }; specificationAttribute.AssignBaseProperties(site); session.Insert(specificationAttribute); nopImportContext.AddEntry(productSpecificationData.Id, specificationAttribute); } }); return(string.Format("{0} product specifications processed", productSpecificationDatas.Count)); }
public string ProcessRegions(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { HashSet <RegionData> regionDatas = dataReader.GetRegionData(); var site = _session.Get <Site>(_site.Id); _session.Transact(session => { foreach (RegionData regionData in regionDatas) { var region = new Region { Name = regionData.Name, Country = nopImportContext.FindNew <Country>(regionData.CountryId) }; region.AssignBaseProperties(site); session.Insert(region); nopImportContext.AddEntry(regionData.Id, region); } }); return(string.Format("{0} regions processed", regionDatas.Count)); }
public string ProcessSpecificationAttributeOptions(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { var optionDatas = dataReader.GetProductSpecificationOptions(); var site = _session.Get <Site>(_site.Id); _session.Transact(session => { foreach (ProductSpecificationAttributeOptionData optionData in optionDatas) { var option = new ProductSpecificationAttributeOption { Name = optionData.Name, ProductSpecificationAttribute = nopImportContext.FindNew <ProductSpecificationAttribute>(optionData.ProductSpecificationId) }; option.AssignBaseProperties(site); session.Insert(option); nopImportContext.AddEntry(optionData.Id, option); } }); return(string.Format("{0} product specification attribute options processed", optionDatas.Count)); }
public string ProcessTaxRates(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { HashSet <TaxData> taxDatas = dataReader.GetTaxData(); var site = _session.Get <Site>(_site.Id); _session.Transact(session => { foreach (TaxData taxData in taxDatas) { var taxRate = new TaxRate { Name = taxData.Name, Percentage = taxData.Rate, }; taxRate.AssignBaseProperties(site); session.Insert(taxRate); nopImportContext.AddEntry(taxData.Id, taxRate); } }); return(string.Format("{0} tax rates processed", taxDatas.Count)); }
public string ProcessCountries(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { var countryDatas = dataReader.GetCountryData(); var site = _session.Get <Site>(_site.Id); _session.Transact(session => { foreach (CountryData countryData in countryDatas) { var country = new Country { Name = countryData.Name, ISOTwoLetterCode = countryData.IsoCode }; country.AssignBaseProperties(site); session.Insert(country); nopImportContext.AddEntry(countryData.Id, country); } }); return(string.Format("{0} countries processed", countryDatas.Count)); }
public string ProcessBrands(NopCommerceDataReader dataReader, NopImportContext nopImportContext) { HashSet <BrandData> brandDatas = dataReader.GetBrands(); var brands = _session.QueryOver <Brand>().List().ToDictionary(x => x.Name); var site = _session.Get <Site>(_site.Id); foreach (BrandData brandData in brandDatas) { string name = brandData.Name.Trim(); Brand brand; if (!brands.ContainsKey(name)) { brand = _getNewBrandPage.Get(name); brand.AssignBaseProperties(site); _session.Transact(session => session.Insert(brand)); } else { brand = brands[name]; } nopImportContext.AddEntry(brandData.Id, brand); } return(string.Format("{0} brands processed", brandDatas.Count)); }
public SupplementCycleDefinition Create(IStatelessSession newSession, Profile profile) { steryd = newSession.Get <Suplement>(new Guid("F099FF98-BB78-4E99-AFA3-EE0355974CD9")); var cycleDefinition = new SupplementCycleDefinition(); cycleDefinition.Profile = profile; cycleDefinition.Name = "Pojedyńczy Trenbolon"; cycleDefinition.Language = "pl"; cycleDefinition.Profile = profile; cycleDefinition.Difficult = TrainingPlanDifficult.Professional; cycleDefinition.CanBeIllegal = true; cycleDefinition.Status = PublishStatus.Published; cycleDefinition.PublishDate = DateTime.UtcNow; cycleDefinition.Purpose = WorkoutPlanPurpose.Mass; cycleDefinition.CreationDate = DateTime.UtcNow; cycleDefinition.Comment = "W USA trenbolon należy od pewnego czasu do hitów, ponieważ jest on silnie anaboliczny i ekstremalnie androgenny. Buduje on szybko i skutecznie czystą, twardą i suchą pod względem jakościowym muskulaturę, jak żaden inny steryd. Osiągany przyrost siły jest ogromny i to pomimo brakującego gromadzenia się wody. Poza tym uzyskana muskulatura nie znika nagle po odstawieniu, jak to ma miejsce często w przypadku Oxymetholonu, Metandienonu i Testosteronu w wysokich dawkach. Trenbolon potęguje również działanie innych hormonów i nadaje się bardzo dobrze jako stymulant IGF-1. Trenbolon jest jedyną substancją (pomijając hormon wzrostu), który powoduje u stosujących zwiększenie wagi ciała przy równoczesnej utracie tłuszczu, pod warunkiem, że odżywianie odbywa się w rozsądnych granicach a dawka proteiny wynosi 3 g na kg ciała dziennie. \r\n\r\nTrenbolonu ze względu na jego możliwą toksyczność nie należy stosować dłużej niż 8-10 tygodni. W każdym razie zaleca się intensywną terapię po cyklu stosowania, ponieważ substancja ta silnie tłumi własną produkcję hormonalną. Dużym problemem przy stosowaniu Trenbolonu jako substancji działającej pojedynczo jest jego wpływ na libido oraz zdolność erekcyjną penisa. Stosujący nie będzie w stanie prowadzić normalne współżycie seksualne. "; cycleDefinition.Url = "http://nabierz-masy.com/przyklady-zastosowania?start=12"; newSession.Insert(cycleDefinition); SupplementCycleWeek week = new SupplementCycleWeek(); week.CycleWeekStart = 1; week.CycleWeekEnd = 10; cycleDefinition.Weeks.Add(week); week.Definition = cycleDefinition; newSession.Insert(week); SupplementCycleDosage dosage = Helper.CreateDosage(100, Trenbolon, steryd, SupplementCycleDayRepetitions.EveryDay); week.Dosages.Add(dosage); dosage.Week = week; newSession.Insert(dosage); return(cycleDefinition); }