public void RemoveSmallGroup(int sgtagid) { var pids = (from p in People(DbUtil.Db.CurrentOrg) select p.PeopleId).ToList(); var name = DbUtil.Db.MemberTags.Single(mm => mm.Id == sgtagid && mm.OrgId == Id).Name; foreach (var pid in pids) { DbUtil.DbDispose(); DbUtil.Db = DbUtil.Create(Util.Host); var om = DbUtil.Db.OrganizationMembers.Single(mm => mm.PeopleId == pid && mm.OrganizationId == Id); var mt = om.OrgMemMemTags.SingleOrDefault(t => t.MemberTagId == sgtagid); if (mt != null) { DbUtil.Db.OrgMemMemTags.DeleteOnSubmit(mt); } DbUtil.Db.SubmitChanges(); if (mt != null) { DbUtil.LogActivity("OrgMem RemoveSubGroup " + name, om.OrganizationId, om.PeopleId); } } DbUtil.Db = DbUtil.Create(Util.Host); DbUtil.Db.ExecuteCommand(@" DELETE dbo.MemberTags WHERE Id = {1} AND OrgId = {0} AND NOT EXISTS(SELECT NULL FROM dbo.OrgMemMemTags WHERE OrgId = {0} AND MemberTagId = {1}) ", Id, sgtagid); }
public void Drop() { if (OrgMember == null) { OrgMember = DbUtil.Db.OrganizationMembers.Single(mm => mm.OrganizationId == OrgId && mm.PeopleId == PeopleId); } if (DropDate.HasValue) { OrgMember.Drop(DbUtil.Db, DropDate.Value); } else { OrgMember.Drop(DbUtil.Db); } DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("OrgMem Drop", OrgId, PeopleId); if (RemoveFromEnrollmentHistory) { DbUtil.DbDispose(); DbUtil.Db = DbUtil.Create(Util.Host); var q = DbUtil.Db.EnrollmentTransactions.Where(tt => tt.OrganizationId == OrgId && tt.PeopleId == PeopleId); DbUtil.Db.EnrollmentTransactions.DeleteAllOnSubmit(q); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("OrgMem RemoveEnrollmentHistory", OrgId, PeopleId); } }
public static void UpdateAll(string host) { if (host.HasValue()) { HttpRuntime.Cache["testhost"] = host; DbUtil.DbDispose(); } var list = DbUtil.Db.Connection.Query(CodeSql.SqlSavedqueries).ToList(); foreach (var sq in list) { var g = sq.QueryId as Guid?; if (!g.HasValue) { continue; } Debug.WriteLine($"{sq.name}"); DbUtil.DbDispose(); try { var c = DbUtil.Db.LoadExistingQuery(g.Value); var s = c.ToCode(); if (s.HasValue()) { UpdateQueryConditions.Run(sq.QueryId); DbUtil.Db.Connection.Execute(@"UPDATE QueryAnalysis set Updated = 1 where Id = @id", new { id = sq.QueryId }); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } } }
public ActionResult List(OrgMembersModel m) { m.ValidateIds(); DbUtil.Db.SetUserPreference("OrgMembersModelIds", $"{m.ProgId}.{m.SourceDivId}.{m.SourceId}"); DbUtil.DbDispose(); DbUtil.Db.SetNoLock(); return(View(m)); }
private string AddNewExtraValueBools(IEnumerable <int> list) { foreach (var pid in list) { Person.AddEditExtraBool(DbUtil.Db, pid, ExtraValueName, ExtraValueCheckbox); DbUtil.Db.SubmitChanges(); DbUtil.DbDispose(); } return(null); }
private string AddNewExtraValueDatums(IEnumerable <int> list) { foreach (var pid in list) { Person.AddEditExtraData(DbUtil.Db, pid, ExtraValueName, ExtraValueTextArea); DbUtil.Db.SubmitChanges(); DbUtil.DbDispose(); } return(null); }
public ActionResult List() { var m = new OrgMembersModel(); UpdateModel(m); m.ValidateIds(); DbUtil.Db.SetUserPreference("OrgMembersModelIds", "{0}.{1}.{2}".Fmt(m.ProgId, m.DivId, m.SourceId)); DbUtil.DbDispose(); DbUtil.Db.SetNoLock(); return(View(m)); }
public ActionResult Add2(Guid id, string field, string value) { var list = DbUtil.Db.PeopleQuery(id).Select(pp => pp.PeopleId).ToList(); foreach (var pid in list) { Person.AddEditExtraValue(DbUtil.Db, pid, field, value); DbUtil.Db.SubmitChanges(); DbUtil.DbDispose(); } return(Content("done")); }
public void Update() { var pids = (from p in People(DbUtil.Db.CurrentOrg) select p.PeopleId).ToList(); foreach (var pid in pids) { DbUtil.DbDispose(); DbUtil.Db = DbUtil.Create(Util.Host); var om = DbUtil.Db.OrganizationMembers.Single(mm => mm.PeopleId == pid && mm.OrganizationId == Id); var changes = new List <ChangeDetail>(); if (InactiveDate.HasValue) { om.UpdateValue(changes, "InactiveDate", InactiveDate); } if (RemoveInactiveDate) { om.UpdateValue(changes, "InactiveDate", null); } if (EnrollmentDate.HasValue) { om.UpdateValue(changes, "EnrollmentDate", EnrollmentDate); } om.Pending = Pending; if (MemberType.Value != "0") { om.UpdateValue(changes, "MemberTypeId", MemberType.Value.ToInt()); } if (MakeMemberTypeOriginal) { var et = (from e in DbUtil.Db.EnrollmentTransactions where e.PeopleId == om.PeopleId where e.OrganizationId == Id orderby e.TransactionDate select e).First(); et.MemberTypeId = om.MemberTypeId; } DbUtil.Db.SubmitChanges(); foreach (var g in changes) { DbUtil.LogActivity("OrgMem change " + g.Field, om.OrganizationId, om.PeopleId); } } }
protected void Application_EndRequest(object sender, EventArgs e) { if (HttpContext.Current != null) { DbUtil.DbDispose(); } if (Response.Status.StartsWith("401") && Request.Url.AbsolutePath.EndsWith(".aspx")) { var r = Models.AccountModel.CheckAccessRole(User.Identity.Name); if (r.HasValue()) { Response.Redirect(r); } } }
public static string DoAnalysis(string host = null) { if (host.HasValue()) { HttpRuntime.Cache["testhost"] = host; DbUtil.DbDispose(); } var sb = new StringBuilder(); var m = new QueryCodeModel(CodeSql.Analyze); foreach (var q in m.List) { sb.Append(m.Analyze(q)); } return(sb.ToString()); }
private string AddNewExtraValueBools(IEnumerable <int> list) { foreach (var pid in list) { if (AddToFamilyRecordInsteadOfPerson) { Family.AddEditExtraBool(DbUtil.Db, pid, ExtraValueName, ExtraValueCheckbox); } else { Person.AddEditExtraBool(DbUtil.Db, pid, ExtraValueName, ExtraValueCheckbox); } DbUtil.Db.SubmitChanges(); DbUtil.DbDispose(); } return(null); }
public ActionResult Delete2(Guid id, string field, string value) { var list = DbUtil.Db.PeopleQuery(id).Select(pp => pp.PeopleId).ToList(); foreach (var pid in list) { var ev = Person.GetExtraValue(DbUtil.Db, pid, field, value); if (ev == null) { continue; } DbUtil.Db.PeopleExtras.DeleteOnSubmit(ev); DbUtil.Db.SubmitChanges(); DbUtil.DbDispose(); } return(Content("done")); }
public string AddSmallGroup(int sgtagid) { var name = DbUtil.Db.MemberTags.Single(mm => mm.Id == sgtagid && mm.OrgId == OrgId).Name; foreach (var pid in Pids) { DbUtil.DbDispose(); DbUtil.Db = DbUtil.Create(Util.Host); var om = DbUtil.Db.OrganizationMembers.Single(mm => mm.PeopleId == pid && mm.OrganizationId == OrgId); var nn = om.AddToGroup(DbUtil.Db, sgtagid); if (nn == 1) { DbUtil.LogActivity("OrgMem AddSubGroup " + name, om.OrganizationId, om.PeopleId); } } return($"{Pids.Count} added to sub-group {name}"); }
public string AddSmallGroup(int sgtagid) { var pids = (from p in People(DbUtil.Db.CurrentOrg) select p.PeopleId).ToList(); var n = 0; var name = DbUtil.Db.MemberTags.Single(mm => mm.Id == sgtagid && mm.OrgId == Id).Name; foreach (var pid in pids) { DbUtil.DbDispose(); DbUtil.Db = DbUtil.Create(Util.Host); var om = DbUtil.Db.OrganizationMembers.Single(mm => mm.PeopleId == pid && mm.OrganizationId == Id); var nn = om.AddToGroup(DbUtil.Db, sgtagid); n += nn; if (nn == 1) { DbUtil.LogActivity("OrgMem AddSubGroup " + name, om.OrganizationId, om.PeopleId); } } return($"{n} added to sub-group {name}"); }
public void Dispose() { DbUtil.Db.Connection.Close(); DbUtil.DbDispose(); Items = null; }