Example #1
0
        private bool SyncCards()
        {
            NotifyMsg(string.Format("{0}{1}......", Resources.Resource1.FrmSyncDataToStandby_Synchronizing, Resources.Resource1.FrmSyncDataToStandby_Card));
            NotifyProgress(100, 0);

            bool          success = true;
            CommandResult result  = null;

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

            QueryResultList <CardInfo> infos = masterbll.GetAllCards();

            success = infos.Result == ResultCode.Successful;
            if (success)
            {
                success = standbybll.DeteleAllCards().Result == ResultCode.Successful;
                if (success)
                {
                    NotifyProgress(infos.QueryObjects.Count, 0);
                    foreach (CardInfo 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_Card, Resources.Resource1.Form_Fail), Color.Red);
            }
            else
            {
                NotifyMsg(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_Card, Resources.Resource1.Form_Success));
            }

            return(success);
        }
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (_DownLoadAll)
     {
         CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect);
         Cards = bll.GetAllCards().QueryObjects;
     }
     if (Cards != null && Cards.Count > 0)
     {
         btnOk.Enabled       = false;
         btnCancel.Enabled   = true;
         this.btnCancel.Text = Resources.Resource1.Form_Stop;
         _Parks                    = hardwareTree1.GetSelectedParks();
         _Entrances                = hardwareTree1.GetSelectedEntrances();
         this.timer1.Enabled       = true;
         this.timer1.Interval      = 1000;
         _Begin                    = DateTime.Now;
         this.progressBar1.Maximum = Cards.Count * _Entrances.Count;
         this.progressBar1.Value   = 0;
         this.progressBar1.Visible = true;
         SyncCards_Thread          = new Thread(SyncAllCards);
         SyncCards_Thread.Start();
     }
 }
Example #3
0
 private void btn_Refresh_Click(object sender, EventArgs e)
 {
     _cards = bll.GetAllCards().QueryObjects;
     cardView.CardSource = _cards;
     FreshStatusBar();
 }