Ejemplo n.º 1
0
        private void InitializeCriteriaBO(CallLogCriteria criteria)
        {
            if (chkCallerNumber.Checked)
            {
                criteria.FromMobileNumber = cmbCallerMobileNumber.Text;
            }

            if (chkCalleeMobileNumber.Checked)
            {
                criteria.ToMobileNumber = cmbCalleeMobileNumber.Text;
            }

            if (chkFromDate.Checked)
            {
                criteria.FromDate = dtpFromDate.Value;
            }

            if (chkToDate.Checked)
            {
                criteria.ToDate = dtpToDate.Value;
            }

            if (chkFromTime.Checked)
            {
                criteria.FromTime = dtpFromTime.Value;
            }

            if (chkToTime.Checked)
            {
                criteria.ToTime = dtpToTime.Value;
            }

            if (chkStartTower.Checked)
            {
                criteria.TowerId = cmbTowerId.Text;
            }

            if (chkImeiNumber.Checked)
            {
                criteria.IMEINumber = cmbImeiNumber.Text;
            }
        }
Ejemplo n.º 2
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string errorMsg = ValidateCriteriaInput();

            if (errorMsg != null)
            {
                MessageBox.Show("Invalid Input:\n\n" + errorMsg, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            CallLogCriteria criteria = new CallLogCriteria();

            InitializeCriteriaBO(criteria);

            DataGridViewRow[] logTable = new DataGridViewRow[dgInputCallLog.Rows.Count];
            dgInputCallLog.Rows.CopyTo(logTable, 0);
            FilterWorker worker = new FilterWorker();

            IEnumerable <DataGridViewRow> filteredRows = worker.Work(logTable, criteria);

            PopulateFilteredDataGrid(filteredRows);

            LoadCriteriaInputDropDowns(dgFilteredCallLog);
        }
Ejemplo n.º 3
0
        public IEnumerable <DataGridViewRow> Work(DataGridViewRow[] inputTable, CallLogCriteria criteria)
        {
            var filteredRows = (from row in inputTable
                                select row);

            // Filter all outgoing calls from given number
            if (criteria.FromMobileNumber != null)
            {
                filteredRows = filteredRows.Where(row => row.Cells[1].Value.ToString().Contains(criteria.FromMobileNumber));
            }

            // Filter all incoming calls for a given number
            if (criteria.ToMobileNumber != null)
            {
                filteredRows = filteredRows.Where(row => row.Cells[2].Value.ToString().Contains(criteria.ToMobileNumber));
            }

            // Filter all calls which were made in given tower Id (Either call started / ended on the given tower Id)
            if (criteria.TowerId != null)
            {
                filteredRows = filteredRows.Where(row => row.Cells[6].Value.ToString().Contains(criteria.TowerId) || row.Cells[7].Value.ToString().Contains(criteria.TowerId));
            }

            // // Filter on Date range
            if (criteria.FromDate != null && criteria.ToDate != null)
            {
                filteredRows = filteredRows.Where(row => DateTime.Parse(row.Cells[3].Value.ToString()) >= criteria.FromDate.Value.Date &&
                                                  DateTime.Parse(row.Cells[3].Value.ToString()) <= criteria.ToDate.Value.Date);
            }
            else if (criteria.FromDate != null)
            {
                filteredRows = filteredRows.Where(row => DateTime.Parse(row.Cells[3].Value.ToString()) >= criteria.FromDate.Value.Date);
            }
            else if (criteria.ToDate != null)
            {
                filteredRows = filteredRows.Where(row => DateTime.Parse(row.Cells[3].Value.ToString()) <= criteria.ToDate.Value.Date);
            }

            // Filter on Time range
            if (criteria.FromTime != null && criteria.ToTime != null)
            {
                filteredRows = filteredRows.Where(row => DateTime.Parse(row.Cells[4].Value.ToString()) >= criteria.FromTime &&
                                                  DateTime.Parse(row.Cells[4].Value.ToString()) <= criteria.ToTime);
            }
            else if (criteria.FromTime != null)
            {
                filteredRows = filteredRows.Where(row => DateTime.Parse(row.Cells[4].Value.ToString()) >= criteria.FromTime);
            }
            else if (criteria.ToTime != null)
            {
                filteredRows = filteredRows.Where(row => DateTime.Parse(row.Cells[4].Value.ToString()) <= criteria.ToTime);
            }

            // Filter all calls which were made using mobile of given IMEI number (Either caller or callee's mobile IMEI is matched)
            if (criteria.IMEINumber != null)
            {
                filteredRows = filteredRows.Where(row => row.Cells[9].Value.ToString().Contains(criteria.IMEINumber) ||
                                                  row.Cells[10].Value.ToString().Contains(criteria.IMEINumber));
            }

            return(filteredRows);
        }