当前位置: 首页>>代码示例>>C#>>正文


C# CMSDataContext.ExecuteCommand方法代码示例

本文整理汇总了C#中CmsData.CMSDataContext.ExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.ExecuteCommand方法的具体用法?C# CMSDataContext.ExecuteCommand怎么用?C# CMSDataContext.ExecuteCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CmsData.CMSDataContext的用法示例。


在下文中一共展示了CMSDataContext.ExecuteCommand方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Index

        public ActionResult Index(int id)
        {
            var mm = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingId == id);
            if (mm == null)
                return Content("error: no meeting");
            DbUtil.LogActivity("Delete meeting for {0}".Fmt(Session["ActiveOrganization"]));

            var runningtotals = new DeleteMeetingRun
            {
                Started = DateTime.Now,
                Count = mm.Attends.Count(a => a.EffAttendFlag == true || a.AttendanceFlag == true),
                Processed = 0,
                Meetingid = id
            };
            DbUtil.Db.DeleteMeetingRuns.InsertOnSubmit(runningtotals);
            DbUtil.Db.SubmitChanges();
            var host = Util.Host;
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
                var Db = new CMSDataContext(Util.GetConnectionString(host));
                var cul = Db.Setting("Culture", "en-US");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);

                var meeting = Db.Meetings.SingleOrDefault(m => m.MeetingId == id);
                var q = from a in Db.Attends
                        where a.MeetingId == id
                        where a.AttendanceFlag == true || a.EffAttendFlag == true
                        select a.PeopleId;
                var list = q.ToList();
                foreach (var pid in list)
                {
                    Db.Dispose();
                    Db = new CMSDataContext(Util.GetConnectionString(host));
                    Attend.RecordAttendance(Db, pid, id, false);
                    var r = Db.DeleteMeetingRuns.Where(m => m.Meetingid == id).OrderByDescending(m => m.Id).First();
                    r.Processed++;
                    Db.SubmitChanges();
                }
                var rr = Db.DeleteMeetingRuns.Where(m => m.Meetingid == id).OrderByDescending(m => m.Id).First();
                rr.Processed--;
                Db.SubmitChanges();
                Db.ExecuteCommand(
                    "delete dbo.SubRequest WHERE EXISTS(SELECT NULL FROM Attend a WHERE a.AttendId = AttendId AND a.MeetingId = {0})",
                    id);
                Db.ExecuteCommand("DELETE dbo.VolRequest where MeetingId = {0}", id);
                Db.ExecuteCommand("delete attend where MeetingId = {0}", id);
                Db.ExecuteCommand("delete MeetingExtra where MeetingId = {0}", id);
                Db.ExecuteCommand("delete meetings where MeetingId = {0}", id);
                rr.Processed++;
                rr.Completed = DateTime.Now;
                Db.SubmitChanges();
            });
            return Redirect("/DeleteMeeting/Progress/" + id);
        }
开发者ID:rossspoon,项目名称:bvcms,代码行数:56,代码来源:DeleteMeetingController.cs

