/// <summary>
        /// Given a hash of an incident title, find the very first occurence of an incident with the 
        /// same hashed title.
        /// </summary>
        /// <param name="hashTitle">Title hash as string</param>
        /// <param name="repository">Document storage as RavenDataController</param>
        /// <returns>On sucess, the parent incident.  On failure a new Incident with no Id</returns>
        public Incident FindParent(string hashTitle, RavenDataController dataController)
        {
            Enforce.That(string.IsNullOrEmpty(hashTitle) == false, "ErrorLoggingController.FindParent - hashTitle can not be null");

            var results = dataController.GetAllWhere<Incident>(x => x.HashedTitle == hashTitle)
                                        .ToList<Incident>();

            if((results == null) | (results.Count == 0))
            {
               return new Incident();
            }

            var parent = results.Aggregate((item, comp) => item.IncidentDateTime < comp.IncidentDateTime ? item : comp);

            if (parent == null)
            {
                return new Incident();
            }

            return parent;
        }
 public List<Incident> GetParentIncidents(RavenDataController dataController)
 {
     return dataController.GetAllWhere<Incident>(x => string.IsNullOrEmpty(x.ParentIncidentId));
 }
示例#3
0
        public void CanQueryIndexForJavascriptIncidentType()
        {
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var batchIndicents = Create15Incidents();
            var dataController = new RavenDataController(docStore);
            batchIndicents.ForEach(x => dataController.Save<Incident>(x));

            Raven.Client.Indexes.IndexCreation.CreateIndexes(typeof(DistinctIncidentTypeIndex).Assembly, docStore);

            var javascriptIncidentType = dataController.GetAllWhere<DistinctIncidentTypeIndex.DistinctIncidentType>
                                                            (x => x.Name == "javascript",
                                                            "DistinctIncidentTypeIndex");

            Assert.AreEqual(5, javascriptIncidentType[0].Count);
        }
示例#4
0
        public void CanQueryForJavascriptIncidentType()
        {
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var batchIndicents = Create15Incidents();
            var dataController = new RavenDataController(docStore);
            batchIndicents.ForEach(x => dataController.Save<Incident>(x));

            int totalJavascriptCount = 0;

            using(var session = docStore.OpenSession())
            {
                totalJavascriptCount = session.Query<Incident>()
                                                .Customize(x => x.WaitForNonStaleResults())
                                                .Where(x => x.IncidentType.Type == "javascript")
                                                .Count();
            }

            //  Test
            var javascriptIncidents = dataController.GetAllWhere<Incident>(inc => inc.IncidentType.Type == "javascript");
            Assert.AreEqual(totalJavascriptCount, javascriptIncidents.Count);
        }