コード例 #1
0
        public void CreateTask(int forPeopleId, Person p, string description)
        {
            var t = p.AddTaskAbout(db, forPeopleId, description);

            db.SubmitChanges();
            db.Email(db.Setting("AdminMail", "*****@*****.**"), db.LoadPersonById(forPeopleId),
                     "TASK: " + description,
                     Task.TaskLink(db, description, t.Id) + "<br/>" + p.Name);
        }
コード例 #2
0
ファイル: Family.cs プロジェクト: lightyeare/bvcms
        public static Task AddTaskAbout(CMSDataContext db, int familyId, int assignTo, string description)
        {
            var f = db.Families.Single(ff => ff.People.Any(mm => mm.FamilyId == familyId));
            var primaryorchild = new[] { PositionInFamily.PrimaryAdult, PositionInFamily.Child };
            var fmembers       = (from p in db.People
                                  where p.FamilyId == familyId
                                  where primaryorchild.Contains(p.PositionInFamilyId)
                                  select p.Name).ToList();
            var hh = db.LoadPersonById(f.HeadOfHouseholdId ?? 0);
            var t  = new Task
            {
                OwnerId               = assignTo,
                Description           = description,
                Notes                 = "Family: " + string.Join(", ", fmembers),
                ForceCompleteWContact = true,
                ListId                = Task.GetRequiredTaskList(db, "InBox", assignTo).Id,
                StatusId              = TaskStatusCode.Active,
            };

            hh.TasksAboutPerson.Add(t);
            if (db.Host.HasValue())
            {
                var gcm = new GCMHelper(db.Host, db);
                gcm.sendRefresh(assignTo, GCMHelper.ACTION_REFRESH);
            }
            return(t);
        }
コード例 #3
0
ファイル: Handlebars.cs プロジェクト: bvcms/bvcms
        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));
            });
        }
コード例 #4
0
        private void dropMembership(bool Deceased, 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 != EnvelopeOptionCode.None)
                        {
                            spouse.EnvelopeOptionsId = EnvelopeOptionCode.Individual;
                        }
                    }
                    spouse.ContributionOptionsId = EnvelopeOptionCode.Individual;
                }

                if (spouse.MemberStatusId == MemberStatusCode.Member)
                {
                    if (spouse.EnvelopeOptionsId == EnvelopeOptionCode.Joint)
                    {
                        spouse.EnvelopeOptionsId = EnvelopeOptionCode.Individual;
                    }
                }
            }
            EnvelopeOptionsId = EnvelopeOptionCode.None;

            var list = OrganizationMembers.ToList();

            foreach (var om in list)
            {
                om.Drop(Db, addToHistory: true);
            }
        }
コード例 #5
0
ファイル: MembershipService.cs プロジェクト: stevesloka/bvcms
 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;
 }
