Пример #1
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);
            }
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var packageName = PackageCreatorFacade.ActivePackageName;
            if (entityToken is PackageCreatorEntityToken)
            {
                packageName = (entityToken as PackageCreatorEntityToken).Source;
            }
            if (string.IsNullOrEmpty(packageName))
            {
                flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                var consoleServices = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"),
                                            PackageCreatorFacade.GetLocalization("NoPackages.Message"));
                return null;
            }

            if (actionToken is AddLocalizationActionToken)
            {
                var token = actionToken as AddLocalizationActionToken;
                PackageCreatorFacade.AddItem(new PCLocalizations(token.CultureName), packageName);
            }

            var treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);
            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var packageName = PackageCreatorFacade.ActivePackageName;

            if (entityToken is PackageCreatorEntityToken)
            {
                packageName = (entityToken as PackageCreatorEntityToken).Source;
            }
            if (string.IsNullOrEmpty(packageName))
            {
                flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"), PackageCreatorFacade.GetLocalization("NoPackages.Message"));
                return null;
            }
            if (actionToken is PackageCreatorActionToken)
            {
                var token = actionToken as PackageCreatorActionToken;

                foreach (var item in PackageCreatorActionFacade.GetPackageCreatorItems(entityToken))
                {
                    if (item.CategoryName == token.CategoryName)
                    {
                        //if diffent item for one category and entitytoken
                        var itemActionToken = item as IPackItemActionToken;
                        if (itemActionToken != null)
                        {
                            if (token.Name != itemActionToken.ActionTokenName)
                            {
                                continue;
                            }
                        }
                        if (item is IPackToggle)
                        {
                            if ((item as IPackToggle).CheckedStatus == ActionCheckedStatus.Checked)
                            {
                                 PackageCreatorFacade.RemoveItem(item, packageName);
                            }
                            else
                            {
                                PackageCreatorFacade.AddItem(item, packageName);
                            }
                            var parentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);
                            parentTreeRefresher.PostRefreshMesseges(entityToken);
                        }
                        else
                        {
                            PackageCreatorFacade.AddItem(item, packageName);
                        }
                        break;
                    }
                }

            }

            SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);
            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            return null;
        }
Пример #4
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var packageName = PackageCreatorFacade.ActivePackageName;

            if (entityToken is PackageCreatorEntityToken)
            {
                packageName = (entityToken as PackageCreatorEntityToken).Source;
            }
            if (string.IsNullOrEmpty(packageName))
            {
                flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();
                IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();
                consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"), PackageCreatorFacade.GetLocalization("NoPackages.Message"));
                return(null);
            }
            if (actionToken is PackageCreatorActionToken)
            {
                var token = actionToken as PackageCreatorActionToken;

                foreach (var item in PackageCreatorActionFacade.GetPackageCreatorItems(entityToken))
                {
                    if (item.CategoryName == token.CategoryName)
                    {
                        //if diffent item for one category and entitytoken
                        var itemActionToken = item as IPackItemActionToken;
                        if (itemActionToken != null)
                        {
                            if (token.Name != itemActionToken.ActionTokenName)
                            {
                                continue;
                            }
                        }
                        if (item is IPackToggle)
                        {
                            if ((item as IPackToggle).CheckedStatus == ActionCheckedStatus.Checked)
                            {
                                PackageCreatorFacade.RemoveItem(item, packageName);
                            }
                            else
                            {
                                PackageCreatorFacade.AddItem(item, packageName);
                            }
                            var parentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);
                            parentTreeRefresher.PostRefreshMesseges(entityToken);
                        }
                        else
                        {
                            PackageCreatorFacade.AddItem(item, packageName);
                        }
                        break;
                    }
                }
            }

            SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            return(null);
        }
        private static void OnFinish(FlowToken flowToken, Dictionary <string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId)
            {
                EventName = "Finish"
            }))
            {
                TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer);
                serviceContainer.AddService(taskManagerFlowControllerService);

                WorkflowFacade.FireFinishEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));
            }


            IFormFlowRenderingService formServices = serviceContainer.GetService <IFormFlowRenderingService>();

            if (!formServices.HasFieldMessages)
            {
                serviceContainer.GetService <IFormFlowRenderingService>().RerenderView();
            }
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var packageName = PackageCreatorFacade.ActivePackageName;

            if (entityToken is PackageCreatorEntityToken)
            {
                packageName = (entityToken as PackageCreatorEntityToken).Source;
            }
            if (string.IsNullOrEmpty(packageName))
            {
                flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();
                var consoleServices = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();
                consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"),
                                            PackageCreatorFacade.GetLocalization("NoPackages.Message"));
                return(null);
            }

            if (actionToken is AddLocalizationActionToken)
            {
                var token = actionToken as AddLocalizationActionToken;
                PackageCreatorFacade.AddItem(new PCLocalizations(token.CultureName), packageName);
            }

            var treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            return(null);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            StringBuilder sb = new StringBuilder();

            var elementInformationService = flowControllerServicesContainer.GetService <IElementInformationService>();

            if (elementInformationService != null)
            {
                Dictionary <string, string> piggybag = elementInformationService.Piggyback;

                foreach (var kvp in piggybag)
                {
                    Core.Serialization.StringConversionServices.SerializeKeyValuePair(sb, kvp.Key, kvp.Value);
                }
            }

            Guid   id       = Guid.NewGuid();
            string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.showinfo", id));

            C1File.WriteAllLines(filename, new string[] { serializedEntityToken, sb.ToString() });

            string url = string.Format("{0}?PiggyBagId={1}", UrlUtils.ResolveAdminUrl("content/views/showelementinformation/Default.aspx"), id);

            ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem {
                Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show Element Information..."
            }, currentConsoleId);

            return(null);
        }
Пример #8
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();
            }
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            if (actionToken.Serialize() == "ShowGraph")
            {
                string url = string.Format("{0}?EntityToken={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/Default.aspx"), System.Web.HttpUtility.UrlEncode(serializedEntityToken));

                ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..." }, currentConsoleId);
            }
            else if (actionToken.Serialize() == "ShowOrientedGraph")
            {
                
                Guid id = Guid.NewGuid();
                string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.RelationshipGraph", id));
                C1File.WriteAllLines(filename, new string[] { serializedEntityToken });

                string url = string.Format("{0}?Id={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/ShowRelationshipOrientedGraph.aspx"), id);

                ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..." }, currentConsoleId);
            }

            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            //string documentTitle = "Unpublished Pages and Page Folder Data";
            //string description = "The list below display pages and page data which are currently being edited or are ready to be approved / published.";
            string documentTitle = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-title");
            string description   = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-description");
            string emptyLabel    = StringResourceSystemFacade.GetString("Composite.Plugins.GeneratedDataTypesElementProvider", "ViewUnpublishedItems-document-empty-label");
            string url           = string.Format("{0}?showpagedata=true&title={1}&description={2}&emptyLabel={3}",
                                                 UrlUtils.ResolveAdminUrl(string.Format("content/views/publishworkflowstatus/ViewUnpublishedItems.aspx")),
                                                 HttpUtility.UrlEncode(documentTitle, Encoding.UTF8),
                                                 HttpUtility.UrlEncode(description, Encoding.UTF8),
                                                 HttpUtility.UrlEncode(emptyLabel, Encoding.UTF8));

            IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();
            OpenViewMessageQueueItem         openViewMsg     = new OpenViewMessageQueueItem
            {
                EntityToken = EntityTokenSerializer.Serialize(entityToken, true),
                ViewId      = "ViewUnpublishedPageItems",
                Label       = documentTitle,
                Url         = url,
                ViewType    = ViewType.Main
            };

            ConsoleMessageQueueFacade.Enqueue(openViewMsg, consoleServices.CurrentConsoleId);

            return(null);
        }
