C# 提示当前上下文中不存在名称Dcommission
落伍的鱼 2017-02-16 11:21:37 新手学习中,在money(string pid, int mall = 0)中引用double sdx(string pid)返回的值,提示当前上下文中不存在名称Dcommission,private string Dcommission; 定义之后并没有返回 key 。请帮忙看看是不是哪里写错了。
public string money(string pid, int mall = 0)
{
try
{
string url = Utility.FormatUrl(Resources.GyTbUrl).Replace("{pid}", pid);
if (mall == 1)
{
url = Utility.FormatUrl(Resources.GyTmUrl).Replace("{pid}", pid);
}
string jsondata = http.GetU(url);
string AuctionId = Utility.Get_Middle_Text(jsondata, "\"auctionId\":", ",");//商品ID
if (tkSpecialCampaignIdRateMap.Trim() != "null")
{
double Dcommission = sdx(pid); //返回比例
}
///提示当前上下文中不存在名称Dcommission
return "{\"auctionId\":\"" + AuctionId + "\",\"Dcommission\":\"" + Dcommission + "\"}";
}
catch (Exception ex)
{
return ex.ToString();
}
}
public double sdx(string pid)
{
try
{
string DxData = http.GetU(Utility.FormatUrl(Resources.DingxList).Replace("{pid}", pid));
int key = 0;
string CampaignID = null;
string ShopKeeperID = null;
Regex regex = new Regex(@"""commissionRate"":(.*?),""CampaignID"":(.*?),.*?""Exist"":(.*?),""manualAudit"":(.*?),""ShopKeeperID"":(.*?),");
if (regex.IsMatch(DxData))
{
MatchCollection matchCollection = regex.Matches(DxData);
foreach (Match match in matchCollection)
{
if (match.Groups[3].Value == "true")
{
runlog("PID:" + pid + " 已申请过");
key = Convert.ToInt32(Convert.ToDouble(match.Groups[1].Value.Trim()));
}
if (match.Groups[4].Value != "1") //排除手动审核
{
if (Convert.ToInt32(Convert.ToDouble(match.Groups[1].Value.Trim())) > key)
{
key = Convert.ToInt32(Convert.ToDouble(match.Groups[1].Value.Trim()));
CampaignID = match.Groups[2].Value;
ShopKeeperID = match.Groups[5].Value;
}
}
}
}
if (CampaignID == null) return 0;
string postDXstatus = http.GetU(Resources.postDX, Utility.FormatUrl(Resources.postDXdata).Replace("{CampaignID}", CampaignID).Replace("{ShopKeeperID}", ShopKeeperID).Replace("{applyreason}", applyreason));
if (postDXstatus.Contains("\"ok\":true"))
{
runlog("PID:" + pid + " 申请成功!");
return key;
}
else
{
runlog("PID:" + pid + " 申请失败" + postDXstatus);
return 0;
}
}
catch
{
return 0;
}
}