本文整理汇总了C#中CmsData.CMSDataContext.PurgePerson方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.PurgePerson方法的具体用法?C# CMSDataContext.PurgePerson怎么用?C# CMSDataContext.PurgePerson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsData.CMSDataContext
的用法示例。
在下文中一共展示了CMSDataContext.PurgePerson方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveAndDeleteAsync
public void MoveAndDeleteAsync(string text)
{
AsyncManager.OutstandingOperations.Increment();
string host = Util.Host;
ThreadPool.QueueUserWorkItem((e) =>
{
var sb = new StringBuilder();
sb.Append("<h2>done</h2>\n<p><a href='/'>home</a></p>\n");
using (var csv = new CsvReader(new StringReader(text), false, '\t'))
{
while (csv.ReadNextRecord())
{
if (csv.FieldCount != 2)
{
sb.AppendFormat("expected two ids, row {0}<br/>\n", csv[0]);
continue;
}
var fromid = csv[0].ToInt();
var toid = csv[1].ToInt();
var Db = new CMSDataContext(Util.GetConnectionString(host));
var p = Db.LoadPersonById(fromid);
if (p == null)
{
sb.AppendFormat("fromid {0} not found<br/>\n", fromid);
Db.Dispose();
continue;
}
var tp = Db.LoadPersonById(toid);
if (tp == null)
{
sb.AppendFormat("toid {0} not found<br/>\n", toid);
Db.Dispose();
continue;
}
try
{
p.MovePersonStuff(Db, toid);
Db.SubmitChanges();
}
catch (Exception ex)
{
sb.AppendFormat("error on move ({0}, {1}): {2}<br/>\n", fromid, toid, ex.Message);
Db.Dispose();
continue;
}
try
{
Db.PurgePerson(fromid);
sb.AppendFormat("moved ({0}, {1}) successful<br/>\n", fromid, toid);
}
catch (Exception ex)
{
sb.AppendFormat("error on delete ({0}): {1}<br/>\n", fromid, ex.Message);
}
finally
{
Db.Dispose();
}
}
}
AsyncManager.Parameters["results"] = sb.ToString();
AsyncManager.OutstandingOperations.Decrement();
});
}