Ejemplo n.º 1
0
        internal void CopyFiles(string moduleName, bool @overrideSystemVersion)
        {
            var tempInstallationPath = _installationFileManager.GetTempInstallationPath(moduleName);

            if (!Directory.Exists(tempInstallationPath.PhysicalPath))
            {
                throw new Exception("The temporary installation directory has been deleted.".Localize());
            }
            ModulePath modulePath = new ModulePath(moduleName);

            Kooboo.IO.IOUtility.CopyDirectory(tempInstallationPath.PhysicalPath, modulePath.PhysicalPath);
            var assemblyFiles = Directory.EnumerateFiles(modulePath.GetModuleInstallationFilePath("Bin").PhysicalPath);
            var binPath       = Settings.BinDirectory;

            foreach (var item in assemblyFiles)
            {
                if (!_assemblyReferences.IsSystemAssembly(item))
                {
                    var fileName      = Path.GetFileName(item);
                    var fileNameInBin = Path.Combine(binPath, fileName);
                    var exists        = File.Exists(fileNameInBin);
                    if (!exists || (exists && overrideSystemVersion))
                    {
                        File.Copy(item, fileNameInBin, overrideSystemVersion);
                    }
                    _assemblyReferences.AddReference(fileNameInBin, moduleName);
                }
            }
        }
Ejemplo n.º 2
0
        public void EnsureAssembliesExistsInBin(Site site, bool overwrite = true, bool copyParent = true, bool copyChildren = false)
        {
            var files = GetFiles(site);

            foreach (var file in files)
            {
                if (!_assemblyReferences.IsSystemAssembly(file.PhysicalPath))
                {
                    var fileInBin = GetAssemblyBinFilePath(file.FileName);
                    if (overwrite == true || !File.Exists(fileInBin))
                    {
                        File.Copy(file.PhysicalPath, fileInBin, true);
                        _assemblyReferences.AddReference(file.PhysicalPath, GetReferenceName(site));
                    }
                }
            }
            //foreach (var file in files)
            //{
            //    var assembly = GetAssembly(site, file.FileName);
            //    if (assembly == null)
            //    {
            //        var fileInBin = GetAssemblyBinFilePath(file.FileName);
            //        Assembly.LoadFrom(fileInBin);
            //    }
            //}
            if (copyParent && site.Parent != null)
            {
                EnsureAssembliesExistsInBin(site.Parent, copyParent, copyChildren);
            }
            if (copyChildren)
            {
                foreach (var child in ServiceFactory.SiteManager.ChildSites(site))
                {
                    EnsureAssembliesExistsInBin(child, copyParent, copyChildren);
                }
            }
        }