private void saveCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            UpdateTreeRefresher updateTreeRefresher = this.CreateUpdateTreeRefresher(this.EntityToken);
            ISqlFunctionInfo    info;

            try
            {
                info = this.GetBinding <ISqlFunctionInfo>("SqlQuery");
                var parameters = this.GetBinding <IEnumerable <ManagedParameterDefinition> >("Parameters");

                ManagedParameterManager.Save(info.Id, parameters);
                DataFacade.Update(info);
            }
            catch (Exception ex)
            {
                LoggingService.LogCritical("SQL Function Save", ex);

                FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
                var consoleMsgService = serviceContainer.GetService <IManagementConsoleMessageService>();
                consoleMsgService.ShowMessage(DialogType.Error, "Error", ex.Message);

                SetSaveStatus(false);
                return;
            }

            updateTreeRefresher.PostRefreshMesseges(info.GetDataEntityToken());
            SetSaveStatus(true);
        }
示例#2
0
        private void saveInfoCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var package = this.GetBinding <PackageInformation>("Package");

            PackageCreatorFacade.SavePackageInformation(package);


            if (!string.IsNullOrEmpty(Payload))
            {
                var         type        = StringConversionServices.DeserializeValueString(StringConversionServices.ParseKeyValueCollection(Payload)["ActionToken"]);
                ActionToken actionToken = ActionTokenSerializer.Deserialize(type);
                ActionExecutorFacade.Execute(package.GetEntityToken(), actionToken, WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId));
            }
            else
            {
                ActionExecutorFacade.Execute(
                    package.GetEntityToken(),
                    new SetActivePackageActionToken(),
                    WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId));
            }

            SpecificTreeRefresher treeRefresher = this.CreateSpecificTreeRefresher();

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());
        }
示例#3
0
        /// <exclude />
        protected void RerenderView()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IFormFlowRenderingService       formFlowRenderingService        = flowControllerServicesContainer.GetService <IFormFlowRenderingService>();

            formFlowRenderingService.RerenderView();
        }
示例#4
0
        /// <exclude />
        protected void CollapseAndRefresh()
        {
            FlowControllerServicesContainer  container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IManagementConsoleMessageService service   = container.GetService <IManagementConsoleMessageService>();

            service.CollapseAndRefresh();
        }
        private void codeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var         type        = StringConversionServices.DeserializeValueType(StringConversionServices.ParseKeyValueCollection(Payload)["ActionToken"]);
            ActionToken actionToken = (ActionToken)Activator.CreateInstance(type);

            ActionExecutorFacade.Execute(this.EntityToken, actionToken, WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId));
        }
示例#6
0
        /// <exclude />
        protected void LogMessage(LogLevel logLevel, string message)
        {
            FlowControllerServicesContainer  container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IManagementConsoleMessageService service   = container.GetService <IManagementConsoleMessageService>();

            service.ShowLogEntry(this.GetType(), logLevel, message);

            switch (logLevel)
            {
            case LogLevel.Info:
            case LogLevel.Debug:
            case LogLevel.Fine:
                LoggingService.LogVerbose(this.GetType().Name, message);
                break;

            case LogLevel.Warning:
                LoggingService.LogWarning(this.GetType().Name, message);
                break;

            case LogLevel.Error:
                LoggingService.LogError(this.GetType().Name, message);
                break;

            case LogLevel.Fatal:
                LoggingService.LogCritical(this.GetType().Name, message);
                break;

            default:
                throw new NotImplementedException();
            }
        }
示例#7
0
        /// <exclude />
        protected void SetSaveStatus(bool succeeded, string serializedEntityToken)
        {
            SaveWorklowTaskManagerEvent saveWorklowTaskManagerEvent = new SaveWorklowTaskManagerEvent
                                                                      (
                new WorkflowFlowToken(this.InstanceId),
                this.WorkflowInstanceId,
                succeeded
                                                                      );

            FlowControllerServicesContainer   container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            ITaskManagerFlowControllerService service   = container.GetService <ITaskManagerFlowControllerService>();

            service.OnStatus(saveWorklowTaskManagerEvent);

            var flowRenderingService = container.GetService <IFormFlowRenderingService>();

            if (flowRenderingService != null)
            {
                flowRenderingService.SetSaveStatus(succeeded);
            }


            IManagementConsoleMessageService managementConsoleMessageService = container.GetService <IManagementConsoleMessageService>();

            managementConsoleMessageService.SaveStatus(succeeded); // TO BE REMOVED

            if (serializedEntityToken != null)
            {
                managementConsoleMessageService = container.GetService <IManagementConsoleMessageService>();
                managementConsoleMessageService.BindEntityTokenToView(serializedEntityToken);
            }
        }
