/// <summary>
        /// Syncs the specified server URI.
        /// </summary>
        /// <param name="serverUri">The server URI.</param>
        /// <param name="learningModuleId">The learning module id.</param>
        /// <param name="userId">The user id.</param>
        /// <param name="path">The path.</param>
        /// <param name="createNew">if set to <c>true</c> [create new].</param>
        /// <param name="overwrite">if set to <c>true</c> [overwrite].</param>
        /// <param name="reportingDelegate">The reporting delegate.</param>
        /// <remarks>Documented by Dev03, 2009-02-12</remarks>
        private static void Sync(string serverUri, int learningModuleId, int userId, ref string path, bool contentProtected, string password, bool createNew, bool overwrite, SyncStatusReportingDelegate reportingDelegate)
        {
            syncStatusDelegate = reportingDelegate;
            SyncAgent syncAgent = SyncClient.GetAgent(serverUri, learningModuleId, userId, ref path, contentProtected, password, createNew, overwrite);
            syncAgent.SessionProgress += new EventHandler<SessionProgressEventArgs>(syncAgent_SessionProgress);
            (syncAgent.LocalProvider as SqlCeClientSyncProvider).ApplyChangeFailed += new EventHandler<ApplyChangeFailedEventArgs>(syncAgent_ApplyChangeFailed);
            try
            {
                SyncStatistics stats = syncAgent.Synchronize();
                if (SyncClient.IsNewDb(syncAgent))
                    SyncClient.ApplyIndicesToDatabase(path, contentProtected, password);

                string text = string.Empty;
                foreach (PropertyInfo info in stats.GetType().GetProperties())
                    text += info.Name + ": " + info.GetValue(stats, null).ToString() + Environment.NewLine;
                Trace.WriteLine(text);

                //If IDENTITY Problem apears again --> uncomment this lines
                //syncStatusDelegate.Invoke(-1, Resources.SyncStateCheckingDataIntegrity);
                //SyncClient.VerifyDataBase(path, contentProtected, password);
                //syncStatusDelegate.Invoke(100, string.Empty);
            }
            catch (Exception ex)
            {
                syncStatusDelegate.Invoke(100, "Sync failed!");
                Trace.WriteLine("LearningModulesPage.Sync - " + ex.Message);

                DriveInfo info = new DriveInfo(path[0].ToString());
                if (info.TotalFreeSpace < 1000000)   //FreeSpace <1MB
                    throw new NotEnoughtDiskSpaceException();

                throw new SynchronizationFailedException(ex);
            }
        }