Inheritance: IndexingTasksDataContext
Ejemplo n.º 1
0
        public static IndexingActivity[] GetUnprocessedActivities(int lastActivityId, out int maxIdInDb, int top = 0, int max = 0)
        {
            using (var context = new IndexingDataContext())
            {
                context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;

                var activityQuery = context.IndexingActivities.Where(a => a.IndexingActivityId > lastActivityId);

                //if last id is given
                if (max > 0)
                {
                    activityQuery = activityQuery.Where(a => a.IndexingActivityId <= max);
                    maxIdInDb     = max;
                }
                else
                {
                    //maxIdInDb = context.IndexingActivities.Max(m => m.IndexingActivityId);
                    //we have to format the query this way to handle empty result
                    maxIdInDb = (from ia in context.IndexingActivities
                                 select(int?) ia.IndexingActivityId).Max() ?? 0;
                }

                activityQuery = activityQuery.OrderBy(b => b.IndexingActivityId);

                return(top > 0 ? activityQuery.Take(top).ToArray() : activityQuery.ToArray());
            }
        }
Ejemplo n.º 2
0
        public static IndexingActivity[] GetUnprocessedActivities(int lastActivityId, out int maxIdInDb, int top = 0, int max = 0)
        {
            using (var context = new IndexingDataContext())
            {
                context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;

                var activityQuery = context.IndexingActivities.Where(a => a.IndexingActivityId > lastActivityId);

                //if last id is given
                if (max > 0)
                {
                    activityQuery = activityQuery.Where(a => a.IndexingActivityId <= max);
                    maxIdInDb = max;
                }
                else
                {
                    //maxIdInDb = context.IndexingActivities.Max(m => m.IndexingActivityId);
                    //we have to format the query this way to handle empty result
                    maxIdInDb = (from ia in context.IndexingActivities
                                 select (int?)ia.IndexingActivityId).Max() ?? 0;
                }

                activityQuery = activityQuery.OrderBy(b => b.IndexingActivityId);
                
                return top > 0 ? activityQuery.Take(top).ToArray() : activityQuery.ToArray();
            }
        }
Ejemplo n.º 3
0
 public static IndexingActivity[] GetUnprocessedActivities(IEnumerable <int> missingActivities)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         return(context.IndexingActivities.Where(a => missingActivities.Contains(a.IndexingActivityId)).OrderBy(b => b.IndexingActivityId).ToArray());
     }
 }
Ejemplo n.º 4
0
 public static IndexingActivity GetActivity(int activityId)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         return(context.IndexingActivities.FirstOrDefault(a => a.IndexingActivityId == activityId));
     }
 }
Ejemplo n.º 5
0
 public static IndexingActivity[] GetUnprocessedActivities(IEnumerable<int> missingActivities)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         return context.IndexingActivities.Where(a => missingActivities.Contains(a.IndexingActivityId)).OrderBy(b => b.IndexingActivityId).ToArray();
     }
 }
Ejemplo n.º 6
0
 public static IndexingActivity GetActivity(int activityId)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         return context.IndexingActivities.FirstOrDefault(a => a.IndexingActivityId == activityId);
     }
 }
Ejemplo n.º 7
0
 public static void UpdateActivity(IndexingActivity activity)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         context.IndexingActivities.Attach(activity, true);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 8
0
 public static void RegisterActivity(IndexingActivity activity)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         context.IndexingActivities.InsertOnSubmit(activity);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 9
0
 public static void UpdateActivity(IndexingActivity activity)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         context.IndexingActivities.Attach(activity, true);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 10
0
 public static void RegisterActivity(IndexingActivity activity)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         context.IndexingActivities.InsertOnSubmit(activity);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 11
0
        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;
            }

        }
Ejemplo n.º 12
0
 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();
     }
 }
Ejemplo n.º 13
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();
     }
 }
Ejemplo n.º 14
0
        [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.ApplyChanges();
            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();
            }

        }