private void SendUpdate(SubscriptionService service, int subscriptionID, DateTime expiryDateTime, Statuses status, int reference, CSubscriptionEngineCapsule.RequestResults result, bool initialBilling) { Statuses actualStatus = status; DateTime actualExpiryDateTime = expiryDateTime; if (actualStatus == Statuses.DoesNotExist) { actualStatus = GetSubscriptionStatus(subscriptionID); } if (actualExpiryDateTime == DateTime.MinValue) { actualExpiryDateTime = GetSubscriptionExpiryDateTime(subscriptionID); } CXMLCapsule capsule = CSubscriptionEngineCapsule.CreateSubscriptionUpdateCapsule(service.ID, subscriptionID, actualExpiryDateTime, (int)actualStatus, reference, result, initialBilling); service.ResponseQueue.Send(capsule); capsule = null; }
public static Hashtable GetActiveServices() { Hashtable hashtable = new Hashtable(); CDB DB = new CDB("GetActiveServices"); SqlDataReader reader = (SqlDataReader)DB.Execute("SUB_GetActiveSubscriptionServices", CDB.exmReturnTypes.RETURN_READER); while (reader.Read()) { SubscriptionService service = new SubscriptionService(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), (BillingFrequencies)reader.GetInt32(3), (BillingTimes)reader.GetInt32(4), reader.GetDecimal(5), reader.GetInt32(6), reader.GetInt32(7), reader.GetString(8), (Statuses)reader.GetInt32(9)); hashtable.Add(service.ID, service); } reader.Close(); reader = null; DB.Close(); DB = null; return(hashtable); }
private DateTime CalculateAndUpdateSubscriptionDateTimes(int subscriptionID, SubscriptionService service) { DateTime expiryDateTime = DateTime.MinValue; DateTime lastBillingDateTime = DateTime.MinValue; DateTime nextBillingDateTime = DateTime.MinValue; CDB DB = new CDB("Get Subscription Date - "); SqlDataReader reader = (SqlDataReader)DB.Execute("SUB_GetSubscriptionDateTimes " + subscriptionID.ToString(), CDB.exmReturnTypes.RETURN_READER); if (reader.Read()) { expiryDateTime = reader.IsDBNull(0) ? DateTime.MinValue : reader.GetDateTime(0); lastBillingDateTime = reader.IsDBNull(1) ? DateTime.MinValue : reader.GetDateTime(1); nextBillingDateTime = reader.IsDBNull(2) ? DateTime.MinValue : reader.GetDateTime(2); } reader.Close(); reader = null; DB.Close(); DB = null; if (expiryDateTime < DateTime.Now) { expiryDateTime = DateTime.Now; } switch (service.BillingFrequency) { case BillingFrequencies.Daily: expiryDateTime = expiryDateTime.AddDays(1D); break; case BillingFrequencies.Weekly: expiryDateTime = expiryDateTime.AddDays(7D); break; case BillingFrequencies.Monthly: expiryDateTime = expiryDateTime.AddMonths(1); break; } nextBillingDateTime = expiryDateTime; switch (service.BillingFrequency) { case BillingFrequencies.Weekly: case BillingFrequencies.Monthly: nextBillingDateTime = expiryDateTime.AddHours(-48D); break; default: nextBillingDateTime = expiryDateTime; break; } // This has been added to set all future billings @ 1AM nextBillingDateTime = new DateTime(nextBillingDateTime.Year, nextBillingDateTime.Month, nextBillingDateTime.Day, 00, 01, 01); UpdateSubscriptionDateTimes(subscriptionID, expiryDateTime, nextBillingDateTime, trackId); return(expiryDateTime); }
public SubscriptionHandler(int subscriptionServiceID) { this.service = new SubscriptionService(subscriptionServiceID); }