Exemple #1
0
        public Dal(IOfflineContext context
                   , String appName
                   , String language
                   , String userName
                   , String userPassword
                   , String configName
                   , String configVersion
                   , IDictionary <string, string> deviceInfo
                   , Action <int, int> p)
        {
            ServicePointManager.Expect100Continue = false;

            _appName       = appName;
            _language      = language;
            _configName    = configName;
            _configVersion = configVersion;
            _onProgress    = p;

            _context = context;
            _context.LoadCompleted += context_LoadCompleted;
            _context.CacheController.RefreshCompleted += CacheController_RefreshCompleted;
            _context.CacheController.ControllerBehavior.Credentials          = new NetworkCredential(userName, userPassword);
            _context.CacheController.ControllerBehavior.ConfigName           = _configName;
            _context.CacheController.ControllerBehavior.ConfigVersion        = _configVersion;
            _context.CacheController.ControllerBehavior.CoreVersion          = CoreInformation.CoreVersion;
            _context.CacheController.ControllerBehavior.ReadProgressCallback = ReadProgressCallback;
            _context.CacheController.ControllerBehavior.DeviceInfo           = deviceInfo;

            DeviceId = deviceInfo["deviceId"];
        }
Exemple #2
0
        public Dal(IOfflineContext context
            , String appName
            , String language
            , String userName
            , String userPassword
            , String configName
            , String configVersion
            , IDictionary<string, string> deviceInfo
            , Action<int, int> p)
        {
            ServicePointManager.Expect100Continue = false;

            _appName = appName;
            _language = language;
            _configName = configName;
            _configVersion = configVersion;
            _onProgress = p;

            _context = context;
            _context.LoadCompleted += context_LoadCompleted;
            _context.CacheController.RefreshCompleted += CacheController_RefreshCompleted;
            _context.CacheController.ControllerBehavior.Credentials = new NetworkCredential(userName, userPassword);
            _context.CacheController.ControllerBehavior.ConfigName = _configName;
            _context.CacheController.ControllerBehavior.ConfigVersion = _configVersion;
            _context.CacheController.ControllerBehavior.CoreVersion = CoreInformation.CoreVersion;
            _context.CacheController.ControllerBehavior.ReadProgressCallback = ReadProgressCallback;
            _context.CacheController.ControllerBehavior.DeviceInfo = deviceInfo;

            DeviceId = deviceInfo["deviceId"];
        }
        public SQLiteCacheData(IsolatedStorageSchema schema, IOfflineContext context)
        {
//            Collections = new Dictionary<EntityType, IsolatedStorageCollection>();
            SyncConflicts = new List<SyncConflict>();
            SyncErrors = new List<SyncError>();

            CreateCollections(schema, context);
        }
        public SQLiteCacheData(IsolatedStorageSchema schema, IOfflineContext context)
        {
//            Collections = new Dictionary<EntityType, IsolatedStorageCollection>();
            SyncConflicts = new List <SyncConflict>();
            SyncErrors    = new List <SyncError>();

            CreateCollections(schema, context);
        }
        private void CreateCollections(IsolatedStorageSchema schema, IOfflineContext context)
        {
//            Type collectionType = typeof(IsolatedStorageCollection<>);
//            foreach (EntityType t in schema.Collections)
//            {
//                // CreateInstance the generic type for the type in the collection.
//                Type generic = collectionType.MakeGenericType(t);
//                IsolatedStorageCollection collection = (IsolatedStorageCollection)Activator.CreateInstance(generic, context);
//                Collections[t] = collection;
//            }
        }
