Beispiel #1
0
        public void AddResult(DataTable table, string crosstab, List <DescriptiveStatistics> statsList, GridCells gridCells)
        {
            freqResultsDataTableList.Add(table);
            this.FreqResultsDescriptiveStatistics = statsList;
            Array.Resize(ref datatableBagArray, datatableBagArray.Length + 1);
            DatatableBag bag = new DatatableBag(table, crosstab, statsList, gridCells);

            datatableBagArray[datatableBagArray.Length - 1] = bag;
        }
Beispiel #2
0
 /// <summary>
 /// Converts the data table.
 /// </summary>
 /// <param name="datatableBag">The datatable bag.</param>
 private void ConvertDataTable(DatatableBag datatableBag, DataTable dt)
 {
     //foreach (DataRow row in dtDataSources.Rows)
     //{
     //    foreach (DataColumn col in dtDataSources.Columns)
     //    {
     //        datatableBag.FieldsList = new List<MyString>();
     //          datatableBag.FieldsList.Add(new MyString(row[col.ColumnName].ToString()));
     //    }
     //      datatableBag.RecordList.Add(fieldsList);
     //}
 }
Beispiel #3
0
        /// <summary>
        /// Gets the line list.
        /// </summary>
        /// <param name="filterList">The filter list.</param>
        /// <param name="gp">The gp.</param>
        /// <returns></returns>
        public List <DatatableBag> GetLineList(GadgetParameters gadgetParameters,
                                               IEnumerable <EwavDataFilterCondition> ewavDataFilters, List <EwavRule_Base> rules, string filterString = "")
        {
            DashboardHelper dh;

            if (gadgetParameters.UseAdvancedDataFilter)
            {
                dh = new DashboardHelper(gadgetParameters, filterString, rules);
                gadgetParameters.UseAdvancedDataFilter  = true;
                gadgetParameters.AdvancedDataFilterText = filterString;
            }
            else
            {
                dh = new DashboardHelper(gadgetParameters, ewavDataFilters, rules);
            }

            List <DatatableBag> datatableBagList = new List <DatatableBag>();

            List <DataTable> dtList = dh.GenerateLineList(gadgetParameters, rules);

            foreach (DataTable dt in dtList)
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    int       numberOfRows = Convert.ToInt32(gadgetParameters.InputVariableList["maxrows"].ToString());
                    DataTable newDt        = dt.AsEnumerable().Take(numberOfRows).ToList().CopyToDataTable();

                    newDt.TableName = dt.TableName;
                    DatatableBag d = new DatatableBag(newDt, "");


                    datatableBagList.Add(d);
                }
            }


            return(datatableBagList);
        }
Beispiel #4
0
 public void PortClassToClient441(DatatableBag dtc)
 {
 }
