/// <summary> /// 文件预取 /// </summary> /// <param name="request"></param> /// <returns></returns> public PrefetchResult Prefetch(PrefetchRequest request) { PrefetchResult result = new PrefetchResult(); string url = prefetchUrl(); string body = request.ToJsonStr(); byte[] data = Encoding.UTF8.GetBytes(body); string token = Auth.createManageToken(url, null, mac); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Authorization", token); httpMgr.postData(url, headers, data, HttpManager.FORM_MIME_JSON, new CompletionHandler(delegate(ResponseInfo respInfo, string respJson) { if (respInfo.StatusCode != 200) { Console.WriteLine(respInfo); } result = JsonConvert.DeserializeObject <PrefetchResult>(respJson); })); return(result); }
public void Build_ReturnDeliveryRequest() { var context = new Mock <Context>().Object; var execute = new ExecuteRequest(); var prefetch = new PrefetchRequest(); var notifications = new List <Notification>(); var customerIds = new List <CustomerId>(); var property = new Property("testToken"); var telemetry = new Telemetry(); var trace = new Trace("testAuthToken"); var expCloud = new ExperienceCloud(); var qaMode = new QAMode(); var request = new TargetDeliveryRequest.Builder() .SetTntId(tntId) .SetMarketingCloudVisitorId(marketingCloudVisitorId) .SetThirdPartyId(thirdPartyId) .SetContext(context) .SetExecute(execute) .SetPrefetch(prefetch) .SetNotifications(notifications) .SetProperty(property) .SetTelemetry(telemetry) .SetTrace(trace) .SetExperienceCloud(expCloud) .SetEnvironmentId(environmentId) .SetImpressionId(impressionId) .SetQaMode(qaMode) .SetLocationHint(locationHint) .SetRequestId(requestId) .SetSessionId(sessionId) .SetTargetCustomerIds(customerIds) .SetDecisioningMethod(DecisioningMethod.Hybrid) .Build(); Assert.Equal(tntId, request.DeliveryRequest.Id.TntId); Assert.Equal(marketingCloudVisitorId, request.DeliveryRequest.Id.MarketingCloudVisitorId); Assert.Equal(thirdPartyId, request.DeliveryRequest.Id.ThirdPartyId); Assert.Equal(customerIds, request.DeliveryRequest.Id.CustomerIds); Assert.Equal(context, request.DeliveryRequest.Context); Assert.Equal(execute, request.DeliveryRequest.Execute); Assert.Equal(prefetch, request.DeliveryRequest.Prefetch); Assert.Equal(notifications, request.DeliveryRequest.Notifications); Assert.Equal(property, request.DeliveryRequest.Property); Assert.Equal(telemetry, request.DeliveryRequest.Telemetry); Assert.Equal(trace, request.DeliveryRequest.Trace); Assert.Equal(expCloud, request.DeliveryRequest.ExperienceCloud); Assert.Equal(qaMode, request.DeliveryRequest.QaMode); Assert.Equal(environmentId, request.DeliveryRequest.EnvironmentId); Assert.Equal(impressionId, request.DeliveryRequest.ImpressionId); Assert.Equal(requestId, request.DeliveryRequest.RequestId); Assert.Equal(locationHint, request.LocationHint); Assert.Equal(sessionId, request.SessionId); Assert.Equal(DecisioningMethod.Hybrid, request.DecisioningMethod); }
/// <summary> /// 文件预取 /// </summary> public static void prefetch() { Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey); FusionManager fusionMgr = new FusionManager(mac); string[] urls = new string[] { "URL1", "URL2" }; PrefetchRequest request = new PrefetchRequest(urls); PrefetchResult result = fusionMgr.Prefetch(request); Console.WriteLine(result); }
/// <summary> /// 文件预取 /// </summary> public static void cdnPrefetch() { Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey); CdnManager fusionMgr = new CdnManager(mac); string[] urls = new string[] { "http://yourdomain.clouddn.com/somefile.php" }; PrefetchRequest request = new PrefetchRequest(urls); PrefetchResult result = fusionMgr.PrefetchUrls(request); Console.WriteLine(result); }
private void Button_FusionPrefetchUrls_Click(object sender, RoutedEventArgs e) { if (prefetchUrls.Count < 1) { TextBox_FusionPrefetchUrlsResultText.Text = "请添加URL"; return; } if (!TryInit()) { return; } string rURLs = TextBox_FusionPrefetchURLs.Text.Trim(); PrefetchRequest request = new PrefetchRequest(); request.AddUrls(rURLs.Split(';')); var result = cdnManager.PrefetchUrls(request); TextBox_FusionPrefetchUrlsResultText.Text = result.Text; TextBox_FusionPrefetchUrlsResultString.Text = result.ToString(); }