Пример #1
0
        //used by ReportEngine
        public static RouteMinutesSummary[] GetCustomerRouteMinutesSummaries(int pTimokDate)
        {
            DataTable _dt;

            using (var _db = new Cdr_Db(TimokDate.ToDateTime(pTimokDate))) {
                _dt = _db.CDRCollection.GetCustomerRoutesTotalMinutes(pTimokDate);
            }
            var _list = new ArrayList();

            if (_dt != null && _dt.Rows.Count > 0)
            {
                using (var _db = new Rbr_Db()) {
                    foreach (DataRow _dataRow in _dt.Rows)
                    {
                        var _routeMinutesSummary = new RouteMinutesSummary
                        {
                            Id      = ((int)_dataRow[CustomerRoutesTotalMinutesDataTable.Id_ColumnName]),
                            Minutes = ((decimal)_dataRow[CustomerRoutesTotalMinutesDataTable.Minutes_ColumnName])
                        };
                        if (_routeMinutesSummary.Id > 0)
                        {
                            var _routeRow = _db.RouteCollection.GetByPrimaryKey(_routeMinutesSummary.Id);
                            _routeMinutesSummary.Name = _routeRow.Name;
                        }
                        _list.Add(_routeMinutesSummary);
                    }
                }
                _list.Sort(new GenericComparer(RouteMinutesSummary.Name_PropName, ListSortDirection.Ascending));
            }
            return((RouteMinutesSummary[])_list.ToArray(typeof(RouteMinutesSummary)));
        }
Пример #2
0
        public static EndpointASR[] GetTermEndpointsASR(int pTimokDate)
        {
            DataTable _dt;

            using (var _db = new Cdr_Db(TimokDate.ToDateTime(pTimokDate))) {
                _dt = _db.CDRCollection.GetTermEpAsr(pTimokDate);
            }
            var _list = new ArrayList();

            if (_dt != null && _dt.Rows.Count > 0)
            {
                using (var _db = new Rbr_Db()) {
                    foreach (DataRow _dataRow in _dt.Rows)
                    {
                        var _endpointAsr = new EndpointASR
                        {
                            EndpointId     = ((short)_dataRow[EndpointAsrDataTable.Id_ColumnName]),
                            Calls          = ((int)_dataRow[EndpointAsrDataTable.Calls_ColumnName]),
                            ConnectedCalls = ((int)_dataRow[EndpointAsrDataTable.Connected_calls_ColumnName]),
                            Asr            = ((int)_dataRow[EndpointAsrDataTable.Asr_ColumnName])
                        };
                        if (_endpointAsr.EndpointId > 0)
                        {
                            var _endPointRow = _db.EndPointCollection.GetByPrimaryKey(_endpointAsr.EndpointId);
                            _endpointAsr.Alias = _endPointRow.Alias;
                        }
                        _list.Add(_endpointAsr);
                    }
                }
                _list.Sort(new GenericComparer(EndpointASR.Alias_PropName, ListSortDirection.Ascending));
            }
            return((EndpointASR[])_list.ToArray(typeof(EndpointASR)));
        }
Пример #3
0
        ///NOTE: depricated
        //static List<string> getCDRs(string pWhereFilter, CdrExportMap pCdrExportMap, int pStartTimokDate, int pEndTimokDate, string pDecimalFormatString, BackgroundWorker pBackgroundWorker) {
        //  pBackgroundWorker.ReportStatus("Retrieving CDRs...");
        //  List<string> _records = new List<string>();
        //  if (Cdr_Db.Exists(TimokDate.ToDateTime(pStartTimokDate))) {
        //    using (Cdr_Db _db = new Cdr_Db(TimokDate.ToDateTime(pStartTimokDate))) {
        //      IDbCommand _cmd = _db.Connection.CreateCommand();
        //      _cmd.CommandText = getSQLForCDRViewExport(_db.Connection.Database, pCdrExportMap.CdrExportMapDetails, pStartTimokDate, pEndTimokDate, pWhereFilter);
        //      IDataReader _reader = _cmd.ExecuteReader();
        //      while (_reader.Read()) {
        //        if (pBackgroundWorker.CancellationPending) {
        //          throw new Exception("CDR Export canceled");
        //        }
        //        StringBuilder _record = new StringBuilder();
        //        foreach (CdrExportMapDetail _field in pCdrExportMap.CdrExportMapDetails) {
        //          object _value = _reader.GetValue(_field.Sequence - 1);
        //          _record.Append(_value);
        //          //NOTE: if need to format prices, here is the place to do that
        //          //if (_value is Decimal) {
        //          //  _record.Append(((decimal) _value).ToString(pDecimalFormatString));
        //          //}
        //          //else {
        //          //  _record.Append(_value);
        //          //}
        //          _record.Append((char) pCdrExportMap.CdrExportDelimeter);
        //        }
        //        _records.Add(_record.ToString().TrimEnd((char) pCdrExportMap.CdrExportDelimeter));
        //      }
        //    }
        //  }
        //  pBackgroundWorker.ReportStatus(string.Format("Retrieved {0} CDRs", _records.Count));
        //  return _records;
        //}
        static List <string> getCDRs(string pWhereFilter, ICdrExportInfo pCdrExportInfo, int pTimokDate, IBackgroundWorker pBackgroundWorker)
        {
            var _records = new List <string>();

            if (Cdr_Db.Exists(TimokDate.ToDateTime(pTimokDate)))
            {
                CDRViewRow[] _cdrViewRows;
                try {
                    using (var _db = new Cdr_Db(TimokDate.ToDateTime(pTimokDate))) {
                        _cdrViewRows = _db.CDRViewCollection.Get(pTimokDate, pWhereFilter);
                    }
                }
                catch (Exception _ex) {
                    TimokLogger.Instance.LogRbr(LogSeverity.Critical, GetcdrsLabel, string.Format("Exception:\r\n{0}", _ex));
                    pBackgroundWorker.ReportStatus(string.Format("Exception! Exported {0} CDRs", _records.Count));
                    return(_records);
                }
                if (_cdrViewRows == null || _cdrViewRows.Length == 0)
                {
                    TimokLogger.Instance.LogRbr(LogSeverity.Error, GetcdrsLabel, "No CDR Records found");
                    pBackgroundWorker.ReportStatus("No CDR Records found");
                    return(_records);
                }

                pBackgroundWorker.ReportStatus(string.Format("Retrieved {0} CDRs for: {1}", _cdrViewRows.Length, TimokDate.ToDateTime(pTimokDate).ToString("yyyy-MM-dd HH:mm")));

                var _recordCount = 0;
                foreach (var _cdrViewRow in _cdrViewRows)
                {
                    if (pBackgroundWorker.CancellationPending)
                    {
                        throw new Exception("CDR Export canceled");
                    }

                    if (pCdrExportInfo.WithRerating && _cdrViewRow.Duration > 0)
                    {
                        if (!rerateCDR(_cdrViewRow, pBackgroundWorker))
                        {
                            continue;
                        }
                    }

                    _records.Add(mapToExportedRecord(_cdrViewRow, pCdrExportInfo.CdrExportMap));
                    pBackgroundWorker.ReportProgress(++_recordCount * 100 / _cdrViewRows.Length);
                }

                if (_records.Count != _cdrViewRows.Length)
                {
                    pBackgroundWorker.ReportStatus(string.Format("ERROR: Exported {0} out of {1} retreived CDRs", _records.Count, _cdrViewRows.Length));
                }
                else
                {
                    pBackgroundWorker.ReportStatus(string.Format("Exported {0} CDRs for: {1}", _records.Count, TimokDate.ToDateTime(pTimokDate).ToString("yyyy-MM-dd HH:mm")));
                }
            }
            return(_records);
        }
