Exemple #1
0
 private void PopulateForm()
 {
     DataLayer.SessionHelper _sessionHelper = new SessionHelper();
     Repository<Guid, NewsItem> _newsItemRepo = new Repository<Guid, NewsItem>(_sessionHelper.GetSession("APL"));
     UnitOfWork _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL"));
     var newsItems = _newsItemRepo.All().ToList();
     dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     dataGridView1.CellContentDoubleClick += DataGridView1_CellContentDoubleClick;
     dataGridView1.ReadOnly = true;
     dataGridView1.DataSource = newsItems;
 }
Exemple #2
0
        private System.Threading.Tasks.Task DoSync()
        {
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(() =>
            {
                DataLayer.SessionHelper _sessionHelper = new SessionHelper();
                UnitOfWork _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL"));
                Repository<Guid, Setting> _settingRepo = new Repository<Guid, APLBackendDB.Setting>(_unitOfWork.Session);
                Setting _settings = new Setting();

                SetStatusText("Starting sync...");

                Util.DBSync d = new Util.DBSync();
                d.ProgressUpdate += D_ProgressUpdate;

                SetStatusText("Syncing States...");
                d.SyncState();

                SetStatusText("Syncing Brands...");
                d.SyncBrand();

                SetStatusText("Syncing Regions...");
                d.SyncRegion();

                SetStatusText("Syncing Venues...");
                d.SyncVenue();

                SetStatusText("Syncing Game Types...");
                d.SyncGameType();

                SetStatusText("Syncing Games...");
                d.SyncGame();

                SetStatusText("Syncing Customers...");
                d.SyncCustomer();

                SetStatusText("Sync Completed.");
                btSync.Enabled = true;

                Setting lastSync = _settingRepo.FindBy(p => (p.Keyname == "LastCompleteSync"));
                if (lastSync == null || string.IsNullOrEmpty(lastSync.Value))
                {
                    lastSync = new Setting();
                    lastSync.Keyname = "LastCompleteSync";
                }
                lastSync.Value = DateTime.Now.ToString();

                _settingRepo.AddOrUpdate(lastSync);
                _unitOfWork.Commit();

            });
            t.Start();
            return t;
        }