public ConditionalAssignDialog(DashboardHelper dashboardHelper)
 {
     InitializeComponent();
     this.dashboardHelper = dashboardHelper;
     this.DataFilters = new DataFilters(dashboardHelper);
     FillComboBoxes();
 }
        public RowFilterDialog(DashboardHelper dashboardHelper, FilterDialogMode pMode, DataFilters filters, bool includeUserDefinedVars)
        {
            InitializeComponent();
            this.includeUserDefinedVars = includeUserDefinedVars;
            this.dashboardHelper = dashboardHelper;
            this.Mode = pMode;
            Construct();

            rfc = new EpiDashboard.RowFilterControl(dashboardHelper, Mode, filters, includeUserDefinedVars);
            host.Child = rfc;
        }
Exemple #3
0
        private DataFilters GetDateOutOfPreDefine(DataFilters dataFilters)
        {
            if (!string.IsNullOrEmpty(dataFilters.PreDefinedDate))
            {
                switch (dataFilters.PreDefinedDate)
                {
                case "Today":
                    dataFilters.FromDate = DateTime.Now.AddDays(-1);
                    dataFilters.ToDate   = DateTime.Now;
                    break;

                case "Yesterday":
                    dataFilters.FromDate = DateTime.Now.AddDays(-2);
                    dataFilters.ToDate   = DateTime.Now.AddDays(-1);
                    break;

                case "CurrentWeek":
                    dataFilters.FromDate = DateTime.Now.AddDays(-7);
                    dataFilters.ToDate   = DateTime.Now;
                    break;

                case "LastWeek":
                    dataFilters.FromDate = DateTime.Now.AddDays(-14);
                    dataFilters.ToDate   = DateTime.Now.AddDays(-7);
                    break;

                case "CurrentMonth":
                    dataFilters.FromDate = DateTime.Now.AddMonths(-1);
                    dataFilters.ToDate   = DateTime.Now;
                    break;

                case "LastMonth":
                    dataFilters.FromDate = DateTime.Now.AddMonths(-2);
                    dataFilters.ToDate   = DateTime.Now.AddMonths(-1);
                    break;

                case "CurrentYear":
                    dataFilters.FromDate = DateTime.Now.AddYears(-1);
                    dataFilters.ToDate   = DateTime.Now;
                    break;

                case "LastYear":
                    dataFilters.FromDate = DateTime.Now.AddYears(-2);
                    dataFilters.ToDate   = DateTime.Now.AddYears(-1);
                    break;

                default:
                    dataFilters.FromDate = DateTime.Now.AddYears(-15);
                    dataFilters.ToDate   = DateTime.Now;
                    break;
                }
            }
            return(dataFilters);
        }
Exemple #4
0
        /// <summary>
        /// Get data from external JSON result and output it as HTML table (for Excel refresh)
        /// </summary>
        public ActionResult HtmlData(DataFilters excelFilters, int timeZoneOffset = 0)
        {
            List <Models.Excel.DataItem> items = new List <Models.Excel.DataItem>();

            try
            {
                /* BEGIN ADJUST TIMES */
                DateTime clientTimeFrom;
                DateTime clientTimeTo;
                if (excelFilters.TimeEntryType == TimeEntryType.Days)
                {
                    clientTimeTo = TimeZoneHelper.ClientCurrentTime(timeZoneOffset);
                    if (excelFilters.Days > 0)
                    {
                        clientTimeFrom = clientTimeTo.AddDays(-excelFilters.Days);
                    }
                    else
                    {
                        clientTimeFrom = clientTimeTo.Date;
                    }
                }
                else
                {
                    clientTimeFrom = excelFilters.From;
                    clientTimeTo   = excelFilters.To;
                }
                /* END ADJUST TIMES */


                //items =
                //    Merger.GetDataItems(
                //        businessId: excelFilters.BusinessId,
                //        lineId: excelFilters.LineId,
                //        timeFrom: clientTimeFrom,
                //        timeTo: clientTimeTo);
                var dbItems =
                    Database.GetDataItems(
                        businessId: excelFilters.BusinessId,
                        lineId: excelFilters.LineId,
                        employeeId: excelFilters.EmployeeId,
                        timeFrom: clientTimeFrom,
                        timeTo: clientTimeTo);

                items = Mapper.Map <List <AdapterDb.DataItem>, List <Models.Excel.DataItem> >(dbItems);
            }
            catch (Exception ex)
            {
                var eatenEx = ex;
                log.Error("problem while merging data items", ex);
            }

            return(View(items));
        }
        private void btnNumeratorRule_Click(object sender, RoutedEventArgs e)
        {
            Dialogs.RowFilterDialog           rowFilterDialog = new Dialogs.RowFilterDialog(this.DashboardHelper, Dialogs.FilterDialogMode.ConditionalMode, Parameters.NumerFilter, true);
            System.Windows.Forms.DialogResult result          = rowFilterDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                _numerFilter           = rowFilterDialog.DataFilters;
                Parameters.NumerFilter = rowFilterDialog.DataFilters;
                numeratorRule.Content  = _numerFilter.GenerateReadableDataFilterString();
            }
        }
Exemple #6
0
        public string GetSearchTableByFilters(string fields, string filters)
        {
            var curFilters = DataFilters.Deserialize(filters);
            var curFields  = DataFields.DecriptAndDeserialize(fields);

            curFields.AddDetailsUrlField();

            FilterCorrector(curFilters, curFields);

            var tableJS = MyExcel.GetSubDataTable(curFilters, curFields);

            return(tableJS);
        }