コード例 #6
0
ファイル: Task.cs プロジェクト: rastographics/bvcms
        public static int AddTask(CMSDataContext Db, int pid)
        {
            var p = Db.LoadPersonById(pid);
            var t = new Task
            {
                ListId                = GetRequiredTaskList(Db, "InBox", Db.UserPeopleId.Value).Id,
                OwnerId               = Db.UserPeopleId.Value,
                Description           = "Please Contact",
                ForceCompleteWContact = true,
                StatusId              = TaskStatusCode.Active,
            };

            p.TasksAboutPerson.Add(t);
            Db.SubmitChanges();
            return(t.Id);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        //public void MemberProfileAutomation0(CMSDataContext Db)
        //{
        //    if (DecisionTypeIdChanged)
        //        switch (DecisionTypeId ?? 0)
        //        {
        //            case DecisionCode.ProfessionForMembership:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (Age <= 12 && Family.People.Any(p =>
        //                        p.PositionInFamilyId == PositionInFamily.PrimaryAdult
        //                        && p.MemberStatusId == MemberStatusCode.Member
        //                        && SqlMethods.DateDiffMonth(p.JoinDate, Util.Now) >= 12))
        //                    BaptismTypeId = BaptismTypeCode.Biological;
        //                else
        //                    BaptismTypeId = BaptismTypeCode.Original;
        //                BaptismStatusId = BaptismStatusCode.NotScheduled;
        //                break;
        //            case DecisionCode.ProfessionNotForMembership:
        //                MemberStatusId = MemberStatusCode.NotMember;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.NotSpecified;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.NonMember;
        //                    BaptismStatusId = BaptismStatusCode.NotScheduled;
        //                }
        //                break;
        //            case DecisionCode.Letter:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.NotSpecified;
        //                    BaptismStatusId = BaptismStatusCode.NotSpecified;
        //                }
        //                break;
        //            case DecisionCode.Statement:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.NotSpecified;
        //                    BaptismStatusId = BaptismStatusCode.NotSpecified;
        //                }
        //                break;
        //            case DecisionCode.StatementReqBaptism:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.Required;
        //                    BaptismStatusId = BaptismStatusCode.NotScheduled;
        //                }
        //                break;
        //            case DecisionCode.Cancelled:
        //                MemberStatusId = MemberStatusCode.NotMember;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.NotSpecified;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                    if (BaptismStatusId != BaptismStatusCode.Completed)
        //                    {
        //                        BaptismTypeId = BaptismTypeCode.NotSpecified;
        //                        BaptismStatusId = BaptismStatusCode.Canceled;
        //                    }
        //                EnvelopeOptionsId = EnvelopeOptionCode.None;
        //                break;
        //        }
        //    // This section sets join codes
        //    if (NewMemberClassStatusIdChanged || BaptismStatusIdChanged)
        //        switch (DecisionTypeId ?? 0)
        //        {
        //            case DecisionCode.ProfessionForMembership:
        //                if (DiscClassStatusCompletedCodes.Contains(NewMemberClassStatusId ?? 0)
        //                    && BaptismStatusId == BaptismStatusCode.Completed)
        //                {
        //                    MemberStatusId = MemberStatusCode.Member;
        //                    if (BaptismTypeId == BaptismTypeCode.Biological)
        //                        JoinCodeId = JoinTypeCode.BaptismBIO;
        //                    else
        //                        JoinCodeId = JoinTypeCode.BaptismPOF;
        //                    if (NewMemberClassDate.HasValue && BaptismDate.HasValue)
        //                        JoinDate = NewMemberClassDate.Value > BaptismDate.Value ?
        //                            NewMemberClassDate.Value : BaptismDate.Value;
        //                }
        //                break;
        //            case DecisionCode.Letter:
        //                if (NewMemberClassStatusIdChanged)
        //                    if (DiscClassStatusCompletedCodes.Contains(NewMemberClassStatusId ?? 0)
        //                        || NewMemberClassStatusId == NewMemberClassStatusCode.AdminApproval)
        //                    {
        //                        MemberStatusId = MemberStatusCode.Member;
        //                        JoinCodeId = JoinTypeCode.Letter;
        //                        JoinDate = NewMemberClassDate.HasValue ? NewMemberClassDate : DecisionDate;
        //                    }
        //                break;
        //            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);
        }
コード例 #9
0
ファイル: Attend.cs プロジェクト: ilkerhalil/bvcms
        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
0
ファイル: BatchController.cs プロジェクト: hkouns/bvcms
        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();
            });
        }
