Пример #1
0
        public object Get(GetPolicy request)
        {
            // Get the contract for the Policy by specifying the Policy address
            var contract = AppServices.web3.Eth.GetContract(AppModelConfig.POLICY.abi, AppServices.GetEcosystemAdr(request.ContractAdr).PolicyContractAdr);

            // PolicyListEntry entry = contract.GetFunction("get").CallDeserializingToObjectAsync<PolicyListEntry>(i).Result;
            // If no Policy hash has been provided as part of the request get the corresponding hash that belongs to the provided idx
            if (request.Hash.IsEmpty() == true)
            {
                request.Hash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync <byte[]>(request.Idx).Result);
            }

            // Retrieve the Policy details from the Blockchain
            PolicyDetail Policy = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <PolicyDetail>(request.Hash.HexToByteArray()).Result;

            // Set the Policy hash to the requested has as specified in the request
            Policy.Hash      = request.Hash;
            Policy.EventLogs = new List <PolicyEventLog>();

            // If Policy hash is set retrieve the logs for the Policy
            if (AppModelConfig.isEmptyHash(Policy.Hash) == false)
            {
                Policy.EventLogs = ((PolicyLogs)this.Get(
                                        new GetPolicyLogs {
                    ContractAdr = request.ContractAdr, Hash = request.Hash
                })).EventLogs;
                // Just for the Policy specific event logs reverse the order to have the events in ascending order
                Policy.EventLogs.Reverse();
            }

            // Return the Policy
            return(Policy);
        }
Пример #2
0
        /// <summary>
        /// 获得文件下载链接
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <returns></returns>
        public static string Download(string fileName)
        {
            string baseUrl    = GetPolicy.MakeBaseUrl(_domain, fileName);
            string privateUrl = GetPolicy.MakeRequest(baseUrl);

            return(privateUrl);
        }
Пример #3
0
        public void MakeRequestTest()
        {
            string  url    = GetPolicy.MakeBaseUrl("qiniuphotos.qiniudn.com", "gogopher.jpg");          // TODO: 初始化为适当的值
            string  actual = Exif.MakeRequest(url);
            ExifRet ret    = Exif.Call(actual);

            Assert.IsTrue(ret.OK, "MakeRequestTest Failure");
        }
Пример #4
0
        public void MakeRequestTest()
        {
            string actual;

            actual = GetPolicy.MakeRequest(FileOpUrl);
            //System.Diagnostics.Process.Start(actual);
            PrintLn(actual);
            Assert.IsTrue(!string.IsNullOrEmpty(actual), "GetPolicyTest MakeRequestTest Failure");
        }
Пример #5
0
        public void MakeBaseUrlTest()
        {
            string actual;

            actual = GetPolicy.MakeBaseUrl(Bucket + ".qiniudn.com", LocalKey);
            //System.Diagnostics.Process.Start(actual);
            PrintLn(actual);
            Assert.IsTrue(!string.IsNullOrEmpty(actual), "GetPolicyTest MakeBaseUrlTest Failure");
        }
Пример #6
0
        public void MakeRequestTest()
        {
            string actual;

            FileOpUrl = "http://private-res.qiniudn.com/gogopher.jpg??download/avialkjdf" + StringEx.ToUrlEncode("橛苛要工苛");

            actual = GetPolicy.MakeRequest(FileOpUrl);
            //System.Diagnostics.Process.Start(actual);
            PrintLn(actual);
            Assert.IsTrue(!string.IsNullOrEmpty(actual), "GetPolicyTest MakeRequestTest Failure");
        }
Пример #7
0
        public static void download()
        {
            //设置需要操作的账号的AK和SK
            Qiniu.Conf.Config.ACCESS_KEY = "Access_Key";
            Qiniu.Conf.Config.SECRET_KEY = "Secret_Key";
            //构造私有空间的需要生成的下载的链接
            string baseUrl = "http://bucketdomain/key";
            //调用MakeRequest方法生成私有下载链接
            string private_url = GetPolicy.MakeRequest(baseUrl);

            Console.WriteLine(private_url);
            Console.ReadLine();
        }
Пример #8
0
        /// <summary>
        ///MakeRequest 的测试
        ///</summary>
        //[Test]
        public void MakeRequestTest()
        {
            string           imageUrl = "http://www.b1.qiniudn.com/images/logo-2.png";                  // TODO: 初始化为适当的值
            int              dissolve = 50;                                                             // TODO: 初始化为适当的值
            ImageWaterMarker target   = new ImageWaterMarker(imageUrl, dissolve, MarkerGravity.Center); // TODO: 初始化为适当的值
            string           actual;

            actual = target.MakeRequest(FileOpUrl);
            // 如果是私有空间,添加下面一句
            actual = GetPolicy.MakeRequest(actual);
            //System.Diagnostics.Process.Start(actual);
            PrintLn(actual);
            Assert.IsTrue(!string.IsNullOrEmpty(actual), "ImageWaterMarkerTest MakeRequestTest Failure");
        }
