本文整理汇总了C#中OpenTween.TabClass.GetSearchPage方法的典型用法代码示例。如果您正苦于以下问题:C# TabClass.GetSearchPage方法的具体用法?C# TabClass.GetSearchPage怎么用?C# TabClass.GetSearchPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenTween.TabClass
的用法示例。
在下文中一共展示了TabClass.GetSearchPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPhoenixSearch
public string GetPhoenixSearch(bool read,
TabClass tab,
bool more)
{
if (MyCommon._endingFlag) return string.Empty;
HttpStatusCode res;
var content = string.Empty;
var page = 0;
var sinceId = 0;
var count = 100;
var querystr = string.Empty;
if (AppendSettingDialog.Instance.UseAdditionalCount &&
AppendSettingDialog.Instance.SearchCountApi != 0)
{
count = AppendSettingDialog.Instance.SearchCountApi;
}
if (more)
{
page = tab.GetSearchPage(count);
if (!string.IsNullOrEmpty(tab.NextPageQuery))
{
querystr = tab.NextPageQuery;
}
}
else
{
sinceId = (int)tab.SinceId;
}
try
{
if (string.IsNullOrEmpty(querystr))
{
res = twCon.PhoenixSearch(tab.SearchWords, tab.SearchLang, count, page, sinceId, ref content);
}
else
{
res = twCon.PhoenixSearch(querystr, ref content);
}
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
switch (res)
{
case HttpStatusCode.BadRequest:
return "Invalid query";
case HttpStatusCode.NotFound:
return "Invalid query";
case HttpStatusCode.PaymentRequired: //API Documentには420と書いてあるが、該当コードがないので402にしてある
return "Search API Limit?";
case HttpStatusCode.OK:
break;
default:
return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
}
if (!TabInformations.GetInstance().ContainsTab(tab)) return string.Empty;
//// TODO
//// 遡るための情報max_idやnext_pageの情報を保持する
string nextPageQuery = tab.NextPageQuery;
var ret = CreatePostsFromPhoenixSearch(content, MyCommon.WORKERTYPE.PublicSearch, tab, read, count, ref tab.OldestId, ref nextPageQuery);
tab.NextPageQuery = nextPageQuery;
return ret;
}
示例2: GetSearch
public string GetSearch(bool read,
TabClass tab,
bool more)
{
if (MyCommon._endingFlag) return string.Empty;
HttpStatusCode res;
var content = string.Empty;
var page = 0;
var sinceId = 0;
var count = 100;
if (AppendSettingDialog.Instance.UseAdditionalCount &&
AppendSettingDialog.Instance.SearchCountApi != 0)
{
count = AppendSettingDialog.Instance.SearchCountApi;
}
else
{
count = AppendSettingDialog.Instance.CountApi;
}
if (more)
{
page = tab.GetSearchPage(count);
}
else
{
sinceId = (int)tab.SinceId;
}
try
{
// TODO:一時的に40>100件に 件数変更UI作成の必要あり
res = twCon.Search(tab.SearchWords, tab.SearchLang, count, page, sinceId, ref content);
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
switch (res)
{
case HttpStatusCode.BadRequest:
return "Invalid query";
case HttpStatusCode.NotFound:
return "Invalid query";
case HttpStatusCode.PaymentRequired: //API Documentには420と書いてあるが、該当コードがないので402にしてある
return "Search API Limit?";
case HttpStatusCode.OK:
break;
default:
return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
}
if (!TabInformations.GetInstance().ContainsTab(tab)) return string.Empty;
content = Regex.Replace(content, @"[\x00-\x1f-[\x0a\x0d]]+", " ");
var xdoc = new XmlDocument();
try
{
xdoc.LoadXml(content);
}
catch(Exception ex)
{
MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
return "Invalid ATOM!";
}
var nsmgr = new XmlNamespaceManager(xdoc.NameTable);
nsmgr.AddNamespace("search", "http://www.w3.org/2005/Atom");
nsmgr.AddNamespace("twitter", "http://api.twitter.com/");
nsmgr.AddNamespace("georss", "http://www.georss.org/georss");
foreach (var xentryNode in xdoc.DocumentElement.SelectNodes("/search:feed/search:entry", nsmgr))
{
var xentry = (XmlElement)xentryNode;
var post = new PostClass();
try
{
post.StatusId = long.Parse(xentry["id"].InnerText.Split(':')[2]);
if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue;
post.CreatedAt = DateTime.Parse(xentry["published"].InnerText);
//本文
post.TextFromApi = xentry["title"].InnerText;
//Source取得(htmlの場合は、中身を取り出し)
post.Source = xentry["twitter:source"].InnerText;
post.InReplyToStatusId = 0;
post.InReplyToUser = string.Empty;
post.InReplyToUserId = 0;
post.IsFav = false;
// Geoが勝手に付加されるバグがいっこうに修正されないので暫定的にGeo情報を無視する
if (xentry["twitter:geo"].HasChildNodes)
{
var pnt = ((XmlElement)xentry.SelectSingleNode("twitter:geo/georss:point", nsmgr)).InnerText.Split(' ');
post.PostGeo = new PostClass.StatusGeo {Lat = Double.Parse(pnt[0]), Lng = Double.Parse(pnt[1])};
}
//以下、ユーザー情報
var xUentry = (XmlElement)xentry.SelectSingleNode("./search:author", nsmgr);
post.UserId = 0;
post.ScreenName = xUentry["name"].InnerText.Split(' ')[0].Trim();
post.Nickname = xUentry["name"].InnerText.Substring(post.ScreenName.Length).Trim();
if (post.Nickname.Length > 2)
{
//.........这里部分代码省略.........
示例3: GetSearch
public string GetSearch(bool read,
TabClass tab,
bool more)
{
if (MyCommon._endingFlag) return "";
HttpStatusCode res;
var content = "";
var page = 0;
var sinceId = 0L;
var count = 100;
if (AppendSettingDialog.Instance.UseAdditionalCount &&
AppendSettingDialog.Instance.SearchCountApi != 0)
{
count = AppendSettingDialog.Instance.SearchCountApi;
}
else
{
count = AppendSettingDialog.Instance.CountApi;
}
if (more)
{
page = tab.GetSearchPage(count);
}
else
{
sinceId = tab.SinceId;
}
try
{
// TODO:一時的に40>100件に 件数変更UI作成の必要あり
res = twCon.Search(tab.SearchWords, tab.SearchLang, count, page, sinceId, ref content);
}
catch(Exception ex)
{
return "Err:" + ex.Message;
}
switch (res)
{
case HttpStatusCode.BadRequest:
return "Invalid query";
case HttpStatusCode.NotFound:
return "Invalid query";
case HttpStatusCode.PaymentRequired: //API Documentには420と書いてあるが、該当コードがないので402にしてある
return "Search API Limit?";
case HttpStatusCode.OK:
break;
default:
return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
}
if (!TabInformations.GetInstance().ContainsTab(tab)) return "";
return this.CreatePostsFromSearchJson(content, tab, read, count, ref tab.OldestId, more);
}