示例#1
0
        public void LoadFromS3(QueryDefinition qd, EntityDefinition ed, string fileName, Dictionary <string, int> fields)
        {
            var fileKey = string.Format("{0}/{1}/{2}/{3}", Settings.Current.Building.Vendor,
                                        Settings.Current.Building.Id, Settings.Current.Building.DestinationSchemaName, fileName);

            using (var reader = new S3DataReaderLookup(Settings.Current.Bucket, fileKey, Settings.Current.S3AwsAccessKeyId,
                                                       Settings.Current.S3AwsSecretAccessKey, fields, (m) => Logger.Write(null, LogMessageTypes.Debug, m)))
            {
                while (reader.Read())
                {
                    Concept conceptDef = null;
                    if (ed.Concepts != null && ed.Concepts.Any())
                    {
                        conceptDef = ed.Concepts[0];
                    }

                    var concept = (T)ed.GetConcepts(conceptDef, reader, null).ToList()[0];

                    var key = concept.GetKey();
                    if (key == null)
                    {
                        continue;
                    }

                    if (!lookup.ContainsKey(key))
                    {
                        lookup.Add(key, concept);
                    }
                }
            }
        }
示例#2
0
        public void Load(QueryDefinition qd, EntityDefinition ed)
        {
            using (var conn = SqlConnectionHelper.OpenConnection(connectionString))
            {
                using (var c = new SqlCommand(qd.Query, conn))
                {
                    c.CommandTimeout = 30000;
                    using (var reader = c.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Concept conceptDef = null;
                            if (ed.Concepts != null && ed.Concepts.Any())
                            {
                                conceptDef = ed.Concepts[0];
                            }

                            var concept = (T)ed.GetConcepts(conceptDef, reader, null).ToList()[0];

                            var key = concept.GetKey();
                            if (key == null)
                            {
                                continue;
                            }

                            if (!lookup.ContainsKey(key))
                            {
                                lookup.Add(key, concept);
                            }
                        }
                    }
                }
            }
        }
示例#3
0
        private void FillList <T>(ICollection <T> list, QueryDefinition qd, EntityDefinition ed) where T : IEntity
        {
            var sql = GetSqlHelper.GetSql(Settings.Current.Building.SourceEngine.Database,
                                          qd.GetSql(Settings.Current.Building.Vendor, Settings.Current.Building.SourceSchema), Settings.Current.Building.SourceSchema);

            if (string.IsNullOrEmpty(sql))
            {
                return;
            }

            var keys = new Dictionary <string, bool>();

            using (var connection = new OdbcConnection(Settings.Current.Building.SourceConnectionString))
            {
                connection.Open();
                using (var c = new OdbcCommand(sql, connection))
                {
                    c.CommandTimeout = 30000;
                    using (var reader = c.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Concept conceptDef = null;
                            if (ed.Concepts != null && ed.Concepts.Any())
                            {
                                conceptDef = ed.Concepts[0];
                            }

                            var concept = (T)ed.GetConcepts(conceptDef, reader, null).ToList()[0];

                            var key = concept.GetKey();
                            if (key == null)
                            {
                                continue;
                            }

                            if (keys.ContainsKey(key))
                            {
                                continue;
                            }

                            keys.Add(key, false);

                            list.Add(concept);

                            if (CurrentState != BuilderState.Running)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
        public void Load(QueryDefinition qd, EntityDefinition ed)
        {
            var sql = qd.GetSql(Settings.Current.Building.SourceEngine.Database, Settings.Current.Building.Vendor, schemaName);

            if (string.IsNullOrEmpty(sql))
            {
                return;
            }

            using (var conn = SqlConnectionHelper.OpenOdbcConnection(connectionString))
            {
                using (var c = new OdbcCommand(sql, conn))
                {
                    c.CommandTimeout = 30000;
                    using (var reader = c.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Concept conceptDef = null;
                            if (ed.Concepts != null && ed.Concepts.Any())
                            {
                                conceptDef = ed.Concepts[0];
                            }

                            var concept = (T)ed.GetConcepts(conceptDef, reader, null).ToList()[0];

                            var key = concept.GetKey();
                            if (key == null)
                            {
                                continue;
                            }

                            if (!lookup.ContainsKey(key))
                            {
                                lookup.Add(key, concept);
                            }
                        }
                    }
                }
            }
        }