public string ToXML(WFReport.Metadata.DataBase db, string metadatapath) { string xml = XML_TEMPLATE; xml = xml.Replace("%META_FILENAME%", metadatapath); xml = xml.Replace("%DB_NAME%", db.Name); xml = xml.Replace("%R_TABLE%", this.rTable.Name); xml = xml.Replace("%R_COLUMN%", this.rColumn.Name); xml = xml.Replace("%R_GROUP%", string.IsNullOrWhiteSpace(this.rGroup) ? "" : ("\n " + "<group>" + this.rGroup + "</group>")); xml = xml.Replace("%C_TABLE%", this.cTable.Name); xml = xml.Replace("%C_COLUMN%", this.cColumn.Name); xml = xml.Replace("%C_GROUP%", string.IsNullOrWhiteSpace(this.cGroup) ? "" : ("\n " + "<group>" + this.cGroup + "</group>")); xml = xml.Replace("%AGGREGATE_NAME%", this.aColumn.Name); string rests = ""; foreach (var i in this.restrictions) rests += i.ToXML() + "\n"; xml = xml.Replace("%RESTRICTIONS%", rests); return xml; }
private void SaveReportToFile(WFReport.DataReport.Report report, string filename) { try { string data = currentReport.ToXML(currentDB, currentPathMetadata); StreamWriter file = new StreamWriter(filename); file.WriteLine(data); file.Close(); currentPathReport = filename; } catch(Exception e) { MessageBox.Show("Error while saving the file \"" + filename + "\": " + e.Message, "File cannot be saved", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private string ConvertGroupBy(WFReport.Metadata.Table table, WFReport.Metadata.Column column, string group) { if (!String.IsNullOrWhiteSpace(group) && column.Type == Metadata.ColumnType.DateColumn) { switch (group) { case "Month": return "strftime(\"%Y-%m\", " + table.Name + "." + column.Name + ")"; case "Year": return "strftime(\"%Y\", " + table.Name + "." + column.Name + ")"; case "Day": default: return "strftime(\"%Y-%m-%d\", " + table.Name + "." + column.Name + ")"; // Sqlite plugin doesn't recognize the unformatted dates. // So default action is changed to be the same as for "day" //default: // return table.Name + "." + column.Name; } } return table.Name + "." + column.Name; }
string ConvertRestrictionToWhereString(WFReport.DataReport.Restriction rest) { if (rest is WFReport.DataReport.FromToRestriction) { WFReport.DataReport.FromToRestriction fromto = rest as WFReport.DataReport.FromToRestriction; return "(" + fromto.table.Name + "." + fromto.column.Name + " >= '" + fromto.fromValue + "' AND " + fromto.table.Name + "." + fromto.column.Name + " <= '" + fromto.toValue + "')"; } if (rest is WFReport.DataReport.OptionsRestriction) { WFReport.DataReport.OptionsRestriction opts = rest as WFReport.DataReport.OptionsRestriction; string res = ""; foreach (var i in opts.options) res += " OR " + opts.table.Name + "." + opts.column.Name + " = '" + i + "'"; return "(" + res.Substring(4) + ")"; } return "TRUE"; }
private void UIProcessGroupBy(WFReport.Metadata.Column col, ComboBox combo, string group) { if (col != null && col.Type == Metadata.ColumnType.DateColumn) { combo.Enabled = true; // day = 1; month = 2; year = 3; another = 0 switch (group) { case "Month": combo.SelectedItem = combo.Items[2]; break; case "Year": combo.SelectedItem = combo.Items[3]; break; case "Day": combo.SelectedItem = combo.Items[1]; break; default: combo.SelectedItem = combo.Items[0]; break; } } else { combo.Enabled = false; combo.SelectedItem = combo.Items[0]; } }