public IEnumerable <EntityToken> GetParents(EntityToken entityToken)
        {
            WebsiteFileElementProviderEntityToken castedEntityToken = (WebsiteFileElementProviderEntityToken)entityToken;

            if ((C1File.Exists(castedEntityToken.Path) == false) &&
                (C1Directory.Exists(castedEntityToken.Path) == false))
            {
                return(null);
            }

            string newFolderPath = Path.GetDirectoryName(castedEntityToken.Path);

            string rootFolder = castedEntityToken.RootPath;

            if (newFolderPath != rootFolder)
            {
                Verify.That(newFolderPath.Length > rootFolder.Length,
                            "File/folder path '{0}' does not much root folder '{1}'",
                            newFolderPath, rootFolder);

                return(new EntityToken[] { new WebsiteFileElementProviderEntityToken(castedEntityToken.Source, newFolderPath, castedEntityToken.RootPath) });
            }

            return(new EntityToken[] { new WebsiteFileElementProviderRootEntityToken(castedEntityToken.Source, castedEntityToken.RootPath) });
        }
        private void finalizeCodeActivity_SaveFile_ExecuteCode(object sender, EventArgs e)
        {
            UploadedFile uploadedFile = this.GetBinding <UploadedFile>("UploadedFile");

            if (uploadedFile.HasFile)
            {
                string currentPath = GetCurrentPath();
                string filename    = uploadedFile.FileName;

                string fullFilename = System.IO.Path.Combine(currentPath, filename);

                if (C1File.Exists(fullFilename))
                {
                    FileUtils.Delete(fullFilename);
                }

                using (C1FileStream fs = new C1FileStream(fullFilename, FileMode.CreateNew))
                {
                    uploadedFile.FileStream.CopyTo(fs);
                }

                SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();
                specificTreeRefresher.PostRefreshMesseges(this.EntityToken);

                if (this.EntityToken is WebsiteFileElementProviderEntityToken)
                {
                    WebsiteFileElementProviderEntityToken folderToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                    var newFileToken = new WebsiteFileElementProviderEntityToken(folderToken.ProviderName, fullFilename, folderToken.RootPath);
                    SelectElement(newFileToken);
                }
            }
        }
Пример #3
0
        private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            UpdateTreeRefresher updateTreeRefresher = this.CreateUpdateTreeRefresher(this.EntityToken);

            WorkflowActionToken workflowActionToken = (WorkflowActionToken)this.ActionToken;

            string folderPath = null;

            if (this.EntityToken is WebsiteFileElementProviderRootEntityToken)
            {
                folderPath = "";
            }
            else
            {
                WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                folderPath = entityToken.Path;
            }

            string keyName = workflowActionToken.Payload;

            string relativeFolderPath = IFolderWhiteListExtensions.GetTildePath(folderPath);

            if (!DataFacade.GetData <IFolderWhiteList>().Any(f => f.TildeBasedPath == relativeFolderPath && f.KeyName == keyName))
            {
                IFolderWhiteList folderWhiteList = DataFacade.BuildNew <IFolderWhiteList>();
                folderWhiteList.KeyName        = keyName;
                folderWhiteList.TildeBasedPath = IFolderWhiteListExtensions.GetTildePath(folderPath);
                DataFacade.AddNew(folderWhiteList);
            }

            updateTreeRefresher.PostRefreshMesseges(this.EntityToken);
        }
        private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;

            WebsiteFile websiteFile = new WebsiteFile(entityToken.Path);


            this.Bindings.Add("FileContent", websiteFile.ReadAllText());
            this.Bindings.Add("FileName", websiteFile.FileName);
            this.Bindings.Add("FileMimeType", websiteFile.MimeType);
        }
        private void saveCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;

            WebsiteFile websiteFile = new WebsiteFile(entityToken.Path);

            string content = this.GetBinding <string>("FileContent");

            websiteFile.WriteAllText(content);

            SetSaveStatus(true);
        }
        private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            string currentPath = GetCurrentPath();
            string newFileName = this.GetBinding<string>("NewFileName");
            string fullPath = Path.Combine(currentPath, newFileName);

            using (C1FileStream fs = C1File.Create(fullPath))
            { }

            SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();
            specificTreeRefresher.PostRefreshMesseges(this.EntityToken);

            if (this.EntityToken is WebsiteFileElementProviderEntityToken)
            {
                WebsiteFileElementProviderEntityToken folderToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                var newFileToken = new WebsiteFileElementProviderEntityToken(folderToken.ProviderName, fullPath, folderToken.RootPath);
                SelectElement(newFileToken);
            }
        }
Пример #7
0
        private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            string currentPath   = GetCurrentPath();
            string newFolderName = this.GetBinding <string>("NewFolderName");

            string newFolderPath = Path.Combine(currentPath, newFolderName);

            C1Directory.CreateDirectory(newFolderPath);

            SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();

            specificTreeRefresher.PostRefreshMesseges(this.EntityToken);

            if (this.EntityToken is WebsiteFileElementProviderEntityToken)
            {
                WebsiteFileElementProviderEntityToken folderToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                var newFileToken = new WebsiteFileElementProviderEntityToken(folderToken.ProviderName, newFolderPath, folderToken.RootPath);
                SelectElement(newFileToken);
            }
        }
