Beispiel #1
0
		internal FillErrorEventArgs CreateFillErrorEvent (DataTable dataTable, object[] values, Exception e)
		{
			FillErrorEventArgs args = new FillErrorEventArgs (dataTable, values);
			args.Errors = e;
			args.Continue = false;
			return args;
		}
        private void OnFillErrorHandler(Exception e, DataTable dataTable, object[] dataValues) {
            FillErrorEventArgs fillErrorEvent = new FillErrorEventArgs(dataTable, dataValues);
            fillErrorEvent.Errors = e;
            OnFillError(fillErrorEvent);

            if (!fillErrorEvent.Continue) {
                if (null != fillErrorEvent.Errors) {
                    throw fillErrorEvent.Errors;
                }
                throw e;
            }
        }
 virtual protected void OnFillError(FillErrorEventArgs value) { // V1.2.3300, DbDataAdapter V1.0.3300
     FillErrorEventHandler handler = (FillErrorEventHandler) Events[EventFillError];
     if (null != handler) {
         handler(this, value);
     }
 }
Beispiel #4
0
 private void _dbDataAdapter_FillError(object sender, FillErrorEventArgs e)
 {
     base.OnFillError(e);
 }
Beispiel #5
0
		internal virtual void OnFillErrorInternal (FillErrorEventArgs value)
		{
#if NET_2_0
			OnFillError (value);
#endif
		}
Beispiel #6
0
        private static DataTable LoadTableFromEnumerable <T>(IEnumerable <T> source, DataTable table, LoadOption?options, FillErrorEventHandler errorHandler)
            where T : DataRow
        {
            if (options.HasValue)
            {
                switch (options.Value)
                {
                case LoadOption.OverwriteChanges:
                case LoadOption.PreserveChanges:
                case LoadOption.Upsert:
                    break;

                default:
                    throw DataSetUtil.InvalidLoadOption(options.Value);
                }
            }


            using (IEnumerator <T> rows = source.GetEnumerator())
            {
                // need to get first row to create table
                if (!rows.MoveNext())
                {
                    return(table ?? throw DataSetUtil.InvalidOperation(SR.DataSetLinq_EmptyDataRowSource));
                }

                DataRow current;
                if (table == null)
                {
                    current = rows.Current;
                    if (current == null)
                    {
                        throw DataSetUtil.InvalidOperation(SR.DataSetLinq_NullDataRow);
                    }

                    table = new DataTable()
                    {
                        Locale = CultureInfo.CurrentCulture
                    };

                    // We do not copy the same properties that DataView.ToTable does.
                    // If user needs that functionality, use other CopyToDataTable overloads.
                    // The reasoning being, the IEnumerator<DataRow> can be sourced from
                    // different DataTable, so we just use the "Default" instead of resolving the difference.

                    foreach (DataColumn column in current.Table.Columns)
                    {
                        table.Columns.Add(column.ColumnName, column.DataType);
                    }
                }

                table.BeginLoadData();
                try
                {
                    do
                    {
                        current = rows.Current;
                        if (current == null)
                        {
                            continue;
                        }

                        object[] values = null;
                        try
                        {
                            // 'recoverable' error block
                            switch (current.RowState)
                            {
                            case DataRowState.Detached:
                                if (!current.HasVersion(DataRowVersion.Proposed))
                                {
                                    throw DataSetUtil.InvalidOperation(SR.DataSetLinq_CannotLoadDetachedRow);
                                }
                                goto case DataRowState.Added;

                            case DataRowState.Unchanged:
                            case DataRowState.Added:
                            case DataRowState.Modified:
                                values = current.ItemArray;
                                if (options.HasValue)
                                {
                                    table.LoadDataRow(values, options.Value);
                                }
                                else
                                {
                                    table.LoadDataRow(values, fAcceptChanges: true);
                                }
                                break;

                            case DataRowState.Deleted:
                                throw DataSetUtil.InvalidOperation(SR.DataSetLinq_CannotLoadDeletedRow);

                            default:
                                throw DataSetUtil.InvalidDataRowState(current.RowState);
                            }
                        }
                        catch (Exception e)
                        {
                            if (!DataSetUtil.IsCatchableExceptionType(e))
                            {
                                throw;
                            }

                            FillErrorEventArgs fillError = null;
                            if (null != errorHandler)
                            {
                                fillError = new FillErrorEventArgs(table, values)
                                {
                                    Errors = e
                                };
                                errorHandler.Invoke(rows, fillError);
                            }
                            if (null == fillError)
                            {
                                throw;
                            }
                            else if (!fillError.Continue)
                            {
                                if (ReferenceEquals(fillError.Errors ?? e, e))
                                {
                                    // if user didn't change exception to throw (or set it to null)
                                    throw;
                                }
                                else
                                {
                                    // user may have changed exception to throw in handler
                                    throw fillError.Errors;
                                }
                            }
                        }
                    } while (rows.MoveNext());
                }
                finally
                {
                    table.EndLoadData();
                }
            }
            Debug.Assert(null != table, "null DataTable");
            return(table);
        }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// fillerroreventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this FillErrorEventHandler fillerroreventhandler, Object sender, FillErrorEventArgs e, AsyncCallback callback)
        {
            if(fillerroreventhandler == null) throw new ArgumentNullException("fillerroreventhandler");

            return fillerroreventhandler.BeginInvoke(sender, e, callback, null);
        }
