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);
        }
Esempio n. 2
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            PackageCreatorFacade.DeletePackageInformation(entityToken.Source);
            SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());
            return(null);
        }
Esempio n. 3
0
 public string GetLabel()
 {
     if (string.IsNullOrEmpty(Label))
     {
         return(PackageCreatorFacade.GetLocalization(string.Format("{0}.Label", Name)));
     }
     return(Label);
 }
Esempio n. 4
0
        private void SaveCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var package = this.GetBinding <PackageInformation>("Package");

            PackageCreatorFacade.SavePackageInformation(package, this.EntityToken.Source);
            SpecificTreeRefresher treeRefresher = this.CreateSpecificTreeRefresher();

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            this.UpdateBinding("PackageUrl", "123");

            this.SetSaveStatus(true);
        }
Esempio n. 5
0
        private void ValidateSave(object sender, ConditionalEventArgs e)
        {
            e.Result = true;
            var package = this.GetBinding <PackageInformation>("Package");
            var maxCompositeVersionSupported = this.GetBinding <string>("MaxCompositeVersionSupported");
            var minCompositeVersionSupported = this.GetBinding <string>("MinCompositeVersionSupported");

            try
            {
                package.MaxCompositeVersionSupported = new Version(maxCompositeVersionSupported);
            }
            catch
            {
                this.ShowFieldMessage("MaxCompositeVersionSupported", PackageCreatorFacade.GetLocalization("Error.WrongVersion"));
                e.Result = false;
            }

            try
            {
                package.MinCompositeVersionSupported = new Version(minCompositeVersionSupported);
            }
            catch
            {
                this.ShowFieldMessage("MinCompositeVersionSupported", PackageCreatorFacade.GetLocalization("Error.WrongVersion"));
                e.Result = false;
            }

            if (string.IsNullOrEmpty(package.Description))
            {
                this.ShowFieldMessage("Package.Description", PackageCreatorFacade.GetLocalization("Required"));
                e.Result = false;
            }

            if (string.IsNullOrEmpty(package.TechnicalDetails))
            {
                this.ShowFieldMessage("Package.TechnicalDetails", PackageCreatorFacade.GetLocalization("Required"));
                e.Result = false;
            }

            if (this.EntityToken.Source != package.Name && PackageCreatorFacade.GetPackageNames().Contains(package.Name.Trim()))
            {
                this.ShowFieldMessage("Package.Name", PackageCreatorFacade.GetLocalization("Error.PackageAlreadyExist"));
                e.Result = false;
            }
            this.UpdateBinding("Package", package);
        }
 private void AddConfig_CodeActivity_ExecuteCode(object sender, EventArgs e)
 {
     try
     {
         UploadedFile uploadedFile = this.GetBinding <UploadedFile>("UploadedFile");
         PackageCreatorFacade.AddConfig(uploadedFile);
         SpecificTreeRefresher treeRefresher = this.CreateSpecificTreeRefresher();
         treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());
     }
     catch (Exception ex)
     {
         this.UpdateBinding("Errors", new List <List <string> > {
             new List <string> {
                 ex.Message, ""
             }
         });
     }
 }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var item = PackageCreatorActionFacade.GetPackageCreatorItem(entityToken.Type, entityToken.Id);

            PackageCreatorFacade.RemoveItem(item, entityToken.Source);

            SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            var itemToggle = item as IPackToggle;

            if (itemToggle != null)
            {
                var itemEntityToken = itemToggle.GetEntityToken();
                if (itemEntityToken != null)
                {
                    var parentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);
                    parentTreeRefresher.PostRefreshMesseges(itemEntityToken);
                }
            }

            return(null);
        }
        public IEnumerable <Element> GetRoots(SearchToken seachToken)
        {
            Element element = new Element(_context.CreateElementHandle(new PackageCreatorElementProviderEntityToken()))
            {
                VisualData = new ElementVisualizedData()
                {
                    Label       = PackageCreatorFacade.GetLocalization("PackageCreatorElementProviderEntityToken.Label"),
                    ToolTip     = PackageCreatorFacade.GetLocalization("PackageCreatorElementProviderEntityToken.ToolTip"),
                    HasChildren = true,
                    Icon        = new ResourceHandle("Composite.Icons", "blocks"),
                    OpenedIcon  = new ResourceHandle("Composite.Icons", "blocks")
                }
            };

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(typeof(CreatePackageWorkflow), new PermissionType[] { PermissionType.Administrate })))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = PackageCreatorFacade.GetLocalization("CreatePackage.Label"),
                    ToolTip        = PackageCreatorFacade.GetLocalization("CreatePackage.ToolTip"),
                    Icon           = new ResourceHandle("Composite.Icons", "blocks"),
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = PackageCreatorFacade.ActionType,
                        IsInFolder  = false,
                        IsInToolbar = true,
                        ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                    }
                }
            });


            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(typeof(UploadConfigWorkflow), new PermissionType[] { PermissionType.Administrate })))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = PackageCreatorFacade.GetLocalization("UploadConfig.Label"),
                    ToolTip        = PackageCreatorFacade.GetLocalization("UploadConfig.ToolTip"),
                    Icon           = new ResourceHandle("Composite.Icons", "package-install-local-package"),
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = PackageCreatorFacade.ActionType,
                        IsInFolder  = false,
                        IsInToolbar = false,
                        ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                    }
                }
            });

            if (UserSettings.C1ConsoleUiLanguage.Name != "en-US")
            {
                element.AddAction(new ElementAction(new ActionHandle(new CreatePackageWorkflowActionToken(string.Format("Composite.Localization.C1Console.{0}", new CultureInfo(UserSettings.C1ConsoleUiLanguage.TwoLetterISOLanguageName).EnglishName), new AddLocalizationActionToken(UserSettings.C1ConsoleUiLanguage.Name))))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = string.Format(PackageCreatorFacade.GetLocalization("CreateLocalizationPackage.Label"), StringResourceSystemFacade.GetString("Composite.Cultures", UserSettings.C1ConsoleUiLanguage.Name)),
                        ToolTip        = string.Format(PackageCreatorFacade.GetLocalization("CreateLocalizationPackage.ToolTip"), StringResourceSystemFacade.GetString("Composite.Cultures", UserSettings.C1ConsoleUiLanguage.Name)),
                        Icon           = new ResourceHandle("Composite.Icons", "package-element-closed-availableitem"),
                        ActionLocation = new ActionLocation
                        {
                            ActionType  = PackageCreatorFacade.ActionType,
                            IsInFolder  = false,
                            IsInToolbar = false,
                            ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                        }
                    }
                });
            }

            yield return(element);

            yield return(GetXmlNodeElement(PCCompositeConfig.Source, string.Empty, PCCompositeConfig.Source));

            yield return(GetXmlNodeElement(PCWebConfig.Source, string.Empty, PCWebConfig.Source));
        }
        public IEnumerable <Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if (entityToken is PackageCreatorElementProviderEntityToken)
            {
                IEnumerable <string> packages = PackageCreatorFacade.GetPackageNames();
                foreach (var package in packages)
                {
                    bool isActivePackage = PackageCreatorFacade.ActivePackageName == package;

                    var icon    = isActivePackage ? (new ResourceHandle("Composite.Icons", "inbox-green")) : new ResourceHandle("Composite.Icons", "inbox");
                    var element = new Element(_context.CreateElementHandle(new PackageCreatorPackageElementProviderEntityToken(package)))
                    {
                        VisualData = new ElementVisualizedData()
                        {
                            Label       = package,
                            ToolTip     = package,
                            HasChildren = true,
                            Icon        = icon,
                            OpenedIcon  = icon
                        }
                    };

                    element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(typeof(EditPackageWorkflow), new[] { PermissionType.Administrate })))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = PackageCreatorFacade.GetLocalization("EditPackage.Label"),
                            ToolTip        = PackageCreatorFacade.GetLocalization("EditPackage.ToolTip"),
                            Icon           = new ResourceHandle("Composite.Icons", "page-edit-page"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = ActionType.Other,
                                IsInFolder  = false,
                                IsInToolbar = true,
                                ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    if (!isActivePackage)
                    {
                        element.AddAction(new ElementAction(new ActionHandle(new SetActivePackageActionToken()))
                        {
                            VisualData = new ActionVisualizedData
                            {
                                Label          = PackageCreatorFacade.GetLocalization("SetActivePackage.Label"),
                                ToolTip        = PackageCreatorFacade.GetLocalization("SetActivePackage.ToolTip"),
                                Icon           = new ResourceHandle("Composite.Icons", "accept"),
                                ActionLocation = new ActionLocation
                                {
                                    ActionType  = ActionType.Other,
                                    IsInFolder  = false,
                                    IsInToolbar = true,
                                    ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                                }
                            }
                        });
                    }

                    element.AddAction(new ElementAction(new ActionHandle(new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteConfigPackageCreatorActionToken))))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = PackageCreatorFacade.GetLocalization("DeleteConfigPackageCreator.Label"),
                            ToolTip        = PackageCreatorFacade.GetLocalization("DeleteConfigPackageCreator.ToolTip"),
                            Icon           = new ResourceHandle("Composite.Icons", "generated-type-delete"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = PackageCreatorFacade.ActionType,
                                IsInFolder  = false,
                                IsInToolbar = false,
                                ActionGroup = new ActionGroup("Other", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    element.AddAction(new ElementAction(new ActionHandle(new DownloadPackageActionToken("package")))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = PackageCreatorFacade.GetLocalization("DownloadPackageButton.Label"),
                            ToolTip        = PackageCreatorFacade.GetLocalization("DownloadPackageButton.ToolTip"),
                            Icon           = new ResourceHandle("Composite.Icons", "package-install-local-package"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = PackageCreatorFacade.ActionType,
                                IsInFolder  = false,
                                IsInToolbar = true,
                                ActionGroup = new ActionGroup("Download", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    element.AddAction(new ElementAction(new ActionHandle(new DownloadPackageActionToken("config")))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = PackageCreatorFacade.GetLocalization("DownloadConfigButton.Label"),
                            ToolTip        = PackageCreatorFacade.GetLocalization("DownloadConfigButton.ToolTip"),
                            Icon           = new ResourceHandle("Composite.Icons", "package-install-local-package"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = PackageCreatorFacade.ActionType,
                                IsInFolder  = false,
                                IsInToolbar = false,
                                ActionGroup = new ActionGroup("Download", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    yield return(element);
                }
            }
            else if (entityToken is PackageCreatorPackageElementProviderEntityToken)
            {
                var categories = PackageCreatorFacade.GetCategories(entityToken.Source);
                foreach (var category in categories)
                {
                    var element = new Element(_context.CreateElementHandle(new PackageCreatorCategoryElementProviderEntityToken(entityToken.Source, category.Name)))
                    {
                        VisualData = new ElementVisualizedData()
                        {
                            Label       = category.GetLabel(),
                            ToolTip     = category.GetLabel(),
                            HasChildren = true,
                            Icon        = new ResourceHandle("Composite.Icons", "folder"),
                            OpenedIcon  = new ResourceHandle("Composite.Icons", "folder-open")
                        }
                    };
                    yield return(element);
                }
            }
            else if (entityToken is PackageCreatorCategoryElementProviderEntityToken)
            {
                var items = PackageCreatorFacade.GetItems(entityToken.Type, entityToken.Source);
                foreach (var item in items.OrderBy(d => d.Id))
                {
                    var element = new Element(_context.CreateElementHandle(new PackageCreatorItemElementProviderEntityToken(item.Id, entityToken.Source, entityToken.Type)))
                    {
                        VisualData = new ElementVisualizedData()
                        {
                            Label       = item.GetLabel(),
                            ToolTip     = item.Id,
                            HasChildren = false,
                            Icon        = item.ItemIcon,
                            OpenedIcon  = item.ItemIcon
                        }
                    };

                    element.AddAction(new ElementAction(new ActionHandle(new DeleteItemPackageCreatorActionToken()))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = PackageCreatorFacade.GetLocalization("DeleteItemPackageCreator.Label"),
                            ToolTip        = PackageCreatorFacade.GetLocalization("DeleteItemPackageCreator.ToolTip"),
                            Icon           = new ResourceHandle("Composite.Icons", "page-delete-page"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = ActionType.Other,
                                IsInFolder  = false,
                                IsInToolbar = true,
                                ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    yield return(element);
                }
            }
            else if (entityToken is XmlNodeElementProviderEntityToken)
            {
                var        configuration = PackageCreatorFacade.GetConfigurationDocument(entityToken.Source);
                var        xpath         = (entityToken as XmlNodeElementProviderEntityToken).XPath;
                XContainer container     = xpath == string.Empty ? configuration as XContainer : configuration.XPathSelectElement(xpath) as XContainer;
                var        element       = container as XElement;
                var        counter       = new Dictionary <string, int>();


                if (container != null)
                {
                    var xmlElements = new List <Element>();
                    foreach (XElement item in container.Elements())
                    {
                        string position = string.Empty;
                        string name     = item.Name.ToString();
                        if (counter.ContainsKey(name))
                        {
                            position = string.Format("[{0}]", ++counter[name]);
                        }
                        else
                        {
                            counter.Add(name, 1);
                        }
                        if (item.Attribute("name") != null)
                        {
                            position = string.Format("[@name='{0}']", item.Attribute("name").Value);
                        }

                        string description = item.IndexAttributeValue();

                        xmlElements.Add(GetXmlNodeElement(entityToken.Source, string.Format("{0}/{1}{2}", xpath, name, position), name + (string.IsNullOrEmpty(description) ? string.Empty : string.Format("({0})", description))));
                    }

                    xmlElements.Sort((a, b) => string.Compare(a.VisualData.Label,
                                                              b.VisualData.Label,
                                                              StringComparison.InvariantCulture));

                    foreach (var e in xmlElements)
                    {
                        yield return(e);
                    }
                }

                if (element != null)
                {
                    var elementPath = Regex.Replace(xpath, @"\[[^\]]*\]$", "");
                    foreach (var attribute in element.Attributes())
                    {
                        string name = attribute.Name.ToString();
                        yield return(GetXmlAttributeElement(entityToken.Source, string.Format("{0}[@{1}='{2}']", elementPath, name, attribute.Value), string.Format("{0}={1}", name, attribute.Value)));
                    }
                }
            }
        }
Esempio n. 10
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);
        }