Пример #11
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string functionNamePrefix = "";

            if (entityToken.Id.IndexOf('.') > -1)
            {
                functionNamePrefix = entityToken.Id.Substring(entityToken.Id.IndexOf('.') + 1);
            }

            bool widgets = entityToken.Id.ToLower().Contains("widget");

            string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId;
            string url = UrlUtils.ResolveAdminUrl(string.Format("content/views/functiondoc/FunctionDocumentation.aspx?functionPrefix={0}&widgets={1}", functionNamePrefix, widgets));

            ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem
            {
                Url         = url,
                EntityToken = EntityTokenSerializer.Serialize(entityToken, true),
                ViewId      = Guid.NewGuid().ToString(),
                ViewType    = ViewType.Main,
                Label       = "Documentation"
            }, currentConsoleId);

            return(null);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            SearchActionToken searchActionToken = (SearchActionToken)actionToken;

            string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            string viewId = Guid.NewGuid().ToString();



            string url = UrlUtils.ResolveAdminUrl(string.Format("content/dialogs/treesearch/treeSearchForm.aspx?ProviderName={0}&EntityToken={1}&ViewId={2}&ConsoleId={3}", HttpUtility.UrlEncode(searchActionToken.ProviderName), HttpUtility.UrlEncode(serializedEntityToken), HttpUtility.UrlEncode(viewId), HttpUtility.UrlEncode(currentConsoleId)));

            ConsoleMessageQueueFacade.Enqueue(
                new OpenViewMessageQueueItem
            {
                Url                = url,
                ViewId             = viewId,
                ViewType           = ViewType.ModalDialog,
                Label              = StringResourceSystemFacade.GetString("Composite.Management", "RelationshipGraphActionExecutor.SearchElements"),
                ToolTip            = StringResourceSystemFacade.GetString("Composite.Management", "RelationshipGraphActionExecutor.SearchElementsToolTip"),
                IconResourceHandle = CommonElementIcons.Question
            }, currentConsoleId);


            return(null);
        }
        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);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            if (actionToken.Serialize() == "ShowGraph")
            {
                string url = string.Format("{0}?EntityToken={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/Default.aspx"), System.Web.HttpUtility.UrlEncode(serializedEntityToken));

                ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem {
                    Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..."
                }, currentConsoleId);
            }
            else if (actionToken.Serialize() == "ShowOrientedGraph")
            {
                Guid   id       = Guid.NewGuid();
                string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.RelationshipGraph", id));
                C1File.WriteAllLines(filename, new string[] { serializedEntityToken });

                string url = string.Format("{0}?Id={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/ShowRelationshipOrientedGraph.aspx"), id);

                ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem {
                    Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..."
                }, currentConsoleId);
            }

            return(null);
        }
Пример #15
0
        /// <exclude />
        protected void RerenderView()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IFormFlowRenderingService       formFlowRenderingService        = flowControllerServicesContainer.GetService <IFormFlowRenderingService>();

            formFlowRenderingService.RerenderView();
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            //string documentTitle = "Unpublished Pages and Page Folder Data";
            //string description = "The list below display pages and page data which are currently being edited or are ready to be approved / published.";
            string documentTitle = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-title");
            string description = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-description");
            string emptyLabel = StringResourceSystemFacade.GetString("Composite.Plugins.GeneratedDataTypesElementProvider", "ViewUnpublishedItems-document-empty-label");
            string url = string.Format("{0}?showpagedata=true&title={1}&description={2}&emptyLabel={3}",
                UrlUtils.ResolveAdminUrl(string.Format("content/views/publishworkflowstatus/ViewUnpublishedItems.aspx")),
                HttpUtility.UrlEncode(documentTitle, Encoding.UTF8),
                HttpUtility.UrlEncode(description, Encoding.UTF8),
                HttpUtility.UrlEncode(emptyLabel, Encoding.UTF8));

            IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
            OpenViewMessageQueueItem openViewMsg = new OpenViewMessageQueueItem
            {
                EntityToken = EntityTokenSerializer.Serialize(entityToken, true),
                ViewId = "ViewUnpublishedPageItems",
                Label = documentTitle,
                Url = url,
                ViewType = ViewType.Main
            };

            ConsoleMessageQueueFacade.Enqueue(openViewMsg, consoleServices.CurrentConsoleId);

            return null;
        }
Пример #17
0
        /// <exclude />
        protected void CollapseAndRefresh()
        {
            FlowControllerServicesContainer  container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
            IManagementConsoleMessageService service   = container.GetService <IManagementConsoleMessageService>();

            service.CollapseAndRefresh();
        }
Пример #18
0
        private static void OnCancel(FlowToken flowToken, Dictionary <string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            if (WorkflowFacade.WorkflowExists(workflowFlowToken.WorkflowInstanceId))
            {
                using (TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId)
                {
                    EventName = "Cancel"
                }))
                {
                    WorkflowFacade.FireCancelEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                    WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                    WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                }
            }
            else
            {
                Log.LogVerbose(LogTitle, "Cancel event suppressed because the workflow was terminated ({0})", workflowFlowToken.WorkflowInstanceId);
            }

            if (serviceContainer != null)
            {
                serviceContainer.GetService <IFormFlowRenderingService>().RerenderView();
            }
        }
        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);
        }
Пример #20
0
        /// <exclude />
        protected string GetCurrentConsoleId()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

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

            return(managementConsoleMessageService.CurrentConsoleId);
        }
Пример #21
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));
        }
Пример #22
0
        /// <exclude />
        protected void SelectElement(EntityToken entityToken)
        {
            FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

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

            service.SelectElement(EntityTokenSerializer.Serialize(entityToken, true));
        }
Пример #23
0
        /// <exclude />
        protected void LockTheSystem()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

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

            managementConsoleMessageService.LockSystem();
        }
        /// <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);
        }
Пример #26
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var downloadActionToken = (DownloadSubmittedFormsActionToken)actionToken;
            var currentConsoleId    = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId;
            var url = "/formbuilder/" + downloadActionToken.FormName + "/submits" + downloadActionToken.Extension;

            ConsoleMessageQueueFacade.Enqueue(new DownloadFileMessageQueueItem(url), currentConsoleId);

            return(null);
        }
Пример #27
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"));
        }
