Exemplo n.º 1
0
        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));
                    }
                }
            }
        }
Exemplo n.º 2
0
        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();
            }
        }