示例#1
0
        public static void Synchronize(string sqlConnectionString)
        {
            bool isScopeExists = ScopeHelper.CheckScope(sqlConnectionString, true);

            if (!isScopeExists)
            {
                ScopeHelper.CreateScope(sqlConnectionString, true);
            }

            using (var localDbConnection = new SqlCeConnection(Constants.LocalConnectionString))
                using (var remoteDbConnection = new SqlConnection(sqlConnectionString))
                {
                    var syncOrchestrator = new SyncOrchestrator
                    {
                        Direction      = SyncDirectionOrder.DownloadAndUpload,
                        RemoteProvider =
                            new SqlSyncProvider("SyncScope", remoteDbConnection),
                        LocalProvider = new SqlCeSyncProvider("SyncScope", localDbConnection)
                    };

                    syncOrchestrator.Synchronize();
                }

            ContactsManager.Current.RefreshCache();
            CompaniesManager.Current.RefreshCache();
        }
示例#2
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            LanguageDictionary.RegisterDictionary(
                CultureInfo.GetCultureInfo("en-US"),
                new XmlLanguageDictionary("Languages/en-US.xml"));

            LanguageDictionary.RegisterDictionary(
                CultureInfo.GetCultureInfo("es-ES"),
                new XmlLanguageDictionary("Languages/es-ES.xml"));

            LanguageDictionary.RegisterDictionary(
                CultureInfo.GetCultureInfo("fr-FR"),
                new XmlLanguageDictionary("Languages/fr-FR.xml"));

            LanguageDictionary.RegisterDictionary(
                CultureInfo.GetCultureInfo("it-IT"),
                new XmlLanguageDictionary("Languages/it-IT.xml"));

            var culture = CurrentCultureManager.Current.CurrentCultureName;

            culture = string.IsNullOrEmpty(culture) ? "en-US" : culture;
            LanguageContext.Current.Culture = CultureInfo.GetCultureInfo(culture);


            DispatcherUnhandledException += onDispatcherUnhandledException;

            //Prepare db for synchronization.
            if (!ScopeHelper.CheckScope(Constants.LocalConnectionString))
            {
                ScopeHelper.CreateScope(Constants.LocalConnectionString);
            }

            base.OnStartup(e);

            SyncServiceManager.Current.RunService();
        }