/// <summary> /// Apply an action on the rows /// </summary> /// <param name="observed">observed operation</param> /// <param name="rowact">callback method for the action</param> /// <returns>resulting operation</returns> public static ApplyOperation Apply(this IObservableOperation observed, Action <Row> rowact) { var op = new ApplyOperation(rowact); observed.Subscribe(op); return(op); }
/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="activator">command parameters</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, CommandActivator activator) { var cmd = new CommandOperation(activator, LogProvider.GetLogger(typeof(CommandOperation).ToString())); observed.Subscribe(cmd); return(cmd); }
/// <summary> /// Write text followed by currently processed row number on console /// </summary> /// <param name="observed">observed operation</param> /// <param name="text">callback method for the action</param> /// <returns>resulting operation</returns> public static ConsoleCountOperation ConsoleCount(this IObservableOperation observed, string text) { var op = new ConsoleCountOperation(text); observed.Subscribe(op); return(op); }
/// <summary> /// Apply an action on the rows /// </summary> /// <param name="observed">observed operation</param> /// <returns>resulting operation</returns> public static EtlResult Start(this IObservableOperation observed) { var op = new StartOperation(); observed.Subscribe(op); op.Trigger(); return op.Result; }
/// <summary> /// Mapper entre 2 objets /// </summary> /// <param name="observed"></param> /// <param name="sourceType"></param> /// <param name="destinationType"></param> /// <returns></returns> public static MapperOperation Mapper(this IObservableOperation observed, Type sourceType, Type destinationType) { MapperOperation cmd = new MapperOperation(sourceType, destinationType); observed.Subscribe(cmd); return(cmd); }
/// <summary> /// Dispatch the grouped elements (trigger for every grouped rows) /// </summary> /// <param name="observed">observed operation</param> /// <returns>resulting operation</returns> public static DispatchGroupOperation DispatchGroup(this IObservableOperation observed) { var op = new DispatchGroupOperation(); observed.Subscribe(op); return(op); }
/// <summary> /// Transform the pipelined row /// </summary> /// <param name="observed">observed operation</param> /// <param name="transform">callback method for transforming the row</param> /// <returns>resulting operation</returns> public static TransformOperation Many(this IObservableOperation observed, Func <Row, IEnumerable <Row> > transform) { var op = new TransformOperation(transform); observed.Subscribe(op); return(op); }
/// <summary> /// Filter the rows /// </summary> /// <param name="observed">observed operation</param> /// <param name="filterexpr">callback method for filtering</param> /// <returns>resulting operation</returns> public static FilterOperation Filter(this IObservableOperation observed, Predicate <Row> filterexpr) { var op = new FilterOperation(filterexpr); observed.Subscribe(op); return(op); }
/// <summary> /// Operation that record values in a list. /// Beware that this operation keep a list of all data in memory /// </summary> /// <param name="observed">observed operation</param> /// <returns>resulting operation</returns> public static RecordOperation Record(this IObservableOperation observed) { var observer = new RecordOperation(); observed.Subscribe(observer); return(observer); }
/// <summary> /// Add an operation in the pipeline. /// </summary> /// <typeparam name="T">type of the operation</typeparam> /// <param name="observed">observed operation</param> /// <param name="args">arguments for the constructor</param> /// <returns>resulting operation</returns> public static T Operation <T>(this IObservableOperation observed, params object[] args) where T : IOperation { T op = (T)Activator.CreateInstance(typeof(T), args); observed.Subscribe(op); return(op); }
/// <summary> /// Join an enumeration of elements to the pipeline /// </summary> /// <typeparam name="T">type of elements to join</typeparam> /// <param name="observed">observed operation</param> /// <param name="activator">join parameters</param> /// <returns>resulting operation</returns> public static JoinOperation <T> Join <T>(this IObservableOperation observed, JoinActivator <T> activator) { var op = new JoinOperation <T>(activator); observed.Subscribe(op); return(op); }
/// <summary> /// Transform the pipelined row /// </summary> /// <param name="observed">observed operation</param> /// <param name="transform">callback method for transforming the row</param> /// <returns>resulting operation</returns> public static TransformOperation Transform(this IObservableOperation observed, Func <Row, Row> transform) { TransformOperation op = new TransformOperation(transform); observed.Subscribe(op); return(op); }
/// <summary> /// Join an enumeration of elements to the pipeline /// </summary> /// <param name="observed">observed operation</param> /// <param name="rightOp">operation to join</param> /// <param name="leftField">Name of the field used for the join</param> /// <param name="rightField">Name of the field used for the join</param> /// <param name="processrow">callback method called to process the row</param> /// <returns>resulting operation</returns> public static JoinOperation <Row> RightJoin(this IObservableOperation observed, IEnumerable <Row> rightOp, string leftField, string rightField, Func <Row, Row, Row> processrow) { return(observed.Join( rightOp, new RowJoinHelper(leftField, rightField).RightJoinMatch, processrow)); }
/// <summary> /// Join an enumeration of elements to the pipeline /// </summary> /// <param name="observed">observed operation</param> /// <param name="rightOp">operation to join</param> /// <param name="field">Name of the field used for the join</param> /// <param name="processrow">callback method called to process the row</param> /// <returns>resulting operation</returns> public static JoinOperation <Row> FullJoin(this IObservableOperation observed, IEnumerable <Row> rightOp, string field, Func <Row, Row, Row> processrow) { return(observed.Join( rightOp, new RowJoinHelper(field).FullJoinMatch, processrow)); }
/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="activator">command parameters</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, CommandActivator activator) { var cmd = new CommandOperation(activator); observed.Subscribe(cmd); return(cmd); }
public static GroupByOperation GroupBy(this IObservableOperation observed, string[] columns, Action <Row, Row> aggregate = null) { var op = new GroupByOperation(columns, aggregate); observed.Subscribe(op); return(op); }
/// <summary> /// Apply an action on the rows /// </summary> /// <param name="observed">observed operation</param> /// <param name="columns">callback method for the action</param> /// <returns>resulting operation</returns> public static GroupByOperation GroupBy(this IObservableOperation observed, params string[] columns) { var op = new GroupByOperation(columns); observed.Subscribe(op); return(op); }
/// <summary> /// Execute the pipeline /// </summary> /// <param name="observed">observed operation</param> /// <returns>List of row resulting from the pipeline</returns> public static EtlFullResult ExecuteInThread(this IObservableOperation observed) { RecordOperation record = new RecordOperation(); observed.Subscribe(record); record.Result.Thread = new Thread(new ThreadStart(record.Trigger)); record.Result.Thread.Start(); return record.Result; }
/// <summary> /// Join an enumeration of elements to the pipeline /// </summary> /// <typeparam name="T">type of elements to join</typeparam> /// <param name="observed">observed operation</param> /// <param name="list">enumeration of elements to join</param> /// <param name="checkMatch">callback method to check if an element is matching the row</param> /// <param name="processrow">callback method called to process the row</param> /// <returns>resulting operation</returns> public static JoinOperation <T> Join <T>(this IObservableOperation observed, IEnumerable <T> list, Func <Row, T, bool> checkMatch, Func <Row, T, Row> processrow) { var activator = new JoinActivator <T>(); activator.List = list; activator.CheckMatch = checkMatch; activator.ProcessRow = processrow; return(observed.Join(activator)); }
/// <summary> /// Join an enumeration of elements to the pipeline /// </summary> /// <param name="observed">observed operation</param> /// <param name="rightOp">operation to join</param> /// <param name="checkMatch">callback method to check if an element is matching the row</param> /// <param name="processrow">callback method called to process the row</param> /// <returns>resulting operation</returns> public static JoinOperation <Row> Join(this IObservableOperation observed, IObservableOperation rightOp, Func <Row, Row, bool> checkMatch, Func <Row, Row, Row> processrow) { var activator = new OperationJoinActivator(); activator.Operation = rightOp; activator.CheckMatch = checkMatch; activator.ProcessRow = processrow; return(observed.Join(activator)); }
/// <summary> /// Start the operation in a thread. Start method calls are bubbled up through the pipeline /// </summary> public static EtlResult StartInThread(this IObservableOperation observed) { var op = new StartOperation(); observed.Subscribe(op); op.Result.Thread = new Thread(new ThreadStart(op.Trigger)); op.Result.Thread.Start(); return op.Result; }
/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="act">callback on command activator</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, Action <CommandActivator> act) { var activator = new CommandActivator(); act(activator); CommandOperation cmd = new CommandOperation(activator); observed.Subscribe(cmd); return(cmd); }
/// <summary> /// Write the result to a stream /// </summary> /// <typeparam name="T">The poco type used to define file format</typeparam> /// <param name="observed">observed operation</param> /// <param name="strm">stream to the file</param> /// <param name="prepare">Callback to prepare the file engine</param> /// <returns>file write operation</returns> public static FileWriteOperation <T> WriteFile <T>(this IObservableOperation observed, Stream strm, Action <FluentFile> prepare) { var activator = new FileWriteActivator <T>() { Stream = strm, PrepareFluentFile = prepare }; var resoperation = new FileWriteOperation <T>(activator); observed.Subscribe(resoperation); return(resoperation); }
/// <summary> /// Apply a command operation /// </summary> /// <param name="observed">observed operation</param> /// <param name="connStr">Name of a connection string defined in the application configuration file</param> /// <param name="CommandText">text of the command</param> /// <param name="isQuery">indicate if the command is a query</param> /// <param name="prepare">callback method to prepare the command</param> /// <returns>command operation</returns> public static CommandOperation DbCommand(this IObservableOperation observed, string connStr, string CommandText, bool isQuery, Action <IDbCommand, Row> prepare) { var activator = new CommandActivator(); activator.ConnStringName = connStr; activator.CommandText = CommandText; activator.Prepare = prepare; activator.IsQuery = isQuery; return(observed.DbCommand(activator)); }
/// <summary> /// Write the result to a stream /// </summary> /// <param name="T">The poco type used to define file format</param> /// <param name="observed">observed operation</param> /// <param name="writer">stream to the file</param> /// <param name="prepare">Callback to prepare the file engine</param> /// <returns>file write operation</returns> public static FileWriteOperation WriteFile(this IObservableOperation observed, TextWriter writer, Action <FluentFile> prepare, Type T) { FileWriteActivator activator = new FileWriteActivator() { Writer = writer, PrepareFluentFile = prepare, Type = T }; FileWriteOperation resoperation = new FileWriteOperation(activator, T); observed.Subscribe(resoperation); return(resoperation); }
/// <summary> /// Write the result to a file /// </summary> /// <typeparam name="T">The poco type used to define file format</typeparam> /// <param name="observed">observed operation</param> /// <param name="filename">full path to the file</param> /// <param name="prepare">Callback to prepare the file engine</param> /// <returns>file write operation</returns> public static FileWriteOperation <T> WriteFile <T>(this IObservableOperation observed, string filename, Action <FluentFile> prepare) { FileWriteActivator <T> activator = new FileWriteActivator <T>() { FileName = filename, PrepareFluentFile = prepare }; FileWriteOperation <T> resoperation = new FileWriteOperation <T>(activator); observed.Subscribe(resoperation); return(resoperation); }
/// <summary> /// Write the result to a stream /// </summary> /// <typeparam name="T">The poco type used to define file format</typeparam> /// <param name="observed">observed operation</param> /// <param name="writer">stream to the file</param> /// <param name="prepare">Callback to prepare the file engine</param> /// <returns>file write operation</returns> public static FileWriteOperation <T> WriteFile <T>(this IObservableOperation observed, TextWriter writer, Action <FluentFile> prepare) { FileWriteActivator <T> activator = new FileWriteActivator <T>() { Writer = writer, PrepareFluentFile = prepare }; FileWriteOperation <T> resoperation = new FileWriteOperation <T>(activator); observed.Subscribe(resoperation); return(resoperation); }
/// <summary> /// Write the result to a file /// </summary> /// <param name="T">The poco type used to define file format</param> /// <param name="observed">observed operation</param> /// <param name="filename">full path to the file</param> /// <param name="prepare">Callback to prepare the file engine</param> /// <returns>file write operation</returns> public static FileWriteOperation WriteFile(this IObservableOperation observed, string filename, Action <FluentFile> prepare, Type T) { FileWriteActivator activator = new FileWriteActivator() { FileName = filename, PrepareFluentFile = prepare, Type = T }; FileWriteOperation resoperation = new FileWriteOperation(activator, T); observed.Subscribe(resoperation); return(resoperation); }
/// <summary> /// upsert into mongodb。處理寫入mongodb。 /// </summary> /// <typeparam name="T">mongodb collection 對應到C# class</typeparam> /// <param name="observed">observed operation</param> /// <param name="database">mongodb IMongoDatabase</param> /// <param name="collectionName">collection name</param> /// <param name="filter">呼叫方要upsert的過濾條件</param> /// <param name="update">每次provider push出來是Row類型,透過委派由呼叫方完成寫入update definition</param> /// <param name="options">mongodb update option</param> /// <returns></returns> public static MongoDbUpdateOperation <T> MongoDbUpsert <T>(this IObservableOperation observed, MongoDB.Driver.IMongoDatabase database, string collectionName, Func <Row, MongoDB.Driver.FilterDefinition <T> > filter, Func <Row, MongoDB.Driver.UpdateDefinition <T> > update, MongoDB.Driver.UpdateOptions options = null) { var mongoDbOperation = new MongoDbUpdateOperation <T>(new CommandActivator(), database, collectionName, filter, update, options); observed.Subscribe(mongoDbOperation); return(mongoDbOperation); }
public static MongoDbUpdateOperation <T> MongoDbUpsert <T>(this IObservableOperation observed, IMongoDatabase database, string collectionName, Func <Row, FilterDefinition <T> > filter, Func <Row, UpdateDefinition <T> > update, UpdateOptions options = null) { var mongoDbOperation = new MongoDbUpdateOperation <T>(new CommandActivator(), database, collectionName, filter, update, LogProvider.GetLogger(typeof(MongoDbUpdateOperation <>).ToString()), options); observed.Subscribe(mongoDbOperation); return(mongoDbOperation); }