public UnitOfWork(OfflineContext db) { _db = db; District = new DistrictRepository(_db); Region = new RegionRepository(_db); Employee = new EmployeeRepository(_db); }
void LoadApplication() { try { if (DAL == null) { EntityFactory.CreateInstance = Entity.CreateInstance; EntityFactory.DbRefFactory = DbRef.CreateInstance; EntityFactory.CustomDictionaryFactory = () => new CustomDictionary(); IDictionary <string, string> deviceInfo = BitBrowserApp.Current.GetDeviceInfo(); XmlDocument document = LoadMetadata(); var uri = new Uri(_settings.Url); Database.Init(_settings.BaseUrl); IsolatedStorageOfflineContext context = new OfflineContext(document, uri.Host, uri); var configuration = document.DocumentElement; Settings.ConfigName = configuration.Attributes ["Name"].Value; Settings.ConfigVersion = configuration.Attributes ["Version"].Value; Settings.WriteSettings(); DAL = new DAL(context , _settings.Application , _settings.Language , _settings.UserName , _settings.Password , Settings.ConfigName , Settings.ConfigVersion , deviceInfo , (total, processed) => { if (LoadingProgress != null) { LoadingProgress(total, processed, D.LOADING_SOLUTION); } }, CacheRequestFactory); } DAL.UpdateCredentials(_settings.UserName, _settings.Password); DAL.LoadSolution(_settings.ClearCacheOnStart, _settings.SyncOnStart, LoadComplete); } catch (CustomException e) { ReturnToStartMenu(e.FriendlyMessage, e.Report); } catch (UriFormatException) { ReturnToStartMenu(D.INVALID_ADDRESS, D.INVALID_ADDRESS); } catch (Exception e) { ReturnToStartMenu(D.LOADING_ERROR, e.ToString()); } }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { context = (OfflineContext)e.Parameter; if (context != null && !string.IsNullOrWhiteSpace(context.Text)) { notebody.Text = context.Text; } }
void LoadApplication(bool clearCache) { if (String.IsNullOrEmpty(Settings.UserName) || String.IsNullOrEmpty(Settings.Password)) { Logon(clearCache); return; } try { _backgroundTaskId = UIApplication.SharedApplication.BeginBackgroundTask(() => { }); if (this.DAL == null) { EntityFactory.CreateInstance = Entity.CreateInstance; EntityFactory.DbRefFactory = DbRef.CreateInstance; EntityFactory.CustomDictionaryFactory = () => new CustomDictionary(); XmlDocument document = LoadMetadata(); Uri uri = new Uri(Settings.Url); //to create db here BitMobile.DbEngine.Database.Init(Settings.BaseUrl); IsolatedStorageOfflineContext context = new OfflineContext(document, uri.Host, uri); var configuration = document.DocumentElement; Settings.ConfigName = configuration.Attributes ["Name"].Value; Settings.ConfigVersion = configuration.Attributes ["Version"].Value; Settings.WriteSettings(); IDictionary <string, string> deviceInfo = GetDeviceInfo(); this.DAL = new DAL(context , Settings.Application , Settings.Language , Settings.UserName , Settings.Password , Settings.ConfigName , Settings.ConfigVersion , deviceInfo , UpdateLoadStatus , CacheRequestFactory); this._commonData = new BitMobile.ValueStack.CommonData(); this.Settings.ConfigName = DAL.ConfigName; this.Settings.ConfigVersion = DAL.ConfigVersion; } LogonComplete(clearCache); } catch (CustomException ex) { Logon(clearCache, ex.FriendlyMessage); } catch (UriFormatException) { Logon(clearCache, D.INVALID_ADDRESS); } }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Parameter.ToString())) { offlineContext = (OfflineContext)e.Parameter; } // TODO: Prepare page for display here. // TODO: If your application contains multiple pages, ensure that you are // handling the hardware Back button by registering for the // Windows.Phone.UI.Input.HardwareButtons.BackPressed event. // If you are using the NavigationHelper provided by some templates, // this event is handled for you. }
public static void LogErrorMessage(bool isConnected, string error, string innerException) { MVIOperationsContext _db = new MVIOperationsContext(); OfflineContext _oc = new OfflineContext(); var e = new Error(); e.Time = DateTime.Now; e.ErrorMessage = error; e.InnerException = innerException; if (isConnected) { _db.Error.Add(e); } else { _oc.Error.Add(e); } }
//OfflineContext _db = new OfflineContext(); public DistrictRepository(OfflineContext db) : base(db) { }
//OfflineContext _db = new OfflineContext(); public RegionRepository(OfflineContext db) : base(db) { }
private void ClearSyncConflict(SyncConflict syncConflict, OfflineContext context) { }
public void AddSerializedError(SyncError error, OfflineContext context) { }
public void AddSyncError(SyncError error, OfflineContext context) { }
public void AddErrors(IEnumerable <SyncError> errors, OfflineContext context) { }
public void AddSerializedConflict(SyncConflict conflict, OfflineContext context) { }
public void AddConflicts(IEnumerable <SyncConflict> conflicts, OfflineContext context) { }
public Repository(OfflineContext db) { _db = db; }
//OfflineContext _db = new OfflineContext(); public EmployeeRepository(OfflineContext db) : base(db) { }