protected override void OnExit(ExitEventArgs e) { if (sync != null) { sync.Dispose(); sync = null; } try { FairiesMemberManageUow uow = ServiceLocator.Current.GetInstance <FairiesMemberManageUow>(); if (uow != null) { uow.Dispose(); uow = null; } } catch (Exception) { } if (mutex != null && ownsMutex) { mutex.ReleaseMutex(); mutex.Dispose(); mutex = null; } base.OnExit(e); }
private void Application_Startup(object sender, StartupEventArgs e) { JudgeOnly(); if (!ownsMutex) { return; } UpdateConfig(); #if !DEBUG if (IsUpdate()) { JudgeUpdate(); } #endif using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["FairiesMemberManage"].ConnectionString)) { try { conn.Open(); if (JudgeSqlUpdate()) { DXInfo.Models.SyncTableStruct.Update(conn); DisplayScreen(conn); sync = DXInfo.Sync.Sync.Instance(); sync.ExecuteSyncSync(); UpdateSqlVersionConfig(); } else { DisplayScreen(conn); } this.SetIoc(); SetMapper(); JudgeSync(conn); DisplayLogin(conn); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误信息", MessageBoxButton.OK, MessageBoxImage.Error); HandleException(ex); } finally { conn.Close(); if (s != null) { s.Close();//new TimeSpan(0, 0, 1)); } } } }
private void InitData() { if (Common.JudgeSqlUpdate()) { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FairiesMemberManage"].ConnectionString; DXInfo.Sync.Sync sync = new DXInfo.Sync.Sync(connectionString); //using (sync.ServerConn) //{ sync.ServerConn.Open(); Common.SyncStruct(sync.ServerConn); sync.ServerConn.Close(); //} sync.ProvisionServer(); sync.CheckProvisionServer(); Common.UpdateSqlVersionConfig(); } }
private void JudgeSync(SqlConnection conn) { int localDeptCount = 0; int userCount = 0; int adminCount = 0; int adminNameCount = 0; localDeptCount = Helper.GetLocalDeptCount(conn); if (localDeptCount == 0) { if (MessageBox.Show(@"在Sql Server从备份还原之后,更新该数据库中的同步元数据。 若不执行此操作这个客户端数据库将不能同步, 执行了此操作后这个客户端数据库将全部重新同步。 请确保这个备份出来的客户端数据库从未执行过此操作,并已经清理过数据。 使用工具SyncOper.exe输入数字3也可达到同样效果。 是否进行这个操作?", "还原的数据库的处理", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { sync = DXInfo.Sync.Sync.Instance(); sync.RestoreDatabase(sync.ClientConn); } } else { userCount = Helper.GetUsersCount(conn); if (userCount > 0) { adminCount = Helper.GetAdminUserNameCount(conn); if (adminCount > 0) { adminNameCount = Helper.GetAdminFullNameCount(conn); } } } if (localDeptCount == 0 || userCount == 0 || adminCount == 0 || adminNameCount == 0) { sync = DXInfo.Sync.Sync.Instance(); sync.ExecuteSyncSync(); } if (localDeptCount == 0) { LocalDeptWindow ld = ServiceLocator.Current.GetInstance <LocalDeptWindow>(); ld.ShowDialog(); } }
private void InitData() { if (DXInfo.Web.Models.Helper.JudgeSqlUpdate()) { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FairiesMemberManage"].ConnectionString; DXInfo.Sync.Sync sync = new DXInfo.Sync.Sync(connectionString); bool bAMSApp = DXInfo.Web.Models.Helper.IsAMSApp(); sync.ServerConn.Open(); DXInfo.Web.Models.Helper.SyncStruct(sync.ServerConn, bAMSApp); sync.ServerConn.Close(); if (!bAMSApp) { sync.ProvisionServer(); sync.CheckProvisionServer(); } DXInfo.Web.Models.Helper.UpdateSqlVersionConfig(); } }
static void Main(string[] args) { string strExit = ""; do { Console.WriteLine("请选择重建\n0:重建客户端同步框架,1:重建服务端同步框架,2:重建所有,3:设置备份的数据库,4:建立服务端同步框架"); string strOper1 = Console.ReadLine(); DXInfo.Sync.Sync s = DXInfo.Sync.Sync.Instance(); List <string> scopeNames = new List <string>(); if (strOper1 != "3") { Console.WriteLine("请选择重建的域"); Console.WriteLine("-1:所有"); for (int i = 0; i < s.ScopeNames.Count; i++) { Console.WriteLine("{0:d}:{1:s}", i, s.ScopeNames[i]); } string strOper2 = Console.ReadLine(); int iOper = int.Parse(strOper2); if (iOper == -1) { scopeNames = (from d in s.ScopeNames select d.Value).ToList(); } else { scopeNames = (from d in s.ScopeNames where d.Key == iOper select d.Value).ToList(); } } switch (strOper1) { case "0": Console.WriteLine("开始重建客户端框架"); s.DeProvision(s.ClientConn, scopeNames); Console.WriteLine("客户端框架重建完成"); break; case "1": Console.WriteLine("开始重建服务端框架"); s.DeProvision(s.ServerConn, scopeNames); Console.WriteLine("服务端框架重建完成"); break; case "2": Console.WriteLine("开始重建框架"); s.DeProvision(s.ClientConn, scopeNames); s.DeProvision(s.ServerConn, scopeNames); Console.WriteLine("框架重建完成"); break; case "3": Console.WriteLine("开始设置备份的数据库"); s.RestoreDatabase(s.ClientConn); Console.WriteLine("备份的数据库设置完成"); break; case "4": Console.WriteLine("开始建服务端框架"); s.ProvisionServer(); Console.WriteLine("服务端框架建完成"); break; } strExit = Console.ReadLine(); }while (strExit != "exit"); }