示例#1
0
        private void DownloadAndOpenDataServicePackage(MruItem item)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                UIServices.Show(
                    PackageExplorer.Resources.Resources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            Uri downloadUrl;

            if (Uri.TryCreate(item.Path, UriKind.Absolute, out downloadUrl))
            {
                var progressWindow = new DownloadProgressWindow(downloadUrl, item.Id, item.Version)
                {
                    Owner = this
                };
                var result = progressWindow.ShowDialog();
                if (result ?? false)
                {
                    LoadPackage(progressWindow.DownloadedPackage, item.Path, PackageType.DataServicePackage);
                }
            }
        }
示例#2
0
        private void OpenPackageFromNuGetFeed()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                UIServices.Show(
                    PackageExplorer.Resources.Resources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            bool canceled = AskToSaveCurrentFile();

            if (canceled)
            {
                return;
            }

            var dialog = new PackageChooserDialog()
            {
                Owner       = this,
                DataContext = _packageViewModelFactory.CreatePackageChooserViewModel()
            };

            bool?result = dialog.ShowDialog();

            if (result ?? false)
            {
                PackageInfo selectedPackage = dialog.SelectedPackage;
                if (selectedPackage != null)
                {
                    Version  packageVersion = new Version(selectedPackage.Version);
                    IPackage cachePackage   = MachineCache.Default.FindPackage(selectedPackage.Id, packageVersion);;
                    if (cachePackage == null || cachePackage.GetHash() != selectedPackage.PackageHash)
                    {
                        // if not in the cache, or if the cache package's hash is different from the feed hash, (re)download it
                        var progressWindow = new DownloadProgressWindow(
                            selectedPackage.DownloadUrl,
                            selectedPackage.Id,
                            packageVersion)
                        {
                            Owner = this
                        };

                        result = progressWindow.ShowDialog();
                        if (result ?? false)
                        {
                            cachePackage = progressWindow.DownloadedPackage;
                        }
                    }

                    if (cachePackage != null)
                    {
                        DataServicePackage servicePackage = selectedPackage.AsDataServicePackage();
                        servicePackage.CorePackage = cachePackage;
                        LoadPackage(servicePackage, selectedPackage.DownloadUrl.ToString(), PackageType.DataServicePackage);
                    }
                }
            }
        }
示例#3
0
        private void OpenPackageFromNuGetFeed()
        {
            if (!NetworkInterface.GetIsNetworkAvailable()) {
                UIServices.Show(
                    PackageExplorer.Resources.Resources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            bool canceled = AskToSaveCurrentFile();
            if (canceled) {
                return;
            }

            var dialog = new PackageChooserDialog() {
                Owner = this,
                DataContext = _packageViewModelFactory.CreatePackageChooserViewModel()
            };

            bool? result = dialog.ShowDialog();
            if (result ?? false) {
                PackageInfo selectedPackage = dialog.SelectedPackage;
                if (selectedPackage != null) {
                    Version packageVersion = new Version(selectedPackage.Version);
                    IPackage cachePackage = MachineCache.Default.FindPackage(selectedPackage.Id, packageVersion); ;
                    if (cachePackage == null || cachePackage.GetHash() != selectedPackage.PackageHash) {
                        // if not in the cache, or if the cache package's hash is different from the feed hash, (re)download it
                        var progressWindow = new DownloadProgressWindow(
                            selectedPackage.DownloadUrl,
                            selectedPackage.Id,
                            packageVersion) {
                                Owner = this
                            };

                        result = progressWindow.ShowDialog();
                        if (result ?? false) {
                            cachePackage = progressWindow.DownloadedPackage;
                        }
                    }

                    if (cachePackage != null) {
                        DataServicePackage servicePackage = selectedPackage.AsDataServicePackage();
                        servicePackage.CorePackage = cachePackage;
                        LoadPackage(servicePackage, selectedPackage.DownloadUrl.ToString(), PackageType.DataServicePackage);
                    }
                }
            }
        }
示例#4
0
        private void DownloadAndOpenDataServicePackage(MruItem item)
        {
            if (!NetworkInterface.GetIsNetworkAvailable()) {
                UIServices.Show(
                    PackageExplorer.Resources.Resources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            Uri downloadUrl;
            if (Uri.TryCreate(item.Path, UriKind.Absolute, out downloadUrl)) {
                var progressWindow = new DownloadProgressWindow(downloadUrl, item.Id, item.Version) {
                    Owner = this
                };
                var result = progressWindow.ShowDialog();
                if (result ?? false) {
                    LoadPackage(progressWindow.DownloadedPackage, item.Path, PackageType.DataServicePackage);
                }
            }
        }