예제 #1
0
        protected void InitializeSettings()
        {
            var settings       = SettingsRepository.Get();
            var saveSettings   = !SettingsRepository.SettingsFileExists;
            var currentVersion = VsixManifest.GetManifest().Version;
            var templateFolder = !SettingsRepository.SettingsFileExists ? LegacySettings.GetGlobalTemplateFolder() : "";

            TemplatesFolder = settings.GetSetting(TemplatesFolderKey,
                                                  !string.IsNullOrEmpty(templateFolder) ? templateFolder : DefaultRootPath);

            InstalledVersion   = settings.GetSetting(InstalledVersionKey, currentVersion);
            TempFolderPath     = settings.GetSetting(TempFolderPathKey, @"c:\_vstemp");
            DefaultDownloadUrl = string.Concat(GithubTemplatesArchiveRootPath, $"release/v{currentVersion}.zip");
            DownloadUrl        = settings.GetSetting(DownloadFromUrlKey, DefaultDownloadUrl);

            if (!DownloadUrl.Equals(DefaultDownloadUrl, StringComparison.Ordinal) &&
                DownloadUrl.StartsWith($"{GithubTemplatesArchiveRootPath}release/v", StringComparison.OrdinalIgnoreCase))
            {
                DownloadUrl  = DefaultDownloadUrl;
                saveSettings = true;
            }

            DownloadTemplates = settings.GetBooleanSetting(DownloadTemplatesKey, true);
            ShowVsTokensTab   = settings.GetBooleanSetting(ShowVsTokensTabKey, true);

            var shownNoticeVersion = settings.GetSetting(VersionNoticeShownForKey);

            VersionNoticeShown = settings.GetBooleanSetting(VersionNoticeShownKey) && shownNoticeVersion.Equals(InstalledVersion);

            if (saveSettings)
            {
                SaveSettings();
            }
        }
예제 #2
0
        public async Task <DownloadUrl> GetDownloadUrl()
        {
            if (!_isAuthenticated)
            {
                await Login();
            }

            if (_activeAgent == null)
            {
                throw new ConnectionException($"There is no remote agent available for the hub {DefaultDatabase}.");
            }

            if (_downloadUrl == null)
            {
                if (_activeAgent.DownloadUrls.Length == 0)
                {
                    throw new ConnectionException($"There are no download urls available for the remoate agent {_activeAgent.Name}.");
                }

                foreach (var downloadUrl in _activeAgent.DownloadUrls)
                {
                    var response = await _httpClient.GetAsync(downloadUrl.Url + "/ping");

                    if (response.IsSuccessStatusCode)
                    {
                        _downloadUrl = downloadUrl;
                        return(downloadUrl);
                    }
                }

                throw new ConnectionException($"Could not connect with any of the download urls for the remoate agent {_activeAgent.Name}.");
            }

            return(_downloadUrl);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            AppPaths.ConfigureFFmpegPaths(this);

            GridInfo.Visibility      = Visibility.Hidden;
            DownloadsView.Visibility = Visibility.Hidden;
            DownloadUrl.Focus();
            DownloadsView.ItemsSource = Manager.DownloadsList;

            List <ListItem <int> > DownloadQualityList = new List <ListItem <int> >();

            DownloadQualityList.Add(new ListItem <int>("Max", 0));
            DownloadQualityList.Add(new ListItem <int>("1080p", 1080));
            DownloadQualityList.Add(new ListItem <int>("720p", 720));
            DownloadQualityList.Add(new ListItem <int>("480p", 480));
            DownloadQualityList.Add(new ListItem <int>("360p", 360));
            DownloadQualityList.Add(new ListItem <int>("240p", 240));
            MaxDownloadQualityCombo.ItemsSource   = DownloadQualityList;
            MaxDownloadQualityCombo.SelectedIndex = 0;

            SplashWindow F = SplashWindow.Instance(this, Properties.Resources.AppIcon);

            F.CanClose();
            F.ShowDialog();
        }