Exemple #7
0
        public ConditionalAssignDialog(DashboardHelper dashboardHelper, Rule_ConditionalAssign conditionalAssignRule)
        {
            InitializeComponent();
            this.dashboardHelper = dashboardHelper;
            this.DataFilters     = conditionalAssignRule.DataFilters;

            editMode = true;

            FillComboBoxes();

            this.txtDestinationField.Text    = conditionalAssignRule.DestinationColumnName;
            this.txtDestinationField.Enabled = false;

            SetAssignValue setAssignValue = new SetAssignValue(SetAssignmentValue);

            switch (conditionalAssignRule.DestinationColumnType)
            {
            case "System.SByte":
            case "System.Byte":
            case "System.Boolean":
                this.cbxFieldType.SelectedItem = "Yes/No";
                setAssignValue = new SetAssignValue(SetBooleanAssignmentValue);
                break;

            case "System.String":
                this.cbxFieldType.SelectedItem = "Text";
                break;

            case "System.Single":
            case "System.Double":
            case "System.Decimal":
            case "System.Int32":
            case "System.Int16":
                this.cbxFieldType.SelectedItem = "Numeric";
                break;
            }

            cbxFieldType.Enabled = false;

            this.txtAssignCondition.Text = DataFilters.GenerateReadableDataFilterString();

            //foreach (KeyValuePair<string, object> kvp in conditionalAssignRule.Conditions)
            //{
            //    this.txtAssignValue.Text = kvp.Value.ToString();
            //    break;
            //}

            setAssignValue(conditionalAssignRule);
        }
        public ConditionalAssignDialog(DashboardHelper dashboardHelper, Rule_ConditionalAssign conditionalAssignRule)
        {
            InitializeComponent();
            this.dashboardHelper = dashboardHelper;
            this.DataFilters = conditionalAssignRule.DataFilters;

            editMode = true;

            FillComboBoxes();

            this.txtDestinationField.Text = conditionalAssignRule.DestinationColumnName;
            this.txtDestinationField.Enabled = false;

            SetAssignValue setAssignValue = new SetAssignValue(SetAssignmentValue);

            switch (conditionalAssignRule.DestinationColumnType)
            {
                case "System.SByte":
                case "System.Byte":
                case "System.Boolean":
                    this.cbxFieldType.SelectedItem = "Yes/No";
                    setAssignValue = new SetAssignValue(SetBooleanAssignmentValue);
                    break;
                case "System.String":
                    this.cbxFieldType.SelectedItem = "Text";
                    break;
                case "System.Single":
                case "System.Double":
                case "System.Decimal":
                case "System.Int32":
                case "System.Int16":
                    this.cbxFieldType.SelectedItem = "Numeric";
                    break;
            }

            cbxFieldType.Enabled = false;

            this.txtAssignCondition.Text = DataFilters.GenerateReadableDataFilterString();

            //foreach (KeyValuePair<string, object> kvp in conditionalAssignRule.Conditions)
            //{
            //    this.txtAssignValue.Text = kvp.Value.ToString();
            //    break;
            //}

            setAssignValue(conditionalAssignRule);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="view">The view to attach</param>
        /// <param name="db">The database to attach</param>
        /// <param name="dashboardHelper">The dashboard helper to attach</param>
        public RowFilterControl(DashboardHelper dashboardHelper, EpiDashboard.Dialogs.FilterDialogMode pMode, DataFilters filters = null, bool includeUserDefinedVars = true)
        {
            InitializeComponent();
            this.dashboardHelper = dashboardHelper;
            this.config = dashboardHelper.Config;
            this.includeUserDefinedVars = includeUserDefinedVars;
            this.Mode = pMode;

            if (filters == null)
            {
                DataFilters = new DataFilters(this.dashboardHelper);
            }
            else
            {
                DataFilters = filters;
            }

            //txtTitle.RenderTransform = new RotateTransform(270);
            FillSelectionComboboxes();

            selectionGridHeight = grdSelectionProperties.Height;
            guidedButtonsGridHeight = grdGuidedModeButtons.Height;

            //if (dashboardHelper.UseAdvancedUserDataFilter)
            //{
            //    pnlAdvancedMode.Visibility = Visibility.Visible;
            //    txtAdvancedFilter.Text = dashboardHelper.AdvancedUserDataFilter;
            //    SetAdvancedFilterMode();
            //    ApplyAdvancedModeFilter();
            //}
            //else
            //{
                pnlAdvancedMode.Visibility = Visibility.Collapsed;
                txtAdvancedFilter.Text = string.Empty;
                SetGuidedFilterMode();
            //}

            UpdateFilterConditions();

            if (!dashboardHelper.IsUsingEpiProject)
            {
                //panelAdvanced.Visibility = Visibility.Collapsed;
            }
            config = Configuration.GetNewInstance();
        }
Exemple #10
0
        public ActionResult GetOperationResult(DataFilters dataFilters)
        {
            OperatorReportItems ProductivityReport = new OperatorReportItems();

            dataFilters = GetDateOutOfPreDefine(dataFilters);
            if (dataFilters.ToDate >= dataFilters.FromDate)
            {
                try
                {
                    SqlCommand sqlcomm = new SqlCommand("dbo.OperatorProductivityWithFilters ", _conn);
                    sqlcomm.CommandType = CommandType.StoredProcedure;
                    sqlcomm.Parameters.Add(new SqlParameter("@fromDate", (dataFilters.FromDate == DateTime.MinValue) ? (object)DBNull.Value : dataFilters.FromDate.ToString("yyyy-MM-dd")));
                    sqlcomm.Parameters.Add(new SqlParameter("@toDate", (dataFilters.ToDate == DateTime.MinValue) ? (object)DBNull.Value : dataFilters.ToDate.ToString("yyyy-MM-dd")));
                    sqlcomm.Parameters.Add(new SqlParameter("@website", dataFilters.Website ?? (object)DBNull.Value));
                    sqlcomm.Parameters.Add(new SqlParameter("@device", dataFilters.Device ?? (object)DBNull.Value));
                    _conn.Open();
                    SqlDataReader dr = sqlcomm.ExecuteReader();
                    while (dr.Read())
                    {
                        OperatorReportViewModel opVM = new OperatorReportViewModel();
                        opVM.ID                    = Convert.ToInt32(dr[0]);
                        opVM.Name                  = Convert.ToString(dr[1]);
                        opVM.ProactiveSent         = Convert.ToInt32(dr[2]);
                        opVM.ProactiveAnswered     = Convert.ToInt32(dr[3]);
                        opVM.ProactiveResponseRate = Convert.ToInt32(dr[4]);
                        opVM.ReactiveAnswered      = Convert.ToInt32(dr[5]);
                        opVM.ReactiveReceived      = Convert.ToInt32(dr[6]);
                        opVM.ReactiveResponseRate  = Convert.ToInt32(dr[7]);
                        opVM.TotalChatLength       = TimeSpan.FromMinutes(Convert.ToInt32(dr[8])).ToString(@"d\d' 'hh\h' 'mm\m");
                        opVM.AverageChatLength     = TimeSpan.FromMinutes(Convert.ToInt32(dr[9])).ToString(@"mm\m");
                        ProductivityReport.OperatorProductivity.Add(opVM);
                    }
                }
                catch (SqlException ex)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Database Error, Connot complete the process"));
                }
                finally
                {
                    _conn.Close();
                }
                return(Json(ProductivityReport.OperatorProductivity));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Supplied Filter is incorrect"));
        }
        public override bool Filter(IDictionary <string, object> data)
        {
            bool result   = (OperatorType == OperatorType.And);
            bool unResult = !result;

            if (!DataFilters.IsNullOrEmpty())
            {
                foreach (var filter in DataFilters.OrderBy(o => o.Rank))
                {
                    result = filter.Filter(data);
                    if (result == unResult)
                    {
                        break;
                    }
                }
            }
            return(result);
        }
Exemple #12
0
 public static IQueryable <ContainerAndGrwarnings> FilterByFacilities(DataFilters filters, IQueryable <ContainerAndGrwarnings> containerAndGuardRailWarnings)
 {
     try
     {
         var facilites    = filters.Facilities;
         var facilityList = Generic.StringToList(facilites);
         //var filterByFacilitiesResponse = filters.AllowUnknown ?
         //    containerAndGuardRailWarnings.Where(p => facilityList.Contains(p.AdtFacility.ToLower()) || p.AdtFacility == null) :
         //    containerAndGuardRailWarnings.Where(p => facilityList.Contains(p.AdtFacility.ToLower()));
         var filterByFacilitiesResponse = filters.AllowUnknown ?
                                          containerAndGuardRailWarnings.Where(p => facilityList.Contains(p.AdtFacility) || p.AdtFacility == null) :
                                          containerAndGuardRailWarnings.Where(p => facilityList.Contains(p.AdtFacility));
         return(filterByFacilitiesResponse);
     }
     catch (Exception ex)
     {
         //log.Error("Facilities Filter Method Has Failed : " + ex);
         return(containerAndGuardRailWarnings);
     }
 }
Exemple #13
0
        public ActionResult Index()
        {
            var dbBusinessList = Database.GetBusinessLineList(User);
            var businessList   = Mapper.Map <List <Models.Config.Business> >(dbBusinessList);

            /* BEGIN ADJUST TIMES */
            DateTime clientCurrentTime = TimeZoneHelper.ClientCurrentTime(ViewBag.TimeZoneOffset);
            DateTime clientTimeFrom    = clientCurrentTime.Date;
            /* END ADJUST TIMES */

            var model = new DataFilters
            {
                TimeEntryType = TimeEntryType.Days,
                Days          = 1,
                From          = clientTimeFrom,
                To            = clientCurrentTime,
                BusinessList  = businessList
            };

            return(View(model));
        }
Exemple #14
0
        private static IQueryable <ContainerAndGrwarnings> ExecuteFilters(DataFilters dataFilters, IQueryable <ContainerAndGrwarnings> dbQueryContainerAndGuardRailWarnings)
        {
            //Filters data by Facilities.
            if (!string.IsNullOrEmpty(dataFilters.Facilities))
            {
                dbQueryContainerAndGuardRailWarnings = FilterByFacilities(dataFilters, dbQueryContainerAndGuardRailWarnings);
            }

            //Filters data by Units
            if (!string.IsNullOrEmpty(dataFilters.Units))
            {
                dbQueryContainerAndGuardRailWarnings = FilterByUnits(dataFilters.Units, dbQueryContainerAndGuardRailWarnings);
            }

            //Filters data by Patients
            if (!string.IsNullOrEmpty(dataFilters.Patients))
            {
                dbQueryContainerAndGuardRailWarnings = FilterByPatients(dataFilters.Patients, dbQueryContainerAndGuardRailWarnings);
            }

            //Filters data by InfusionTypes
            if (!string.IsNullOrEmpty(dataFilters.Infusions))
            {
                dbQueryContainerAndGuardRailWarnings = FilterByInfusionTypes(dataFilters.Infusions, dbQueryContainerAndGuardRailWarnings);
            }

            //Filters data by Infusion Statues
            if (!string.IsNullOrEmpty(dataFilters.Statuses))
            {
                dbQueryContainerAndGuardRailWarnings = FilterByInfusionStatuses(dataFilters.Statuses, dbQueryContainerAndGuardRailWarnings);
            }

            //Filters data in specified datetime range.
            dbQueryContainerAndGuardRailWarnings = FilterByDateTime(dataFilters.Startdate, dataFilters.Stopdate, dataFilters.Preservehours, dbQueryContainerAndGuardRailWarnings);

            return(dbQueryContainerAndGuardRailWarnings);
        }
Exemple #15
0
        public RowFilterDialog(DashboardHelper dashboardHelper, FilterDialogMode pMode, DataFilters filters, bool includeUserDefinedVars)
        {
            InitializeComponent();
            this.includeUserDefinedVars = includeUserDefinedVars;
            this.dashboardHelper        = dashboardHelper;
            this.Mode = pMode;
            Construct();

            rfc        = new EpiDashboard.RowFilterControl(dashboardHelper, Mode, filters, includeUserDefinedVars);
            host.Child = rfc;

            System.Windows.Size elementSize = GetElementPixelSize(host.Child);

            this.Width  = (int)elementSize.Width + 90;
            this.Height = (int)elementSize.Height + 90;
        }
        /// <summary>
        /// Creates the rule from an Xml element
        /// </summary>
        /// <param name="element">The XmlElement from which to create the rule</param>
        public override void CreateFromXml(System.Xml.XmlElement element)
        {
            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.ToLower().Equals("friendlyrule"))
                {
                    this.friendlyRule = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                }
                else if (child.Name.ToLower().Equals("destinationcolumnname"))
                {
                    this.destinationColumnName = child.InnerText;
                }
                else if (child.Name.ToLower().Equals("destinationcolumntype"))
                {
                    this.destinationColumnType = child.InnerText;
                }
                else if (child.Name.ToLower().Equals("datafilters"))
                {
                    this.DataFilters = new DataFilters(this.dashboardHelper);
                    this.DataFilters.CreateFromXml(child);
                }
                else if (child.Name.ToLower().Equals("useelse"))
                {
                    this.UseElse = bool.Parse(child.InnerText);
                }
            }

            if (DestinationColumnType.Equals("System.String"))
            {
                this.variableType = DashboardVariableType.Text;
            }
            else if (destinationColumnType.Equals("System.Boolean"))
            {
                this.variableType = DashboardVariableType.YesNo;
            }
            else
            {
                this.variableType = DashboardVariableType.Numeric;
            }

            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.ToLower().Equals("assignvalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.assignValue = " ";
                    }
                    else
                    {
                        //this.assignValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                        string strValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");

                        if (variableType == DashboardVariableType.Numeric)
                        {
                            decimal d;
                            bool success = Decimal.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out d);
                            if (success)
                            {
                                this.assignValue = d;
                            }
                            //this.elseValue = decimal.Parse()
                        }
                        else
                        {
                            this.assignValue = strValue;
                        }
                    }
                }
                else if (child.Name.ToLower().Equals("elsevalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.elseValue = " ";
                    }
                    else
                    {
                        string strValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");

                        if (variableType == DashboardVariableType.Numeric)
                        {
                            decimal d;
                            bool success = Decimal.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out d);
                            if (success)
                            {
                                this.elseValue = d;
                            }
                            //this.elseValue = decimal.Parse()
                        }
                        else
                        {
                            this.elseValue = strValue;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Creates the rule from an Xml element
        /// </summary>
        /// <param name="element">The XmlElement from which to create the rule</param>
        public override void CreateFromXml(System.Xml.XmlElement element)
        {
            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.ToLowerInvariant().Equals("friendlyrule"))
                {
                    this.friendlyRule = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                }
                else if (child.Name.ToLowerInvariant().Equals("destinationcolumnname"))
                {
                    this.destinationColumnName = child.InnerText;
                }
                else if (child.Name.ToLowerInvariant().Equals("destinationcolumntype"))
                {
                    this.destinationColumnType = child.InnerText;
                }
                else if (child.Name.ToLowerInvariant().Equals("datafilters"))
                {
                    this.DataFilters = new DataFilters(this.dashboardHelper);
                    this.DataFilters.CreateFromXml(child);
                }
                else if (child.Name.ToLowerInvariant().Equals("useelse"))
                {
                    this.UseElse = bool.Parse(child.InnerText);
                }
            }

            if (DestinationColumnType.Equals("System.String"))
            {
                this.variableType = DashboardVariableType.Text;
            }
            else if (destinationColumnType.Equals("System.Boolean"))
            {
                this.variableType = DashboardVariableType.YesNo;
            }
            else
            {
                this.variableType = DashboardVariableType.Numeric;
            }

            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.ToLowerInvariant().Equals("assignvalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.assignValue = " ";
                    }
                    else
                    {
                        //this.assignValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                        string strValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");

                        if (variableType == DashboardVariableType.Numeric)
                        {
                            decimal d;
                            bool    success = Decimal.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out d);
                            if (success)
                            {
                                this.assignValue = d;
                            }
                            //this.elseValue = decimal.Parse()
                        }
                        else
                        {
                            this.assignValue = strValue;
                        }
                    }
                }
                else if (child.Name.ToLowerInvariant().Equals("elsevalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.elseValue = " ";
                    }
                    else
                    {
                        string strValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");

                        if (variableType == DashboardVariableType.Numeric)
                        {
                            decimal d;
                            bool    success = Decimal.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out d);
                            if (success)
                            {
                                this.elseValue = d;
                            }
                            //this.elseValue = decimal.Parse()
                        }
                        else
                        {
                            this.elseValue = strValue;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Creates the rule from an Xml element
        /// </summary>
        /// <param name="element">The XmlElement from which to create the rule</param>
        public override void CreateFromXml(System.Xml.XmlElement element)
        {
            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.ToLower().Equals("friendlyrule"))
                {
                    this.friendlyRule = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                }
                else if (child.Name.ToLower().Equals("destinationcolumnname"))
                {
                    this.destinationColumnName = child.InnerText;
                }
                else if (child.Name.ToLower().Equals("destinationcolumntype"))
                {
                    this.destinationColumnType = child.InnerText;
                }
                else if (child.Name.ToLower().Equals("datafilters"))
                {
                    this.DataFilters = new DataFilters(this.dashboardHelper);
                    this.DataFilters.CreateFromXml(child);
                }
                else if (child.Name.ToLower().Equals("assignvalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.assignValue = " ";
                    }
                    else
                    {
                        this.assignValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                    }
                }
                else if (child.Name.ToLower().Equals("elsevalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.elseValue = " ";
                    }
                    else
                    {
                        this.elseValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                    }
                }
                else if (child.Name.ToLower().Equals("useelse"))
                {
                    this.UseElse = bool.Parse(child.InnerText);
                }
            }

            if (DestinationColumnType.Equals("System.String"))
            {
                this.variableType = DashboardVariableType.Text;
            }
            else if (destinationColumnType.Equals("System.Boolean"))
            {
                this.variableType = DashboardVariableType.YesNo;
            }
            else
            {
                this.variableType = DashboardVariableType.Numeric;
            }
        }
        /// <summary>
        /// Creates the rule from an Xml element
        /// </summary>
        /// <param name="element">The XmlElement from which to create the rule</param>
        public override void CreateFromXml(System.Xml.XmlElement element)
        {
            foreach (XmlElement child in element.ChildNodes)
            {
                if (child.Name.ToLower().Equals("friendlyrule"))
                {
                    this.friendlyRule = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                }
                else if (child.Name.ToLower().Equals("destinationcolumnname"))
                {
                    this.destinationColumnName = child.InnerText;
                }
                else if (child.Name.ToLower().Equals("destinationcolumntype"))
                {
                    this.destinationColumnType = child.InnerText;
                }
                else if (child.Name.ToLower().Equals("datafilters"))
                {
                    this.DataFilters = new DataFilters(this.dashboardHelper);
                    this.DataFilters.CreateFromXml(child);
                }
                else if (child.Name.ToLower().Equals("assignvalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.assignValue = " ";
                    }
                    else
                    {
                        this.assignValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                    }
                }
                else if (child.Name.ToLower().Equals("elsevalue"))
                {
                    if (child.InnerText.Equals("&#xA0;"))
                    {
                        this.elseValue = " ";
                    }
                    else
                    {
                        this.elseValue = child.InnerText.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">");
                    }
                }
                else if (child.Name.ToLower().Equals("useelse"))
                {
                    this.UseElse = bool.Parse(child.InnerText);
                }
            }

            if (DestinationColumnType.Equals("System.String"))
            {
                this.variableType = DashboardVariableType.Text;
            }
            else if (destinationColumnType.Equals("System.Boolean"))
            {
                this.variableType = DashboardVariableType.YesNo;
            }
            else
            {
                this.variableType = DashboardVariableType.Numeric;
            }
        }
 private void btnIfCondition_Click(object sender, EventArgs e)
 {
     RowFilterDialog rfd = new RowFilterDialog(this.dashboardHelper, FilterDialogMode.ConditionalMode, DataFilters, true);
     DialogResult result = rfd.ShowDialog();
     if (result == DialogResult.OK)
     {
         this.DataFilters = rfd.DataFilters;
         this.txtAssignCondition.Text = DataFilters.GenerateReadableDataFilterString();//this.DataFilters.GenerateDataFilterString();
     }
 }
