コード例 #1
0
        private List <DuplicateResourceTO> DuplicateAndSaveResources(string sourceLocation, string destFolderPath, List <IResource> resourcesToMove)
        {
            var resourceMaps = new List <DuplicateResourceTO>();

            foreach (var oldResource in resourcesToMove)
            {
                try
                {
                    string savePath  = CalculateResourceSavePath(sourceLocation, destFolderPath, oldResource.ResourceName, oldResource);
                    var    itemToAdd = GenerateItemToAdd(savePath);
                    ServerExplorerRepository.Instance.AddItem(itemToAdd, GlobalConstants.ServerWorkspaceID);

                    var result      = _resourceCatalog.GetResourceContents(GlobalConstants.ServerWorkspaceID, oldResource.ResourceID);
                    var xElement    = result.ToXElement();
                    var newResource = DuplicateResource(xElement);

                    resourceMaps.Add(
                        new DuplicateResourceTO
                    {
                        OldResourceID    = oldResource.ResourceID,
                        NewResource      = newResource,
                        DestinationPath  = savePath,
                        ResourceContents = xElement.ToStringBuilder()
                    });
                }
                catch (Exception e)
                {
                    Dev2Logger.Error(e.Message, e, GlobalConstants.WarewolfError);
                }
            }

            _resourceCatalog.SaveResources(GlobalConstants.ServerWorkspaceID, resourceMaps, overrideExisting: true);
            return(resourceMaps);
        }