예제 #4
0
 private void Download()
 {
     if (DownloadUrl.StartsWith("http", System.StringComparison.OrdinalIgnoreCase))
     {
         var downloader = new AssetDownloader(DownloadUrl, Path.GetFileName(DownloadUrl))
         {
             DownloadFolder = DownloadFolder
         };
         downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;
         downloader.Download();
     }
     else
     {
         if (DownloadUrl.EndsWith(".zip", System.StringComparison.OrdinalIgnoreCase))
         {
             File.Copy(DownloadUrl, Path.Combine(DownloadFolder, Path.GetFileName(DownloadUrl)));
         }
         else
         {
             var robo = new ExecutableUtil()
             {
                 Executable   = "robocopy.exe",
                 SuccessCodes = new[] { 0, 1 },
                 Args         = $"\"{DownloadUrl}\" \"{DownloadFolder}\" /E /PURGE /XA:H"
             };
             var result = robo.Run();
             if (!result.WasSuccess)
             {
                 throw new System.Exception(result.Output);
             }
         }
     }
 }
예제 #5
0
        private void GetDownloadUrl(Invoice invoice, PSInvoice psInvoice, string billingAccountName, bool downloadBySubscription = false)
        {
            var invoiceDocument = invoice.Documents.FirstOrDefault(p =>
                                                                   p.Kind.Equals("INVOICE", StringComparison.InvariantCultureIgnoreCase) &&
                                                                   p.Url.Contains(invoice.Name) &&
                                                                   p.Source.Equals("DRS", StringComparison.InvariantCultureIgnoreCase));

            if (invoiceDocument != null)
            {
                DownloadUrl downloadUrl = null;

                var downloadToken = invoiceDocument.Url.Split('=')?[1].Split('&')?[0];

                if (invoiceDocument.Url.ToLowerInvariant().Contains("billingaccounts/default/billingsubscriptions") ||
                    downloadBySubscription)
                {
                    downloadUrl = BillingManagementClient.Invoices
                                  .DownloadBillingSubscriptionInvoice(
                        invoiceName: invoice.Name,
                        downloadToken: downloadToken);
                }
                else
                {
                    downloadUrl = BillingManagementClient.Invoices
                                  .DownloadInvoice(
                        billingAccountName: billingAccountName,
                        invoiceName: invoice.Name,
                        downloadToken: downloadToken);
                }

                psInvoice.DownloadUrl       = downloadUrl.Url;
                psInvoice.DownloadUrlExpiry = downloadUrl.ExpiryTime;
            }
        }
예제 #6
0
 public DownloadDataTask(ISharedSettings sharedSettings, long hubKey, DownloadData downloadData, DownloadUrl downloadUrl, string connectionId, string reference)
 {
     _sharedSettings = sharedSettings;
     _hubKey         = hubKey;
     _downloadData   = downloadData;
     _downloadUrl    = downloadUrl;
     _connectionId   = connectionId;
     _reference      = reference;
 }
예제 #7
0
 private void UnZip()
 {
     if (DownloadUrl.EndsWith(".zip", System.StringComparison.OrdinalIgnoreCase))
     {
         var filename = Path.GetFileName(DownloadUrl);
         var zip      = Path.Combine(DownloadFolder, filename);
         Logger?.Info("PluginUpdator - UnZip");
         ZipFile.ExtractToDirectory(zip, Path.Combine(Path.GetDirectoryName(zip), Path.GetFileNameWithoutExtension(zip)));
     }
 }
