Beispiel #1
0
        public ImportFileItemControl(MessageFileItem item)
        {
            InitializeComponent();

            if (!DesignMode)
            {
                _item = item;
                Init();
            }
        }
        public void AddFiles(List <FileItem> files, List <MessageFileItem> listFiles)
        {
            if (files == null || files.Count == 0)
            {
                return;
            }
            MessageFileItem messageFile;

            if (_listFiles == null)
            {
                _listFiles = new List <MessageFileItem>();
            }
            foreach (FileItem file in files)
            {
                FileExistType type = IOHelper.IsExist(file.Path, "", file.Type);

                //add file
                if (type == FileExistType.No)
                {
                    string libraryFileName = IOHelper.GetLibraryFileName(file.Name, string.Empty, file.Type);
                    file.Path = libraryFileName;
                    //
                    messageFile         = new MessageFileItem();
                    file.Path           = libraryFileName;
                    messageFile.Item    = file;
                    messageFile.OldItem = file.Copy();
                    messageFile.IsValid = true;
                    //
                    _listFiles.Add(messageFile);
                    //LibraryGroup.Current.AddFile(file);
                }
                else if (type == FileExistType.Yes)
                {
                    //rename file
                    messageFile = new MessageFileItem();
                    string libraryFileName = IOHelper.GetLibraryFileName(file.Name, string.Empty, file.Type);
                    file.Path           = libraryFileName;
                    messageFile.Item    = file;
                    messageFile.OldItem = file.Copy();
                    messageFile.IsValid = false;
                    //file.Id =
                    listFiles.Add(messageFile);
                }
            }
        }
        private void ImportPlaylist(List <FileItem> images, List <FileItem> videos, List <MessageInfo> messages, List <TimeSliceGroupInfo> timesliceGroups, List <PlaylistInfo> playlists, PlaylistInfo playlistInfo)
        {
            if ((images == null || images.Count == 0) && (videos == null || videos.Count == 0) && (messages == null || messages.Count == 0) && (timesliceGroups == null || timesliceGroups.Count == 0) && (playlists == null || playlists.Count == 0) && playlistInfo == null)
            {
                return;
            }
            List <MessageFileItem>    listFiles           = new List <MessageFileItem>();
            List <MessageItem>        listMessages        = new List <MessageItem>();
            List <TimeSliceGroupItem> listTimeSliceGroups = new List <TimeSliceGroupItem>();
            List <PlaylistItem>       listPlaylists       = new List <PlaylistItem>();

            PlaylistInfo playlist     = null;
            PlaylistItem playlistItem = null;
            bool         isValid      = false;
            //if (images != null && images.Count > 0)
            //{

            MessageFileItem messageFile = null;

            AddFiles(images, listFiles);
            AddFiles(videos, listFiles);
            AddMessages(messages, listMessages);
            AddTimeSliceGroups(timesliceGroups, listTimeSliceGroups);
            AddPlaylists(playlists, listPlaylists);

            playlist             = LibraryGroup.Current.Playlists.GetByName(playlistInfo.Name);
            playlistItem         = new PlaylistItem();
            playlistItem.Item    = playlistInfo.Copy() as PlaylistInfo;
            playlistItem.IsValid = false;
            if (playlist == null)
            {
                playlistItem.IsValid = true;
            }
            //Batch load file :rename file and message
            ImportPlaylistRename(listFiles, listMessages, listTimeSliceGroups, listPlaylists, playlistItem);
            //}
        }