/// <summary> /// Shows the OleDb connection dialog. /// </summary> /// <returns>A DialogResult value, determining, if the dialog was cancelled or the OK button was pressed.</returns> public DialogResult Show() { Type t = Type.GetTypeFromCLSID(new Guid("{00000514-0000-0010-8000-00AA006D2EA4}")); object oc = Activator.CreateInstance(t); if (oc == null) { throw new Exception("Can't construct a Connection object"); } Connection15 cn = (Connection15)oc; if (cn == null) { throw new Exception("Can't get the connection interface"); } t = Type.GetTypeFromCLSID(new Guid("{2206CDB2-19C1-11D1-89E0-00C04FD7A829}")); object odl = Activator.CreateInstance(t); if (odl == null) { throw new Exception("Can't construct a DataLinksClass object"); } IDataSourceLocator dl = (IDataSourceLocator)odl; if (dl == null) { throw new Exception("Can't get the IDataSourceLocator interface"); } cn.ConnectionString = this.connectionString; int trials = 0; while (true) { try { dl.PromptEdit(ref oc); break; } catch (COMException ex) { if (trials > 0) { throw ex; } trials++; cn.ConnectionString = null; } } this.connectionString = cn.ConnectionString; if (cn.ConnectionString == null) { return(DialogResult.Cancel); } else { return(DialogResult.OK); } }
public DialogResult Show() { Type t = Type.GetTypeFromCLSID(new Guid("{00000514-0000-0010-8000-00AA006D2EA4}")); object oc = Activator.CreateInstance(t); if (oc == null) { throw new Exception("Can't construct a Connection object"); } Connection15 cn = (Connection15)oc; if (cn == null) { throw new Exception("Can't get the connection interface"); } t = Type.GetTypeFromCLSID(new Guid("{2206CDB2-19C1-11D1-89E0-00C04FD7A829}")); object odl = Activator.CreateInstance(t); if (odl == null) { throw new Exception("Can't construct a DataLinksClass object"); } IDataSourceLocator dl = (IDataSourceLocator)odl; if (dl == null) { throw new Exception("Can't get the IDataSourceLocator interface"); } cn.ConnectionString = this.connectionString; try { dl.PromptEdit(ref oc); } catch (COMException ex) { if (ex.ErrorCode == -2147217887) { throw new Exception("Wrong connection string format - delete your connection string and press the edit button again."); } else { throw ex; } } this.connectionString = cn.ConnectionString; if (cn.ConnectionString == null) { return(DialogResult.Cancel); } else { return(DialogResult.OK); } }
public static IEnumerable<DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(IDataSourceLocator locator, MyReportBase report, out DynamicTree<DesignTimeDataSourceTreeItem> tree, out List<DesignTimeDataSourceTreeItem> flatList) { var treeItems = BuildDesignTimeDataSourceTreeItems(locator, report); Func<string, string, DesignTimeDataSourceTreeItem> structureBuilder = (string1, string2) => { return new DesignTimeDataSourceTreeItem() { Name = string1, Path = string2, IsStructure = true }; }; var treeView = new TreeviewStructureBuilder<DesignTimeDataSourceTreeItem>(); treeView.Delimiter = @"\"; treeView.CreateTree(treeItems, structureBuilder, out tree, out flatList, DuplicateTreeItemBehavior.ShowOnlyOneItem); return treeItems; }
protected string PrepareSql(IDataSourceLocator source, IList <string> columnNames) { var builder = new StringBuilder(); builder.AppendLine("SELECT"); if (columnNames == null || columnNames.Count == 0) { builder.AppendLine("*"); } else { for (int i = 0; i < columnNames.Count; i++) { builder.Append(columnNames[i]); if (i < (columnNames.Count - 1)) { builder.AppendLine(","); } else { builder.AppendLine(); } } } builder.AppendLine("FROM"); switch (source.DataSourceType) { case DataSourceType.SqlTableOrView: builder.AppendLine(source.FullName); break; case DataSourceType.SqlStatement: builder.AppendLine("("); builder.AppendLine(source.SqlStatement); builder.AppendLine(") T1"); break; } return(builder.ToString()); }
public DummyDesignerContext(IDataSourceLocator locator) { DataSourceLocator = locator; DesignForm = new XRDesignForm(); }
private static IEnumerable <DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(IDataSourceLocator locator, MyReportBase report) { // Report Requested Datasource Definitions var requestedDatasources = report.DesignTimeDataSources; Func <IReportDatasourceMetadata, DesignTimeDataSourceDefinition, bool> match = (metadata, requested) => { if (metadata == null || requested == null) { return(false); } else { return(metadata.UniqueId == requested.DataSourceName); } }; Func <IReportDatasourceMetadata, DesignTimeDataSourceDefinition, DesignTimeDataSourceTreeItem> CreateDataSourceTreeItem = (metadataNullable, definitionNullable) => { var definition = definitionNullable ?? new DesignTimeDataSourceDefinition(metadataNullable.UniqueId, metadataNullable.Name, String.Empty); return(new DesignTimeDataSourceTreeItem() { Path = string.Empty, Name = definition.DataSourceName, DesignTimeDataSourceDefinition = definition, Metadata = metadataNullable, PreviouslyUsedWithThisReport = (definitionNullable != null).ToString(), RelationPath = definition.DataSourceRelationPath }); }; var dataSourceTreeItems = (from datasourceProvider in locator.GetReportDatasourceProviders() let availableDatasources = datasourceProvider.GetReportDatasources() // Join availableDatasources & requestedDatasources on datasource name from tuple in availableDatasources.FullOuterJoin(requestedDatasources, match) let export = tuple.T1Object let definition = tuple.T2Object select CreateDataSourceTreeItem(export, definition)).ToList(); return(dataSourceTreeItems); }
public static IEnumerable <DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(IDataSourceLocator locator, MyReportBase report, out DynamicTree <DesignTimeDataSourceTreeItem> tree, out List <DesignTimeDataSourceTreeItem> flatList) { var treeItems = BuildDesignTimeDataSourceTreeItems(locator, report); Func <string, string, DesignTimeDataSourceTreeItem> structureBuilder = (string1, string2) => { return(new DesignTimeDataSourceTreeItem() { Name = string1, Path = string2, IsStructure = true }); }; var treeView = new TreeviewStructureBuilder <DesignTimeDataSourceTreeItem>(); treeView.Delimiter = @"\"; treeView.CreateTree(treeItems, structureBuilder, out tree, out flatList, DuplicateTreeItemBehavior.ShowOnlyOneItem); return(treeItems); }
public override DataFrame Read(IDataSourceLocator source, DataFrameSamplingParameters samplingParameters) { var textSource = source as TextDataSourceLocator; if (textSource == null) { throw new ArgumentException("Data source should be a text file"); } var fileName = textSource.FullName; var headerFlag = textSource.ContainsHeaderWithColumnNames; var delim = textSource.Delimiter; var firstK = textSource.NumLinesForTypeInference; var columnReport = TextIOUtils.CreateColumnReport(fileName, headerFlag, delim, firstK); var columnCollection = columnReport.ColumnCollection; var numLines = TextIOUtils.GetNumberOfLines(fileName); var capacity = samplingParameters.MaxSampleSize; var ratio = (numLines <= capacity) ? 1.0 : ((double)capacity) / numLines; var frame = new DataFrame(); frame.Initialize(columnCollection, capacity); var indices = columnCollection.GetValidIndices(); var length = indices.Length; var rand = new Random(); using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { using (var reader = new StreamReader(stream)) { //var colCount = -1; var line = String.Empty; if (headerFlag) { line = reader.ReadLine(); } var cnt = 0; while ((line = reader.ReadLine()) != null) { ++cnt; if (rand.NextDouble() > ratio) { continue; } var parsed = line.Split(delim); //if (parsed == null || parsed.Length != colCount) //{ // throw new InvalidOperationException(String.Format("There is a non-conformant record in line {0} of file {1} ", cnt, fileName)); //} for (int i = 0; i < length; i++) { var idx = indices[i]; frame.Add(idx, parsed[idx]); } } } } //frame.Cleanup(new List<string>()); return(frame); }
public override DataFrame Read(IDataSourceLocator source, IList <string> excludedColumnList, DataFrameSamplingParameters samplingParameters) { throw new NotImplementedException(); }
public override DataFrame Read(IDataSourceLocator source, DataFrameSamplingParameters samplingParameters) { throw new NotImplementedException(); }
public abstract DataFrame Read(IDataSourceLocator source, IList <string> excludedColumnList, DataFrameSamplingParameters samplingParameters);
public abstract DataFrame Read(IDataSourceLocator source, DataFrameSamplingParameters samplingParameters);
private static IEnumerable<DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(IDataSourceLocator locator, MyReportBase report) { // Report Requested Datasource Definitions var requestedDatasources = report.DesignTimeDataSources; Func<IReportDatasourceMetadata, DesignTimeDataSourceDefinition, bool> match = (metadata, requested) => { if (metadata == null || requested == null) return false; else return metadata.UniqueId == requested.DataSourceName; }; Func<IReportDatasourceMetadata, DesignTimeDataSourceDefinition, DesignTimeDataSourceTreeItem> CreateDataSourceTreeItem = (metadataNullable, definitionNullable) => { var definition = definitionNullable ?? new DesignTimeDataSourceDefinition(metadataNullable.UniqueId, metadataNullable.Name, String.Empty); return new DesignTimeDataSourceTreeItem() { Path = string.Empty, Name = definition.DataSourceName, DesignTimeDataSourceDefinition = definition, Metadata = metadataNullable, PreviouslyUsedWithThisReport = (definitionNullable != null).ToString(), RelationPath = definition.DataSourceRelationPath }; }; var dataSourceTreeItems = (from datasourceProvider in locator.GetReportDatasourceProviders() let availableDatasources = datasourceProvider.GetReportDatasources() // Join availableDatasources & requestedDatasources on datasource name from tuple in availableDatasources.FullOuterJoin(requestedDatasources, match) let export = tuple.T1Object let definition = tuple.T2Object select CreateDataSourceTreeItem(export, definition)).ToList(); return dataSourceTreeItems; }