예제 #1
0
    protected void cmbFields_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        ReportDataType dataType = GetDataType(cmbFields.SelectedValue);

        SetOperator(dataType);
        SetValueBoxes(dataType, (ConditionOperator)int.Parse(cmbOperator.SelectedValue));
    }
        // ------------------------------------ Reports ------------------------------------

        #region Reports

        /// <summary>
        /// Gets the report for <paramref name="reportId"/>. Returns null if no report could be found.
        /// </summary>
        /// <param name="reportId"></param>
        /// <param name="dataType"></param>
        /// <param name="dataFormat"></param>
        /// <returns></returns>
        public async Task <ApiResponse <ReportData> > GetReportAsync(int reportId, ReportDataType dataType = ReportDataType.ReportData, DataFormat dataFormat = DataFormat.Raw)
        {
            var path   = UrlHelper.GetReportByIdPath(reportId, dataType, dataFormat);
            var report = await GetAsync <ReportData>(path);

            return(report);
        }
예제 #3
0
    private ReportDataType GetDataType(string value)
    {
        bool isCustomField = IsValueCustomField(value);
        int  id            = GetValueFieldID(value);

        ReportDataType dataType = ReportDataType.String;

        if (isCustomField)
        {
            CustomField field = (CustomField)CustomFields.GetCustomField(UserSession.LoginUser, id);
            switch (field.FieldType)
            {
            case CustomFieldType.Date:
            case CustomFieldType.Time:
            case CustomFieldType.DateTime:
                dataType = ReportDataType.DateTime;
                break;

            case CustomFieldType.Boolean:
                dataType = ReportDataType.Boolean;
                break;

            case CustomFieldType.Number:
                dataType = ReportDataType.Int;
                break;

            default:
                break;
            }
        }
        else
        {
            ReportTableField field = (ReportTableField)ReportTableFields.GetReportTableField(UserSession.LoginUser, id);

            switch (field.DataType)
            {
            case "bit":
                dataType = ReportDataType.Boolean;
                break;

            case "datetime":
                dataType = ReportDataType.DateTime;
                break;

            case "int":
                dataType = ReportDataType.Int;
                break;

            case "float":
                dataType = ReportDataType.Float;
                break;

            default:
                break;
            }
        }
        return(dataType);
    }
예제 #4
0
    private void LoadAll(int subcategoryID)
    {
        LoadFields(subcategoryID);
        ReportDataType dataType = GetDataType(cmbFields.SelectedValue);

        SetOperator(dataType);
        SetValueBoxes(dataType, (ConditionOperator)int.Parse(cmbOperator.SelectedValue));
        litDisplayText.Text = ReportConditions.ToString();
        SetCaptionConjunction(ReportConditions.MatchAll);
    }
