public static FilteredClaimsTable GetUpcomingExpiringClaimsTable(DataTable fullTable, int daysInFutureToCheckForExpiry = 30) { DateTime startOfDateRange = DateTime.Now; DateTime endOfDateRange = DateTime.Now.AddDays(daysInFutureToCheckForExpiry); DataTable upcomingExpiringClaimsTable = Filter(fullTable, TableType.EXPIRY_DATE, startOfDateRange, endOfDateRange); //Console.WriteLine("Upcoming claim will expire on: " + finalDT); FilteredClaimsTable table = new FilteredClaimsTable(TableType.UPCOMING_EXPIRING_CLAIMS_TABLE, daysInFutureToCheckForExpiry, upcomingExpiringClaimsTable); Console.WriteLine("\nNumber of claims that will expire in next " + Convert.ToString(daysInFutureToCheckForExpiry) + " days is: " + Convert.ToString(upcomingExpiringClaimsTable.Rows.Count.ToString())); return(table); }
public static FilteredClaimsTable GetNewClaimsTable(DataTable fullTable, int daysInPastToCheckForNewClaims = 30) //default is 30 { DateTime startOfDateRange = DateTime.Now.AddDays(-daysInPastToCheckForNewClaims); DateTime endOfDateRange = DateTime.Now; DataTable newClaimsTable = Filter(fullTable, TableType.STAKE_DATE, startOfDateRange, endOfDateRange); //Console.WriteLine("Recent claim was staked on: " + finalDT); FilteredClaimsTable table = new FilteredClaimsTable(TableType.NEW_CLAIMS_TABLE, daysInPastToCheckForNewClaims, newClaimsTable); Console.WriteLine("\nNumber of new claims staked in last " + Convert.ToString(daysInPastToCheckForNewClaims) + " days is: " + newClaimsTable.Rows.Count); return(table); }
public static FilteredClaimsTable GetPastExpiredClaimsTable(DataTable fullTable, int daysInPastToCheckForExpiredClaims = 30) { DateTime startOfDateRange = DateTime.Now.AddDays(-daysInPastToCheckForExpiredClaims); DateTime endOfDateRange = DateTime.Now; DataTable pastExpiredClaimsTable = Filter(fullTable, TableType.EXPIRY_DATE, startOfDateRange, endOfDateRange); //Console.WriteLine("Claim was recently expired on: " + finalDT); FilteredClaimsTable table = new FilteredClaimsTable(TableType.EXPIRED_CLAIMS_TABLE, daysInPastToCheckForExpiredClaims, pastExpiredClaimsTable); Console.WriteLine("\nNumber of claims that expired in last " + Convert.ToString(daysInPastToCheckForExpiredClaims) + " days is: " + Convert.ToString(pastExpiredClaimsTable.Rows.Count)); return(table); }
private static void SortByDateAndLabel(FilteredClaimsTable table) { //DataView view = new DataView(table.DataTable); DataView view = table.DataTable.DefaultView; string sortingDateColumn = table.TableType.DefiningDateColumn; string combinedSortingColumns = String.Join(", ", sortingDateColumn, TableType.LABEL); //Console.WriteLine("combined sorting columns: " + combinedSortingColumns); //Console.ReadLine(); view.Sort = combinedSortingColumns; //Console.WriteLine("view.sort is: " + view.Sort); //Console.ReadLine(); //table.DataTable = view.ToTable(); //SET table.DataTable AT THE END OF METHOD INSTEAD //////////////////////////////////////////// table.DataTable = view.ToTable(); //DataTable fullTableToSortByLabel = view.ToTable(); //using this, going to break into small subtables which will then be sorted by views. //now it's sorted by date, but still need to sort by label within this: //DataView view2 = fullTableToSortByLabel.DefaultView; //IS this THE SAME AS VIEW? GET RID OF REDUNDANCIES // ///TEST:::::::::::::::::::::: // DataRow row1 = fullTableToSortByLabel.Rows[1]; //or 2 cuz of headers? // //DateTime currentDate = row1.Field<DateTime>(sortingDateColumn); // DataTable subTableToSortByLabel = new DataTable(); //need this . // DataRow headers = fullTableToSortByLabel.Rows[0]; //ARE THESE THE HEADERS? OR IS IT 1???????????? // //foreach (DataColumn dc in fullTableToSortByLabel) // //{ // // subTableToSortByLabel.Columns.Add(dc.ColumnName, dc.DataType); // //} // //subTableToSortByLabel.Columns. = fullTableToSortByLabel.Columns.; // subTableToSortByLabel.Rows.Add(headers.ItemArray); // subTableToSortByLabel.Rows.Add(row1.ItemArray); // //the 2 below lines didnt' work, replacing with above 2 lines // //subTableToSortByLabel.Rows.Add(headers); //set the headers // //subTableToSortByLabel.Rows.Add(row1); // DataTable masterSortedTable = new DataTable(); // masterSortedTable.Rows.Add(headers); //set the headers // for (int i = 2; i <= fullTableToSortByLabel.Rows.Count; i++) //(DataRow row in table.DataTable.Rows) //start at 3 cuz of headers? // { // //need a subset of view2 // DataRow currentRow = fullTableToSortByLabel.Rows[i]; // DataRow prevRow = fullTableToSortByLabel.Rows[i-1]; // //looking at specific row i now: // if (currentRow.Field<DateTime>(sortingDateColumn) == prevRow.Field<DateTime>(sortingDateColumn)) //TRYING DATETIME BUT MIGHT NEED TO CHANGE BACK to string // { // //then add the row to the current subtable // subTableToSortByLabel.Rows.Add(currentRow); // } // else // { // //cement the subtable up to this point as it's own view, sort, and then make a new datatable. // DataView subview = subTableToSortByLabel.DefaultView; //this is a temporary view, and that's fine. it's cemented in the table which we create below, subSortedTable. // subview.Sort = "LABEL"; // DataTable subSortedTable = subview.ToTable(); // //now add subSortedTable to the master sorted table. // for (int j = 1; j <= subSortedTable.Rows.Count; j++) // { // masterSortedTable.Rows.Add(subSortedTable.Rows[j]); //this contains all rows, sorted by label. // } // //now also need to begin the next datatable: // subTableToSortByLabel.Clear(); //THIS SHOULD KEEP THE HEADERS, BUT DOUBLECHECK!!! // subTableToSortByLabel.Rows.Add(currentRow); // } // } // Console.WriteLine("length of master table: " + masterSortedTable.Rows.Count.ToString()); // Console.ReadLine(); // // // Console.WriteLine("\ntest: the name of this table's DataTable is: " + table.TableType.Name); // Console.WriteLine("\n and the defining column to sort by is: " + table.TableType.DefiningDateColumn); // Console.ReadLine(); // //FINALLY AT END OF METHOD: // table.DataTable = masterSortedTable; // //each TableType has a defining column that it gets filtered by and sorted by afterwards // //workSheet.Sort(table.TableType.DefiningDateColumn); }