public void Delete(IEnumerable <DataSourceId> dataSourceIds)
        {
            foreach (DataSourceId dataSourceId in dataSourceIds)
            {
                if (dataSourceId == null)
                {
                    throw new ArgumentException("DataSourceIds must me non-null");
                }
            }

            foreach (DataSourceId dataSourceId in dataSourceIds)
            {
                MediaDataId dataId = dataSourceId.DataId as MediaDataId;

                if (dataId.MediaType == _fileType)
                {
                    if (IsReadOnlyFolder(dataId.Path))
                    {
                        throw new ArgumentException("Cannot delete read only file " + dataId.FileName);
                    }
                    C1File.Delete(GetAbsolutePath(dataId));
                }
                else
                {
                    if (IsReadOnlyFolder(dataId.Path))
                    {
                        throw new ArgumentException("Cannot delete read only folder " + dataId.Path);
                    }
                    C1Directory.Delete(GetAbsolutePath(dataId), true);
                }
            }
        }
        private static void MoveRenderingLayoutToFormsFolder(string baseFolder)
        {
            var layoutsFolder = Path.Combine(baseFolder, "FormRenderingLayouts");

            if (!C1Directory.Exists(layoutsFolder))
            {
                return;
            }

            foreach (var file in C1Directory.GetFiles(layoutsFolder, "*.xml"))
            {
                var fileName = Path.GetFileNameWithoutExtension(file);
                if (fileName == null)
                {
                    continue;
                }

                var folder = Path.Combine(baseFolder, fileName);
                if (!C1Directory.Exists(folder))
                {
                    C1Directory.CreateDirectory(folder);
                }

                var newFilePath = Path.Combine(folder, "RenderingLayout.xml");
                File.Move(file, newFilePath);
            }

            C1Directory.Delete(layoutsFolder);
        }
        private IEnumerable <PackageFragmentValidationResult> FinalizeProcess()
        {
            try
            {
                if (_packageInstallDirectory != null &&
                    (_preUninstallValidationResult == null || _preUninstallValidationResult.Count == 0) &&
                    (_validationResult == null || _validationResult.Count == 0) &&
                    (_uninstallationResult == null || _uninstallationResult.Count == 0))
                {
                    if (C1Directory.Exists(_packageInstallDirectory))
                    {
                        C1Directory.Delete(_packageInstallDirectory, true);
                    }

                    Log.LogInformation(LogTitle, "Package successfully uninstalled");
                }

                return(new List <PackageFragmentValidationResult>());
            }
            catch (Exception ex)
            {
                return(new List <PackageFragmentValidationResult> {
                    new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex)
                });
            }
        }
Example #4
0
        public override IEnumerable <XElement> Install()
        {
            if (_files == null && _directories == null)
            {
                throw new InvalidOperationException(GetType().Name + " has not been validated");
            }

            if (_files != null)
            {
                foreach (var file in _files)
                {
                    C1File.Delete(file);
                }
            }

            if (_directories != null)
            {
                foreach (var directory in _directories)
                {
                    C1Directory.Delete(directory, true);
                }
            }

            return(Configuration);
        }
        internal static void DeleteEmptyAncestorFolders(string filePath)
        {
            string folder = Path.GetDirectoryName(filePath);

            while (!C1Directory.GetFiles(folder).Any() && !C1Directory.GetDirectories(folder).Any())
            {
                C1Directory.Delete(folder);

                folder = folder.Substring(0, folder.LastIndexOf('\\'));
            }
        }
        /// <exclude />
        public void CancelInstallation()
        {
            if (_zipFilename != null && C1File.Exists(_zipFilename))
            {
                C1File.Delete(_zipFilename);
            }

            if (C1Directory.Exists(_packageInstallDirectory))
            {
                C1Directory.Delete(_packageInstallDirectory, true);
            }
        }
        public static void Delete(IDynamicDefinition definition)
        {
            var dir = Path.Combine(ModelsFacade.RootPath, definition.Name);

            C1Directory.Delete(dir, true);

            foreach (var submitHandler in definition.SubmitHandlers)
            {
                submitHandler.Delete(definition);
            }

            ModelsFacade.NotifyFormChanges();
        }
        private ICollection <PackageFragmentValidationResult> FinalizeProcess(bool install)
        {
            try
            {
                if (_zipFilename != null && C1File.Exists(_zipFilename))
                {
                    C1File.Delete(_zipFilename);
                }

                Func <IList <PackageFragmentValidationResult>, bool> isNotEmpty = list => list != null && list.Count > 0;

                bool installationFailed = isNotEmpty(_preInstallValidationResult) ||
                                          isNotEmpty(_validationResult) ||
                                          isNotEmpty(_installationResult);

                if (installationFailed && C1Directory.Exists(_packageInstallDirectory))
                {
                    C1Directory.Delete(_packageInstallDirectory, true);
                }

                if (!installationFailed && install)
                {
                    Log.LogInformation(LogTitle, "Package successfully installed");

                    C1File.WriteAllText(Path.Combine(_packageInstallDirectory, PackageSystemSettings.InstalledFilename), "");

                    // Moving package files to a proper location, if an newer version of an already installed package is installed
                    if (_originalPackageInstallDirectory != null)
                    {
                        C1Directory.Delete(_originalPackageInstallDirectory, true);

                        C1Directory.Move(_packageInstallDirectory, _originalPackageInstallDirectory);
                    }
                }

                return(new PackageFragmentValidationResult[0]);
            }
            catch (Exception ex)
            {
                return(new [] { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex) });
            }
        }
Example #9
0
        private void deleteCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            DeleteTreeRefresher treeRefresher = this.CreateDeleteTreeRefresher(this.EntityToken);

            WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;

            try
            {
                C1Directory.Delete(entityToken.Path, true);

                treeRefresher.PostRefreshMesseges();
            }
            catch (Exception)
            {
                this.ShowMessage(
                    DialogType.Error,
                    StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DeleteWebsiteFolderWorkflow.DeleteErrorTitle"),
                    StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DeleteWebsiteFolderWorkflow.DeleteErrorMessage")
                    );
            }
        }
Example #10
0
        /// <exclude />
        public static void OnApplicationEnd()
        {
            // Deleting everything that is older than 24 hours
            string tempDirectoryName = TempDirectoryPath;

            if (!C1Directory.Exists(tempDirectoryName))
            {
                return;
            }



            foreach (string filename in C1Directory.GetFiles(tempDirectoryName))
            {
                try
                {
                    if (DateTime.Now > C1File.GetLastWriteTime(filename) + TemporaryFileExpirationTimeSpan)
                    {
                        C1File.Delete(filename);
                    }
                }
                catch
                {
                }
            }

            foreach (string directoryPath in C1Directory.GetDirectories(tempDirectoryName))
            {
                try
                {
                    if (DateTime.Now > C1Directory.GetCreationTime(directoryPath) + TemporaryFileExpirationTimeSpan)
                    {
                        C1Directory.Delete(directoryPath, true);
                    }
                }
                catch
                {
                }
            }
        }