Ejemplo n.º 1
0
        private bool SyncRoles()
        {
            NotifyMsg(string.Format("{0}{1}......", Resources.Resource1.FrmSyncDataToStandby_Synchronizing, Resources.Resource1.FrmSyncDataToStandby_Role));
            NotifyProgress(100, 0);

            bool          success = true;
            CommandResult result  = null;

            RoleBll masterbll  = new RoleBll(AppSettings.CurrentSetting.CurrentMasterConnect);
            RoleBll standbybll = new RoleBll(AppSettings.CurrentSetting.CurrentStandbyConnect);

            QueryResultList <RoleInfo> infos = masterbll.GetAllRoles();

            success = infos.Result == ResultCode.Successful;
            if (success)
            {
                success = standbybll.DeleteAllRoles().Result == ResultCode.Successful;
                if (success)
                {
                    NotifyProgress(infos.QueryObjects.Count, 0);
                    foreach (RoleInfo info in infos.QueryObjects)
                    {
                        result  = standbybll.Insert(info);
                        success = result.Result == ResultCode.Successful;
                        NotifyProgress(null, null);
                        if (!success)
                        {
                            break;
                        }
                    }
                }
            }

            if (!success)
            {
                NotifyMsg(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_Role, Resources.Resource1.Form_Fail), Color.Red);
            }
            else
            {
                NotifyMsg(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_Role, Resources.Resource1.Form_Success));
            }

            return(success);
        }