private static void Print(Dictionary <string, string> d, string cgi, string header) { DataTable t = new DataTable(); t.Columns.Add("name"); t.Columns.Add("example"); if (CgiUtility.IsRemoteRequest()) { cgi += ".pl?"; } else { cgi += "?"; } foreach (var item in d) { var example = "<a href=\"" + cgi + item.Value + "\">" + item.Value + "</a>"; t.Rows.Add(item.Key, example); } var s = DataTableOutput.ToHTML(t, true, header); Console.WriteLine(s); }
private string PrintHtmlReport(TimeRange r, string siteID, string parameter) { var s = db.GetSeriesFromTableName("daily_" + siteID + "_" + parameter); if (s == null) { return("Error: no data found: " + siteID + "/" + parameter); } var startYear = r.StartDate.Year; var endYear = r.EndDate.Year; DateTime t1 = r.StartDate; StringBuilder sb = new StringBuilder(); for (int i = startYear; i < endYear; i++) { s.Read(t1, t1.AddMonths(12)); DataTable wyTable = Usgs.WaterYearTable(s); var header = GetHeader(i + 1, siteID, parameter); var html = DataTableOutput.ToHTML(wyTable, true, "", header); sb.Append(html); sb.AppendLine(); t1 = t1.AddMonths(12); } return(sb.ToString()); }
public void ADLogin() { var psql = GetPGServer(); var tbl = psql.Table("test", "show search_path"); DataTableOutput.Write(tbl, FileUtility.GetTempFileName(".csv"), false, true); }
/// <summary> /// /// </summary> /// <param name="fullRatingTable">table with two columns (gh,q)</param> /// <param name="title"></param> /// <param name="htmlFile"></param> public static void WriteHtmlFile(DataTable fullRatingTable, string title, string htmlFile) { var tbl = ConvertToMultiColumn(fullRatingTable); var s = DataTableOutput.ToHTML(tbl, FormatCell, true, title); File.WriteAllText(htmlFile, s); }
public DataTableOutput <SalaryTabulator> GetSalarysTabulators(DataTableInput input) { var output = new DataTableOutput <SalaryTabulator>(); var searchBy = (input.search != null) ? input.search.value : null; var take = input.length; var skip = input.start; var recordsFiltered = 0; string sortBy = ""; bool sortDir = true; if (input.order != null) { // in this example we just default sort on the 1st column sortBy = input.columns[input.order[0].column].data; sortDir = input.order[0].dir.ToLower() == "asc"; } IEnumerable <SalaryTabulator> result = repository.SortOrderAndPaging(searchBy, take, skip, sortBy, sortDir, out recordsFiltered); if (result == null) { output.data = new List <SalaryTabulator>(); } output.data = result.ToList(); output.recordsFiltered = recordsFiltered; output.recordsTotal = repository.Count(x => 1 == 1); return(output); }
private void buttonGenerate_Click(object sender, EventArgs e) { FolderBrowserDialog dlg = new FolderBrowserDialog(); var dir = ""; if (!preview) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { dir = dlg.SelectedPath; } else { return; } } GenerateSounds(dir, tbl); // id, text, filename if (checkBoxSite.Checked) { var sc = m_svr.Table("sitecatalog"); AlarmDataSet.alarm_scriptsDataTable scripts = new AlarmDataSet.alarm_scriptsDataTable(); for (int i = 0; i < sc.Rows.Count; i++) { var r = sc.Rows[i]; var fn = r["siteid"].ToString() + "_site.wav"; scripts.Addalarm_scriptsRow(r["description"].ToString(), fn); } GenerateSounds(dir, scripts); } if (checkBoxParameter.Checked) { var sc = m_svr.Table("parametercatalog"); AlarmDataSet.alarm_scriptsDataTable scripts = new AlarmDataSet.alarm_scriptsDataTable(); for (int i = 0; i < sc.Rows.Count; i++) { var r = sc.Rows[i]; var fn = r["id"].ToString() + "_parameter.wav"; scripts.Addalarm_scriptsRow(r["name"].ToString(), fn); } GenerateSounds(dir, scripts); } if (preview) { tblPreview.Columns.Remove("id"); var s = DataTableOutput.ToHTML(tblPreview); var fn = FileUtility.GetTempFileName(".html"); File.WriteAllText(fn, s); System.Diagnostics.Process.Start(fn); } }
private void buttonSaveCsv_Click(object sender, EventArgs e) { csv.Rows[rowIndex]["cbtt"] = this.textBoxcbtt.Text; csv.Rows[rowIndex]["pcode"] = this.textBoxPcode.Text; csv.Rows[rowIndex]["usgs"] = this.textBoxUsgs.Text; csv.Rows[rowIndex]["owrd"] = this.textBoxOwrd.Text; csv.Rows[rowIndex]["idwr"] = this.textBoxIdwr.Text; csv.Rows[rowIndex]["notes"] = this.textBoxNotes.Text; csv.Rows[rowIndex]["idahopower"] = this.textBoxIdaCorp.Text; csv.Rows[rowIndex]["nrcs"] = this.textBoxSnotel.Text; csv.Rows[rowIndex]["Updated"] = this.textBoxLastUpdate.Text; DataTableOutput.Write(this.csv, labelFileName.Text, false); }
private static dynamic FormatDataTable(string fmt, DataTable sites) { if (fmt == "json") { return(DataTableOutput.ToJson(sites) + " " + fmt); } else if (fmt == "xml") { var fn = FileUtility.GetTempFileName(".xml"); sites.WriteXml(fn, System.Data.XmlWriteMode.WriteSchema); return(File.ReadAllText(fn)); } else if (fmt == "csv") { var fn = FileUtility.GetTempFileName(".csv"); CsvFile.WriteToCSV(sites, fn, false); return(File.ReadAllText(fn)); } else if (fmt == "chart") { var fn = FileUtility.GetTempFileName(".html"); var chartData = sites; chartData.Columns.Remove("flag"); DyGraphWriter.writeHTML_dyGraphs(chartData, fn); return(File.ReadAllText(fn)); } else if (fmt == "waterml2") { var fn = FileUtility.GetTempFileName(".wml"); var data = sites; data.Columns.Remove("flag"); WaterMLWriter.writeWaterML2Data(data, fn); return(File.ReadAllText(fn)); } else if (fmt == "hydrojson") { var fn = FileUtility.GetTempFileName(".json"); var data = sites; data.Columns.Remove("flag"); HydroJsonWriter.writeHydroJsonData(data, fn); return(File.ReadAllText(fn)); } else // html { return(DataTableOutput.ToHTML(sites, FormatSiteCell)); } }
private void PrintHtmlReport(TimeRange r, string siteID, string parameter) { Console.Write("Content-type: text/html\n\n"); var s = new HydrometDailySeries(siteID, parameter, HydrometHost.PNLinux); var startYear = r.StartDate.Year; var endYear = r.EndDate.Year; DateTime t1 = r.StartDate; for (int i = startYear; i < endYear; i++) { s.Read(t1, t1.AddMonths(12)); DataTable wyTable = Usgs.WaterYearTable(s); var header = GetHeader(i + 1, siteID, parameter); var html = DataTableOutput.ToHTML(wyTable, true, "", header); Console.WriteLine(html); t1 = t1.AddMonths(12); } }
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { Cursor = Cursors.WaitCursor; try { if (e.Button == toolBarButtonCopy) {// copy to clipboard. if (dataGridView1.SelectedCells.Count > 0) { dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; Clipboard.SetDataObject( this.dataGridView1.GetClipboardContent()); } } else if (e.Button == toolBarButtonSave) { if (m_seriesList.ReadOnly || m_seriesList.Count > 1) { return; } m_seriesList.Save(); } else if (e.Button == toolBarButtonExcel) { string tmpFilename = FileUtility.GetTempFileName(".csv"); //DataTableOutput.Write(this.table, tmpFilename, false); DataTableOutput.Write(this.table, tmpFilename, false, false); System.Diagnostics.Process.Start(tmpFilename); } else if (e.Button == toolBarButtonPaste) { this.pasteToolStripMenuItem_Click(this, EventArgs.Empty); } } catch (Exception ex) { MessageBox.Show(ex.Message); } Cursor = Cursors.Default; }
public JsonResult CustomServerSideSearchAction(DataTableVM <PaymentSearch> model) { DataTableOutput <Payment> payments = new DataTableOutput <Payment>(); DataTableOutput <PaymentDTO> paymentsDTO = new DataTableOutput <PaymentDTO>(); try { payments = _paymentService.GetByFilters(model.Filters.Employee ?? null, model.Filters.DepartamentId ?? null, model.dataTablesInput ?? null); paymentsDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <PaymentDTO> >(payments); } catch (Exception e) { sb.Clear(); sb.Append("An error has occurred when it try to retrieve payments"); SeriLogHelper.WriteError(e, sb.ToString()); return(new JsonHttpStatusResult(e.Message, HttpStatusCode.BadRequest)); } return(Json(paymentsDTO, JsonRequestBehavior.DenyGet)); }
public JsonResult getAll(DataTableInput input) { DataTableOutput <SalaryTabulator> salaryTabulators = new DataTableOutput <SalaryTabulator>(); DataTableOutput <SalaryTabulatorDTO> salaryTabulatorsDTO = new DataTableOutput <SalaryTabulatorDTO>(); try { salaryTabulators = salaryTabuladorService.GetSalarysTabulators(input); salaryTabulatorsDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <SalaryTabulatorDTO> >(salaryTabulators); } catch (Exception e) { sb.Clear(); sb.Append("An error has ocurred when it try to retrieve Salary Tabulators"); SeriLogHelper.WriteError(e, sb.ToString()); return(new JsonHttpStatusResult(e.Message, HttpStatusCode.InternalServerError)); } return(Json(salaryTabulatorsDTO, JsonRequestBehavior.DenyGet)); }
internal void Run() { Console.Write("Content-type: text/html\n\n"); if (query == "") { query = HydrometWebUtility.GetQuery(); } var collection = HttpUtility.ParseQueryString(query); TimeRange r = GetDateRange(collection); var siteID = ""; if (collection.AllKeys.Contains("site")) { siteID = collection["site"]; } var parameter = ""; if (collection.AllKeys.Contains("parameter")) { parameter = collection["parameter"]; } var s = new HydrometDailySeries(siteID, parameter); var startYear = r.StartDate.Year; var endYear = r.EndDate.Year; DateTime t1 = r.StartDate; for (int i = startYear; i < endYear; i++) { s.Read(t1, t1.AddMonths(12)); DataTable wyTable = Usgs.WaterYearTable(s); var header = GetHeader(i + 1, siteID, parameter); var html = DataTableOutput.ToHTML(wyTable, true, "", header); Console.WriteLine(html); t1 = t1.AddMonths(12); } }
public void TestDataTypesToString() { var fn = Path.Combine(Globals.TestDataPath, "npoi", "datatypes.xlsx"); NpoiExcel x = new NpoiExcel(fn); var tbl = x.ReadDataTable("Sheet1", true, true); Console.WriteLine(DataTableOutput.ToJson(tbl)); Assert.AreEqual("text entry", tbl.Rows[0][0].ToString()); Assert.AreEqual("1", tbl.Rows[1][0].ToString()); Assert.AreEqual("3.15", tbl.Rows[2][0].ToString()); Assert.AreEqual(Convert.ToDateTime("7/8/2016"), Convert.ToDateTime(tbl.Rows[3][0].ToString())); var d = Convert.ToDouble(tbl.Rows[4][0].ToString()); Assert.AreEqual(Convert.ToDateTime("7/8/2016"), DateTime.FromOADate(d)); Assert.AreEqual(9, Convert.ToInt32(tbl.Rows[5][0].ToString())); }
public JsonResult CustomServerSideSearchAction(DataTableVM <SearchEmployee> model) { DataTableOutput <Employee> employees = new DataTableOutput <Employee>(); DataTableOutput <EmployeeDTO> employeesDTO = new DataTableOutput <EmployeeDTO>(); try { employees = _employeeService.GetByFilters(model.Filters.KeyEmplooye ?? null, model.Filters.Name ?? null, model.Filters.DepartamentId ?? null, model.Filters.SalaryTabulatorId ?? null, model.dataTablesInput ?? null); employeesDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <EmployeeDTO> >(employees); } catch (Exception e) { sb.Clear(); sb.Append("An error has occurred when it try to retrieve employees"); SeriLogHelper.WriteError(e, sb.ToString()); return(new JsonHttpStatusResult(e.Message, HttpStatusCode.BadRequest)); } Debug.Write(JsonConvert.SerializeObject(employeesDTO)); return(Json(employeesDTO, JsonRequestBehavior.DenyGet)); }
public void DatabaseAboveAlarmTest() { var db = GetNewDatabase(); // create database with alarm def var ds = db.Alarms; ds.AddNewAlarmGroup("palisades"); var def_id = ds.alarm_definition.Addalarm_definitionRow(true, "palisades", "pal", "fb", "above 5520", "").id; ds.SaveTable(ds.alarm_definition); var test = db.Server.Table("alarm_definition"); Console.WriteLine("alarm_definition has " + test.Rows.Count + " rows"); ds.alarm_recipient.Addalarm_recipientRow("palisades", 4, "5272", "office", "*****@*****.**"); ds.SaveTable(ds.alarm_recipient); String file = Path.Combine(TestData.DataPath, "alarms", "pal_fb.csv"); TextSeries s = new TextSeries(file); //TO DO .. read flags s.Parameter = "fb"; s.SiteID = "pal"; s.Read(); Console.WriteLine("pal/fb series count = " + s.Count); Assert.IsTrue(s.Count > 500); ds.Check(s); var queue = ds.GetAlarmQueue(def_id);//"pal", "fb"); Console.WriteLine(DataTableOutput.ToHTML(queue)); Assert.AreEqual(1, queue.Rows.Count); }
public DataTableOutput <Employee> GetByFilters(string jobNumber, string name, int?departamentId, int?salaryTabulatorId, DataTableInput input) { var output = new DataTableOutput <Employee>(); var query = repository.GetPredicateByFilters(null, jobNumber, name, "", "", "", null, null, null, null, departamentId, salaryTabulatorId); string sortBy = ""; bool sortDir = true; if (input.order != null) { // in this example we just default sort on the 1st column sortBy = input.columns[input.order[0].column].data; sortDir = input.order[0].dir.ToLower() == "asc"; } IEnumerable <Employee> result = repository.SortOrderAndPaging(query, input.length, input.start, sortBy, sortDir); if (result == null) { output.data = new List <Employee>(); } output.data = result.ToList(); output.recordsFiltered = repository.Count(query); output.recordsTotal = repository.Count(x => 1 == 1); return(output); }
/// <summary> /// Creates Daily Crop Water Use Charts /// </summary> /// <param name="cbtt"></param> /// <param name="t"></param> /// <returns></returns> private static List <string> CreateDailyHTMLReport(string cbtt, DateTime t, CropDatesDataSet.CropDatesRow[] cropRow) { var rval = new List <string>(); //var cropRow = CropDatesDataSet.GetCropFiles(t.Year, cbtt); DataTable heading_tbl = new DataTable(); // Produces Crop Chart heading heading_tbl.Columns.Add("\t" + "ESTIMATED CROP WATER USE " + t.ToString("MMM dd, yyyy") + " " + cbtt + " "); DataTable tbl = new DataTable(); tbl.Columns.Add("Crop"); tbl.Columns.Add("Start Date"); tbl.Columns.Add("ET(IN) " + t.Month.ToString() + "/" + t.AddDays(-4).Day.ToString()); tbl.Columns.Add("ET(IN) " + t.Month.ToString() + "/" + t.AddDays(-3).Day.ToString()); tbl.Columns.Add("ET(IN) " + t.Month.ToString() + "/" + t.AddDays(-2).Day.ToString()); tbl.Columns.Add("ET(IN) " + t.Month.ToString() + "/" + t.AddDays(-1).Day.ToString()); tbl.Columns.Add("Daily Forecast"); tbl.Columns.Add("Cover Date"); tbl.Columns.Add("Termination Date"); tbl.Columns.Add("Sum of ET"); tbl.Columns.Add("7 Day Use"); tbl.Columns.Add("14 Day Use"); var et = new HydrometDailySeries(cbtt, "ETRS", s_host); // Below is the calculation to determine how many days to read back. Set to calculate based on ETr Start Date. var etStartDate = cropRow[0].startdate.DayOfYear; var etTodayDate = t.DayOfYear; int numDaysRead = etTodayDate - etStartDate - 1; et.Read(t.AddDays(-numDaysRead), t.AddDays(-1)); // For-Loop to populate chart for (int i = 0; i < cropRow.Length; i++) { var row = tbl.NewRow(); var cRow = cropRow[i]; row[0] = cRow.cropname; row[1] = cRow.startdate.ToString("MM/dd"); row[2] = CropCurves.ETCropDaily(numDaysRead, 4, et, cRow); row[3] = CropCurves.ETCropDaily(numDaysRead, 3, et, cRow); row[4] = CropCurves.ETCropDaily(numDaysRead, 2, et, cRow); row[5] = CropCurves.ETCropDaily(numDaysRead, 1, et, cRow); // Today's forecast is the average of previous 3 days row[6] = (CropCurves.EtSummation(3, et, cRow, numDaysRead) / 3).ToString("F2"); row[7] = cRow.fullcoverdate.ToString("MM/dd"); row[8] = cRow.terminatedate.ToString("MM/dd"); // Cumulative summation from Crop Start Date to today row[9] = CropCurves.EtSummation(numDaysRead, et, cRow, numDaysRead).ToString("F1"); // 7 and 14 day use row[10] = CropCurves.EtSummation(7, et, cRow, numDaysRead).ToString("F1"); row[11] = CropCurves.EtSummation(14, et, cRow, numDaysRead).ToString("F1"); tbl.Rows.Add(row); } rval.Add(""); rval.Add("<html>"); rval.Add(DataTableOutput.ToHTML(heading_tbl)); rval.Add(DataTableOutput.ToHTML(tbl)); rval.Add("</html>"); return(rval); }
private void PrintHtmlInventory(string siteID, TimeInterval interval, bool ui) { var parms = db.GetParameters(siteID, interval); var desc = db.GetSiteDescription(siteID); WriteLine("<!DOCTYPE html>"); WriteLine("<html>"); DataTable tbl = new DataTable(); tbl.Columns.Add("parameter"); tbl.Columns.Add("available records"); tbl.Columns.Add("description"); int firstYear = DateTime.Now.Year; int minYr = 0, maxYr = 0; int min = 0, max = 0; for (int i = 0; i < parms.Length; i++) { string por = db.GetPeriodOfRecord(siteID, parms[i], interval, out minYr, out maxYr); if (i == 0) { min = minYr; max = maxYr; } if (minYr < min) { min = minYr; } if (maxYr > max) { max = maxYr; } if (ui) { var cb = " <input type=\"checkbox\" name=\"pcode\" value=\"" + parms[i] + "\" id=\"" + parms[i] + "\">" + parms[i].ToUpper(); tbl.Rows.Add(cb, db.GetParameterDescription(parms[i], interval), por); } else { tbl.Rows.Add(parms[i], db.GetParameterDescription(parms[i], interval), por); } } if (ui) { string cgiTag = ""; if (CgiUtility.IsRemoteRequest()) { cgiTag = ".pl"; } if (interval == TimeInterval.Daily) { WriteLine("<form name=\"Form\" action=\"/pn-bin/daily" + cgiTag + "\" method=\"get\" >"); } else { WriteLine("<form name=\"Form\" action=\"/pn-bin/instant" + cgiTag + "\" method=\"get\" >"); } WriteLine("<input name=station type=\"hidden\" value=\"" + siteID + "\">"); WriteLine("<input name=format type=\"hidden\" value=\"html\">"); WriteTimeSelector(siteID, min, max); } var s = DataTableOutput.ToHTML(tbl, false, desc); WriteLine(s); WriteLine("<p><input type=\"submit\" value=\"Retrieve Daily Data\">"); if (ui) { WriteLine("</form>"); } //WriteLine("<\\html>"); }