Example #1
0
        /// <summary>
        /// Load a <see cref="CDRLib.SIPAccount"/> instance from database using a <see cref="System.Guid"/> identifier.
        /// </summary>		
        public static SIPAccount Load(Guid Id)
        {
            bool success = false;
            SIPAccount result = new SIPAccount ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns
                (
                    "id",
                    "createtimestamp",
                    "updatetimestamp",
                    "name",
                    "numbers"
                );

            qb.AddWhere ("id", "=", Id);

            Query query = Runtime.DBConnection.Query (qb.QueryString);

            if (query.Success)
            {
                if (query.NextRow ())
                {
                    result._id = query.GetGuid (qb.ColumnPos ("id"));
                    result._createtimestamp = query.GetInt (qb.ColumnPos ("createtimestamp"));
                    result._updatetimestamp = query.GetInt (qb.ColumnPos ("updatetimestamp"));
                    result._name = query.GetString (qb.ColumnPos ("name"));

                    foreach (string number in query.GetString (qb.ColumnPos ("numbers")).Split (";".ToCharArray (), StringSplitOptions.RemoveEmptyEntries))
                    {
            //						Console.WriteLine (number);
                        result._numbers.Add (new Number (SNDK.Convert.StringToEnum<Enums.NumberType> (number.Split ("|".ToCharArray ())[0]), number.Split ("|".ToCharArray ())[1], SNDK.Convert.StringToBool (number.Split ("|".ToCharArray ())[2])));
                    }

                    success = true;
                }
            }

            query.Dispose ();
            query = null;
            qb = null;

            if (!success)
            {
                throw new Exception (string.Format (Strings.Exception.SIPAccountLoad, Id));
            }

            return result;
        }
Example #2
0
        public static void GetUsageold(SIPAccount SIPAccount)
        {
            foreach (Number number in SIPAccount._numbers)
            {
                Console.WriteLine ("--------------------------");
                Console.WriteLine (number.Value);
                Console.WriteLine ("--------------------------");

            //				List<qnaxLib.voip.Usage> usage = qnaxLib.voip.Usage.List (number.Value, DateTime.Parse ("01/10/2010"), DateTime.Parse ("31/10/2010"));
                List<qnaxLib.voip.Usage> usage = qnaxLib.voip.Usage.List (number.Value, DateTime.Parse ("01/01/2010"), DateTime.Parse ("31/12/2011"));

                UsageReport report = new UsageReport (number);

                foreach (qnaxLib.voip.Usage u in usage)
                {
                    report.AddUsage (u);
                }

                foreach (UsageReportItem item in report.GetNationalUsage ())
                {
                    Console.WriteLine ("Range : "+ item.Range.Name);
                    Console.WriteLine ("Calls : "+ item.Calls);
                    Console.WriteLine ("Duration : "+ item.DurationInSeconds);
                    Console.WriteLine ("Cost callcharge : "+ item.CostDialCharge);
                    Console.WriteLine ("Costprice : "+ item.Costprice);
                    Console.WriteLine ("Total costprice : "+ item.TotalCostPrice);
                    Console.WriteLine ("Retail callcharge : "+ item.RetailDialCharge);
                    Console.WriteLine ("Retailprice : "+ item.Retailprice);
                    Console.WriteLine ("Total retailprice : "+ item.TotalRetailPrice);
                    Console.WriteLine ("");
                }

                foreach (UsageReportItem item in report.GetInternationalUsage ())
                {
                    Console.WriteLine ("Range : "+ item.Range.Name);
                    Console.WriteLine ("Calls : "+ item.Calls);
                    Console.WriteLine ("Duration : "+ item.DurationInSeconds);
                    Console.WriteLine ("Cost callcharge : "+ item.CostDialCharge);
                    Console.WriteLine ("Costprice : "+ item.Costprice);
                    Console.WriteLine ("Total costprice : "+ item.TotalCostPrice);
                    Console.WriteLine ("Retail callcharge : "+ item.RetailDialCharge);
                    Console.WriteLine ("Retailprice : "+ item.Retailprice);
                    Console.WriteLine ("Total retailprice : "+ item.TotalRetailPrice);
                    Console.WriteLine ("");
                }
            }
        }
Example #3
0
        public static List<UsageReport> GetUsageReports(SIPAccount SIPAccount, DateTime From, DateTime To)
        {
            List<UsageReport> result = new List<UsageReport> ();

            foreach (Number number in SIPAccount._numbers)
            {

                UsageReport report = new UsageReport (number);

                foreach (qnaxLib.voip.Usage u in qnaxLib.voip.Usage.List (number.Value, From, To))
                {
                    report.AddUsage (u);
                }

                result.Add (report);
            }

            return result;
        }
Example #4
0
        public static SIPAccount FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);

            SIPAccount result;

            if (item.ContainsKey ("id"))
            {
                try
                {
                    result = SIPAccount.Load (new Guid ((string)item["id"]));
                }
                catch
                {
                    result = new SIPAccount ();
                    result._id = new Guid ((string)item["id"]);
                }
            }
            else
            {
                throw new Exception ("SIPACCOUNT FROMXMLDOCUMENT NEW");
            }

            if (item.ContainsKey ("name"))
            {
                result._name = (string)item["name"];
            }

            if (item.ContainsKey ("numbers"))
            {
                result._numbers.Clear ();

                foreach (XmlDocument number in (List<XmlDocument>)item["numbers"])
                {
                    result._numbers.Add (Number.FromXmlDocument (number));
                }
            }

            return result;
        }