private void AddNamedQueries() { INamedQueryCacheService service = ApplicationContext.Current.Services.Get <INamedQueryCacheService>(false); if (service == null) { INamedQueryLookupService lsvc = ApplicationContext.Current.Services.Get <INamedQueryLookupService>(false); if (lsvc != null) { service = lsvc as INamedQueryCacheService; } } if (service == null) { return; } if (!service.Contains("ContactSearch")) { service.Add(GetContactNamedQueryinfo()); } if (!service.Contains("LeadSearch")) { service.Add(GetLeadNamedQueryinfo()); } if (!service.Contains("AccountSearch")) { service.Add(GetAccountNamedQueryinfo()); } }
protected void Page_Load(object sender, EventArgs e) { const string QueryName = "campaignResponses"; const string targetsQuery = "campaignTargetsQuery"; INamedQueryCacheService service = ApplicationContext.Current.Services.Get <INamedQueryCacheService>(false); if (service != null) { if (!service.Contains(QueryName)) { NamedQueryInfo queryinfo = new NamedQueryInfo(); string activeEquiv = GetGlobalResourceObject("Campaign", "Campaign_Status_Active").ToString(); string whereClause = string.Empty; if (!string.IsNullOrEmpty(activeEquiv)) { whereClause = string.Format("where c.Status='{0}'", activeEquiv); } queryinfo.Hql = string.Format("select c.id, c.CampaignName, c.StartDate, c.EndDate, c.ExpectedContactResponses, c.ExpectedLeadResponses from Campaign c {0} order by c.EndDate asc", whereClause); queryinfo.Name = QueryName; queryinfo.ColumnAliases = new string[] { "id", "name", "startdate", "enddate", "expectedcontact", "expectedlead" }; service.Add(queryinfo); } if (!service.Contains(targetsQuery)) { NamedQueryInfo targetsQueryInfo = new NamedQueryInfo(); targetsQueryInfo.Hql = "select t.ResponseDate from TargetResponse t"; targetsQueryInfo.Name = targetsQuery; targetsQueryInfo.ColumnAliases = new string[] { "ResponseDate" }; service.Add(targetsQueryInfo); } } }
protected void Page_Load(object sender, EventArgs e) { const string QueryName = "recentNotes"; INamedQueryCacheService service = ApplicationContext.Current.Services.Get <INamedQueryCacheService>(false); if (service != null) { if (!service.Contains(QueryName)) { SLXUserService slxUserService = ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>() as SLXUserService; NamedQueryInfo queryinfo = new NamedQueryInfo(); // queryinfo.Hql = "select h.id, h.Description, h.Notes from History h where h.Type=262148 and h.UserId=? and h.CreateDate>? order by h.CreateDate desc"; queryinfo.Name = QueryName; queryinfo.ColumnAliases = new string[] { "id", "description", "notes" }; queryinfo.SetParameter(0, slxUserService.GetUser().Id); queryinfo.SetParameter(1, DateTime.Now.AddDays(-15)); service.Add(queryinfo); } } }