public static void TestChangingMemberGroupToSystemValueSavesOldValue(MembersContainer container, string systemValue) { const string group = "TheGroup"; Member m = CreateJohnDoe(); m.MemberDetais.membergroup = group; container.MemberSet.AddObject(m); container.SaveChanges(); m.MemberDetais.membergroup = systemValue; container.SaveChanges(); IEnumerable<Changelog> entries = container.ChangelogSet.AsEnumerable(). Where(entry => entry.action.Equals(DBConstants.NewNonMember)); Assert.AreEqual(1, entries.Count()); Changelog log = entries.First(); Assert.AreEqual(group, log.oldvalue); }
/// <summary> /// Import member database from XML file. /// </summary> /// <param name="path"></param> /// <param name="container">Table adapter for member table</param> public override void Import(string path, MembersContainer container) { if (container == null) throw new ArgumentNullException("container"); _document = new XmlDocument(); _document.Load(path); try { //EmptyDatabase(container); OnProgressChanged(0.0); ImportOrganization(container); ImportMembers(container); container.SaveChanges(); OnProgressChanged(1.0); } finally { } }
/// <summary> /// Import member database from CoW access database. /// </summary> /// <param name="path">The source (CoW) database</param> /// <param name="container">The target database</param> public override void Import(string path, MembersContainer container) { if (container == null) throw new ArgumentNullException("container"); string connectionString = String.Format(CultureInfo.CurrentCulture, "Provider=Microsoft.JET.OLEDB.4.0;data source=\"{0}\"", path); _connection = new OleDbConnection(connectionString); _connection.Open(); try { ImportOrganization(container); ImportMembers(container); HandleResignedMembers(container, _connection); container.SaveChanges(); // the important part! ;o OnProgressChanged(1.0); } finally { _connection.Close(); } }
private static void EmptyDatabase(MembersContainer container) { foreach(var m in container.MemberSet.AsEnumerable()) { container.MemberSet.DeleteObject(m); } container.SaveChanges(); }