示例#8
0
        private void editPreviewCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            var webRenderService = serviceContainer.GetService <IFormFlowWebRenderingService>();

            try
            {
                var selectedPage = GetBinding <IPage>("SelectedPage");

                var contents            = new List <IPagePlaceholderContent>();
                var namedXhtmlFragments = GetBinding <Dictionary <string, string> >("NamedXhtmlFragments");
                foreach (var placeHolderContent in namedXhtmlFragments)
                {
                    var content = DataFacade.BuildNew <IPagePlaceholderContent>();
                    content.PageId        = selectedPage.Id;
                    content.VersionId     = selectedPage.VersionId;
                    content.PlaceHolderId = placeHolderContent.Key;
                    content.Content       = placeHolderContent.Value;
                    contents.Add(content);
                }

                var output = PagePreviewBuilder.RenderPreview(selectedPage, contents);
                webRenderService.SetNewPageOutput(new LiteralControl(output));
            }
            catch (Exception ex)
            {
                Control errOutput = new LiteralControl("<pre>" + ex + "</pre>");
                webRenderService.SetNewPageOutput(errOutput);
            }
        }
        private void finalizecodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            AddNewTreeRefresher addNewTreeRefresher = this.CreateAddNewTreeRefresher(this.EntityToken);

            IXsltFunction xslt = this.GetBinding <IXsltFunction>("NewXslt");
            Guid          copyFromFunctionId = this.GetBinding <Guid>(Binding_CopyFromFunctionId);

            IXsltFunction copyFromFunction = null;

            if (copyFromFunctionId != Guid.Empty)
            {
                copyFromFunction = DataFacade.GetData <IXsltFunction>().First(f => f.Id == copyFromFunctionId);
            }

            xslt.XslFilePath = xslt.CreateXslFilePath();

            IFile file = IFileServices.TryGetFile <IXsltFile>(xslt.XslFilePath);

            using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope())
            {
                if (file == null)
                {
                    IXsltFile xsltfile = DataFacade.BuildNew <IXsltFile>();

                    xsltfile.FolderPath = System.IO.Path.GetDirectoryName(xslt.XslFilePath);
                    xsltfile.FileName   = System.IO.Path.GetFileName(xslt.XslFilePath);

                    string xslTemplate = _newXsltMarkup;
                    if (copyFromFunction != null)
                    {
                        IFile copyFromFile = IFileServices.GetFile <IXsltFile>(copyFromFunction.XslFilePath);
                        xslTemplate = copyFromFile.ReadAllText();
                    }

                    xsltfile.SetNewContent(xslTemplate);

                    DataFacade.AddNew <IXsltFile>(xsltfile, "XslFileProvider");
                }

                xslt = DataFacade.AddNew <IXsltFunction>(xslt);

                UserSettings.LastSpecifiedNamespace = xslt.Namespace;


                if (copyFromFunction != null)
                {
                    CloneFunctionParameters(copyFromFunction, xslt);
                    CloneFunctionCalls(copyFromFunction, xslt);
                }

                transactionScope.Complete();
            }
            addNewTreeRefresher.PostRefreshMesseges(xslt.GetDataEntityToken());

            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            var executionService = container.GetService <IActionExecutionService>();

            executionService.Execute(xslt.GetDataEntityToken(), new WorkflowActionToken(typeof(EditXsltFunctionWorkflow)), null);
        }
示例#10
0
        /// <exclude />
        protected string GetCurrentConsoleId()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();

            return(managementConsoleMessageService.CurrentConsoleId);
        }
示例#11
0
        /// <exclude />
        protected void LockTheSystem()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();

            managementConsoleMessageService.LockSystem();
        }
示例#12
0
        /// <exclude />
        protected void ShowFieldMessage(string fieldBindingPath, string message)
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IFormFlowRenderingService formFlowRenderingService = flowControllerServicesContainer.GetService <IFormFlowRenderingService>();

            formFlowRenderingService.ShowFieldMessage(fieldBindingPath, StringResourceSystemFacade.ParseString(message));
        }