Пример #9
0
        public async Task MakeRequestTest()
#endif
        {
            string url    = GetPolicy.MakeBaseUrl("qiniuphotos.qiniudn.com", "gogopher.jpg");           // TODO: 初始化为适当的值
            string actual = Exif.MakeRequest(url);

#if NET20 || NET40
            ExifRet ret = Exif.Call(actual);
            Assert.IsTrue(ret.OK, "MakeRequestTest Failure");
#else
            ExifRet ret = await Exif.CallAsync(actual);

            Assert.True(ret.OK, "MakeRequestTest Failure");
#endif
        }
Пример #10
0
        public void MakeRequestTest()
        {
            string          text     = "Qiniu";                                                                                     // TODO: 初始化为适当的值
            string          fontname = string.Empty;                                                                                // TODO: 初始化为适当的值
            string          color    = "#123abc";                                                                                   // TODO: 初始化为适当的值
            int             fontsize = 2000;                                                                                        // TODO: 初始化为适当的值
            int             dissolve = 50;                                                                                          // TODO: 初始化为适当的值
            int             dx       = 0;                                                                                           // TODO: 初始化为适当的值
            int             dy       = 0;                                                                                           // TODO: 初始化为适当的值
            TextWaterMarker target   = new TextWaterMarker(text, fontname, color, fontsize, dissolve, MarkerGravity.South, dx, dy); // TODO: 初始化为适当的值

            string actual;

            actual = target.MakeRequest(FileOpUrl);
            // 如果是私有空间,添加下面一句
            actual = GetPolicy.MakeRequest(actual);
            //System.Diagnostics.Process.Start(actual);
            PrintLn(actual);
            Assert.IsTrue(!string.IsNullOrEmpty(actual), "TextWaterMarkerTest MakeRequestTest Failure");
        }
Пример #11
0
        public string GetDownloadUrl(string fileKey, string type = "image")
        {
            string bucket;
            string domain;

            GetTokenAndDomain(type, out bucket, out domain);
            if (type == "video")
            {
                if (string.IsNullOrWhiteSpace(fileKey))
                {
                    return(string.Empty);
                }
                string baseUrl    = GetPolicy.MakeBaseUrl(domain, fileKey);
                string privateUrl = GetPolicy.MakeRequest(baseUrl);
                return(privateUrl);
            }
            else
            {
                return(string.Format("http://{0}/{1}", domain, fileKey));
            }
        }
Пример #12
0
 /// <summary>
 /// 获得url地址
 /// </summary>
 /// <returns></returns>
 public static string GetUrl(string key)
 {
     return(GetPolicy.MakeBaseUrl(Url, key));
 }
Пример #13
0
        /// <summary>
        /// 获取下载连接
        /// </summary>
        /// <returns></returns>
        public static string MakeGetToken()
        {
            string baseUrl = GetPolicy.MakeBaseUrl(domain, key);

            return(GetPolicy.MakeRequest(baseUrl));
        }
Пример #14
0
        public static string GetDownloadUrl(string domain, string bucket_name, string key)
        {
            string format = GetPolicy.MakeBaseUrl(domain, key);

            return(string.Format(format, bucket_name));
        }
Пример #15
0
        public static string GetDownloadUrlWithToken(string domain, string bucket_name, string key)
        {
            string baseUrl = string.Format(GetPolicy.MakeBaseUrl(domain, key), bucket_name);

            return(GetPolicy.MakeRequest(baseUrl, 3600u, null));
        }
Пример #16
0
        public static string GetPublicThumbUrl(string domain, string bucket_name, string key)
        {
            string format = GetPolicy.MakeBaseUrl(domain, key) + "?imageView2/1/w/50/h/50/q/75";

            return(string.Format(format, bucket_name));
        }
Пример #17
0
        public static string GetPrivateThumbUrl(string domain, string bucket_name, string key)
        {
            string baseUrl = string.Format(GetPolicy.MakeBaseUrl(domain, key), bucket_name) + "?imageView2/1/w/50/h/50/q/75";

            return(GetPolicy.MakeRequest(baseUrl, 3600u, null));
        }
Пример #18
0
        public Task <Policy> GetPolicy(string PolicyNumber)
        {
            var obj = new GetPolicy(PolicyNumber);

            return(obj.ExecuteReaderAsync());
        }