本文整理汇总了C#中CmsData.CMSDataContext.ContentHtml方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.ContentHtml方法的具体用法?C# CMSDataContext.ContentHtml怎么用?C# CMSDataContext.ContentHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsData.CMSDataContext
的用法示例。
在下文中一共展示了CMSDataContext.ContentHtml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(Stream stream, CMSDataContext Db, IEnumerable<ContributorInfo> q, int set = 0)
{
pageEvents.set = set;
pageEvents.PeopleId = 0;
var contributors = q;
PdfContentByte dc;
var font = FontFactory.GetFont(FontFactory.HELVETICA, 11);
var boldfont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11);
var doc = new Document(PageSize.LETTER);
doc.SetMargins(36f, 30f, 24f, 36f);
var w = PdfWriter.GetInstance(doc, stream);
w.PageEvent = pageEvents;
doc.Open();
dc = w.DirectContent;
var prevfid = 0;
var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).FirstOrDefault();
runningtotals.Processed = 0;
Db.SubmitChanges();
var count = 0;
foreach (var ci in contributors)
{
if (set > 0 && pageEvents.FamilySet[ci.PeopleId] != set)
continue;
var contributions = APIContribution.contributions(Db, ci, FromDate, ToDate).ToList();
var pledges = APIContribution.pledges(Db, ci, ToDate).ToList();
var giftsinkind = APIContribution.GiftsInKind(Db, ci, FromDate, ToDate).ToList();
var nontaxitems = Db.Setting("DisplayNonTaxOnStatement", "false").ToBool()
? APIContribution.NonTaxItems(Db, ci, FromDate, ToDate).ToList()
: new List<ContributionInfo>();
if ((contributions.Count + pledges.Count + giftsinkind.Count + nontaxitems.Count) == 0)
{
runningtotals.Processed += 1;
runningtotals.CurrSet = set;
Db.SubmitChanges();
if (set == 0)
pageEvents.FamilySet[ci.PeopleId] = 0;
continue;
}
pageEvents.NextPeopleId = ci.PeopleId;
doc.NewPage();
if (prevfid != ci.FamilyId)
{
prevfid = ci.FamilyId;
pageEvents.EndPageSet();
pageEvents.PeopleId = ci.PeopleId;
}
if (set == 0)
pageEvents.FamilySet[ci.PeopleId] = 0;
count++;
var css = @"
<style>
h1 { font-size: 24px; font-weight:normal; margin-bottom:0; }
h2 { font-size: 11px; font-weight:normal; margin-top: 0; }
p { font-size: 11px; }
</style>
";
//----Church Name
var t1 = new PdfPTable(1);
t1.TotalWidth = 72f*5f;
t1.DefaultCell.Border = Rectangle.NO_BORDER;
var html1 = Db.ContentHtml("StatementHeader", Resource1.ContributionStatementHeader);
var html2 = Db.ContentHtml("StatementNotice", Resource1.ContributionStatementNotice);
var mh = new MyHandler();
using (var sr = new StringReader(css + html1))
XMLWorkerHelper.GetInstance().ParseXHtml(mh, sr);
var cell = new PdfPCell(t1.DefaultCell);
foreach (var e in mh.elements)
if (e.Chunks.Count > 0)
cell.AddElement(e);
//cell.FixedHeight = 72f * 1.25f;
t1.AddCell(cell);
t1.AddCell("\n");
var t1a = new PdfPTable(1);
t1a.TotalWidth = 72f*5f;
t1a.DefaultCell.Border = Rectangle.NO_BORDER;
var ae = new PdfPTable(1);
ae.DefaultCell.Border = Rectangle.NO_BORDER;
ae.WidthPercentage = 100;
var a = new PdfPTable(1);
a.DefaultCell.Indent = 25f;
a.DefaultCell.Border = Rectangle.NO_BORDER;
a.AddCell(new Phrase(ci.Name, font));
foreach (var line in ci.MailingAddress.SplitLines())
a.AddCell(new Phrase(line, font));
cell = new PdfPCell(a) {Border = Rectangle.NO_BORDER};
//cell.FixedHeight = 72f * 1.0625f;
//.........这里部分代码省略.........
示例2: Run
public void Run(Stream stream, CMSDataContext Db, IEnumerable<ContributorInfo> q, int set = 0)
{
pageEvents.set = set;
IEnumerable<ContributorInfo> contributors = q;
var toDate = ToDate.Date.AddHours(24).AddSeconds(-1);
PdfContentByte dc;
var font = FontFactory.GetFont(FontFactory.HELVETICA, 11);
var boldfont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 11);
var doc = new Document(PageSize.LETTER);
doc.SetMargins(36f, 30f, 24f, 36f);
var w = PdfWriter.GetInstance(doc, stream);
w.PageEvent = pageEvents;
doc.Open();
dc = w.DirectContent;
int prevfid = 0;
var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).FirstOrDefault();
runningtotals.Processed = 0;
Db.SubmitChanges();
var count = 0;
foreach (var ci in contributors)
{
if (set > 0 && pageEvents.FamilySet[ci.PeopleId] != set)
continue;
doc.NewPage();
if (prevfid != ci.FamilyId)
{
prevfid = ci.FamilyId;
pageEvents.EndPageSet();
}
if (set == 0)
pageEvents.FamilySet[ci.PeopleId] = 0;
count++;
var css = @"
<style>
h1 { font-size: 24px; font-weight:normal; margin-bottom:0; }
h2 { font-size: 11px; font-weight:normal; margin-top: 0; }
p { font-size: 11px; }
</style>
";
//----Church Name
var t1 = new PdfPTable(1);
t1.TotalWidth = 72f * 5f;
t1.DefaultCell.Border = Rectangle.NO_BORDER;
string html1 = Db.ContentHtml("StatementHeader", Resource1.ContributionStatementHeader);
string html2 = Db.ContentHtml("StatementNotice", Resource1.ContributionStatementNotice);
var mh = new MyHandler();
using (var sr = new StringReader(css + html1))
XMLWorkerHelper.GetInstance().ParseXHtml(mh, sr);
var cell = new PdfPCell(t1.DefaultCell);
foreach (var e in mh.elements)
if (e.Chunks.Count > 0)
cell.AddElement(e);
//cell.FixedHeight = 72f * 1.25f;
t1.AddCell(cell);
t1.AddCell("\n");
var t1a = new PdfPTable(1);
t1a.TotalWidth = 72f * 5f;
t1a.DefaultCell.Border = Rectangle.NO_BORDER;
var ae = new PdfPTable(1);
ae.DefaultCell.Border = Rectangle.NO_BORDER;
ae.WidthPercentage = 100;
var a = new PdfPTable(1);
a.DefaultCell.Indent = 25f;
a.DefaultCell.Border = Rectangle.NO_BORDER;
a.AddCell(new Phrase(ci.Name, font));
a.AddCell(new Phrase(ci.Address1, font));
if (ci.Address2.HasValue())
a.AddCell(new Phrase(ci.Address2, font));
a.AddCell(new Phrase(ci.CityStateZip, font));
cell = new PdfPCell(a) { Border = Rectangle.NO_BORDER };
//cell.FixedHeight = 72f * 1.0625f;
ae.AddCell(cell);
cell = new PdfPCell(t1a.DefaultCell);
cell.AddElement(ae);
t1a.AddCell(ae);
//-----Notice
var t2 = new PdfPTable(1);
t2.TotalWidth = 72f * 3f;
t2.DefaultCell.Border = Rectangle.NO_BORDER;
t2.AddCell(new Phrase("\nPrint Date: {0:d} (id:{1} {2})".Fmt(DateTime.Now, ci.PeopleId, ci.CampusId), font));
t2.AddCell("");
var mh2 = new MyHandler();
using (var sr = new StringReader(css + html2))
XMLWorkerHelper.GetInstance().ParseXHtml(mh2, sr);
cell = new PdfPCell(t1.DefaultCell);
foreach (var e in mh2.elements)
if (e.Chunks.Count > 0)
cell.AddElement(e);
//.........这里部分代码省略.........
示例3: DoGiving
public int DoGiving(CMSDataContext Db)
{
var gateway = Db.Setting("TransactionGateway", "");
AuthorizeNet anet = null;
SagePayments sage = null;
if (gateway == "AuthorizeNet")
anet = new AuthorizeNet(Db, testing: false);
else if (gateway == "Sage")
sage = new SagePayments(Db, testing: false);
else
return 0;
TransactionResponse ret = null;
var total = (from a in Db.RecurringAmounts
where a.PeopleId == PeopleId
where a.ContributionFund.FundStatusId == 1
select a.Amt).Sum();
if (!total.HasValue || total == 0)
return 0;
var preferredtype = (from pi in Db.PaymentInfos
where pi.PeopleId == PeopleId
select pi.PreferredGivingType).Single();
var t = new Transaction
{
TransactionDate = DateTime.Now,
TransactionId = "started",
First = Person.FirstName,
MiddleInitial = Person.MiddleName.Truncate(1) ?? "",
Last = Person.LastName,
Suffix = Person.SuffixCode,
Amt = total,
Description = "Recurring Giving",
Testing = false,
TransactionGateway = gateway,
Financeonly = true
};
Db.Transactions.InsertOnSubmit(t);
Db.SubmitChanges();
if (gateway == "AuthorizeNet")
ret = anet.createCustomerProfileTransactionRequest(PeopleId, total ?? 0, "Recurring Giving", t.Id);
else
ret = sage.createVaultTransactionRequest(PeopleId, total ?? 0, "Recurring Giving", t.Id, preferredtype);
t.TransactionPeople.Add(new TransactionPerson { PeopleId = PeopleId, Amt = total });
t.Message = ret.Message;
t.AuthCode = ret.AuthCode;
t.Approved = ret.Approved;
t.TransactionId = ret.TransactionId;
var systemEmail = Db.Setting("SystemEmailAddress", "[email protected]");
var contributionemail = (from ex in Person.PeopleExtras
where ex.Field == "ContributionEmail"
select ex.Data).SingleOrDefault();
if (contributionemail.HasValue())
contributionemail = contributionemail.Trim();
if (!Util.ValidEmail(contributionemail))
contributionemail = Person.FromEmail;
var gift = Db.Setting("NameForPayment", "gift");
var church = Db.Setting("NameOfChurch", Db.CmsHost);
if (ret.Approved)
{
var q = from a in Db.RecurringAmounts
where a.PeopleId == PeopleId
select a;
foreach (var a in q)
{
if (a.ContributionFund.FundStatusId == 1 && a.Amt > 0)
Person.PostUnattendedContribution(Db,
a.Amt ?? 0,
a.FundId,
"Recurring Giving", pledge: false);
}
var tot = q.Where(aa => aa.ContributionFund.FundStatusId == 1).Sum(aa => aa.Amt);
NextDate = FindNextDate(DateTime.Today.AddDays(1));
Db.SubmitChanges();
if (tot > 0)
{
Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(contributionemail),
"Recurring {0} for {1}".Fmt(gift, church),
"Your payment of ${0:N2} was processed this morning.".Fmt(tot),
Util.ToMailAddressList(contributionemail), 0, null);
}
}
else
{
Db.SubmitChanges();
var failedGivingMessage = Db.ContentHtml("FailedGivingMessage", Resources.ManagedGiving_FailedGivingMessage);
var adminEmail = Db.Setting("AdminMail", systemEmail);
Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(contributionemail),
"Recurring {0} failed for {1}".Fmt(gift, church),
failedGivingMessage.Replace("{first}", Person.PreferredName),
Util.ToMailAddressList(contributionemail), 0, null);
foreach (var p in Db.FinancePeople())
Util.SendMsg(systemEmail, Db.CmsHost, Util.TryGetMailAddress(adminEmail),
"Recurring Giving Failed on " + Db.CmsHost,
//.........这里部分代码省略.........