コード例 #1
0
        /// <summary>
        /// Processes the CDR
        /// </summary>
        /// <returns>Returns task to wait for</returns>
        private async Task _Process()
        {
            // Calculate Gatway Price
            if (this.callDataRecord.CLGatewayRatePerMin.HasValue)
            {
                this.callDataRecord.CLGatewayRateTotal = this.callDataRecord.CLGatewayRatePerMin * (((decimal)this.callDataRecord.YBilltime) / 1000 / 60);
            }

            // Calculate Customer Price
            if (this.callDataRecord.CLCustomerRatePerMin.HasValue)
            {
                this.callDataRecord.CLCustomerRateTotal = this.callDataRecord.CLCustomerRatePerMin * (((decimal)this.callDataRecord.YBilltime) / 1000 / 60);
            }

            /// Retrieve routing tree prepared in <see cref="CallRouteWorker"/> if CDR is of incoming leg
            Utilities.RoutingTree.Root routingTree = null;

            if (callDataRecord.YDirection == Direction.Incoming)
            {
                object data;
                string key = $"routingTree-{this.Node.Id}-{this.callDataRecord.YBillId}";

                data = LiveCache.Get(key);
                if (data != null && data is Utilities.RoutingTree.Root)
                {
                    routingTree = data as Utilities.RoutingTree.Root;
                }

                if (this.callDataRecord.YEnded)
                {
                    LiveCache.Remove(key);
                }

                if (routingTree != null)
                {
                    this.callDataRecord.RoutingTree = JsonConvert.SerializeObject(routingTree, Formatting.None);
                }
            }

            this.isHandled = await this.database.WriteCDR(this.callDataRecord).ConfigureAwait(false);

            this._Acknowledge();
        }
コード例 #2
0
        /// <summary>
        /// Accesses the LiveCache to get the Routing Tree
        /// </summary>
        /// <param name="node"></param>
        /// <param name="billId"></param>
        /// <param name="ended"></param>
        /// <returns></returns>
        internal Utilities.RoutingTree.Root getRoutingTree(INode node, string billId, bool ended)
        {
            object data = null;

            Utilities.RoutingTree.Root root = null;
            string key = $"routingTree-{node.Id}-{billId}";

            data = Caching.LiveCache.Get(key);
            if (data != null && data is Utilities.RoutingTree.Root)
            {
                root = data as Utilities.RoutingTree.Root;
            }

            if (ended)
            {
                Caching.LiveCache.Remove(key);
            }

            return(root);
        }