示例#13
0
        /// <exclude />
        protected void SelectElement(EntityToken entityToken)
        {
            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IManagementConsoleMessageService service = container.GetService <IManagementConsoleMessageService>();

            service.SelectElement(EntityTokenSerializer.Serialize(entityToken, true));
        }
示例#14
0
        /// <exclude />
        protected void ExecuteAction(EntityToken entityToken, ActionToken actionToken)
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IActionExecutionService actionExecutionService = flowControllerServicesContainer.GetService <IActionExecutionService>();

            var taskManagerEvent = new WorkflowCreationTaskManagerEvent(_instanceId);

            actionExecutionService.Execute(entityToken, actionToken, taskManagerEvent);
        }
        private void MissingActiveLanguageCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            var managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();

            managementConsoleMessageService.ShowMessage(
                DialogType.Message,
                GetText("UserElementProvider.MissingActiveLanguageTitle"),
                GetText("UserElementProvider.MissingActiveLanguageMessage"));
        }
示例#16
0
        private void MissingActiveLanguageCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            var managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();

            managementConsoleMessageService.ShowMessage(
                DialogType.Message,
                LocalizationFiles.Composite_Management.UserElementProvider_MissingActiveLanguageTitle,
                LocalizationFiles.Composite_Management.UserElementProvider_MissingActiveLanguageMessage);
        }
        /// <exclude />
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IFormFlowRenderingService service = container.GetService <IFormFlowRenderingService>();

            service.ShowFieldMessage(this.FieldBindingPath, this.Message);

            return(ActivityExecutionStatus.Closed);
        }
        /// <exclude />
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IFormFlowRenderingService formFlowRenderingService = flowControllerServicesContainer.GetService <IFormFlowRenderingService>();

            formFlowRenderingService.RerenderView();

            return(ActivityExecutionStatus.Closed);
        }
        /// <exclude />
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IManagementConsoleMessageService service = container.GetService <IManagementConsoleMessageService>();

            service.ShowMessage(this.DialogType, StringResourceSystemFacade.ParseString(this.Title), StringResourceSystemFacade.ParseString(this.Message));

            return(ActivityExecutionStatus.Closed);
        }
示例#20
0
        /// <exclude />
        protected void CloseCurrentView()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            var managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();

            if (!managementConsoleMessageService.CloseCurrentViewRequested)
            {
                managementConsoleMessageService.CloseCurrentView();
            }
        }
        public static bool PublishIfNeeded(IData data, bool doPublish, IDictionary <string, object> binding, Action <DialogType, string, string> messageAction)
        {
            if (!(data is IPublishControlled))
            {
                return(false);
            }

            WorkflowInstance publishWorkflowInstance   = null;
            WorkflowInstance unpublishWorkflowInstance = null;

            var publishDate   = binding.ContainsKey("PublishDate") ? (DateTime?)binding["PublishDate"] : null;
            var unpublishDate = binding.ContainsKey("UnpublishDate") ? (DateTime?)binding["UnpublishDate"] : null;

            string cultureName = UserSettings.ActiveLocaleCultureInfo.Name;

            HandlePublishUnpublishWorkflows(data, cultureName, publishDate, unpublishDate, ref publishWorkflowInstance, ref unpublishWorkflowInstance);

            if (publishWorkflowInstance != null)
            {
                publishWorkflowInstance.Start();

                WorkflowFacade.RunWorkflow(publishWorkflowInstance);
            }

            if (unpublishWorkflowInstance != null)
            {
                unpublishWorkflowInstance.Start();

                WorkflowFacade.RunWorkflow(unpublishWorkflowInstance);
            }

            if (!doPublish)
            {
                return(false);
            }

            if (publishWorkflowInstance == null || publishDate < DateTime.Now)
            {
                var actionToken      = new GenericPublishProcessController.PublishActionToken();
                var serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

                ActionExecutorFacade.Execute(data.GetDataEntityToken(), actionToken, serviceContainer);

                return(true);
            }

            var title   = Texts.Website_Forms_Administrative_EditPage_PublishDatePreventPublishTitle;
            var message = Texts.Website_Forms_Administrative_EditPage_PublishDatePreventPublish;

            messageAction(DialogType.Warning, title, message);

            return(false);
        }
        private void sendMessageCodeActivity_SendMessage_ExecuteCode(object sender, EventArgs e)
        {
            this.CloseCurrentView();

            string title   = this.GetBinding <string>("Title");
            string message = this.GetBinding <string>("Message");

            FlowControllerServicesContainer  flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();

            managementConsoleMessageService.ShowGlobalMessage(DialogType.Message, title, message);
        }
        internal Dictionary <string, Exception> GetBindingErrors()
        {
            Guid workflowId = WorkflowEnvironment.WorkflowInstanceId;;

            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(workflowId);
            var bindingValidationService = container.GetService <IBindingValidationService>();

            if (bindingValidationService == null)
            {
                return(new Dictionary <string, Exception>());
            }

            return(bindingValidationService.BindingErrors);
        }