コード例 #11
0
        public static IHandlebars RegisterHelpers(CMSDataContext db, PythonModel pm = null, IHandlebars handlebars = null)
        {
            handlebars = handlebars ?? Handlebars.Create();
            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("HtmlComment", (writer, context, args) =>
            {
#if DEBUG
                writer.Write($"<h6>{args[0].ToString()} {args[1].ToString()}</h6>");
#else
                writer.Write($"<!--{args[0].ToString()} {args[1].ToString()}-->");
#endif
            });
            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("IfCond", (writer, options, context, args) =>
            {
                var op = HttpUtility.HtmlDecode(args[1].ToString());
                bool b = false;
                switch (op)
                {
                case "==":
                    b = Compare(args) == 0;
                    break;

                case "!=":
                    b = Compare(args) != 0;
                    break;

                case "<":
                    b = Compare(args) < 0;
                    break;

                case ">":
                    b = Compare(args) > 0;
                    break;

                case ">=":
                    b = Compare(args) >= 0;
                    break;

                case "<=":
                    b = Compare(args) <= 0;
                    break;

                case "&&":
                    b = NumTrue(args) == 2;
                    break;

                case "||":
                    b = NumTrue(args) >= 1;
                    break;
                }
                if (b)
                {
                    options.Template(writer, (object)context);
                }
                else
                {
                    options.Inverse(writer, (object)context);
                }
            });
            handlebars.RegisterHelper("IfGT", (writer, options, context, args) =>
            {
                if (Compare2(args) > 0)
                {
                    options.Template(writer, (object)context);
                }
                else
                {
                    options.Inverse(writer, (object)context);
                }
            });
            handlebars.RegisterHelper("IfLT", (writer, options, context, args) =>
            {
                if (Compare2(args) < 0)
                {
                    options.Template(writer, (object)context);
                }
                else
                {
                    options.Inverse(writer, (object)context);
                }
            });
            handlebars.RegisterHelper("IfGE", (writer, options, context, args) =>
            {
                if (Compare2(args) <= 0)
                {
                    options.Template(writer, (object)context);
                }
                else
                {
                    options.Inverse(writer, (object)context);
                }
            });
            handlebars.RegisterHelper("IfLE", (writer, options, context, args) =>
            {
                if (Compare2(args) <= 0)
                {
                    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() ?? "");
            });

            handlebars.RegisterHelper("FmtMDY", (writer, context, args) =>
            {
                DateTime dt;
                var s = args[0].ToString();
                if (DateTime.TryParse(s, out dt))
                {
                    writer.Write(dt.ToShortDateString());
                }
            });
            handlebars.RegisterHelper("FmtDate", (writer, context, args) =>
            {
                DateTime dt;
                var s = args[0].ToString();
                if (DateTime.TryParse(s, out dt))
                {
                    writer.Write(dt.ToShortDateString());
                }
            });
            handlebars.RegisterHelper("FmtMoney", (writer, context, args) =>
            {
                decimal d;
                var s = args[0].ToString();
                if (decimal.TryParse(s, out d))
                {
                    writer.Write(d.ToString("C"));
                }
            });

            // 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));
            });
            handlebars.RegisterHelper("Json", (writer, options, context, args) =>
            {
                dynamic a = JsonDeserialize2(args[0].ToString());
                foreach (var item in a)
                {
                    options.Template(writer, item);
                }
            });

            handlebars.RegisterHelper("Calc", (writer, context, args) =>
            {
                var calcAmt    = args[0].ToDouble() - args[1].ToDouble();
                var calcAmtfmt = $"{{0:{'c'}}}";
                writer.Write(calcAmtfmt, calcAmt);
            });

            handlebars.RegisterHelper("ThrowError", (writer, context, args) =>
            {
                throw new Exception("ThrowError called in Handlebars Helper");
            });

            return(handlebars);
        }
コード例 #12
0
        // 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));
            }
        }
コード例 #13
0
ファイル: Person.cs プロジェクト: GSBCfamily/bvcms
 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();
 }
コード例 #14
0
ファイル: Person.cs プロジェクト: alexserdyuk/bvcms
 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;
 }
