Ejemplo n.º 1
0
        private static DataTable CreateTransformedUserFlowTable(DumpDataSet ds)
        {
            DataTable table = new DataTable("Table1");


            table.Columns.Add(new DataColumn("ID", typeof(Int32)));
            table.Columns.Add(new DataColumn("Type", typeof(string)));
            table.Columns.Add(new DataColumn("Title", typeof(string)));
            table.Columns.Add(new DataColumn("Tags", typeof(string)));
            table.Columns.Add(new DataColumn("DayEnding", typeof(DateTime)));
            table.Columns.Add(new DataColumn("NewThisDay", typeof(bool)));
            table.Columns.Add(new DataColumn("ActiveThisDay", typeof(bool)));
            table.Columns.Add(new DataColumn("DayEndingState", typeof(string)));

            DumpDataSet.UserStoryFlow_ByDayRow row = ds.UserStoryFlow_ByDay.FirstOrDefault(x => x.ID > 0);

            for (int i = 1; i <= 15; i++)
            {
                string colName1 = string.Format("State{0}Desc", i);
                if (row.IsNull(colName1))
                {
                    continue;
                }
                else
                {
                    string newColName1 = $"Was_{row[colName1]}";
                    string newColName2 = $"Entered_{row[colName1]}";
                    table.Columns.Add(new DataColumn(newColName1, typeof(bool)));
                    table.Columns.Add(new DataColumn(newColName2, typeof(bool)));
                }
            }

            foreach (DataColumn col in table.Columns)
            {
                col.AllowDBNull = true;
            }

            foreach (DumpDataSet.UserStoryFlow_ByDayRow dayRow in ds.UserStoryFlow_ByDay)
            {
                DataRow newRow = table.NewRow();
                newRow["ID"]             = dayRow.ID;
                newRow["Type"]           = dayRow.Type;
                newRow["Title"]          = dayRow.Title;
                newRow["Tags"]           = GetTags(ds, dayRow.ID);
                newRow["DayEnding"]      = dayRow.DayEnding;
                newRow["NewThisDay"]     = dayRow.NewThisDay == 1;
                newRow["ActiveThisDay"]  = dayRow.ActiveThisDay == 1;
                newRow["DayEndingState"] = StaticUtil.CurrentFuzzFile.GetStates(dayRow.DayEndingState).First().Category;

                for (int i = 1; i <= 15; i++)
                {
                    string colName1    = string.Format("State{0}Desc", i);
                    string colNameBase = dayRow[colName1].ToString();

                    if (dayRow.IsNull(colName1))
                    {
                        continue;
                    }
                    else
                    {
                        string wasInCol   = string.Format("State{0}", i);
                        string enteredCol = string.Format("State{0}Entered", i);

                        string newColName1 = $"Was_{colNameBase}";
                        string newColName2 = $"Entered_{colNameBase}";

                        if (!dayRow.IsNull(wasInCol))
                        {
                            newRow[newColName1] = Convert.ToBoolean(dayRow[wasInCol]);
                        }
                        if (!dayRow.IsNull(enteredCol))
                        {
                            newRow[newColName2] = Convert.ToBoolean(dayRow[enteredCol]);
                        }
                    }
                }

                table.Rows.Add(newRow);
            }

            table.AcceptChanges();

            FillInBetweenStates(table);

            return(table);
        }