/// <summary>
        /// Loads the media.
        /// </summary>
        /// <param name="groupId">The group id.</param>
        /// <param name="from">Image From.</param>
        /// <param name="count">The count.</param>
        /// <returns>
        /// List of DumpedMediaFiles
        /// </returns>
        /// <exception cref="System.Exception">Unable to find TempWebFolder setting.</exception>
        public IEnumerable <DumpedMediaFile> LoadMedia(int groupId, int from, int count)
        {
            if (string.IsNullOrEmpty(this.tempFolder))
            {
                throw new Exception("Unable to find TempWebFolder setting.");
            }

            var dumpedList = new List <DumpedMediaFile>();

            IStoreDataSource  ds = new StoreDataProvider(this.connectionString);
            List <MediaDraft> list;

            if (groupId == 0)
            {
                list = ds.LoadAllMedia().ToList();
            }
            else
            {
                list = ds.LoadPartMedia(groupId, from, count).ToList();
            }

            var threadList = new List <Thread>();

            foreach (var item in list)
            {
                var cachedItem = this.ReadItemFromCache(item.Id);
                if (cachedItem != null)
                {
                    this.logger.Info(string.Format("Reading image from cache. Image Id = {0}", item.Id));
                    dumpedList.Add(cachedItem);
                }
                else
                {
                    this.logger.Info(string.Format("Dumping image and putting to cache. Image Id = {0}", item.Id));

                    if (item.ServerFilePath != null)
                    {
                        string guid          = Guid.NewGuid().ToString();
                        string localFileName = Path.GetFileName(item.ServerFilePath).Replace(" ", string.Empty);

                        string currentFolder = Path.Combine(this.tempFolder, guid);
                        Directory.CreateDirectory(currentFolder);

                        var di = new DumpedMediaFile();
                        di.Thumbnail.LocalFilePath = Path.Combine(
                            currentFolder, string.Format("{0}_{1}_{2}", item.Id, this.thumbnailLiteral, localFileName));
                        di.Preview.LocalFilePath = Path.Combine(
                            currentFolder, string.Format("{0}_{1}_{2}", item.Id, this.previewLiteral, localFileName));
                        di.Fullsize.LocalFilePath = Path.Combine(
                            currentFolder, string.Format("{0}_{1}_{2}", item.Id, this.fullsizeLiteral, localFileName));

                        di.Id      = item.Id;
                        di.GroupId = item.GroupId;

                        threadList.Add(this.SaveFileToLocalTemp(di, item.Media, item.FileSize));

                        di.FileDateTime = item.FileDateTime;

                        di.Thumbnail.GlobalFileUrl = string.Format(
                            @"/temp/{0}/{1}",
                            guid,
                            string.Format("{0}_{1}_{2}", item.Id, this.thumbnailLiteral, localFileName));
                        di.Preview.GlobalFileUrl = string.Format(
                            @"temp/{0}/{1}",
                            guid,
                            string.Format("{0}_{1}_{2}", item.Id, this.previewLiteral, localFileName));
                        di.Fullsize.GlobalFileUrl = string.Format(
                            @"temp/{0}/{1}",
                            guid,
                            string.Format("{0}_{1}_{2}", item.Id, this.fullsizeLiteral, localFileName));

                        this.AddItemToCache(di);

                        dumpedList.Add(di);
                    }
                }
            }

            foreach (var thread in threadList)
            {
                thread.Join();
            }

            return(dumpedList);
        }
        /// <summary>
        /// Gets the images count.
        /// </summary>
        /// <returns>Images count</returns>
        public int GetImagesCount()
        {
            IStoreDataSource ds = new StoreDataProvider(this.connectionString);

            return(ds.GetImagesCount());
        }