\r
public void update(bool downloadPackageListFlag)\r
{\r
- NaGet.SubCommands.NaGetUpdate tasks = new NaGet.SubCommands.NaGetUpdate(pkgListMan, downloadPackageListFlag);\r
+ NaGet.SubCommands.NaGetUpdate2 tasks = new NaGet.SubCommands.NaGetUpdate2(pkgListMan, downloadPackageListFlag);\r
tasks.TaskEventRaised += delegate(object sender, TaskEventArgs e) { \r
switch (e.Type) {\r
// case NaGetTaskSetEventType.COMPLETED_TASKSET\r
break;\r
}\r
};\r
- DownloadListener dl = new DownloadListener();\r
- tasks.Downloader.DownloadEventRaised += dl.OnDownload;\r
+ tasks.SubTaskEventRaised += delegate (object sender, TaskEventArgs e) {\r
+ if (sender is NaGet.SubCommands.SubTask.DownloadSubTask) {\r
+ if (e.Type == TaskEventType.STARTED) {\r
+ Console.WriteLine();\r
+ }\r
+ \r
+ int origPosX = Console.CursorLeft;\r
+ for (int i = 0; i < Console.WindowWidth - 1; i++) {\r
+ Console.Write(' ');\r
+ }\r
+ Console.CursorLeft = origPosX;\r
+ \r
+ if (e.Type == TaskEventType.PING) {\r
+ int origPos = Console.CursorLeft;\r
+ Console.Write(e.TaskMessage);\r
+ Console.CursorLeft = origPos;\r
+ } else {\r
+ Console.WriteLine(e.TaskMessage);\r
+ }\r
+ }\r
+ };\r
\r
tasks.Run();\r
}\r
{
public class LocalUpdateSubTask : NaGetSubTask
{
- PackageListsManager pkgListMan;
+ private PackageListsManager pkgListMan;
public LocalUpdateSubTask(PackageListsManager pkgListMan)
{
public override void Run()
{
NotifyStarted();
- RaiseTaskSetEvent(TaskEventType.STARTED, "リスト更新", 0);
+ RaiseTaskSetEvent(TaskEventType.STARTED, "ã\82¤ã\83³ã\82¹ã\83\88ã\83¼ã\83«æ¸\88ã\81¿ã\83\95ã\82¡ã\82¤ã\83«ã\83ªã\82¹ã\83\88æ\9b´æ\96°", 0);
pkgListMan.DetectInstalledPkgs();
pkgListMan.SaveInstalledPackageList();
pkgListMan.SaveSystemInstalledPackageList();
RaiseTaskSetEvent(TaskEventType.INFO, string.Format("{0} を更新しました", NaGet.Env.SystemInstalledPackageListFile), 100);
- RaiseTaskSetEvent(TaskEventType.COMPLETED, "リスト更新", 100);
+ RaiseTaskSetEvent(TaskEventType.COMPLETED, "ã\82¤ã\83³ã\82¹ã\83\88ã\83¼ã\83«æ¸\88ã\81¿ã\83\95ã\82¡ã\82¤ã\83«ã\83ªã\82¹ã\83\88æ\9b´æ\96°", 100);
NotifyCompleted();
}
}
--- /dev/null
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Net;
+using NaGet.Packages;
+using NaGet.Packages.Install;
+using NaGet.Net;
+using NaGet.SubCommands;
+using NaGet.SubCommands.SubTask;
+using NaGet.Tasks;
+
+namespace NaGet.SubCommands
+{
+ /// <summary>
+ /// ソフトリストなどのアップデート処理
+ /// </summary>
+ public class NaGetUpdate2 : NaGetTaskSet2
+ {
+ private PackageListsManager pkgListMan = null;
+
+ private bool downloadPackageLists = true;
+
+ private RepositoriesList repoList = null;
+
+ private IList<string> tempRepoFiles = null;
+
+ public NaGetUpdate2(PackageListsManager pkgListMan)
+ : this(pkgListMan, true)
+ {
+ }
+
+ /// <summary>
+ /// コンストラクタ
+ /// </summary>
+ /// <param name="pkgMan">参照パッケージマネージャ</param>
+ /// <param name="downloadPackageListsFlag">リストをダウンロードするか?</param>
+ public NaGetUpdate2(PackageListsManager pkgMan, bool downloadPackageListsFlag)
+ {
+ this.pkgListMan = pkgMan;
+ this.downloadPackageLists = downloadPackageListsFlag;
+
+ // taskセットの初期化
+ initSubTask();
+ if (this.downloadPackageLists) {
+ // repos.list.xmlがあるとき、そこからよみとる。
+ repoList = NaGet.Utils.GetDeserializedObject<RepositoriesList>(NaGet.Env.RepositoriesListFile);
+ tempRepoFiles = new List<string>();
+
+ foreach (RepositoryInfo repo in repoList.EnabledRepositories) {
+ string filepath = Path.GetTempFileName();
+
+ tempRepoFiles.Add(filepath);
+ registSubTask(string.Format("リスト取得: {0}", repo.Url.Href),
+ new DownloadSubTask(repo.Url.Href, filepath));
+ }
+ registSubTask(string.Format("リスト更新: {0}", NaGet.Env.PackageListFile),
+ new FunctionalSubTask(runUpdatePackageListFile, null));
+ }
+ registSubTask("インストール済みのソフトリスト更新",
+ new LocalUpdateSubTask(this.pkgListMan));
+ }
+
+ public override void Run()
+ {
+ NotifyStarted();
+ try {
+ while (hasMoreSubTask) {
+ RaiseTaskSetEvent(TaskEventType.STARTED_SUBTASK, currentSubTaskName);
+ currentSubTask.Run();
+ RaiseTaskSetEvent(TaskEventType.COMPLETED_SUBTASK, currentSubTaskName);
+
+ NotifyGoToNextSubTask();
+ }
+ } finally {
+ runDeleteTempFiles();
+ if (cancelCalled) {
+ NotifyCancelled();
+ } else {
+ NotifyCompleted();
+ }
+ }
+ }
+
+ private void runUpdatePackageListFile(object dummy)
+ {
+ int i = 0;
+ PackageList<Package> avaiablePackageList = new PackageList<Package>();
+
+ // かならず常にrepositoryリストに書き込む。
+ NaGet.Utils.PutSerializeObject(NaGet.Env.RepositoriesListFile, repoList);
+
+ foreach (RepositoryInfo repo in repoList.EnabledRepositories) {
+ if (repo.Type == RepositoryType.APPLISTATION_NATIVE_XML_1_0) {
+ try {
+ string tmpfileName = tempRepoFiles[i];
+ PackageList<Package> pkgList = NaGet.Utils.GetDeserializedObject<PackageList<Package>>(tmpfileName);
+ pkgList.FixPackageListName(); // PackageListNameとの紐付けを行う
+
+ // RepositoryReferenceの名前を読み込む
+ repo.Name = (string.IsNullOrEmpty(pkgList.Name))? repo.Name : pkgList.Name;
+
+ avaiablePackageList.AddPackages(pkgList);
+ } catch (InvalidOperationException) {
+ RaiseTaskSetEvent(TaskEventType.ERROR, string.Format("レポジトリ'{0}'はAppliStation Native XML softlist形式ではありません。", repo.Name ?? repo.Url.Href));
+ }
+ } else {
+ RaiseTaskSetEvent(TaskEventType.WARNING, string.Format("レポジトリ'{0}'の設定が不正です。", repo.Name ?? repo.Url.Href));
+ }
+ i++;
+ }
+
+ pkgListMan.availablePkgList = avaiablePackageList; // Mediatorのリストを更新
+ pkgListMan.SaveAvailablePackageList();
+ }
+
+ private void runDeleteTempFiles()
+ {
+ if (tempRepoFiles != null) {
+ foreach (string file in tempRepoFiles) {
+ if (File.Exists(file)) {
+ File.Delete(file);
+ }
+ }
+ }
+ }
+
+ public override bool Cancelable {
+ get {
+ return !cancelCalled && Running && isDuringDownloading;
+ }
+ }
+
+ private bool isDuringDownloading {
+ get {
+ return Running && (currentSubTask is DownloadSubTask);
+ }
+ }
+
+ }
+}
<Compile Include="NaGet.Packages\VersionComparetor.cs" />\r
<Compile Include="NaGet.SubCommands.SubTask\FunctionalSubTask.cs" />\r
<Compile Include="NaGet.SubCommands.SubTask\DownloadSubTask.cs" />\r
+ <Compile Include="NaGet.SubCommands.SubTask\LocalUpdateSubTask.cs" />\r
<Compile Include="NaGet.SubCommands.SubTask\NaGetSubTask.cs" />\r
<Compile Include="NaGet.SubCommands\NaGetDownloadToCache.cs" />\r
<Compile Include="NaGet.SubCommands\NaGetInstall.cs" />\r
<Compile Include="NaGet.SubCommands\NaGetTaskSet.cs" />\r
<Compile Include="NaGet.SubCommands\NaGetTaskSet2.cs" />\r
<Compile Include="NaGet.SubCommands\NaGetUninstall.cs" />\r
+ <Compile Include="NaGet.SubCommands\NaGetUpdate2.cs" />\r
<Compile Include="NaGet.Tasks\Task.cs" />\r
<Compile Include="NaGet.Tasks\TaskCanceledException.cs" />\r
<Compile Include="NaGet.Tasks\TaskEventArgs.cs" />\r
<Compile Include="NaGet.Packages.Install\UninstallInformation.cs" />\r
<Compile Include="NaGet.Packages.Install\InstalledPackage.cs" />\r
<Compile Include="NaGet.SubCommands\NaGetUpdate.cs" />\r
- <None Include="NaGet.SubCommands.SubTask\LocalUpdateSubTask.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Folder Include="NaGet.InteropServices" />\r