Пример #1
0
        /// ------------------------------------------------------------------------------------
        public void SetFilesToArchive(ArchivingDlgViewModel model)
        {
            model.AddFileGroup(string.Empty, GetSessionFilesToArchive(model.GetType()), AddingSessionFilesProgressMsg);

            var fmt = LocalizationManager.GetString("DialogBoxes.ArchivingDlg.AddingContributorFilesProgressMsg", "Adding Files for Contributor '{0}'");

            foreach (var person in GetParticipantFilesToArchive(model.GetType()))
            {
                model.AddFileGroup(person.Key, person.Value, string.Format(fmt, person.Key));
            }
        }
 /// ------------------------------------------------------------------------------------
 private void SetFilesToArchive(ArchivingDlgViewModel model)
 {
     foreach (var kvp in _filesToAdd)
     {
         model.AddFileGroup(kvp.Key, kvp.Value.Item1, kvp.Value.Item2);
     }
 }
Пример #3
0
        /// ------------------------------------------------------------------------------------
        public void SetFilesToArchive(ArchivingDlgViewModel model)
        {
            Dictionary <string, HashSet <string> > contributorFiles = new Dictionary <string, HashSet <string> >();
            Type archiveType = model.GetType();

            foreach (var session in GetAllSessions())
            {
                model.AddFileGroup(session.Id, session.GetSessionFilesToArchive(archiveType), session.AddingSessionFilesProgressMsg);
                foreach (var person in session.GetParticipantFilesToArchive(model.GetType()))
                {
                    if (!contributorFiles.ContainsKey(person.Key))
                    {
                        contributorFiles.Add(person.Key, new HashSet <string>());
                    }

                    foreach (var file in person.Value)
                    {
                        contributorFiles[person.Key].Add(file);
                    }
                }

                IArchivingSession s = model.AddSession(session.Id);
                s.Location.Address = session.MetaDataFile.GetStringValue(SessionFileType.kLocationFieldName, string.Empty);
                s.Title            = session.Title;
            }

            // project description documents
            var docsPath = Path.Combine(FolderPath, ProjectDescriptionDocsScreen.kFolderName);

            if (Directory.Exists(docsPath))
            {
                var files = Directory.GetFiles(docsPath, "*.*", SearchOption.TopDirectoryOnly);

                // the directory exists and contains files
                if (files.Length > 0)
                {
                    model.AddFileGroup(ProjectDescriptionDocsScreen.kArchiveSessionName, files,
                                       LocalizationManager.GetString("DialogBoxes.ArchivingDlg.AddingProjectDescriptionDocumentsToIMDIArchiveProgressMsg",
                                                                     "Adding Project Description Documents..."));
                }
            }

            // other project documents
            docsPath = Path.Combine(FolderPath, ProjectOtherDocsScreen.kFolderName);
            if (Directory.Exists(docsPath))
            {
                var files = Directory.GetFiles(docsPath, "*.*", SearchOption.TopDirectoryOnly);

                // the directory exists and contains files
                if (files.Length > 0)
                {
                    model.AddFileGroup(ProjectOtherDocsScreen.kArchiveSessionName, files,
                                       LocalizationManager.GetString("DialogBoxes.ArchivingDlg.AddingOtherProjectDocumentsToIMDIArchiveProgressMsg",
                                                                     "Adding Other Project Documents..."));
                }
            }

            foreach (var key in contributorFiles.Keys)
            {
                model.AddFileGroup("\n" + key, contributorFiles[key],
                                   LocalizationManager.GetString("DialogBoxes.ArchivingDlg.AddingContributorFilesToIMDIArchiveProgressMsg",
                                                                 "Adding Files for Contributors..."));
            }
        }
		// We now accept languages not in the Arbil list
		//[Test]
		//public void SetAbstract_BogusLanguage_ThrowsException()
		//{
		//    _model.Initialize();
		//    Dictionary<string, string> descriptions = new Dictionary<string, string>();
		//    descriptions["eng"] = "Story about a frog";
		//    descriptions["frn"] = "L'histoire d'une grenouille";
		//    Assert.Throws(typeof (ArgumentException), () => _model.SetAbstract(descriptions));
		//}

		#endregion

		#region Helper methods
		/// ------------------------------------------------------------------------------------
		private void SetFilesToArchive(ArchivingDlgViewModel model)
		{
			if (_filesToAdd == null)
				return;
			foreach (var kvp in _filesToAdd)
				model.AddFileGroup(kvp.Key, kvp.Value.Item1, kvp.Value.Item2);
		}