Example #1
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)
                {
                    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);
            }
        }
Example #2
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);
            }
        }