コード例 #15
0
ファイル: SagePayments.cs プロジェクト: chrisgundersen/bvcms
        public void storeVault(int PeopleId,
                               string type, string cardnumber, string expires, string cardcode,
                               string routing, string account, bool giving)
        {
            var p  = Db.LoadPersonById(PeopleId);
            var pi = p.PaymentInfo();

            if (pi == null)
            {
                pi = new PaymentInfo();
                p.PaymentInfos.Add(pi);
            }
            var wc = new WebClient();

            wc.BaseAddress = "https://www.sagepayments.net/web_services/wsVault/wsVault.asmx/";
            var coll = new NameValueCollection();

            coll["M_ID"]  = login;
            coll["M_KEY"] = key;

            XElement resp = null;

            if (type == "C")
            {
                coll["CARDNUMBER"]      = cardnumber;
                coll["EXPIRATION_DATE"] = expires;

                if (pi.SageCardGuid == null)
                {
                    var b   = wc.UploadValues("INSERT_CREDIT_CARD_DATA", "POST", coll);
                    var ret = Encoding.ASCII.GetString(b);
                    resp            = getResponse(ret);
                    pi.SageCardGuid = Guid.Parse(resp.Element("GUID").Value);
                }
                else
                {
                    coll["GUID"] = pi.SageCardGuid.ToString().Replace("-", "");
                    if (!cardnumber.StartsWith("X"))
                    {
                        var b   = wc.UploadValues("UPDATE_CREDIT_CARD_DATA", "POST", coll);
                        var ret = Encoding.ASCII.GetString(b);
                        resp = getResponse(ret);
                    }
                    else
                    {
                        var b   = wc.UploadValues("UPDATE_CREDIT_CARD_EXPIRATION_DATE", "POST", coll);
                        var ret = Encoding.ASCII.GetString(b);
                        resp = getResponse(ret);
                    }
                }
            }
            else
            {
                coll["ROUTING_NUMBER"] = routing;                 // 064000020
                coll["ACCOUNT_NUMBER"] = account;                 // my account number
                coll["C_ACCT_TYPE"]    = "DDA";

                if (pi.SageBankGuid == null)
                {
                    var b   = wc.UploadValues("INSERT_VIRTUAL_CHECK_DATA", "POST", coll);
                    var ret = Encoding.ASCII.GetString(b);
                    resp            = getResponse(ret);
                    pi.SageBankGuid = Guid.Parse(resp.Element("GUID").Value);
                }
                else
                {
                    if (!account.StartsWith("X"))
                    {
                        coll["GUID"] = pi.SageBankGuid.ToString().Replace("-", "");
                        var b   = wc.UploadValues("UPDATE_VIRTUAL_CHECK_DATA", "POST", coll);
                        var ret = Encoding.ASCII.GetString(b);
                        resp = getResponse(ret);
                    }
                }
            }
            pi.MaskedAccount = Util.MaskAccount(account);
            pi.Routing       = Util.Mask(new StringBuilder(routing), 2);
            pi.MaskedCard    = Util.MaskCC(cardnumber);
            pi.Ccv           = cardcode;
            pi.Expires       = expires;
            pi.Testing       = testing;
            if (giving)
            {
                pi.PreferredGivingType = type;
            }
            else
            {
                pi.PreferredPaymentType = type;
            }
            Db.SubmitChanges();
            //var sw =new StringWriter();
            //ObjectDumper.Write(pi, 0, sw);

            //Util.SendMsg(DbUtil.AdminMail, Db.CmsHost, Util.TryGetMailAddress("*****@*****.**"), "Sage Vault",
            //	"<a href='{0}{1}'>{2}</a><br>{3},{4}<br><pre>{5}</pre>".Fmt(
            //	Db.CmsHost, p.PeopleId, p.Name, type, giving ? "giving" : "regular", sw.ToString()),
            //	Util.ToMailAddressList("*****@*****.**"), 0, null);
        }
コード例 #16
0
        // 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);
            }
        }
コード例 #17
0
ファイル: Person.cs プロジェクト: GSBCfamily/bvcms
 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();
 }
コード例 #18
0
ファイル: UpdatePeopleModel.cs プロジェクト: stevesloka/bvcms
        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();
            }
        }
コード例 #19
0
ファイル: EmailReplacements.cs プロジェクト: ilkerhalil/bvcms
        // 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;

                pi = GetPayInfo(emailqueueto.OrgId ?? currentOrgId ?? db.CurrentSessionOrgId, p.PeopleId);

                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], emailqueueto);
                    }
                }

                db.SubmitChanges();
                return(string.Join("", texta));
            }
        }
