/// <remarks/>
 public System.IAsyncResult BeginGetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession, System.AsyncCallback callback, object asyncState)
 {
     return(this.BeginInvoke("GetChanges", new object[] {
         groupMetadata,
         syncSession
     }, callback, asyncState));
 }
Ejemplo n.º 2
0
 private SyncGroupMetadata InitializeMetadata(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncContext syncContext)
 {
     syncContext.DataSet       = dataSet;
     groupMetadata             = GenerateOrderGroupMetadata(groupMetadata);
     syncContext.GroupProgress = new SyncGroupProgress(groupMetadata, dataSet);
     return(groupMetadata);
 }
Ejemplo n.º 3
0
 /// <remarks/>
 public System.IAsyncResult BeginApplyChanges(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("ApplyChanges", new object[] {
                 groupMetadata,
                 dataSet,
                 syncSession}, callback, asyncState);
 }
Ejemplo n.º 4
0
    public SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
    {
        SyncContext syncContext;

        syncContext = syncServiceClient.GetChanges(groupMetadata, syncSession);
        //Inspect and or modify the syncContext that's received.
        return(syncContext);
    }
Ejemplo n.º 5
0
 public SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession)
 {
     object[] results = this.Invoke("ApplyChanges", new object[] {
                 groupMetadata,
                 dataSet,
                 syncSession});
     return ((SyncContext)(results[0]));
 }
Ejemplo n.º 6
0
 public SyncContext GetChanges(SyncGroupMetadata groupMetaData, SyncSession syncSession)
 {
     object[] results = this.Invoke("GetChanges", new object[] {
         groupMetaData,
         syncSession
     });
     return((SyncContext)(results[0]));
 }
Ejemplo n.º 7
0
 /// <remarks/>
 public System.IAsyncResult BeginApplyChanges(SyncGroupMetadata groupMetaData, System.Data.DataSet changeSet, SyncSession syncSession, System.AsyncCallback callback, object asyncState)
 {
     return(this.BeginInvoke("ApplyChanges", new object[] {
         groupMetaData,
         changeSet,
         syncSession
     }, callback, asyncState));
 }
Ejemplo n.º 8
0
        public override SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession)
        {
            Console.Write("apply changes on client..");
            PrintDataSet(dataSet);
            var context = base.ApplyChanges(groupMetadata, dataSet, syncSession);

            return(context);
        }
        public SyncContext GetChanges([System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] SyncGroupMetadata groupMetadata, [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] SyncSession syncSession)
        {
            object[] results = this.Invoke("GetChanges", new object[] {
                groupMetadata,
                syncSession
            });

            return((SyncContext)(results[0]));
        }
