Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public static void UpdateResourceXml(IResourceCatalog resourceCatalog, Guid workspaceID, IResource effectedResource, IList <ICompileMessageTO> compileMessagesTO)
        {
            var resourceContents = resourceCatalog.GetResourceContents(workspaceID, effectedResource.ResourceID);

            UpdateXmlToDisk(effectedResource, compileMessagesTO, resourceContents);
            var serverResource = resourceCatalog.GetResource(Guid.Empty, effectedResource.ResourceName);

            if (serverResource != null)
            {
                resourceContents = resourceCatalog.GetResourceContents(Guid.Empty, serverResource.ResourceID);
                UpdateXmlToDisk(serverResource, compileMessagesTO, resourceContents);
            }
        }
Exemplo n.º 3
0
 public bool CopyResource(IResource resource, Guid targetWorkspaceID, string userRoles = null)
 {
     if (resource != null)
     {
         var copy           = new Resource(resource);
         var globalResource = _resourceCatalog.GetResource(Guid.Empty, resource.ResourceID);
         if (globalResource != null)
         {
             copy.VersionInfo = globalResource.VersionInfo;
         }
         var contents   = _resourceCatalog.GetResourceContents(resource);
         var saveResult = ((ResourceCatalog)_resourceCatalog).SaveImpl(targetWorkspaceID, copy, contents);
         return(saveResult.Status == ExecStatus.Success);
     }
     return(false);
 }
Exemplo n.º 4
0
        public IWebSource Get(string resourceId, Guid workspaceId)
        {
            var result = new WebSource();

            try
            {
                var xmlStr = _resourceCatalog.GetResourceContents(workspaceId, Guid.Parse(resourceId)).ToString();
                if (!string.IsNullOrEmpty(xmlStr))
                {
                    var xml = XElement.Parse(xmlStr);
                    result = new WebSource(xml);
                }
            }
            catch (Exception ex)
            {
                RaiseError(ex);
            }
            return(result);
        }
Exemplo n.º 5
0
        Connection GetConnection(Guid environmentId)
        {
            if (environmentId == Guid.Empty)
            {
                var localhostConnection = new Connection
                {
                    Address = EnvironmentVariables.WebServerUri,
                    AuthenticationType = AuthenticationType.Windows
                };
                return localhostConnection;
            }
            var xml = _resourceCatalog.GetResourceContents(GlobalConstants.ServerWorkspaceID, environmentId);

            if (xml == null || xml.Length == 0)
            {
                return null;
            }

            var xe = xml.ToXElement();
            return new Connection(xe);
        }
Exemplo n.º 6
0
        // POST: Service/Services/Get
        public Service Get(string args, Guid workspaceId, Guid dataListId)
        {
            ResourceType resourceType = ResourceType.Unknown;

            try
            {
                var webRequestPoco  = JsonConvert.DeserializeObject <WebRequestPoco>(args);
                var resourceTypeStr = webRequestPoco.ResourceType;
                resourceType = Resources.ParseResourceType(resourceTypeStr);
                var resourceId = webRequestPoco.ResourceId;
                var xmlStr     = _resourceCatalog.GetResourceContents(workspaceId, Guid.Parse(resourceId));

                if (xmlStr != null && xmlStr.Length != 0)
                {
                    return(DeserializeService(xmlStr.ToXElement(), resourceType));
                }
                return(GetDefaultService(resourceType));
            }
            catch (Exception ex)
            {
                RaiseError(ex);
                return(GetDefaultService(resourceType));
            }
        }
Exemplo n.º 7
0
        ResourceCatalogResult UpdateResourceName(Guid workspaceID, IResource resource, string newName, string resourcePath)
        {
            //rename where used
            RenameWhereUsed(_resourceCatalog.GetDependentsAsResourceForTrees(workspaceID, resource.ResourceID), workspaceID, resourcePath, newName);

            //rename resource
            var resourceContents = _resourceCatalog.GetResourceContents(workspaceID, resource.ResourceID);

            var resourceElement = resourceContents.ToXElement();
            //xml name attibute
            var    nameAttrib = resourceElement.Attribute("Name");
            string oldName    = null;

            if (nameAttrib == null)
            {
                resourceElement.Add(new XAttribute("Name", newName));
            }
            else
            {
                oldName = nameAttrib.Value;
                nameAttrib.SetValue(newName);
            }
            //xaml
            var actionElement = resourceElement.Element("Action");
            var xaml          = actionElement?.Element("XamlDefinition");

            xaml?.SetValue(xaml.Value
                           .Replace("x:Class=\"" + oldName, "x:Class=\"" + newName)
                           .Replace("ToolboxFriendlyName=\"" + oldName, "ToolboxFriendlyName=\"" + newName)
                           .Replace("DisplayName=\"" + oldName, "DisplayName=\"" + newName));
            //xml display name element
            var displayNameElement = resourceElement.Element("DisplayName");

            displayNameElement?.SetValue(newName);

            //delete old resource in local workspace without updating dependants with compile messages
            lock (Common.GetFileLock(resource.FilePath))
            {
                if (_dev2FileWrapper.Exists(resource.FilePath))
                {
                    lock (Common.GetFileLock(resource.FilePath))
                    {
                        _dev2FileWrapper.Delete(resource.FilePath);
                    }
                }
            }

            var resPath = resource.GetResourcePath(workspaceID);

            var savePath          = resPath;
            var resourceNameIndex = resPath.LastIndexOf(resource.ResourceName, StringComparison.InvariantCultureIgnoreCase);

            if (resourceNameIndex >= 0)
            {
                savePath = resPath.Substring(0, resourceNameIndex);
            }
            resource.ResourceName = newName;
            var contents = resourceElement.ToStringBuilder();

            return(((ResourceCatalog)_resourceCatalog).SaveImpl(workspaceID, resource, contents, savePath));
        }