Example #1
0
 protected virtual void OnApplyingChanges(ApplyingChangesEventArgs args)
 {
     if (ApplyingChanges != null)
     {
         ApplyingChanges(this, args);
     }
 }
Example #2
0
        //Look for inserted rows in the dataset that have a CustomerType
        //of Wholesale and update these rows. With access to the dataset,
        //you can write any business logic that your application requires.
        //<snippetOCS_CS_Events_BusinessLogic>
        private void SampleServerSyncProvider_ApplyingChanges(object sender, ApplyingChangesEventArgs e)
        {
            DataTable customerDataTable = e.Changes.Tables["Customer"];

            for (int i = 0; i < customerDataTable.Rows.Count; i++)
            {
                if (customerDataTable.Rows[i].RowState == DataRowState.Added &&
                    customerDataTable.Rows[i]["CustomerType"] == "Wholesale")
                {
                    customerDataTable.Rows[i]["CustomerType"] = "Wholesale (from mobile sales)";
                }
            }
        }
Example #3
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);
        }
Example #4
0
 protected override void OnApplyingChanges(ApplyingChangesEventArgs value)
 {
     Console.Write("on applying changes on client..");
     base.OnApplyingChanges(value);
 }