コード例 #20
0
ファイル: MemberRules.cs プロジェクト: stevesloka/bvcms
        //public void MemberProfileAutomation0(CMSDataContext Db)
        //{
        //    if (DecisionTypeIdChanged)
        //        switch (DecisionTypeId ?? 0)
        //        {
        //            case DecisionCode.ProfessionForMembership:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (Age <= 12 && Family.People.Any(p =>
        //                        p.PositionInFamilyId == PositionInFamily.PrimaryAdult
        //                        && p.MemberStatusId == MemberStatusCode.Member
        //                        && SqlMethods.DateDiffMonth(p.JoinDate, Util.Now) >= 12))
        //                    BaptismTypeId = BaptismTypeCode.Biological;
        //                else
        //                    BaptismTypeId = BaptismTypeCode.Original;
        //                BaptismStatusId = BaptismStatusCode.NotScheduled;
        //                break;
        //            case DecisionCode.ProfessionNotForMembership:
        //                MemberStatusId = MemberStatusCode.NotMember;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.NotSpecified;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.NonMember;
        //                    BaptismStatusId = BaptismStatusCode.NotScheduled;
        //                }
        //                break;
        //            case DecisionCode.Letter:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.NotSpecified;
        //                    BaptismStatusId = BaptismStatusCode.NotSpecified;
        //                }
        //                break;
        //            case DecisionCode.Statement:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.NotSpecified;
        //                    BaptismStatusId = BaptismStatusCode.NotSpecified;
        //                }
        //                break;
        //            case DecisionCode.StatementReqBaptism:
        //                MemberStatusId = MemberStatusCode.Pending;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.Pending;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                {
        //                    BaptismTypeId = BaptismTypeCode.Required;
        //                    BaptismStatusId = BaptismStatusCode.NotScheduled;
        //                }
        //                break;
        //            case DecisionCode.Cancelled:
        //                MemberStatusId = MemberStatusCode.NotMember;
        //                if (NewMemberClassStatusId != NewMemberClassStatusCode.Attended)
        //                    NewMemberClassStatusId = NewMemberClassStatusCode.NotSpecified;
        //                if (BaptismStatusId != BaptismStatusCode.Completed)
        //                    if (BaptismStatusId != BaptismStatusCode.Completed)
        //                    {
        //                        BaptismTypeId = BaptismTypeCode.NotSpecified;
        //                        BaptismStatusId = BaptismStatusCode.Canceled;
        //                    }
        //                EnvelopeOptionsId = EnvelopeOptionCode.None;
        //                break;
        //        }
        //    // This section sets join codes
        //    if (NewMemberClassStatusIdChanged || BaptismStatusIdChanged)
        //        switch (DecisionTypeId ?? 0)
        //        {
        //            case DecisionCode.ProfessionForMembership:
        //                if (DiscClassStatusCompletedCodes.Contains(NewMemberClassStatusId ?? 0)
        //                    && BaptismStatusId == BaptismStatusCode.Completed)
        //                {
        //                    MemberStatusId = MemberStatusCode.Member;
        //                    if (BaptismTypeId == BaptismTypeCode.Biological)
        //                        JoinCodeId = JoinTypeCode.BaptismBIO;
        //                    else
        //                        JoinCodeId = JoinTypeCode.BaptismPOF;
        //                    if (NewMemberClassDate.HasValue && BaptismDate.HasValue)
        //                        JoinDate = NewMemberClassDate.Value > BaptismDate.Value ?
        //                            NewMemberClassDate.Value : BaptismDate.Value;
        //                }
        //                break;
        //            case DecisionCode.Letter:
        //                if (NewMemberClassStatusIdChanged)
        //                    if (DiscClassStatusCompletedCodes.Contains(NewMemberClassStatusId ?? 0)
        //                        || NewMemberClassStatusId == NewMemberClassStatusCode.AdminApproval)
        //                    {
        //                        MemberStatusId = MemberStatusCode.Member;
        //                        JoinCodeId = JoinTypeCode.Letter;
        //                        JoinDate = NewMemberClassDate.HasValue ? NewMemberClassDate : DecisionDate;
        //                    }
        //                break;
        //            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);
        }
