コード例 #1
0
        public static void Download(string baseDir, bool force, Config config, string ulearnUrl, Credentials credentials)
        {
            var fileName     = config.ULearnCourseId + ".zip";
            var fileFullName = Path.Combine(baseDir, fileName);
            var downloadUrl  = string.Format("{0}/Unit/DownloadPackage?courseId={1}", ulearnUrl, HttpUtility.UrlEncode(config.ULearnCourseId));

            var client = Login(ulearnUrl, credentials.Email, credentials.GetPassword());

            client.TryDownloadFile(downloadUrl, fileFullName);
            Console.Out.WriteLine("Package downloaded to {0}", fileFullName);

            var dir = new DirectoryInfo(baseDir);

            using (var zip = ZipFile.Read(fileFullName, new ReadOptions {
                Encoding = Encoding.GetEncoding(866)
            }))
            {
                var courseDir = dir.CreateSubdirectory(config.ULearnCourseId);
                Directory.Delete(courseDir.FullName, force);
                courseDir.Create();
                zip.ExtractAll(courseDir.FullName, ExtractExistingFileAction.OverwriteSilently);
            }

            new FileInfo(fileFullName).Delete();
        }
コード例 #2
0
ファイル: DownloadManager.cs プロジェクト: fakefeik/uLearn
		public static void Download(string baseDir, Config config, string edxStudioUrl, Credentials credentials)
		{
			Console.WriteLine("Downloading {0}.tar.gz", config.CourseRun);
			Download(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, baseDir + "/" + config.CourseRun + ".tar.gz");

			ArchiveManager.ExtractTar(baseDir + "/" + config.CourseRun + ".tar.gz", baseDir);
			Utils.DeleteFileIfExists(baseDir + "/" + config.CourseRun + ".tar.gz");
			Utils.DeleteDirectoryIfExists(baseDir + "/olx");
			Directory.Move(baseDir + "/" + config.CourseRun, baseDir + "/olx");
		}
コード例 #3
0
        public static void Download(string baseDir, Config config, string edxStudioUrl, Credentials credentials)
        {
            Console.WriteLine("Downloading {0}.tar.gz from {1}", config.CourseRun, edxStudioUrl);
            Download(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, baseDir + "/" + config.CourseRun + ".tar.gz");

            ArchiveManager.ExtractTar(baseDir + "/" + config.CourseRun + ".tar.gz", baseDir);
            Utils.DeleteFileIfExists(baseDir + "/" + config.CourseRun + ".tar.gz");
            Utils.DeleteDirectoryIfExists(baseDir + "/olx");
            Directory.Move(baseDir + "/" + config.CourseRun, baseDir + "/olx");
        }
コード例 #4
0
ファイル: ULearnInteractor.cs プロジェクト: andgein/uLearn
		public static void Upload(string baseDir, Config config, string ulearnUrl, Credentials credentials)
		{
			var fileFullName = Path.Combine(baseDir, config.ULearnCourseId + ".zip");
			var uploadUrl = ulearnUrl + "/Unit/UploadCourse?courseId=" + config.ULearnCourseId;
			var courseDir = Path.Combine(baseDir, config.ULearnCourseId);

			if (File.Exists(fileFullName))
				File.Delete(fileFullName);
			using (var zip = new ZipFile(fileFullName, Encoding.GetEncoding(866)))
			{
				zip.AddDirectory(courseDir);
				zip.Save();
			}

			var client = Login(ulearnUrl, credentials.Email, credentials.GetPassword());
			client.UploadFile(uploadUrl, fileFullName);
		}
コード例 #5
0
        public static void Upload(string baseDir, Config config, string ulearnUrl, Credentials credentials)
        {
            var fileFullName = Path.Combine(baseDir, config.ULearnCourseId + ".zip");
            var uploadUrl    = ulearnUrl + "/Unit/UploadCourse?courseId=" + config.ULearnCourseId;
            var courseDir    = Path.Combine(baseDir, config.ULearnCourseId);

            if (File.Exists(fileFullName))
            {
                File.Delete(fileFullName);
            }
            using (var zip = new ZipFile(fileFullName, Encoding.GetEncoding(866)))
            {
                zip.AddDirectory(courseDir);
                zip.Save();
            }

            var client = Login(ulearnUrl, credentials.Email, credentials.GetPassword());

            client.UploadFile(uploadUrl, fileFullName);
        }