Пример #8
0
        private void deleteCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            DeleteTreeRefresher treeRefresher = this.CreateDeleteTreeRefresher(this.EntityToken);

            WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;

            try
            {
                C1File.Delete(entityToken.Path);

                treeRefresher.PostRefreshMesseges();
            }
            catch (Exception)
            {
                this.ShowMessage(
                    DialogType.Error,
                    StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DeleteWebsiteFileWorkflow.DeleteErrorTitle"),
                    StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "DeleteWebsiteFileWorkflow.DeleteErrorMessage")
                    );
            }
        }
Пример #9
0
        private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            string currentPath   = GetCurrentPath();
            string newFolderName = this.GetBinding <string>("NewFolderName");

            string newFolderPath = Path.Combine(currentPath, newFolderName);

            C1Directory.CreateDirectory(newFolderPath);

            SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();

            specificTreeRefresher.PostRefreshMesseges(this.EntityToken);

            string providerName;
            string rootPath;

            switch (this.EntityToken.GetType().Name)
            {
            case nameof(WebsiteFileElementProviderRootEntityToken):
                WebsiteFileElementProviderRootEntityToken rootToken = (WebsiteFileElementProviderRootEntityToken)this.EntityToken;
                providerName = rootToken.ProviderName;
                rootPath     = rootToken.RootPath;
                break;

            case nameof(WebsiteFileElementProviderEntityToken):
                WebsiteFileElementProviderEntityToken folderToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                providerName = folderToken.ProviderName;
                rootPath     = folderToken.RootPath;
                break;

            default:
                throw new InvalidOperationException("Unexpected EntityToken type");
            }

            var newFileToken = new WebsiteFileElementProviderEntityToken(providerName, newFolderPath, rootPath);

            SelectElement(newFileToken);
        }
        private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            WorkflowActionToken workflowActionToken = (WorkflowActionToken)this.ActionToken;
            string folderPath = null;

            if (this.EntityToken is WebsiteFileElementProviderRootEntityToken)
            {
                folderPath = "";
            }
            else
            {
                WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                folderPath = entityToken.Path;
            }

            UpdateTreeRefresher updateTreeRefresher = this.CreateUpdateTreeRefresher(this.EntityToken);

            string keyName = workflowActionToken.Payload;

            DataFacade.Delete <IFolderWhiteList>(f => f.TildeBasedPath == IFolderWhiteListExtensions.GetTildePath(folderPath) && f.KeyName == keyName);

            updateTreeRefresher.PostRefreshMesseges(this.EntityToken);
        }
Пример #11
0
        private void finalizeCodeActivity_SaveFile_ExecuteCode(object sender, EventArgs e)
        {
            UploadedFile uploadedFile = this.GetBinding<UploadedFile>("UploadedFile");

            if (uploadedFile.HasFile)
            {
                string currentPath = GetCurrentPath();
                string filename = uploadedFile.FileName;

                string fullFilename = System.IO.Path.Combine(currentPath, filename);

                if (C1File.Exists(fullFilename))
                {
                    FileUtils.Delete(fullFilename);
                }

                using (C1FileStream fs = new C1FileStream(fullFilename, FileMode.CreateNew))
                {
                    uploadedFile.FileStream.CopyTo(fs);
                }

                SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();
                specificTreeRefresher.PostRefreshMesseges(this.EntityToken);

                if (this.EntityToken is WebsiteFileElementProviderEntityToken)
                {
                    WebsiteFileElementProviderEntityToken folderToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                    var newFileToken = new WebsiteFileElementProviderEntityToken(folderToken.ProviderName, fullFilename, folderToken.RootPath);
                    SelectElement(newFileToken);
                }
            }
        }
        private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            string currentPath = GetCurrentPath();
            string newFolderName = this.GetBinding<string>("NewFolderName");

            string newFolderPath = Path.Combine(currentPath, newFolderName);

            C1Directory.CreateDirectory(newFolderPath);

            SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();
            specificTreeRefresher.PostRefreshMesseges(this.EntityToken);

            string providerName;
            string rootPath;

            switch (this.EntityToken.GetType().Name)
            {
                case nameof(WebsiteFileElementProviderRootEntityToken):
                    WebsiteFileElementProviderRootEntityToken rootToken = (WebsiteFileElementProviderRootEntityToken)this.EntityToken;
                    providerName = rootToken.ProviderName;
                    rootPath = rootToken.RootPath;
                    break;
                case nameof(WebsiteFileElementProviderEntityToken):
                    WebsiteFileElementProviderEntityToken folderToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                    providerName = folderToken.ProviderName;
                    rootPath = folderToken.RootPath;
                    break;
                default:
                    throw new InvalidOperationException("Unexpected EntityToken type");
            }

            var newFileToken = new WebsiteFileElementProviderEntityToken(providerName, newFolderPath, rootPath);
            SelectElement(newFileToken);
        }