Beispiel #8
0
		internal virtual void OnFillErrorInternal (FillErrorEventArgs value)
		{
			OnFillError (value);
		}
Beispiel #9
0
 /// <summary>Invoked when an error occurs during a Fill.</summary>
 /// <param name="value">A <see cref="T:System.Data.FillErrorEventArgs" /> object.</param>
 protected virtual void OnFillError(FillErrorEventArgs value)
 {
     FillErrorEventHandler fillErrorEventHandler = (FillErrorEventHandler)base.Events[NativeDataAdapter.EventFillError];
     if (fillErrorEventHandler != null)
     {
         fillErrorEventHandler(this, value);
     }
 }
Beispiel #10
0
 private void OnFillErrorHandler(Exception e, DataTable dataTable, object[] dataValues)
 {
     FillErrorEventArgs fillErrorEventArgs = new FillErrorEventArgs(dataTable, dataValues);
     fillErrorEventArgs.Errors = e;
     this.OnFillError(fillErrorEventArgs);
     if (fillErrorEventArgs.Continue)
     {
         return;
     }
     if (fillErrorEventArgs.Errors != null)
     {
         throw fillErrorEventArgs.Errors;
     }
     throw e;
 }
		private void ExecuteSqlFillErrorHandler(object sender, FillErrorEventArgs e)
		{
			log.Error("ExecuteSqlFillErrorHandler", e.Errors);

			// Setting e.Continue to True tells the Load method to continue trying. Setting it to False
			// indicates that an error has occurred, and the Load method raises the exception that got
			// you here.
			e.Continue = true;
		}
 private void OnFillErrorHandler(Exception e, DataTable dataTable, object[] dataValues)
 {
     FillErrorEventArgs args = new FillErrorEventArgs(dataTable, dataValues) {
         Errors = e
     };
     this.OnFillError(args);
     if (!args.Continue)
     {
         if (args.Errors != null)
         {
             throw args.Errors;
         }
         throw e;
     }
 }
 protected virtual void OnFillError(FillErrorEventArgs value)
 {
     FillErrorEventHandler handler = (FillErrorEventHandler) base.Events[EventFillError];
     if (handler != null)
     {
         handler(this, value);
     }
 }
 private static void da_FillError(object sender, FillErrorEventArgs e)
 {
     fillError = e.Errors.Message;
     e.Continue = true;
 }
Beispiel #15
0
        static void adapter_FillError(object sender, FillErrorEventArgs e)
        {

        }
Beispiel #16
0
		private void dbDA_FillError(object sender, FillErrorEventArgs args) {
			blnReadDBData_Fill = true;
			args.Continue = false;
		}
Beispiel #17
0
		internal override void OnFillErrorInternal (FillErrorEventArgs value)
		{
			OnFillError (value);
		}
Beispiel #18
0
		void ErrorHandler (object sender, FillErrorEventArgs args)
		{
			args.Continue = FillErrorContinue;
		}
Beispiel #19
0
		internal static int FillFromReader (DataTable table,
                                                    IDataReader reader,
                                                    int start,
                                                    int length,
                                                    int [] mapping,
                                                    LoadOption loadOption,
                                                    FillErrorEventHandler errorHandler)
		{
			if (reader.FieldCount == 0)
				return 0 ;

			for (int i = 0; i < start; i++)
				reader.Read ();

			int counter = 0;
			object [] values = new object [mapping.Length];
			while (reader.Read () && (length == 0 || counter < length)) {
				for (int i = 0 ; i < mapping.Length; i++)
					values [i] = mapping [i] < 0 ? null : reader [mapping [i]];
				table.BeginLoadData ();
				try {
					table.LoadDataRow (values, loadOption);
				} catch (Exception e) {
					FillErrorEventArgs args = new FillErrorEventArgs (table, values);
					args.Errors = e;
					args.Continue = false;
					errorHandler (table, args);
					// if args.Continue is not set to true or if a handler is not set, rethrow the error..
					if(!args.Continue)
						throw e;
				}
				table.EndLoadData ();
				counter++;
			}
			return counter;
		}
Beispiel #20
0
		protected virtual void OnFillError (FillErrorEventArgs value)
		{
			if (FillError != null)
				FillError (this, value);
		}
Beispiel #21
0
		private void fillErrorHandler (object sender, FillErrorEventArgs e) {
			e.Continue = fillErr[fillErrCounter].contFlag;
			Assert.AreEqual (fillErr[fillErrCounter].tableName, e.DataTable.TableName, "fillErr-T");
			Assert.AreEqual (fillErr[fillErrCounter].contFlag, e.Continue, "fillErr-C");
			fillErrCounter++;
		}
Beispiel #22
0
		private void fillErrorHandler (object sender, FillErrorEventArgs e)
		{
			e.Continue = fillErr[fillErrCounter].contFlag;
			Assert.AreEqual (fillErr[fillErrCounter].tableName, e.DataTable.TableName, "fillErr-T");
			//Assert.AreEqual (fillErr[fillErrCounter].rowKey, e.Values[0], "fillErr-R");
			Assert.AreEqual (fillErr[fillErrCounter].contFlag, e.Continue, "fillErr-C");
			//Assert.AreEqual (fillErr[fillErrCounter].error, e.Errors.Message, "fillErr-E");
			fillErrCounter++;
		}
Beispiel #23
0
 private void OnAdapterFillError(object sender, FillErrorEventArgs e)
 {
     e.Continue = true;
 }