示例2: Drop

        public EnrollmentTransaction Drop(CMSDataContext db, DateTime dropdate, string orgname)
        {
            db.SubmitChanges();
            while (true)
            {
                if (!EnrollmentDate.HasValue)
                    EnrollmentDate = CreatedDate;
                var sglist = (from mt in db.OrgMemMemTags
                              where mt.PeopleId == PeopleId
                              where mt.OrgId == OrganizationId
                              select mt.MemberTag.Name
                    ).ToList();
                var droptrans = new EnrollmentTransaction
                {
                    OrganizationId = OrganizationId,
                    PeopleId = PeopleId,
                    MemberTypeId = MemberTypeId,
                    OrganizationName = orgname,
                    TransactionDate = dropdate,
                    TransactionTypeId = 5, // drop
                    CreatedBy = Util.UserId1,
                    CreatedDate = Util.Now,
                    Pending = Pending,
                    AttendancePercentage = AttendPct,
                    InactiveDate = InactiveDate,
                    UserData = UserData,
                    Request = Request,
                    ShirtSize = ShirtSize,
                    Grade = Grade,
                    Tickets = Tickets,
                    RegisterEmail = RegisterEmail,
                    Score = Score,
                    SmallGroups = string.Join("\n", sglist)
                };

                db.EnrollmentTransactions.InsertOnSubmit(droptrans);
                db.OrgMemMemTags.DeleteAllOnSubmit(this.OrgMemMemTags);
                db.OrganizationMembers.DeleteOnSubmit(this);
                db.ExecuteCommand(@"
DELETE dbo.SubRequest
FROM dbo.SubRequest sr
JOIN dbo.Attend a ON a.AttendId = sr.AttendId
WHERE a.OrganizationId = {0}
AND a.MeetingDate > {1}
AND a.PeopleId = {2}
", OrganizationId, Util.Now, PeopleId);
                db.ExecuteCommand("DELETE dbo.Attend WHERE OrganizationId = {0} AND MeetingDate > {1} AND PeopleId = {2} AND ISNULL(Commitment, 1) = 1", OrganizationId, Util.Now, PeopleId);
                db.ExecuteCommand("DELETE dbo.Attend WHERE OrganizationId = {0} AND DATEADD(DAY, DATEDIFF(DAY, 0, MeetingDate), 0) = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0) AND PeopleId = {1} AND AttendanceFlag = 0", OrganizationId, PeopleId);
                db.ExecuteCommand("UPDATE dbo.GoerSenderAmounts SET InActive = 1 WHERE OrgId = {0} AND (GoerId = {1} OR SupporterId = {1})", OrganizationId, PeopleId);
                return droptrans;
            }
        }
开发者ID:stevesloka,项目名称:bvcms,代码行数:52,代码来源:OrganizationMember.cs

示例3: Find

        public ActionResult Find(string FromDate, string ToDate)
        {
            var fdt = FromDate.ToDate();
            var tdt = ToDate.ToDate();
            string host = Util.Host;
            var runningtotals = new DuplicatesRun
            {
                Started = DateTime.Now,
                Count = 0,
                Processed = 0,
                Found = 0
            };
            DbUtil.Db.DuplicatesRuns.InsertOnSubmit(runningtotals);
            DbUtil.Db.SubmitChanges();

            Alias.Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.Priority = ThreadPriority.Lowest;
                var Db = new CMSDataContext(Util.GetConnectionString(host));
                var rt = Db.DuplicatesRuns.OrderByDescending(mm => mm.Id).First();
                Db.ExecuteCommand("delete duplicate");
                var q = from p in Db.People
                        where p.CreatedDate > fdt
                        where p.CreatedDate < tdt.Value.AddDays(1)
                        select p.PeopleId;
                rt.Count = q.Count();
                Db.SubmitChanges();
                foreach(var p in q)
                {
                    var pids = Db.FindPerson4(p);
                    rt.Processed++;
                    Db.SubmitChanges();
                    if (pids.Count() == 0)
                        continue;
                    foreach(var pid in pids)
                        Db.InsertDuplicate(p, pid.PeopleId.Value);
                    rt.Found++;
                }
                rt.Completed = DateTime.Now;
                Db.SubmitChanges();
            });
            return Redirect("/Manage/Duplicates/Progress");
        }
开发者ID:rossspoon,项目名称:bvcms,代码行数:43,代码来源:DuplicatesController.cs

示例4: DeletePicture

 public void DeletePicture(CMSDataContext db)
 {
     if (Picture == null)
         return;
     Image.Delete(Picture.ThumbId);
     Image.Delete(Picture.SmallId);
     Image.Delete(Picture.MediumId);
     Image.Delete(Picture.LargeId);
     var pid = PictureId;
     Picture = null;
     db.SubmitChanges();
     db.ExecuteCommand("DELETE dbo.Picture WHERE PictureId = {0}", pid);
 }
开发者ID:vs06,项目名称:bvcms,代码行数:13,代码来源:Family.cs

示例5: MovePersonStuff


