Ejemplo n.º 1
0
 /// <inheritdoc/>
 public void AddChild(Base child)
 {
     if (child is DataConnectionBase)
     {
         Connections.Add(child as DataConnectionBase);
     }
     else if (child is DataSourceBase)
     {
         DataSources.Add(child as DataSourceBase);
     }
     else if (child is Relation)
     {
         Relations.Add(child as Relation);
     }
     else if (child is Parameter)
     {
         Parameters.Add(child as Parameter);
     }
     else if (child is Total)
     {
         Totals.Add(child as Total);
     }
     else if (child is CubeSourceBase)
     {
         CubeSources.Add(child as CubeSourceBase);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var precos = _beneficiamentoFluxo.PesquisarResumoPrecosPadraoBeneficiamentos(Descricao);

            // Recupera o critério da pesquisa
            DataSources.Add(new ReportDataSource("BenefConfigPreco", precos.ToArray()));
        }
Ejemplo n.º 3
0
        public async Task <ModelItem> AddDataSource(ReferenceDescriptionViewModel vm)
        {
            if (_session != null && _session.Connected)
            {
                var nodeId = ExpandedNodeId.ToNodeId(vm.NodeId, _session.NamespaceUris);
                var type   = await _session.GetDataTypeFromNodeId(nodeId);

                var name  = string.Concat(vm.Parent.DisplayName, vm.DisplayName, "Source").Replace(" ", "");
                var regex = new Regex(@"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Nl}\p{Mn}\p{Mc}\p{Cf}\p{Pc}\p{Lm}]");
                name = regex.Replace(name, "_");
                if (!char.IsLetter(name, 0))
                {
                    name = string.Concat("_", name);
                }
                var list2 = Properties.Select(mi => (string)mi.Properties["DisplayName"].ComputedValue).Concat(Commands.Select(mi => (string)mi.Properties["DisplayName"].ComputedValue)).Concat(DataSources.Select(mi => (string)mi.Properties["DisplayName"].ComputedValue)).ToList();
                while (list2.Contains(name))
                {
                    name = string.Concat(name, "_2");
                }
                var item = ModelFactory.CreateItem(_modelItem.Context, new UaItem {
                    DisplayName = name, StartNodeId = nodeId, Type = type, NodeClass = vm.NodeClass, CacheQueueSize = 240
                });
                DataSources.Add(item);
                return(item);
            }
            return(null);
        }
Ejemplo n.º 4
0
        private void AddDataSourceViewModel(DataSource dataSource)
        {
            switch (dataSource)
            {
            case FlatFileDataSource:
                DataSources.Add(new FlatFileDataSourceViewModel(dataSource));
                break;

            case GraphQlDataSource:
                DataSources.Add(new GraphQlDataSourceViewModel(dataSource));
                break;

            //case JsonFileDataSource:
            //	DataSources.Add(new JsonFileDataSourceViewModel(dataSource));
            //	break;
            case RestDataSource:
                DataSources.Add(new RestDataSourceViewModel(dataSource));
                break;

            case ScriptDataSource:
                DataSources.Add(new ScriptDataSourceViewModel(dataSource));
                break;

            case SqlDataSource:
                DataSources.Add(new SqlDataSourceViewModel(dataSource));
                break;

            default:
                throw new InvalidOperationException("Invalid connection type");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var tiposFiscais = String.IsNullOrEmpty(TiposFiscais) ? null :
                               TiposFiscais.Split(',')
                               .Select(x => (Data.Model.TipoFiscalCliente)x.StrParaInt())
                               .ToArray();

            var formasPagto = String.IsNullOrEmpty(FormasPagto) ? null :
                              FormasPagto.Split(',')
                              .Select(x => x.StrParaInt())
                              .ToArray();

            var situacao = String.IsNullOrEmpty(Situacao) ? null :
                           Situacao.Split(',')
                           .Select(x => x.StrParaInt())
                           .ToArray();

            var tiposCliente = String.IsNullOrEmpty(IdTipoCliente) ? null :
                               IdTipoCliente.Split(',')
                               .Select(x => x.StrParaInt())
                               .ToArray();

            var clientes = _clienteFluxo.PesquisarClientes(IdCliente, NomeOuApelido, CpfCnpj, IdLoja, Telefone,
                                                           Logradouro, Bairro, IdCidade, tiposCliente, situacao, CodigoRota, IdVendedor, tiposFiscais, formasPagto,
                                                           DataCadastroIni, DataCadastroFim, DataSemCompraIni, DataSemCompraFim, DataInativadoIni, DataInativadoFim,
                                                           DataNascimentoIni, DataNascimentoFim, IdTabelaDescontoAcrescimo, ApenasSemRota, Limite, Uf, TipoPessoa, ComCompra);

            // Recupera o critério da pesquisa
            Parameters.Add("Criterio", clientes.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            this.Parameters.Add("AgruparVend", this.AgruparVendedor);
            Parameters.Add("ExibirHistorico", ExibirHistorico);
            Parameters.Add("ExibirCidade", true);

            DataSources.Add(new ReportDataSource("Cliente", clientes));
        }
Ejemplo n.º 6
0
        public bool StartReport()
        {
            fmPaymentStatement fmPayStat = new fmPaymentStatement();

            if (fmPayStat.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }
            string               error             = string.Empty;
            DateTime             dat               = fmPayStat.GetDateParam();
            EnumPaymentStatement enumPayStat       = fmPayStat.GetFormParam();
            List <int>           id_typePayment    = fmPayStat.GetIdCheckedTypePayment();
            List <int>           id_typeAddPayment = fmPayStat.GetIdCheckedTypeAddPayment();

            LoadDataForPrint(dat, enumPayStat, id_typePayment, id_typeAddPayment, out error);
            if (error != string.Empty)
            {
                MessageBox.Show("Помилка.\nТехнічна інформація: " + error, "Помилка");
                return(false);
            }

            Parameters[0] = new ReportParameter("MonthName", SalaryHelper.GetMonthNameById(dat.Month, EnumCaseWorld.Nominative));
            Parameters[1] = new ReportParameter("SumTotalRep",
                                                (_paymentStatement.Sum(rec => rec.Payment_Sm) + _addPaymentStatement.Sum(rec => rec.AddPayment_Sm)).ToString("0.00"));

            ReportDataSource report  = new ReportDataSource("dsPaymentStatement", _paymentStatement);
            ReportDataSource report2 = new ReportDataSource("dsAddPaymentStatement", _addPaymentStatement);

            DataSources.Add(report);
            DataSources.Add(report2);
            return(true);
        }
Ejemplo n.º 7
0
        public bool StartReport()
        {
            fmAccrStatement fmAccrStat = new fmAccrStatement();

            if (fmAccrStat.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }
            string         error    = string.Empty;
            DateTime       datBeg   = fmAccrStat.GetDateBegParam();
            DateTime       datEnd   = fmAccrStat.GetDateEndParam();
            EnumSalaryList typeForm = fmAccrStat.GetFormParam();
            List <int>     id_dep   = fmAccrStat.GetIdCheckedDep();

            Parameters[0] = new ReportParameter("MonthNameBeg", SalaryHelper.GetMonthNameById(datBeg.Month, EnumCaseWorld.Genetive));
            Parameters[1] = new ReportParameter("MonthNameEnd", SalaryHelper.GetMonthNameById(datEnd.Month, EnumCaseWorld.Nominative));

            LoadDataForPrint(datBeg, datEnd, typeForm, id_dep, out error);
            if (error != string.Empty)
            {
                MessageBox.Show("Помилка.\nТехнічна інформація: " + error, "Помилка");
                return(false);
            }
            ReportDataSource report = new ReportDataSource("dsAccrStatement", _accrStatement);

            DataSources.Add(report);
            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Loads the configuration from the specified file.
        /// </summary>
        public bool Load(string fileName, out string errMsg)
        {
            try
            {
                SetToDefault();

                if (!File.Exists(fileName))
                {
                    throw new FileNotFoundException(string.Format(CommonPhrases.NamedFileNotFound, fileName));
                }

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);
                XmlElement rootElem = xmlDoc.DocumentElement;

                if (rootElem.SelectSingleNode("GeneralOptions") is XmlNode generalOptionsNode)
                {
                    GeneralOptions.LoadFromXml(generalOptionsNode);
                }

                if (xmlDoc.DocumentElement.SelectSingleNode("Connections") is XmlNode connectionsNode)
                {
                    foreach (XmlNode connectionNode in connectionsNode.SelectNodes("Connection"))
                    {
                        ConnectionOptions connectionOptions = new ConnectionOptions();
                        connectionOptions.LoadFromXml(connectionNode);
                        Connections[connectionOptions.Name] = connectionOptions;
                    }
                }

                if (rootElem.SelectSingleNode("DataSources") is XmlNode dataSourcesNode)
                {
                    foreach (XmlElement dataSourceElem in dataSourcesNode.SelectNodes("DataSource"))
                    {
                        DataSourceConfig dataSourceConfig = new DataSourceConfig();
                        dataSourceConfig.LoadFromXml(dataSourceElem);
                        DataSources.Add(dataSourceConfig);
                    }
                }

                if (rootElem.SelectSingleNode("Lines") is XmlNode linesNode)
                {
                    foreach (XmlElement lineElem in linesNode.SelectNodes("Line"))
                    {
                        LineConfig lineConfig = new LineConfig();
                        lineConfig.LoadFromXml(lineElem);
                        Lines.Add(lineConfig);
                    }
                }

                FillDriverCodes();
                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = CommonPhrases.LoadAppConfigError + ": " + ex.Message;
                return(false);
            }
        }
Ejemplo n.º 9
0
        public bool StartReport()
        {
            fmSalaryList fmList = new fmSalaryList(_checkedId == null ? false : true);

            if (fmList.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            string         error    = string.Empty;
            DateTime       dat      = fmList.GetDateParam();
            EnumSalaryList typeForm = fmList.GetFormParam();
            List <int>     id_dep   = fmList.GetIdCheckedDep();

            LoadDataForPrint(dat, typeForm, id_dep, out error);
            if (error != string.Empty)
            {
                MessageBox.Show("Помилка.\nТехнічна інформація: " + error, "Помилка");
                return(false);
            }
            ReportDataSource report = new ReportDataSource("dsSalaryList", _salaryList);

            DataSources.Add(report);
            return(true);
        }
Ejemplo n.º 10
0
        public IDataSource CreateLocalDataSourceConnection(ConnectionProperties dataConnection, string pdatasourcename, string ClassDBHandlerName)
        {
            ErrorObject.Flag = Errors.Ok;
            IDataSource             ds      = null;
            ConnectionDriversConfig package = null;

            if (ConfigEditor.DataDriversClasses.Where(x => x.classHandler == ClassDBHandlerName).Any())
            {
                package = ConfigEditor.DataDriversClasses.Where(x => x.classHandler == ClassDBHandlerName).FirstOrDefault();
                string packagename = ConfigEditor.DataSourcesClasses.Where(x => x.className == package.classHandler).FirstOrDefault().PackageName;

                Type            adc  = assemblyHandler.GetType(packagename);
                ConstructorInfo ctor = adc.GetConstructors().First();
                ObjectActivator <IDataSource> createdActivator = GetActivator <IDataSource>(ctor);

                //create an instance:
                ds = createdActivator(dataConnection.ConnectionName, Logger, this, dataConnection.DatabaseType, ErrorObject);
            }


            try
            {
                if (ds != null)
                {
                    ds.Dataconnection.ConnectionProp   = dataConnection;
                    ds.Dataconnection.DataSourceDriver = package;
                    ds.Dataconnection.ReplaceValueFromConnectionString();
                    ILocalDB dB = (ILocalDB)ds;
                    DataSources.Add(ds);

                    AddLogMessage("Fail", $"Success Created Local Database  {pdatasourcename}", DateTime.Now, -1, "", Errors.Failed);
                    return(ds);
                }
                else
                {
                    AddLogMessage("Fail", "Could Find DataSource Drivers", DateTime.Now, 0, pdatasourcename, Errors.Failed);
                    return(null);
                }

                //     bool ok= dB.CreateDB();
                //      if (ok)
                //      {
                //  ds.ConnectionStatus = ds.Dataconnection.OpenConnection();
                //if (ds.ConnectionStatus == ConnectionState.Open)
                //{
                // ConfigEditor.DataConnections.Add(dataConnection);


                //}else
                //{
                //    return null;
                //}
            }
            catch (Exception ex)
            {
                AddLogMessage("Fail", $"Error in Opening Connection (Check DLL for Connection drivers,connect string, Datasource down,Firewall, .. etc)({ex.Message})", DateTime.Now, -1, "", Errors.Failed);
                return(null);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var comissionados = _comissionadoFluxo.PesquisarComissionados(Nome, Situacao);

            // Recupera o critério da pesquisa
            //Parameters.Add("Criterio", comissionados.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            DataSources.Add(new ReportDataSource("Comissionado", comissionados.ToArray()));
        }
Ejemplo n.º 12
0
 private void frmDataSources_FormClosed(object sender, FormClosedEventArgs e)
 {
     lstDs = new DataSources();
     foreach (ListViewItem oRow in lvwDS.Items)
     {
         lstDs.Add((DataSource)oRow.Tag);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var rota         = _rotaFluxo.ObtemRota(IdRota);
            var rotaClientes = _rotaFluxo.PesquisarClientesRota(IdRota);

            DataSources.Add(new ReportDataSource("Rota", new Global.Negocios.Entidades.Rota[] { rota }));
            DataSources.Add(new ReportDataSource("RotaCliente", rotaClientes.ToArray()));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var funcionarios = _funcionarioFluxo
                               .PesquisarFuncionarios(IdLoja, Nome, Situacao, ApenasRegistrados, IdTipoFuncionario, IdSetor, DataNascInicio, DataNascFim);

            this.Parameters.Add("Criterio", funcionarios.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            // Recupera o critério da pesquisa
            DataSources.Add(new ReportDataSource("Funcionario", funcionarios.ToArray()));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Atualiza as fontes de dados.
        /// </summary>
        public override void RefreshDataSources()
        {
            var produtosFornecedor = _fornecedorFluxo.PesquisarProdutosFornecedor(IdFornecedor, IdProduto, null, CodigoProduto, DescricaoProduto);

            // Recupera o critério da pesquisa
            Parameters.Add("Criterio", produtosFornecedor.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            Parameters.Add("AgruparProduto", (produtosFornecedor.Select(x => x.IdProd).Distinct().Count() == 1).ToString());
            Parameters.Add("AgruparFornecedor", (produtosFornecedor.Select(x => x.IdFornec).Distinct().Count() == 1).ToString());
            DataSources.Add(new ReportDataSource("ProdutoFornecedor", produtosFornecedor));
        }
Ejemplo n.º 16
0
        private void AddDocumentDataSourceButton_Click(object sender, EventArgs e)
        {
            var dataSourceObject = new DataSourceObject();

            DataSources.Add(dataSourceObject);

            var documentDataSource = new DocumentDataSource();

            dataSourceObject.DataSource        = documentDataSource;
            documentDataSource.ObjectInspector = ObjectInspector;
            GridViewDataSources.RefreshData();
        }
Ejemplo n.º 17
0
        protected override ModuleEndpointDataSource GetOrCreateDataSource()
        {
            var dataSource = DataSources.OfType <ModuleEndpointDataSource <TModule> >().FirstOrDefault();

            if (dataSource == null)
            {
                dataSource = ServiceProvider.GetRequiredService <ModuleEndpointDataSource <TModule> >();
                DataSources.Add(dataSource);
            }

            return(dataSource);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var tipoPessoa = !TipoPessoa.HasValue ? (Data.Model.TipoPessoa?) null:
                             TipoPessoa.Value == 1 ? Data.Model.TipoPessoa.Fisica :
                             Data.Model.TipoPessoa.Juridica;

            var fornecedores = _fornecedorFluxo.PesquisarFornecedores
                                   (IdFornecedor, NomeFornecedor, Situacao, Cnpj, ComCredito, tipoPessoa, IdConta.GetValueOrDefault(0), TipoPagto.GetValueOrDefault(0),
                                   Endereco, Vendedor);

            // Recupera o critério da pesquisa
            Parameters.Add("Criterio", fornecedores.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            DataSources.Add(new ReportDataSource("Fornecedor", fornecedores.ToArray()));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var situacoes2 = new Situacao[0];

            if (!string.IsNullOrEmpty(Situacao))
            {
                situacoes2 = Situacao.Split(',').Select(f => (Situacao)int.Parse(f)).ToArray();
            }

            var sugestoes = _sugestaoFluxo.PesquisarSugestoes(
                IdSugestao, IdCliente, IdFunc, null, NomeCliente, DataInicio, DataFim, Tipo, Descricao, situacoes2, IdRota, IdPedido, IdOrcamento, IdVendedorAssoc);

            // Recupera o critério da pesquisa
            Parameters.Add("Criterio", sugestoes.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            DataSources.Add(new ReportDataSource("SugestaoCliente", sugestoes.ToArray()));
        }
Ejemplo n.º 20
0
        private void Handle(FeedDataSourceSubscribedEvent evt)
        {
            if (UserId != evt.UserId)
            {
                throw new DomainException(Global.UserNotAuthorizedToSubscribe);
            }

            if (DataSources.Any(d => d.DatasourceId == evt.DataSourceId))
            {
                throw new DomainException(string.Format(Global.DatasourceAlreadyExists, evt.DataSourceId));
            }

            DataSources.Add(FeedDatasource.Create(evt.DataSourceId));
            UpdateDateTime = evt.CreateDateTime;
            Version        = evt.Version;
        }
        public void CreateDataSource()
        {
            if (AllowEdit)
            {
                _dataSourceDialog.DataSourceInfo = null;

                if (_dataSourceDialog.ShowDialog(this) == DialogResult.OK)
                {
                    var newDataSourceInfo = _dataSourceDialog.DataSourceInfo;

                    DataSources.Add(newDataSourceInfo);

                    UpdateDataSourceNode(newDataSourceInfo, null);

                    InvokeDataSourceCreated(newDataSourceInfo);
                }
            }
        }
Ejemplo n.º 22
0
        public void InitDataSource()
        {
            DataSourceWrapper dsw            = DataSourceWrapper.Create();
            IEditableObject   editableObject = dsw;

            editableObject.BeginEdit();
            bool acceptChanges = OpenDataSourceEditor(dsw);

            if (acceptChanges)
            {
                dsw.DoEndEdit();
                DataSources.Add(dsw);
                SelectedDataSource = dsw;
            }
            else
            {
                dsw.DoCancelEdit();
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Atualiza os DataSources.
        /// </summary>
        public override void RefreshDataSources()
        {
            var tiposFiscais = String.IsNullOrEmpty(TiposFiscais) ? null :
                               TiposFiscais.Split(',')
                               .Select(x => (Data.Model.TipoFiscalCliente)x.StrParaInt())
                               .ToArray();

            var clientes = _clienteFluxo.PesquisarClientes(IdCliente, NomeOuApelido, CpfCnpj, IdLoja, Telefone,
                                                           Logradouro, Bairro, IdCidade, IdTipoCliente, Situacao, CodigoRota, IdVendedor, tiposFiscais,
                                                           DataCadastroIni, DataCadastroFim, DataSemCompraIni, DataSemCompraFim, DataInativadoIni, DataInativadoFim,
                                                           IdTabelaDescontoAcrescimo, ApenasSemRota);

            // Recupera o critério da pesquisa
            Parameters.Add("Criterio", clientes.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            Parameters.Add("AgruparVend", AgruparVendedor);
            Parameters.Add("ExibirHistorico", Glass.Configuracoes.ClienteConfig.TelaListagemClientes.ExibirHistoricoRptLstCliente);

            DataSources.Add(new ReportDataSource("Cliente", clientes));
        }
Ejemplo n.º 24
0
        internal void RegisterDataTable(DataTable table, string referenceName, bool enabled)
        {
            AddRegisteredItem(table, referenceName);

            TableDataSource source = FindDataComponent(referenceName) as TableDataSource;

            if (source != null)
            {
                source.Reference = table;
                source.InitSchema();
                source.RefreshColumns(true);
            }
            else
            {
                // check tables inside connections. Are we trying to replace the connection table
                // with table provided by an application?
                source = FindByAlias(referenceName) as TableDataSource;
                // check "Data.TableName" case
                if (source == null && referenceName.StartsWith("Data."))
                {
                    source = FindByAlias(referenceName.Remove(0, 5)) as TableDataSource;
                }
                if (source != null && (source.Connection != null || source.IgnoreConnection))
                {
                    source.IgnoreConnection = true;
                    source.Reference        = table;
                    source.InitSchema();
                    source.RefreshColumns(true);
                }
                else
                {
                    source = new TableDataSource();
                    source.ReferenceName = referenceName;
                    source.Reference     = table;
                    source.Name          = CreateUniqueName(referenceName.Contains(".") ? table.TableName : referenceName);
                    source.Alias         = CreateUniqueAlias(source.Alias);
                    source.Enabled       = enabled;
                    source.InitSchema();
                    DataSources.Add(source);
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Atualiza as fontes de dados.
        /// </summary>
        public override void RefreshDataSources()
        {
            var produtos = _produtoFluxo.PesquisarProdutos(
                CodInterno, Descricao, Situacao, IdLoja, IdFornecedor, NomeFornecedor, IdGrupoProd, IdSubgrupoProd,
                TipoNegociacaoProduto, ApenasProdutosEstoqueBaixa, Agrupar, AlturaInicio, AlturaFim, LarguraInicio, LarguraFim, Ordenacao);

            if (string.IsNullOrEmpty(this.Colunas))
            {
                this.Colunas = "3,4,5,6,7,8";
            }

            Parameters.Add("Criterio", produtos.GetSearchParameterDescriptions().Join(" ").Format() ?? "");
            Parameters.Add("ApenasProdutosEstoqueBaixa", ApenasProdutosEstoqueBaixa.ToString());
            Parameters.Add("Colunas", Colunas);
            Parameters.Add("Agrupar", Agrupar);
            Parameters.Add("DescricaoAtacadoReposicao", DescricaoAtacadoReposicao);


            DataSources.Add(new ReportDataSource("Produto", produtos.ToArray()));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Registers a business object.
        /// </summary>
        /// <param name="data">The business object.</param>
        /// <param name="referenceName">The name of the object.</param>
        /// <param name="maxNestingLevel">Maximum level of data nesting.</param>
        /// <param name="enabled">Determines wheter to enable the object or not.</param>
        /// <remarks>
        /// This method is for internal use only.
        /// </remarks>
        public void RegisterBusinessObject(IEnumerable data, string referenceName, int maxNestingLevel, bool enabled)
        {
            AddRegisteredItem(data, referenceName);

            Type dataType = data.GetType();

            if (data is BindingSource)
            {
                if ((data as BindingSource).DataSource is Type)
                {
                    dataType = ((data as BindingSource).DataSource as Type);
                }
                else
                {
                    dataType = (data as BindingSource).DataSource.GetType();
                }
            }

            BusinessObjectConverter  converter = new BusinessObjectConverter(this);
            BusinessObjectDataSource source    = FindDataComponent(referenceName) as BusinessObjectDataSource;

            if (source != null)
            {
                source.Reference = data;
                source.DataType  = dataType;
                converter.UpdateExistingObjects(source, maxNestingLevel);
            }
            else
            {
                source = new BusinessObjectDataSource();
                source.ReferenceName = referenceName;
                source.Reference     = data;
                source.DataType      = dataType;
                source.Name          = CreateUniqueName(referenceName);
                source.Alias         = CreateUniqueAlias(source.Alias);
                source.Enabled       = enabled;
                DataSources.Add(source);

                converter.CreateInitialObjects(source, maxNestingLevel);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Loads the configuration from the specified reader.
        /// </summary>
        protected override void Load(TextReader reader)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(reader);
            XmlElement rootElem = xmlDoc.DocumentElement;

            if (rootElem.SelectSingleNode("GeneralOptions") is XmlNode generalOptionsNode)
            {
                GeneralOptions.LoadFromXml(generalOptionsNode);
            }

            if (rootElem.SelectSingleNode("ConnectionOptions") is XmlNode connectionOptionsNode)
            {
                ConnectionOptions.LoadFromXml(connectionOptionsNode);
            }

            if (rootElem.SelectSingleNode("DataSources") is XmlNode dataSourcesNode)
            {
                foreach (XmlElement dataSourceElem in dataSourcesNode.SelectNodes("DataSource"))
                {
                    DataSourceConfig dataSourceConfig = new DataSourceConfig();
                    dataSourceConfig.LoadFromXml(dataSourceElem);
                    DataSources.Add(dataSourceConfig);
                }
            }

            if (rootElem.SelectSingleNode("Lines") is XmlNode linesNode)
            {
                foreach (XmlElement lineElem in linesNode.SelectNodes("Line"))
                {
                    LineConfig lineConfig = new LineConfig {
                        Parent = this
                    };
                    lineConfig.LoadFromXml(lineElem);
                    Lines.Add(lineConfig);
                }
            }

            FillDriverCodes();
        }
Ejemplo n.º 28
0
        protected override ModuleEndpointDataSource GetOrCreateDataSource()
        {
            var edsType    = typeof(ModuleEndpointDataSource <>).MakeGenericType(ModuleType);
            var dataSource = default(ModuleEndpointDataSource);

            foreach (var eds in DataSources)
            {
                if (eds.GetType() == edsType)
                {
                    dataSource = (ModuleEndpointDataSource)eds;
                }
            }

            if (dataSource == null)
            {
                dataSource = (ModuleEndpointDataSource)ServiceProvider.GetService(edsType);
                DataSources.Add(dataSource);
            }

            return(dataSource);
        }
        public override void Run()
        {
            var dataSetForMainTable = CreateDataSet();
            var mainTable           = MainTable.Create(dataSetForMainTable.Name);
            var dataSetForSubTable  = CreateDataSet();
            var subTable            = SubTable.Create(dataSetForSubTable.Name);
            var body = new Body();

            body.AddReportItem(mainTable);
            body.AddReportItem(subTable);
            Report.AddReportSection(new ReportSection(body));

            Report.AddDataSet(dataSetForMainTable);
            Report.AddDataSet(dataSetForSubTable);
            DataSources.Add(new ReportDataSource(dataSetForMainTable.Name, MainTableDataSource.Create()));
            DataSources.Add(new ReportDataSource(dataSetForSubTable.Name, SubTableDataSource.Create()));

            CreateEmbeddedImages();

            base.Run();
        }
Ejemplo n.º 30
0
        public HistoricalDataBroker(IDataStorage localStorage,
                                    IEnumerable <IHistoricalDataSource> additionalSources = null)
        {
            if (localStorage == null)
            {
                throw new ArgumentNullException(nameof(localStorage));
            }

            dataStorage = localStorage;

            //add the continuous futures broker to the data sources

            //add additional sources
            if (additionalSources != null)
            {
                foreach (IHistoricalDataSource ds in additionalSources)
                {
                    if (!DataSources.ContainsKey(ds.Name))
                    {
                        ds.Error += DatasourceError;
                        ds.HistoricalDataArrived += ExternalHistoricalDataArrived;
                        ds.Disconnected          += SourceDisconnects;
                        DataSources.Add(ds.Name, ds);
                    }
                }
            }

            dataStorage.Error += DatasourceError;
            dataStorage.HistoricalDataArrived += LocalStorageHistoricalDataArrived;

            connectionTimer          = new Timer(10000);
            connectionTimer.Elapsed += ConnectionTimerElapsed;
            connectionTimer.Start();

            originalRequests = new ConcurrentDictionary <int, HistoricalDataRequest>();
            subRequests      = new ConcurrentDictionary <int, List <HistoricalDataRequest> >();
            usedIDs          = new List <int>();

            TryConnect();
        }