public ActionResult SavePythonScript(string name, string body, string contentKeyWords) { var content = CurrentDatabase.Content(name, "", ContentTypeCode.TypePythonScript); content.Body = body; CurrentDatabase.SubmitChanges(); return(new EmptyResult()); }
public ActionResult FetchBuildingActivities(string id) { if (!Authenticate()) { return(Content("not authorized")); } var m = new CheckInModel(CurrentDatabase); return(Content(CurrentDatabase.Content($"BuildingCheckin-{id}.xml", "<BuildingActivity/>"), "text/xml")); }
public ActionResult Script(string id) { try { var script = CurrentDatabase.Content(id); PythonModel.RunScript(Util.Host, script.Body); } catch (Exception e) { return(Content(e.Message)); } return(Content("done")); }
public ActionResult Summary(string table) { if (Util2.OrgLeadersOnly) { return(Redirect("/Home")); } var m = ExtraInfo.CodeSummary(table); var c = CurrentDatabase.Content("StandardExtraValues2", "<Views />", ContentTypeCode.TypeText); ViewBag.EvSpecId = c.Id; return(View("Reports/Summary", m)); }
public void ParseSettings() { var list = new Dictionary <int, Settings>(); if (masterorgid.HasValue) { foreach (var o in UserSelectClasses(masterorg)) { list[o.OrganizationId] = CurrentDatabase.CreateRegistrationSettings(o.OrganizationId); } list[masterorg.OrganizationId] = CurrentDatabase.CreateRegistrationSettings(masterorg.OrganizationId); } else if (_orgid == null) { return; } else if (org != null) { list[_orgid.Value] = CurrentDatabase.CreateRegistrationSettings(_orgid.Value); } HttpContextFactory.Current.Items["RegSettings"] = list; if (org == null || !org.AddToSmallGroupScript.HasValue()) { return; } var script = CurrentDatabase.Content(org.AddToSmallGroupScript); if (script == null || !script.Body.HasValue()) { return; } Log("Script:" + org.AddToSmallGroupScript); try { var pe = new PythonModel(CurrentDatabase.Host, "RegisterEvent", script.Body); HttpContextFactory.Current.Items["PythonEvents"] = pe; } catch (Exception ex) { Log("PythonError"); org.AddToExtraText("Python.errors", ex.Message); throw; } }
public ActionResult Statements(ContributionsModel m) { if (!CurrentDatabase.CurrentUserPerson.CanViewStatementFor(CurrentDatabase, m.PeopleId)) { return(Content("No permission to view statement")); } var hasCustomStatementsXml = CurrentDatabase.Content("CustomStatements", "") != string.Empty; var hasStandardFundLabel = CurrentDatabase.Setting("StandardFundSetName", string.Empty) != string.Empty; var hasContributionFundStatementsEnabled = CurrentDatabase.Setting("EnableContributionFundsOnStatementDisplay", false); var useNewStatementView = hasCustomStatementsXml && hasStandardFundLabel && hasContributionFundStatementsEnabled; return(View(useNewStatementView ? "Giving/StatementsWithFund" : "Giving/Statements", m)); }
public ActionResult Application(int orgid, int peopleid, string content) { #if DEBUG2 var c = System.IO.File.ReadAllText(Server.MapPath("/Application.html")); var replacements = new EmailReplacements(CurrentDatabase, c, null); #else var c = CurrentDatabase.Content(content); if (c == null) { return(Message("no content at " + content)); } var replacements = new EmailReplacements(CurrentDatabase, c.Body, null); #endif var p = CurrentDatabase.LoadPersonById(peopleid); CurrentDatabase.SetCurrentOrgId(orgid); ViewBag.html = replacements.DoReplacements(CurrentDatabase, p); return(View()); }
public ConfirmEnum ConfirmManageSubscriptions() { var p = List[0]; if (p.IsNew) { p.AddPerson(null, GetEntryPoint()); } if (p.CreatingAccount) { p.CreateAccount(); } var c = CurrentDatabase.Content("OneTimeConfirmation"); if (c == null) { c = new Content(); c.Name = "OneTimeConfirmation"; c.Title = "Manage Your Subscriptions"; c.Body = @"Hi {name}, <p>Here is your <a href=""{url}"">link</a> to manage your subscriptions. (note: it will only work once for security reasons)</p> "; CurrentDatabase.Contents.InsertOnSubmit(c); CurrentDatabase.SubmitChanges(); } var Staff = CurrentDatabase.StaffPeopleForOrg(masterorgid.Value); p.SendOneTimeLink( Staff.First().FromEmail, CurrentDatabase.ServerLink("/OnlineReg/ManageSubscriptions/"), c.Title, c.Body); Log("SendOneTimeLinkManageSub"); return(ConfirmEnum.ConfirmAccount); }
public ActionResult VoteLinkSg(string id, string message, bool?confirm, FormCollection formCollection) { var li = new LinkInfo(votelinkSTR, confirmSTR, id); if (li.error.HasValue()) { return(Message(li.error)); } try { var smallgroup = li.a[4]; if (!li.oid.HasValue) { throw new Exception("orgid missing"); } if (!li.pid.HasValue) { throw new Exception("peopleid missing"); } var q = (from pp in CurrentDatabase.People where pp.PeopleId == li.pid let org = CurrentDatabase.Organizations.SingleOrDefault(oo => oo.OrganizationId == li.oid) let om = CurrentDatabase.OrganizationMembers.SingleOrDefault(oo => oo.OrganizationId == li.oid && oo.PeopleId == li.pid) select new { p = pp, org, om }).Single(); if (q.org == null && CurrentDatabase.Host == "trialdb") { var oid = li.oid + Util.TrialDbOffset; q = (from pp in CurrentDatabase.People where pp.PeopleId == li.pid let org = CurrentDatabase.Organizations.SingleOrDefault(oo => oo.OrganizationId == oid) let om = CurrentDatabase.OrganizationMembers.SingleOrDefault(oo => oo.OrganizationId == oid && oo.PeopleId == li.pid) select new { p = pp, org, om }).Single(); } if (q.org == null) { throw new Exception("org missing, bad link"); } if ((q.org.RegistrationTypeId ?? RegistrationTypeCode.None) == RegistrationTypeCode.None) { throw new Exception("votelink is no longer active"); } if (q.om == null && q.org.Limit <= q.org.RegLimitCount(CurrentDatabase)) { throw new Exception("sorry, maximum limit has been reached"); } if (q.om == null && (q.org.RegistrationClosed == true || q.org.OrganizationStatusId == OrgStatusCode.Inactive)) { throw new Exception("sorry, registration has been closed"); } var setting = CurrentDatabase.CreateRegistrationSettings(li.oid.Value); if (IsSmallGroupFilled(setting, li.oid.Value, smallgroup)) { throw new Exception("sorry, maximum limit has been reached for " + smallgroup); } var omb = OrganizationMember.Load(CurrentDatabase, li.pid.Value, li.oid.Value) ?? OrganizationMember.InsertOrgMembers(CurrentDatabase, li.oid.Value, li.pid.Value, MemberTypeCode.Member, Util.Now, null, false); if (q.org.AddToSmallGroupScript.HasValue()) { var script = CurrentDatabase.Content(q.org.AddToSmallGroupScript); if (script != null && script.Body.HasValue()) { try { var pe = new PythonModel(Util.Host, "RegisterEvent", script.Body); pe.instance.AddToSmallGroup(smallgroup, omb); } catch (Exception) { } } } omb.AddToGroup(CurrentDatabase, smallgroup); li.ot.Used = true; CurrentDatabase.SubmitChanges(); DbUtil.LogActivity($"{votelinkSTR}{confirmSTR}: {smallgroup}", li.oid, li.pid); if (confirm == true) { var subject = Util.PickFirst(setting.Subject, "no subject"); var msg = Util.PickFirst(setting.Body, "no message"); msg = APIOrganization.MessageReplacements(CurrentDatabase, q.p, q.org.DivisionName, q.org.OrganizationId, q.org.OrganizationName, q.org.Location, msg); msg = msg.Replace("{details}", smallgroup); var NotifyIds = CurrentDatabase.StaffPeopleForOrg(q.org.OrganizationId); try { CurrentDatabase.Email(NotifyIds[0].FromEmail, q.p, subject, msg); // send confirmation } catch (Exception ex) { CurrentDatabase.Email(q.p.FromEmail, NotifyIds, q.org.OrganizationName, "There was a problem sending confirmation from org: " + ex.Message); } CurrentDatabase.Email(q.p.FromEmail, NotifyIds, q.org.OrganizationName, $"{q.p.Name} has registered for {q.org.OrganizationName}<br>{smallgroup}<br>(from votelink)"); } } catch (Exception ex) { DbUtil.LogActivity($"{votelinkSTR}{confirmSTR}Error: {ex.Message}", li.oid, li.pid); return(Message(ex.Message)); } return(Message(message)); }