示例#24
0
        /// <exclude />
        protected void ShowMessage(DialogType dialogType, string title, string message)
        {
            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IManagementConsoleMessageService service = container.GetService <IManagementConsoleMessageService>();

            string localizedTitle   = StringResourceSystemFacade.ParseString(title);
            string localizedMessage = StringResourceSystemFacade.ParseString(message);

            service.ShowMessage(
                dialogType,
                localizedTitle,
                localizedMessage
                );
        }
示例#25
0
        /// <exclude />
        protected void ReportException(Exception ex)
        {
            if (ex == null)
            {
                throw new ArgumentNullException("ex");
            }

            this.ShowMessage(DialogType.Error, "An unfortunate error occurred", string.Format("Sorry, but an error has occurred, preventing the opperation from completing as expected. The error has been documented in details so a technican may follow up on this issue.\n\nThe error message is: {0}", ex.Message));

            Log.LogCritical(this.GetType().Name, ex);

            FlowControllerServicesContainer  container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IManagementConsoleMessageService service   = container.GetService <IManagementConsoleMessageService>();

            service.ShowLogEntry(this.GetType(), ex);
        }
        private void editPreviewCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                XhtmlDocument templateDocument = GetTemplateDocumentFromBindings();

                IVisualFunction function      = this.GetBinding <IVisualFunction>("Function");
                Type            interfaceType = TypeManager.GetType(function.TypeManagerName);

                DataTypeDescriptor typeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(interfaceType);

                this.LogMessage(Composite.Core.Logging.LogLevel.Info, DataScopeManager.CurrentDataScope.Name);

                FunctionContextContainer fcc = PageRenderer.GetPageRenderFunctionContextContainer();

                XhtmlDocument result = RenderingHelper.RenderCompleteDataList(function, templateDocument, typeDescriptor, fcc);

                IPage previewPage = DataFacade.BuildNew <IPage>();
                previewPage.Id    = GetRootPageId();
                previewPage.Title = function.Name;
                previewPage.DataSourceId.DataScopeIdentifier = DataScopeIdentifier.Administrated;
                previewPage.DataSourceId.LocaleScope         = LocalizationScopeManager.CurrentLocalizationScope;

                previewPage.TemplateId = this.GetBinding <Guid>("PreviewTemplateId");

                var pageTemplate = PageTemplateFacade.GetPageTemplate(previewPage.TemplateId);
                IPagePlaceholderContent placeHolderContent = DataFacade.BuildNew <IPagePlaceholderContent>();
                placeHolderContent.Content       = string.Concat((result.Body.Elements().Select(b => b.ToString())).ToArray());
                placeHolderContent.PlaceHolderId = pageTemplate.DefaultPlaceholderId;

                string output = PagePreviewBuilder.RenderPreview(previewPage, new List <IPagePlaceholderContent> {
                    placeHolderContent
                });

                var serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

                var webRenderService = serviceContainer.GetService <IFormFlowWebRenderingService>();
                webRenderService.SetNewPageOutput(new LiteralControl(output));
            }
            catch (Exception ex)
            {
                FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
                Control errOutput        = new LiteralControl("<pre>" + ex + "</pre>");
                var     webRenderService = serviceContainer.GetService <IFormFlowWebRenderingService>();
                webRenderService.SetNewPageOutput(errOutput);
            }
        }
        /// <exclude />
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            FormsWorkflow formsWorkflow = this.GetRoot <FormsWorkflow>();

            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            if (container != null)
            {
                IManagementConsoleMessageService service = container.GetService <IManagementConsoleMessageService>();

                if (service != null)
                {
                    service.CloseCurrentView();
                }
            }

            return(ActivityExecutionStatus.Closed);
        }
