Esempio n. 1
0
        public String IssueContextToHTML(IssueContext context)
        {
            var table_ids = context.GetTables();
            var tables    = table_ids.Select(tid => this.dblint.DatabaseModel.GetTable(tid));

            if (tables.Count() > 0)
            {
                var formatted_tables = tables.Select(t => this.formatter.Format(t));
                return(String.Join("<br/>", formatted_tables));
            }
            else
            {
                return("-");
            }
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IssueContext db)
        {
            TstLeftJoin(db);

            Console.WriteLine("hello");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
Esempio n. 3
0
        public IList <IssueExecutionDTO> ObterTodasAsExecucoesDaTarefa(int idTarefa)
        {
            using (IssueContext db = new IssueContext())
            {
                var resultado = db.IssueExecutions.AsQueryable();

                resultado = resultado.Where(c => c.Issue.Id == idTarefa);

                var listaTarefas = resultado.ToList();

                var listaTarefasDTO = listaTarefas.Select(c => new IssueExecutionDTO()
                {
                    CodigoJira = c.Issue.IssueName, StartTime = c.StartDateTime.Value, EndTime = c.EndDateTime, Id = c.Id, CodigoTarefaPai = c.Issue.Id
                }).ToList();

                return(listaTarefasDTO);
            }
        }
Esempio n. 4
0
        public async Task TstLeftJoin(IssueContext db)
        {
            //Int Ids
            try
            {
                using (var l2db = db.CreateLinqToDbConnection())
                {
                    LinqToDB.Common.Configuration.Linq.GenerateExpressionTest = true;
                    var test =
                        from dt in l2db.GetTable <Devtypes>()
                        from d in l2db.GetTable <Devices>().LeftJoin(pr => pr.Devtypeid == dt.Devtypeid)
                        select new { dt, d }
                    ;

                    var x0 = test.ToList();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(JsonConvert.SerializeObject(e).ToString());
                //throw;
            }

            //Guid Ids
            try
            {
                using (var l2db = db.CreateLinqToDbConnection())
                {
                    LinqToDB.Common.Configuration.Linq.GenerateExpressionTest = true;
                    var test =
                        from g in l2db.GetTable <DAL_Gateway>()
                        from gs in l2db.GetTable <DAL_GatewaySettings>().LeftJoin(pr => pr.GatewayId == g.Id)
                        select new { g, gs }
                    ;

                    var x0 = test.ToList();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(JsonConvert.SerializeObject(e).ToString());
                //throw;
            }
        }
Esempio n. 5
0
        public IList <IssueExecutionDTO> ObterTarefasUltimos7Dias()
        {
            using (IssueContext db = new IssueContext())
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("SELECT IE.Id, IE.Issue_Id, IE.StartDate, IE.EndDate ");
                sb.Append("FROM IssueExecution IE, Issue I ");
                sb.Append("where IE.Issue_Id = I.Id and  IE.StartDate >= '");
                sb.Append(DateTime.Now.Date.AddDays(-7).ToString("yyyy-MM-dd"));
                sb.Append("'");

                IList <IssueExecutionDTO> lista = db.IssueExecutions.SqlQuery(sb.ToString()).ToList <IssueExecution>().Select(c => new IssueExecutionDTO()
                {
                    CodigoJira = c.Issue.IssueName, StartTime = c.StartDateTime.Value, EndTime = c.EndDateTime, Id = c.Id, CodigoTarefaPai = c.Issue.Id
                }).ToList();

                return(lista.OrderBy(c => c.StartTime).ToList());
            }
        }
Esempio n. 6
0
        public Issue GetIssue(List <List <Column> > groups)
        {
            var colCount = groups.SelectMany(v => v).Count();
            var dt       = new DataTable();

            dt.Columns.Add("Number of Columns");
            dt.Columns.Add("Percentage");
            foreach (var group in groups)
            {
                var row = dt.NewRow();
                row[0] = String.Format("{0} columns have length {1}", group.Count, group.First().CharacterMaxLength);
                row[1] = String.Format("{0}%", Math.Round((100.0 / colCount) * group.Count, 2));
                dt.Rows.Add(row);
            }

            Description description = null;

            if (groups.Count == 2)
            {
                var firstGroupCount   = groups[0].Count;
                var secondGroupCount  = groups[1].Count;
                var firstGroupLength  = groups[0].First().CharacterMaxLength;
                var secondGroupLength = groups[1].First().CharacterMaxLength;

                description = new Description("Inconsistent lengths of varchar columns. {0} columns have length {1} and {2} columns have length {3}", firstGroupCount, firstGroupLength, secondGroupCount, secondGroupLength);
            }
            else
            {
                description = new Description("Inconsistent lengths of {0} varchar columns.", colCount);
            }

            var contextTables = groups.SelectMany(gt => gt.Select(g => g.Table)).Distinct().ToList();
            var issue         = new Issue(this, this.DefaultSeverity.Value)
            {
                Name                = this.Name,
                Context             = IssueContext.Create(contextTables),
                Description         = description,
                ExtendedDescription = new Description("{0}", dt)
            };

            return(issue);
        }
Esempio n. 7
0
        public void IniciarAtendimentoTarefa(int idTarefa)
        {
            try
            {
                using (IssueContext db = new IssueContext())
                {
                    Issue issue = db.Issues.Where(c => c.Id == idTarefa).ToList().FirstOrDefault();

                    IssueExecution newIssueExecution = new IssueExecution();
                    newIssueExecution.Issue         = issue;
                    newIssueExecution.StartDateTime = DateTime.Now;

                    db.IssueExecutions.Add(newIssueExecution);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 8
0
        public void RemoverTarefasExecutadas(IList <int> listaIdsTarefasSelecionadas)
        {
            using (IssueContext db = new IssueContext())
            {
                try
                {
                    var resultado = db.IssueExecutions.AsQueryable();
                    resultado = resultado.Where(c => listaIdsTarefasSelecionadas.Contains(c.Id));
                    var listaTarefas = resultado.ToList();
                    foreach (var tarefa in listaTarefas)
                    {
                        db.IssueExecutions.Remove(tarefa);
                    }

                    db.SaveChanges();
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }
            }
        }
Esempio n. 9
0
        // This function will get triggered/executed when a new message is written
        // on an Azure Queue called queue.
//		public static async Task ProcessQueueMessage([TimerTrigger("0 */10 * * * *")]TimerInfo timer)
        public static async void ProcessQueueMessage([TimerTrigger("0 0 12 1/3 * *")] TimerInfo timer)
        {
            var issueCommandRepository = new IssueCommandRepository();
            var issueQueryRepository   = new IssueQueryRepository();
            var issueContext           = new IssueContext(issueQueryRepository, issueCommandRepository);
            var issueFactory           = new IssueFactory(issueContext);

            var titleCommandRepository = new TitleCommandRepository();
            var titleQueryRepository   = new TitleQueryRepository();
            var titleContext           = new TitleContext(titleQueryRepository, titleCommandRepository);
            var titleFactory           = new TitleFactory(titleContext);

            var publisherQueryRepository = new PublisherQueryRepository();
            var publisherContext         = new PublisherContext(publisherQueryRepository);
            var publisherFactory         = new PublisherFactory(publisherContext);

            var catalogContext = new CatalogContext(publisherFactory, titleFactory, issueFactory);

            var Catalog = new CatalogObject(catalogContext);

            await Catalog.Commands.NewReleases(0);

            var end = string.Empty;
        }
Esempio n. 10
0
        public override void Execute(Database database, IIssueCollector issueCollector, IProviderCollection providers)
        {
            foreach (var schema in database.Schemas)
            {
                if (!schema.Tables.Any(t => t.ForeignKeys.Count > 0))
                {
                    Issue s = new Issue(this, Severity.Critical);
                    s.Name        = "No Foreign Keys";
                    s.Description = new Description("The schema '{0}' has no foreign keys", schema.SchemaName);
                    s.Context     = new SchemaContext(schema);
                    issueCollector.ReportIssue(s);
                    continue;
                }

                DatabaseDictionary <TableID, Table> seenTables = DictionaryFactory.CreateTableID <Table>();
                DatabaseDictionary <TableID, Table> notSeen    = DictionaryFactory.CreateTableID <Table>();

                foreach (var t in schema.Tables)
                {
                    notSeen.Add(t, t);
                }
                List <List <Table> > clusters = new List <List <Table> >();
                while (notSeen.Count > 0)
                {
                    var table   = notSeen.First().Value;
                    var cluster = new List <Table>(schema.Tables.Count);
                    BrowseTables(table, seenTables, notSeen, cluster);
                    clusters.Add(cluster);
                }

                foreach (var cluster in clusters)
                {
                    if (cluster.Count == 1)
                    {
                        Issue issue = new Issue(this, this.DefaultSeverity.Value)
                        {
                            Context     = new TableContext(cluster[0]),
                            Name        = "Table Island",
                            Description = new Description("Table {0} does not reference anything and is not referenced by anything", cluster[0]),
                        };
                        issueCollector.ReportIssue(issue);
                    }
                    else
                    {
                        if (cluster.Count > schema.Tables.Count * this.MaxFractionTables.Value / 100f || schema.Tables.Count > this.MaxTableIslandCount.Value)
                        {
                            continue;
                        }

                        string tableList = String.Join(", ", cluster.Select(c => c.TableName));
                        if (tableList.Length > 20)
                        {
                            tableList = tableList.Substring(0, 20) + "...";
                        }

                        Issue issue = new Issue(this, LargeTableIslandSeverity.Value)
                        {
                            Context             = IssueContext.Create(cluster),
                            Name                = "Table Island",
                            Description         = new Description("There is a table island containing {0} tables: {1}", cluster.Count, tableList),
                            ExtendedDescription = new Description("Tables: {0}", cluster),
                        };
                        issueCollector.ReportIssue(issue);
                    }
                }
            }
        }
        public override void Execute(Database database, IIssueCollector issueCollector, IProviderCollection providers)
        {
            var ignoredNames = GetIgnoredNames(this.IgnoreName.Value).ToDictionary(n => n);

            var nameGroups = from col in database.Columns
                             where !ignoredNames.ContainsKey(col.ColumnName.ToLower())
                             group col by col.ColumnName into colgroup
                             select colgroup;

            foreach (var columnGroup in nameGroups)
            {
                var datatypeGroups = (from column in columnGroup
                                      group column by new { column.DataType, column.CharacterMaxLength, column.NumericPrecision, column.NumericScale } into datatypeGroup
                                      orderby datatypeGroup.Count() descending
                                      select datatypeGroup).ToArray();

                if (datatypeGroups.Length > 1)
                {
                    var totalCount = datatypeGroups.Sum(g => g.Count());

                    var issue = new Issue(this, this.DefaultSeverity.Value);
                    issue.Name = this.Name;

                    var context = from dtgroup in datatypeGroups
                                  where dtgroup.Count() <= totalCount / 2
                                  select dtgroup;

                    var contextColumns = context.SelectMany(group => group).ToArray();
                    issue.Context = IssueContext.Create(contextColumns);

                    var tbl = new DataTable();
                    tbl.Columns.Add("Data Type");
                    tbl.Columns.Add("Table", typeof(IEnumerable <Table>));

                    var sb = new StringBuilder("Different data types for columns named '" + columnGroup.Key + "'. Data types: ");

                    foreach (var datatypeGroup in datatypeGroups)
                    {
                        var    datatype = datatypeGroup.Key;
                        var    count    = datatypeGroup.Count();
                        string typeDescription;
                        if (datatype.NumericPrecision > 0 && datatype.NumericScale >= 0)
                        {
                            typeDescription = string.Format("{0}({1}, {2})", datatype.DataType, datatype.NumericPrecision, datatype.NumericScale);
                        }
                        else if (datatype.CharacterMaxLength > 0)
                        {
                            typeDescription = string.Format("{0}({1})", datatype.DataType, datatype.CharacterMaxLength);
                        }
                        else
                        {
                            typeDescription = datatype.DataType.ToString();
                        }
                        sb.AppendFormat("{0} ", typeDescription);

                        var tables = (from col in datatypeGroup
                                      select col.Table);
                        tbl.Rows.Add(typeDescription, tables);
                    }
                    issue.Description = new Description(sb.ToString());

                    issue.ExtendedDescription = new Description(string.Format("Data types for '{0}': ", columnGroup.Key) + "{0}", tbl);
                    issueCollector.ReportIssue(issue);
                }
            }
        }
Esempio n. 12
0
 public IndexModel(IssueContext dbContext)
 {
     _db = dbContext;
 }
Esempio n. 13
0
        private Issue GetIssue(DatabaseID context, Match match)
        {
            var   identifierName = String.Empty;
            var   dbObject       = String.Empty;
            Table table          = null;

            if (context is Schema)
            {
                var sid = context as Schema;
                identifierName = sid.SchemaName;
                dbObject       = "schema";
            }
            else if (context is Table)
            {
                var sid = context as Table;
                identifierName = sid.TableName;
                dbObject       = "table";
            }
            else if (context is Column)
            {
                var sid = context as Column;
                identifierName = sid.ColumnName;
                dbObject       = "column";
                table          = sid.Table;
            }
            else if (context is PrimaryKey)
            {
                var sid = context as PrimaryKey;
                identifierName = sid.PrimaryKeyName;
                dbObject       = "primary-key";
                table          = sid.Table;
            }
            else if (context is ForeignKey)
            {
                var sid = context as ForeignKey;
                identifierName = sid.ForeignKeyName;
                dbObject       = "foreign-key";
            }
            else if (context is Index)
            {
                var sid = context as Index;
                identifierName = sid.IndexName;
                dbObject       = "index";
                table          = sid.Table;
            }
            var issue = new Issue(this, this.DefaultSeverity.Value);

            issue.Context = IssueContext.Create(context);
            issue.Name    = "Use of Special Character in Identifier";

            if (table != null)
            {
                issue.Description = new Description("The special character '{0}' is used in the {2} name: '{3}' in table in table '{1}'", match.Value, table, dbObject, identifierName);
            }
            else
            {
                issue.Description = new Description("The special character '{0}' is used in the {1} name: '{2}'", match.Value, dbObject, identifierName);
            }

            return(issue);
        }
Esempio n. 14
0
 public IssuesController(IssueContext context)
 {
     _context = context;
 }