本文整理汇总了C#中Title.AsUnprefixedDbPath方法的典型用法代码示例。如果您正苦于以下问题:C# Title.AsUnprefixedDbPath方法的具体用法?C# Title.AsUnprefixedDbPath怎么用?C# Title.AsUnprefixedDbPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title.AsUnprefixedDbPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Archive_GetCountByTitle
public uint Archive_GetCountByTitle(Title title) {
return Catalog.NewQuery(@" /* Archive_GetCountByTitle */
SELECT COUNT(*)
FROM archive
WHERE ar_namespace = ?NS and ar_title = ?TITLE;")
.With("TITLE", title.AsUnprefixedDbPath())
.With("NS", (int) title.Namespace)
.ReadAsUInt() ?? 0;
}
示例2: Archive_GetPagesByTitleTransactions
public IList<KeyValuePair<uint, IList<ArchiveBE>>> Archive_GetPagesByTitleTransactions(Title title, uint? trans_offset, uint? trans_limit, out Dictionary<uint, TransactionBE> transactionsById, out uint? queryTotalTransactionCount) {
string innerSelectQuery = String.Empty;
if (title != null) {
innerSelectQuery = @"
select transactions.*
from archive
join transactions
on t_id = ar_transaction_id
where ar_title like ?TITLE
and (?NS = 0 or ar_namespace = ?NS )
and ar_old_id = 0
and t_reverted = 0
group by t_id";
} else {
innerSelectQuery = @"
select *
from transactions
where t_type = 5
and t_reverted = 0
and t_page_id is not null";
}
DataCommand cmd = Catalog.NewQuery(String.Format(@" /* Archive_GetPagesByTitleTransactions */
select *
from (
select t.*, archive.*
from archive
join (
{0}
order by t_timestamp desc
limit ?LIMIT offset ?OFFSET
) t
on t.t_id = ar_transaction_id
where ar_old_id = 0
) a
order by a.t_timestamp desc, a.ar_title asc;
select count(*) as queryTotalTransactionCount
from (
{0}
) a;", innerSelectQuery))
.With("LIMIT", trans_limit ?? UInt32.MaxValue)
.With("OFFSET", trans_offset ?? 0);
if(title != null) {
cmd.With("TITLE", "%" + title.AsUnprefixedDbPath() + "%")
.With("NS", (int) title.Namespace);
}
return Archive_PopulateByTransactionQuery(cmd, out transactionsById, out queryTotalTransactionCount);
}
示例3: MWToDWTitle
/// <summary>
/// Converts a MediaWiki title to its MindTouch format
/// </summary>
/// <param name="mwTitle">The title to convert</param>
/// <param name="replaceSeparator">If true, replace ":" with "/"</param>
/// <returns>The converted title</returns>
public Title MWToDWTitle(Site site, Title mwTitle, bool useNewFormat) {
string dbPrefix = null;
string dbPath = mwTitle.AsUnprefixedDbPath();
string displayName = mwTitle.DisplayName;
// create a language heirarchy in the main namespaces
if (CreateLanguageHierarchyForNS(mwTitle.Namespace)) {
dbPrefix = site.DWRootPage + "/";
if (site.MWRootPage == mwTitle.Path && useNewFormat) {
displayName = displayName ?? mwTitle.AsUserFriendlyName();
dbPath = String.Empty;
}
}
// prefix template pages with language to make unique accross langauges
else if (mwTitle.IsTemplate || NS.TEMPLATE_TALK == mwTitle.Namespace || mwTitle.IsSpecial) {
return mwTitle;
}
// if this is a user page that corresponds to a renamed user, rename the page.
else if (mwTitle.IsUser || NS.USER_TALK == mwTitle.Namespace) {
string parentSegment = mwTitle.AsUnprefixedDbSegments()[0];
string newParentSegment;
if (_MWToDWUserNameMap.TryGetValue(parentSegment, out newParentSegment)) {
dbPath = newParentSegment + mwTitle.Path.Substring(newParentSegment.Length - 1);
}
}
if ('/' != MediaWikiConverterContext.Current.MWPageSeparator) {
dbPath = dbPath.Replace("/", "//");
// If desired, replace the page separator with "/"
if (useNewFormat && 0 < MediaWikiConverterContext.Current.MWPageSeparator) {
String[] segments = dbPath.Split(MediaWikiConverterContext.Current.MWPageSeparator);
if (1 < segments.Length) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < segments.Length; i++) {
if ((0 < i && !String.IsNullOrEmpty(segments[i - 1])) &&
!(i == segments.Length - 1 && String.IsNullOrEmpty(segments[i]))) {
result.Append("/");
}
if (String.IsNullOrEmpty(segments[i])) {
result.Append(MediaWikiConverterContext.Current.MWPageSeparator);
} else {
result.Append(segments[i].Trim(new char[] { '_' }));
}
}
dbPath = result.ToString();
}
}
}
dbPath = dbPrefix + dbPath;
return Title.FromDbPath(mwTitle.Namespace, dbPath.Trim('/'), displayName, mwTitle.Filename, mwTitle.Anchor, mwTitle.Query);
}
示例4: Pages_UpdateTitlesForMove
public void Pages_UpdateTitlesForMove(Title currentTitle, ulong newParentId, Title title, DateTime touchedTimestamp) {
string query = @" /* Pages_UpdateTitlesForMove */
-- Delete redirects at source of move
delete from pages
where
page_namespace = ?NS
AND (
page_title = ?TITLE
/* OR util_Page_IsAntecedent(?TITLE, page_title) */
OR ((?TITLE = '' AND page_title != '') OR (LEFT(page_title, CHAR_LENGTH(?TITLE) + 1) = CONCAT(?TITLE, '/') AND SUBSTRING(page_title, CHAR_LENGTH(?TITLE) + 2, 1) != '/'))
)AND (page_is_redirect=1);
update pages
set page_title = CONCAT(?NEWTITLE, SUBSTRING(page_title, CHAR_LENGTH(?TITLE) + 1)),
/*page_title = util_String_ReplaceStartOfString(page_title, ?TITLE, ?NEWTITLE),*/
page_namespace = ?NEWNS,
page_touched = ?TOUCHED
where
page_namespace = ?NS
AND (
page_title = ?TITLE
OR (
/*util_Page_IsAntecedent(?TITLE, page_title)*/
((?TITLE = '' AND page_title != '') OR (LEFT(page_title, CHAR_LENGTH(?TITLE) + 1) = CONCAT(?TITLE, '/') AND SUBSTRING(page_title, CHAR_LENGTH(?TITLE) + 2, 1) != '/'))
AND page_title like ?TITLELIKE
)
) AND (
page_is_redirect = 0
);
update pages
set page_parent = ?NEWPARENTID,
page_touched = ?TOUCHED
where page_namespace = ?NEWNS
AND page_title = ?NEWTITLE;
";
Catalog.NewQuery(query)
.With("NS", (int)currentTitle.Namespace)
.With("TITLE", currentTitle.AsUnprefixedDbPath())
.With("NEWPARENTID", newParentId)
.With("NEWTITLE", title.AsUnprefixedDbPath())
.With("NEWNS", (int)title.Namespace)
.With("TITLELIKE", string.Format("{0}%", currentTitle.AsUnprefixedDbPath()))
.With("TOUCHED", DbUtils.ToString(touchedTimestamp))
.Execute();
}
示例5: AddMovePageRecentChange
public static void AddMovePageRecentChange(DateTime timestamp, PageBE oldTitle, Title newTitle, UserBE user, string comment, bool minorChange, uint transactionId) {
DbUtils.CurrentSession.RecentChanges_Insert(timestamp, oldTitle, user, comment, 0, RC.MOVE, (uint)newTitle.Namespace, newTitle.AsUnprefixedDbPath(), minorChange, transactionId);
}
示例6: Nav_GetNearestParent
public ulong Nav_GetNearestParent(Title title) {
string query = @"/* Nav_GetNearestParent */
SELECT page_id FROM pages WHERE page_namespace={0} AND STRCMP(SUBSTRING('{1}', 1, CHAR_LENGTH(page_title) + 1), CONCAT(page_title, '/'))=0 ORDER BY CHAR_LENGTH(page_title) DESC LIMIT 1";
return Catalog.NewQuery(string.Format(query, (int)title.Namespace, DataCommand.MakeSqlSafe(title.AsUnprefixedDbPath()))).ReadAsULong() ?? Head.Pages_HomePageId;
}
示例7: AddMovePageRecentChange
public static void AddMovePageRecentChange(DateTime timestamp, PageBE oldTitle, Title newTitle, UserBE user, DekiResource comment, bool minorChange, uint transactionId) {
var resources = DekiContext.Current.Resources;
DbUtils.CurrentSession.RecentChanges_Insert(timestamp, oldTitle, user, resources.Localize(comment), 0, RC.MOVE, (uint)newTitle.Namespace, newTitle.AsUnprefixedDbPath(), minorChange, transactionId);
}
示例8: GetFileAlternates
private static Title[] GetFileAlternates(Title baseTitle, Title title) {
List<Title> alternates = new List<Title>();
// look for the file using exactly the information provided
alternates.Add(title);
// if the string has an empty path, attempt to look for the file on the current page
if(!baseTitle.IsHomepage && title.IsHomepage) {
alternates.Add(Title.FromDbPath(baseTitle.Namespace, baseTitle.AsUnprefixedDbPath(), null, title.Filename));
}
return alternates.ToArray();
}
示例9: MWToDWTitle
/// <summary>
/// Converts a MediaWiki title to its MindTouch format
/// </summary>
/// <param name="mwTitle">The title to convert</param>
/// <param name="replaceSeparator">If true, replace ":" with "/"</param>
/// <returns>The converted title</returns>
public Title MWToDWTitle(string rootPage, Title mwTitle) {
string dbPath = null;
string dbPrefix = null;
// create a language heirarchy in the main namespaces
if (CreateLanguageHierarchyForNS(mwTitle.Namespace)) {
dbPrefix = rootPage + "/";
}
// prefix template pages with language to make unique accross langauges
else if (mwTitle.IsTemplate || NS.TEMPLATE_TALK == mwTitle.Namespace || mwTitle.IsSpecial) {
return mwTitle;
}
dbPath = mwTitle.AsUnprefixedDbPath();
if ('/' != _pageSeparator) {
dbPath = dbPath.Replace("/", "//");
if (0 < _pageSeparator) {
// Replace page separator with "/"
String[] segments = dbPath.Split(_pageSeparator);
if (1 < segments.Length) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < segments.Length; i++) {
if ((0 < i && !String.IsNullOrEmpty(segments[i - 1])) &&
!(i == segments.Length - 1 && String.IsNullOrEmpty(segments[i]))) {
result.Append("/");
}
if (String.IsNullOrEmpty(segments[i])) {
result.Append(_pageSeparator);
} else {
result.Append(segments[i].Trim(new char[] { '_' }));
}
}
dbPath = result.ToString();
}
}
}
dbPath = dbPrefix + dbPath;
return Title.FromDbPath(mwTitle.Namespace, dbPath.Trim('/'), null, mwTitle.Filename, mwTitle.Anchor, mwTitle.Query);
}