Beispiel #5
0
        public DatatableBag GetEpiCurveData(GadgetParameters gadgetParameters,
                                            List <EwavDataFilterCondition> ewavDataFilters, List <EwavRule_Base> rules, string filterString, bool byEpiWeek, string dateVar, string caseStatusVar)
        {
            DataTable    data = new DataTable();
            DatatableBag dtb  = new DatatableBag();

            int recordCount = 0;

            if (gadgetParameters.UseAdvancedDataFilter)
            {
                dh = new DashboardHelper(gadgetParameters, filterString, rules);
                gadgetParameters.UseAdvancedDataFilter  = true;
                gadgetParameters.AdvancedDataFilterText = filterString;
            }
            else
            {
                if (gadgetParameters.GadgetFilters != null)
                {
                    ewavDataFilters.AddRange(gadgetParameters.GadgetFilters);
                }

                dh = new DashboardHelper(gadgetParameters, ewavDataFilters, rules);
            }

            if (byEpiWeek)
            {
                decimal?minWeek = null;
                decimal?maxWeek = null;

                dh.FindUpperLowerNumericValues(dateVar, ref minWeek, ref maxWeek);
                if (minWeek.HasValue && maxWeek.HasValue)
                {
                    // override min and max values if the user set custom start and end points for the x-axis
                    if (gadgetParameters.InputVariableList.ContainsKey("xaxisstart"))
                    {
                        minWeek = decimal.Parse(gadgetParameters.InputVariableList["xaxisstart"]);
                    }
                    if (gadgetParameters.InputVariableList.ContainsKey("xaxisend"))
                    {
                        maxWeek = decimal.Parse(gadgetParameters.InputVariableList["xaxisend"]);
                    }

                    if (string.IsNullOrEmpty(caseStatusVar))
                    {
                        gadgetParameters.CrosstabVariableName = "_default_";
                        data = dh.GenerateEpiCurveTable(gadgetParameters, minWeek.Value, maxWeek.Value);
                    }
                    else
                    {
                        data = dh.GenerateEpiCurveTable(gadgetParameters, minWeek.Value, maxWeek.Value);
                    }

                    recordCount = Convert.ToInt16(data.Compute("Sum(totals)", ""));

                    if (data != null && data.Rows.Count > 0)
                    {
                        if (string.IsNullOrEmpty(caseStatusVar))
                        {
                            data = Pivot(data, dateVar, "_default_", "totals");
                        }
                        else
                        {
                            data = Pivot(data, dateVar, caseStatusVar, "totals");
                        }
                    }
                    decimal currentWeek = minWeek.Value;
                    while (currentWeek <= maxWeek.Value)
                    {
                        if (data.Select("[" + dateVar + "] = '" + currentWeek.ToString() + "'").Count() == 0)
                        {
                            DataRow row = data.NewRow();
                            row[0] = currentWeek;
                            data.Rows.Add(row);
                        }
                        currentWeek = currentWeek + 1;
                    }
                }
            }
            else
            {
                string dateInterval = gadgetParameters.InputVariableList["dateinterval"];

                DateTime?minDate = null;
                DateTime?maxDate = null;

                dh.FindUpperLowerDateValues(dateVar, ref minDate, ref maxDate, gadgetParameters);
                if (minDate.HasValue && maxDate.HasValue)
                {
                    if (gadgetParameters.InputVariableList.ContainsKey("xaxisstart"))
                    {
                        DateTime dt;
                        bool     success = DateTime.TryParse(gadgetParameters.InputVariableList["xaxisstart"], out dt);
                        if (success)
                        {
                            minDate = dt;
                        }
                    }
                    if (gadgetParameters.InputVariableList.ContainsKey("xaxisend"))
                    {
                        DateTime dt;
                        bool     success = DateTime.TryParse(gadgetParameters.InputVariableList["xaxisend"], out dt);
                        if (success)
                        {
                            maxDate = dt;
                        }
                    }

                    if (string.IsNullOrEmpty(caseStatusVar))
                    {
                        gadgetParameters.CrosstabVariableName = "_default_";
                    }

                    data = dh.GenerateEpiCurveTable(gadgetParameters, (DateTime)minDate, (DateTime)maxDate);

                    recordCount = Convert.ToInt16(data.Compute("Sum(totals)", ""));

                    if (data != null && data.Rows.Count > 0)
                    {
                        if (string.IsNullOrEmpty(caseStatusVar))
                        {
                            data = Pivot(data, dateVar, "_default_", "totals");
                        }
                        else
                        {
                            data = Pivot(data, dateVar, caseStatusVar, "totals");
                        }
                    }
                    else
                    {
                        return(new DatatableBag());
                    }
                    DateTime currentDate = minDate.Value;
                    while (currentDate <= maxDate.Value)
                    {
                        //if (IsCancelled())
                        //{
                        //    data = null;
                        //    return data;
                        //}

                        if (data.Select("[" + dateVar + "] = '" + currentDate.ToString() + "'").Length == 0)
                        {
                            DataRow row = data.NewRow();
                            row[0] = currentDate;
                            data.Rows.Add(row);
                        }

                        //if (dashboardHelper.IsUsingEpiProject && View.Fields.Contains(dateVar) && View.Fields[dateVar] is DateTimeField && !(View.Fields[dateVar] is DateField) && !(View.Fields[dateVar] is TimeField))
                        if (dateInterval.ToLower().Equals("hours"))
                        {
                            currentDate = currentDate.AddHours(1);
                        }
                        else if (dateInterval.ToLower().Equals("days"))
                        {
                            currentDate = currentDate.AddDays(1);
                        }
                        else if (dateInterval.ToLower().Equals("months"))
                        {
                            currentDate = currentDate.AddMonths(1);
                        }
                        else if (dateInterval.ToLower().Equals("years"))
                        {
                            currentDate = currentDate.AddMonths(1);
                        }
                    }
                }
            }

            if (data == null || data.Columns.Count == 0)
            {
                return(null);
            }



            data.DefaultView.Sort = "[" + data.Columns[0].ColumnName + "]";
            DataView  dv    = data.DefaultView;
            DataTable newDT = dv.ToTable();

            DatatableBag returnedTable = new DatatableBag(newDT, "");

            returnedTable.ExtraInfo = new List <DictionaryDTO>();
            returnedTable.ExtraInfo.Add(new DictionaryDTO()
            {
                Key = new MyString("RecordCount"), Value = new MyString(recordCount.ToString())
            });

            return(returnedTable);

            //  return dtb.ToDatatableBag(newDT);      //  .Select("",
            //    "[" + data.Columns[0].ColumnName + "]"));
        }