public List <string> Keys(DynamicData metadata = null) { var keys = new List <string>(); if (metadata != null) { foreach (var k in metadata.dict) { var typ = k.Value.ToString(); var tok = typ.GetCsvToken(1, sep: " "); switch (tok) { case "hidden": case "special": case "readonly": continue; } keys.Add(k.Key); } return(keys); } foreach (var k in dict) { if (k.Value is DynamicData || k.Value is Array) { continue; } keys.Add(k.Key); } return(keys); }
public PythonEvents(string dbname, Dictionary<string, object> dict) { dictionary = dict; Data = new DynamicData(dictionary); db = DbUtil.Create(dbname); pythonPath = ConfigurationManager.AppSettings["pythonPath"]; pyrazorPath = ConfigurationManager.AppSettings["pyrazorPath"]; }
public List <string> SpecialKeys(DynamicData metadata) { var keys = new List <string>(); foreach (var k in metadata.dict) { if (k.Value.ToString().StartsWith("special ")) { keys.Add(k.Key); } } return(keys); }
public static void ConfirmDuePaidTransaction(Transaction ti, string transactionId, bool sendmail) { var db = DbUtil.Db; var org = db.LoadOrganizationById(ti.OrgId); ti.TransactionId = transactionId; if (ti.Testing == true && !ti.TransactionId.Contains("(testing)")) ti.TransactionId += "(testing)"; var amt = ti.Amt; var due = PaymentForm.AmountDueTrans(db, ti); foreach (var pi in ti.OriginalTrans.TransactionPeople) { var p = db.LoadPersonById(pi.PeopleId); if (p != null) { var om = db.OrganizationMembers.SingleOrDefault(m => m.OrganizationId == ti.OrgId && m.PeopleId == pi.PeopleId); if (om == null) continue; db.SubmitChanges(); if (org.IsMissionTrip == true) { db.GoerSenderAmounts.InsertOnSubmit( new GoerSenderAmount { Amount = ti.Amt, GoerId = pi.PeopleId, Created = DateTime.Now, OrgId = org.OrganizationId, SupporterId = pi.PeopleId, }); var setting = db.CreateRegistrationSettings(org.OrganizationId); var fund = setting.DonationFundId; p.PostUnattendedContribution(db, ti.Amt ?? 0, fund, $"SupportMissionTrip: org={org.OrganizationId}; goer={pi.PeopleId}", typecode: BundleTypeCode.Online); } var pay = amt; if (org.IsMissionTrip == true) ti.Amtdue = due; var sb = new StringBuilder(); sb.AppendFormat("{0:g} ----------\n", Util.Now); sb.AppendFormat("{0:c} ({1} id) transaction amount\n", ti.Amt, ti.Id); sb.AppendFormat("{0:c} applied to this registrant\n", pay); sb.AppendFormat("{0:c} total due all registrants\n", due); om.AddToMemberDataBelowComments(sb.ToString()); var reg = p.SetRecReg(); reg.AddToComments(sb.ToString()); reg.AddToComments($"{org.OrganizationName} ({org.OrganizationId})"); amt -= pay; } else db.Email(db.StaffEmailForOrg(org.OrganizationId), db.PeopleFromPidString(org.NotifyIds), "missing person on payment due", $"Cannot find {pi.Person.Name} ({pi.PeopleId}), payment due completed of {pi.Amt:c} but no record"); } db.SubmitChanges(); dynamic d = new DynamicData(); d.Name = Transaction.FullName(ti); d.Amt = ti.Amt; d.Description = ti.Description; d.Amtdue = PaymentForm.AmountDueTrans(db, ti); d.names = string.Join(", ", ti.OriginalTrans.TransactionPeople.Select(i => i.Person.Name)); var msg = DbUtil.Db.RenderTemplate(@" <p> Thank you {{Name}}, for your payment of {{Fmt Amt 'c'}} on {{Description}}.<br/> {{#if Amtdue}} Your balance is {{Fmt Amtdue 'c'}}<br/> {{/if}} {{names}} </p>", d); var msgstaff = DbUtil.Db.RenderTemplate(@" <p> {{Name}} paid {{Fmt Amt 'c'}} on {{Description}}.<br/> {{#if Amtdue}} The balance is {{Fmt Amtdue 'c'}}<br/> {{/if}} {{names}} </p>", d); var pid = ti.FirstTransactionPeopleId(); var p0 = db.LoadPersonById(pid); // question: should we be sending to all TransactionPeople? if (sendmail) { if (p0 == null) db.SendEmail(Util.TryGetMailAddress(db.StaffEmailForOrg(org.OrganizationId)), "Payment confirmation", msg, Util.ToMailAddressList(Util.FirstAddress(ti.Emails)), pid: pid).Wait(); else { db.Email(db.StaffEmailForOrg(org.OrganizationId), p0, Util.ToMailAddressList(ti.Emails), "Payment confirmation", msg, false); db.Email(p0.FromEmail, db.PeopleFromPidString(org.NotifyIds), "payment received for " + ti.Description, msgstaff); } } }
public PythonModel(string dbname, Dictionary<string, object> dict) { dictionary = dict; Data = new DynamicData(dictionary); db = DbUtil.Create(dbname); }