Exemple #21
0
 public static string GetSubDataTable(DataFilters filters, DataFields fields)
 {
     return(excelDocument.GetSubDataTableJS(filters, fields));
 }
Exemple #22
0
        public ActionResult Index(DataFilters excelFilters)
        {
            /* BEGIN ADJUST TIMES */
            DateTime clientTimeFrom;
            DateTime clientTimeTo;

            if (excelFilters.TimeEntryType == TimeEntryType.Days)
            {
                clientTimeTo = TimeZoneHelper.ClientCurrentTime(ViewBag.TimeZoneOffset);

                if (excelFilters.Days > 0)
                {
                    clientTimeFrom = clientTimeTo.AddDays(-excelFilters.Days);
                }
                else
                {
                    clientTimeFrom = clientTimeTo.Date;
                }
            }
            else
            {
                clientTimeFrom = excelFilters.From;
                clientTimeTo   = excelFilters.To;
            }
            /* END ADJUST TIMES */

            string xlsxRelPath = String.Format("/App_Data/{0}", _reportTemplate);
            string xlsxPath    = System.Web.HttpContext.Current.Server.MapPath(xlsxRelPath);

            MemoryStream memoryStream = new MemoryStream();

            lock (_fileAccessLock)
            {
                FileStream fileStream = System.IO.File.Open(xlsxPath, FileMode.Open);

                using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(fileStream, true))
                {
                    var conn             = spreadSheet.WorkbookPart.ConnectionsPart.Connections.FirstChild;
                    OpenXmlAttribute url = conn.FirstChild.GetAttribute("url", "");

                    string dataLinkUrl = String.Format("{0}://{1}{2}",
                                                       HttpContext.Request.Url.Scheme,
                                                       HttpContext.Request.Url.Authority,
                                                       Url.Action("HtmlData", "Excel", new
                    {
                        BusinessId     = excelFilters.BusinessId,
                        LineId         = excelFilters.LineId,
                        EmployeeId     = excelFilters.EmployeeId,
                        TimeEntryType  = excelFilters.TimeEntryType,
                        Days           = excelFilters.Days,
                        From           = excelFilters.From.ToString("s"),
                        To             = excelFilters.To.ToString("s"),
                        TimeZoneOffset = ViewBag.TimeZoneOffset
                    }));

                    url.Value = dataLinkUrl;
                    conn.FirstChild.SetAttribute(url);

                    // *** BEGIN For saving template ONLY ***
                    //var nt = new NameTable();
                    //var nsmgr = new XmlNamespaceManager(nt);
                    //nsmgr.AddNamespace("sh", spreadsheetmlNamespace);
                    //var xdoc = new XmlDocument(nt);
                    ////xdoc.Load(spreadSheet.WorkbookPart.ConnectionsPart.GetStream());
                    //xdoc.Save(spreadSheet.WorkbookPart.ConnectionsPart.GetStream());
                    //spreadSheet.WorkbookPart.Workbook.Save();
                    // *** END For saving template ONLY ***

                    spreadSheet.Close();
                }

                fileStream.Position = 0;

                // Pre-fill sheet
                using (SLDocument sl = new SLDocument(fileStream))
                {
                    //List<Models.Shared.DataItem> items =
                    //    Merger.GetDataItems(
                    //        businessId: excelFilters.BusinessId,
                    //        lineId: excelFilters.LineId,
                    //        timeFrom: clientTimeFrom,
                    //        timeTo: clientTimeTo);

                    var dbItems =
                        Database.GetDataItems(
                            businessId: excelFilters.BusinessId,
                            lineId: excelFilters.LineId,
                            employeeId: excelFilters.EmployeeId,
                            timeFrom: clientTimeFrom,
                            timeTo: clientTimeTo);

                    var items = Mapper.Map <List <AdapterDb.DataItem>, List <Models.Excel.DataItem> >(dbItems);

                    // Add total row
                    Models.Excel.DataItem aggregateTotal = new Models.Excel.DataItem();
                    if (dbItems.Count() > 0)
                    {
                        aggregateTotal = new Models.Excel.DataItem
                        {
                            WaitTime = dbItems.Count > 0 ?
                                       new TimeSpan(0, 0, (int)(dbItems.Average(_ => _.WaitTimeSec) ?? 0)) :
                                       new TimeSpan(0, 0, 0),
                            ServiceTime = dbItems.Count > 0 ?
                                          new TimeSpan(0, 0, (int)(dbItems.Average(_ => _.ServiceTimeSec) ?? 0)) :
                                          new TimeSpan(0, 0, 0),
                            Name = String.Format("Total: {0} customers", dbItems.Count())
                        };
                    }
                    items.Add(aggregateTotal);


                    SLStyle intStyle = sl.CreateStyle();
                    intStyle.FormatCode = "0";
                    intStyle.Alignment  = new SLAlignment {
                        Horizontal = HorizontalAlignmentValues.Right
                    };

                    int startRow = 2;
                    for (int idx = 0; idx < items.Count; idx++)
                    {
                        sl.SetCellValueNumeric(idx + startRow, 1, string.Format("{0}", items[idx].LineId));
                        sl.SetCellValueNumeric(idx + startRow, 2, string.Format("{0}", items[idx].ServiceId));
                        sl.SetCellValueNumeric(idx + startRow, 3, string.Format("{0}", items[idx].AnalyticId));
                        sl.SetCellValueNumeric(idx + startRow, 4, string.Format("{0}", items[idx].BusinessId));
                        sl.SetCellValue(idx + startRow, 5, string.Format("{0}", items[idx].Name));
                        sl.SetCellValueNumeric(idx + startRow, 6, string.Format("{0}", items[idx].QueueId));
                        sl.SetCellValueNumeric(idx + startRow, 7, string.Format("{0}", items[idx].Verification));
                        sl.SetCellValue(idx + startRow, 8, string.Format("{0}", items[idx].Serviced));
                        sl.SetCellValue(idx + startRow, 9, string.Format("{0}", items[idx].ServicedByName));
                        sl.SetCellValue(idx + startRow, 10, string.Format("{0}", items[idx].Called));
                        sl.SetCellValue(idx + startRow, 11, string.Format("{0}", items[idx].CalledByName));
                        sl.SetCellValue(idx + startRow, 12, string.Format("{0}", items[idx].Entered));
                        sl.SetCellValue(idx + startRow, 13, string.Format("{0}", items[idx].WaitTime));
                        sl.SetCellValue(idx + startRow, 14, string.Format("{0}", items[idx].ServiceTime));

                        sl.SetCellStyle(idx + startRow, 1, intStyle);
                        sl.SetCellStyle(idx + startRow, 2, intStyle);
                        sl.SetCellStyle(idx + startRow, 3, intStyle);
                        sl.SetCellStyle(idx + startRow, 4, intStyle);
                        sl.SetCellStyle(idx + startRow, 6, intStyle);
                        sl.SetCellStyle(idx + startRow, 7, intStyle);
                    }

                    var defNames = sl.GetDefinedNames();
                    var name     = defNames[0].Name;
                    var val      = Regex.Replace(defNames[0].Text, @"\$[0-9]+", "");
                    sl.SetDefinedName(name, val);

                    sl.SaveAs(memoryStream);
                }
                fileStream.Close();
            }

            memoryStream.Position = 0;

            return(File(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", _reportOutFile));
        }
        public RatesProperties(
            DashboardHelper dashboardHelper,
            IGadget gadget,
            RatesParameters parameters,
            List <Grid> strataGridList,
            List <string> columnOrder
            )
        {
            InitializeComponent();
            this.DashboardHelper = dashboardHelper;
            this.Gadget          = gadget;
            this.Parameters      = parameters;
            this.StrataGridList  = strataGridList;
            this.ColumnOrder     = columnOrder;

            _numerFilter = new DataFilters(DashboardHelper);
            _denomFilter = new DataFilters(DashboardHelper);

            List <FieldInfo> items  = new List <FieldInfo>();
            List <string>    fields = new List <string>();

            fields.Add(string.Empty);
            items.Add(new FieldInfo()
            {
                Name             = "",
                DataType         = "",
                VariableCategory = VariableCategory.Field
            });

            foreach (string fieldName in DashboardHelper.GetFieldsAsList())
            {
                items.Add(new FieldInfo()
                {
                    Name             = fieldName,
                    DataType         = DashboardHelper.GetColumnDbType(fieldName).ToString(),
                    VariableCategory = VariableCategory.Field
                });

                fields.Add(fieldName);
            }

            foreach (string fieldName in DashboardHelper.GetAllGroupsAsList())
            {
                FieldInfo fieldInfo = new FieldInfo()
                {
                    Name             = fieldName,
                    DataType         = String.Empty,
                    VariableCategory = VariableCategory.Group
                };
                items.Add(fieldInfo);
            }

            if (DashboardHelper.IsUsingEpiProject)
            {
                for (int i = 0; i < DashboardHelper.View.Pages.Count; i++)
                {
                    items.Add(new FieldInfo()
                    {
                        Name             = "Page " + (i + 1).ToString(),
                        DataType         = String.Empty,
                        VariableCategory = VariableCategory.Page
                    });
                }
            }

            fields.Sort();

            cmbNumeratorField.ItemsSource   = items;
            cmbDenominatorField.ItemsSource = items;

            cmbGroupField.ItemsSource          = fields;
            cmbSecondaryGroupField.ItemsSource = fields;

            foreach (string fieldName in fields)
            {
                lbxAvailableVariables.Items.Add(fieldName);
            }

            //nk  CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lvNumerator.ItemsSource);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription("VariableCategory");

            //nk  view.GroupDescriptions.Add(groupDescription);

            RowFilterControl = new RowFilterControl(this.DashboardHelper, Dialogs.FilterDialogMode.ConditionalMode, (gadget as RatesControl).DataFilters, true);
            RowFilterControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            panelFilters.Children.Add(RowFilterControl);

            #region Translation

            lblSelectNumeratorAggregateFunction.Content = DashboardSharedStrings.AGGREGATE_COLON;   // Aggregate:
            lblNumerator.Content               = DashboardSharedStrings.OF_COLON;                   // of:
            lblNumeratorWhere.Content          = DashboardSharedStrings.AND_WHERE;                  // And Where: (filter condition - optional)
            checkBoxNumberatorDistinct.Content = DashboardSharedStrings.DISTINCT;                   // Distinct
            lblPER.Content = DashboardSharedStrings.PER;                                            // PER
            lblSelectDenominatorAggregateFunction.Content = DashboardSharedStrings.AGGREGATE_COLON; // Aggregate:
            lblDenominator.Content              = DashboardSharedStrings.OF_COLON;                  // of:
            lblDenominatorWhere.Content         = DashboardSharedStrings.AND_WHERE;                 // And Where: (filter condition - optional)
            checkBoxDenominatorDistinct.Content = DashboardSharedStrings.DISTINCT;                  // Distinct
            tblockVariableDenominator.Content   = DashboardSharedStrings.DENOMINATOR_COLON;         // Denominator:

            lblRateMultiplier.Content  = DashboardSharedStrings.RATE_MULTIPLIER_COLON;              // Rate Multiplier:
            defaultColorOption.Content = DashboardSharedStrings.USE_DEFAULT_COLOR;                  // Use default color

            btnDenominatorRule.Content = DashboardSharedStrings.CREATE_EDIT_CONDITION;              // Create/Edit Condition
            btnNumeratorRule.Content   = DashboardSharedStrings.CREATE_EDIT_CONDITION;              // Create/Edit Condition

            lblConfigExpandedTitle.Content = DashboardSharedStrings.GADGET_CONFIG_TITLE_RATES;
            tbtnVariables.Title            = DashboardSharedStrings.DEFINE_RATE;;
            tbtnVariables.Description      = DashboardSharedStrings.CREATE_RULES_TO_DEFINE_A_RATE; // Create rules to define a rate.
            tbtnSorting.Title       = DashboardSharedStrings.GADGET_TABBUTTON_SORTING;
            tbtnSorting.Description = DashboardSharedStrings.GADGET_TABDESC_SORTING;
            tbtnDisplay.Title       = DashboardSharedStrings.GADGET_TABBUTTON_DISPLAY;
            tbtnDisplay.Description = DashboardSharedStrings.GADGET_TABDESC_DISPLAY;
            tbtnFilters.Title       = DashboardSharedStrings.GADGET_TABBUTTON_FILTERS;
            tbtnFilters.Description = DashboardSharedStrings.GADGET_TABDESC_FILTERS;

            tblockPanelVariables.Content    = DashboardSharedStrings.DEFINE_RATE; //"Define Rate";
            tblockPanelDisplay.Content      = DashboardSharedStrings.GADGET_PANELHEADER_DISPLAY;
            tblockPanelSorting.Content      = DashboardSharedStrings.GADGET_PANELHEADER_SORTING;
            tblockPanelDataFilter.Content   = DashboardSharedStrings.GADGET_PANELHEADER_DATA_FILTER;
            tblockGroupingSubheader.Content = DashboardSharedStrings.GADGET_PANELSUBHEADER_GROUPING;
            tblockSortingSubheader.Content  = DashboardSharedStrings.GADGET_PANELSUBHEADER_SORTING;
            tblockSortMethod.Content        = DashboardSharedStrings.GADGET_SORT_METHOD;
            tblockTitle.Content             = DashboardSharedStrings.GADGET_GADET_TITLE;
            tblockDesc.Content                = DashboardSharedStrings.GADGET_DESCRIPTION;
            tblockPanelOutputOpt.Content      = DashboardSharedStrings.GADGET_OUTPUT_OPTIONS;
            tblockAnyFilterGadgetOnly.Content = DashboardSharedStrings.GADGET_FILTER_GADGET_ONLY;
            tblockVariableDenominator.Content = DashboardSharedStrings.GADGET_VARIABLES_DENOMINATOR;
            tblockGroupby.Content             = DashboardSharedStrings.GADGET_GROUP_BY;
            tblockSubGroupBy.Content          = DashboardSharedStrings.GADGET_SUBGROUP_BY;
            tblockAvailableVariables.Content  = DashboardSharedStrings.GADGET_AVAILABLE_VARIABLES;
            tblockSortOrder.Content           = DashboardSharedStrings.GADGET_SORT_ORDER;
            tblockDimensions.Content          = DashboardSharedStrings.GADGET_DIMENSIONS;
            tblockTitleNDescSubheader.Content = DashboardSharedStrings.GADGET_PANELSUBHEADER_TITLENDESC;
            tblockMaxWidth.Text               = DashboardSharedStrings.GADGET_MAX_WIDTH;
            btnOK.Content      = DashboardSharedStrings.BUTTON_OK;
            btnCancel.Content  = DashboardSharedStrings.BUTTON_CANCEL;
            tblockMaxRows.Text = SharedStrings.DASHBOARD_OPTION_MAX_ROWS;
            #endregion // Translation
        }
Exemple #24
0
        /// <summary>
        /// Constructs the gadget
        /// </summary>
        protected virtual void Construct()
        {
            strataGridList = new List<Grid>();
            strataPanelList = new List<StackPanel>();
            strataExpanderList = new List<Expander>();
            strataCount = 0;

            GadgetOptions = new GadgetParameters();
            GadgetOptions.InputVariableList = new Dictionary<string, string>();
            GadgetOptions.ShouldIncludeFullSummaryStatistics = false;
            GadgetOptions.ShouldIncludeMissing = false;
            GadgetOptions.ShouldSortHighToLow = false;
            GadgetOptions.ShouldUseAllPossibleValues = false;
            GadgetOptions.StrataVariableNames = new List<string>();
            GadgetOptions.PSUVariableName = string.Empty;
            GadgetOptions.CustomFilter = string.Empty;

            if (this.DashboardHelper != null)
            {
                this.dataFilters = new Epi.WPF.Dashboard.DataFilters(this.DashboardHelper);
            }

            object el = this.FindName("headerPanel");
            if (el != null)
            {
                Controls.GadgetHeaderPanel headerPanel = el as Controls.GadgetHeaderPanel;
                headerPanel.GadgetCloseButtonClicked += new GadgetCloseButtonHandler(CloseGadget);
                headerPanel.GadgetOutputCollapseButtonClicked += new GadgetOutputCollapseButtonHandler(CollapseOutput);
                headerPanel.GadgetOutputExpandButtonClicked += new GadgetOutputExpandButtonHandler(ExpandOutput);
                headerPanel.GadgetConfigButtonClicked += new GadgetConfigButtonHandler(ShowHideConfigPanel);
                headerPanel.GadgetDescriptionButtonClicked += new GadgetDescriptionButtonHandler(ShowHideDescriptionPanel);
                headerPanel.GadgetFilterButtonClicked += new GadgetFilterButtonHandler(ShowCustomFilterDialog);
            }

            el = this.FindName("messagePanel");
            if (el != null)
            {
                Controls.GadgetMessagePanel messagePanel = el as Controls.GadgetMessagePanel;
                messagePanel.MessagePanelType = Controls.MessagePanelType.StatusPanel;
                messagePanel.Text = string.Empty;
                messagePanel.Visibility = System.Windows.Visibility.Collapsed;
            }

            el = this.FindName("descriptionPanel");
            if (el != null)
            {
                Controls.GadgetDescriptionPanel descriptionPanel = el as Controls.GadgetDescriptionPanel;
                if (!string.IsNullOrEmpty(CustomOutputDescription) && !CustomOutputHeading.Equals("(none)"))
                {
                    descriptionPanel.Text = CustomOutputDescription;
                    descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.DisplayMode;
                }
                else
                {
                    descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.Collapsed;
                }
            }
        }