12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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
- /// <inheritdoc/>
- public override void TestConnection()
- {
- using (DataSet dataset = CreateDataSet())
- {
- }
- }
- /// <inheritdoc/>
- public override ConnectionEditorBase GetEditor()
- {
- return new CsvConnectionEditor();
- }
- /// <inheritdoc/>
- public override string GetConnectionId()
- {
- return "Csv: " + CsvFile;
- }
- #endregion Public Methods
- #region Private Methods
- /// <inheritdoc/>
- 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
- }
- }
|