示例#1
0
        internal void OnInstall(object _item)
        {
            IsBusy = true;
            Task.Run(async() =>
            {
                try
                {
                    if (!string.IsNullOrEmpty(SelectedPackageItem.InstalledVersion))
                    {
                        var _minver   = VersionRange.Parse(SelectedPackageItem.InstalledVersion);
                        var _identity = new PackageIdentity(SelectedPackageItem.Id, _minver.MinVersion);

                        // per project or joined ?
                        // string TargetFolder = System.IO.Path.Combine(project.Path, "extensions");
                        string TargetFolder = System.IO.Path.Combine(Interfaces.Extensions.ProjectsDirectory, "extensions");

                        BusyContent = "Uninstalling " + _identity.ToString();
                        NuGetPackageManager.Instance.UninstallPackage(TargetFolder, _identity);
                        SelectedPackageItem.IsInstalled = false;
                    }
                    BusyContent  = "Initializing";
                    var minver   = VersionRange.Parse(SelectedPackageItem.SelectedVersion);
                    var identity = new PackageIdentity(SelectedPackageItem.Id, minver.MinVersion);
                    if (SelectedPackageItem.RequireLicenseAcceptance)
                    {
                        // Request accept
                    }
                    if (project.dependencies == null)
                    {
                        project.dependencies = Newtonsoft.Json.Linq.JObject.Parse("{}");
                    }
                    project.dependencies.Remove(identity.Id);
                    project.dependencies.Add(identity.Id, minver.MinVersion.ToString());
                    BusyContent = "Saving current project settings";
                    await project.Save(false);
                    BusyContent = "Installing NuGet Packages";
                    await project.InstallDependencies(false);
                    NeedsReload = true;
                    //BusyContent = "Reloading Activities Toolbox";
                    //GenericTools.RunUI(()=> WFToolbox.Instance.InitializeActivitiesToolbox());
                    SelectedPackageItem.InstalledVersion = SelectedPackageItem.SelectedVersion;
                    SelectedPackageItem.IsInstalled      = true;
                    IsBusy = false;
                    if (SelectedPackageSource.source == null)
                    {
                        SelectedPackageSource.ClearCache();
                        GenericTools.RunUI(() =>
                        {
                            FilterText = FilterText;
                        });
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            });
        }
示例#2
0
        //private async Task UpdateFilterText(string value)
        //{
        //    _FilterText = value;
        //    NotifyPropertyChanged("FilterText");
        //    if (SelectedPackageSource == null) { IsBusy = false; return; }
        //    async Task<bool> UserKeepsTyping()
        //    {
        //        string txt = value;   // remember text
        //        await Task.Delay(500);        // wait some
        //        return txt != value;  // return that text chaged or not
        //    }
        //    if (await UserKeepsTyping()) return;
        //    SelectedPackageSource.Search(project, this, IncludePrerelease, _FilterText);
        //}
        private void treePackageSources_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            SelectedPackageSource = treePackageSources.SelectedItem as PackageSourceWrapper;
            if (SelectedPackageSource.source == null)
            {
                SelectedPackageSource.ClearCache();
            }

            FilterText = "";
        }
示例#3
0
        internal void OnUninstall(object _item)
        {
            IsBusy = true;
            Task.Run(async() =>
            {
                try
                {
                    BusyContent  = "Initializing";
                    var minver   = VersionRange.Parse(SelectedPackageItem.InstalledVersion);
                    var identity = new PackageIdentity(SelectedPackageItem.Id, minver.MinVersion);
                    if (project.dependencies == null)
                    {
                        project.dependencies = Newtonsoft.Json.Linq.JObject.Parse("{}");
                    }
                    project.dependencies.Remove(identity.Id);

                    // per project or joined ?
                    // string TargetFolder = System.IO.Path.Combine(project.Path, "extensions");
                    string TargetFolder = System.IO.Path.Combine(Interfaces.Extensions.ProjectsDirectory, "extensions");

                    BusyContent = "Uninstalling package";
                    NuGetPackageManager.Instance.UninstallPackage(TargetFolder, identity);
                    SelectedPackageItem.IsInstalled = false;
                    BusyContent = "Saving current project settings";
                    await project.Save(false);
                    //BusyContent = "Updating NuGet Packages";
                    //await project.InstallDependencies();
                    //BusyContent = "Reloading Activities Toolbox";
                    //GenericTools.RunUI(() => WFToolbox.Instance.InitializeActivitiesToolbox());
                    SelectedPackageItem.InstalledVersion = "";
                    SelectedPackageItem.IsInstalled      = false;
                    if (NuGetPackageManager.PendingDeletion.Count > 0)
                    {
                        Config.local.files_pending_deletion = NuGetPackageManager.PendingDeletion.ToArray();
                        Config.Save();
                        MessageBox.Show("Please restart the robot for the change to take fully effect");
                    }
                    if (SelectedPackageSource.source == null)
                    {
                        SelectedPackageSource.ClearCache();
                        GenericTools.RunUI(() =>
                        {
                            FilterText = FilterText;
                        });
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
                IsBusy = false;
            });
        }
示例#4
0
        internal void OnUninstall(object _item)
        {
            IsBusy = true;
            Task.Run(async() =>
            {
                try
                {
                    BusyContent  = "Initializing";
                    var minver   = VersionRange.Parse(SelectedPackageItem.InstalledVersion);
                    var identity = new PackageIdentity(SelectedPackageItem.Id, minver.MinVersion);

                    if (project.dependencies == null)
                    {
                        project.dependencies = new Dictionary <string, string>();
                    }
                    var keys = project.dependencies.Keys.ToList();
                    foreach (var key in keys)
                    {
                        if (key.ToLower() == identity.Id.ToLower())
                        {
                            project.dependencies.Remove(key);
                        }
                    }
                    // per project or joined ?
                    // string TargetFolder = System.IO.Path.Combine(project.Path, "extensions");
                    string TargetFolder = System.IO.Path.Combine(Interfaces.Extensions.ProjectsDirectory, "extensions");

                    BusyContent = "Uninstalling package";
                    NuGetPackageManager.Instance.UninstallPackage(TargetFolder, identity);
                    SelectedPackageItem.IsInstalled = false;
                    BusyContent = "Saving current project settings";
                    await project.Save <Project>(true);
                    //BusyContent = "Updating NuGet Packages";
                    //await project.InstallDependencies();
                    //BusyContent = "Reloading Activities Toolbox";
                    //GenericTools.RunUI(() => WFToolbox.Instance.InitializeActivitiesToolbox());
                    SelectedPackageItem.InstalledVersion = "";
                    SelectedPackageItem.IsInstalled      = false;
                    if (NuGetPackageManager.PendingDeletion.Count > 0)
                    {
                        Config.local.files_pending_deletion = NuGetPackageManager.PendingDeletion.ToArray();
                        Config.Save();
                        Log.Output("Please restart the robot for the change to take fully effect");
                        Log.Warning("package files will be deleted next time you start the robot");
                        // MessageBox.Show("Please restart the robot for the change to take fully effect");
                    }
                    if (SelectedPackageSource.source == null)
                    {
                        GenericTools.RunUI(() =>
                        {
                            SelectedPackageSource.ClearCache();
                            FilterText = FilterText;
                        });
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
                IsBusy = false;
            });
        }