try-catch when copying remote users to the local database, ver. 2.12.499
This commit is contained in:
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.12.498.0")]
|
[assembly: AssemblyVersion("2.12.499.0")]
|
||||||
[assembly: AssemblyFileVersion("2.12.498.0")]
|
[assembly: AssemblyFileVersion("2.12.499.0")]
|
||||||
|
|||||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.12.498.1")]
|
[assembly: AssemblyVersion("2.12.499.1")]
|
||||||
[assembly: AssemblyFileVersion("2.12.498.1")]
|
[assembly: AssemblyFileVersion("2.12.499.1")]
|
||||||
|
|||||||
@@ -145,52 +145,62 @@ namespace Users.Forms
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
try
|
||||||
/// Read remote users
|
{
|
||||||
///
|
///
|
||||||
DB.DbType = GlobalData.RemoteUsersDB.DbType;
|
/// Read remote users
|
||||||
DB.ConnectionString = GlobalData.RemoteUsersDB.ConnectionString;
|
///
|
||||||
ISession session = DB.CreateSession();
|
DB.DbType = GlobalData.RemoteUsersDB.DbType;
|
||||||
IList<User> remoteUsers = session.QueryOver<User>().List();
|
DB.ConnectionString = GlobalData.RemoteUsersDB.ConnectionString;
|
||||||
IList<Group> remoteGroups = session.QueryOver<Group>().List();
|
ISession session = DB.CreateSession();
|
||||||
|
IList<User> remoteUsers = session.QueryOver<User>().List();
|
||||||
|
IList<Group> remoteGroups = session.QueryOver<Group>().List();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Delete all local users
|
/// Delete all local users
|
||||||
///
|
///
|
||||||
DB.DbType = GlobalData.LocalUsersDB.DbType;
|
DB.DbType = GlobalData.LocalUsersDB.DbType;
|
||||||
DB.ConnectionString = GlobalData.LocalUsersDB.ConnectionString;
|
DB.ConnectionString = GlobalData.LocalUsersDB.ConnectionString;
|
||||||
session = DB.CreateSession();
|
session = DB.CreateSession();
|
||||||
IList<User> users = session.QueryOver<User>().List();
|
IList<User> users = session.QueryOver<User>().List();
|
||||||
foreach (var user in users) DB.DeleteObject(session, user);
|
foreach (var user in users) DB.DeleteObject(session, user);
|
||||||
IList<Group> groups = session.QueryOver<Group>().List();
|
IList<Group> groups = session.QueryOver<Group>().List();
|
||||||
foreach (var group in groups) DB.DeleteObject(session, group);
|
foreach (var group in groups) DB.DeleteObject(session, group);
|
||||||
session.Flush();
|
session.Flush();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Save all remote users to the local DB
|
/// Save all remote users to the local DB
|
||||||
///
|
///
|
||||||
DB.DbType = GlobalData.LocalUsersDB.DbType;
|
DB.DbType = GlobalData.LocalUsersDB.DbType;
|
||||||
DB.ConnectionString = GlobalData.LocalUsersDB.ConnectionString;
|
DB.ConnectionString = GlobalData.LocalUsersDB.ConnectionString;
|
||||||
session = DB.CreateSession();
|
session = DB.CreateSession();
|
||||||
IList<User> newUsers = session.QueryOver<User>().List();
|
IList<User> newUsers = session.QueryOver<User>().List();
|
||||||
IList<Group> newGroups = session.QueryOver<Group>().List();
|
IList<Group> newGroups = session.QueryOver<Group>().List();
|
||||||
foreach (var user in remoteUsers)
|
foreach (var user in remoteUsers)
|
||||||
{
|
{
|
||||||
User newUser = (User)user.Clone();
|
User newUser = (User)user.Clone();
|
||||||
newUsers.Add(newUser);
|
newUsers.Add(newUser);
|
||||||
foreach (var group in user.Groups)
|
foreach (var group in user.Groups)
|
||||||
{
|
{
|
||||||
Group newGroup = new Group(group.Gid, group.Name);
|
Group newGroup = new Group(group.Gid, group.Name);
|
||||||
newUser.AddGroup(newGroup);
|
newUser.AddGroup(newGroup);
|
||||||
}
|
}
|
||||||
DB.SaveObject(session, newUser);
|
DB.SaveObject(session, newUser);
|
||||||
}
|
}
|
||||||
session.Flush();
|
session.Flush();
|
||||||
|
|
||||||
MessageBox.Show(string.Format(Strings.N_users_copied, remoteUsers.Count),
|
MessageBox.Show(string.Format(Strings.N_users_copied, remoteUsers.Count),
|
||||||
Strings.Confirmation,
|
Strings.Confirmation,
|
||||||
MessageBoxButtons.OK,
|
MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Information);
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception exc)
|
||||||
|
{
|
||||||
|
MessageBox.Show(Strings.Copying_remote_users_failed,
|
||||||
|
Strings.Confirmation,
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.12.498.0")]
|
[assembly: AssemblyVersion("2.12.499.0")]
|
||||||
[assembly: AssemblyFileVersion("2.12.498.0")]
|
[assembly: AssemblyFileVersion("2.12.499.0")]
|
||||||
|
|||||||
Generated
+9
@@ -105,6 +105,15 @@ namespace Users.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Copying remote users failed.
|
||||||
|
/// </summary>
|
||||||
|
internal static string Copying_remote_users_failed {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Copying_remote_users_failed", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Description.
|
/// Looks up a localized string similar to Description.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -198,4 +198,7 @@
|
|||||||
<data name="N_users_copied" xml:space="preserve">
|
<data name="N_users_copied" xml:space="preserve">
|
||||||
<value>{0} users copied</value>
|
<value>{0} users copied</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Copying_remote_users_failed" xml:space="preserve">
|
||||||
|
<value>Copying remote users failed</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user