Ejemplo n.º 1
0
        // Returns list of ids of child exhibits of timeline with given id.
        private List<Guid> GetChildExhibitsIds(Guid id)
        {
            var exhibits = new List<Guid>();

            string exhibitsQuery = string.Format(
                CultureInfo.InvariantCulture,
                "SELECT *, Year as [Time] FROM Exhibits WHERE Timeline_Id IN ('{0}')",
                string.Join("', '", id));

            IEnumerable<ExhibitRaw> exhibitsRaw = new ExhibitRaw[0];
            try
            {
                retryPolicy.ExecuteAction(
                  () =>
                  {
                      exhibitsRaw = Database.SqlQuery<ExhibitRaw>(exhibitsQuery);
                  });
            }
            catch (Exception e)
            {
                throw e;
            }

            foreach (ExhibitRaw exhibitRaw in exhibitsRaw)
                exhibits.Add(exhibitRaw.Id);

            return exhibits;
        }
Ejemplo n.º 2
0
 public ExhibitRaw GetContentItemParentExhibit(Guid contentItemId)
 {
     IEnumerable<ExhibitRaw> exhibitRaw = new ExhibitRaw[0];
     try
     {
         retryPolicy.ExecuteAction(
           () =>
           {
               exhibitRaw = Database.SqlQuery<ExhibitRaw>("SELECT * FROM Exhibits WHERE Id in (SELECT Exhibit_Id FROM ContentItems WHERE Id = {0})", contentItemId);
           });
     }
     catch (Exception e)
     {
         throw e;
     }
     return exhibitRaw.FirstOrDefault();
 }
Ejemplo n.º 3
0
        private void FillTimelineRelations(Dictionary<Guid, Timeline> timelinesMap, int maxElements)
        {
            if (!timelinesMap.Keys.Any())
                return;


            // Populate Exhibits
            string exhibitsQuery = string.Format(
                CultureInfo.InvariantCulture,
                "SELECT TOP({0}) *, Year as [Time] FROM Exhibits WHERE Timeline_Id IN ('{1}')",
                maxElements,
                string.Join("', '", timelinesMap.Keys.ToArray()));

            IEnumerable<ExhibitRaw> exhibitsRaw = new ExhibitRaw[0];

            try
            {
                retryPolicy.ExecuteAction(
                  () =>
                  {
                      exhibitsRaw = Database.SqlQuery<ExhibitRaw>(exhibitsQuery);
                  });
            }
            catch (Exception e)
            {
                throw e;
            }


            Dictionary<Guid, Exhibit> exhibits = new Dictionary<Guid, Exhibit>();
            foreach (ExhibitRaw exhibitRaw in exhibitsRaw)
            {
                if (exhibitRaw.ContentItems == null)
                    exhibitRaw.ContentItems = new Collection<ContentItem>();

                if (timelinesMap.Keys.Contains(exhibitRaw.Timeline_ID))
                {
                    timelinesMap[exhibitRaw.Timeline_ID].Exhibits.Add(exhibitRaw);
                    exhibits[exhibitRaw.Id] = exhibitRaw;
                }
            }

            if (exhibits.Keys.Any())
            {
                // Populate Content Items
                string contentItemsQuery = string.Format(
                    CultureInfo.InvariantCulture,
                    @"
                        SELECT * 
                        FROM ContentItems 
                        WHERE Exhibit_Id IN ('{0}')
                        ORDER BY [Order] ASC
                    ",
                    string.Join("', '", exhibits.Keys.ToArray()));

                IEnumerable<ContentItemRaw> contentItemsRaw = new ContentItemRaw[0];
                try
                {
                    retryPolicy.ExecuteAction(
                      () =>
                      {
                          contentItemsRaw = Database.SqlQuery<ContentItemRaw>(contentItemsQuery);
                      });
                }
                catch (Exception e)
                {
                    throw e;
                }


                foreach (ContentItemRaw contentItemRaw in contentItemsRaw)
                {
                    if (exhibits.Keys.Contains(contentItemRaw.Exhibit_ID))
                    {
                        exhibits[contentItemRaw.Exhibit_ID].ContentItems.Add(contentItemRaw);
                    }
                }
            }
        }