//.........这里部分代码省略.........
                if (Util.HasValue(frrecreg.Policy))
                    torecreg.Policy = frrecreg.Policy;
                if (Util.HasValue(frrecreg.Mname))
                    torecreg.Mname = frrecreg.Mname;
                if (Util.HasValue(frrecreg.Fname))
                    torecreg.Fname = frrecreg.Fname;
                if (Util.HasValue(frrecreg.Emcontact))
                    torecreg.Emcontact = frrecreg.Emcontact;
                if (Util.HasValue(frrecreg.Emphone))
                    torecreg.Emphone = frrecreg.Emphone;
                if (frrecreg.ActiveInAnotherChurch.HasValue)
                    torecreg.ActiveInAnotherChurch = frrecreg.ActiveInAnotherChurch;
            }
            TrySubmit(db, "RegReg");

            var mg = db.ManagedGivings.FirstOrDefault(mm => mm.PeopleId == targetid);
            if (mg == null)
            {
                var v = this.ManagedGivings.FirstOrDefault();
                if (v != null)
                {
                    db.ManagedGivings.InsertOnSubmit(new ManagedGiving()
                                {
                                    Day1 = v.Day1,
                                    Day2 = v.Day2,
                                    EveryN = v.EveryN,
                                    NextDate = v.NextDate,
                                    PeopleId = targetid,
                                    Period = v.Period,
                                    SemiEvery = v.SemiEvery,
                                    StartWhen = v.StartWhen,
                                    StopAfter = v.StopAfter,
                                    StopWhen = v.StopWhen,
                                    Type = v.Type,
                                });
                    var qq = from ra in db.RecurringAmounts
                             where ra.PeopleId == PeopleId
                             select ra;
                    foreach (var ra in qq)
                        db.RecurringAmounts.InsertOnSubmit(
                            new RecurringAmount()
                                {
                                    PeopleId = targetid,
                                    Amt = ra.Amt,
                                    FundId = ra.FundId,
                                });
                }
                TrySubmit(db, "ManagedGivings");
            }

            var pi = db.PaymentInfos.FirstOrDefault(mm => mm.PeopleId == targetid);
            if (pi == null) // the target has none
                foreach (var i in PaymentInfos)
                    DbUtil.Db.PaymentInfos.InsertOnSubmit(
                        new PaymentInfo
                            {
                                Address = i.Address,
                                Address2 = i.Address2,
                                AuNetCustId = i.AuNetCustId,
                                AuNetCustPayId = i.AuNetCustPayId,
                                AuNetCustPayBankId = i.AuNetCustPayBankId,
                                BluePayCardVaultId = i.BluePayCardVaultId,
                                City = i.City,
                                Country = i.Country,
                                Expires = i.Expires,
                                FirstName = i.FirstName,
                                LastName = i.LastName,
                                MaskedAccount = i.MaskedAccount,
                                MaskedCard = i.MaskedCard,
                                MiddleInitial = i.MiddleInitial,
                                PeopleId = targetid,
                                Phone = i.Phone,
                                PreferredGivingType = i.PreferredGivingType,
                                PreferredPaymentType = i.PreferredPaymentType,
                                Routing = i.Routing,
                                SageBankGuid = i.SageBankGuid,
                                SageCardGuid = i.SageCardGuid,
                                State = i.State,
                                Suffix = i.Suffix,
                                Testing = i.Testing,
                                Zip = i.Zip,
                                TbnBankVaultId = i.TbnBankVaultId,
                                TbnCardVaultId = i.TbnCardVaultId
                            });
            TrySubmit(db, "PaymentInfos");

            foreach (var bc in this.BackgroundChecks)
                bc.PeopleID = targetid;
            TrySubmit(db, "BackgroundChecks");

            foreach (var c in this.CheckInTimes)
                c.PeopleId = targetid;
            TrySubmit(db, "CheckinTimes");

            db.ExecuteCommand(@"
            UPDATE dbo.GoerSupporter SET GoerId = {1} WHERE GoerId = {0};
            UPDATE dbo.GoerSupporter SET SupporterId = {1} WHERE SupporterId = {0};
            UPDATE dbo.GoerSenderAmounts SET GoerId = {1} WHERE GoerId = {0};
            UPDATE dbo.GoerSenderAmounts SET SupporterId = {1} WHERE SupporterId = {0}", PeopleId, targetid);
        }
开发者ID:alexserdyuk,项目名称:bvcms,代码行数:101,代码来源:Person.cs

示例6: Drop

 public EnrollmentTransaction Drop(CMSDataContext Db, DateTime dropdate, bool addToHistory)
 {
     Db.SubmitChanges();
     int ntries = 2;
     while (true)
     {
         try
         {
             var q = from o in Db.Organizations
                     where o.OrganizationId == OrganizationId
                     let count = Db.Attends.Count(a => a.PeopleId == PeopleId
                                                       && a.OrganizationId == OrganizationId
                                                       && (a.MeetingDate < DateTime.Today || a.AttendanceFlag == true))
                     select new { count, Organization.DaysToIgnoreHistory };
             var i = q.Single();
             if (!EnrollmentDate.HasValue)
                 EnrollmentDate = CreatedDate;
             var droptrans = new EnrollmentTransaction
                             {
                                 OrganizationId = OrganizationId,
                                 PeopleId = PeopleId,
                                 MemberTypeId = MemberTypeId,
                                 OrganizationName = Organization.OrganizationName,
                                 TransactionDate = dropdate,
                                 TransactionTypeId = 5,
                                 // drop
                                 CreatedBy = Util.UserId1,
                                 CreatedDate = Util.Now,
                                 Pending = Pending,
                                 AttendancePercentage = AttendPct,
                             };
             Db.EnrollmentTransactions.InsertOnSubmit(droptrans);
             Db.OrgMemMemTags.DeleteAllOnSubmit(this.OrgMemMemTags);
             Db.OrganizationMembers.DeleteOnSubmit(this);
             Db.ExecuteCommand("DELETE FROM dbo.SubRequest WHERE EXISTS(SELECT NULL FROM Attend a WHERE a.AttendId = AttendId AND a.OrganizationId = {0} AND a.MeetingDate > {1} AND a.PeopleId = {2})", OrganizationId, Util.Now, PeopleId);
             Db.ExecuteCommand("DELETE dbo.Attend WHERE OrganizationId = {0} AND MeetingDate > {1} AND PeopleId = {2} AND ISNULL(Commitment, 1) = 1", OrganizationId, Util.Now, PeopleId);
             return droptrans;
         }
         catch (SqlException ex)
         {
             if (ex.Number == 1205)
                 if (--ntries > 0)
                 {
                     Db.Dispose();
                     System.Threading.Thread.Sleep(500);
                     continue;
                 }
             throw;
         }
     }
 }
开发者ID:hkouns,项目名称:bvcms,代码行数:51,代码来源:OrganizationMember.cs


注:本文中的CmsData.CMSDataContext.ExecuteCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。