Ejemplo n.º 1
0
        public override void OnCreate(BitsJob jobToConfigure)
        {
            jobToConfigure.Description =
                string.Format("License verification for {0}", Name);

            jobToConfigure.AddFile(
                VerifyUrl,
                LocalFileName
                );
        }
Ejemplo n.º 2
0
        /// <summary>Downloads the application updates.</summary>
        /// <param name="application">The Sui containing the update info.</param>
        /// <param name="bitsJob">The bits job that will download the update.</param>
        static void DownloadUpdates(Sui application, ref BitsJob bitsJob)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            if (bitsJob == null)
            {
                throw new ArgumentNullException("bitsJob");
            }

            for (int y = 0; y < application.Updates.Count; y++)
            {
                // Create download directory consisting of application name and update title
                string downloadDir = Path.Combine(downloadDirectory, application.Updates[y].Name[0].Value);

                Directory.CreateDirectory(downloadDir);

                for (int z = 0; z < application.Updates[y].Files.Count; z++)
                {
                    if (application.Updates[y].Files[z].Action == FileAction.Delete ||
                        application.Updates[y].Files[z].Action == FileAction.UnregisterThenDelete ||
                        application.Updates[y].Files[z].Action == FileAction.CompareOnly)
                    {
                        continue;
                    }

                    string destination = Path.GetFileName(application.Updates[y].Files[z].Destination);
                    if (string.IsNullOrWhiteSpace(destination))
                    {
                        throw new InvalidOperationException();
                    }

                    if (Utilities.GetHash(Path.Combine(downloadDir, destination))
                        == application.Updates[y].Files[z].Hash)
                    {
                        continue;
                    }

                    try
                    {
                        File.Delete(Path.Combine(downloadDir, destination));
                    }
                    catch (IOException)
                    {
                    }

                    bitsJob.AddFile(
                        new Uri(application.Updates[y].Files[z].Source).AbsoluteUri,
                        Path.Combine(downloadDir, destination));
                }
            }
        }