Exemplo n.º 1
0
 public async Task <bool> ExecuteAsync()
 {
     try
     {
         AkaMSLinkManager manager = new AkaMSLinkManager(ClientId, ClientSecret, Tenant, Log);
         await manager.DeleteLinksAsync(new List <string>(ShortUrls));
     }
     catch (Exception e)
     {
         Log.LogErrorFromException(e);
     }
     return(!Log.HasLoggedErrors);
 }
Exemplo n.º 2
0
        public async Task <bool> ExecuteAsync()
        {
            // Parse out the Links items.
            List <AkaMSLink> linksToCreate = new List <AkaMSLink>();

            foreach (var link in Links)
            {
                string shortUrl    = link.ItemSpec;
                string targetUrl   = link.GetMetadata(nameof(AkaMSLink.TargetUrl));
                string description = link.GetMetadata(nameof(AkaMSLink.Description));

                if (string.IsNullOrEmpty(shortUrl))
                {
                    Log.LogError($"Short url (ItemSpec) should not be empty");
                }

                if (string.IsNullOrEmpty(targetUrl))
                {
                    Log.LogError($"TargetUrl (metadata) should not be empty");
                }

                if (Log.HasLoggedErrors)
                {
                    return(false);
                }

                linksToCreate.Add(new AkaMSLink
                {
                    ShortUrl    = shortUrl,
                    TargetUrl   = targetUrl,
                    Description = description
                });
            }

            try
            {
                foreach (var link in linksToCreate)
                {
                    string descriptionString = !string.IsNullOrEmpty(link.Description) ? $" ({link.Description})" : "";
                    Log.LogMessage(MessageImportance.High, $"Creating link aka.ms/{link.ShortUrl} -> {link.TargetUrl}{descriptionString}");
                }
                AkaMSLinkManager manager = new AkaMSLinkManager(ClientId, ClientSecret, Tenant, Log);
                await manager.CreateOrUpdateLinksAsync(linksToCreate, Owners, CreatedBy, GroupOwner, Overwrite);
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
            }

            return(!Log.HasLoggedErrors);
        }
Exemplo n.º 3
0
 public LatestLinksManager(
     string akaMSClientId,
     string akaMSClientSecret,
     string akaMSTenant,
     string akaMSGroupOwner,
     string akaMSCreatedBy,
     string akaMsOwners,
     TaskLoggingHelper logger)
 {
     Logger            = logger;
     AkaMSClientId     = akaMSClientId;
     AkaMSClientSecret = akaMSClientSecret;
     AkaMSTenant       = akaMSTenant;
     AkaMSGroupOwner   = akaMSGroupOwner;
     AkaMSCreatedBy    = akaMSCreatedBy;
     AkaMsOwners       = akaMsOwners;
     LinkManager       = new AkaMSLinkManager(AkaMSClientId, AkaMSClientSecret, AkaMSTenant, Logger);
 }