public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { string raw = value as string; try { string[] dayCodes = raw.Split(new char[] { '-' }, 2); DayCodeRange range = new DayCodeRange(Int32.Parse(dayCodes[0]), Int32.Parse(dayCodes[1])); return(range); } catch (Exception ex) { throw new Exception("Invalid range: " + raw, ex); } }
private string GetSQL(string Sql, string HavingString, int AccountID, DayCodeRange DaysCode, DataGrouping DataGrouping, MeasureSort[] DataSort, int Top, string IdsList, Mode mode) { string OrderBy = null, TableName = null, AggregateFunctions = null, ltop = null, Selectfields = null, Join = null, GroupBy = null, AdditionalWhere = null, BetweenDatesSql = null, AdditionalWhere2 = null; TableName = "Dwh_Fact_PPC_Campaigns_ProcessedMeasures"; if (mode == Mode.Simple && IdsList == null) { OrderBy = GetOrderBy(DataSort); } BetweenDatesSql = " AND a.Day_ID BETWEEN " + DaysCode.From + " AND " + DaysCode.To; if (mode == Mode.Simple) { ltop = Top <= 0 ? "" : "TOP " + Top.ToString() + " "; } AggregateFunctions = Sql; GetSqlOptions(out Selectfields, out Join, out GroupBy, out AdditionalWhere, out AdditionalWhere2, DataGrouping, IdsList); Sql = "SELECT " + ltop + Selectfields + AggregateFunctions + " FROM " + TableName + " a inner JOIN " + Join + " WHERE a.Account_ID = " + AccountID + AdditionalWhere + AdditionalWhere2 + BetweenDatesSql + " GROUP BY " + GroupBy + " HAVING " + HavingString + OrderBy; return(Sql); }