public static ICollection <Product> GetPaging(int page, int maxResule) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Product)).SetFirstResult(page).SetMaxResults(maxResule).List <Product>()); } }
public ICollection <GroupCampaign> GetAllAccount(Campaign acc) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(GroupCampaign)).List <GroupCampaign>()); } }
public static Product FindById(int productId) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Product)).Add(Restrictions.Like("ProductId", productId)).FutureValue <Product>().Value); } }
public ICollection <Message> GetAllMessage() { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Message)).List <Message>()); } }
public void AddStdout(string data) { using (NHibernate.ISession session = SessionFactory.OpenSession()) { using (NHibernate.ITransaction trans = session.BeginTransaction()) { var process = session .CreateCriteria <SinterProcess>() .Add(Restrictions.Eq("Id", this.id)) .UniqueResult <SinterProcess>(); if (process.stdout == null) { process.stdout = data; } else { process.stdout += data; } session.Save(process); trans.Commit(); } } }
public static ICollection <User> GetAllUsers() { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(User)).List <User>()); } }
public static int GetProductCount() { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Product)).SetProjection(Projections.RowCount()).FutureValue <int>().Value); } }
public static ICollection <Product> GetAll() { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Product)).List <Product>()); } }
protected virtual async Task <ResponseApi> DefaultQuery(F query, int?page, int?size) { IQueryable <T> queryable = this.Query(); //树形列表查询 无条件则可以 树形列表查询 有条件取消 List <NHibernate.Criterion.AbstractCriterion> wheres = new List <NHibernate.Criterion.AbstractCriterion>(); List <NHibernate.Criterion.AbstractCriterion> ands = new List <NHibernate.Criterion.AbstractCriterion>(); bool res = this.QueryFilterByOr(ref wheres, query); bool andRes = this.QueryFilterByAnd(ands, query); if (andRes) { res = true; } List <T> data = null; int total = 0; if (res) { //模糊查询 using (NHibernate.ISession session = HttpContext.RequestServices.GetService <NHibernate.ISession>()) { NHibernate.ICriteria criteria = session.CreateCriteria <T>(); NHibernate.Criterion.AbstractCriterion abstractCriterion = wheres.Any() ? wheres[0] : ands[0]; for (int i = wheres.Any() ? 0 : 1; i < ands.Count; i++) { abstractCriterion &= ands[i]; } for (int i = 1; i < wheres.Count; i++) { abstractCriterion |= wheres[i]; } criteria = criteria.Add(abstractCriterion); NHibernate.ICriteria pageCriteria = (NHibernate.ICriteria)criteria.Clone(); total = pageCriteria.SetProjection(Projections.RowCount()).UniqueResult <int>(); OrderBy(ref criteria); data = criteria.SetFirstResult((page.Value - 1) * size.Value).SetMaxResults(size.Value).List <T>().ToList(); //数据不规则整理成树形列表信息 如果断层了 断层的下级的成为上级 data = this.DataParseIfWhileReference(data, true); } } else { data = this.QueryChildFilter(queryable, query).OrderBy(it => it.CreateDate).Skip((page.Value - 1) * size.Value).Take(size.Value).ToList(); total = queryable.ToFutureValue(it => it.Count()).Value; //树形列表查询 去递归引用 automapper 才能正常运行 否则异常 data = this.DataParseIfWhileReference(data); } ResultModel <G> result = new ResultModel <G>(); result.Data = data.Any() ? ObjectMapper.Map <List <G> >(data) : null; result.Result = new PageModel() { Total = total, Size = size.Value, Page = total == 0 ? 0 : total % size.Value == 0 ? total / size.Value : (total / size.Value + 1) }; ResponseApi response = ResponseApi.Create(GetLanguage(), Code.QuerySuccess); response.Data = result; return(await Task.FromResult(response)); }
public ICollection <Page> GetAllAccount(Page acc) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Page)).List <Page>()); } }
/// <getAllActiveRssFeeds> /// Get all active rss feeds /// </summary> /// <returns>Return object of RssFeeds Class with value of each member in the form of IEnumerable list.(List<RssFeeds>)</returns> public IEnumerable <RssFeeds> getAllActiveRssFeeds() { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { //Proceed action, to get all feeds return(session.CreateCriteria(typeof(RssFeeds)).List <RssFeeds>().Where(x => x.Status == false)); //NHibernate.IQuery query = session.CreateQuery("from RssFeeds where Status = 0"); //List<RssFeeds> lst = new List<RssFeeds>(); //foreach (RssFeeds item in query.Enumerable<RssFeeds>()) //{ // lst.Add(item); //} //return lst; } catch (Exception ezx) { Console.WriteLine(ezx.StackTrace); return(null); } } //End Transaction } //End Session }
//通过流程和活动实例编号获取工作任务 private IList <WorkItem> GetWorkItems(NHibernate.ISession session, Process process, long activityInstanceId) { return(session.CreateCriteria <WorkItem>() .Add(Expression.Eq("Process", process)) .Add(Expression.Eq("ActivityInstanceId", activityInstanceId)) .List <WorkItem>()); }
public ICollection <Event> GetAllAccount(Event acc) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Event)).List <Event>()); } }
private void AddError(string error_type, Dictionary <string, List <string> > dictionary) { using (NHibernate.ISession session = SessionFactory.OpenSession()) { using (NHibernate.ITransaction trans = session.BeginTransaction()) { var process = session .CreateCriteria <SinterProcess>() .Add(Restrictions.Eq("Id", this.id)) .UniqueResult <SinterProcess>(); //ProcessError error; foreach (KeyValuePair <String, List <String> > entry in dictionary) { foreach (String msg in entry.Value) { var error = new ProcessError(); error.type = "convergence"; error.name = entry.Key; error.msg = msg; process.errors.Add(error); } } } } }
public ICollection <Friend> GetAllAccount(Friend acc) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { return(session.CreateCriteria(typeof(Friend)).List <Friend>()); } }
public static ICollection <Product> GetProductsByWildcard(string productName) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { var searchCriteria = session.CreateCriteria(typeof(Product)); searchCriteria.Add(Expression.Sql(string.Format("ProductName like '%{0}%'", productName))); return(searchCriteria.List <Product>()); } }
public override async Task <ResponseApi> Category() { using (NHibernate.ISession session = HttpContext.RequestServices.GetService <NHibernate.ISession>()) { var result = session.CreateCriteria <FileCategoryInfo>().SetProjection(new IProjection[] { Projections.Property("Id").As("Id"), Projections.Property("Category").As("Category"), Projections.Property("Accept").As("Accept") }) .SetResultTransformer(new AliasToBeanResultTransformer(typeof(FileCategoryEntry))).List <FileCategoryEntry>(); ResponseApi response = ResponseApi.Create(GetLanguage(), Code.QuerySuccess); response.Data = result; return(await Task.FromResult(response)); } }
public byte[] GetSimulationBackup() { using (NHibernate.ISession session = SessionFactory.OpenSession()) { using (NHibernate.ITransaction trans = session.BeginTransaction()) { var job = session .CreateCriteria <Job>() .Add(Restrictions.Eq("Id", this.id)) .UniqueResult <Job>(); return(job.simulation.backup); } } }
public Dictionary <String, Object> GetSimulationDefaults() { using (NHibernate.ISession session = SessionFactory.OpenSession()) { using (NHibernate.ITransaction trans = session.BeginTransaction()) { var job = session .CreateCriteria <Job>() .Add(Restrictions.Eq("Id", this.id)) .UniqueResult <Job>(); String data = System.Text.Encoding.ASCII.GetString(job.simulation.defaults); return(JsonConvert.DeserializeObject <Dictionary <string, Object> >(data)); } } }
//Sets the dir in the function to MyDocs, but doesn't actually chdir void SetWorkingDirectory(string path) { using (NHibernate.ISession session = SessionFactory.OpenSession()) { using (NHibernate.ITransaction trans = session.BeginTransaction()) { var process = session .CreateCriteria <SinterProcess>() .Add(Restrictions.Eq("Id", this.id)) .UniqueResult <SinterProcess>(); process.workingdir = path; session.Save(process); trans.Commit(); } } }
public ICollection<GroupCompaignReport> GetAllGroupCompaignReport(GroupCompaignReport groupCompaignReport) { ICollection<GroupCompaignReport> iCol = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { iCol = session.CreateCriteria(typeof(GroupCompaignReport)).List<GroupCompaignReport>(); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return iCol; }
/// <getAllMessages> /// Get All Messages by date. /// </summary> /// <returns>Return object of ScheduledMessage Class with value of each member in the form of IEnumerable list.(IEnumerable<ScheduledMessage>)</returns> public IEnumerable <ScheduledMessage> getAllMessage() { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { try { //Proceed action, to get all records of scheduled message. return(session.CreateCriteria(typeof(ScheduledMessage)).List <ScheduledMessage>().Where(x => x.Status == false && x.ScheduleTime <= DateTime.Now)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } }//End Session }
public ICollection <faceboardpro.Domain.Captcha> GetAllCaptchaSetting(faceboardpro.Domain.Captcha captcha) { ICollection <faceboardpro.Domain.Captcha> eCol = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { eCol = session.CreateCriteria(typeof(faceboardpro.Domain.Captcha)).List <faceboardpro.Domain.Captcha>(); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return(eCol); }
public ICollection <Setting> GetAllSetting(Setting setting) { ICollection <Setting> iCol = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { iCol = session.CreateCriteria(typeof(Setting)).List <Setting>(); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return(iCol); }
public static IProcess Get(int id) { using (NHibernate.ISession session = SessionFactory.OpenSession()) { using (NHibernate.ITransaction trans = session.BeginTransaction()) { var process = session .CreateCriteria <SinterProcess>() .Add(Restrictions.Eq("Id", id)) .UniqueResult <SinterProcess>(); return(new SinterProcessContract() { id = id }); } } }
public List <FanPageData> GetFanPageDataUsingCount(FanPageData acc, int count) { List <FanPageData> iCol = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { iCol = session.CreateCriteria(typeof(FanPageData)).List <FanPageData>().Take <FanPageData>(count).ToList(); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return(iCol); }
public ICollection <FanPageData> GetAllFanPageData(FanPageData acc) { ICollection <FanPageData> iCol = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { iCol = session.CreateCriteria(typeof(FanPageData)).List <FanPageData>(); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return(iCol); }
public ICollection <Email> GetAllEmail(Email email) { ICollection <Email> eCol = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { eCol = session.CreateCriteria(typeof(Email)).List <Email>(); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return(eCol); }
/// <summary> /// Retrieves All The Data From Table Related to the Class /// </summary> public static List <T> GetAllData <T>() { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { return(session.CreateCriteria(typeof(T)).List <T>().ToList <T>()); } catch (Exception) { throw; } } } }
public ICollection <CmpFanPageLiker> GetAllCampaign() { ICollection <CmpFanPageLiker> iCol = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { iCol = session.CreateCriteria(typeof(CmpFanPageLiker)).List <CmpFanPageLiker>(); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return(iCol); }