Exemple #6
0
        void LoadApplication()
        {
            try
            {
                if (Dal == null)
                {
                    IDictionary <string, string> deviceInfo = BitBrowserApp.Current.GetDeviceInfo();

                    XmlDocument document = LoadMetadata();
                    var         uri      = new UriBuilder(_settings.Url).Uri;

                    DbContext.Current.InitDatabase(_settings.BaseUrl);
                    IOfflineContext context = BitMobile.Application.SyncLibrary.SyncContext.Current.CreateOfflineContext(document, uri.Host, uri);

                    var configuration = document.DocumentElement;
                    Settings.ConfigName    = configuration.Attributes["Name"].Value;
                    Settings.ConfigVersion = configuration.Attributes["Version"].Value;
                    Settings.WriteSettings();

                    Dal = DalContext.Current.CreateDal(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);
                        }
                    });
                }

                Dal.UpdateCredentials(_settings.UserName, _settings.Password);

                Dal.LoadSolution(_settings.ClearCacheOnStart, _settings.SyncOnStart, LoadComplete);
            }
            catch (CustomException e)
            {
                ReturnToStartMenu(e.FriendlyMessage, e.Report);
            }
            catch (UriFormatException e)
            {
                ReturnToStartMenu(D.INVALID_ADDRESS, D.INVALID_ADDRESS);
            }
            catch (Exception e)
            {
                ReturnToStartMenu(D.LOADING_ERROR, e.ToString());
            }
        }
Exemple #7
0
        public SQLiteStorageHandler(IOfflineContext ctx, IsolatedStorageSchema schema, string cachePath, SymmetricAlgorithm encryptionAlgorithm)
        {
            _context             = ctx;
            _schema              = schema;
            _cachePath           = cachePath;
            _encryptionAlgorithm = encryptionAlgorithm;
            _anchor              = null;

            _knownTypes = new List <IEntityType>();

            AddKnownTypes();
        }
        public SQLiteStorageHandler(IOfflineContext ctx, IsolatedStorageSchema schema, string cachePath, SymmetricAlgorithm encryptionAlgorithm)
        {
            _context = ctx;
            _schema = schema;
            _cachePath = cachePath;
            _encryptionAlgorithm = encryptionAlgorithm;
            _anchor = null;

            _knownTypes = new List<IEntityType>();

            AddKnownTypes();
        }
Exemple #9
0
        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)
                {
                    XmlDocument document = LoadMetadata();
                    Uri         uri      = new Uri(Settings.Url);

                    //to create db here
                    DbContext.Current.InitDatabase(Settings.BaseUrl);
                    IOfflineContext context = SyncContext.Current.CreateOfflineContext(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 = DalContext.Current.CreateDal
                                   (context
                                   , Settings.Application
                                   , Settings.Language
                                   , Settings.UserName
                                   , Settings.Password
                                   , Settings.ConfigName
                                   , Settings.ConfigVersion
                                   , deviceInfo
                                   , UpdateLoadStatus);

                    this._commonData = ValueStackContext.Current.CreateCommonData();

                    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);
            }
        }
Exemple #10
0
 public SQLiteCacheData Load(IOfflineContext context)
 {
     return(new SQLiteCacheData(_schema, context));
 }
 public SQLiteCacheData Load(IOfflineContext context)
 {
     return new SQLiteCacheData(_schema, context);
 }
Exemple #12
0
 public void AddUploadChanges(byte[] anchor, IEnumerable<Conflict> conflicts, IEnumerable<IsolatedStorageOfflineEntity> updatedItems, IOfflineContext context)
 {
 }
Exemple #13
0
        private void CreateCollections(IsolatedStorageSchema schema, IOfflineContext context)
        {
//            Type collectionType = typeof(IsolatedStorageCollection<>);
//            foreach (EntityType t in schema.Collections)
//            {
//                // CreateInstance the generic type for the type in the collection.
//                Type generic = collectionType.MakeGenericType(t);
//                IsolatedStorageCollection collection = (IsolatedStorageCollection)Activator.CreateInstance(generic, context);
//                Collections[t] = collection;
//            }
        }
Exemple #14
0
 public void AddUploadChanges(byte[] anchor, IEnumerable <Conflict> conflicts, IEnumerable <IsolatedStorageOfflineEntity> updatedItems, IOfflineContext context)
 {
 }
Exemple #15
0
 public IDal CreateDal(IOfflineContext context, string appName, string language, string userName, string userPassword,
     string configName, string configVersion, IDictionary<string, string> deviceInfo, Action<int, int> progress)
 {
     return new Dal(context, appName, language, userName, userPassword, configName, configVersion, deviceInfo, progress);
 }
Exemple #16
0
 public IDal CreateDal(IOfflineContext context, string appName, string language, string userName, string userPassword,
                       string configName, string configVersion, IDictionary <string, string> deviceInfo, Action <int, int> progress)
 {
     return(new Dal(context, appName, language, userName, userPassword, configName, configVersion, deviceInfo, progress));
 }