示例#28
0
        /// <exclude />
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            FormsWorkflow formsWorkflow = this.GetRoot <FormsWorkflow>();

            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

            IActionExecutionService actionExecutionService = flowControllerServicesContainer.GetService <IActionExecutionService>();

            WorkflowActionToken workflowActionToken = new WorkflowActionToken(this.ChildWorkflowType)
            {
                Payload = this.ChildWorkflowPayload,
                ParentWorkflowInstanceId = formsWorkflow.InstanceId
            };

            actionExecutionService.Execute(formsWorkflow.EntityToken, workflowActionToken, null);

            return(ActivityExecutionStatus.Closed);
        }
        private void finalizecodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var provider = GetFunctionProvider <RazorFunctionProvider>();

            string functionName      = this.GetBinding <string>(Binding_Name);
            string functionNamespace = ChangeNamespaceAccordingToExistingFolders(provider, this.GetBinding <string>(Binding_Namespace));
            string functionFullName  = functionNamespace + "." + functionName;

            AddNewTreeRefresher addNewTreeRefresher = this.CreateAddNewTreeRefresher(this.EntityToken);

            string fileName = functionName + ".cshtml";
            string folder   = Path.Combine(provider.PhysicalPath, functionNamespace.Replace('.', '\\'));

            string cshtmlFilePath = Path.Combine(folder, fileName);

            string code;

            string copyFromFunction = this.GetBinding <string>(Binding_CopyFromFunctionName);

            if (string.IsNullOrEmpty(copyFromFunction))
            {
                code = NewRazorFunction_CSHTML;
            }
            else
            {
                code = GetFunctionCode(copyFromFunction);
            }

            C1Directory.CreateDirectory(folder);
            C1File.WriteAllText(cshtmlFilePath, code);

            UserSettings.LastSpecifiedNamespace = functionNamespace;

            provider.ReloadFunctions();

            var newFunctionEntityToken = new FileBasedFunctionEntityToken(provider.Name, functionFullName);

            addNewTreeRefresher.PostRefreshMesseges(newFunctionEntityToken);

            var container        = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            var executionService = container.GetService <IActionExecutionService>();

            executionService.Execute(newFunctionEntityToken, new WorkflowActionToken(typeof(EditRazorFunctionWorkflow)), null);
        }
示例#30
0
        private void uploadCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            UpdateTreeRefresher updateTreeRefresher = this.CreateUpdateTreeRefresher(this.EntityToken);

            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            var managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();

            UploadedFile uploadedFile = this.GetBinding <UploadedFile>("UploadedFile");
            IMediaFile   mediaFile    = this.GetBinding <IMediaFile>("File");

            if (uploadedFile.HasFile)
            {
                string mimeType = MimeTypeInfo.GetMimeType(uploadedFile);

                // Image cannot be replaced with a file of not image mime type
                string imageMimeTypePrefix = "image/";
                if ((mediaFile.MimeType.StartsWith(imageMimeTypePrefix, StringComparison.OrdinalIgnoreCase) &&
                     !mimeType.StartsWith(imageMimeTypePrefix, StringComparison.OrdinalIgnoreCase)))
                {
                    managementConsoleMessageService.CloseCurrentView();
                    string failure        = StringResourceSystemFacade.GetString("Composite.Management", "UploadNewMediaFileWorkflow.UploadFailure");
                    string failureMessage = StringResourceSystemFacade.GetString("Composite.Management", "UploadNewMediaFileWorkflow.UploadFailureMessage");
                    managementConsoleMessageService.ShowMessage(DialogType.Message, failure, failureMessage);
                    return;
                }

                using (System.IO.Stream readStream = uploadedFile.FileStream)
                {
                    using (System.IO.Stream writeStream = mediaFile.GetNewWriteStream())
                    {
                        readStream.CopyTo(writeStream);
                    }
                }
            }

            DataFacade.Update(mediaFile);

            SetSaveStatus(true);

            SelectElement(mediaFile.GetDataEntityToken());

            updateTreeRefresher.PostRefreshMesseges(mediaFile.GetDataEntityToken());
        }