本文整理汇总了C#中CmsData.CMSDataContext.Content方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.Content方法的具体用法?C# CMSDataContext.Content怎么用?C# CMSDataContext.Content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsData.CMSDataContext
的用法示例。
在下文中一共展示了CMSDataContext.Content方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VitalStats
public static string VitalStats(CMSDataContext Db)
{
var qf = new QueryFunctions(Db);
var script = Db.Content("VitalStats");
if (script == null)
return "no VitalStats script";
#if DEBUG2
var options = new Dictionary<string, object>();
options["Debug"] = true;
var engine = Python.CreateEngine(options);
var paths = engine.GetSearchPaths();
paths.Add(path);
engine.SetSearchPaths(paths);
var sc = engine.CreateScriptSourceFromFile(HttpContext.Current.Server.MapPath("/MembershipAutomation2.py"));
#else
var engine = Python.CreateEngine();
var sc = engine.CreateScriptSourceFromString(script.Body);
#endif
try
{
var code = sc.Compile();
var scope = engine.CreateScope();
code.Execute(scope);
dynamic VitalStats = scope.GetVariable("VitalStats");
dynamic m = VitalStats();
return m.Run(qf);
}
catch (Exception ex)
{
return "VitalStats script error: " + ex.Message;
}
}
示例2: MemberProfileAutomation
public string MemberProfileAutomation(CMSDataContext Db)
{
if (Db.Setting("UseMemberProfileAutomation", "true") != "true")
return "ok";
var script = Db.Content("MemberProfileAutomation");
if (script == null)
return "ok";
var path = HttpContext.Current.Server.MapPath("/Content/");
#if DEBUG2
var options = new Dictionary<string, object>();
options["Debug"] = true;
var engine = Python.CreateEngine(options);
var paths = engine.GetSearchPaths();
paths.Add(path);
engine.SetSearchPaths(paths);
var sc = engine.CreateScriptSourceFromFile(HttpContext.Current.Server.MapPath("/Content/MembershipAutomation2.py"));
#else
var engine = Python.CreateEngine();
var paths = engine.GetSearchPaths();
paths.Add(path);
engine.SetSearchPaths(paths);
var sc = engine.CreateScriptSourceFromString(script.Body);
#endif
try
{
var code = sc.Compile();
var scope = engine.CreateScope();
code.Execute(scope);
dynamic MembershipAutomation = scope.GetVariable("MembershipAutomation");
dynamic m = MembershipAutomation();
var ret = m.Run(Db, this);
//var m = scope.GetVariable("MembershipAutomation");
//dynamic instance = engine.Operations.CreateInstance(m);
//var value = instance.Run(Db, this);
return errorReturn;
}
catch (Exception ex)
{
return "MemberProfileAutomation script error: " + ex.Message;
}
}
示例3: SetStandardExtraValues2
public static void SetStandardExtraValues2(CMSDataContext db, string xml)
{
var c = db.Content("StandardExtraValues2");
c.Body = xml;
HttpRuntime.Cache.Insert(db.Host + "StandardExtraValues2", xml, null,
DateTime.Now.AddMinutes(Util.IsDebug() ? 0 : 1), Cache.NoSlidingExpiration);
}
示例4: DoGiving
public int DoGiving(CMSDataContext db)
{
var total = (from a in db.RecurringAmounts
where a.PeopleId == PeopleId
where a.ContributionFund.FundStatusId == 1
where a.ContributionFund.OnlineSort != null
select a.Amt).Sum();
if (!total.HasValue || total == 0)
return 0;
var paymentInfo = db.PaymentInfos.Single(x => x.PeopleId == PeopleId);
var preferredType = paymentInfo.PreferredGivingType;
var gw = GetGateway(db, paymentInfo);
var orgid = (from o in db.Organizations
where o.RegistrationTypeId == RegistrationTypeCode.ManageGiving
select o.OrganizationId).FirstOrDefault();
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 = gw.GatewayType,
Financeonly = true,
PaymentType = preferredType,
LastFourCC = preferredType == PaymentType.CreditCard ? paymentInfo.MaskedCard.Last(4) : null,
LastFourACH = preferredType == PaymentType.Ach ? paymentInfo.MaskedAccount.Last(4) : null,
OrgId = orgid,
};
db.Transactions.InsertOnSubmit(t);
db.SubmitChanges();
var ret = gw.PayWithVault(PeopleId, total ?? 0, "Recurring Giving", t.Id, preferredType);
t.Message = ret.Message;
t.AuthCode = ret.AuthCode;
t.Approved = ret.Approved;
t.TransactionId = ret.TransactionId;
var gift = db.Setting("NameForPayment", "gift");
var church = db.Setting("NameOfChurch", db.CmsHost);
var q = from a in db.RecurringAmounts
where a.PeopleId == PeopleId
select a;
var tot = q.Where(aa => aa.ContributionFund.FundStatusId == 1).Sum(aa => aa.Amt);
t.TransactionPeople.Add(new TransactionPerson
{
PeopleId = Person.PeopleId,
Amt = tot,
});
var notify = db.RecurringGivingNotifyPersons();
var from = Util.TryGetMailAddress(notify[0].EmailAddress);
if (ret.Approved)
{
foreach (var a in q)
{
if (a.ContributionFund.FundStatusId == 1 && a.ContributionFund.OnlineSort != null && a.Amt > 0)
Person.PostUnattendedContribution(db, a.Amt ?? 0, a.FundId, "Recurring Giving", tranid: t.Id);
}
NextDate = FindNextDate(Util.Now.Date.AddDays(1));
db.SubmitChanges();
if (tot > 0)
{
var msg = db.Content("RecurringGiftNotice") ?? new Content
{ Title = $"Recurring {gift} for {{church}}",
Body = "Your gift of {total} was processed this morning." };
var subject = msg.Title.Replace("{church}", church);
var body = msg.Body.Replace("{total}", $"${tot:N2}");
var m = new EmailReplacements(db, body, from);
body = m.DoReplacements(db, Person);
db.EmailFinanceInformation(from, Person, null, subject, body);
}
}
else
{
db.SubmitChanges();
var msg = db.Content("RecurringGiftFailedNotice") ?? new Content
{ Title = $"Recurring {gift} for {{church}} did not succeed",
Body = @"Your payment of {total} failed to process this morning.<br>
The message was '{message}'.
Please contact the Finance office at the church." };
var subject = msg.Title.Replace("{church}", church);
var body = msg.Body.Replace("{total}", $"${tot:N2}")
.Replace("{message}", ret.Message);
var m = new EmailReplacements(db, body, from);
body = m.DoReplacements(db, Person);
db.Email(from, Person, null, subject, body, false);
foreach (var p in db.RecurringGivingNotifyPersons())
//.........这里部分代码省略.........
示例5: VitalStats
public static string VitalStats(CMSDataContext Db)
{
var qf = new QueryFunctions(Db);
var script = Db.Content("VitalStats");
if (script == null)
return "no VitalStats script";
if (!script.Body.Contains("class VitalStats"))
return RunScript(Db, script.Body);
var engine = Python.CreateEngine();
var sc = engine.CreateScriptSourceFromString(script.Body);
try
{
var code = sc.Compile();
var scope = engine.CreateScope();
code.Execute(scope);
dynamic VitalStats = scope.GetVariable("VitalStats");
dynamic m = VitalStats();
return m.Run(qf);
}
catch (Exception ex)
{
return "VitalStats script error: " + ex.Message;
}
}