本文整理汇总了C#中CmsData.CMSDataContext.LoadPersonById方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.LoadPersonById方法的具体用法?C# CMSDataContext.LoadPersonById怎么用?C# CMSDataContext.LoadPersonById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsData.CMSDataContext
的用法示例。
在下文中一共展示了CMSDataContext.LoadPersonById方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterHelpers
public static void RegisterHelpers(CMSDataContext db)
{
Handlebars.RegisterHelper("BottomBorder", (writer, context, args) => { writer.Write(CssStyle.BottomBorder); });
Handlebars.RegisterHelper("AlignTop", (writer, context, args) => { writer.Write(CssStyle.AlignTop); });
Handlebars.RegisterHelper("AlignRight", (writer, context, args) => { writer.Write(CssStyle.AlignRight); });
Handlebars.RegisterHelper("DataLabelStyle", (writer, context, args) => { writer.Write(CssStyle.DataLabelStyle); });
Handlebars.RegisterHelper("LabelStyle", (writer, context, args) => { writer.Write(CssStyle.LabelStyle); });
Handlebars.RegisterHelper("DataStyle", (writer, context, args) => { writer.Write(CssStyle.DataStyle); });
Handlebars.RegisterHelper("ServerLink", (writer, context, args) => { writer.Write(db.ServerLink().TrimEnd('/')); });
Handlebars.RegisterHelper("FmtZip", (writer, context, args) => { writer.Write(args[0].ToString().FmtZip()); });
Handlebars.RegisterHelper("IfEqual", (writer, options, context, args) =>
{
if (IsEqual(args))
options.Template(writer, (object)context);
else
options.Inverse(writer, (object)context);
});
Handlebars.RegisterHelper("IfNotEqual", (writer, options, context, args) =>
{
if (!IsEqual(args))
options.Template(writer, (object)context);
else
options.Inverse(writer, (object)context);
});
Handlebars.RegisterHelper("GetToken", (writer, context, args) =>
{
var s = args[0].ToString();
var n = args[1].ToInt();
var ntoks = args.Length > 2 ? args[2].ToInt() : 2;
var sep = args.Length > 3 ? args[3].ToString() : " ";
var a = s.SplitStr(sep, ntoks);
writer.Write(a[n].trim());
});
// Format helper in form of: {{Fmt value "fmt"}}
// ex. {{Fmt Total "C"}}
// fmt is required. Uses standard/custom dotnet format strings
Handlebars.RegisterHelper("Fmt", (writer, context, args) =>
{
var fmt = $"{{0:{args[1]}}}";
writer.Write(fmt, args[0]);
});
// FmtPhone helper in form of: {{FmtPhone phone# "prefix"}}
Handlebars.RegisterHelper("FmtPhone", (writer, context, args) => { writer.Write(args[0].ToString().FmtFone($"{args[1]}")); });
Handlebars.RegisterHelper("ReplaceCode", (writer, context, args) =>
{
EmailReplacements r = context.Replacements as EmailReplacements
?? (context.Replacements = new EmailReplacements(db));
var code = args[0].ToString();
var p = db.LoadPersonById(args[1].ToInt());
int? oid = null;
if(args.Length == 3)
oid = args[2].ToInt2();
writer.Write(r.RenderCode(code, p, oid));
});
}
示例2: CreateUser
public static User CreateUser(CMSDataContext db, int peopleId)
{
var p = db.LoadPersonById(peopleId);
var uname = FetchUsername(db, p.PreferredName, p.LastName);
var pword = Guid.NewGuid().ToString();
CMSMembershipProvider.provider.AdminOverride = true;
var user = CMSMembershipProvider.provider.NewUser(
uname,
pword,
null,
true,
peopleId);
CMSMembershipProvider.provider.AdminOverride = false;
return user;
}
示例3: CanViewStatementFor
public bool CanViewStatementFor(CMSDataContext Db, int id)
{
bool canview = Util.UserPeopleId == id || HttpContext.Current.User.IsInRole("Finance");
if (!canview)
{
var p = Db.CurrentUserPerson;
if (p.SpouseId == id)
{
var sp = Db.LoadPersonById(id);
if ((p.ContributionOptionsId ?? StatementOptionCode.Joint) == StatementOptionCode.Joint &&
(sp.ContributionOptionsId ?? StatementOptionCode.Joint) == StatementOptionCode.Joint)
canview = true;
}
}
return canview;
}
示例4: AddRelated
public RelatedFamily AddRelated(CMSDataContext db, int pid)
{
var p2 = db.LoadPersonById(pid);
var rf = db.RelatedFamilies.SingleOrDefault(r =>
(r.FamilyId == FamilyId && r.RelatedFamilyId == p2.FamilyId)
|| (r.FamilyId == p2.FamilyId && r.RelatedFamilyId == FamilyId)
);
if (rf == null)
{
rf = new RelatedFamily
{
FamilyId = FamilyId,
RelatedFamilyId = p2.FamilyId,
FamilyRelationshipDesc = "",
CreatedBy = Util.UserId1,
CreatedDate = Util.Now,
};
db.RelatedFamilies.InsertOnSubmit(rf);
db.SubmitChanges();
}
return rf;
}
示例5: DropMemberships
//.........这里部分代码省略.........
// case DecisionCode.Statement:
// if (NewMemberClassStatusIdChanged)
// if (DiscClassStatusCompletedCodes.Contains(NewMemberClassStatusId ?? 0))
// {
// MemberStatusId = MemberStatusCode.Member;
// JoinCodeId = JoinTypeCode.Statement;
// JoinDate = NewMemberClassDate.HasValue ? NewMemberClassDate : DecisionDate;
// }
// break;
// case DecisionCode.StatementReqBaptism:
// if (DiscClassStatusCompletedCodes.Contains(NewMemberClassStatusId ?? 0)
// && BaptismStatusId == BaptismStatusCode.Completed)
// {
// MemberStatusId = MemberStatusCode.Member;
// JoinCodeId = JoinTypeCode.BaptismSRB;
// if (NewMemberClassDate.HasValue)
// JoinDate = NewMemberClassDate.Value > BaptismDate.Value ?
// NewMemberClassDate.Value : BaptismDate.Value;
// else
// JoinDate = BaptismDate;
// }
// break;
// }
// if (DeceasedDateChanged)
// {
// if (DeceasedDate.HasValue)
// DeceasePerson(Db);
// }
// else if (DropCodeIdChanged)
// {
// switch (DropCodeId)
// {
// case DropTypeCode.Administrative:
// DropMembership(Db);
// break;
// case DropTypeCode.AnotherDenomination:
// DropMembership(Db);
// break;
// case DropTypeCode.Duplicate:
// DropMembership(Db);
// MemberStatusId = MemberStatusCode.NotMember;
// break;
// case DropTypeCode.LetteredOut:
// DropMembership(Db);
// break;
// case DropTypeCode.Other:
// DropMembership(Db);
// break;
// case DropTypeCode.Requested:
// DropMembership(Db);
// break;
// }
// }
// if (NewMemberClassStatusIdChanged
// && NewMemberClassStatusId == NewMemberClassStatusCode.Attended)
// {
// var q = from om in Db.OrganizationMembers
// where om.PeopleId == PeopleId
// where om.Organization.OrganizationName == "Step 1"
// select om;
// foreach (var om in q)
// om.Drop(Db, addToHistory: true);
// }
//}
public void DropMemberships(CMSDataContext Db)
{
if (MemberStatusId == MemberStatusCode.Member)
{
if (Deceased)
DropCodeId = DropTypeCode.Deceased;
MemberStatusId = MemberStatusCode.Previous;
DropDate = Util.Now.Date;
}
if (Deceased)
{
EmailAddress = null;
DoNotCallFlag = true;
DoNotMailFlag = true;
DoNotVisitFlag = true;
}
if (SpouseId.HasValue)
{
var spouse = Db.LoadPersonById(SpouseId.Value);
if (Deceased)
{
spouse.MaritalStatusId = MaritalStatusCode.Widowed;
if (spouse.EnvelopeOptionsId.HasValue)
if (spouse.EnvelopeOptionsId != StatementOptionCode.None)
spouse.EnvelopeOptionsId = StatementOptionCode.Individual;
spouse.ContributionOptionsId = StatementOptionCode.Individual;
}
if (spouse.MemberStatusId == MemberStatusCode.Member)
if (spouse.EnvelopeOptionsId == StatementOptionCode.Joint)
spouse.EnvelopeOptionsId = StatementOptionCode.Individual;
}
EnvelopeOptionsId = StatementOptionCode.None;
DropAllMemberships(Db);
}
示例6: UpdatePeople
private static void UpdatePeople(DbConnection cn, CMSDataContext Db, int userPeopleId)
{
var cv = new CodeValueModel();
var pcmd = cn.CreateCommand();
pcmd.CommandText = "select * from [Sheet1$]";
var rd = pcmd.ExecuteReader();
while (rd.Read())
{
var i = Util.GetAs(rd, typeof(UpdatePeopleItem)) as UpdatePeopleItem;
var p = Db.LoadPersonById(i.PeopleId);
//var psb = new StringBuilder();
var psb = new List<ChangeDetail>();
p.UpdateValue(psb, "TitleCode", i.Title);
p.UpdateValue(psb, "FirstName", i.First);
p.UpdateValue(psb, "NickName", i.GoesBy);
p.UpdateValue(psb, "LastName", i.Last);
p.UpdateValue(psb, "SuffixCode", i.Suffix);
p.UpdateValue(psb, "EmailAddress", i.Email1);
p.UpdateValue(psb, "EmailAddress2", i.Email2);
p.UpdateValue(psb, "DOB", i.BirthDate.FormatDate());
p.UpdateValue(psb, "WeddingDate", i.Anniversary);
p.UpdateValue(psb, "JoinDate", i.Joined);
p.UpdateValue(psb, "CellPhone", i.Cell.GetDigits());
p.UpdateValue(psb, "WorkPhone", i.Work.GetDigits());
p.UpdateValue(psb, "AltName", i.AltName);
p.UpdateValue(psb, "SchoolOther", i.School);
p.UpdateValue(psb, "OccupationOther", i.Occupation);
p.UpdateValue(psb, "EmployerOther", i.Employer);
p.UpdateValue(psb, "Grade", i.Grade);
p.UpdateValue(psb, "DeceasedDate", i.Deceased);
p.UpdateValue(psb, "MemberStatusId", CviOrNull(cv.MemberStatusCodes().SingleOrDefault(c => c.Value == i.Member)) ?? 20);
p.UpdateValue(psb, "GenderId", CviOrNull(cv.GenderCodes().SingleOrDefault(c => c.Value == i.Gender)) ?? 0);
p.UpdateValue(psb, "MaritalStatusId", CviOrNull(cv.MaritalStatusCodes().SingleOrDefault(c => c.Value == i.Marital)) ?? 0);
p.UpdateValue(psb, "PositionInFamilyId", CviOrNull(cv.FamilyPositionCodes().SingleOrDefault(c => c.Value == i.FamilyPos)) ?? 0);
p.UpdateValue(psb, "CampusId", CviOrNull(cv.AllCampuses().SingleOrDefault(c => c.Value == i.Campus)));
p.LogChanges(Db, psb);
Db.SubmitChanges();
}
}
示例7: 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();
});
}
示例8: DoReplacements
// this will run replacements in a new dataContext
//
public string DoReplacements(int pid, EmailQueueTo emailqueueto)
{
using (db = CMSDataContext.Create(connStr, host))
{
if (currentOrgId.HasValue)
db.SetCurrentOrgId(currentOrgId);
var p = db.LoadPersonById(pid);
person = p;
var pi = emailqueueto.OrgId.HasValue
? (from m in db.OrganizationMembers
let ts = db.ViewTransactionSummaries.SingleOrDefault(tt => tt.RegId == m.TranId && tt.PeopleId == m.PeopleId)
where m.PeopleId == emailqueueto.PeopleId && m.OrganizationId == emailqueueto.OrgId
select new PayInfo
{
PayLink = m.PayLink2(db),
Amount = ts.IndAmt,
AmountPaid = ts.IndPaid,
AmountDue = ts.IndDue,
RegisterMail = m.RegisterEmail
}).SingleOrDefault()
: null;
var aa = db.GetAddressList(p);
if (emailqueueto.EmailQueue.CCParents ?? false)
aa.AddRange(db.GetCcList(p, emailqueueto));
if (emailqueueto.AddEmail.HasValue())
foreach (var ad in emailqueueto.AddEmail.SplitStr(","))
Util.AddGoodAddress(aa, ad);
if (emailqueueto.OrgId.HasValue && pi != null)
Util.AddGoodAddress(aa, Util.FullEmail(pi.RegisterMail, p.Name));
ListAddresses = aa.DistinctEmails();
var noreplacements = emailqueueto.EmailQueue.NoReplacements ?? false;
var texta = new List<string>(stringlist);
for (var i = 1; i < texta.Count; i += 2)
if (noreplacements)
texta[i] = "";
else
texta[i] = DoReplaceCode(texta[i], p, pi, emailqueueto);
db.SubmitChanges();
return string.Join("", texta);
}
}
示例9: RecordAttend
public static void RecordAttend(CMSDataContext Db, int PeopleId, int OrgId, bool Present, DateTime dt)
{
var q = from o in Db.Organizations
where o.OrganizationId == OrgId
let p = Db.People.Single(pp => pp.PeopleId == PeopleId)
select new
{
o.Location,
OrgEntryPoint = o.EntryPointId,
p.EntryPointId,
};
var info = q.Single();
if (info.EntryPointId == null)
{
var p = Db.LoadPersonById(PeopleId);
if (info.OrgEntryPoint > 0)
{
p.EntryPointId = info.OrgEntryPoint;
Db.SubmitChanges();
}
}
int ntries = 6;
while (true)
{
try
{
Db.RecordAttendance(OrgId, PeopleId, dt, Present, info.Location);
return;
}
catch (SqlException ex)
{
if (ex.Number == 1205)
if (--ntries > 0)
{
System.Threading.Thread.Sleep(500);
continue;
}
throw;
}
}
}
示例10: DoReplacements
// this will run replacements in a new dataContext
//
public string DoReplacements(int pid, EmailQueueTo emailqueueto)
{
using (db = CMSDataContext.Create(connStr, host))
{
if (currentOrgId.HasValue)
db.SetCurrentOrgId(currentOrgId);
var p = db.LoadPersonById(pid);
person = p;
var pi = emailqueueto.OrgId.HasValue
? (from m in db.OrganizationMembers
let ts = db.ViewTransactionSummaries.SingleOrDefault(tt => tt.RegId == m.TranId && tt.PeopleId == m.PeopleId)
where m.PeopleId == emailqueueto.PeopleId && m.OrganizationId == emailqueueto.OrgId
select new PayInfo
{
PayLink = m.PayLink2(db),
Amount = ts.IndAmt,
AmountPaid = ts.IndPaid,
AmountDue = ts.IndDue,
RegisterMail = m.RegisterEmail
}).SingleOrDefault()
: null;
var aa = db.GetAddressList(p);
if (emailqueueto.EmailQueue.FinanceOnly == true)
{
var contributionemail = (from ex in db.PeopleExtras
where ex.PeopleId == p.PeopleId
where ex.Field == "ContributionEmail"
select ex.Data).SingleOrDefault();
if (contributionemail.HasValue())
contributionemail = contributionemail.trim();
if (!Util.ValidEmail(contributionemail))
contributionemail = p.FromEmail;
aa.Clear();
aa.Add(Util.TryGetMailAddress(contributionemail));
}
if (OptOuts != null && emailqueueto.EmailQueue.CCParents == true)
{
var pp = OptOuts.SingleOrDefault(vv => vv.PeopleId == emailqueueto.PeopleId);
if(pp != null)
{
if (pp.HhPeopleId.HasValue && Util.ValidEmail(pp.HhEmail))
{
aa.Add(new MailAddress(pp.HhEmail, pp.HhName));
emailqueueto.Parent1 = pp.HhPeopleId;
}
if (pp.HhSpPeopleId.HasValue && Util.ValidEmail(pp.HhSpEmail))
{
aa.Add(new MailAddress(pp.HhSpEmail, pp.HhSpName));
emailqueueto.Parent2 = pp.HhSpPeopleId;
}
}
}
if (emailqueueto.AddEmail.HasValue())
foreach (var ad in emailqueueto.AddEmail.SplitStr(","))
Util.AddGoodAddress(aa, ad);
if (emailqueueto.OrgId.HasValue && pi != null)
Util.AddGoodAddress(aa, Util.FullEmail(pi.RegisterMail, p.Name));
ListAddresses = aa.DistinctEmails();
var noreplacements = emailqueueto.EmailQueue.NoReplacements ?? false;
var texta = new List<string>(stringlist);
for (var i = 1; i < texta.Count; i += 2)
if (noreplacements && !texta[i].StartsWith("<style"))
texta[i] = "";
else
texta[i] = DoReplaceCode(texta[i], p, pi, emailqueueto);
db.SubmitChanges();
return string.Join("", texta);
}
}
示例11: UpdateElectronicStatement
public void UpdateElectronicStatement(CMSDataContext db, bool tf)
{
const string field = "ElectronicStatement";
UpdateValue(field, tf);
var sp = db.LoadPersonById(SpouseId ?? 0);
if (sp != null && ContributionOptionsId == StatementOptionCode.Joint)
{
sp.UpdateValue(field, tf);
sp.LogChanges(db);
}
LogChanges(db);
db.SubmitChanges();
}
示例12: UpdateOption
private void UpdateOption(CMSDataContext db, string field, int option)
{
int? opt = option;
if (opt == 0)
opt = null;
UpdateValue(field, opt);
LogChanges(db);
var sp = db.LoadPersonById(SpouseId ?? 0);
if (sp != null)
switch (opt)
{
case StatementOptionCode.Joint:
case StatementOptionCode.Individual:
case StatementOptionCode.None:
sp.UpdateValue(field, opt);
sp.LogChanges(db);
break;
case null:
if (sp.ContributionOptionsId == StatementOptionCode.Joint)
{
sp.UpdateValue(field, null);
sp.LogChanges(db);
}
break;
}
db.SubmitChanges();
}