Ejemplo n.º 10
0
 public SyncContext ApplyChanges(SyncGroupMetadata groupMetaData, System.Data.DataSet changeSet, SyncSession syncSession)
 {
     object[] results = this.Invoke("ApplyChanges", new object[] {
         groupMetaData,
         changeSet,
         syncSession
     });
     return((SyncContext)(results[0]));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Selects for a table in the server database the inserts, updates, and deletes to apply to the client database for a synchronization group.
        /// </summary>
        /// <param name="groupMetadata">A SyncGroupMetadata object that contains metadata about the synchronization group.</param>
        /// <param name="syncSession">A SyncSession object that contains synchronization session variables, such as the ID of the client that is synchronizing.</param>
        /// <returns>A SyncContext object that contains synchronization data and metadata.</returns>
        public override SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
        {//#DOWNLOAD a batch 1
            if (groupMetadata == null)
            {
                throw new ArgumentNullException("groupMetadata");
            }
            if (syncSession == null)
            {
                throw new ArgumentNullException("syncSession");
            }

            SyncContext syncContext = new SyncContext();
            DataSet     dataSet     = new DataSet();

            groupMetadata = InitializeMetadata(groupMetadata, dataSet, syncContext);

            SelectingChangesEventArgs selectingArgs = new SelectingChangesEventArgs(groupMetadata, syncSession, syncContext, Connection, null);

            OnSelectingChanges(selectingArgs);

            SyncSchema          schema        = new SyncSchema();
            Collection <string> tables        = new Collection <string>();
            Collection <string> missingTables = new Collection <string>();

            foreach (var tableMetadata in groupMetadata.TablesMetadata)
            {
                tables.Add(tableMetadata.TableName);
            }

            if (tables.Count > 0)
            {
                schema = GetSchemaInternal(tables, out missingTables);
            }

            if (missingTables != null)
            {
                string[] tableArray = new string[missingTables.Count];
                missingTables.CopyTo(tableArray, 0);
                SchemaException e = new SchemaException(String.Format(CultureInfo.CurrentCulture,
                                                                      Messages.MissingTables, String.Join(", ", tableArray)));
                e.SyncStage   = SyncStage.ReadingSchema;
                e.ErrorNumber = SyncErrorNumber.MissingTableSchema;
                throw e;
            }

            // FIX: Get schema from somewhere (possibly the adapter or a temporary schema)
            // Possible performance hit when in mobile

            EnumerateChanges(groupMetadata, syncSession, syncContext, schema);

            ChangesSelectedEventArgs selectedArgs = new ChangesSelectedEventArgs(groupMetadata, syncSession, syncContext, Connection, null);//sYNC tODO

            OnChangesSelected(selectedArgs);

            return(syncContext);
        }
Ejemplo n.º 12
0
 /// <remarks/>
 public void GetChangesAsync(SyncGroupMetadata groupMetadata, SyncSession syncSession, object userState)
 {
     if ((this.GetChangesOperationCompleted == null))
     {
         this.GetChangesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetChangesOperationCompleted);
     }
     this.InvokeAsync("GetChanges", new object[] {
         groupMetadata,
         syncSession
     }, this.GetChangesOperationCompleted, userState);
 }
Ejemplo n.º 13
0
        internal static AnchorException ReadingAnchorError(SyncGroupMetadata metadata, SyncSession session, string source, string helpLink, Exception inner)
        {
            AnchorException anchorException = new AnchorException(SyncResource.GetString("GetNewServerAnchorFailed"), inner);

            anchorException.SyncSource    = source;
            anchorException.SyncStage     = SyncStage.DownloadingChanges;
            anchorException.ErrorNumber   = SyncErrorNumber.StoreException;
            anchorException.GroupMetadata = metadata;
            anchorException.HelpLink      = helpLink;
            anchorException.Session       = session;
            SyncTracer.Warning("{0}", new object[1]
            {
                (object)anchorException
            });
            return(anchorException);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Applies inserts, updates, and deletes for a synchronization group to the server database.
        /// </summary>
        /// <param name="groupMetadata">A SyncGroupMetadata object that contains metadata about the synchronization group.</param>
        /// <param name="dataSet">A DataSet object that contains the changes to be applied to the server database for each table in the synchronization group.</param>
        /// <param name="syncSession">A SyncSession object that contains synchronization session variables, such as the ID of the client that is synchronizing.</param>
        /// <returns>A SyncContext object that contains synchronization data and metadata.</returns>
        /// #UPLOAD 1
        public override SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
        {
            if (groupMetadata == null)
            {
                throw new ArgumentNullException("groupMetadata");
            }
            if (syncSession == null)
            {
                throw new ArgumentNullException("syncSession");
            }

            SyncContext syncContext = new SyncContext();

            groupMetadata = InitializeMetadata(groupMetadata, dataSet, syncContext);

            // connect to database
            Connection.Open();

            // create transaction

            ApplyingChangesEventArgs applyingArgs = new ApplyingChangesEventArgs(groupMetadata, dataSet, syncSession, syncContext, Connection, null);

            OnApplyingChanges(applyingArgs);

            ApplyChangesInternal(groupMetadata, dataSet, syncSession, syncContext);
            // commit transaction

            ChangesAppliedEventArgs appliedArgs = new ChangesAppliedEventArgs(groupMetadata, syncSession, syncContext, Connection, null);

            OnChangesApplied(appliedArgs);

            // disconnect from database
            Connection.Close();

            return(syncContext);
        }
Ejemplo n.º 15
0
        private SyncGroupMetadata GenerateOrderGroupMetadata(SyncGroupMetadata groupMetadata)
        {
            if (groupMetadata.TablesMetadata.Count <= 1)
            {
                return(groupMetadata);
            }

            SyncTableMetadata[] tableMetadatas = new SyncTableMetadata[groupMetadata.TablesMetadata.Count];
            for (int i = 0; i < groupMetadata.TablesMetadata.Count; ++i)
            {
                int index = SyncAdapters.IndexOf(groupMetadata.TablesMetadata[i].TableName);

                if (index == -1)
                {
                    throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
                                                              Messages.InvalidTableName, groupMetadata.TablesMetadata[i].TableName));
                }
                else
                {
                    tableMetadatas[index] = groupMetadata.TablesMetadata[i];
                }
            }
            SyncGroupMetadata newGroupMetadata = new SyncGroupMetadata(groupMetadata);

            newGroupMetadata.TablesMetadata.Clear();

            for (int i = 0; i < tableMetadatas.Length; i++)
            {
                if (tableMetadatas[i] != null)
                {
                    newGroupMetadata.TablesMetadata.Add(tableMetadatas[i]);
                }
            }

            return(newGroupMetadata);
        }
