Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CDRLib.SIPAccount"/> class.
 /// </summary>
 public SIPAccount(Subscription Subscription)
 {
     this._id = System.Guid.NewGuid ();
     this._createtimestamp = Toolbox.Date.CurrentDateTimeToTimestamp ();
     this._updatetimestamp = Toolbox.Date.CurrentDateTimeToTimestamp ();
     this._subscriptionid = Subscription.Id;
     this._numbers = new List<string> ();
 }
Esempio n. 2
0
 public Usage(Subscription Subscription)
 {
     this._id = Guid.NewGuid ();
     this._createtimestamp = Toolbox.Date.CurrentDateTimeToTimestamp ();
     this._updatetimestamp = Toolbox.Date.CurrentDateTimeToTimestamp ();
     this._subscriptionid = Subscription.Id;
     this._begintimestamp = 0;
     this._duration = 0;
     this._anumber = string.Empty;
     this._bnumber = string.Empty;
     this._direction = CDRLib.Enums.UsageDirection.None;
 }
Esempio n. 3
0
        /// <summary>
        /// Load a <see cref="CDRLib.Subscription"/> instance from database using a <see cref="System.Guid"/> identifier.
        /// </summary>
        public static Subscription Load(Guid Id)
        {
            bool success = false;
            Subscription result = new Subscription ();

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

            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"));

                    success = true;
                }
            }

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

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

            return result;
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a list of all <see cref="CDRLib.SIPAccount"/> instances in the database, belonging to a <see cref="CDRLib.Subscription"/> instance.
        /// </summary>			
        internal static List<SIPAccount> List(Subscription Subscription)
        {
            List<SIPAccount> result = new List<SIPAccount> ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns ("id");

            if (Subscription != null)
            {
                qb.AddWhere ("subscriptionid", "=",  Subscription.Id);
            }

            Query query = Runtime.DBConnection.Query (qb.QueryString);
            if (query.Success)
            {
                while (query.NextRow ())
                {
                    try
                    {
                        result.Add (Load (query.GetGuid (qb.ColumnPos ("id"))));
                    }
                    catch
                    {}
                }
            }

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

            return result;
        }