public static List<Value> GetStandardExtraValues(CMSDataContext db, string table, bool nocache = false) { return (from vv in GetViews(db, nocache).List where vv.Table == table from v in vv.Values select v).ToList(); }
public void Add(CMSDataContext db) { var fields = Views.GetStandardExtraValues(db, Table); const string defaultCodes = @" Option 1 Option 2 "; var codes = Type == "Bits" ? Checkboxes : Type == "Code" ? Codes ?? defaultCodes : null; var a = codes.SplitLines(noblanks: true).Select(ss => BitPrefix + ss).ToList(); var v = new Value { Type = Type, Name = Name, VisibilityRoles = VisibilityRoles, Codes = a, //Link = HttpUtility.HtmlEncode(ExtraValueLink) }; var i = Views.GetViewsView(db, Table, Location); i.view.Values.Add(v); i.views.Save(db); }
public static OnlineRegPersonModel0 CreateFromSettings(CMSDataContext db, int orgid) { var m = new OnlineRegPersonModel0(null, db); var settings = db.CreateRegistrationSettings(orgid); foreach (var ask in settings.AskItems) { switch (ask.Type) { case "AskExtraQuestions": var eq = (AskExtraQuestions)ask; if(eq.UniqueId >= m.ExtraQuestion.Count) m.ExtraQuestion.Add(new Dictionary<string, string>()); foreach (var q in eq.list) m.ExtraQuestion[eq.UniqueId][q.Question] = ""; break; case "AskText": var tx = (AskText)ask; if(tx.UniqueId >= m.Text.Count) m.Text.Add(new Dictionary<string, string>()); foreach (var q in tx.list) m.Text[tx.UniqueId][q.Question] = ""; break; } } return m; }
public static IEnumerable<ContributionInfo> contributions(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in Db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId != ContributionTypeCode.GiftInKind where c.ContributionTypeId != ContributionTypeCode.Stock where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate where c.ContributionDate.Value.Date <= toDate.Date where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where !(c.ContributionFund.NonTaxDeductible ?? false) where !ContributionTypeCode.NonTaxTypes.Contains(c.ContributionTypeId) orderby c.ContributionDate select new ContributionInfo { ContributionId = c.ContributionId, ContributionAmount = c.ContributionAmount ?? 0, ContributionDate = c.ContributionDate ?? SqlDateTime.MinValue.Value, Fund = c.ContributionFund.FundName, CheckNo = c.CheckNo, Name = c.Person.Name, Description = c.ContributionDesc }; return q; }
public static void DeleteSession(CMSDataContext db, User user) { var apiSession = user.ApiSessions.SingleOrDefault(); if (apiSession == null) return; db.ApiSessions.DeleteOnSubmit(apiSession); db.SubmitChanges(); }
public static Views GetViews(CMSDataContext db, bool nocache = false) { var xml = DbUtil.StandardExtraValues2(db, nocache); var f = Util.DeSerialize<Views>(xml); if (f == null) return new Views(); return f; }
public static Settings CreateSettings(string s, CMSDataContext db, Organization org) { var settings = !s.HasValue() ? new Settings() : Util.DeSerialize<Settings>(s); settings.Db = db; settings.OrgId = org.OrganizationId; settings.org = org; return settings; }
public static string MessageReplacements(CMSDataContext db, Person p, string DivisionName, string OrganizationName, string Location, string message) { message = message.Replace("{first}", p.PreferredName, ignoreCase: true); message = message.Replace("{name}", p.Name, ignoreCase: true); message = message.Replace("{division}", DivisionName, ignoreCase: true); message = message.Replace("{org}", OrganizationName, ignoreCase: true); message = message.Replace("{location}", Location, ignoreCase: true); message = message.Replace("{cmshost}", db.CmsHost, ignoreCase: true); return message; }
public bool UserCanView(CMSDataContext db) { if (db.FromBatch) return true; if (!VisibilityRoles.HasValue()) return true; var a = VisibilityRoles.SplitStr(","); var user = HttpContext.Current.User; return a.Any(role => user.IsInRole(role.Trim())); }
public static string MessageReplacements(CMSDataContext db, Person p, string divisionName, int orgId, string organizationName, string location, string message) { message = message.Replace("{first}", p.PreferredName, ignoreCase: true); message = message.Replace("{name}", p.Name, ignoreCase: true); message = message.Replace("{division}", divisionName, ignoreCase: true); message = message.Replace("{org}", organizationName, ignoreCase: true); message = message.Replace("{location}", location, ignoreCase: true); message = message.Replace("{cmshost}", db.CmsHost, ignoreCase: true); message = message.Replace("{orgbarcode}", $"{{orgbarcode:{orgId}}}"); return message; }
public static List<StandardValueNameType> GetViewableDataTypes(CMSDataContext db, bool nocache = false) { var list = (from vv in GetStandardExtraValues(db, "People", nocache) where vv.Type == "Data" select new StandardValueNameType() { Name = vv.Name, Type = vv.Type, CanView = vv.UserCanView(db) }).ToList(); return list; }
public BluePayGateway(CMSDataContext db, bool testing) { this.db = db; IsLive = !(testing || db.Setting("GatewayTesting")); _login = db.Setting("bluepay_accountId", ""); _key = db.Setting("bluepay_secretKey", ""); if (string.IsNullOrWhiteSpace(_login)) throw new Exception("bluepay_accountId setting not found, which is required for BluePay."); if (string.IsNullOrWhiteSpace(_key)) throw new Exception("bluepay_secretKey setting not found, which is required for BluePay."); }
public static Settings CreateSettings(string s, CMSDataContext db, int orgId) { if (s == null) s = ""; if (s.StartsWith("<?xml") || s.StartsWith("<Settings>")) { var settings = Util.DeSerialize<Settings>(s); settings.Db = db; settings.OrgId = orgId; settings.org = db.LoadOrganizationById(orgId); return settings; } return Parser.ParseSettings(s, db, orgId); }
public static ViewValue GetViewsViewValue(CMSDataContext db, string table, string name) { var views = GetViews(db, nocache: true); var i = from view in views.List where view.Table == table from value in view.Values where value.Name == name select new ViewValue { views = views, view = view, value = value }; return i.Single(); }
public SummaryInfo(CMSDataContext db, int pid, int oid) { this.db = db; OrgMember = OrganizationMember.Load(DbUtil.Db, pid, oid); if (!OrgMember.OnlineRegData.HasValue()) return; Person = new OnlineRegPersonModel0(); Person.ReadXml(OrgMember.OnlineRegData); Person.setting = DbUtil.Db.CreateRegistrationSettings(OrgMember.Organization.RegSettingXml, oid); Handlebars.RegisterHelper("Registrant", Registrant); Handlebars.RegisterHelper("IfShowTransaction", IfShowTransaction); Handlebars.RegisterHelper("IfSupportMissionTrip", IfSupportMissionTrip); Handlebars.RegisterHelper("AskItems", AskItems); Handlebars.RegisterHelper("IfAskAllergies", IfAskAllergies); Handlebars.RegisterHelper("IfAskCheckboxes", IfAskCheckboxes); Handlebars.RegisterHelper("IfAskCoaching", IfAskCoaching); Handlebars.RegisterHelper("IfAskChurch", IfAskChurch); Handlebars.RegisterHelper("IfAskDoctor", IfAskDoctor); Handlebars.RegisterHelper("IfAskDropdown", IfAskDropdown); Handlebars.RegisterHelper("IfAskEmContact", IfAskEmContact); Handlebars.RegisterHelper("IfAskExtraQuestions", IfAskExtraQuestions); Handlebars.RegisterHelper("IfAskGradeOptions", IfAskGradeOptions); Handlebars.RegisterHelper("IfAskHeader", IfAskHeader); Handlebars.RegisterHelper("IfAskInstruction", IfAskInstruction); Handlebars.RegisterHelper("IfAskInsurance", IfAskInsurance); Handlebars.RegisterHelper("IfAskMenu", IfAskMenu); Handlebars.RegisterHelper("IfAskParents", IfAskParents); Handlebars.RegisterHelper("IfAskRequest", IfAskRequest); Handlebars.RegisterHelper("IfAskSize", IfAskSize); Handlebars.RegisterHelper("IfAskSms", IfAskSms); Handlebars.RegisterHelper("IfAskTextQuestions", IfAskTextQuestions); Handlebars.RegisterHelper("IfAskTickets", IfAskTickets); Handlebars.RegisterHelper("IfAskTylenolEtc", IfAskTylenolEtc); Handlebars.RegisterHelper("IfAskYesNoQuestions", IfAskYesNoQuestions); Handlebars.RegisterHelper("IfHasAgeGroups", IfHasAgeGroups); Handlebars.RegisterHelper("MenuItems", MenuItems); Handlebars.RegisterHelper("Checkboxes", Checkboxes); Handlebars.RegisterHelper("TopLabel", (writer, context, args) => { writer.Write(TopLabel); }); Handlebars.RegisterHelper("BottomStyle", (writer, context, args) => { writer.Write(RowStyle); }); CssStyle.RegisterHelpers(db); }
public TransNationalGateway(CMSDataContext db, bool testing) { this.db = db; if(testing || db.Setting("GatewayTesting", "false").ToLower() == "true") { _userName = "******"; _password = "******"; } else { _userName = db.GetSetting("TNBUsername", ""); _password = db.GetSetting("TNBPassword", ""); if (string.IsNullOrWhiteSpace(_userName)) throw new Exception("TNBUsername setting not found, which is required for TransNational."); if (string.IsNullOrWhiteSpace(_password)) throw new Exception("TNBPassword setting not found, which is required for TransNational."); } }
public AuthorizeNetGateway(CMSDataContext db, bool testing) { this.db = db; IsLive = !(testing || db.Setting("GatewayTesting", "false").ToLower() == "true"); if (!IsLive) { _login = "******"; _key = "9wE4j7M372ehz6Fy"; } else { _login = db.GetSetting("x_login", ""); _key = db.GetSetting("x_tran_key", ""); if (string.IsNullOrWhiteSpace(_login)) throw new Exception("x_login setting not found, which is required for Authorize.net."); if (string.IsNullOrWhiteSpace(_key)) throw new Exception("x_tran_key setting not found, which is required for Authorize.net."); } }
public Settings(string s, CMSDataContext Db, int OrgId) : this() { this.Db = Db; this.OrgId = OrgId; org = Db.LoadOrganizationById(OrgId); var parser = new Parser(s); while (parser.NextSection()) ParseSection(parser); SetUniqueIds("AskDropdown"); SetUniqueIds("AskExtraQuestions"); SetUniqueIds("AskCheckboxes"); SetUniqueIds("AskMenu"); var sglist = new List<string>(); AskItems.ForEach(a => sglist.AddRange(a.SmallGroups())); var q = sglist.GroupBy(mi => mi).Where(g => g.Count() > 1).Select(g => g.Key).ToList(); if (q.Any()) throw parser.GetException("Duplicate SmallGroup: " + string.Join(",", q)); parser.data = null; }
public static List<StandardValueNameType> GetViewableNameTypes(CMSDataContext db, string table, bool nocache = false) { var list = (from vv in GetStandardExtraValues(db, table, nocache) where vv.Type != "Bits" select new StandardValueNameType() { Name = vv.Name, Type = vv.Type, CanView = vv.UserCanView(db) }).ToList(); var list2 = (from vv in GetStandardExtraValues(db, table, nocache) where vv.Type == "Bits" from v in vv.Codes select new StandardValueNameType() { Name = v, Type = vv.Type, CanView = vv.UserCanView(db) }).ToList(); return list.Union(list2).OrderBy(vv => vv.Name).ToList(); }
public SageGateway(CMSDataContext db, bool testing) { this.db = db; var gatewayTesting = db.Setting("GatewayTesting", "false").ToLower() == "true"; if (testing || gatewayTesting) { _id = "856423594649"; _key = "M5Q4C9P2T4N5"; _originatorId = "1111111111"; } else { _id = db.GetSetting("M_ID", ""); _key = db.GetSetting("M_KEY", ""); if (string.IsNullOrWhiteSpace(_id)) throw new Exception("M_ID setting not found, which is required for Sage."); if (string.IsNullOrWhiteSpace(_key)) throw new Exception("M_KEY setting not found, which is required for Sage."); _originatorId = db.Setting("SageOriginatorId", ""); } }
public QueryResults() : base("na", "asc") { Db = DbUtil.Db; }
public MeetingCategoryService(IRequestManager currentRequest) { _dataContext = currentRequest.CurrentDatabase; }
public APIContribution(CMSDataContext Db) { this.Db = Db; }
public static IEnumerable<ContributionInfo> GiftsInKind(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in Db.Contributions where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId == ContributionTypeCode.GiftInKind || c.ContributionTypeId == ContributionTypeCode.Stock where c.ContributionStatusId.Value != ContributionStatusCode.Reversed where c.ContributionDate >= fromDate where c.ContributionDate <= toDate orderby c.ContributionDate select new ContributionInfo { ContributionId = c.ContributionId, ContributionDate = c.ContributionDate ?? SqlDateTime.MinValue.Value, Fund = c.ContributionFund.FundName, Description = c.ContributionDesc }; return q; }
public APIPerson(CMSDataContext Db) { this.Db = Db; }
public static IEnumerable<ContributorInfo> contributors(CMSDataContext Db, DateTime fromDate, DateTime toDate, int PeopleId, int? SpouseId, int FamilyId, bool noaddressok, bool useMinAmt, string startswith = null, string sort = null, bool singleStatement = false, int? tagid = null, bool excludeelectronic = false) { var MinAmt = Db.Setting("MinContributionAmount", "5").ToDecimal(); if (!useMinAmt) MinAmt = 0; var endswith = ""; if (startswith != null && startswith.Contains("-")) { var a = startswith.SplitStr("-", 2); startswith = a[0]; endswith = a[1]; } var q = from p in Db.Contributors(fromDate, toDate, PeopleId, SpouseId, FamilyId, noaddressok, tagid) select p; if (startswith.HasValue() && !endswith.HasValue()) q = from p in q where p.LastName.StartsWith(startswith) select p; else if (startswith.HasValue() && endswith.HasValue()) q = from p in q // ReSharper disable StringCompareToIsCultureSpecific where (p.LastName.CompareTo(startswith) >= 0 && p.LastName.CompareTo(endswith) < 0) || SqlMethods.Like(p.LastName, endswith + "%") select p; if (sort == "zip") q = from p in q orderby p.PrimaryZip, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age select p; else if (sort == "name") q = from p in q orderby p.LastName, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age select p; else q = from p in q orderby p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age select p; if (singleStatement) { var familylist = q.ToList(); if (familylist.Any(m => m.DeceasedDate != null && m.ContributionOptionsId == 2)) return GetInfo(familylist); } const int NOTSPEC = 0; const int NONE = StatementOptionCode.None; const int JOINT = StatementOptionCode.Joint; const int INDIV = StatementOptionCode.Individual; if (MinAmt > 0) q = from p in q let option = (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? NOTSPEC) != INDIV ? JOINT : INDIV) : p.ContributionOptionsId where option != NONE || noaddressok where (option == INDIV && (p.Amount > MinAmt)) || (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > MinAmt)) where p.ElectronicStatement == false || excludeelectronic == false select p; else q = from p in q let option = (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != INDIV ? JOINT : INDIV) : p.ContributionOptionsId where option != NONE || noaddressok where p.ElectronicStatement == false || excludeelectronic == false where (option == INDIV && (p.Amount > 0 || p.GiftInKind == true)) // GiftInKind = NonTaxDeductible Fund or Pledge OR GiftInkind || (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > 0 || p.GiftInKind == true)) select p; IEnumerable<ContributorInfo> q2 = null; if (Db.Setting("NoTitlesOnStatements", "false").ToBool()) q2 = from p in q let option = (p.ContributionOptionsId ?? 0) == 0 ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != 1 ? 2 : 1) : p.ContributionOptionsId let name = option == 1 ? p.Name : (p.SpouseId == null ? p.Name : (p.HohFlag == 1 ? p.CoupleName ?? (p.Name + " and " + p.SpouseName) : p.CoupleName ?? (p.SpouseName + " and " + p.Name))) select new ContributorInfo { Name = name, MailingAddress = MailingAddress(p), PeopleId = p.PeopleId, SpouseID = p.SpouseId, DeacesedDate = p.DeceasedDate, FamilyId = p.FamilyId, Age = p.Age, FamilyPositionId = p.PositionInFamilyId, hohInd = p.HohFlag, Joint = option == 2, CampusId = p.CampusId, }; else q2 = GetInfo(q); return q2; }
public static IEnumerable<PledgeSummaryInfo> pledges(CMSDataContext Db, ContributorInfo ci, DateTime toDate) { var PledgeExcludes = new int[] { ContributionTypeCode.Reversed, }; var showPledgeIfMet = Db.Setting("ShowPledgeIfMet", "true").ToBool(); var qp = from p in Db.Contributions where p.PeopleId == ci.PeopleId || (ci.Joint && p.PeopleId == ci.SpouseID) where p.ContributionTypeId == ContributionTypeCode.Pledge where p.ContributionStatusId.Value != ContributionStatusCode.Reversed where p.ContributionFund.FundStatusId == 1 // active where p.ContributionDate <= toDate group p by p.FundId into g select new { FundId = g.Key, Fund = g.First().ContributionFund.FundName, Total = g.Sum(p => p.ContributionAmount) }; var qc = from c in Db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId != ContributionTypeCode.GiftInKind where !Codes.ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId != ContributionTypeCode.Pledge where c.ContributionStatusId != ContributionStatusCode.Reversed where c.ContributionDate <= toDate group c by c.FundId into g select new { FundId = g.Key, Total = g.Sum(c => c.ContributionAmount) }; var q = from p in qp join c in qc on p.FundId equals c.FundId into items from c in items.DefaultIfEmpty() where (p.Total ?? 0) > (c == null ? 0 : c.Total ?? 0) || showPledgeIfMet orderby p.FundId descending select new PledgeSummaryInfo { Fund = p.Fund, ContributionAmount = c.Total, PledgeAmount = p.Total }; return q; }
public static UserValidationResult AuthenticateLogon(string userName, string password, string url, CMSDataContext db) { var userQuery = db.Users.Where(uu => uu.Username == userName || uu.Person.EmailAddress == userName || uu.Person.EmailAddress2 == userName ); var impersonating = false; User user = null; var userExists = false; try { userExists = userQuery.Any(); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(UserValidationResult.Invalid(UserValidationStatus.BadDatabase, "bad database")); } var failedPasswordCount = 0; foreach (var u in userQuery.ToList()) { if (u.TempPassword != null && password == u.TempPassword) { u.TempPassword = null; if (password == "bvcms") // set this up so Admin/bvcms works until password is changed { u.Password = ""; u.MustChangePassword = true; } else { var mu = CMSMembershipProvider.provider.GetUser(userName, false); mu?.UnlockUser(); CMSMembershipProvider.provider.AdminOverride = true; mu?.ChangePassword(mu.ResetPassword(), password); CMSMembershipProvider.provider.AdminOverride = false; u.MustChangePassword = true; } u.IsLockedOut = false; db.SubmitChanges(); user = u; break; } if (password == db.Setting("ImpersonatePassword", Guid.NewGuid().ToString())) { user = u; impersonating = true; HttpContextFactory.Current.Session["IsNonFinanceImpersonator"] = "true"; break; } if (CMSMembershipProvider.provider.ValidateUser(u.Username, password)) { db.Refresh(RefreshMode.OverwriteCurrentValues, u); user = u; break; } failedPasswordCount = Math.Max(failedPasswordCount, u.FailedPasswordAttemptCount); } return(ValidateUserBeforeLogin(db, userName, url, user, userExists, failedPasswordCount, impersonating)); }
private static UserValidationResult GetUserViaCredentials() { string username; string password; var auth = HttpContextFactory.Current.Request.Headers["Authorization"]; if (auth.HasValue()) { var cred = Encoding.ASCII.GetString( Convert.FromBase64String(auth.Substring(6))).SplitStr(":", 2); username = cred[0]; password = cred[1]; } else { // NOTE: this is necessary only for the old iOS application username = HttpContextFactory.Current.Request.Headers["username"]; password = HttpContextFactory.Current.Request.Headers["password"]; } if (!string.IsNullOrEmpty(username) || !string.IsNullOrEmpty(password)) { var creds = new NetworkCredential(username, password); UserName2 = creds.UserName; return(AuthenticateLogon(creds.UserName, creds.Password, HttpContextFactory.Current.Request.Url.OriginalString, CMSDataContext.Create(HttpContextFactory.Current))); } return(null); }
public static void ConfirmDuePaidTransaction(Transaction ti, string transactionId, bool sendmail, CMSDataContext 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 = 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 = 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) { MailAddress staffEmail; if (!Util.TryGetMailAddress(db.StaffEmailForOrg(org.OrganizationId), out staffEmail)) { staffEmail = GetAdminMailAddress(db); } if (p0 == null) { db.SendEmail(staffEmail, "Payment confirmation", msg, Util.ToMailAddressList(Util.FirstAddress(ti.Emails)), pid: pid).Wait(); } else { db.Email(staffEmail, p0, Util.ToMailAddressList(ti.Emails), "Payment confirmation", msg, false); db.Email(p0.FromEmail, db.PeopleFromPidString(org.NotifyIds), "payment received for " + ti.Description, msgstaff); } } }
public static UserValidationResult AuthenticateLogon(string userName, string password, HttpSessionStateBase Session, HttpRequestBase Request, CMSDataContext db, CMSImageDataContext idb) { var status = AuthenticateLogon(userName, password, Request.Url.OriginalString, db); if (status.IsValid) { return(UserValidationResult.Valid(status.User)); } return(UserValidationResult.Invalid(UserValidationStatus.IncorrectPassword, status.ErrorMessage)); }
public static void FinishLogin(string userName, HttpSessionStateBase Session, CMSDataContext db, CMSImageDataContext idb, bool logEntry = true) { SetUserInfo(db, idb, userName, logEntry); FormsAuthentication.SetAuthCookie(userName, false); if (logEntry) { DbUtil.LogActivity($"User {userName} logged in"); } }
public static object AutoLogin(string userName, HttpSessionStateBase Session, HttpRequestBase Request, CMSDataContext db, CMSImageDataContext idb) { #if DEBUG FinishLogin(userName, Session, db, idb, false); #endif return(null); }
public static void ForgotPassword(CMSDataContext db, string username) { // first find a user with the email address or username string msg = null; var path = new StringBuilder(); username = username.Trim(); var q = db.Users.Where(uu => uu.Username == username || uu.Person.EmailAddress == username || uu.Person.EmailAddress2 == username ); if (!q.Any()) { path.Append("u0"); // could not find a user to match // so we look for a person without an account, to match the email address var minage = db.Setting("MinimumUserAge", "16").ToInt(); var q2 = from uu in db.People where uu.EmailAddress == username || uu.EmailAddress2 == username where uu.Age == null || uu.Age >= minage select uu; if (q2.Any()) { path.Append("p+"); // we found person(s), not a user // we will compose an email for each of them to create an account foreach (var p in q2) { var ot = new OneTimeLink { Id = Guid.NewGuid(), Querystring = p.PeopleId.ToString() }; db.OneTimeLinks.InsertOnSubmit(ot); db.SubmitChanges(); var url = db.ServerLink($"/Account/CreateAccount/{ot.Id.ToCode()}"); msg = db.ContentHtml("ForgotPasswordReset", Resource1.AccountModel_ForgotPasswordReset); msg = msg.Replace("{name}", p.Name); msg = msg.Replace("{first}", p.PreferredName); msg = msg.Replace("{email}", username); msg = msg.Replace("{resetlink}", url); db.SendEmail(Util.FirstAddress(DbUtil.AdminMail), "touchpointsoftware new password link", msg, Util.ToMailAddressList(p.EmailAddress ?? p.EmailAddress2)); } DbUtil.LogActivity($"ForgotPassword ('{username}', {path})"); return; } path.Append("p0"); if (!Util.ValidEmail(username)) { DbUtil.LogActivity($"ForgotPassword ('{username}', {path})"); return; } path.Append("n0"); msg = db.ContentHtml("ForgotPasswordBadEmail", Resource1.AccountModel_ForgotPasswordBadEmail); msg = msg.Replace("{email}", username); db.SendEmail(Util.FirstAddress(DbUtil.AdminMail), "Forgot password request for " + db.Setting("NameOfChurch", "bvcms"), msg, Util.ToMailAddressList(username)); DbUtil.LogActivity($"ForgotPassword ('{username}', {path})"); return; } path.Append("u+"); // we found users who match, // so now we send the users who match the username or email a set of links to all their usernames var sb = new StringBuilder(); var addrlist = new List <MailAddress>(); foreach (var user in q) { Util.AddGoodAddress(addrlist, user.EmailAddress); user.ResetPasswordCode = Guid.NewGuid(); user.ResetPasswordExpires = DateTime.Now.AddHours(db.Setting("ResetPasswordExpiresHours", "24").ToInt()); var link = db.ServerLink($"/Account/SetPassword/{user.ResetPasswordCode}"); sb.Append($@"{user.Name}, <a href=""{link}"">{user.Username}</a><br>"); db.SubmitChanges(); } msg = db.ContentHtml("ForgotPasswordReset2", Resource1.AccountModel_ForgotPasswordReset2); msg = msg.Replace("{email}", username); msg = msg.Replace("{resetlink}", sb.ToString()); db.SendEmail(Util.FirstAddress(DbUtil.AdminMail), "TouchPoint password reset link", msg, addrlist); DbUtil.LogActivity($"ForgotPassword ('{username}', {path})"); }
public static IEnumerable <ContributorInfo> contributors(CMSDataContext Db, DateTime fromDate, DateTime toDate, int PeopleId, int?SpouseId, int FamilyId, bool noaddressok, bool useMinAmt, string startswith = null, string sort = null, bool singleStatement = false, int?tagid = null, bool excludeelectronic = false) { var MinAmt = Db.Setting("MinContributionAmount", "5").ToDecimal(); if (!useMinAmt) { MinAmt = 0; } var endswith = ""; if (startswith != null && startswith.Contains("-")) { var a = startswith.SplitStr("-", 2); startswith = a[0]; endswith = a[1]; } var q = from p in Db.Contributors(fromDate, toDate, PeopleId, SpouseId, FamilyId, noaddressok, tagid) select p; if (startswith.HasValue() && !endswith.HasValue()) { q = from p in q where p.LastName.StartsWith(startswith) select p; } else if (startswith.HasValue() && endswith.HasValue()) { q = from p in q // ReSharper disable StringCompareToIsCultureSpecific where (p.LastName.CompareTo(startswith) >= 0 && p.LastName.CompareTo(endswith) < 0) || SqlMethods.Like(p.LastName, endswith + "%") select p; } if (sort == "zip") { q = from p in q orderby p.PrimaryZip, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age select p; } else if (sort == "name") { q = from p in q orderby p.LastName, p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age select p; } else { q = from p in q orderby p.FamilyId, p.PositionInFamilyId, p.HohFlag, p.Age select p; } if (singleStatement) { var familylist = q.ToList(); if (familylist.Any(m => m.DeceasedDate != null && m.ContributionOptionsId == 2)) { return(GetInfo(familylist)); } } const int NOTSPEC = 0; const int NONE = StatementOptionCode.None; const int JOINT = StatementOptionCode.Joint; const int INDIV = StatementOptionCode.Individual; if (MinAmt > 0) { q = from p in q let option = (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? NOTSPEC) != INDIV ? JOINT : INDIV) : p.ContributionOptionsId where option != NONE || noaddressok where (option == INDIV && (p.Amount >= MinAmt)) || (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) >= MinAmt)) where p.ElectronicStatement == false || excludeelectronic == false select p; } else { q = from p in q let option = (p.ContributionOptionsId ?? NOTSPEC) == NOTSPEC ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != INDIV ? JOINT : INDIV) : p.ContributionOptionsId where option != NONE || noaddressok where p.ElectronicStatement == false || excludeelectronic == false where (option == INDIV && (p.Amount > 0 || p.GiftInKind == true)) || // GiftInKind = NonTaxDeductible Fund or Pledge OR GiftInkind (option == JOINT && p.HohFlag == 1 && ((p.Amount + p.SpouseAmount) > 0 || p.GiftInKind == true)) select p; } IEnumerable <ContributorInfo> q2 = null; if (Db.Setting("NoTitlesOnStatements", "false").ToBool()) { q2 = from p in q let option = (p.ContributionOptionsId ?? 0) == 0 ? (p.SpouseId > 0 && (p.SpouseContributionOptionsId ?? 0) != 1 ? 2 : 1) : p.ContributionOptionsId let name = option == 1 ? p.Name : (p.SpouseId == null ? p.Name : (p.HohFlag == 1 ? p.CoupleName ?? (p.Name + " and " + p.SpouseName) : p.CoupleName ?? (p.SpouseName + " and " + p.Name))) select new ContributorInfo { Name = name, MailingAddress = MailingAddress(p), PeopleId = p.PeopleId, SpouseID = p.SpouseId, DeacesedDate = p.DeceasedDate, FamilyId = p.FamilyId, Age = p.Age, FamilyPositionId = p.PositionInFamilyId, hohInd = p.HohFlag, Joint = option == 2, CampusId = p.CampusId, } } ; else { q2 = GetInfo(q); } return(q2); }
public static void ExpireSessionToken(CMSDataContext db, string sessionToken) { ApiSessionModel.ExpireSession(db, Guid.Parse(sessionToken)); }
public CodeValueModel(CMSDataContext db) { Db = db; }
public APIFunctions(CMSDataContext Db) { this.Db = Db; }
public static IEnumerable<ContributionInfo> quarterlySummary(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { int[] excludetypes = new int[] { ContributionTypeCode.ReturnedCheck, ContributionTypeCode.Reversed, ContributionTypeCode.GiftInKind, ContributionTypeCode.Stock, ContributionTypeCode.NonTaxDed, ContributionTypeCode.Pledge, }; var q = from c in Db.Contributions where !excludetypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate where c.ContributionDate <= toDate where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId != ContributionTypeCode.Pledge where (c.ContributionFund.NonTaxDeductible ?? false) == false group c by c.ContributionFund.FundName into g orderby g.Key select new ContributionInfo { ContributionAmount = g.Sum(z => z.ContributionAmount ?? 0), Fund = g.Key, }; return q; }
public APIContributionSearchModel(CMSDataContext db) { this.db = db; model = new ContributionSearchInfo(); }
public APIOrganization(CMSDataContext Db) { this.Db = Db; }
public OrgSearchModel(CMSDataContext db) { CurrentDatabase = db; Pager = new PagerModel2(); Pager.GetCount = Count; }
public CodeValueModel() { Db = DbUtil.Db; }
public CheckinControlModel(CMSDataContext db) : base(db) { }
public APIContributionSearchModel(CMSDataContext db, ContributionSearchInfo m) { this.db = db; model = m; }
public EmailSentModel(CMSDataContext db) : base(db) { }
private static MailAddress GetAdminMailAddress(CMSDataContext db) { return(new MailAddress(db.Setting("AdminMail", ConfigurationManager.AppSettings["supportemail"]))); }
public OrgSearchModel() { CurrentDatabase = CurrentDatabase ?? DbUtil.Db; Pager = new PagerModel2(); Pager.GetCount = Count; }