Пример #4
0
        public static List <CdrDto> GetCDRsByCarrierAcctIdEndpointId(int pStartTimokDate, int pEndTimokDate, short pCarrierAcctId, short pEndpointId)
        {
            var _cdrViewRows = new CDRViewRow[0];

            if (Cdr_Db.Exists(TimokDate.ToDateTime(pStartTimokDate)))
            {
                using (var db = new Cdr_Db(TimokDate.ToDateTime(pStartTimokDate))) {
                    _cdrViewRows = db.CDRViewCollection.GetByCarrierAcctIdEndpointId(pStartTimokDate, pEndTimokDate, pCarrierAcctId, pEndpointId);
                }
            }
            return(mapToCDRs(_cdrViewRows));
        }
Пример #5
0
        public static List <CdrDto> GetRetailAcctCDRs(int pStartTimokDate, int pEndTimokDate, int pRetailAcctId)
        {
            var _cdrViewRows = new CDRViewRow[0];

            if (Cdr_Db.Exists(TimokDate.ToDateTime(pStartTimokDate)))
            {
                using (var db = new Cdr_Db(TimokDate.ToDateTime(pStartTimokDate))) {
                    _cdrViewRows = db.CDRViewCollection.GetByRetailAcctId(pStartTimokDate, pEndTimokDate, pRetailAcctId);
                }
            }
            return(mapToCDRs(_cdrViewRows));
        }
Пример #6
0
        public static List <CdrDto> GetCDRsByRetailAcctId(int pStartTimokDate, int pEndTimokDate, int pRetailAcctId, int pPageNumber, int pPageSize, out int pTotalCount)
        {
            pTotalCount = 0;
            var _cdrViewRows = new CDRViewRow[0];

            if (Cdr_Db.Exists(TimokDate.ToDateTime(pStartTimokDate)))
            {
                using (var _db = new Cdr_Db(TimokDate.ToDateTime(pStartTimokDate))) {
                    _cdrViewRows = _db.CDRViewCollection.GetByRetailAcctIdPaged(pStartTimokDate, pEndTimokDate, pRetailAcctId, pPageNumber, pPageSize, out pTotalCount);
                }
            }
            return(mapToCDRs(_cdrViewRows));
        }
Пример #7
0
 //Day node_id  route_id carrier_acct_id Total Completed InMinutes OutMinutes Cost Name  PopName
 public RouteReportRecord(int?pDay, string pNode, string pCustomerName, int?pTotal, int?pCompleted, int?pInMinutes, decimal?pOutMinutes, decimal?pCost, string pRouteName, string pCarrierName)
 {
     Date         = TimokDate.ToDateTime((int)pDay).ToShortDateString();
     Node         = pNode;
     CustomerName = pCustomerName;
     Total        = pTotal;
     Completed    = pCompleted;
     InMinutes    = pInMinutes;
     OutMinutes   = pOutMinutes;
     Cost         = pCost;
     RouteName    = pRouteName;
     CarrierName  = pCarrierName;
     Asr          = StatsCalc.GetASR(Total, Completed);
     Acd          = StatsCalc.GetACD(OutMinutes, Completed);
 }
Пример #8
0
 private static ArrayList getDBDateList(int pStartTimokDate, int pEndTimokDate)
 {
     return(getDBDateList(TimokDate.ToDateTime(pStartTimokDate), TimokDate.ToDateTime(pEndTimokDate)));
 }