Exemple #1
0
        /// <summary>
        /// 缓存刷新
        /// </summary>
        public static void refresh()
        {
            Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
            FusionManager fusionMgr = new FusionManager(mac);

            string[] urls = new string[] { "URL1", "URL2" };
            string[] dirs = new string[] { "DIR1", "DIR2" };
            RefreshRequest request = new RefreshRequest();
            request.AddUrls(urls);
            request.AddDirs(dirs);
            RefreshResult result = fusionMgr.Refresh(request);
            Console.WriteLine(result);
        }
Exemple #2
0
        /// <summary>
        /// 缓存刷新
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public RefreshResult Refresh(RefreshRequest request)
        {
            RefreshResult result = new RefreshResult();

            string url = refreshUrl();
            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<RefreshResult>(respJson);
                }));

            return result;
        }