コード例 #21
0
ファイル: AuthorizeNet.cs プロジェクト: davidbwire/bvcms
        public void AddUpdateCustomerProfile(int PeopleId,
                                             string type,
                                             string cardnumber,
                                             string expires,
                                             string cardcode,
                                             string routing,
                                             string account)
        {
            var exp = expires;

            if (exp.HasValue())
            {
                exp = "20" + expires.Substring(2, 2) + "-" + expires.Substring(0, 2);
            }
            var p  = Db.LoadPersonById(PeopleId);
            var pi = p.PaymentInfo();

            if (pi == null)
            {
                pi = new PaymentInfo();
                p.PaymentInfos.Add(pi);
            }
            if (pi.AuNetCustId == null)             // create a new profilein Authorize.NET CIM
            {
                XDocument request = null;
                if (type == "B")
                {
                    request = new XDocument(new XDeclaration("1.0", "utf-8", null),
                                            Element("createCustomerProfileRequest",
                                                    Element("merchantAuthentication",
                                                            Element("name", login),
                                                            Element("transactionKey", key)
                                                            ),
                                                    Element("profile",
                                                            Element("merchantCustomerId", PeopleId),
                                                            Element("email", p.EmailAddress),
                                                            Element("paymentProfiles",
                                                                    Element("billTo",
                                                                            Element("firstName", p.FirstName),
                                                                            Element("lastName", p.LastName),
                                                                            Element("address", p.PrimaryAddress),
                                                                            Element("city", p.PrimaryCity),
                                                                            Element("state", p.PrimaryState),
                                                                            Element("zip", p.PrimaryZip),
                                                                            Element("phoneNumber", p.HomePhone)
                                                                            ),
                                                                    Element("payment",
                                                                            Element("bankAccount",
                                                                                    Element("routingNumber", routing),
                                                                                    Element("accountNumber", account),
                                                                                    Element("nameOnAccount", p.Name)
                                                                                    )
                                                                            )
                                                                    )
                                                            )
                                                    )
                                            );
                }
                else
                {
                    request = new XDocument(new XDeclaration("1.0", "utf-8", null),
                                            Element("createCustomerProfileRequest",
                                                    Element("merchantAuthentication",
                                                            Element("name", login),
                                                            Element("transactionKey", key)
                                                            ),
                                                    Element("profile",
                                                            Element("merchantCustomerId", PeopleId),
                                                            Element("email", p.EmailAddress),
                                                            Element("paymentProfiles",
                                                                    Element("billTo",
                                                                            Element("firstName", p.FirstName),
                                                                            Element("lastName", p.LastName),
                                                                            Element("address", p.PrimaryAddress),
                                                                            Element("city", p.PrimaryCity),
                                                                            Element("state", p.PrimaryState),
                                                                            Element("zip", p.PrimaryZip),
                                                                            Element("phoneNumber", p.HomePhone)
                                                                            ),
                                                                    Element("payment",
                                                                            Element("creditCard",
                                                                                    Element("cardNumber", cardnumber),
                                                                                    Element("expirationDate", exp),
                                                                                    Element("cardCode", cardcode)
                                                                                    )
                                                                            )
                                                                    )
                                                            )
                                                    )
                                            );
                }
                var s   = request.ToString();
                var x   = getResponse(s);
                var id  = x.Descendants(ns + "customerProfileId").First().Value.ToInt();
                var pid = x.Descendants(ns + "customerPaymentProfileIdList")
                          .Descendants(ns + "numericString").First().Value.ToInt();
                pi.AuNetCustId    = id;
                pi.AuNetCustPayId = pid;
            }
            else
            {
                if (account.HasValue() && account.StartsWith("X"))
                {
                    var xe  = getCustomerPaymentProfile(PeopleId);
                    var xba = xe.Descendants(ns + "bankAccount").Single();
                    routing = xba.Element(ns + "routingNumber").Value;
                    account = xba.Element(ns + "accountNumber").Value;
                }

                var request = new XDocument(new XDeclaration("1.0", "utf-8", null),
                                            Element("updateCustomerProfileRequest",
                                                    Element("merchantAuthentication",
                                                            Element("name", login),
                                                            Element("transactionKey", key)
                                                            ),
                                                    Element("profile",
                                                            Element("merchantCustomerId", PeopleId),
                                                            Element("email", p.EmailAddress),
                                                            Element("customerProfileId", pi.AuNetCustId)
                                                            )
                                                    )
                                            );
                var x = getResponse(request.ToString());
                if (type == "B")
                {
                    request = new XDocument(new XDeclaration("1.0", "utf-8", null),
                                            Element("updateCustomerPaymentProfileRequest",
                                                    Element("merchantAuthentication",
                                                            Element("name", login),
                                                            Element("transactionKey", key)
                                                            ),
                                                    Element("customerProfileId", pi.AuNetCustId),
                                                    Element("paymentProfile",
                                                            Element("billTo",
                                                                    Element("firstName", p.FirstName),
                                                                    Element("lastName", p.LastName),
                                                                    Element("address", p.PrimaryAddress),
                                                                    Element("city", p.PrimaryCity),
                                                                    Element("state", p.PrimaryState),
                                                                    Element("zip", p.PrimaryZip),
                                                                    Element("phoneNumber", p.HomePhone)
                                                                    ),
                                                            Element("payment",
                                                                    Element("bankAccount",
                                                                            Element("routingNumber", routing),
                                                                            Element("accountNumber", account),
                                                                            Element("nameOnAccount", p.Name)
                                                                            )
                                                                    ),
                                                            Element("customerPaymentProfileId", pi.AuNetCustPayId)
                                                            )
                                                    )
                                            );
                }
                else
                {
                    request = new XDocument(new XDeclaration("1.0", "utf-8", null),
                                            Element("updateCustomerPaymentProfileRequest",
                                                    Element("merchantAuthentication",
                                                            Element("name", login),
                                                            Element("transactionKey", key)
                                                            ),
                                                    Element("customerProfileId", pi.AuNetCustId),
                                                    Element("paymentProfile",
                                                            Element("billTo",
                                                                    Element("firstName", p.FirstName),
                                                                    Element("lastName", p.LastName),
                                                                    Element("address", p.PrimaryAddress),
                                                                    Element("city", p.PrimaryCity),
                                                                    Element("state", p.PrimaryState),
                                                                    Element("zip", p.PrimaryZip),
                                                                    Element("phoneNumber", p.HomePhone)
                                                                    ),
                                                            Element("payment",
                                                                    Element("creditCard",
                                                                            Element("cardNumber", cardnumber),
                                                                            Element("expirationDate", exp),
                                                                            Element("cardCode", cardcode)
                                                                            )
                                                                    ),
                                                            Element("customerPaymentProfileId", pi.AuNetCustPayId)
                                                            )
                                                    )
                                            );
                }
                x = getResponse(request.ToString());
            }
            pi.MaskedAccount = Util.MaskAccount(account);
            pi.MaskedCard    = Util.MaskCC(cardnumber);
            pi.Ccv           = cardcode;
            pi.Expires       = expires;
            Db.SubmitChanges();
        }
コード例 #22
0
ファイル: Person.cs プロジェクト: alexserdyuk/bvcms
 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;
 }
コード例 #23
0
ファイル: Attend.cs プロジェクト: stevesloka/bvcms
		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;
				}
			}
		}
コード例 #24
0
        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));
            });
        }
コード例 #25
0
ファイル: EmailReplacements.cs プロジェクト: peclecl/bvcms
        // 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);
            }
        }