예제 #8
0
        /// <summary>
        /// Update Downlaoder
        /// </summary>
        /// <param name="downloadurl">file url to download</param>
        public void DownloadUpdate()
        {
            bool useDownloadSpeedThrottling = false;

            var file              = new FileInfo(Path.GetFileName(DownloadUrl.ToString()));
            var requestBuilder    = new SimpleWebRequestBuilder();
            var dlChecker         = new DownloadChecker();
            var httpDlBuilder     = new SimpleDownloadBuilder(requestBuilder, dlChecker);
            var timeForHeartbeat  = 3000;
            var timeToRetry       = 5000;
            var maxRetries        = 25;
            var resumingDlBuilder = new ResumingDownloadBuilder(timeForHeartbeat, timeToRetry, maxRetries, httpDlBuilder);
            List <DownloadRange> alreadyDownloadedRanges = null;
            var bufferSize    = 4096;
            var numberOfParts = 4;
            var download      = new MultiPartDownload(DownloadUrl, bufferSize, numberOfParts, resumingDlBuilder, requestBuilder, dlChecker, alreadyDownloadedRanges);
            var speedMonitor  = new DownloadSpeedMonitor(maxSampleCount: 50000);

            speedMonitor.Attach(download);
            var progressMonitor = new DownloadProgressMonitor();

            progressMonitor.Attach(download);

            if (useDownloadSpeedThrottling)
            {
                var downloadThrottling = new DownloadThrottling(maxBytesPerSecond: 200 * 10024, maxSampleCount: 1288);
                downloadThrottling.Attach(download);
            }

            var dlSaver = new DownloadToFileSaver(file);

            dlSaver.Attach(download);
            download.DownloadCompleted += OnCompleted;
            download.Start();

            while (!DownloadFinished)
            {
                var alreadyDownloadedSizeInBytes = progressMonitor.GetCurrentProgressInBytes(download);
                var totalDownloadSizeInBytes     = progressMonitor.GetTotalFilesizeInBytes(download);
                var currentSpeedInBytesPerSecond = speedMonitor.GetCurrentBytesPerSecond();

                var currentProgressInPercent   = progressMonitor.GetCurrentProgressPercentage(download) * 100;
                var alreadyDownloadedSizeInKiB = (alreadyDownloadedSizeInBytes / 1024);
                var totalDownloadSizeInKiB     = (totalDownloadSizeInBytes / 1024);
                var currentSpeedInKiBPerSecond = (currentSpeedInBytesPerSecond / 1024);
                var remainingTimeInSeconds     = currentSpeedInBytesPerSecond == 0 ? 0 : (totalDownloadSizeInBytes - alreadyDownloadedSizeInBytes) / currentSpeedInBytesPerSecond;

                DownloaderProgress.Progress       = currentProgressInPercent;
                DownloaderProgress.DownlaodedSize = alreadyDownloadedSizeInKiB;
                DownloaderProgress.TotalSize      = totalDownloadSizeInKiB;
                DownloaderProgress.Speed          = currentSpeedInKiBPerSecond;
                DownloaderProgress.RemainingTime  = remainingTimeInSeconds;
            }
        }
예제 #9
0
        /// <summary>
        /// Serves as the default hash function.
        /// </summary>
        /// <returns>A hash code for the current object.</returns>
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = PayloadId != null?PayloadId.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (DownloadUrl != null ? DownloadUrl.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (int)Status;

                return(hashCode);
            }
        }