예제 #5
0
    private void SetOperator(ReportDataType dataType)
    {
        cmbOperator.Items.Clear();
        switch (dataType)
        {
        case ReportDataType.String:
            cmbOperator.Items.Add(new RadComboBoxItem("Is equal to", ((int)ConditionOperator.IsEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not equal to", ((int)ConditionOperator.IsNotEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Contains", ((int)ConditionOperator.Contains).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Starts with", ((int)ConditionOperator.StartsWith).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Ends with", ((int)ConditionOperator.EndsWith).ToString()));
            break;

        case ReportDataType.Int:
            cmbOperator.Items.Add(new RadComboBoxItem("Is equal to", ((int)ConditionOperator.IsEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not equal to", ((int)ConditionOperator.IsNotEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is greater than", ((int)ConditionOperator.IsGreaterThan).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is less than", ((int)ConditionOperator.IsLessThan).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is in between", ((int)ConditionOperator.IsInBetween).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not in between", ((int)ConditionOperator.IsNotInBetween).ToString()));
            break;

        case ReportDataType.Float:
            cmbOperator.Items.Add(new RadComboBoxItem("Is equal to", ((int)ConditionOperator.IsEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not equal to", ((int)ConditionOperator.IsNotEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is greater than", ((int)ConditionOperator.IsGreaterThan).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is less than", ((int)ConditionOperator.IsLessThan).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is in between", ((int)ConditionOperator.IsInBetween).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not in between", ((int)ConditionOperator.IsNotInBetween).ToString()));
            break;

        case ReportDataType.DateTime:
            cmbOperator.Items.Add(new RadComboBoxItem("Is equal to", ((int)ConditionOperator.IsEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not equal to", ((int)ConditionOperator.IsNotEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is greater than", ((int)ConditionOperator.IsGreaterThan).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is less than", ((int)ConditionOperator.IsLessThan).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is in between", ((int)ConditionOperator.IsInBetween).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not in between", ((int)ConditionOperator.IsNotInBetween).ToString()));
            break;

        case ReportDataType.Boolean:
            cmbOperator.Items.Add(new RadComboBoxItem("Is equal to", ((int)ConditionOperator.IsEqualTo).ToString()));
            cmbOperator.Items.Add(new RadComboBoxItem("Is not equal to", ((int)ConditionOperator.IsNotEqualTo).ToString()));
            break;

        default:
            break;
        }

        cmbOperator.SelectedIndex = 0;
    }
예제 #6
0
        private static ReportDataAccess GetReportDataAccess(ReportDataType reportDataType)
        {
            ReportDataAccess reportDataAccess = null;

            switch (reportDataType)
            {
            case ReportDataType.Coola:
                reportDataAccess = new CoolaReportDataAccess();
                break;

            default:
                break;
            }

            return(reportDataAccess);
        }
예제 #7
0
    private void SetValueBoxes(ReportDataType dataType, ConditionOperator op)
    {
        textValue.Visible  = false;
        dateValue1.Visible = false;
        dateValue2.Visible = false;
        numValue1.Visible  = false;
        numValue2.Visible  = false;
        cmbBool.Visible    = false;
        lblAnd.Visible     = false;

        switch (dataType)
        {
        case ReportDataType.String:
            textValue.Visible = true;
            break;

        case ReportDataType.Int:
            numValue1.Visible = true;
            numValue2.Visible = op == ConditionOperator.IsNotInBetween || op == ConditionOperator.IsInBetween;
            break;

        case ReportDataType.Float:
            numValue1.Visible = true;
            numValue2.Visible = op == ConditionOperator.IsNotInBetween || op == ConditionOperator.IsInBetween;
            break;

        case ReportDataType.DateTime:
            dateValue1.Visible = true;
            dateValue2.Visible = op == ConditionOperator.IsNotInBetween || op == ConditionOperator.IsInBetween;
            break;

        case ReportDataType.Boolean:
            cmbBool.Visible = true;
            break;

        default:
            break;
        }
        lblAnd.Visible = op == ConditionOperator.IsNotInBetween || op == ConditionOperator.IsInBetween;
    }
예제 #8
0
 protected ReportData(DateTime timestamp, ReportDataType type)
 {
     m_timestamp = timestamp;
     m_type      = type;
 }
예제 #9
0
 /// <summary>
 /// Gets the path for getting a report by its identifier.
 /// </summary>
 /// <param name="reportId"></param>
 /// <param name="dataType"></param>
 /// <param name="dataFormat"></param>
 /// <returns></returns>
 public static string GetReportByIdPath(int reportId, ReportDataType dataType, DataFormat dataFormat)
 {
     return($"/reports/id/{reportId}?apiDataFormat={dataFormat}&dataType={dataType}");
 }
        public IActionResult GetById(int reportId, [FromQuery] DataFormat apiDataFormat = DataFormat.Raw, [FromQuery] ReportDataType dataType = ReportDataType.ReportData)
        {
            var report = new ReportData
            {
                Columns = new List <string>
                {
                    "Id",
                    "Name",
                    "Description"
                },
                Rows = new List <ReportDataRow>()
            };

            if (dataType == ReportDataType.ChartData)
            {
                report.Rows.Add(new ReportDataRow
                {
                    RecordId = 1,
                    Cells    = new List <object>
                    {
                        "1",
                        "Test Name 1",
                        "Test description 1"
                    }
                });

                report.Rows.Add(new ReportDataRow
                {
                    RecordId = 2,
                    Cells    = new List <object>
                    {
                        "2",
                        "Test Name 2",
                        "Test description 2"
                    }
                });
            }
            else
            {
                report.Rows.Add(new ReportDataRow
                {
                    RecordId = 1,
                    Cells    = new List <object> {
                        "1"
                    }
                });

                report.Rows.Add(new ReportDataRow
                {
                    RecordId = 2,
                    Cells    = new List <object> {
                        "2"
                    }
                });
            }
            return(Ok(report));
        }
예제 #11
0
 protected abstract object GetConnectionInfo(ReportDataType reportDataType);
예제 #12
0
 public static IDictionary <string, JsonElement> ConvertDataToDictionary(this JsonElement row, ReportDataType ReportDataType, Func <JsonElement, (string, JsonElement)> PopulateItem, bool replace = true)
예제 #13
0
    private void AddCondition()
    {
        ReportConditions conditions = ReportConditions;
        ReportCondition  condition  = new ReportCondition();

        condition.IsCustomField     = IsValueCustomField(cmbFields.SelectedValue);
        condition.FieldID           = GetValueFieldID(cmbFields.SelectedValue);
        condition.DisplayName       = cmbFields.SelectedItem.Text;
        condition.ConditionOperator = (ConditionOperator)int.Parse(cmbOperator.SelectedValue);
        ReportDataType dataType = GetDataType(cmbFields.SelectedValue);

        switch (dataType)
        {
        case ReportDataType.String:
            /*if (textValue.Text == "")
             * {
             * _manager.Alert("Please enter a value.");
             * return;
             * }*/
            condition.Value1 = textValue.Text;
            break;

        case ReportDataType.Int:
            if (numValue1.Value == null)
            {
                _manager.Alert("Please enter a value.");
                return;
            }
            if (numValue2.Visible && numValue2.Value == null)
            {
                _manager.Alert("Please enter the second value.");
                return;
            }

            condition.Value1 = (int)numValue1.Value;
            if (numValue2.Visible)
            {
                condition.Value2 = (int)numValue2.Value;
            }
            break;

        case ReportDataType.Float:
            if (numValue1.Value == null)
            {
                _manager.Alert("Please enter a value.");
                return;
            }
            if (numValue2.Visible && numValue2.Value == null)
            {
                _manager.Alert("Please enter the second value.");
                return;
            }

            condition.Value1 = (double)numValue1.Value;
            if (numValue2.Visible)
            {
                condition.Value2 = (double)numValue2.Value;
            }
            break;

        case ReportDataType.DateTime:
            if (dateValue1.SelectedDate == null)
            {
                _manager.Alert("Please enter a date.");
                return;
            }
            if (dateValue2.Visible && dateValue2.SelectedDate == null)
            {
                _manager.Alert("Please enter the second date.");
                return;
            }
            condition.Value1 = (DateTime)dateValue1.SelectedDate;
            if (dateValue2.Visible)
            {
                condition.Value2 = (DateTime)dateValue2.SelectedDate;
            }
            break;

        case ReportDataType.Boolean:
            condition.Value1 = cmbBool.SelectedIndex == 0;
            break;

        default:
            break;
        }

        if (condition.Value1 == null)
        {
            _manager.Alert("Please enter a value.");
            return;
        }

        if ((condition.ConditionOperator == ConditionOperator.IsNotInBetween || condition.ConditionOperator == ConditionOperator.IsInBetween) && condition.Value2 == null)
        {
            _manager.Alert("Please enter the second value.");
            return;
        }

        conditions.Items.Add(condition);
        ReportConditions    = conditions;
        litDisplayText.Text = conditions.ToString();
    }
예제 #14
0
 protected override object GetConnectionInfo(ReportDataType reportDataType)
 {
     throw new NotImplementedException();
 }
예제 #15
0
        /// <summary>
        /// Set the value of a cell
        /// </summary>
        /// <param name="row">Row</param>
        /// <param name="cellIndex">Index of the cell in the sheet</param>
        /// <param name="value">Value of the cell</param>
        /// <param name="cellStyle">Style of the cell</param>
        /// <param name="dataType">DataType</param>
        private void SetCellValue(IRow row, int cellIndex, object value, XSSFCellStyle cellStyle, ReportDataType dataType = ReportDataType.Text)
        {
            if (value == null)
            {
                return;
            }

            ICell cell = row.CreateCell(cellIndex);

            switch (dataType)
            {
            case ReportDataType.Date:
            case ReportDataType.Double:
                cell.SetCellType(CellType.Numeric);
                cell.SetCellValue((double)value);
                break;

            case ReportDataType.Integer:
                cell.SetCellType(CellType.Numeric);
                cell.SetCellValue((int)value);
                break;

            case ReportDataType.RichText:
                cell.SetCellType(CellType.String);
                cell.SetCellValue((IRichTextString)value);
                break;

            default:
                cell.SetCellType(CellType.String);
                cell.SetCellValue((string)value);
                break;
            }
            cell.CellStyle = cellStyle;
        }