Ejemplo n.º 16
0
 /// <remarks/>
 public void ApplyChangesAsync(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession)
 {
     this.ApplyChangesAsync(groupMetadata, dataSet, syncSession, null);
 }
Ejemplo n.º 17
0
 public override SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
 {
     return(this.mServiceProxy.GetChanges(groupMetadata, syncSession));
 }
Ejemplo n.º 18
0
 public SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
 {
     object[] results = this.Invoke("GetChanges", new object[] {
                 groupMetadata,
                 syncSession});
     return ((SyncContext)(results[0]));
 }
Ejemplo n.º 19
0
 public SyncContext ApplyChanges(SyncGroupMetadata groupMetaData, System.Data.DataSet changeSet, SyncSession syncSession)
 {
     return(this.mSyncProvider.ApplyChanges(groupMetaData, changeSet, syncSession));
 }
Ejemplo n.º 20
0
		/// <remarks/>
		public void ApplyChangesAsync(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession, object userState) {
			if ((this.ApplyChangesOperationCompleted == null)) {
				this.ApplyChangesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnApplyChangesOperationCompleted);
			}
			this.InvokeAsync("ApplyChanges", new object[] {
						groupMetadata,
						dataSet,
						syncSession}, this.ApplyChangesOperationCompleted, userState);
		}
 public virtual SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
 {
     return this._serverSyncProvider.GetChanges(groupMetadata, syncSession);
 }
