private string GetStorageUrl(string resourceGroupName, string accountName, string applicationId, string version, out bool didCreateAppPackage) { try { // Checks to see if the package exists ApplicationPackage response = BatchManagementClient.ApplicationPackage.Get( resourceGroupName, accountName, applicationId, version); didCreateAppPackage = false; return(response.StorageUrl); } catch (CloudException exception) { // If the application package is not found we want to create a new application package. if (exception.Response.StatusCode != HttpStatusCode.NotFound) { var message = string.Format(Resources.FailedToGetApplicationPackage, applicationId, version, exception.Message); throw new CloudException(message, exception); } } try { ApplicationPackage addResponse = BatchManagementClient.ApplicationPackage.Create( resourceGroupName, accountName, applicationId, version); // If Application was created we need to return a flag. didCreateAppPackage = true; return(addResponse.StorageUrl); } catch (Exception exception) { var message = string.Format(Resources.FailedToAddApplicationPackage, applicationId, version, exception.Message); throw new NewApplicationPackageException(message, exception); } }
/// <summary> /// Uploads an application package to Storage /// </summary> public static ApplicationPackage CreateApplicationPackage(BatchController controller, BatchAccountContext context, string applicationId, string version, string filePath) { ApplicationPackage applicationPackage = null; if (HttpMockServer.Mode == HttpRecorderMode.Record) { applicationPackage = controller.BatchManagementClient.ApplicationPackage.Create( context.ResourceGroupName, context.AccountName, applicationId, version); CloudBlockBlob blob = new CloudBlockBlob(new Uri(applicationPackage.StorageUrl)); #if NETSTANDARD Task.Run(() => blob.UploadFromFileAsync(filePath)).Wait(); #else blob.UploadFromFile(filePath, FileMode.Open); #endif } return(applicationPackage); }
private static PSApplicationPackage ConvertGetApplicationPackageResponseToApplicationPackage(ApplicationPackage response) { return new PSApplicationPackage { Format = response.Format, StorageUrl = response.StorageUrl, StorageUrlExpiry = response.StorageUrlExpiry, State = response.State.Value, Id = response.Id, Name = response.Name, LastActivationTime = response.LastActivationTime }; }
public static ApplicationViewModel GetApplicationViewModel(NodeType nodeType, string ID) { // Adding Application Details var vm = new ApplicationViewModel(); try { using (_certonaService = new CertonaServiceClient()) { try { UserDTO user = FormsAuthenticationWrapper.User; var appDetailResponse = new GetApplicationDetailsResponse(); var appDetailRequest = new GetApplicationDetailsRequest { ApplicationID = ID, User = user }; appDetailResponse = _certonaService.GetApplicationDetails(appDetailRequest); var applicationDetails = new ApplicationDetails { Name = appDetailResponse.ApplicationDetails.Name, Description = appDetailResponse.ApplicationDetails.Description, ApplicationID = ID, URL = appDetailResponse.ApplicationDetails.ApplicationURL, Classifications = appDetailResponse.ApplicationDetails.Classifications }; vm.ApplicationDetails = applicationDetails; // Adding Manage Locations var appPackagesRequest = new GetApplicationPackagesRequest { ApplicationID = ID, User = user }; var appPackagesResponse = _certonaService.GetApplicationPackages(appPackagesRequest); List <ApplicationPackage> appPackageList = new List <ApplicationPackage>(); if (appPackagesResponse.ApplicationPackages.Count > 0) { foreach (var appPackage in appPackagesResponse.ApplicationPackages) { ApplicationPackage pkg = new ApplicationPackage { PackageId = appPackage.PackageId, PackageName = appPackage.PackageName, Status = appPackage.Status, Type = appPackage.PackageType, Description = appPackage.Description, SubType = appPackage.SubType }; appPackageList.Add(pkg); } } vm.ApplicationPackages = appPackageList; // Remarketing Campaigns var campaignSummaryRequest = new GetApplicationRemarketingCampaignsRequest() { ApplicationID = ID, StatusFilter = "All", User = user }; var campaignSummaryResponse = _certonaService.GetApplicationRemarketingCampaigns(campaignSummaryRequest); vm.ApplicationRemarketingCampaigns = new ApplicationRemarketingCampaigns(); if (campaignSummaryResponse.RemarketingCampaigns.Count > 0) { vm.ApplicationRemarketingCampaigns.RemarketingCampaigns = new List <RemarketingCampaignSummaryDTO>(); foreach (var campaign in campaignSummaryResponse.RemarketingCampaigns) { vm.ApplicationRemarketingCampaigns.RemarketingCampaigns.Add(new RemarketingCampaignSummaryDTO() { RemarketingCampaignId = campaign.RemarketingCampaignId, Name = campaign.Name, Status = campaign.Status, LastModified = campaign.LastModified, LastSent = campaign.LastSent, NextScheduled = campaign.NextScheduled }); } } // Frequency Caps var freqCap = GetFrequencyCap(ID, user); if (freqCap != null) { vm.ApplicationRemarketingCampaigns.FrequencyCapEnabled = freqCap.Enabled; vm.ApplicationRemarketingCampaigns.FrequencyCapDays = freqCap.FrequencyCapDays; vm.ApplicationRemarketingCampaigns.FrequencyCapEmails = freqCap.FrequencyCapEmails; } } catch (TimeoutException exception) { _certonaService.Abort(); throw; } catch (CommunicationException exception) { _certonaService.Abort(); throw; } } } catch (Exception ex) { throw; } return(vm); }
private PSApplicationPackage ConvertGetApplicationPackageResponseToApplicationPackage(ApplicationPackage response) { return(new PSApplicationPackage() { Format = response.Format, StorageUrl = response.StorageUrl, StorageUrlExpiry = response.StorageUrlExpiry.Value, State = response.State.Value, Id = response.Id, Version = response.Version, LastActivationTime = response.LastActivationTime, }); }