本文整理汇总了C#中CmsData.CMSDataContext.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# CMSDataContext.SubmitChanges方法的具体用法?C# CMSDataContext.SubmitChanges怎么用?C# CMSDataContext.SubmitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmsData.CMSDataContext
的用法示例。
在下文中一共展示了CMSDataContext.SubmitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoWork
public void DoWork()
{
Db = DbUtil.Create(Host);
Db.CommandTimeout = 1200;
var noaddressok = Db.Setting("RequireAddressOnStatement", "true") == "false";
showCheckNo = Db.Setting("RequireCheckNoOnStatement", "false").ToLower() == "true";
showNotes = Db.Setting("RequireNotesOnStatement", "false").ToLower() == "true";
const bool UseMinAmt = true;
var qc = APIContribution.contributors(Db, fd, td, 0, 0, 0, noaddressok, UseMinAmt, StartsWith, Sort, tagid: TagId, excludeelectronic: ExcludeElectronic);
var runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
runningtotals.Count = qc.Count();
Db.SubmitChanges();
if (showCheckNo || showNotes)
{
var c = new ContributionStatementsExtra
{
FromDate = fd,
ToDate = td,
typ = 3,
ShowCheckNo = showCheckNo,
ShowNotes = showNotes
};
using (var stream = new FileStream(OutputFile, FileMode.Create))
c.Run(stream, Db, qc);
LastSet = c.LastSet();
var sets = c.Sets();
foreach (var set in sets)
using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
c.Run(stream, Db, qc, set);
runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
runningtotals.LastSet = LastSet;
runningtotals.Sets = string.Join(",", sets);
runningtotals.Completed = DateTime.Now;
Db.SubmitChanges();
}
else
{
var c = new ContributionStatements
{
FromDate = fd,
ToDate = td,
typ = 3
};
using (var stream = new FileStream(OutputFile, FileMode.Create))
c.Run(stream, Db, qc);
LastSet = c.LastSet();
var sets = c.Sets();
foreach (var set in sets)
using (var stream = new FileStream(Output(OutputFile, set), FileMode.Create))
c.Run(stream, Db, qc, set);
runningtotals = Db.ContributionsRuns.OrderByDescending(mm => mm.Id).First();
runningtotals.LastSet = LastSet;
runningtotals.Sets = string.Join(",", sets);
runningtotals.Completed = DateTime.Now;
Db.SubmitChanges();
}
}
示例2: 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);
}
示例3: Start
public ActionResult Start(int tag, int meetingid, bool addasmembers)
{
var runningtotals = new AddToOrgFromTagRun
{
Started = DateTime.Now,
Count = 0,
Processed = 0,
Orgid = meetingid
};
DbUtil.Db.AddToOrgFromTagRuns.InsertOnSubmit(runningtotals);
DbUtil.Db.SubmitChanges();
var host = Util.Host;
var qid = DbUtil.Db.FetchLastQuery().Id;
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.BelowNormal;
var Db = new CMSDataContext(Util.GetConnectionString(host));
IEnumerable<int> q = null;
if (tag == -1) // (last query)
q = Db.PeopleQuery(qid).Select(pp => pp.PeopleId);
else
q = from t in Db.TagPeople
where t.Id == tag
select t.PeopleId;
var pids = q.ToList();
var meeting = Db.Meetings.SingleOrDefault(mm => mm.MeetingId == meetingid);
var joindate = meeting.MeetingDate.Value.AddMinutes(-1);
var orgid = meeting.OrganizationId;
foreach (var pid in pids)
{
Db.Dispose();
Db = new CMSDataContext(Util.GetConnectionString(host));
if (addasmembers)
OrganizationMember.InsertOrgMembers(Db,
orgid, pid, MemberTypeCode.Member, joindate, null, false);
Db.RecordAttendance(meetingid, pid, true);
var r = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == meetingid).OrderByDescending(mm => mm.Id).First();
r.Processed++;
r.Count = pids.Count;
Db.SubmitChanges();
}
var rr = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == meetingid).OrderByDescending(mm => mm.Id).First();
rr.Completed = DateTime.Now;
Db.SubmitChanges();
Db.UpdateMainFellowship(orgid);
});
return Redirect("/AddAttendeesFromTag/Progress/" + meetingid);
}
示例4: RemoveExistingLop
public void RemoveExistingLop(CMSDataContext db, int id, string op)
{
var exlop = FetchLongRunningOp(db, id, op);
if (exlop != null)
db.LongRunningOps.DeleteOnSubmit(exlop);
db.SubmitChanges();
}
示例5: FetchOrCreateMeeting
public static Meeting FetchOrCreateMeeting(CMSDataContext Db, int OrgId, DateTime dt, bool? noautoabsents = null)
{
var meeting = (from m in Db.Meetings
where m.OrganizationId == OrgId && m.MeetingDate == dt
select m).FirstOrDefault();
if (meeting == null)
{
var acr = (from s in Db.OrgSchedules
where s.OrganizationId == OrgId
where s.SchedTime.Value.TimeOfDay == dt.TimeOfDay
where s.SchedDay == (int)dt.DayOfWeek
select s.AttendCreditId).SingleOrDefault();
meeting = new Meeting
{
OrganizationId = OrgId,
MeetingDate = dt,
CreatedDate = Util.Now,
CreatedBy = Util.UserId1,
GroupMeetingFlag = false,
AttendCreditId = acr ?? 1,
NoAutoAbsents = noautoabsents
};
Db.Meetings.InsertOnSubmit(meeting);
Db.SubmitChanges();
}
return meeting;
}
示例6: AddAsPreviousMember
public static void AddAsPreviousMember(CMSDataContext db, int oid, int pid, string orgname, int mbrid, DateTime joindt, DateTime dropdt, int userid)
{
db.EnrollmentTransactions.InsertOnSubmit(
new EnrollmentTransaction
{
OrganizationId = oid,
PeopleId = pid,
OrganizationName = orgname,
MemberTypeId = mbrid,
TransactionDate = joindt,
TransactionTypeId = 1,
CreatedBy = userid,
CreatedDate = Util.Now,
});
db.EnrollmentTransactions.InsertOnSubmit(
new EnrollmentTransaction
{
OrganizationId = oid,
PeopleId = pid,
OrganizationName = orgname,
MemberTypeId = mbrid,
TransactionDate = dropdt,
TransactionTypeId = 5,
CreatedBy = userid,
CreatedDate = Util.Now,
});
db.SubmitChanges();
}
示例7: AddOrgMember
public static OrganizationMember AddOrgMember(CMSDataContext db, int organizationId, int peopleId, int memberTypeId, DateTime enrollmentDate, string name)
{
var om = new OrganizationMember
{
OrganizationId = organizationId,
PeopleId = peopleId,
MemberTypeId = memberTypeId,
EnrollmentDate = enrollmentDate,
CreatedDate = Util.Now,
SkipInsertTriggerProcessing = true
};
var et = new EnrollmentTransaction
{
OrganizationId = om.OrganizationId,
PeopleId = om.PeopleId,
MemberTypeId = om.MemberTypeId,
OrganizationName = name,
TransactionDate = enrollmentDate,
EnrollmentDate = enrollmentDate,
TransactionTypeId = 1,
// join
CreatedBy = Util.UserId1,
CreatedDate = Util.Now,
AttendancePercentage = om.AttendPct,
SkipInsertTriggerProcessing = true
};
db.OrganizationMembers.InsertOnSubmit(om);
db.EnrollmentTransactions.InsertOnSubmit(et);
db.SubmitChanges();
return om;
}
示例8: Save
public void Save(CMSDataContext Db, bool increment = false, string owner = null)
{
var q = (from e in Db.Queries
where e.QueryId == Id
select e).FirstOrDefault();
if (q == null)
{
q = new Query
{
QueryId = Id,
Owner = Util.UserName,
Created = DateTime.Now,
Ispublic = IsPublic,
Name = Description
};
Db.Queries.InsertOnSubmit(q);
}
if(increment)
q.LastRun = DateTime.Now;
if (Description != q.Name)
{
var same = (from v in Db.Queries
where !v.Ispublic
where v.Owner == Util.UserName
where v.Name == Description
orderby v.LastRun descending
select v).FirstOrDefault();
if (same != null)
same.Text = ToXml();
else
{
var c = Clone();
var cq = new Query
{
QueryId = c.Id,
Owner = Util.UserName,
Created = q.Created,
Ispublic = q.Ispublic,
Name = q.Name,
Text = c.ToXml(),
RunCount = q.RunCount,
CopiedFrom = q.CopiedFrom,
LastRun = q.LastRun
};
Db.Queries.InsertOnSubmit(cq);
}
}
q.Name = Description;
q.LastRun = DateTime.Now;
if(owner.HasValue())
q.Owner = owner;
q.Ispublic = IsPublic;
if (increment)
q.RunCount = q.RunCount + 1;
q.Text = ToXml();
Db.SubmitChanges();
}
示例9: 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");
}
示例10: FetchOrCreateMinistry
public static Ministry FetchOrCreateMinistry(CMSDataContext Db, string name)
{
var m = Db.Ministries.SingleOrDefault(pp => pp.MinistryName == name);
if (m == null)
{
m = new Ministry { MinistryName = name };
Db.Ministries.InsertOnSubmit(m);
Db.SubmitChanges();
}
return m;
}
示例11: GetRequiredTaskList
public static TaskList GetRequiredTaskList(CMSDataContext Db, string name, int pid)
{
var list = Db.TaskLists.SingleOrDefault(tl => tl.CreatedBy == pid && tl.Name == name);
if (list == null)
{
list = new TaskList { CreatedBy = pid, Name = name };
Db.TaskLists.InsertOnSubmit(list);
Db.SubmitChanges();
}
return list;
}
示例12: FetchOrCreateBundleType
public static int FetchOrCreateBundleType(CMSDataContext Db, string type)
{
var bt = Db.BundleHeaderTypes.SingleOrDefault(m => m.Description == type);
if (bt == null)
{
var max = Db.BundleHeaderTypes.Max(mm => mm.Id) + 1;
bt = new BundleHeaderType { Id = max, Code = "M" + max, Description = type };
Db.BundleHeaderTypes.InsertOnSubmit(bt);
Db.SubmitChanges();
}
return bt.Id;
}
示例13: 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;
}
}
示例14: Process
public void Process(CMSDataContext db)
{
var lop = new LongRunningOp
{
Started = DateTime.Now,
Count = Orgs.Split(',').Length,
Processed = 0,
Id = Id,
Operation = Op
};
db.LongRunningOps.InsertOnSubmit(lop);
db.SubmitChanges();
Tasks.Task.Run(() => DoWork(this));
}
示例15: FetchOrCreateContactType
public static ContactType FetchOrCreateContactType(CMSDataContext Db, string type)
{
var ct = Db.ContactTypes.SingleOrDefault(pp => pp.Description == type);
if (ct == null)
{
var max = Db.ContactTypes.Max(mm => mm.Id) + 10;
if (max < 1000)
max = 1010;
ct = new ContactType { Id = max, Description = type, Code = type.Truncate(20) };
Db.ContactTypes.InsertOnSubmit(ct);
Db.SubmitChanges();
}
return ct;
}