예제 #10
0
        public virtual void WriteTo(XElement xE)
        {
            XElement xItem = null;

            if (Id != null)
            {
                xItem = new XElement(XName.Get("id", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(Id.Value.ToString());
                xE.Add(xItem);
            }
            if (Status != null)
            {
                xItem = new XElement(XName.Get("status", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(Status.Value.ToXmlValue());
                xE.Add(xItem);
            }
            if (ProgressStats != null)
            {
                xItem = new XElement(XName.Get("progressStats", "https://adwords.google.com/api/adwords/cm/v201609"));
                ProgressStats.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (UploadUrl != null)
            {
                xItem = new XElement(XName.Get("uploadUrl", "https://adwords.google.com/api/adwords/cm/v201609"));
                UploadUrl.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (DownloadUrl != null)
            {
                xItem = new XElement(XName.Get("downloadUrl", "https://adwords.google.com/api/adwords/cm/v201609"));
                DownloadUrl.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (ProcessingErrors != null)
            {
                foreach (var processingErrorsItem in ProcessingErrors)
                {
                    xItem = new XElement(XName.Get("processingErrors", "https://adwords.google.com/api/adwords/cm/v201609"));
                    processingErrorsItem.WriteTo(xItem);
                    xE.Add(xItem);
                }
            }
            if (DiskUsageQuotaBalance != null)
            {
                xItem = new XElement(XName.Get("diskUsageQuotaBalance", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(DiskUsageQuotaBalance.Value.ToString());
                xE.Add(xItem);
            }
        }
예제 #11
0
        public override InputValidationResult ValidateInput()
        {
            if (DownloadUrl.IsNullOrWhiteSpace())
            {
                return(new InputValidationResult(Resources.StaticCommands.UrlCannotBeEmpty, ValidationState.Error));
            }

            if (!string.IsNullOrEmpty(Hash) && (Hash?.Length != 64 || !Hash.IsHex()))
            {
                return(InputValidationResult.Error(Resources.StaticCommands.InvalidSHA256HashValueHex));
            }

            return(InputValidationResult.Successful);
        }
예제 #12
0
 public DownloadFilesTask(ISharedSettings sharedSettings, string messageId, long hubKey, ConnectionFlatFile connectionFlatFile,
                          FlatFile flatFile, EFlatFilePath path, string[] files, DownloadUrl downloadUrl, string connectionId, string reference)
 {
     _sharedSettings     = sharedSettings;
     _messageId          = messageId;
     _hubKey             = hubKey;
     _connectionFlatFile = connectionFlatFile;
     _flatFile           = flatFile;
     _path         = path;
     _files        = files;
     _downloadUrl  = downloadUrl;
     _connectionId = connectionId;
     _reference    = reference;
 }
예제 #13
0
        /// <summary>
        /// Tries to download and execute the latest installer from GitHub.
        /// </summary>
        public static void TryToInstall()
        {
            var newFile = Path.GetTempPath() + FileName;

            if (File.Exists(newFile))
            {
                File.Delete(newFile);
            }

            var file = DownloadUrl.DownloadFileAsync(Path.GetTempPath()).Result;

            if (file != default(string))
            {
                Process.Start(file);
            }
        }
예제 #14
0
        public void Init(string storePath, VersionModel model)
        {
            DownloadUrl = model.ResourceUrl.Replace("\\", "/");
            FilePath    = System.IO.Path.Combine(storePath, DownloadUrl.Substring(DownloadUrl.LastIndexOf("/") + 1));
            ResVersion  = model.ToVersion;

            FileInfo fileInfo = new FileInfo(FilePath);

            if (fileInfo.Exists)
            {
                _fileInfo = fileInfo;
                ExistSize = (int)fileInfo.Length;
            }

            DownloadSize = ExistSize;
            TotalSize    = int.Parse(model.FileSize);
        }
예제 #15
0
        private void Deploy()
        {
            Logger?.Info("PluginUpdator - deploying");

            string source;

            if (DownloadUrl.EndsWith(".zip", System.StringComparison.OrdinalIgnoreCase))
            {
                var filename = Path.GetFileName(DownloadUrl);
                source = Path.Combine(DownloadFolder, Path.GetFileNameWithoutExtension(filename));
            }
            else
            {
                source = DownloadFolder;
            }

            var installer = new CcnetPluginInstaller(source, PluginDirectory, ServiceDirecotry);

            installer.Install();
        }
예제 #16
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((Type != null ? Type.GetHashCode() : 0) ^ (Sha != null ? Sha.GetHashCode() : 0) ^ (Path != null ? Path.GetHashCode() : 0) ^ (GitUrl != null ? GitUrl.GetHashCode() : 0) ^ (HtmlUrl != null ? HtmlUrl.GetHashCode() : 0) ^ (DownloadUrl != null ? DownloadUrl.GetHashCode() : 0) ^ (Encoding != null ? Encoding.GetHashCode() : 0) ^ (Url != null ? Url.GetHashCode() : 0) ^ (Size != null ? Size.GetHashCode() : 0) ^ (Name != null ? Name.GetHashCode() : 0) ^ (Content != null ? Content.GetHashCode() : 0));
     }
 }
예제 #17
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Low, $"Task {nameof (PrepareInstall)}");
            Log.LogMessage(MessageImportance.Low, $"  {nameof (HostOS)}: {HostOS}");
            Log.LogMessage(MessageImportance.Low, $"  {nameof (HostOSName)}: {HostOSName}");
            Log.LogMessage(MessageImportance.Low, $"  {nameof (Program)}: {Program}");
            Log.LogMessage(MessageImportance.Low, $"  {nameof (UseSudo)}: {UseSudo}");

            SetDownloadUrl();
            SetInstallCommand();

            Log.LogMessage(MessageImportance.Low, $"  [Output] {nameof (DownloadUrl)}: {DownloadUrl} [Url: {DownloadUrl?.GetMetadata ("Url")}]");
            Log.LogMessage(MessageImportance.Low, $"  [Output] {nameof (InstallCommand)}: {InstallCommand}");

            return(!Log.HasLoggedErrors);
        }
예제 #18
0
        public HttpResponseMessage DownloadM(DownloadUrl t)
        {
            if (t == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            HttpResponseMessage result = null;

            try
            {
                var httpRequest = HttpContext.Current.Request;

                Boolean bCheck = false;
                var     user   = User.Identity.Name;
                string  sRight = "R";



                using (ZipFile zip = new ZipFile())
                {
                    zip.AlternateEncodingUsage = ZipOption.AsNecessary;
                    zip.AddDirectoryByName("Files");


                    foreach (var percorso in t.Urls)
                    {
                        bCheck = false;

                        //var user = User.Identity.Name;
                        using (ExtranetDB dbContext = new ExtranetDB())
                        {
                            var sPath        = percorso.Split('/');
                            var sPathToCheck = sPath[0];
                            //var utente = dbContext.Users.Include("UserShares");
                            //FTPabilitazioni[] abilitazioni = dbContext.FTPabilitazioni.Include("UserShares").Where(e => e.ftpUser == User.Identity.Name && e.UserShares).FirstOrDefault();
                            UserShares abilitazioni = dbContext.UserShares.Where(e => e.username == User.Identity.Name && e.SharePath == sPathToCheck).FirstOrDefault();
                            if (abilitazioni != null)
                            {
                                bCheck = true;
                            }
                        }
                        if (bCheck == false)
                        {
                            var resultB = new HttpResponseMessage(HttpStatusCode.BadRequest);
                            return(resultB);
                        }

                        var sPercorso = ftpRoot + "\\" + percorso;
                        sPercorso = sPercorso.Replace("/", "\\");
                        zip.AddFile(sPercorso.ToString(), "Files");
                    }
                    return(ZipContentResult(zip));
                }
            }

            catch (Exception e)
            {
                result = Request.CreateResponse(HttpStatusCode.BadRequest, e.Message);
            }
            return(result);
        }
        public void StartDownload(string url)
        {
            mutex_.WaitOne();

            try
            {
                string host_url = url;
                if (host_url[host_url.Length - 1] != '/')
                    host_url += "/";

                if (state_ == State.Downloading)
                {
                    DownloadUrl info = new DownloadUrl();
                    info.host = host_url;
                    info.url = url;
                    url_list_.Add(info);
                    return;
                }

                state_ = State.Start;
                host_url_ = host_url;

                // Check file list
                CheckLocalFiles();
            }
            finally
            {
                mutex_.ReleaseMutex();
            }
        }
예제 #20
0
        //public string VersionStatus { get; set; }

        public void OpenDaxStudioReleasePageInBrowser()
        {
            // Open URL in Browser
            System.Diagnostics.Process.Start(DownloadUrl.ToString());
        }