Ejemplo n.º 1
0
        public static SelectList GatewayGatewayAccountList()
        {
            List <string> list = CMSDataContext.Create(HttpContextFactory.Current).GatewayAccount
                                 .Select(g => g.GatewayAccountName).ToList();

            list.Insert(0, "");
            return(new SelectList(list));
        }
Ejemplo n.º 2
0
        private static void _logActivity(string host, string activity, int?orgId, int?peopleId, int?datumId, int?userId, string pageUrl = null, string clientIp = null)
        {
            var ip = HttpContextFactory.Current?.Request.UserHostAddress;

            using (var db = CMSDataContext.Create(host))
            {
                if (!userId.HasValue || userId == 0)
                {
                    userId = db.UserId;
                }

                if (userId == 0)
                {
                    userId = null;
                }

                if (orgId.HasValue && !db.PeopleIdOk(peopleId))
                {
                    peopleId = null;
                }

                if (peopleId.HasValue && !db.OrgIdOk(orgId))
                {
                    orgId = null;
                }

                var a = new ActivityLog
                {
                    ActivityDate = Util.Now,
                    UserId       = userId,
                    Activity     = activity.Truncate(200),
                    Machine      = Environment.MachineName,
                    OrgId        = orgId,
                    PeopleId     = peopleId,
                    DatumId      = datumId,
                    PageUrl      = pageUrl,
                    ClientIp     = clientIp ?? ip
                };

                db.ActivityLogs.InsertOnSubmit(a);
                db.SubmitChanges();
            }
        }
Ejemplo n.º 3
0
 public static CMSDataContext Create(string connstr, string host)
 {
     return(CMSDataContext.Create(connstr, host));
 }
Ejemplo n.º 4
0
 public static CMSDataContext Create(string host)
 {
     return(CMSDataContext.Create(Util.GetConnectionString(host), host));
 }
Ejemplo n.º 5
0
 private CMSDataContext NewDataContext()
 {
     return(CMSDataContext.Create(db.Host));
 }
Ejemplo n.º 6
0
 public PythonModel(string dbname, Dictionary <string, object> dict)
 {
     dictionary = dict;
     Data       = new DynamicData(dictionary);
     db         = CMSDataContext.Create(dbname);
 }
Ejemplo n.º 7
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;

                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));
            }
        }
Ejemplo n.º 8
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));
            }
        }
Ejemplo n.º 9
0
 public QueryFunctions(string dbname)
 {
     db = CMSDataContext.Create(dbname);
 }