private IndexingActivity[] GetCarActivities(int lastActivityId) { using (var context = new IndexingDataContext()) { context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout; return(context.IndexingActivities.Where(a => a.IndexingActivityId > lastActivityId).OrderBy(b => b.IndexingActivityId).ToArray()); } }
private long GetLastTimestamp(int versionId) { using (var context = new IndexingDataContext()) { var activity = context.IndexingActivities.Where(a => a.VersionId == versionId).OrderByDescending(a => a.IndexingActivityId).FirstOrDefault(); if (activity == null) { return(0); } return(activity.VersionTimestamp ?? 0); } }
private static void RemoveFakeTestActivity() { using (var context = new IndexingDataContext()) { var sql = @"DELETE FROM IndexingActivity WHERE VersionId = @FakeId"; var proc = DataProvider.CreateDataProcedure(sql); proc.CommandType = System.Data.CommandType.Text; proc.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FakeId", SqlDbType.Int)); proc.Parameters["@FakeId"].Value = _fakeId; proc.ExecuteNonQuery(); } }
[Description("An activity execution with update activity after delete activity not throws any exception.")] // ?? public void Indexing_ActivitesWithMissingVersion() { var content = Content.CreateNew("Car", TestRoot, "Car_Indexing_ActivitesWithMissingVersion"); var handler = (GenericContent)content.ContentHandler; //handler.VersioningMode = VersioningType.None; content.Save(); var id = content.Id; LuceneManager.UnregisterActivity(0, false); IndexingActivity[] act = new IndexingActivity[3]; act[0] = new IndexingActivity { ActivityType = IndexingActivityType.RemoveDocument, NodeId = _fakeId, VersionId = _fakeId }; act[1] = new IndexingActivity { ActivityType = IndexingActivityType.UpdateDocument, NodeId = _fakeId, VersionId = _fakeId }; act[2] = new IndexingActivity { ActivityType = IndexingActivityType.AddDocument, NodeId = _fakeId, VersionId = _fakeId }; try { using (var context = new IndexingDataContext()) { foreach (var a in act) { context.IndexingActivities.InsertOnSubmit(a); context.SubmitChanges(); } } var max = 0; var activities = IndexingActivityManager.GetUnprocessedActivities(act[2].IndexingActivityId - 1, out max); foreach (var a in activities) { IndexingActivityManager.ExecuteActivityDirect(a); } } finally { RemoveFakeTestActivity(); } }