Example #1
0
      public static void PascalDiscipline(IDisciplineStorage storage, string path)
		{
			if (storage.GetDisciplines().Any(d => d.Name == "Pascal" && d.Owner == "OlehVukladachenko"))
			{
				return;
			}
			
			ImportExportDiscipline importer = new ImportExportDiscipline(storage);
         importer.Import(path);

		}
Example #2
0
      public static void SeleniumTestingSystemTestDiscipline(IDisciplineStorage storage, string path)
      {
         if (storage.GetDisciplines().Any(d => d.Name == "Testing discipline" && d.Owner == "SeleniumTeacher"))
         {
            return;
         }

         ImportExportDiscipline importer = new ImportExportDiscipline(storage);
         importer.Import(path);

      }
Example #3
0
      public static void GenerateAllDisciplines(IDisciplineStorage storage)
      {
         ImportExportDiscipline importer = new ImportExportDiscipline(storage);

         var path = (new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;
         path = path.Replace("IUDICO.LMS/Plugins/IUDICO.DataGenerator.DLL", "IUDICO.DataGenerator/Content/Disciplines/");

         if (Directory.Exists(path))
         {
           var files = Directory.GetFiles(path, "*.zip");

            foreach (var file in files)
            {
               var name = Path.GetFileNameWithoutExtension(file);

               if (storage.GetDisciplines().Any(d => d.Name == name && d.Owner == "prof3"))
               {
                  return;
               }

               importer.Import(file);
            }
         }
      }
Example #4
0
        public void ImportTestWithChapter()
        {
            // importing test discipline
            var controller = this.GetController<DisciplineController>();
            var path = "..\\..\\CurriculumManagement\\NUnit\\Discipline2.zip";
            ImportExportDiscipline imExDisc = new ImportExportDiscipline(this.DisciplineStorage);
            Assert.IsTrue(imExDisc.Validate(path));
            controller.Import(path);

            // gets imported and expected disciplines
            var importedDiscipline = this.DisciplineStorage.GetDisciplines().Last();
            var disciplineIds = this.DataPreparer.CreateDisciplinesSet3();
            var excpectedDiscipline = this.DisciplineStorage.GetDisciplines()[disciplineIds[0] - 1];

            // checks if imported and excpected are similar
            Assert.AreEqual(importedDiscipline.Name, excpectedDiscipline.Name);
            Assert.AreEqual(importedDiscipline.Owner, excpectedDiscipline.Owner);
            Assert.AreEqual(importedDiscipline.IsValid, excpectedDiscipline.IsValid);
            Assert.AreEqual(importedDiscipline.IsDeleted, excpectedDiscipline.IsDeleted);
            Assert.AreEqual(importedDiscipline.Chapters, excpectedDiscipline.Chapters);
            Assert.AreEqual(importedDiscipline.Curriculums, excpectedDiscipline.Curriculums);
            Assert.AreNotEqual(importedDiscipline.Id, excpectedDiscipline.Id);
        }
Example #5
0
        public ContentResult UploadFiles()
        {
           string savedFileName = string.Empty;

           if (Request.Files.Count > 1)
           {
                return Content("{\"message\":\"" + "You must select one file" + "\"}", "application/json");
           }

           foreach (string file in Request.Files)
           {
              HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;
              if (hpf.ContentLength == 0)
                 continue;

              if (Path.GetExtension(hpf.FileName) != ".zip")
              {
                 return Content("{\"message\":\"" + "You must select .zip file" + "\"}", "application/json");
              }

              savedFileName = Path.Combine(Server.MapPath("~/Data/Disciplines"), Path.GetFileName(hpf.FileName));
              hpf.SaveAs(savedFileName); // Save the file

              var importer = new ImportExportDiscipline(Storage);

              if (importer.Validate(savedFileName))
              {
                 importer.Import(savedFileName);
              }
              else
              {
                 System.IO.File.Delete(savedFileName);
                 return Content("{\"message\":\"" + "Invalid discipline" + "\"}", "application/json");
              }

				  System.IO.File.Delete(savedFileName);
           }

           return Content("{\"message\":\"" + "complete" + "\"}", "application/json");
        }
Example #6
0
        public ActionResult Import(string path)
        {
           if (path == string.Empty)
           {
              return View();
           }

           var importer = new ImportExportDiscipline(Storage);

           importer.Import(path);

           return RedirectToAction("Index");
        }
Example #7
0
        public ActionResult Import(HttpPostedFileBase file)
        {
            if (file == null)
            {
                return View();
            }

            var importer = new ImportExportDiscipline(Storage);
            
            importer.Import(file);

            return RedirectToAction("Index");
        }
Example #8
0
        public FilePathResult Export(int disciplineId)
        {
            var importer = new ImportExportDiscipline(Storage);
            var path = importer.Export(disciplineId);

            return new FilePathResult(path, "application/octet-stream")
                        {FileDownloadName = importer.GetFileName(disciplineId)};
        }