Ejemplo n.º 22
0
 public override SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
 {
     return(serviceProxy.ApplyChanges(groupMetadata, dataSet, syncSession));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Enumerates the changes from the server and puts them to the synccontext object
        /// </summary>
        /// <param name="groupMetadata">the metadata about the synchronization tables</param>
        /// <param name="syncSession">the object that contains synchronization variables</param>
        /// <param name="syncContext">the synchronization context to be changed</param>
        /// <param name="schema">the schema of the synchronization tables</param>
        private void EnumerateChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession, SyncContext syncContext, SyncSchema schema)
        {//#DOWNLOAD a batch 2
            SyncStage syncStage = SyncStage.DownloadingChanges;

            SpSyncGroupAnchor newSyncAnchor = new SpSyncGroupAnchor();

            bool hasMoreData = false;

            foreach (SyncTableMetadata tableMetadata in groupMetadata.TablesMetadata)
            {
                SpSyncAdapter adapter = null;

                if (this.SyncAdapters.Contains(tableMetadata.TableName))
                {
                    adapter = this.SyncAdapters[tableMetadata.TableName];
                }

                if (adapter == null)
                {
                    throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
                                                              Messages.InvalidTableName, tableMetadata.TableName));
                }

                if (!schema.SchemaDataSet.Tables.Contains(tableMetadata.TableName))
                {
                    throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
                                                              Messages.TableNotInSchema, tableMetadata.TableName));
                }

                DataTable dataTable = schema.SchemaDataSet.Tables[tableMetadata.TableName].Clone();

                SyncTableProgress tableProgress = syncContext.GroupProgress.FindTableProgress(tableMetadata.TableName);

                SpSyncAnchor tableAnchor = SpSyncAnchor.Empty;

                if (tableMetadata.LastReceivedAnchor != null &&
                    tableMetadata.LastReceivedAnchor.Anchor != null)
                {
                    SpSyncGroupAnchor anchors = SpSyncGroupAnchor.Deserialize(tableMetadata.LastReceivedAnchor.Anchor);
                    if (anchors != null)
                    {
                        if (anchors.Contains(connString, tableMetadata.TableName))
                        {
                            tableAnchor = anchors[connString, tableMetadata.TableName];
                        }
                        newSyncAnchor = anchors;
                    }
                }

                SpSyncAnchor newAnchor = SpSyncAnchor.Empty;

                try
                {
                    if (tableMetadata.SyncDirection == SyncDirection.Snapshot)
                    {
                        newAnchor = adapter.SelectAll(tableAnchor, BatchSize, dataTable, Connection);
                    }
                    else
                    {
                        newAnchor = adapter.SelectIncremental(tableAnchor, BatchSize, Connection, dataTable);
                    }

                    hasMoreData = hasMoreData || newAnchor.HasMoreData;

                    if (syncContext.DataSet.Tables.Contains(tableMetadata.TableName))
                    {
                        DataTable contextTable = syncContext.DataSet.Tables[tableMetadata.TableName];
                        foreach (DataRow row in dataTable.Rows)
                        {
                            contextTable.ImportRow(row);
                        }
                    }
                    else
                    {
                        dataTable.TableName = tableMetadata.TableName;
                        syncContext.DataSet.Tables.Add(dataTable);
                    }
                }
                catch (Exception e)
                {
                    var e2 = new Microsoft.Synchronization.SyncException(e.Message, e);
                    throw e2;
                }
                finally
                {
                    newSyncAnchor[connString, tableMetadata.TableName] = newAnchor;
                }

                tableProgress.DataTable = dataTable;
                SyncProgressEventArgs args = new SyncProgressEventArgs(tableMetadata, tableProgress, groupMetadata, syncContext.GroupProgress, syncStage);//SYNC TODO
                OnSyncProgress(args);
                tableProgress.DataTable = null;
            }

            syncContext.NewAnchor = new SyncAnchor();

            syncContext.NewAnchor.Anchor = SpSyncGroupAnchor.Serialize(newSyncAnchor);

            int batchCount = groupMetadata.BatchCount == 0 ? 1 : groupMetadata.BatchCount;

            if (hasMoreData)
            {
                syncContext.BatchCount = batchCount + 1;
            }
            else
            {
                syncContext.BatchCount = batchCount;
            }
        }
Ejemplo n.º 24
0
 public SyncContext GetChanges(SyncGroupMetadata groupMetaData, SyncSession syncSession)
 {
     return(this.mSyncProvider.GetChanges(groupMetaData, syncSession));
 }
Ejemplo n.º 25
0
 public virtual SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
 {
     return(this._serverSyncProvider.ApplyChanges(groupMetadata, dataSet, syncSession));
 }
