Match Defini
Total Page:16
File Type:pdf, Size:1020Kb
68 Bridge, St. Suite 307 +1 888-779-6578 [email protected] www.DataLadder.com SuȂ$eld, CT 06708 ReadTable( Prepares to read data from the data source. ReaderConfigura�on Opens connec�ons, creates required structures, etc. configuration, Boolean toDetermineFields) configuration - Se�ngs that contain informa�on about the data source toDetermineFields - If true, informa�on about columns will be refreshed from the data source while it is read. If false, column informa�on from ReaderConfigura�on se�ngs will be used returns - true if successful Disconnect() Releases resources (closes connec�ons to DB, flushes files, closes file streams, etc.) ReaderToVariableTableConvertor class Namespace: dataladder.Data Assemblies: DataMatch.Api.dll This class is used to copy data from ISimpleReader to a table stored in either a hard disk drive or in memory. C# public class ReaderToVariableTableConvertor Remarks This class contains a single sta�c method, Copy(…), that loads data from any data source in internal storage. Methods: Copy(IReader reader, Loads data from a data source which is wrapped by String path, IReader into file storage (OnDriveTable). String name, IReader can represent different source types: Excel, SQL out String error, DB, CSV, etc. Cancella�onToken cancel, ProgressDelegate progress = null, reader - ISimpleReader that can wrap various data Int32 toRow = Int32.MaxValue, source types String fileNameBase = null, path - specifies file path where the file storage will be Opera�onModes operationMode created or opened from = Opera�onModes.Disk, name - First half of file storage name (second half will MinSpaceReachedDelegate be the GUID) onMinSpaceReached = null) error - Error display message that should be returned cancel - Cancella�on token to cancel job progress - Callback func�on to show import progress toRow - Number of rows to load from data source to file fileNameBase - Name of file storage. If this parameter is null, then new name of file will be created from 'name' parameter and new random GUID operationMode - Should the data be loaded onto hard disk or in a virtual memory file? onMinSpaceReached - Callback func�on to check minimum space on hard drive Returns - loaded data as OnDriveTable ReaderConfigura�on class Namespace: dataladder.Data Assemblies: DataMatch.Data.Core.dll Se�ngs to import and export data C# public class ReaderConfigura�on : ICloneable Examples: //Prepares for reading a data source from Excel file ReaderConfigura�on rc = new ReaderConfigura�on(); rc.DataSourceTypeDescrip�on = SourceDb.Excel.ToString(); rc.DataSourceId = 0; rc.FileName = @"D:\ContactListMaster.xls"; // name that will be used in the applica�on is assigned to TableName rc.TableName = @"Contact List"; // name of the Excel sheet is assigned to OriginalTableName property rc.OriginalTableName = @"Sheet1"; Remarks This class contains se�ngs that allow you to import or export a data source. The relevance of different proper�es in this class varies based on the file source you are dealing with. For example, for file-based sources (CSV, Excel, etc.), the filename property must be filled, but for database sources, Configura�onString is required. The ‘SourceDb’ enum sec�on further down in this handbook lists down possible data source types. Constructors: public ReaderConfigura�on() Create instance of class Proper�es: DataSourceTypeDescrip�on String get; Data source type as string set; DataSourceType SourceDb get; Data source type as 'SourceDb' enum DataSourceTypeDescrip�onFriendly String get; Data source descrip�on Configura�onString String get; Connec�on string set; SchemaName String get; Schema name for SQL based data set; sources TableName String get; Table name. Original name can set; be changed while impor�ng OriginalTableName String get; Name of the source in the set; original file path. Important for when the refresh is performed. SelectCmd String get; For SQL-based data sources, it is set; possible to import data with custom SELECT query. For example, when impor�ng specific records or tables using complex queries. FileName String get; This property is important for set; file-based data sources (Excel, CSV etc.). Full path to the file. ColumnsSe�ngs DataTable get; Column se�ngs (count of set; columns, their names, and their types) as DataTable DataSourceId Int32 get; Iden�fier of data source - must set; be unique. For master table, it must be '0' SourceDb enum Namespace: dataladder.Data Assemblies: DataMatch.Data.Core.dll Type of imported or exported data source. C# public enum SourceDb Enum values: Excel Old Excel (.xls) files Excel2007 Open office xml (.xlsx) Excel files CSV Text files with delimiters (csv, tsv, etc.) DBase Dbase files (.dbf) FixedWidthTextFile Text files with fixed width of columns XML XML files (.xml) SqlServer MS SQL Server database Mysql MySQL database Odbc Connec�ons through ODBC mechanism DB2 DB2 database Oracle Oracle database Salesforce Salesforce CRM CdJson Json files (.JSON) CdHBase HBase database CdMongoDb MongoDb database DynamicsCRM MS Dynamics CRM Twi�er Twi�er Facebook Facebook CdAccess Access database CdSugarCRM SugarCRM PostgreSql PostgreSQL database OleUniversal Connec�ons through OLE mechanism Email IMAP and POP connec�ons for email Teradata Teradata database Field class Namespace: dataladder.Data Assemblies: DataMatch.Data.Core.dll Represents a column of a data source C# public class Field Remarks This class has mul�ple proper�es for name: Name, NewName, OriginalName, because the class embeds logic to correct filename automa�cally. When a value is being assigned to the Name property, it is checked for prohibited symbols or whether that name is already reserved. If special characters exist, then the value will be complemented with underscore symbols. This new value will be placed into NewName property and will be returned whenever Name or NewName is requested. Original value will be placed into OriginalName property. If property UseOriginalName is set as “true”, then Name property will return original value of the name. Constructors: Field() Create instance of class Proper�es: Name String get; set; Name of column NewName String get; set; Alias name of column OriginalName String get Name of this column in the original data source UseOriginalName Boolean get; set; If true, Name will return Original Name Type Type get; set; Type of column Included Boolean get; set; Has this column been chosen for import? If false, this column will not be loaded from data source Fields class Namespace: dataladder.Data Assemblies: DataMatch.Data.Core.dll List of columns(fields) that are belonged some data source C# public class Fields : IContainer2CoordsMapper Examples: Remarks … descrip�on of the class Constructors: Fields() Create instance of class Proper�es: this[Int32] Field get; set; Gets column by index this[String] Field get; set; Gets column by column name Methods: Add(Field field) Adds new field at the end of list field - added field Clear() Removes all columns Remove(Field field) Removes a specific field field - removed field SaveColumnsSe�ngs() Converts this class to 'DataTable' instance (to save in xml format) Returns - Fields class saved as DataTable LoadColumnsSe�ngs( Loads this instance from DataTable that contains previously saved DataTable settings) 'Fields' instance Settings - Fields class saved as DataTable IContainer2CoordsMapper class Namespace: dataladder.XtraGridHelper Assemblies: DataMatch.Core.dll Simple interface for represen�ng a tabular data structure. The interface has methods: ● to get/set data in every cell - GetData(...), SetData(...) ● to get count of columns and rows ● to get every column name C# public interface IContainer2CoordsMapper Proper�es: RecordCount Int32 get; Count of rows ColumnCount Int32 get; Count of columns Methods: GetData(Int32 rowIndex, Int32 Gets value from a specific cell colIndex); rowIndex - row index of cell colIndex - column index of cell returns - value from cell SetData(Object obj, Int32 rowIndex, Sets value in a specific cell Int32 colIndex) obj - new value of cell rowIndex - row index of cell colIndex - column index of cell GetColumnName(Int32 colIndex) Gets name of a specific column colIndex - index of column returns - column name OnDriveTable class Namespace: dataladder.Data Assemblies: DataMatch.DataStorage.dll Permanent tabular storage on hard disk C# public class OnDriveTable : ITable2CoordsMapper, IGetMul�pleReadOnlyViews, IDisposable Examples: /// <summary> /// Create simple filled storage /// </summary> /// <param name="path">folder where new storage will be created</param> /// <param name="name">name of storage</param> /// <returns></returns> public static OnDriveTable CreateDemoTable(String path, String name) { OnDriveTable onDriveTable = new OnDriveTable(path, name); onDriveTable.AddField("FirstName", typeof(String)); onDriveTable.AddField("LastName", typeof(String)); onDriveTable.SetData("John", 0, 0); onDriveTable.SetData("Smith", 0, 1); onDriveTable.SetData("Joan", 1, 0); onDriveTable.SetData("Smit", 1, 1); return onDriveTable; } /// <summary> /// Prints contents of OnDriveTable in console. /// </summary> /// <param name="mapper">data source that will be printed</param> public static void PrintInConsole(OnDriveTable mapper) { // Prints header for (Int32 i = 0; i < mapper.ColumnCount; i++) { String columnName = mapper.GetColumnName(i); Console.Write($"| {i}:{columnName} "); } Console.WriteLine("|"); Console.WriteLine("-------------------------------------------------------"); //Prints body for (Int32 j = 0; j < mapper.RecordCount ; j++) { for (Int32 i = 0; i < mapper.ColumnCount; i++) { Object cellValue