コード例 #6
0
ファイル: ULearnInteractor.cs プロジェクト: andgein/uLearn
		public static void Download(string baseDir, bool force, Config config, string ulearnUrl, Credentials credentials)
		{
			var fileName = config.ULearnCourseId + ".zip";
			var fileFullName = Path.Combine(baseDir, fileName);
			var downloadUrl = string.Format("{0}/Unit/DownloadPackage?courseId={1}", ulearnUrl, HttpUtility.UrlEncode(config.ULearnCourseId));

			var client = Login(ulearnUrl, credentials.Email, credentials.GetPassword());
			client.TryDownloadFile(downloadUrl, fileFullName);
			Console.Out.WriteLine("Package downloaded to {0}", fileFullName);

			var dir = new DirectoryInfo(baseDir);
			using (var zip = ZipFile.Read(fileFullName, new ReadOptions { Encoding = Encoding.GetEncoding(866) }))
			{
				var courseDir = dir.CreateSubdirectory(config.ULearnCourseId);
				Directory.Delete(courseDir.FullName, force);
				courseDir.Create();
				zip.ExtractAll(courseDir.FullName, ExtractExistingFileAction.OverwriteSilently);
			}

			new FileInfo(fileFullName).Delete();
		}
コード例 #7
0
        public static void Upload(string baseDir, string courseName, Config config, string edxStudioUrl, Credentials credentials)
        {
            Environment.CurrentDirectory = baseDir;
            Utils.DeleteDirectoryIfExists("temp");
            if (Directory.Exists(courseName))
            {
                Directory.Move(courseName, "temp");
            }
            Utils.DirectoryCopy("olx", courseName, true);
            Utils.DeleteFileIfExists(courseName + ".tar.gz");

            Console.WriteLine("Creating {0}.tar.gz...", courseName);
            ArchiveManager.CreateTar(courseName + ".tar.gz", courseName);

            Utils.DeleteDirectoryIfExists(courseName);
            if (Directory.Exists("temp"))
            {
                Directory.Move("temp", courseName);
            }

            Console.WriteLine("Uploading {0}.tar.gz to {1}", courseName, edxStudioUrl);
            Upload(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, courseName + ".tar.gz");
            Utils.DeleteFileIfExists(courseName + ".tar.gz");
        }
コード例 #8
0
ファイル: EdxInteraction.cs プロジェクト: kontur-edu/uLearn
		public static void Download(string baseDir, Config config, string edxStudioUrl, Credentials credentials)
		{
			Console.WriteLine($"Downloading {config.ULearnCourseId}.tar.gz from {edxStudioUrl}");
			Download(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, baseDir + "/" + config.ULearnCourseId + ".tar.gz");
		}
コード例 #9
0
ファイル: EdxInteraction.cs プロジェクト: kontur-edu/uLearn
		public static void Upload(string courseName, Config config, string edxStudioUrl, Credentials credentials)
		{
			Console.WriteLine($"Uploading {courseName}.tar.gz to {edxStudioUrl}");
			Upload(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, courseName + ".tar.gz");
			Utils.DeleteFileIfExists(courseName + ".tar.gz");
		}
コード例 #10
0
ファイル: EdxInteraction.cs プロジェクト: epeshk/uLearn
 public static void Download(string baseDir, Config config, string edxStudioUrl, Credentials credentials)
 {
     Console.WriteLine($"Downloading {config.ULearnCourseId}.tar.gz from {edxStudioUrl}");
     Download(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, baseDir + "/" + config.ULearnCourseId + ".tar.gz");
 }
コード例 #11
0
ファイル: EdxInteraction.cs プロジェクト: epeshk/uLearn
 public static void Upload(string courseName, Config config, string edxStudioUrl, Credentials credentials)
 {
     Console.WriteLine($"Uploading {courseName}.tar.gz to {edxStudioUrl}");
     Upload(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, courseName + ".tar.gz");
     Utils.DeleteFileIfExists(courseName + ".tar.gz");
 }
コード例 #12
0
ファイル: DownloadManager.cs プロジェクト: fakefeik/uLearn
		public static void Upload(string baseDir, string courseName, Config config, string edxStudioUrl, Credentials credentials)
		{
			Environment.CurrentDirectory = baseDir;
			Utils.DeleteDirectoryIfExists("temp");
			if (Directory.Exists(courseName))
				Directory.Move(courseName, "temp");
			Utils.DirectoryCopy("olx", courseName, true);
			Utils.DeleteFileIfExists(courseName + ".tar.gz");

			Console.WriteLine("Creating {0}.tar.gz...", courseName);
			ArchiveManager.CreateTar(courseName + ".tar.gz", courseName);

			Utils.DeleteDirectoryIfExists(courseName);
			if (Directory.Exists("temp"))
				Directory.Move("temp", courseName);

			Console.WriteLine("Uploading {0}.tar.gz...", courseName);
			Upload(edxStudioUrl, credentials.Email, credentials.GetPassword(), config.Organization, config.CourseNumber, config.CourseRun, courseName + ".tar.gz");
			Utils.DeleteFileIfExists(courseName + ".tar.gz");
		}