本文整理汇总了C#中Test.List.Any方法的典型用法代码示例。如果您正苦于以下问题:C# Test.List.Any方法的具体用法?C# Test.List.Any怎么用?C# Test.List.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test.List
的用法示例。
在下文中一共展示了Test.List.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// The first two calls handle the error redirect from MyMav asking for cookies. The rest basically emulate the post requests
/// from MyMav and you can use FireBug in FireFox to analyze any of MyMavs request and see how these are put together. One thing to note
/// is that the ICIS code is the most important part as it is how the MyMav ties your session together
/// </summary>
public void Execute()
{
string errorPage = "https://sis-cs-prod.uta.edu/psc/ACSPRD/EMPLOYEE/PSFT_ACS/c/COMMUNITY_ACCESS.CLASS_SEARCH.GBL?&";
request = (HttpWebRequest)WebRequest.Create(errorPage);
request.CookieContainer = cc;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
response = (HttpWebResponse)request.GetResponse();
string searchPage = "https://sis-cs-prod.uta.edu/psc/ACSPRD/EMPLOYEE/PSFT_ACS/c/COMMUNITY_ACCESS.CLASS_SEARCH.GBL?&";
request = (HttpWebRequest)WebRequest.Create(searchPage);
request.CookieContainer = cc;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
response = (HttpWebResponse)request.GetResponse();
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
html = sr.ReadToEnd();
}
var document = new HtmlDocument();
document.LoadHtml(html);
var getSemesterList = "https://sis-cs-prod.uta.edu/psc/ACSPRD/EMPLOYEE/PSFT_ACS/c/COMMUNITY_ACCESS.CLASS_SEARCH.GBL";
var getSemesterListParameters = new Dictionary<string, string>()
{
{"CLASS_SRCH_WRK2_STRM$273$", document.GetElementbyId("CLASS_SRCH_WRK2_STRM$273$").InnerText},
{"FacetPath", document.GetElementbyId("FacetPath") != null ? document.GetElementbyId("FacetPath").GetAttributeValue("value","") : "None"},
{"ICAJAX","1"},
{"ACAPPCLSDATA",document.GetElementbyId("ICAPPCLSDATA") != null ? document.GetElementbyId("ICAPPCLSDATA").GetAttributeValue("value","") : ""},
{"ICAction", "CLASS_SRCH_WRK2_STRM$273$$prompt"},
{"ICActionPrompt", document.GetElementbyId("ICActionPrompt") != null ? document.GetElementbyId("ICActionPrompt").GetAttributeValue("value","") : "false"},
{"ICAddCount", document.GetElementbyId("ICAddCount") != null ? document.GetElementbyId("ICAddCount").GetAttributeValue("value","") : ""},
{"ICChanged", document.GetElementbyId("ICChanged") != null ? document.GetElementbyId("ICChanged").GetAttributeValue("value","") : "-1"},
{"ICElementNum", document.GetElementbyId("ICElementNum") != null ? document.GetElementbyId("ICElementNum").GetAttributeValue("value","") : "0"},
{"ICFind", document.GetElementbyId("ICFind") != null ? document.GetElementbyId("ICFind").GetAttributeValue("value","") : ""},
{"ICFocus", ""},
{"ICNAVTYPEDROPDOWN", "0"},
{"ICResubmit", document.GetElementbyId("ICResubmit")!= null ? document.GetElementbyId("ICResubmit").GetAttributeValue("value","") : "0"},
{"ICSID", document.GetElementbyId("ICSID") != null ? document.GetElementbyId("ICSID").GetAttributeValue("value","") : ""},
{"ICSaveWarningFilter",document.GetElementbyId("ICSaveWarningFilter") != null ? document.GetElementbyId("ICSaveWarningFilter").GetAttributeValue("value","") : "0"},
{"ICStateNum",document.GetElementbyId("ICStateNum") != null ? document.GetElementbyId("ICStateNum").GetAttributeValue("value","") : ""},
{"ICType", document.GetElementbyId("ICType") != null ? document.GetElementbyId("ICType").GetAttributeValue("value","") : "Panel"},
{"ICXPos", document.GetElementbyId("ICXPos") != null ? document.GetElementbyId("ICXPos").GetAttributeValue("value","") : "0"},
{"ICYPos", document.GetElementbyId("ICYPos") != null ? document.GetElementbyId("ICYPos").GetAttributeValue("value","") : "0"},
{"ResponseToDiffFrame", document.GetElementbyId("ResponsetoDiffFrame") != null ? document.GetElementbyId("ResponsetoDiffFrame").GetAttributeValue("value","") : "-1"},
{"TargetFrameName",document.GetElementbyId("TargetFrameName") != null ? document.GetElementbyId("TargetFrameName").GetAttributeValue("value","") : "None"},
};
foreach (var key in getSemesterListParameters.Keys)
{
sb.Append(key + "=" + getSemesterListParameters[key] + "&");
}
sb.Remove(sb.Length - 1, 1);
request = (HttpWebRequest)WebRequest.Create(getSemesterList);
request.Method = WebRequestMethods.Http.Post;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
request.AllowWriteStreamBuffering = true;
request.ProtocolVersion = HttpVersion.Version11;
request.AllowAutoRedirect = true;
request.ContentType = "application/x-www-form-urlencoded";
request.CookieContainer = cc;
byteArray = Encoding.ASCII.GetBytes(sb.ToString());
request.ContentLength = byteArray.Length;
requestStream = request.GetRequestStream();
requestStream.Write(byteArray, 0, byteArray.Length);
requestStream.Close();
response = (HttpWebResponse)request.GetResponse();
html = "";
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
html = sr.ReadToEnd();
var tempy = html;
}
document.LoadHtml(html);
var semesterNodes = new List<string>();
HtmlNode node = document.GetElementbyId("SEARCH_RESULT1");
int i = 1;
while (node != null)
{
semesterNodes.Add(node.InnerText);
node = document.GetElementbyId("RESULT0$" + i);
i++;
}
node = document.GetElementbyId("SEARCH_RESULTLAST");
if (node != null)
semesterNodes.Add(node.InnerText);
if(!semesterNodes.Any())
{
getSemesterList = "https://sis-cs-prod.uta.edu/psc/ACSPRD/EMPLOYEE/PSFT_ACS/c/COMMUNITY_ACCESS.CLASS_SEARCH.GBL";
getSemesterListParameters = new Dictionary<string, string>()
{
//.........这里部分代码省略.........
示例2: Execute
//.........这里部分代码省略.........
requestStream = request.GetRequestStream();
requestStream.Write(byteArray, 0, byteArray.Length);
requestStream.Close();
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
System.Threading.Thread.Sleep(10000);
response = (HttpWebResponse)request.GetResponse();
}
html = "";
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
html = sr.ReadToEnd();
var tempy = html;
}
document.LoadHtml(html);
var semesterNodes = new List<string>();
HtmlNode node = document.GetElementbyId("SEARCH_RESULT1");
int i = 1;
while (node != null)
{
semesterNodes.Add(node.InnerText);
node = document.GetElementbyId("RESULT0$" + i);
i++;
}
node = document.GetElementbyId("SEARCH_RESULTLAST");
if (node != null)
semesterNodes.Add(node.InnerText);
if (!semesterNodes.Any())
{
getSemesterList = "https://sis-cs-prod.uta.edu/psc/ACSPRD/EMPLOYEE/PSFT_ACS/c/COMMUNITY_ACCESS.CLASS_SEARCH.GBL";
getSemesterListParameters = new Dictionary<string, string>()
{
{"CLASS_SRCH_WRK2_STRM$273$", document.GetElementbyId("CLASS_SRCH_WRK2_STRM$273$").InnerText},
{"FacetPath", document.GetElementbyId("FacetPath") != null ? document.GetElementbyId("FacetPath").GetAttributeValue("value","") : "None"},
{"ICAJAX","1"},
{"ACAPPCLSDATA",document.GetElementbyId("ICAPPCLSDATA") != null ? document.GetElementbyId("ICAPPCLSDATA").GetAttributeValue("value","") : ""},
{"ICAction", "CLASS_SRCH_WRK2_STRM$273$$prompt"},
{"ICActionPrompt", document.GetElementbyId("ICActionPrompt") != null ? document.GetElementbyId("ICActionPrompt").GetAttributeValue("value","") : "false"},
{"ICAddCount", document.GetElementbyId("ICAddCount") != null ? document.GetElementbyId("ICAddCount").GetAttributeValue("value","") : ""},
{"ICChanged", document.GetElementbyId("ICChanged") != null ? document.GetElementbyId("ICChanged").GetAttributeValue("value","") : "-1"},
{"ICElementNum", document.GetElementbyId("ICElementNum") != null ? document.GetElementbyId("ICElementNum").GetAttributeValue("value","") : "0"},
{"ICFind", document.GetElementbyId("ICFind") != null ? document.GetElementbyId("ICFind").GetAttributeValue("value","") : ""},
{"ICFocus", ""},
{"ICNAVTYPEDROPDOWN", "0"},
{"ICResubmit", document.GetElementbyId("ICResubmit")!= null ? document.GetElementbyId("ICResubmit").GetAttributeValue("value","") : "0"},
{"ICSID", document.GetElementbyId("ICSID") != null ? document.GetElementbyId("ICSID").GetAttributeValue("value","") : ""},
{"ICSaveWarningFilter",document.GetElementbyId("ICSaveWarningFilter") != null ? document.GetElementbyId("ICSaveWarningFilter").GetAttributeValue("value","") : "0"},
{"ICStateNum",document.GetElementbyId("ICStateNum") != null ? document.GetElementbyId("ICStateNum").GetAttributeValue("value","") : ""},
{"ICType", document.GetElementbyId("ICType") != null ? document.GetElementbyId("ICType").GetAttributeValue("value","") : "Panel"},
{"ICXPos", document.GetElementbyId("ICXPos") != null ? document.GetElementbyId("ICXPos").GetAttributeValue("value","") : "0"},
{"ICYPos", document.GetElementbyId("ICYPos") != null ? document.GetElementbyId("ICYPos").GetAttributeValue("value","") : "0"},
{"ResponseToDiffFrame", document.GetElementbyId("ResponsetoDiffFrame") != null ? document.GetElementbyId("ResponsetoDiffFrame").GetAttributeValue("value","") : "-1"},
{"TargetFrameName",document.GetElementbyId("TargetFrameName") != null ? document.GetElementbyId("TargetFrameName").GetAttributeValue("value","") : "None"},
};
foreach (var key in getSemesterListParameters.Keys)
{
sb.Append(key + "=" + getSemesterListParameters[key] + "&");
}
sb.Remove(sb.Length - 1, 1);