Exemplo 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());
            }
        }
Exemplo n.º 2
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());
     }
 }
Exemplo n.º 3
0
 public static IndexingActivity GetActivity(int activityId)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         return(context.IndexingActivities.FirstOrDefault(a => a.IndexingActivityId == activityId));
     }
 }
Exemplo n.º 4
0
 public static void UpdateActivity(IndexingActivity activity)
 {
     using (var context = new IndexingDataContext())
     {
         context.CommandTimeout = RepositoryConfiguration.SqlCommandTimeout;
         context.IndexingActivities.Attach(activity, true);
         context.SubmitChanges();
     }
 }