Пример #29
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            MessageBoxActionToken messageBoxActionToken = (MessageBoxActionToken)actionToken;

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

            managementConsoleMessageService.ShowMessage(messageBoxActionToken.DialogType, messageBoxActionToken.Title, messageBoxActionToken.Message);

            return null;
        }
        /// <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);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var generatedDataTypetoken = entityToken as GeneratedDataTypesElementProviderTypeEntityToken;
            string typeName = generatedDataTypetoken.SerializedTypeName;
            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;
            string url = DownloadUrl.FormatWith(typeName);

            ConsoleMessageQueueFacade.Enqueue(new DownloadFileMessageQueueItem(url), currentConsoleId);

            return null;
        }
Пример #32
0
        /// <exclude />
        protected void CloseCurrentView()
        {
            FlowControllerServicesContainer flowControllerServicesContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);

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

            if (!managementConsoleMessageService.CloseCurrentViewRequested)
            {
                managementConsoleMessageService.CloseCurrentView();
            }
        }
        private static bool ConsoleIdEquals(FlowControllerServicesContainer flowControllerServicesContainer, string consoleId)
        {
            var managementConsoleMessageService = flowControllerServicesContainer?.GetService <IManagementConsoleMessageService>();

            if (managementConsoleMessageService == null)
            {
                return(false);
            }

            return(managementConsoleMessageService.CurrentConsoleId == consoleId);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var    generatedDataTypetoken = entityToken as GeneratedDataTypesElementProviderTypeEntityToken;
            string typeName         = generatedDataTypetoken.SerializedTypeName;
            string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId;
            string url = DownloadUrl.FormatWith(typeName);

            ConsoleMessageQueueFacade.Enqueue(new DownloadFileMessageQueueItem(url), currentConsoleId);

            return(null);
        }
        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);
        }
Пример #36
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId;
            var packageName      = entityToken.Source;

            string url = UrlUtils.ResolveAdminUrl(
                string.Format(@"InstalledPackages/content/views/Composite.Forms.FormSubmitHandler/GetData.aspx?entityToken={0}", EntityTokenSerializer.Serialize(entityToken))
                );

            ConsoleMessageQueueFacade.Enqueue(new DownloadFileMessageQueueItem(url), currentConsoleId);
            return(null);
        }
Пример #37
0
		public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
		{
			var currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;
			var packageName = entityToken.Source;

			string url = UrlUtils.ResolveAdminUrl(
				string.Format(@"InstalledPackages/content/views/Composite.Forms.FormSubmitHandler/GetData.aspx?entityToken={0}", EntityTokenSerializer.Serialize(entityToken))
			);

			ConsoleMessageQueueFacade.Enqueue(new DownloadFileMessageQueueItem(url), currentConsoleId);
			return null;
		}
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            Dictionary<string, string> viewArguments = new Dictionary<string, string>();
            viewArguments.Add("serializedEntityToken", serializedEntityToken);

            ConsoleMessageQueueFacade.Enqueue(new OpenHandledViewMessageQueueItem(EntityTokenSerializer.Serialize(entityToken, true), "Composite.Management.PermissionEditor", viewArguments), currentConsoleId);

            return null;
        }
Пример #39
0
 internal static void HandleRerender(string consoleId, string elementProviderName, FlowToken flowToken, FlowUiDefinitionBase oldUiDefinition, FlowUiDefinitionBase newUiDefinition, FlowControllerServicesContainer servicesContainer)
 {
     if (newUiDefinition.UiContainerType.ActionResultResponseType != oldUiDefinition.UiContainerType.ActionResultResponseType)
     {
         var messageService = servicesContainer.GetService<IManagementConsoleMessageService>();
         messageService.CloseCurrentView();
         HandleNew(consoleId, elementProviderName, string.Empty, flowToken, newUiDefinition);
     }
     else
     {
         // Force update in same container
         HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery, false);
     }
 }
