Exemple #1
0
        IExplorerItem SaveResource(Guid resourceId, string newPath, string newResourceName)
        {
            var result      = _resourceCatalog.GetResourceContents(GlobalConstants.ServerWorkspaceID, resourceId);
            var xElement    = result.ToXElement();
            var newResource = new Resource(xElement)
            {
                IsUpgraded = true
            };
            var resource = _resourceCatalog.GetResources(GlobalConstants.ServerWorkspaceID)
                           .FirstOrDefault(p => p.ResourceID == resourceId);
            var actionElement = xElement.Element("Action");
            var xamlElement   = actionElement?.Element("XamlDefinition");

            xElement.SetAttributeValue("Name", newResourceName);
            var resourceID = Guid.NewGuid();

            newResource.ResourceName = newResourceName;
            newResource.ResourceID   = resourceID;
            xElement.SetElementValue("DisplayName", newResourceName);
            if (xamlElement != null)
            {
                var xamlContent = xamlElement.Value;
                xamlElement.Value = xamlContent.
                                    Replace("x:Class=\"" + resource?.ResourceName + "\"", "x:Class=\"" + newResourceName + "\"")
                                    .Replace("Flowchart DisplayName=\"" + resource?.ResourceName + "\"", "Flowchart DisplayName=\"" + newResourceName + "\"");
            }
            var fixedResource = xElement.ToStringBuilder();

            _resourceCatalog.SaveResource(GlobalConstants.ServerWorkspaceID, newResource, fixedResource, newPath);
            SaveTests(resourceId, resourceID);
            return(ServerExplorerRepository.Instance.UpdateItem(newResource));
        }
Exemple #2
0
        // POST: Service/Services/Save
        public string Save(string args, Guid workspaceId, Guid dataListId)
        {
            try
            {
                var service   = DeserializeService(args);
                var dbService = service as DbService;
                if (dbService != null)
                {
                    var source = _resourceCatalog.GetResource <DbSource>(workspaceId, dbService.Source.ResourceID);
                    if (source.ServerType == enSourceType.MySqlDatabase)
                    {
                        var broker = new MySqlDatabaseBroker();
                        broker.UpdateServiceOutParameters(dbService, source);
                    }
                }
                _resourceCatalog.SaveResource(workspaceId, service);

                if (workspaceId != GlobalConstants.ServerWorkspaceID)
                {
                    _resourceCatalog.SaveResource(GlobalConstants.ServerWorkspaceID, service);
                }

                return(service.ToString());
            }
            catch (Exception ex)
            {
                RaiseError(ex);
                return(new ValidationResult {
                    IsValid = false, ErrorMessage = ex.Message
                }.ToString());
            }
        }
Exemple #3
0
        // POST: Service/EmailSources/Save
        public string Save(string args, Guid workspaceId, Guid dataListId)
        {
            try
            {
                var source = JsonConvert.DeserializeObject <EmailSource>(args);

                _resourceCatalog.SaveResource(workspaceId, source);
                if (workspaceId != GlobalConstants.ServerWorkspaceID)
                {
                    _resourceCatalog.SaveResource(GlobalConstants.ServerWorkspaceID, source);
                }

                return(source.ToString());
            }
            catch (Exception ex)
            {
                RaiseError(ex);
                return(new ValidationResult {
                    IsValid = false, ErrorMessage = ex.Message
                }.ToString());
            }
        }
        public IRollbackResult RollbackTo(Guid resourceId, string versionNumber)
        {
            var      res         = _catalogue.GetResource(Guid.Empty, resourceId);
            var      xmlBuilder  = GetVersion(new VersionInfo(DateTime.MinValue, "", "", versionNumber, resourceId, res.VersionInfo.VersionId));
            var      xml         = xmlBuilder.ToXElement();
            Resource oldResource = new Resource(xml);

            UpdateCategoryIfRenamed(res, oldResource, xml);
            StoreAndDeleteCurrentIfRenamed(res, oldResource);
            UpdateVersionInfoIfNotExists(resourceId, xml, res);
            _catalogue.SaveResource(Guid.Empty, xml.ToStringBuilder(), null, "Rollback", "Unknown");
            if (oldResource.ResourceName != res.ResourceName)
            {
                _catalogue.GetResource(Guid.Empty, res.ResourceID).ResourceName = oldResource.ResourceName;
            }
            return(new RollbackResult {
                DisplayName = oldResource.ResourceName, VersionHistory = GetVersions(resourceId)
            });
        }