コード例 #1
0
        private void mnuConnect_Click(object sender, EventArgs e)
        {
            try
            {
                using (frmChooseDatasource frmChooseDatasource = new frmChooseDatasource())
                {
                    if (frmChooseDatasource.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        IDataSourceProviderEditor provEditor = DataSourceProviderManager.CreateProviderEditor(frmChooseDatasource.SelectedProvider);
                        Form frmEditor = (Form)provEditor;
                        if (frmEditor.ShowDialog() == DialogResult.OK)
                        {
                            this.Cursor = Cursors.WaitCursor;

                            m_dsProvider = (DataSourceProvider)provEditor.CreateProvider(new NullProgressIndicator());

                            UpdateControls();
                            UpdateDataGridView(m_dsProvider.Information);

                            UpdateMessage("Data source of type '" + frmChooseDatasource.SelectedProvider + "' was successfully connected.");

                            this.Cursor = Cursors.Default;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                UpdateMessage("Exception: " + ex.Message);
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
 internal Repository(IDataSourceProvider dataSourceProvider)
 {
     if (dataSourceProvider == null)
     {
         throw new ArgumentNullException("dataSourceProvider");
     }
     _dataSourceProvider = dataSourceProvider;
 }
コード例 #3
0
        public void AddDataSourceProvider(string invariantName, IDataSourceProvider provider)
        {
            if (_providers.ContainsKey(invariantName))
            {
                return;
            }

            _providers.Add(invariantName, provider);
        }
コード例 #4
0
        /// <summary>
        /// Creates a new instance of the <see cref="AdoNetConnection"/> class.
        /// </summary>
        /// <param name="dataSourceProvider">The data source provider.</param>
        /// <param name="connectionStringName">Name of the connection string.</param>
        /// <exception cref="System.ArgumentException">Connection string name '{0}' could not be found in configuration.WithValues(connectionString)</exception>
        public AdoNetConnection(IDataSourceProvider dataSourceProvider, string connectionStringName)
        {
            var connectionEntry = ConfigurationManager.ConnectionStrings[connectionStringName];

            if (connectionEntry == null)
            {
                throw new ArgumentException("Connection string name '{0}' could not be found in configuration".WithValues(connectionStringName));
            }

            this.dataSourceProvider = dataSourceProvider;
            this.connectionString   = connectionEntry.ConnectionString;
        }
コード例 #5
0
        public IList <string> GetDatabases(SqlConnectionString connectionString)
        {
            var dbProvider = connectionString.DbProvider?.InvariantName;

            if (string.IsNullOrWhiteSpace(dbProvider))
            {
                return(new List <string>());
            }

            IDataSourceProvider provider = null;

            _providers.TryGetValue(dbProvider, out provider);
            if (provider == null)
            {
                return(new List <string>());
            }

            var factory = DbProviderFactories.GetFactory(dbProvider);

            var databases = new List <string>();

            using (var sqlConnection = factory.CreateConnection())
            {
                if (sqlConnection == null)
                {
                    return(new List <string>());
                }

                sqlConnection.ConnectionString = connectionString.ToString();
                sqlConnection.Open();

                using (var command = factory.CreateCommand())
                {
                    if (command == null)
                    {
                        return(new List <string>());
                    }

                    command.Connection  = sqlConnection;
                    command.CommandText = provider.DataBasesQuery;
                    command.CommandType = CommandType.Text;
                    using (IDataReader dataReader = command.ExecuteReader())
                    {
                        while (dataReader.Read())
                        {
                            databases.Add(dataReader[0].ToString());
                        }
                    }
                }
            }

            return(databases);
        }
コード例 #6
0
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     string[] array = null;
     if (context != null)
     {
         IComponent instance = context.Instance as IComponent;
         if (instance != null)
         {
             ISite site = instance.Site;
             if (site != null)
             {
                 IDesignerHost service = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                 if (service != null)
                 {
                     IDesigner dataBoundControlDesigner = service.GetDesigner(instance);
                     DesignerDataSourceView view        = this.GetView(dataBoundControlDesigner);
                     if (view != null)
                     {
                         IDataSourceDesigner dataSourceDesigner = view.DataSourceDesigner;
                         if (dataSourceDesigner != null)
                         {
                             string[] viewNames = dataSourceDesigner.GetViewNames();
                             if (viewNames != null)
                             {
                                 array = new string[viewNames.Length];
                                 viewNames.CopyTo(array, 0);
                             }
                         }
                     }
                     if (((array == null) && (dataBoundControlDesigner != null)) && (dataBoundControlDesigner is IDataSourceProvider))
                     {
                         IDataSourceProvider provider = dataBoundControlDesigner as IDataSourceProvider;
                         object dataSource            = null;
                         if (provider != null)
                         {
                             dataSource = provider.GetSelectedDataSource();
                         }
                         if (dataSource != null)
                         {
                             array = DesignTimeData.GetDataMembers(dataSource);
                         }
                     }
                 }
             }
         }
         if (array == null)
         {
             array = new string[0];
         }
         Array.Sort(array, Comparer.Default);
     }
     return(new TypeConverter.StandardValuesCollection(array));
 }
コード例 #7
0
 public QueryBuilder(
     IDataQueryExecutor executor,
     IDslParser parser,
     IDataQueryExpressionTranslator translator,
     IQueryEntityNameTranslator nameTranslator,
     IDataSourceProvider dataSourceProvider)
 {
     _executor           = executor;
     _parser             = parser;
     _translator         = translator;
     _nameTranslator     = nameTranslator;
     _dataSourceProvider = dataSourceProvider;
 }
コード例 #8
0
        public IList <string> GetDataSources(SqlConnectionString connectionString)
        {
            var dbProvider = connectionString.DbProvider?.InvariantName;

            if (string.IsNullOrWhiteSpace(dbProvider))
            {
                return(new List <string>());
            }

            IDataSourceProvider provider = null;

            _providers.TryGetValue(dbProvider, out provider);
            return(provider != null?provider.GetDataSources() : new List <string>());
        }
コード例 #9
0
        private void mnuDiconnect_Click(object sender, EventArgs e)
        {
            if (m_dsProvider != null)
            {
                m_dsProvider.Close();
                m_dsProvider.Dispose();
                m_dsProvider = null;

                UpdateControls();
                UpdateDataGridView(null);

                UpdateMessage("Data source has been disconnected");
            }
        }
 private void ExtractFields(IDataSourceProvider dataSourceProvider, ArrayList fields)
 {
     IEnumerable resolvedSelectedDataSource = dataSourceProvider.GetResolvedSelectedDataSource();
     if (resolvedSelectedDataSource != null)
     {
         PropertyDescriptorCollection dataFields = DesignTimeData.GetDataFields(resolvedSelectedDataSource);
         if ((dataFields != null) && (dataFields.Count != 0))
         {
             foreach (PropertyDescriptor descriptor in dataFields)
             {
                 fields.Add(new FieldItem(descriptor.Name, descriptor.PropertyType));
             }
         }
     }
 }
コード例 #11
0
        protected Repository(string connectionName)
        {
            if (string.IsNullOrWhiteSpace(connectionName))
            {
                throw new ArgumentNullException("connectionName");
            }
            _connectionName = connectionName;
            var dataSourceProvider = GetDataSourceProvider();

            if (dataSourceProvider == null)
            {
                throw new ArgumentNullException("dataSourceProvider");
            }
            _dataSourceProvider = dataSourceProvider;
        }
コード例 #12
0
 /// <summary>
 /// If sourceInstance is null attempt to create a SourceInstance from SourceLocation
 /// </summary>
 /// <exception cref="ResourceStaticAnalysisException">Thrown when data source instance could not be initialized properly. This could happen - for example - if a file comprising the datasource does not exist.</exception>
 public void Initialize(IDataSourceProvider provider)
 {
     if (this._sourceInstance == null)
     {
         lock (this)
         {
             try
             {
                 this._sourceInstance = provider.CreateDataSourceInstance(SourceLocation);
             }
             catch (FileNotFoundException e)
             {
                 throw new ResourceStaticAnalysisException(string.Format(CultureInfo.InvariantCulture, "File '{1}' that is part of a datasource of type {0} cannot be found.",
                                                                         provider.DataSourceType, e.FileName), e);
             }
             catch (Exception e)
             {
                 throw new ResourceStaticAnalysisException(String.Format(CultureInfo.InvariantCulture, "Creating datasource instance of type {0} from source location {1} failed.",
                                                                         provider.DataSourceType, SourceLocation), e);
             }
         }
     }
 }
コード例 #13
0
            public StringCollection GetStandardValues(Component component)
            {
                StringCollection fields = new StringCollection();

                if (component != null)
                {
                    ISite site1 = component.Site;
                    if (site1 != null)
                    {
                        IDesignerHost host1 = (IDesignerHost)site1.GetService(typeof(IDesignerHost));
                        if (host1 != null)
                        {
                            IDesigner designer1          = host1.GetDesigner(component);
                            DesignerDataSourceView view1 = ((DataBoundControlDesigner)designer1).DesignerView;
                            if (view1 != null)
                            {
                                IDataSourceViewSchema schema1 = null;
                                try
                                {
                                    schema1 = view1.Schema;
                                }
                                catch (Exception exception1)
                                {
                                    IComponentDesignerDebugService service1 = (IComponentDesignerDebugService)site1.GetService(typeof(IComponentDesignerDebugService));
                                    if (service1 != null)
                                    {
                                        service1.Fail("DataSource DebugService FailedCall\r\n" + exception1.ToString());
                                    }
                                }
                                if (schema1 != null)
                                {
                                    IDataSourceFieldSchema[] schemaArray1 = schema1.GetFields();
                                    if (schemaArray1 != null)
                                    {
                                        for (int num1 = 0; num1 < schemaArray1.Length; num1++)
                                        {
                                            fields.Add(schemaArray1[num1].Name);
                                        }
                                    }
                                }
                            }
                            if (((fields.Count == 0) && (designer1 != null)) && (designer1 is IDataSourceProvider))
                            {
                                IDataSourceProvider provider1   = designer1 as IDataSourceProvider;
                                IEnumerable         enumerable1 = null;
                                if (provider1 != null)
                                {
                                    enumerable1 = provider1.GetResolvedSelectedDataSource();
                                }
                                if (enumerable1 != null)
                                {
                                    PropertyDescriptorCollection collection1 = DesignTimeData.GetDataFields(enumerable1);
                                    if (collection1 != null)
                                    {
                                        foreach (PropertyDescriptor descriptor1 in collection1)
                                        {
                                            fields.Add(descriptor1.Name);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(fields);
            }
コード例 #14
0
        public async Task <GeneratedTemplateInfos> GenerateTemplateExecute(string template, IDataSourceProvider dataSourceProvider)
        {
            if (template == null)
            {
                return(null);
            }

            var parsingOptions = new ParserOptions(template,
                                                   () => new MemoryStream(),
                                                   Encoding.Default,
                                                   _templateServiceProvider.ParserOptions.MaxSize,
                                                   _templateServiceProvider.ParserOptions.DisableContentEscaping);

            parsingOptions.Timeout = _templateServiceProvider.ParserOptions.Timeout;
            parsingOptions.Null    = _templateServiceProvider.ParserOptions.NullSubstitute;
            parsingOptions.StackOverflowBehavior = _templateServiceProvider.ParserOptions.PartialStackOverflowBehavior;
            parsingOptions.PartialStackSize      = _templateServiceProvider.ParserOptions.PartialStackSize;
            parsingOptions.ValueResolver         = new JObjectResolver();

            //if (_templateServiceProvider.ParserOptions.EnableExtendedMissingPathOutput)
            //{
            //	parsingOptions.UnresolvedPath += ParsingOptionsOnUnresolvedPath;
            //}

            //var formatterService = new MorestachioFormatterService();
            //var formatters = _templateServiceProvider.ObtainFormatters();

            //foreach (var formatter in formatters)
            //{
            //	var morestachioFormatterModel = formatter.CreateFormatter();
            //	formatterService.Add(morestachioFormatterModel.Function, morestachioFormatterModel);
            //}


            MorestachioDocumentInfo extendedParseInformation;

            try
            {
                extendedParseInformation = Parser.ParseWithOptions(parsingOptions);
            }
            catch (Exception e)
            {
                return(new GeneratedTemplateInfos()
                {
                    Errors = new IMorestachioError[]
                    {
                        new MorestachioSyntaxError(new CharacterLocationExtended(), "Error ", "", "", e.Message),
                    }
                });
            }

            if (extendedParseInformation.Errors.Any())
            {
                var generatedTemplateInfos = new GeneratedTemplateInfos()
                {
                    InferredTemplateModel = extendedParseInformation.Document,
                    Errors = extendedParseInformation.Errors.ToArray()
                };
                _templateServiceProvider.OnTemplateCreated(generatedTemplateInfos);
                return(generatedTemplateInfos);
            }

            var result = await dataSourceProvider.Fetch();

            if (result == null)
            {
                return(null);
            }

            var generateTemplateExecute = new GeneratedTemplateInfos()
            {
                Result = await extendedParseInformation.CreateAndStringifyAsync(result),
                InferredTemplateModel = extendedParseInformation.Document
            };

            _templateServiceProvider.OnTemplateCreated(generateTemplateExecute);
            return(generateTemplateExecute);
        }
コード例 #15
0
 public Repository(IConfiguration configuration)
 {
     DbContext = new DbProvider <T>(configuration);
 }
コード例 #16
0
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     object[] objArray1 = null;
     if (context != null)
     {
         IComponent component1 = context.Instance as IComponent;
         if (component1 != null)
         {
             ISite site1 = component1.Site;
             if (site1 != null)
             {
                 IDesignerHost host1 = (IDesignerHost)site1.GetService(typeof(IDesignerHost));
                 if (host1 != null)
                 {
                     IDesigner designer1          = host1.GetDesigner(component1);
                     DesignerDataSourceView view1 = this.GetView(designer1);
                     if (view1 != null)
                     {
                         IDataSourceViewSchema schema1 = null;
                         try
                         {
                             schema1 = view1.Schema;
                         }
                         catch (Exception exception1)
                         {
                             IComponentDesignerDebugService service1 = (IComponentDesignerDebugService)site1.GetService(typeof(IComponentDesignerDebugService));
                             if (service1 != null)
                             {
                                 service1.Fail("DataSource DebugService FailedCall\r\n" + exception1.ToString());
                             }
                         }
                         if (schema1 != null)
                         {
                             IDataSourceFieldSchema[] schemaArray1 = schema1.GetFields();
                             if (schemaArray1 != null)
                             {
                                 objArray1 = new object[schemaArray1.Length];
                                 for (int num1 = 0; num1 < schemaArray1.Length; num1++)
                                 {
                                     objArray1[num1] = schemaArray1[num1].Name;
                                 }
                             }
                         }
                     }
                     if (((objArray1 == null) && (designer1 != null)) && (designer1 is IDataSourceProvider))
                     {
                         IDataSourceProvider provider1   = designer1 as IDataSourceProvider;
                         IEnumerable         enumerable1 = null;
                         if (provider1 != null)
                         {
                             enumerable1 = provider1.GetResolvedSelectedDataSource();
                         }
                         if (enumerable1 != null)
                         {
                             PropertyDescriptorCollection collection1 = DesignTimeData.GetDataFields(enumerable1);
                             if (collection1 != null)
                             {
                                 ArrayList list1 = new ArrayList();
                                 foreach (PropertyDescriptor descriptor1 in collection1)
                                 {
                                     list1.Add(descriptor1.Name);
                                 }
                                 objArray1 = list1.ToArray();
                             }
                         }
                     }
                 }
             }
         }
     }
     return(new TypeConverter.StandardValuesCollection(objArray1));
 }
コード例 #17
0
        public async Task <GeneratedTemplateInfos> GenerateTemplateExecute(string template, IDataSourceProvider dataSourceProvider)
        {
            if (template == null)
            {
                return(null);
            }

            var parsingOptions = new ParserOptions(template,
                                                   () => new MemoryStream(),
                                                   Encoding.Default, false, true);

            parsingOptions.ValueResolver = new JObjectResolver();

            //var formatterService = new MorestachioFormatterService();
            //var formatters = _templateServiceProvider.ObtainFormatters();

            //foreach (var formatter in formatters)
            //{
            //	var morestachioFormatterModel = formatter.CreateFormatter();
            //	formatterService.Add(morestachioFormatterModel.Function, morestachioFormatterModel);
            //}


            MorestachioDocumentInfo extendedParseInformation;

            try
            {
                extendedParseInformation = Parser.ParseWithOptions(parsingOptions);
            }
            catch (Exception e)
            {
                return(new GeneratedTemplateInfos()
                {
                    Errors = new IMorestachioError[]
                    {
                        new MorestachioSyntaxError(new CharacterLocationExtended(), "Error ", "", "", e.Message),
                    }
                });
            }

            if (extendedParseInformation.Errors.Any())
            {
                return(new GeneratedTemplateInfos()
                {
                    InferredTemplateModel = extendedParseInformation.Document,
                    Errors = extendedParseInformation.Errors.ToArray()
                });
            }

            var result = await dataSourceProvider.Fetch();

            if (result == null)
            {
                return(null);
            }

            return(new GeneratedTemplateInfos()
            {
                Result = extendedParseInformation.Create(result).Stream.Stringify(true, Encoding.Default),
                InferredTemplateModel = extendedParseInformation.Document
            });
        }
コード例 #18
0
 public TrackerProvider(string connectionName)
 {
     _connectionName     = connectionName;
     _dataSourceProvider = DataSourceProviderFactory.Create(_connectionName);
     RegisterEvents();
 }
コード例 #19
0
        public DataSourceProviderViewModel(IDataSourceProvider provider)
        {
            this.provider = provider;

            this.DataSources = this.provider.DataSources.Select(o => new DataSourceViewModel(o));
        }
コード例 #20
0
 public CustomerTabSubWindowContainer(TabControl tabControl, IDataSourceProvider <Core.Model.Customer> dataSourceProvider)
     : base(tabControl, dataSourceProvider)
 {
 }
コード例 #21
0
 private DummyMultiplexer()
 {
     _source   = new DataSource("Local", "Provider=OLEDB;Data Source=localhost;Initial Catalog=db;Integrated Security=SSPI", "Dummy");
     _provider = new DummySourceProvider(_source);
     _selector = new DummySourceSelector(_source);
 }
コード例 #22
0
 /// <summary>
 /// Prevent from uncontroled creation.
 /// </summary>
 private DynamicDataSourceProvider(IDataSourceProvider provider)
 {
     this.provider = provider;
 }
コード例 #23
0
 public AppInfo(IDataSourceProvider dataSourceProvider, IAppDrive appDrive)
 {
     _dataSourceProvider = dataSourceProvider;
     _appDrive           = appDrive;
 }
コード例 #24
0
 public LogProvider(IDataSourceProvider <Log> dataSourceProvider)
 {
     _dataSourceProvider = dataSourceProvider;
 }
コード例 #25
0
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     object[] values = null;
     if (context != null)
     {
         IComponent instance = context.Instance as IComponent;
         if (instance != null)
         {
             ISite site = instance.Site;
             if (site != null)
             {
                 IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost));
                 if (host != null)
                 {
                     IDesigner dataBoundControlDesigner = host.GetDesigner(instance);
                     DesignerDataSourceView view        = this.GetView(dataBoundControlDesigner);
                     if (view != null)
                     {
                         IDataSourceViewSchema schema = null;
                         try
                         {
                             schema = view.Schema;
                         }
                         catch (Exception exception)
                         {
                             IComponentDesignerDebugService service = (IComponentDesignerDebugService)site.GetService(typeof(IComponentDesignerDebugService));
                             if (service != null)
                             {
                                 service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.Schema", exception.Message }));
                             }
                         }
                         if (schema != null)
                         {
                             IDataSourceFieldSchema[] fields = schema.GetFields();
                             if (fields != null)
                             {
                                 values = new object[fields.Length];
                                 for (int i = 0; i < fields.Length; i++)
                                 {
                                     values[i] = fields[i].Name;
                                 }
                             }
                         }
                     }
                     if (((values == null) && (dataBoundControlDesigner != null)) && (dataBoundControlDesigner is IDataSourceProvider))
                     {
                         IDataSourceProvider provider   = dataBoundControlDesigner as IDataSourceProvider;
                         IEnumerable         dataSource = null;
                         if (provider != null)
                         {
                             dataSource = provider.GetResolvedSelectedDataSource();
                         }
                         if (dataSource != null)
                         {
                             PropertyDescriptorCollection dataFields = DesignTimeData.GetDataFields(dataSource);
                             if (dataFields != null)
                             {
                                 ArrayList list = new ArrayList();
                                 foreach (PropertyDescriptor descriptor in dataFields)
                                 {
                                     list.Add(descriptor.Name);
                                 }
                                 values = list.ToArray();
                             }
                         }
                     }
                 }
             }
         }
     }
     return(new TypeConverter.StandardValuesCollection(values));
 }
コード例 #26
0
 public PlayersController(IMediator mediator, IDataSourceProvider dataSource)
 {
     this._mediator           = mediator;
     this._dataSourceProvider = dataSource;
 }
コード例 #27
0
 public MyODataRoutingMatcherPolicy(IODataTemplateTranslator translator,
                                    IDataSourceProvider provider)
 {
     _translator = translator;
     _provider   = provider;
 }
コード例 #28
0
        private async Task <bool> InitSqlStructure(ISqlFactory factory, IDataSourceProvider dataSourceProvider)
        {
            var executor = new InitialSqlScriptsExecutor(factory);

            return(await executor.ExecuteScripts(useDb : dataSourceProvider.UseDb));
        }
コード例 #29
0
 private DynamicDataSourceProvider(IDataSourceProvider provider) 
 {
     this.provider = provider;
 }
コード例 #30
0
 public PersonalLoanProvider(IDataSourceProvider <PersonalLoan> dataSourceProvider)
 {
     _dataSourceProvider = dataSourceProvider;
 }
コード例 #31
0
    private void mnuConnect_Click(object sender, EventArgs e)
    {
      try
      {
        using (frmChooseDatasource frmChooseDatasource = new frmChooseDatasource())
        {
          if (frmChooseDatasource.ShowDialog() == System.Windows.Forms.DialogResult.OK)
          {
            IDataSourceProviderEditor provEditor = DataSourceProviderManager.CreateProviderEditor(frmChooseDatasource.SelectedProvider);
            Form frmEditor = (Form)provEditor;
            if (frmEditor.ShowDialog() == DialogResult.OK)
            {
              this.Cursor = Cursors.WaitCursor;

              m_dsProvider = (DataSourceProvider)provEditor.CreateProvider();

              UpdateControls();
              UpdateDataGridView(m_dsProvider.Information);

              UpdateMessage("Data source of type '" + frmChooseDatasource.SelectedProvider + "' was successfully connected.");

              this.Cursor = Cursors.Default;
            }
          }
        }
      }
      catch(Exception ex)
      {
        this.Cursor = Cursors.Default;
        UpdateMessage("Exception: " + ex.Message);
        MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    }
コード例 #32
0
 public DataSourceController(IDataSourceProvider dataSource)
 {
     this._dataSourceProvider = dataSource;
 }
コード例 #33
0
    private void mnuDiconnect_Click(object sender, EventArgs e)
    {
      if (m_dsProvider != null)
      {
        m_dsProvider.Close();
        m_dsProvider.Dispose();
        m_dsProvider = null;

        UpdateControls();
        UpdateDataGridView(null);

        UpdateMessage("Data source has been disconnected");
      }
    }
コード例 #34
0
 public virtual void OnDataProviderChanged(IDataSourceProvider e)
 {
     LastProvider = e;
     DataProviderChanged?.Invoke(this, e);
 }
コード例 #35
0
 public HandleAllController(IDataSourceProvider provider)
 {
     _provider = provider;
 }