Пример #40
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            UrlActionToken urlActionToken = (UrlActionToken)actionToken;

            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            string url = string.Format("{0}?EntityToken={1}", urlActionToken.Url, HttpUtility.UrlEncode(serializedEntityToken));

            ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = urlActionToken.Label }, currentConsoleId);

            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var token = actionToken as DownloadPackageActionToken;
            if (token != null)
            {
                var currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;
                var packageName = entityToken.Source;

                var url = UrlUtils.ResolveAdminUrl(
                    string.Format(@"InstalledPackages/services/Composite.Tools.PackageCreator/GetPackage.ashx?{0}={1}&consoleId={2}", token.Name, packageName, currentConsoleId));

                ConsoleMessageQueueFacade.Enqueue(new DownloadFileMessageQueueItem(url), currentConsoleId);
            }
            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string url = UrlUtils.ResolveAdminUrl("InstalledPackages/content/views/Composite.Tools.LinkChecker/ListBrokenLinks.aspx");

            var consoleServices = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
            var openViewMsg = new OpenViewMessageQueueItem
            {
                EntityToken = EntityTokenSerializer.Serialize(entityToken, true),
                ViewId = "LinkChecker",
                Label = GetResourceString("LinkCheckerActionToken.Label"),
                Url = url,
                ViewType = ViewType.Main
            };

            ConsoleMessageQueueFacade.Enqueue(openViewMsg, consoleServices.CurrentConsoleId);

            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            FunctionInfoActionToken urlActionToken = (FunctionInfoActionToken)actionToken;

            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            string url = UrlUtils.ResolveAdminUrl(@"content/views/functioninfo/ShowFunctionInfo.aspx");
            url += "?Name=" + urlActionToken.FunctionName + "&IsWidget=" + urlActionToken.IsWidgetFunction;

            ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem
            {
                Url = url,
                Label = urlActionToken.FunctionName,
                ViewId = Guid.NewGuid().ToString(),
                ViewType = ViewType.Main
            }, currentConsoleId);

            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.GetService<Composite.C1Console.Events.IManagementConsoleMessageService>().CurrentConsoleId;

            DisplayLocalOrderingActionToken castedActionToken = (DisplayLocalOrderingActionToken)actionToken;

            string url = string.Format("{0}?ParentPageId={1}", BaseUrl, HttpUtility.UrlEncode(castedActionToken.ParentPageId.ToString()));

            ConsoleMessageQueueFacade.Enqueue(
                new OpenViewMessageQueueItem
                    {
                        EntityToken = EntityTokenSerializer.Serialize(entityToken, true),
                        Url = url,
                        ViewId = Guid.NewGuid().ToString(),
                        ViewType = ViewType.Main,
                        Label = "Pages local orderings"
                    },
                currentConsoleId);

            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string functionNamePrefix = "";
            if (entityToken.Id.IndexOf('.') > -1)
            {
                functionNamePrefix = entityToken.Id.Substring(entityToken.Id.IndexOf('.') + 1);
            }

            bool widgets = entityToken.Id.ToLower().Contains("widget");

            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;
            string url = UrlUtils.ResolveAdminUrl(string.Format("content/views/functiondoc/FunctionDocumentation.aspx?functionPrefix={0}&widgets={1}", functionNamePrefix, widgets));

            ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem
                {
                    Url = url,
                    EntityToken = EntityTokenSerializer.Serialize(entityToken, true),
                    ViewId = Guid.NewGuid().ToString(),
                    ViewType = ViewType.Main,
                    Label = "Documentation"
                }, currentConsoleId);

            return null;
        }
            public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
            {
                var xslFunction = (IXsltFunction) ((DataEntityToken)entityToken).Data;

                string @namespace = xslFunction.Namespace;
                string name = xslFunction.Name;
                string functionFullName = @namespace + "." + name;

                Guid xslFunctionId = xslFunction.Id;
                var function = FunctionFacade.GetFunction(functionFullName);

                // TODO: default values convertion

                var cshtml = new StringBuilder();

                cshtml.Append(
                    @"@inherits RazorFunction

                @functions {
                ");

                if(!function.Description.IsNullOrEmpty())
                {
                    cshtml.Append(
                @"    public override string FunctionDescription
                {
                get { return @""" + function.Description.Replace("\"", "\"\"") + @"""; }
                }
                ");
                }

                if(function.ReturnType != typeof(XhtmlDocument))
                {
                    cshtml.Append(
                @"    public override Type FunctionReturnType
                {
                get { return typeof(" + function.ReturnType.FullName + @"); }
                }
                ");
                }

                foreach(var parameterProfile in function.ParameterProfiles)
                {
                    string parameterTemplate =
                @"
                [FunctionParameter(%Properties%)]
                public %Type% %Name% { get; set; }%DefaultValueNote%

                ";
                    var parameterProperties = new List<string>();

                    if(!parameterProfile.Label.IsNullOrEmpty()
                        && parameterProfile.Label != parameterProfile.Name)
                    {
                        parameterProperties.Add("Label=\"{0}\"".FormatWith(parameterProfile.Label));
                    }

                    if(parameterProfile.HelpDefinition != null
                        && !string.IsNullOrEmpty(parameterProfile.HelpDefinition.HelpText))
                    {
                        parameterProperties.Add("Help=@\"{0}\""
                            .FormatWith(parameterProfile.HelpDefinition.HelpText.Replace("\"", "\"\"")));
                    }

                    string parameterName = parameterProfile.Name;

                    IParameter parameter = DataFacade.GetData<IParameter>()
                        .FirstOrDefault(p => p.OwnerId == xslFunctionId && p.Name == parameterName);

                    string defaultValueTodoHint = string.Empty;
                    if(!parameter.DefaultValueFunctionMarkup.IsNullOrEmpty())
                    {
                        XElement markup = XElement.Parse(parameter.DefaultValueFunctionMarkup);

                        defaultValueTodoHint = @"// TODO: convert default value function markup
                /*" + markup + "*/";

                    }

                    string typeName = GetCSharpFriendlyTypeName(parameterProfile.Type);

                    Verify.IsNotNull(parameter, "Failed to get information about parameter " + parameterName);
                    if(!parameter.WidgetFunctionMarkup.IsNullOrEmpty())
                    {
                        const string start = @"<f:widgetfunction xmlns:f=""http://www.composite.net/ns/function/1.0"" name=""";
                        const string end1 = @""" label="""" bindingsourcename=""""><f:helpdefinition xmlns:f=""http://www.composite.net/ns/function/1.0"" helptext="""" /></f:widgetfunction>";
                        const string end2 = @""" />";

                        if (parameter.WidgetFunctionMarkup.StartsWith(start)
                            && (parameter.WidgetFunctionMarkup.EndsWith(end1)
                                || parameter.WidgetFunctionMarkup.EndsWith(end2)))
                        {
                            string str1 = parameter.WidgetFunctionMarkup.Substring(start.Length);
                            string widgetFunctionName = str1.Substring(0, str1.IndexOf("\""));

                            // Skipping default widget for string fields
                            if (widgetFunctionName != GetDefaultWidgetFunctionName(parameterProfile.Type))
                            {
                                parameterProperties.Add("WidgetFunctionName=\"{0}\"".FormatWith(widgetFunctionName));
                            }
                        }
                        else
                        {
                            parameterProperties.Add("WidgetMarkup=@\"{0}\"".FormatWith(parameter.WidgetFunctionMarkup.Replace("\"", "\"\"")));
                        }
                    }

                    cshtml.Append(parameterTemplate
                                      .Replace("%Properties%", string.Join(", ", parameterProperties))
                                      .Replace("%Type%", typeName)
                                      .Replace("%Name%", parameterProfile.Name)
                                      .Replace("%DefaultValueNote%", defaultValueTodoHint));
                }

                cshtml.Append(
                    @"}

                @{
                ");
                var functionCalls = DataFacade.GetData<INamedFunctionCall>().Where(fc => fc.XsltFunctionId == xslFunctionId).ToList();
                foreach(var functionCall in functionCalls)
                {
                     cshtml.Append(@"// TODO: convert function call '{0}'
                /* ".FormatWith(functionCall.Name));

                     XElement markup = XElement.Parse(functionCall.SerializedFunction);

                     cshtml.Append(markup);

                    cshtml.Append(@"*/
                ");
                }

                cshtml.Append(@"}

                <html xmlns=""http://www.w3.org/1999/xhtml"">
                <head>
                </head>
                <body>

                @* TODO: convert XSL template: *@

                @*
                ");
                try
                {
                    IFile file = IFileServices.TryGetFile<IXsltFile>(xslFunction.XslFilePath);
                    cshtml.Append(file.ReadAllText());
                }
                catch(Exception ex)
                {
                    cshtml.Append("Failed to load the file: " + ex);
                }

                cshtml.Append(@"
                *@
                </body>
                </html>");

                string fileFolder = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Razor/" + @namespace.Replace('.', '/'));
                Directory.CreateDirectory(fileFolder);

                string filePath = fileFolder + "/" + name + ".cshtml";
                File.WriteAllText(filePath, cshtml.ToString(), Encoding.UTF8);

                xslFunction.Name = xslFunction.Name + "_backup";
                DataFacade.Update(xslFunction);

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

                consoleMsgService.RefreshTreeSection(new BaseFunctionFolderElementEntityToken("ROOT:XsltBasedFunctionProviderElementProvider"));
                consoleMsgService.RefreshTreeSection(new BaseFunctionFolderElementEntityToken("ROOT:RazorFunctionProviderElementProvider"));

                consoleMsgService.ShowMessage( DialogType.Message, "XSL -> CSHTML",
                        (@"Template for the razor function '{0}'  have been added. Parts that have to be converted manually:
                a) Default values for parameters
                b) Function calls
                c) Transformation template itself".FormatWith(functionFullName)));

                return null;
            }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            SearchActionToken searchActionToken = (SearchActionToken)actionToken;

            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            string viewId = Guid.NewGuid().ToString();



            string url = UrlUtils.ResolveAdminUrl(string.Format("content/dialogs/treesearch/treeSearchForm.aspx?ProviderName={0}&EntityToken={1}&ViewId={2}&ConsoleId={3}", HttpUtility.UrlEncode(searchActionToken.ProviderName), HttpUtility.UrlEncode(serializedEntityToken), HttpUtility.UrlEncode(viewId), HttpUtility.UrlEncode(currentConsoleId)));

            ConsoleMessageQueueFacade.Enqueue(
                new OpenViewMessageQueueItem
                {
                    Url = url,
                    ViewId = viewId,
                    ViewType = ViewType.ModalDialog,
                    Label = StringResourceSystemFacade.GetString("Composite.Management", "RelationshipGraphActionExecutor.SearchElements"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Management", "RelationshipGraphActionExecutor.SearchElementsToolTip"),
                    IconResourceHandle = CommonElementIcons.Question
                }, currentConsoleId);


            return null;
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            StringBuilder sb = new StringBuilder();

            var elementInformationService = flowControllerServicesContainer.GetService<IElementInformationService>();

            if (elementInformationService != null)
            {
                Dictionary<string, string> piggybag = elementInformationService.Piggyback;

                foreach (var kvp in piggybag)
                {
                    Core.Serialization.StringConversionServices.SerializeKeyValuePair(sb, kvp.Key, kvp.Value);
                }
            }

            Guid id = Guid.NewGuid();
            string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.showinfo", id));

            C1File.WriteAllLines(filename, new string[] { serializedEntityToken, sb.ToString() });

            string url = string.Format("{0}?PiggyBagId={1}", UrlUtils.ResolveAdminUrl("content/views/showelementinformation/Default.aspx"), id);

            ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show Element Information..." }, currentConsoleId);

            return null;
        }
Пример #49
0
        /// <exclude />
        public static FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer, TaskManagerEvent taskManagerEvent)
        {
            if (entityToken == null) throw new ArgumentNullException("entityToken");
            if (actionToken == null) throw new ArgumentNullException("actionToken");


            string username = UserValidationFacade.GetUsername();
#if NO_SECURITY
#else
            HookingFacade.EnsureInitialization();

            IEnumerable<UserPermissionDefinition> userPermissionDefinitions = PermissionTypeFacade.GetUserPermissionDefinitions(username);
            IEnumerable<UserGroupPermissionDefinition> userGroupPermissionDefinitions = PermissionTypeFacade.GetUserGroupPermissionDefinitions(username);
            SecurityResult securityResult = SecurityResolver.Resolve(UserValidationFacade.GetUserToken(), actionToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinitions);
            if ((securityResult != SecurityResult.Allowed) && (entityToken.GetType() != typeof(SecurityViolationWorkflowEntityToken)))
            {
                return ExecuteSecurityViolation(actionToken, entityToken, flowControllerServicesContainer);
            }
#endif

            bool ignoreLocking = actionToken.IsIgnoreEntityTokenLocking();

            if ((ignoreLocking) ||
                (ActionLockingFacade.IsLocked(entityToken) == false))
            {
                IActionExecutor actionExecutor = ActionExecutorCache.GetActionExecutor(actionToken);

                ActionEventSystemFacade.FireOnBeforeActionExecution(entityToken, actionToken);

                FlowToken flowToken;
                using (TaskContainer taskContainer = TaskManagerFacade.CreateNewTasks(entityToken, actionToken, taskManagerEvent))
                {
                    ITaskManagerFlowControllerService taskManagerService = null;
                    if (flowControllerServicesContainer.GetService(typeof(ITaskManagerFlowControllerService)) == null)
                    {
                        taskManagerService = new TaskManagerFlowControllerService(taskContainer);
                        flowControllerServicesContainer.AddService(taskManagerService);
                    }

                    try
                    {
                        if ((actionExecutor is IActionExecutorSerializedParameters))
                        {
                            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);
                            string serializedActionToken = ActionTokenSerializer.Serialize(actionToken);

                            flowToken = Execute(actionExecutor as IActionExecutorSerializedParameters,
                                                serializedEntityToken, serializedActionToken, actionToken,
                                                flowControllerServicesContainer);
                        }
                        else
                        {
                            flowToken = Execute(actionExecutor, entityToken, actionToken,
                                                flowControllerServicesContainer);
                        }
                    }
                    finally
                    {
                        if (taskManagerService != null)
                        {
                            flowControllerServicesContainer.RemoveService(taskManagerService);
                        }
                    }

                    taskContainer.SetOnIdleTaskManagerEvent(new FlowTaskManagerEvent(flowToken));
                    taskContainer.UpdateTasksWithFlowToken(flowToken);

                    taskContainer.SaveTasks();
                }

                ActionEventSystemFacade.FireOnAfterActionExecution(entityToken, actionToken, flowToken);

                IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                if (managementConsoleMessageService != null)
                {
                    FlowControllerFacade.RegisterNewFlowInformation(flowToken, entityToken, actionToken, managementConsoleMessageService.CurrentConsoleId);
                }
                else
                {
                    LoggingService.LogWarning("ActionExecutorFacade", "Missing ManagementConsoleMessageService, can not register the flow");
                }

                return flowToken;
            }
            else
            {
                return ExecuteEntityTokenLocked(actionToken, entityToken, flowControllerServicesContainer);
            }
        }
Пример #50
0
        private static bool ConsoleIdEquals(FlowControllerServicesContainer flowControllerServicesContainer, string consoleId)
        {
            if (flowControllerServicesContainer == null) return false;

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

            if (managementConsoleMessageService == null) return false;

            return managementConsoleMessageService.CurrentConsoleId == consoleId;
        }
Пример #51
0
        private static void OnFinish(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Finish" }))
            {
                TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer);
                serviceContainer.AddService(taskManagerFlowControllerService);

                WorkflowFacade.FireFinishEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));
            }


            IFormFlowRenderingService formServices = serviceContainer.GetService<IFormFlowRenderingService>();

            if (!formServices.HasFieldMessages)
            {
                serviceContainer.GetService<IFormFlowRenderingService>().RerenderView();
            }
        }
Пример #52
0
        private static void OnPrevious(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Previous" }))
            {
                WorkflowFacade.FirePreviousEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));
            }

            serviceContainer.GetService<IFormFlowRenderingService>().RerenderView();
        }
        public FlowToken Execute(
           EntityToken entityToken,
           ActionToken actionToken,
           FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.
               GetService<IManagementConsoleMessageService>().CurrentConsoleId;
            if (entityToken is NugetRootEntityToken)
            {
                var dataEntityToken = entityToken as NugetRootEntityToken;

                string url = string.Format("/Composite/InstalledPackages/Composite.Integration.Nuget/views/NugetPackageManager.cshtml");
                ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem
                {
                    Url = url,
                    ViewId = Guid.NewGuid().ToString(),
                    ViewType = ViewType.Main,
                    Label = "loading..."
                }, currentConsoleId);
              
            }
            else if (entityToken is NugetPackageEntityToken)
            {
                var pm = new CompositePackageManager();
                var token = entityToken as NugetPackageEntityToken;
                IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();

                if(token.IsLocalPackage())
                {
                    try
                    {
                        pm.UninstallPackage(token.PackageId, new NuGet.SemanticVersion(token.Version),false,true);
                       
                    }catch(InvalidOperationException ex)
                    {
                       
   
                      //  ConsoleMessageQueueFacade.Enqueue(new MessageBoxMessageQueueItem { DialogType = DialogType.Question, Message = ex.Message, Title = "Package Manager" }, managementConsoleMessageService.CurrentConsoleId);
                        ConsoleMessageQueueFacade.Enqueue(new MessageBoxMessageQueueItem { DialogType = DialogType.Error, Message = ex.Message, Title = "Package Manager" }, managementConsoleMessageService.CurrentConsoleId);
                   //     ConsoleMessageQueueFacade.Enqueue(new MessageBoxMessageQueueItem { DialogType = DialogType.Message, Message = ex.Message, Title = "Package Manager" }, managementConsoleMessageService.CurrentConsoleId);
                   //     ConsoleMessageQueueFacade.Enqueue(new MessageBoxMessageQueueItem { DialogType = DialogType.Warning, Message = ex.Message, Title = "Package Manager" }, managementConsoleMessageService.CurrentConsoleId);
                 //       throw;
                    }
                }
                else if(token.IsRemotePackage())
                {
                    try
                    {


                        pm.InstallPackage(token.PackageId, new NuGet.SemanticVersion(token.Version));
                    }
                    catch(Exception ex)
                    {
                        ConsoleMessageQueueFacade.Enqueue(new MessageBoxMessageQueueItem { DialogType = DialogType.Error, Message = ex.Message, Title = "Package Manager" }, managementConsoleMessageService.CurrentConsoleId);
                    

                    }
                    finally
                    {
                        ConsoleMessageQueueFacade.Enqueue(new RefreshTreeMessageQueueItem { EntityToken = NugetEntityToken.InstalledEntityToken }, currentConsoleId);
                   
                    }
                
                }else if(token.IsUpdatePackage())
                {
                    pm.UpdatePackage(token.PackageId, true, false);

                    ConsoleMessageQueueFacade.Enqueue(new RefreshTreeMessageQueueItem { EntityToken = NugetEntityToken.InstalledEntityToken }, currentConsoleId);
                
                }
            }
            ConsoleMessageQueueFacade.Enqueue(new RefreshTreeMessageQueueItem { EntityToken = new NugetRootEntityToken()}, currentConsoleId);
            return null;
        }
Пример #54
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            CustomUrlActionNodeActionToken customUrlActionNodeActionToken = (CustomUrlActionNodeActionToken)actionToken;

            CustomUrlActionNode customUrlActionNode = (CustomUrlActionNode)ActionNode.Deserialize(customUrlActionNodeActionToken.SerializedActionNode);

            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            switch (customUrlActionNode.ViewType)
            {
                case CustomUrlActionNodeViewType.DocumentView:
                    {
                        string viewId = Guid.NewGuid().ToString();
                        string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);

                        OpenViewMessageQueueItem openViewMessageQueueItem = new OpenViewMessageQueueItem()
                        {
                            ViewId = viewId,
                            EntityToken = serializedEntityToken,
                            Label = customUrlActionNodeActionToken.ViewLabel,
                            ToolTip = customUrlActionNodeActionToken.ViewToolTip,
                            IconResourceHandle = customUrlActionNode.ViewIcon,
                            Url = customUrlActionNodeActionToken.Url,
                            UrlPostArguments = customUrlActionNode.PostParameters
                        };
                        ConsoleMessageQueueFacade.Enqueue(openViewMessageQueueItem, currentConsoleId);

                        BindEntityTokenToViewQueueItem bindEntityTokenToViewQueueItem = new BindEntityTokenToViewQueueItem()
                        {
                            ViewId = viewId,
                            EntityToken = serializedEntityToken
                        };
                        ConsoleMessageQueueFacade.Enqueue(bindEntityTokenToViewQueueItem, currentConsoleId);
                    }
                    break;

                case CustomUrlActionNodeViewType.ExternalView:
                    {
                        string viewId = Guid.NewGuid().ToString();
                        string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);

                        OpenExternalViewQueueItem openExternalViewQueueItem = new OpenExternalViewQueueItem(entityToken)
                        {
                            ViewId = viewId,
                            EntityToken = serializedEntityToken,
                            Label = customUrlActionNodeActionToken.ViewLabel,
                            ToolTip = customUrlActionNodeActionToken.ViewToolTip,
                            IconResourceHandle = customUrlActionNode.ViewIcon,
                            Url = customUrlActionNodeActionToken.Url,
                            ViewType = customUrlActionNodeActionToken.ViewType,
                            UrlPostArguments = customUrlActionNode.PostParameters
                        };
                        ConsoleMessageQueueFacade.Enqueue(openExternalViewQueueItem, currentConsoleId);

                        BindEntityTokenToViewQueueItem bindEntityTokenToViewQueueItem = new BindEntityTokenToViewQueueItem()
                        {
                            ViewId = viewId,
                            EntityToken = serializedEntityToken
                        };
                        ConsoleMessageQueueFacade.Enqueue(bindEntityTokenToViewQueueItem, currentConsoleId);
                    }
                    break;

                case CustomUrlActionNodeViewType.GenericView:
                    {
                        string viewId = Guid.NewGuid().ToString();
                        string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);

                        OpenGenericViewQueueItem openGenericViewQueueItem = new OpenGenericViewQueueItem(entityToken)
                        {
                            ViewId = viewId,
                            EntityToken = serializedEntityToken,
                            Label = customUrlActionNodeActionToken.ViewLabel,
                            ToolTip = customUrlActionNodeActionToken.ViewToolTip,
                            IconResourceHandle = customUrlActionNode.ViewIcon,
                            Url = customUrlActionNodeActionToken.Url,
                            UrlPostArguments = customUrlActionNode.PostParameters
                        };
                        ConsoleMessageQueueFacade.Enqueue(openGenericViewQueueItem, currentConsoleId);

                        BindEntityTokenToViewQueueItem bindEntityTokenToViewQueueItem = new BindEntityTokenToViewQueueItem()
                        {
                            ViewId = viewId,
                            EntityToken = serializedEntityToken
                        };
                        ConsoleMessageQueueFacade.Enqueue(bindEntityTokenToViewQueueItem, currentConsoleId);
                    }
                    break;


                case CustomUrlActionNodeViewType.PageBrowser:
                    Dictionary<string, string> arguments = new Dictionary<string, string>();
                    arguments.Add("URL", customUrlActionNodeActionToken.Url);

                    OpenHandledViewMessageQueueItem openHandledViewMessageQueueItem = new OpenHandledViewMessageQueueItem(
                        EntityTokenSerializer.Serialize(entityToken, true), 
                        "Composite.Management.Browser", 
                        arguments
                    );

                    ConsoleMessageQueueFacade.Enqueue(openHandledViewMessageQueueItem, currentConsoleId);                    
                    break;


                case CustomUrlActionNodeViewType.FileDownload:
                    DownloadFileMessageQueueItem downloadFileMessageQueueItem = new DownloadFileMessageQueueItem(customUrlActionNodeActionToken.Url);

                    ConsoleMessageQueueFacade.Enqueue(downloadFileMessageQueueItem, currentConsoleId);                    
                    break;
            }


            return null;
        }
Пример #55
0
        private static void OnCancel(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            if (WorkflowFacade.WorkflowExists(workflowFlowToken.WorkflowInstanceId))
            {
                using (TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Cancel" }))
                {
                    WorkflowFacade.FireCancelEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                    WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                    WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);                    
                }
            }
            else
            {
                Log.LogVerbose(LogTitle, "Cancel event suppressed because the workflow was terminated ({0})", workflowFlowToken.WorkflowInstanceId);
            }

            if (serviceContainer != null)
            {
                serviceContainer.GetService<IFormFlowRenderingService>().RerenderView();
            }
        }
        private static void BaseEventHandler(string consoleId, 
                                             string elementProviderName, 
                                             FlowToken flowToken,
                                             FormFlowUiDefinition formFlowUiCommand,
                                             FlowControllerServicesContainer servicesContainer, 
                                             Dictionary<IFormEventIdentifier, FormFlowEventHandler> eventHandlers,
                                             IFormEventIdentifier localScopeEventIdentifier,
                                             FlowControllerServicesContainer formServicesContainer)
        {
            FormTreeCompiler activeFormTreeCompiler = CurrentFormTreeCompiler;
            Dictionary<string, object> activeInnerFormBindings = CurrentInnerFormBindings;

            FormFlowEventHandler handler = eventHandlers[localScopeEventIdentifier];
            Dictionary<string, Exception> bindingErrors = activeFormTreeCompiler.SaveAndValidateControlProperties();

            formServicesContainer.AddService(new BindingValidationService(bindingErrors));

            handler.Invoke(flowToken, activeInnerFormBindings, formServicesContainer);

            if (formServicesContainer.GetService<IManagementConsoleMessageService>().CloseCurrentViewRequested)
            {
                ViewTransitionHelper.HandleCloseCurrentView(formFlowUiCommand.UiContainerType);
                return;
            }
            
            var formFlowService = (FormFlowRenderingService) formServicesContainer.GetService<IFormFlowRenderingService>();
            bool replacePageOutput = (formServicesContainer.GetService<IFormFlowWebRenderingService>().NewPageOutput != null);

            bool rerenderView = formFlowService.RerenderViewRequested;
            if (formFlowService.BindingPathedMessages != null)
            {
                ShowFieldMessages(CurrentControlTreeRoot, formFlowService.BindingPathedMessages, CurrentControlContainer,
                                    servicesContainer);
            }

            List<bool> boolCounterList = new List<bool> {replacePageOutput, rerenderView};

            if (boolCounterList.Count(f => f) > 1)
            {
                StringBuilder sb = new StringBuilder("Flow returned conflicting directives for post handling:\n");
                if (replacePageOutput) sb.AppendLine(" - Replace page output with new web control.");
                if (rerenderView) sb.AppendLine(" - Rerender view.");

                throw new InvalidOperationException(sb.ToString());
            }

            if (rerenderView)
            {
                Log.LogVerbose("FormFlowRendering", "Re-render requested");
                IFlowUiDefinition newFlowUiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken,
                                                                                                    servicesContainer);
                if (!(newFlowUiDefinition is FlowUiDefinitionBase))
                    throw new NotImplementedException("Unable to handle transitions to ui definition of type " +
                                                        newFlowUiDefinition.GetType());
                ViewTransitionHelper.HandleRerender(consoleId, elementProviderName, flowToken, formFlowUiCommand,
                                                    (FlowUiDefinitionBase) newFlowUiDefinition, servicesContainer);
            }

            if (replacePageOutput)
            {
                Log.LogVerbose("FormFlowRendering", "Replace pageoutput requested");
                IFormFlowWebRenderingService webRenderingService =
                    formServicesContainer.GetService<IFormFlowWebRenderingService>();
                Control newPageOutput = webRenderingService.NewPageOutput;

                foreach (Control control in GetNestedControls(newPageOutput).Where(f => f is ScriptManager).ToList())
                {
                    control.Parent.Controls.Remove(control);
                }

                Page currentPage = HttpContext.Current.Handler as Page;

                HtmlHead newHeadControl = GetNestedControls(newPageOutput).FirstOrDefault(f => f is HtmlHead) as HtmlHead;

                HtmlHead oldHeadControl = currentPage.Header;

                ControlCollection headContainer = null;
                bool headersHasToBeSwitched = newHeadControl != null && oldHeadControl != null;
                if (headersHasToBeSwitched)
                {
                    headContainer = newHeadControl.Parent.Controls;
                    headContainer.Remove(newHeadControl);
                }

                currentPage.Controls.Clear();
                if (string.IsNullOrEmpty(webRenderingService.NewPageMimeType))
                {
                    currentPage.Response.ContentType = "text/html";
                }
                else
                {
                    currentPage.Response.ContentType = webRenderingService.NewPageMimeType;
                }
                currentPage.Controls.Add(newPageOutput);

                if (headersHasToBeSwitched)
                {
                    oldHeadControl.Controls.Clear();
                    oldHeadControl.InnerHtml = "";
                    oldHeadControl.InnerText = "";
                    if (newHeadControl.ID != null)
                    {
                        oldHeadControl.ID = newHeadControl.ID;
                    }
                    oldHeadControl.Title = newHeadControl.Title;

                    headContainer.AddAt(0, oldHeadControl);

                    foreach (Control c in newHeadControl.Controls.Cast<Control>().ToList())
                    {
                        oldHeadControl.Controls.Add(c);
                    }
                }
            }
            
        }
        public static IUiControl Render(
            string consoleId,
            string elementProviderName,
            FlowToken flowToken,
            FormFlowUiDefinition formFlowUiCommand,
            IFormChannelIdentifier channel,
            bool debugMode,
            FlowControllerServicesContainer servicesContainer)
        {
            FlowControllerServicesContainer formServicesContainer = new FlowControllerServicesContainer(servicesContainer);
            formServicesContainer.AddService(new FormFlowRenderingService());
            formServicesContainer.AddService(new FormFlowWebRenderingService());

            IFormMarkupProvider formMarkupProvider = formFlowUiCommand.MarkupProvider;
            IFormMarkupProvider customToolbarItemsMarkupProvider = formFlowUiCommand.CustomToolbarItemsMarkupProvider;
            Dictionary<string, object> innerFormBindings = formFlowUiCommand.BindingsProvider.GetBindings();
            Dictionary<IFormEventIdentifier, FormFlowEventHandler> eventHandlers = formFlowUiCommand.EventHandlers;
            Dictionary<string, List<ClientValidationRule>> bindingsValidationRules = formFlowUiCommand.BindingsValidationRules;

            FormTreeCompiler formCompiler = new FormTreeCompiler();
            IUiContainer renderingContainer = GetRenderingContainer(channel, formFlowUiCommand.UiContainerType);

            // Setting state related objects so the delegate below can access them "fresh"
            CurrentFormTreeCompiler = formCompiler;
            CurrentInnerFormBindings = innerFormBindings;
            CurrentControlContainer = (IWebUiContainer)renderingContainer;


            Dictionary<string, object> containerEventHandlerStubs = new Dictionary<string, object>();

            foreach (IFormEventIdentifier eventIdentifier in eventHandlers.Keys)
            {
                IFormEventIdentifier localScopeEventIdentifier = eventIdentifier;  // See: Local variable usage with anonymous methods within loop control structures

                EventHandler handlerStub = delegate(object sender, EventArgs e)
                {
                    try
                    {
                        BaseEventHandler(consoleId, elementProviderName, flowToken, formFlowUiCommand, servicesContainer, eventHandlers, localScopeEventIdentifier, formServicesContainer);
                    }
                    catch (Exception ex)
                    {
                        formServicesContainer.GetService<IManagementConsoleMessageService>().ShowLogEntry(typeof(FormFlowUiDefinitionRenderer), ex);
                        throw;
                    }
                };

                containerEventHandlerStubs.Add(eventIdentifier.BindingName, handlerStub);

                if (innerFormBindings.ContainsKey(eventIdentifier.BindingName))
                {
                    innerFormBindings.Remove(eventIdentifier.BindingName);
                }

                innerFormBindings.Add(eventIdentifier.BindingName, handlerStub);
            }

            XDocument document;

            using (XmlReader formMarkupReader = formMarkupProvider.GetReader())
            {
                document = XDocument.Load(formMarkupReader);
                formMarkupReader.Close();
            }

            formCompiler.Compile(document, channel, innerFormBindings, debugMode, "", bindingsValidationRules);

            IUiControl innerForm = formCompiler.UiControl;

            IUiControl customToolbarItems = null;
            if (customToolbarItemsMarkupProvider != null)
            {
                FormTreeCompiler toolbarCompiler = new FormTreeCompiler();
                using (XmlReader formMarkupReader = customToolbarItemsMarkupProvider.GetReader())
                {
                    toolbarCompiler.Compile(formMarkupReader, channel, innerFormBindings, debugMode, bindingsValidationRules);
                }
                customToolbarItems = toolbarCompiler.UiControl;
            }

            CurrentControlTreeRoot = (IWebUiControl)innerForm;

            string label = formCompiler.Label;
            if(label.IsNullOrEmpty())
            {
                label = formFlowUiCommand.ContainerLabel ?? "";
            }

            string labelField = GetFormLabelField(document);
            ResourceHandle containerIcon = formCompiler.Icon;

            return renderingContainer.Render(formCompiler.UiControl, customToolbarItems, channel, containerEventHandlerStubs, label, labelField, containerIcon);
        }
        private static void ShowFieldMessages(IWebUiControl webUiControlTreeRoot, Dictionary<string, string> bindingPathedMessages, IWebUiContainer container, FlowControllerServicesContainer servicesContainer)
        {
            Dictionary<string, string> pathToClientIDMappings = new Dictionary<string, string>();
            ResolveBindingPathToCliendIDMappings(webUiControlTreeRoot, pathToClientIDMappings);

            Dictionary<string, string> cliendIDPathedMessages = new Dictionary<string, string>();
            Dictionary<string, string> homelessMessages = new Dictionary<string, string>();

            foreach (var msgElement in bindingPathedMessages)
            {
                string clientId = null;

                if (pathToClientIDMappings.TryGetValue(msgElement.Key, out clientId))
                {
                    cliendIDPathedMessages.Add(clientId, msgElement.Value);
                }
                else
                {
                    homelessMessages.Add(msgElement.Key, msgElement.Value);
                }
            }

            container.ShowFieldMessages(cliendIDPathedMessages);

            if (homelessMessages.Count > 0)
            {
                StringBuilder sb = new StringBuilder();

                foreach (var msgElement in homelessMessages)
                {
                    sb.AppendFormat("{0}: {1}\n", msgElement.Key, msgElement.Value);
                }

                var consoleMsgService = servicesContainer.GetService<IManagementConsoleMessageService>();
                consoleMsgService.ShowMessage(DialogType.Warning, "Field messages", sb.ToString());
            }
        }
            public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
            {
                DataEntityToken token = (DataEntityToken)entityToken;

                IPublishControlled publishControlled = (IPublishControlled)DataFacade.GetDataFromDataSourceId(token.DataSourceId);

                ValidationResults validationResults = ValidationFacade.Validate((IData)publishControlled);

                if (validationResults.IsValid)
                {
                    UpdateTreeRefresher treeRefresher = new UpdateTreeRefresher(token.Data.GetDataEntityToken(), flowControllerServicesContainer);

                    if (actionToken is PublishActionToken)
                    {
                        publishControlled.PublicationStatus = Published;
                    }
                    else if (actionToken is DraftActionToken)
                    {
                        publishControlled.PublicationStatus = Draft;
                    }
                    else if (actionToken is AwaitingApprovalActionToken)
                    {
                        publishControlled.PublicationStatus = AwaitingApproval;
                    }
                    else if (actionToken is AwaitingPublicationActionToken)
                    {
                        publishControlled.PublicationStatus = AwaitingPublication;
                    }
                    else if (actionToken is UnpublishActionToken)
                    {
                        publishControlled.PublicationStatus = Draft;

                        using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope())
                        {
                            IData data = DataFacade.GetDataFromOtherScope(token.Data, DataScopeIdentifier.Public).SingleOrDefault();

                            if (data != null)
                            {
                                IPage page = data as IPage;
                                if (page != null)
                                {
                                    IEnumerable<IData> referees;
                                    using (new DataScope(DataScopeIdentifier.Public))
                                    {
                                        referees = page.GetMetaData();
                                    }

                                    DataFacade.Delete(referees, CascadeDeleteType.Disable);
                                }

                                
                                DataFacade.Delete(data, CascadeDeleteType.Disable);
                            }
                            
                            transactionScope.Complete();
                        }
                    }
                    else if (actionToken is UndoPublishedChangesActionToken)
                    {
                        using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope())
                        {
                            using (ProcessControllerFacade.NoProcessControllers)
                            {
                                var administrativeData = (IPublishControlled)token.Data;
                                IData publishedData = DataFacade.GetDataFromOtherScope(token.Data, DataScopeIdentifier.Public).Single();

                                publishedData.FullCopyChangedTo(administrativeData);
                                administrativeData.PublicationStatus = Draft;

                                DataFacade.Update(administrativeData);
                            }

                            transactionScope.Complete();
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Unknown action token", "actionToken");
                    }
                    
                    DataFacade.Update(publishControlled);

                    treeRefresher.PostRefreshMesseges(publishControlled.GetDataEntityToken());
                }
                else
                {
                    var managementConsoleMessageService = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();

                    StringBuilder sb = new System.Text.StringBuilder();
                    sb.AppendLine(StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "ValidationErrorMessage"));
                    foreach (ValidationResult result in validationResults)
                    {
                        sb.AppendLine(result.Message);
                    }

                    managementConsoleMessageService.ShowMessage(DialogType.Error, StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "ValidationErrorTitle"), sb.ToString());
                }

                return null;
            }