Ejemplo n.º 26
0
        /// #UPLOAD 2
        private void ApplyChangesInternal(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession, SyncContext syncContext)
        {
            SyncStage syncStage = SyncStage.UploadingChanges;

            foreach (SyncTableMetadata tableMetadata in groupMetadata.TablesMetadata)
            {
                SpSyncAdapter adapter = null;

                if (this.SyncAdapters.Contains(tableMetadata.TableName))
                {
                    adapter = this.SyncAdapters[tableMetadata.TableName];
                }

                if (adapter == null)
                {
                    throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
                                                              Messages.InvalidTableName, tableMetadata.TableName));
                }


                // SpSyncAnchor anchor
                if (!dataSet.Tables.Contains(tableMetadata.TableName))
                {
                    throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
                                                              Messages.TableNotInSchema, tableMetadata.TableName));
                }

                SyncTableProgress tableProgress = syncContext.GroupProgress.FindTableProgress(tableMetadata.TableName);

                DataTable dataTable = dataSet.Tables[tableMetadata.TableName];

                try
                {
                    Collection <SyncConflict> conflicts;
                    int changesCount = dataTable.Rows.Count;
                    adapter.Update(dataTable, Connection, out conflicts);

                    if (conflicts != null)
                    {
                        foreach (SyncConflict conflict in conflicts)
                        {
                            ApplyChangeFailedEventArgs failureArgs = new ApplyChangeFailedEventArgs(tableMetadata, conflict, null, syncSession, syncContext, Connection, null);
                            OnApplyChangeFailed(failureArgs);

                            if (failureArgs.Action == ApplyAction.Continue)
                            {
                                if (conflict != null)
                                {
                                    tableProgress.ChangesFailed++;
                                    tableProgress.Conflicts.Add(conflict);
                                }
                            }
                        }
                    }
                    tableProgress.ChangesApplied = changesCount - tableProgress.ChangesFailed;
                }
                catch (Exception e)
                {
                    SyncConflict conflict = new SyncConflict(ConflictType.ErrorsOccurred, SyncStage.UploadingChanges)
                    {
                        ErrorMessage = e.Message + ", InnerException:" + e.InnerException.ToString(), ServerChange = dataTable, ClientChange = dataTable
                    };
                    ApplyChangeFailedEventArgs failureArgs = new ApplyChangeFailedEventArgs(tableMetadata, conflict, null, syncSession, syncContext, Connection, null);
                    OnApplyChangeFailed(failureArgs);
                    // handle errors?
                    if (SyncTracer.IsErrorEnabled())
                    {
                        SyncTracer.Error(e.ToString());
                    }
                }

                SyncProgressEventArgs args = new SyncProgressEventArgs(tableMetadata, tableProgress, groupMetadata, syncContext.GroupProgress, syncStage);
                OnSyncProgress(args);
            }
        }
Ejemplo n.º 27
0
 public virtual SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
 {
     return(this._serverSyncProvider.GetChanges(groupMetadata, syncSession));
 }
Ejemplo n.º 28
0
 public SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, Microsoft.Synchronization.Data.SyncSession syncSession)
 {
     return serverSyncProvider.ApplyChanges(groupMetadata, dataSet, syncSession);
 }
Ejemplo n.º 29
0
		/// <remarks/>
		public void GetChangesAsync(SyncGroupMetadata groupMetadata, SyncSession syncSession) {
			this.GetChangesAsync(groupMetadata, syncSession, null);
		}
Ejemplo n.º 30
0
 public SyncContext GetChanges(SyncGroupMetadata groupMetadata, Microsoft.Synchronization.Data.SyncSession syncSession)
 {
     return serverSyncProvider.GetChanges(groupMetadata, syncSession);
 }
Ejemplo n.º 31
0
		/// <remarks/>
		public void ApplyChangesAsync(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession) {
			this.ApplyChangesAsync(groupMetadata, dataSet, syncSession, null);
		}
Ejemplo n.º 32
0
 /// <remarks/>
 public void GetChangesAsync(SyncGroupMetadata groupMetadata, SyncSession syncSession)
 {
     this.GetChangesAsync(groupMetadata, syncSession, null);
 }
 public virtual SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
 {
     return this._serverSyncProvider.ApplyChanges(groupMetadata, dataSet, syncSession);
 }