本文整理汇总了C#中BaseLib.clsDBQueryManager.GetUserName方法的典型用法代码示例。如果您正苦于以下问题:C# clsDBQueryManager.GetUserName方法的具体用法?C# clsDBQueryManager.GetUserName怎么用?C# clsDBQueryManager.GetUserName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseLib.clsDBQueryManager
的用法示例。
在下文中一共展示了clsDBQueryManager.GetUserName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUserNameFromUserId
public static string GetUserNameFromUserId(string userid)
{
string username = string.Empty;
ChilkatHttpHelpr httpHelper = new ChilkatHttpHelpr();
clsDBQueryManager DB = new clsDBQueryManager();
DataSet ds = DB.GetUserName(userid);
string user_id = string.Empty;
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dataRow in ds.Tables["tb_UsernameDetails"].Rows)
{
user_id = dataRow.ItemArray[0].ToString();
return user_id;
}
}
try
{
string PageSource = string.Empty;
if (!string.IsNullOrEmpty(userid) && NumberHelper.ValidateNumber(userid))
{
PageSource = httpHelper.GetHtml("https://api.twitter.com/1/users/show.xml?user_id=" + userid + "&include_entities=true");
if (!PageSource.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour."))
{
try
{
int startIndex = PageSource.IndexOf("<screen_name>");
if (startIndex > 0)
{
string Start = PageSource.Substring(startIndex);
int endIndex = Start.IndexOf("</screen_name>");
string End = Start.Substring(0, endIndex);
username = End.Replace("<screen_name>", "");
}
}
catch (Exception ex)
{
Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
}
}
else
{
username = "Rate Limit Exceeded";
}
}
}
catch (Exception ex)
{
Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserNameFromUserId() -- " + userid + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
}
return username;
}
示例2: GetUserNameFromUserId_New
public static string GetUserNameFromUserId_New(string UserId, out string Status, ref GlobusHttpHelper HttpHelper)
{
string _UserName = string.Empty;
clsDBQueryManager DB = new clsDBQueryManager();
DataSet ds = DB.GetUserName(UserId);
try
{
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dataRow in ds.Tables["tb_UsernameDetails"].Rows)
{
_UserName = dataRow.ItemArray[0].ToString();
Status = "No Error";
return _UserName;
}
}
}
catch { };
try
{
string pagesource = string.Empty;
string Url = "https://twitter.com/account/redirect_by_id?id=" + UserId;
pagesource = HttpHelper.getHtmlfromUrl(new Uri(Url), "", "");
if (!pagesource.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour.") && !pagesource.Contains("Sorry, that page does not exist") && !pagesource.Contains("User has been suspended"))
{
int startindex = pagesource.IndexOf("screen_name");
string start = pagesource.Substring(startindex).Replace("screen_name", "");
int endindex = start.IndexOf("}");
string end = start.Substring(0, endindex);
_UserName = end.Replace("<s>", string.Empty).Replace("</s>", string.Empty).Replace("</span>", string.Empty).Replace(""", string.Empty).Replace(":", string.Empty);
if (string.IsNullOrEmpty(_UserName))
{
_UserName = string.Empty;
string[] Arr_Name = (HttpHelper.gResponse.ResponseUri.ToString()).Split('/');
_UserName = Arr_Name[Arr_Name.Count() - 1];
}
}
else if (pagesource.Contains("Rate limit exceeded. Clients may not make more than 150 requests per hour."))
{
Status = "Rate limit exceeded";
}
else if (pagesource.Contains("Sorry, that page does not exist"))
{
Status = "Sorry, that page does not exist";
}
else if (pagesource.Contains("User has been suspended"))
{
Status = "User has been suspended";
}
}
catch (Exception ex)
{
Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> GetUserIDFromUsername() -- " + UserId + " --> " + ex.Message, Globals.Path_TwitterDataScrapper);
Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> GetUserIDFromUsername() -- " + UserId + " --> " + ex.Message, Globals.Path_TwtErrorLogs);
Status = "Error";
}
Status = "No Error";
return _UserName;
}