本文整理汇总了C#中System.Net.Connection.GetUsernameByToken方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.GetUsernameByToken方法的具体用法?C# Connection.GetUsernameByToken怎么用?C# Connection.GetUsernameByToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Connection
的用法示例。
在下文中一共展示了Connection.GetUsernameByToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchDocuments
public IEnumerable<Document> SearchDocuments(string token, string pattern)
{
_conn = new Connection(_connectionString);
try
{
_conn.OpenConnection();
return !string.IsNullOrEmpty(_conn.GetUsernameByToken(token)) ? _conn.SearchDocuments(pattern) : null;
}
finally
{
_conn.CloseConnection();
}
}
示例2: Delete
public bool Delete([FromUri] string token, [FromUri] long id)
{
_conn = new Connection(_connectionString);
try
{
_conn.OpenConnection();
return !string.IsNullOrEmpty(_conn.GetUsernameByToken(token)) && _conn.DeleteDocument(id);
}
finally
{
_conn.CloseConnection();
}
}
示例3: GetFtpCredential
public NetworkCredential GetFtpCredential([FromUri] string token)
{
_conn = new Connection(_connectionString);
try
{
_conn.OpenConnection();
string username = _conn.GetUsernameByToken(token);
return !string.IsNullOrEmpty(username) ? _accessCredential : null;
}
finally
{
_conn.CloseConnection();
}
}
示例4: UploadDocument
public Document UploadDocument(string token, string name, long size, string description)
{
_conn = new Connection(_connectionString);
_conn.OpenConnection();
string username = _conn.GetUsernameByToken(token);
try
{
if (!string.IsNullOrEmpty(username))
{
Document doc = new Document()
{
Name = name,
Size = size,
Author = username,
Path = _ftpUri + name,
Description = description
};
return _conn.UploadDocument(doc) ? doc : null;
}
else
{
return null;
}
}
finally
{
_conn.CloseConnection();
}
}