示例#1
0
        public SingleCloudDiskCapacityModel GetCloudDiskCapacityInfo()
        {
            SortedDictionary <string, string> ParamList = getParamList();
            string SourceString = GetApiSourceString(this.account_infoUrl, ParamList);
            string SecretKey    = GetSecretKey();
            string Sign         = GetSignature(SourceString, SecretKey);

            ParamList.Add("oauth_signature", Sign);
            string  URL        = this.account_infoUrl + "?" + ParamToUrl(ParamList, false);
            object  jsonAccess = GetGeneralContent(URL);
            XmlNode node       = JsonHelper.DeserializeToXmlNode(jsonAccess.ToString());
            SingleCloudDiskCapacityModel fileInfo = new SingleCloudDiskCapacityModel();

            fileInfo.TotalByte = Convert.ToDouble(node.ChildNodes[0].SelectSingleNode("quota_total").InnerText);
            var used = Convert.ToDouble(node.ChildNodes[0].SelectSingleNode("quota_used").InnerText);

            fileInfo.TotalAvailableByte = fileInfo.TotalByte - used;
            return(fileInfo);
        }
示例#2
0
        public SingleCloudDiskCapacityModel GetCloudDiskCapacityInfo()
        {
            /*
             * string url = "https://pcs.baidu.com/rest/2.0/pcs/quota";
             * string para = "?method=info&access_token=" + _accessToken;
             * SingleCloudDiskCapacityModel m = new SingleCloudDiskCapacityModel();
             * WebRequestHelper helper = new WebRequestHelper(url);
             * var result = helper.Get(url + para);
             * XmlNode node = JsonHelper.DeserializeToXmlNode(result);
             * m.TotalByte = Convert.ToDouble(node.ChildNodes[0].SelectSingleNode("quota").InnerText);
             * var comsumed = Convert.ToDouble(node.ChildNodes[0].SelectSingleNode("used").InnerText);
             * m.TotalAvailableByte = m.TotalByte - comsumed;
             * return m;*/
            string url     = "http://bcs.duapp.com/?";
            string flag    = "MBO";
            string para    = "sign=" + flag + ":" + _appKey + ":";
            string content = flag + "\n"
                             + "Method=GET" + "\n"
                             + "Bucket=" + "\n"
                             + "Object=/" + "\n";
            string sign = BaiduSignatureHelper.GetSignature(content, _appSecret);

            para = para + sign;
            WebRequestHelper helper = new WebRequestHelper(url);
            var result = helper.Get(url + para);
            List <BaiduBucketInfo>       info = JsonHelper.DeserializeObject <List <BaiduBucketInfo> >(result);
            SingleCloudDiskCapacityModel m    = new SingleCloudDiskCapacityModel();

            if (info != null)
            {
                foreach (BaiduBucketInfo one in info)
                {
                    if (one.bucket_name == _bucketName)
                    {
                        m.TotalByte = Convert.ToDouble(info[0].total_capacity);
                        var comsumed = Convert.ToDouble(info[0].used_capacity);
                        m.TotalAvailableByte = m.TotalByte - comsumed;
                    }
                }
            }

            return(m);
        }
示例#3
0
 public Model.CloudDisk.SingleCloudDiskCapacityModel GetCloudDiskCapacityInfo()
 {
     try
     {
         string url = "https://api.weipan.cn/2/account/info";
         SingleCloudDiskCapacityModel m      = new SingleCloudDiskCapacityModel();
         WebRequestHelper             helper = new WebRequestHelper(url);
         var     result = helper.Get(url + "?access_token=" + _accessToken);
         XmlNode node   = JsonHelper.DeserializeToXmlNode(result);
         m.TotalByte = Convert.ToDouble(node.ChildNodes[0].SelectSingleNode("quota_info").SelectSingleNode("quota").InnerText);
         var comsumed = Convert.ToDouble(node.ChildNodes[0].SelectSingleNode("quota_info").SelectSingleNode("consumed").InnerText);
         m.TotalAvailableByte = m.TotalByte - comsumed;
         return(m);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }