本文整理汇总了C#中CmsData.CMSDataContext.Setting方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.Setting方法的具体用法?C# CMSDataContext.Setting怎么用?C# CMSDataContext.Setting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsData.CMSDataContext
的用法示例。
在下文中一共展示了CMSDataContext.Setting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoWork
public void DoWork()
{
Db = DbUtil.Create(Host);
Db.CommandTimeout = 1200;
var noaddressok = Db.Setting("RequireAddressOnStatement", "true") == "false";
showCheckNo = Db.Setting("RequireCheckNoOnStatement", "false").ToLower() == "true";
showNotes = Db.Setting("RequireNotesOnStatement", "false").ToLower() == "true";
const bool UseMinAmt = true;
var qc = APIContribution.contributors(Db, fd, td, 0, 0, 0, noaddressok, UseMinAmt, StartsWith, Sort, tagid: TagId, excludeelectronic: ExcludeElectronic);
var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
runningtotals.Count = qc.Count();
Db.SubmitChanges();
if (showCheckNo || showNotes)
{
var c = new ContributionStatementsExtra
{
FromDate = fd,
ToDate = td,
typ = 3,
ShowCheckNo = showCheckNo,
ShowNotes = showNotes
};
using (var stream = new FileStream(OutputFile, FileMode.Create))
c.Run(stream, Db, qc);
LastSet = c.LastSet();
var sets = c.Sets();
foreach (var set in sets)
using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
c.Run(stream, Db, qc, set);
runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
runningtotals.LastSet = LastSet;
runningtotals.Sets = string.Join(",", sets);
runningtotals.Completed = DateTime.Now;
Db.SubmitChanges();
}
else
{
var c = new ContributionStatements
{
FromDate = fd,
ToDate = td,
typ = 3
};
using (var stream = new FileStream(OutputFile, FileMode.Create))
c.Run(stream, Db, qc);
LastSet = c.LastSet();
var sets = c.Sets();
foreach (var set in sets)
using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
c.Run(stream, Db, qc, set);
runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
runningtotals.LastSet = LastSet;
runningtotals.Sets = string.Join(",", sets);
runningtotals.Completed = DateTime.Now;
Db.SubmitChanges();
}
}
示例2: DoAllGiving
public static int DoAllGiving(CMSDataContext Db)
{
var gateway = Db.Setting("TransactionGateway", "");
int count = 0;
if (gateway.HasValue())
{
var q = from rg in Db.ManagedGivings
where rg.NextDate < Util.Now.Date
//where rg.PeopleId == 819918
select rg;
foreach (var rg in q)
rg.NextDate = rg.FindNextDate(Util.Now.Date);
var rgq = from rg in Db.ManagedGivings
where rg.NextDate == Util.Now.Date
select new
{
rg,
rg.Person,
rg.Person.RecurringAmounts,
};
foreach (var i in rgq)
count += i.rg.DoGiving(Db);
}
return count;
}
示例3: UploadAddressesModel
public UploadAddressesModel(CMSDataContext db, int peopleId)
{
this.db = db;
userpeopleid = peopleId;
var spec = db.Setting("NcoaColumns", "PeopleId=1,Addr1=4,Addr2=5,City=6,State=7,Zip=8,MoveDate=10");
NcoaCols = spec.Split(',').Select(vv => vv.Split('=')).ToDictionary(vv => vv[0], vv => vv[1].ToInt()-1);
}
示例4: SagePayments
public SagePayments(CMSDataContext Db, bool testing)
{
#if DEBUG2
testing = true;
#endif
this.Db = Db;
if (testing)
{
login = "287793447481";
key = "S4S3N4D2W1D9";
}
else
{
login = Db.Setting("M_id", "");
key = Db.Setting("M_key", "");
}
this.testing = testing;
}
示例5: Index
public ActionResult Index(int id)
{
var mm = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingId == id);
if (mm == null)
return Content("error: no meeting");
DbUtil.LogActivity("Delete meeting for {0}".Fmt(Session["ActiveOrganization"]));
var runningtotals = new DeleteMeetingRun
{
Started = DateTime.Now,
Count = mm.Attends.Count(a => a.EffAttendFlag == true || a.AttendanceFlag == true),
Processed = 0,
Meetingid = id
};
DbUtil.Db.DeleteMeetingRuns.InsertOnSubmit(runningtotals);
DbUtil.Db.SubmitChanges();
var host = Util.Host;
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
var Db = new CMSDataContext(Util.GetConnectionString(host));
var cul = Db.Setting("Culture", "en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
var meeting = Db.Meetings.SingleOrDefault(m => m.MeetingId == id);
var q = from a in Db.Attends
where a.MeetingId == id
where a.AttendanceFlag == true || a.EffAttendFlag == true
select a.PeopleId;
var list = q.ToList();
foreach (var pid in list)
{
Db.Dispose();
Db = new CMSDataContext(Util.GetConnectionString(host));
Attend.RecordAttendance(Db, pid, id, false);
var r = Db.DeleteMeetingRuns.Where(m => m.Meetingid == id).OrderByDescending(m => m.Id).First();
r.Processed++;
Db.SubmitChanges();
}
var rr = Db.DeleteMeetingRuns.Where(m => m.Meetingid == id).OrderByDescending(m => m.Id).First();
rr.Processed--;
Db.SubmitChanges();
Db.ExecuteCommand(
"delete dbo.SubRequest WHERE EXISTS(SELECT NULL FROM Attend a WHERE a.AttendId = AttendId AND a.MeetingId = {0})",
id);
Db.ExecuteCommand("DELETE dbo.VolRequest where MeetingId = {0}", id);
Db.ExecuteCommand("delete attend where MeetingId = {0}", id);
Db.ExecuteCommand("delete MeetingExtra where MeetingId = {0}", id);
Db.ExecuteCommand("delete meetings where MeetingId = {0}", id);
rr.Processed++;
rr.Completed = DateTime.Now;
Db.SubmitChanges();
});
return Redirect("/DeleteMeeting/Progress/" + id);
}
示例6: AuthorizeNet
public AuthorizeNet(CMSDataContext Db, bool testing)
{
#if DEBUG
testing = true;
#endif
this.Db = Db;
if (testing)
{
login = "9t8Pqzs4CW3S";
key = "9j33v58nuZB865WR";
url = testurl;
}
else
{
login = Db.Setting("x_login", "");
key = Db.Setting("x_tran_key", "");
url = produrl;
}
}
示例7: CanVoid
public bool CanVoid(CMSDataContext db)
{
if (!Util.IsSage.HasValue)
Util.IsSage = db.Setting("TransactionGateway", "").ToLower() == "sage";
return Approved == true
&& !CanCredit(db)
&& Util.IsSage.Value
&& Voided != true
&& Credited != true
&& (Coupon ?? false) == false
&& TransactionId.HasValue()
&& Amt > 0;
}
示例8: Start
public ActionResult Start(int tag, int orgid, bool pending = false, bool prospect = false)
{
var runningtotals = new AddToOrgFromTagRun
{
Started = DateTime.Now,
Count = 0,
Processed = 0,
Orgid = orgid
};
DbUtil.Db.AddToOrgFromTagRuns.InsertOnSubmit(runningtotals);
DbUtil.Db.SubmitChanges();
var host = Util.Host;
var qid = DbUtil.Db.FetchLastQuery().Id;
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
var Db = new CMSDataContext(Util.GetConnectionString(host));
var cul = Db.Setting("Culture", "en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
IEnumerable<int> q = null;
if (tag == -1) // (last query)
q = Db.PeopleQuery(qid).Select(pp => pp.PeopleId);
else
q = from t in Db.TagPeople
where t.Id == tag
select t.PeopleId;
var pids = q.ToList();
foreach (var pid in pids)
{
Db.Dispose();
Db = new CMSDataContext(Util.GetConnectionString(host));
OrganizationMember.InsertOrgMembers(Db, orgid, pid,
prospect ? MemberTypeCode.Prospect : MemberTypeCode.Member,
DateTime.Now, null, pending);
var r = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == orgid).OrderByDescending(mm => mm.Id).First();
r.Processed++;
r.Count = pids.Count;
Db.SubmitChanges();
}
var rr = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == orgid).OrderByDescending(mm => mm.Id).First();
rr.Completed = DateTime.Now;
Db.SubmitChanges();
Db.UpdateMainFellowship(orgid);
});
return Redirect("/AddToOrgFromTag/Progress/" + orgid);
}
示例9: 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;
}
}
示例10: AddNewPerson
public static void AddNewPerson(CMSDataContext Db, int newpersonid)
{
var newPeopleManagerId = Db.NewPeopleManagerId;
if (Db.Setting("NoNewPersonTasks") || newPeopleManagerId == 0)
return;
var task = new Task
{
ListId = GetRequiredTaskList(Db, "InBox", newPeopleManagerId).Id,
OwnerId = newPeopleManagerId,
Description = "New Person Data Entry",
WhoId = newpersonid,
StatusId = TaskStatusCode.Active,
};
if (Util.UserPeopleId.HasValue && Util.UserPeopleId.Value != newPeopleManagerId)
{
task.CoOwnerId = Util.UserPeopleId.Value;
task.CoListId = GetRequiredTaskList(Db, "InBox", Util.UserPeopleId.Value).Id;
}
Db.Tasks.InsertOnSubmit(task);
Db.SubmitChanges();
}
示例11: SetTagString
public void SetTagString(CMSDataContext db, string value)
{
if (!value.HasValue())
{
db.DivOrgs.DeleteAllOnSubmit(DivOrgs);
return;
}
var a = value.Split(',');
var qdelete = from d in DivOrgs
where !a.Contains(d.Division.Name)
select d;
db.DivOrgs.DeleteAllOnSubmit(qdelete);
var q = from s in a
join d2 in DivOrgs on s equals d2.Division.Name into g
from d in g.DefaultIfEmpty()
where d == null
select s;
foreach (var s in q)
{
var div = db.Divisions.FirstOrDefault(d => d.Name == s);
if (div == null)
{
div = new Division { Name = s };
string misctags = db.Setting("MiscTagsString", "Misc Tags");
var prog = db.Programs.SingleOrDefault(p => p.Name == misctags);
if (prog == null)
{
prog = new Program { Name = misctags };
db.Programs.InsertOnSubmit(prog);
}
div.Program = prog;
}
DivOrgs.Add(new DivOrg { Division = div });
}
tagString = value;
}
示例12: Add
public static Person Add(CMSDataContext Db, bool SendNotices, Family fam, int position, Tag tag, string firstname, string nickname, string lastname, string dob, int MarriedCode, int gender, int originId, int? EntryPointId, bool testing = false)
{
var p = new Person();
p.CreatedDate = Util.Now;
p.CreatedBy = Util.UserId;
Db.People.InsertOnSubmit(p);
p.PositionInFamilyId = position;
p.AddressTypeId = 10;
if (Util.HasValue(firstname))
p.FirstName = firstname.Trim().ToProper().Truncate(25);
else
p.FirstName = "";
if (Util.HasValue(nickname))
p.NickName = nickname.Trim().ToProper().Truncate(15);
if (Util.HasValue(lastname))
p.LastName = lastname.Trim().ToProper().Truncate(30);
else
p.LastName = "?";
p.GenderId = gender;
if (p.GenderId == 99)
p.GenderId = 0;
p.MaritalStatusId = MarriedCode;
DateTime dt;
if (Util.BirthDateValid(dob, out dt))
{
if (dt.Year == Util.SignalNoYear)
{
p.BirthDay = dt.Day;
p.BirthMonth = dt.Month;
p.BirthYear = null;
}
else
{
while (dt.Year < 1900)
dt = dt.AddYears(100);
if (dt > Util.Now)
dt = dt.AddYears(-100);
p.BirthDay = dt.Day;
p.BirthMonth = dt.Month;
p.BirthYear = dt.Year;
}
if (p.GetAge() < 18 && MarriedCode == 0)
p.MaritalStatusId = MaritalStatusCode.Single;
}
// I think this else statement is no longer necessary
else if (DateTime.TryParse(dob, out dt))
{
p.BirthDay = dt.Day;
p.BirthMonth = dt.Month;
if (Regex.IsMatch(dob, @"\d+[-/]\d+[-/]\d+"))
{
p.BirthYear = dt.Year;
while (p.BirthYear < 1900)
p.BirthYear += 100;
if (p.GetAge() < 18 && MarriedCode == 0)
p.MaritalStatusId = MaritalStatusCode.Single;
}
}
p.MemberStatusId = MemberStatusCode.JustAdded;
if (fam == null)
{
fam = new Family();
Db.Families.InsertOnSubmit(fam);
p.Family = fam;
}
else
fam.People.Add(p);
if (tag != null)
tag.PersonTags.Add(new TagPerson { Person = p });
p.OriginId = originId;
p.EntryPointId = EntryPointId;
p.FixTitle();
if(Db.Setting("ElectronicStatementDefault", "false").Equal("true"))
p.ElectronicStatement = true;
if (!testing)
Db.SubmitChanges();
if (SendNotices)
{
if (Util.UserPeopleId.HasValue
&& Util.UserPeopleId.Value != Db.NewPeopleManagerId
&& HttpContext.Current.User.IsInRole("Access")
&& !HttpContext.Current.User.IsInRole("OrgMembersOnly")
&& !HttpContext.Current.User.IsInRole("OrgLeadersOnly"))
Task.AddNewPerson(Db, p.PeopleId);
else
{
var np = Db.GetNewPeopleManagers();
if (np != null)
Db.Email(Util.SysFromEmail, np,
$"Just Added Person on {Db.Host}",
$"<a href='{Db.ServerLink("/Person2/" + p.PeopleId)}'>{p.Name}</a>");
}
//.........这里部分代码省略.........
示例13: PostUnattendedContribution
public Contribution PostUnattendedContribution(CMSDataContext Db, decimal Amt, int? Fund, string Description, bool pledge = false, int? typecode = null, int? tranid = null)
{
if (!typecode.HasValue)
{
typecode = BundleTypeCode.Online;
if (pledge)
typecode = BundleTypeCode.OnlinePledge;
}
var now = Util.Now;
var d = now.Date;
BundleHeader bundle = null;
var spec = Db.Setting("OnlineContributionBundleDayTime", "");
if (Util.HasValue(spec))
{
var a = spec.SplitStr(" ", 2);
try
{
var next = DateTime.Parse(now.ToShortDateString() + " " + a[1]);
var dow = Enum.Parse(typeof(DayOfWeek), a[0], ignoreCase: true);
next = next.Sunday().Add(next.TimeOfDay).AddDays(dow.ToInt());
if(now > next)
next = next.AddDays(7);
var prev = next.AddDays(-7);
var bid = BundleTypeCode.MissionTrip == typecode
? Db.GetCurrentMissionTripBundle(next, prev)
: Db.GetCurrentOnlineBundle(next, prev);
bundle = Db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid);
}
catch (Exception)
{
spec = "";
}
}
if(!Util.HasValue(spec))
{
var nextd = d.AddDays(1);
var bid = BundleTypeCode.MissionTrip == typecode
? Db.GetCurrentMissionTripBundle(nextd, d)
: Db.GetCurrentOnlineBundle(nextd, d);
bundle = Db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid);
}
if (bundle == null)
{
bundle = new BundleHeader
{
BundleHeaderTypeId = typecode.Value,
BundleStatusId = BundleStatusCode.Open,
CreatedBy = Util.UserId1,
ContributionDate = d,
CreatedDate = now,
FundId = Db.Setting("DefaultFundId", "1").ToInt(),
RecordStatus = false,
TotalCash = 0,
TotalChecks = 0,
TotalEnvelopes = 0,
BundleTotal = 0
};
Db.BundleHeaders.InsertOnSubmit(bundle);
}
if (!Fund.HasValue)
Fund = Db.Setting("DefaultFundId", "1").ToInt();
var fundtouse = (from f in Db.ContributionFunds
where f.FundId == Fund
select f).SingleOrDefault();
//failsafe if fund is not found
if(fundtouse == null)
Fund = (from f in Db.ContributionFunds
where f.FundStatusId == 1
orderby f.FundId
select f.FundId).First();
var FinanceManagerId = Db.Setting("FinanceManagerId", "").ToInt2();
if (!FinanceManagerId.HasValue)
{
var qu = from u in Db.Users
where u.UserRoles.Any(ur => ur.Role.RoleName == "Finance")
orderby u.Person.LastName
select u.UserId;
FinanceManagerId = qu.FirstOrDefault();
if (!FinanceManagerId.HasValue)
FinanceManagerId = 1;
}
var bd = new BundleDetail
{
BundleHeaderId = bundle.BundleHeaderId,
CreatedBy = FinanceManagerId.Value,
CreatedDate = now,
};
var typid = ContributionTypeCode.CheckCash;
if (pledge)
typid = ContributionTypeCode.Pledge;
bd.Contribution = new Contribution
{
CreatedBy = FinanceManagerId.Value,
CreatedDate = bd.CreatedDate,
FundId = Fund.Value,
PeopleId = PeopleId,
//.........这里部分代码省略.........
示例14: SendNow
public ActionResult SendNow(int id)
{
string host = Util.Host;
// save these from HttpContext to set again inside thread local storage
var useremail = Util.UserEmail;
var isinroleemailtest = User.IsInRole("EmailTest");
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
try
{
var Db = new CMSDataContext(Util.GetConnectionString(host));
Db.Host = host;
var cul = Db.Setting("Culture", "en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
// set these again inside thread local storage
Util.UserEmail = useremail;
Util.IsInRoleEmailTest = isinroleemailtest;
Db.SendPeopleEmail(id);
}
catch (Exception ex)
{
var ex2 = new Exception("Emailing error for queueid " + id, ex);
ErrorLog errorLog = ErrorLog.GetDefault(null);
errorLog.Log(new Error(ex2));
var Db = new CMSDataContext(Util.GetConnectionString(host));
Db.Host = host;
var equeue = Db.EmailQueues.Single(ee => ee.Id == id);
equeue.Error = ex.Message.Truncate(200);
Db.SubmitChanges();
}
});
return Redirect("/Manage/Emails/Details/" + id);
}
示例15: GetGateway
private IGateway GetGateway(CMSDataContext db, PaymentInfo pi)
{
var tempgateway = db.Setting("TemporaryGateway", "");
if (!tempgateway.HasValue())
return db.Gateway();
var gateway = db.Setting("TransactionGateway", "");
switch (gateway.ToLower()) // Check to see if standard gateway is set up
{
case "sage":
if ((pi.PreferredGivingType == "B" && pi.SageBankGuid.HasValue) ||
(pi.PreferredGivingType == "C" && pi.SageCardGuid.HasValue))
return db.Gateway();
break;
case "transnational":
if ((pi.PreferredGivingType == "B" && pi.TbnBankVaultId.HasValue) ||
(pi.PreferredGivingType == "C" && pi.TbnCardVaultId.HasValue))
return db.Gateway();
break;
}
// fall back to temporary gateway because the user hasn't migrated their payments off of the temporary gateway yet
return db.Gateway(usegateway: tempgateway);
}