using System;
using System.Data;
using System.IO;
using System.Net;
using FastReport.Data.ConnectionEditors;
using FastReport.Utils;
namespace FastReport.Data
{
partial class CsvDataConnection
{
#region Public Methods
///
public override void TestConnection()
{
using (DataSet dataset = CreateDataSet())
{
}
}
///
public override ConnectionEditorBase GetEditor()
{
return new CsvConnectionEditor();
}
///
public override string GetConnectionId()
{
return "Csv: " + CsvFile;
}
#endregion Public Methods
#region Private Methods
///
private string CheckForChangeConnection(CsvConnectionStringBuilder builder)
{
RelatedPathCheck(builder);
if (File.Exists(builder.CsvFile))
{
ConnectionString = builder.ToString();
return ConnectionString;
}
else
{
// added a check for the existence of a file when it is changed in the connection string in the properties (the CsvFile property)
// from the local path to the uri.
// the data in the table changes, but the name and list of fields on the "Data" tab do not change
// the same thing happens when changing from a local path to another local path
Uri uri = new Uri(builder.CsvFile);
WebRequest request = WebRequest.Create(uri);
try
{
using (WebResponse response = request.GetResponse())
{
ConnectionString = builder.ToString();
return ConnectionString;
}
}
catch
{
builder.CsvFile = ConnectionString;
FRMessageBox.Error(Res.Get("ConnectionEditors,Common,ErrorUrlException"));
return ConnectionString;
}
}
}
#endregion Private Methods
}
}