Esempio n. 1
0
        /// <summary>
        /// Load files attached to a session
        /// </summary>
        /// <param name="session"></param>
        public void LoadData(PhotoSession session)
        {
            if (session == null)
            {
                return;
            }
            FileItem[] fileItems = new FileItem[session.Files.Count];
            session.Files.CopyTo(fileItems, 0);
            //session.Files.Clear();
            if (!Directory.Exists(session.Folder))
            {
                Directory.CreateDirectory(session.Folder);
            }
            string[] files = Directory.GetFiles(session.Folder);
            foreach (string file in files)
            {
                if (session.SupportedExtensions.Contains(Path.GetExtension(file).ToLower()))
                {
                    if (!session.ContainFile(file))
                    {
                        session.AddFile(file);  // TODO: Check if this is exploding session with proshots.jar running
                    }
                }
            }
            // remove files which was deleted or not exist
            List <FileItem> removedItems = session.Files.Where(fileItem => !File.Exists(fileItem.FileName)).ToList();

            foreach (FileItem removedItem in removedItems)
            {
                session.Files.Remove(removedItem);
            }
            //session.Files = new AsyncObservableCollection<FileItem>(session.Files.OrderBy(x => x.FileDate));
        }
Esempio n. 2
0
        /// <summary>
        /// Load files attached to a session
        /// </summary>
        /// <param name="session"></param>
        public void LoadData(PhotoSession session)
        {
            try
            {
                if (session == null)
                {
                    return;
                }
                if (!Directory.Exists(session.Folder))
                {
                    return;
                }
                if (session.AlowFolderChange && session.ReloadOnFolderChange)
                {
                    session.Files.Clear();
                }

                FileItem[] fileItems = new FileItem[session.Files.Count];
                session.Files.CopyTo(fileItems, 0);
                ////session.Files.Clear();
                //if (!Directory.Exists(session.Folder))
                //{
                //    Directory.CreateDirectory(session.Folder);
                //}
                string[] files = Directory.GetFiles(session.Folder);
                foreach (string file in files)
                {
                    if (session.SupportedExtensions.Contains(Path.GetExtension(file).ToLower()))
                    {
                        if (!string.IsNullOrEmpty(file) && !session.ContainFile(file))
                        {
                            session.AddFile(file);
                        }
                    }
                }
                // remove files which was deleted or not exist
                List <FileItem> removedItems = session.Files.Where(fileItem => !File.Exists(fileItem.FileName)).ToList();
                foreach (FileItem removedItem in removedItems)
                {
                    session.Files.Remove(removedItem);
                }
                //session.Files = new AsyncObservableCollection<FileItem>(session.Files.OrderBy(x => x.FileDate));
            }
            catch (Exception exception)
            {
                Log.Error("Error loading session ", exception);
            }
        }
 /// <summary>
 /// Load files attached to a session
 /// </summary>
 /// <param name="session"></param>
 public void LoadData(PhotoSession session)
 {
     try
     {
         if (session == null)
             return;
         FileItem[] fileItems = new FileItem[session.Files.Count];
         session.Files.CopyTo(fileItems, 0);
         //session.Files.Clear();
         if (!Directory.Exists(session.Folder))
         {
             Directory.CreateDirectory(session.Folder);
         }
         string[] files = Directory.GetFiles(session.Folder);
         foreach (string file in files)
         {
             if (session.SupportedExtensions.Contains(Path.GetExtension(file).ToLower()))
             {
                 if (!string.IsNullOrEmpty(file) && !session.ContainFile(file))
                     session.AddFile(file);
             }
         }
         // remove files which was deleted or not exist
         List<FileItem> removedItems = session.Files.Where(fileItem => !File.Exists(fileItem.FileName)).ToList();
         foreach (FileItem removedItem in removedItems)
         {
             session.Files.Remove(removedItem);
         }
         //session.Files = new AsyncObservableCollection<FileItem>(session.Files.OrderBy(x => x.FileDate));
     }
     catch (Exception exception)
     {
         Log.Error("Error loading session ", exception);
     }
 }