Esempio n. 1
0
        private void CommitItems(List <UpdateItem> updateItems, string rootDirectory, string sourceDirectory)
        {
            string relativeDirectory = sourceDirectory.Substring(rootDirectory.Length).TrimStart(new char [] { '\\' });

            foreach (string directory in Directory.GetDirectories(sourceDirectory))
            {
                CommitItems(updateItems, rootDirectory, directory);
            }

            foreach (string filename in Directory.GetFiles(sourceDirectory))
            {
                bool foundExistingItem = false;
                foreach (UpdateItem updateItem in updateItems)
                {
                    if (updateItem.RelativeDirectory == relativeDirectory && updateItem.Name == Path.GetFileName(filename))
                    {
                        AutoUpdateManager.DeleteFileFromPackage(this.Target, updateItem.RelativeDirectory, updateItem.Name);
                        AutoUpdateManager.AddFileToPackage(this.Target, relativeDirectory, filename);

                        if (updateItem.IsProtected == true)
                        {
                            AutoUpdateManager.SetFileProtectionForPackage(this.Target, relativeDirectory, Path.GetFileName(filename), updateItem.IsProtected);
                        }

                        if (updateItem.IsIncluded == false)
                        {
                            AutoUpdateManager.SetFileInclusionForPackage(this.Target, relativeDirectory, Path.GetFileName(filename), updateItem.IsIncluded);
                        }

                        foundExistingItem = true;
                        break;
                    }
                }

                if (foundExistingItem == false)
                {
                    AutoUpdateManager.AddFileToPackage(this.Target, relativeDirectory, filename);
                }
            }

            // Clean up files that are no longer in the package.
            foreach (UpdateItem updateItem in updateItems)
            {
                if (updateItem.RelativeDirectory == relativeDirectory)
                {
                    if (File.Exists(Path.Combine(sourceDirectory, updateItem.Name)) == false)
                    {
                        AutoUpdateManager.DeleteFileFromPackage(this.Target, updateItem.RelativeDirectory, updateItem.Name);
                    }
                }
            }
        }
Esempio n. 2
0
        private void AddUploadedFilesToPackage(string packageName, string rootDirectory, string currentDirectory)
        {
            foreach (string directory in Directory.GetDirectories(currentDirectory))
            {
                AddUploadedFilesToPackage(packageName, rootDirectory, directory);
            }

            string relativeDirectory = currentDirectory.Substring(rootDirectory.Length).TrimStart(new char[] { '\\' });

            foreach (string filename in Directory.GetFiles(currentDirectory))
            {
                AutoUpdateManager.AddFileToPackage(packageName, relativeDirectory, filename);
            }
        }