//============================================================================ public static UserLimit GetLimitModel(UserLimit limit) { using (var cn = new MySqlConnection(sqlconnectionString)) { cn.Open(); IEnumerable <UserLimit> i = cn.Query <UserLimit>(@" select * from AspNetLimit where UserId =@UserId and Category=@Category", limit); cn.Close(); return(i.FirstOrDefault()); } }
public ActionResult SetGlobalEmailLimit() { UserLimit limit = SUBLL.GetLimitModel(new UserLimit { Category = 3, UserId = "0" }); if (limit == null) { limit = new UserLimit() { AccessNo = "20000,20,20000" }; } return(View(limit)); }
/// <summary> /// Gets the hash code for this object. /// </summary> /// <returns> /// The hash code for this object. /// </returns> /// <remarks> /// * CA2218: /// * If two objects are equal in value based on the Equals override, they must both return the same value for calls /// to GetHashCode. /// * GetHashCode must be overridden whenever Equals is overridden. /// * It is fine if the value overflows. /// </remarks> public override int GetHashCode() { int result = GlobalId.GetHashCode() + ParentDealId.GetHashCode() + ProviderId.GetHashCode() + MerchantId.GetHashCode() + ProviderCategory.GetHashCode() + StartDate.GetHashCode() + EndDate.GetHashCode() + Amount.GetHashCode() + Count.GetHashCode() + UserLimit.GetHashCode() + MinimumPurchase.GetHashCode() + MaximumDiscount.GetHashCode() + DealStatusId.GetHashCode(); if (MerchantName != null) { result += MerchantName.GetHashCode(); } if (Currency != null) { result += Currency.GetHashCode(); } if (DiscountSummary != null) { result += DiscountSummary.GetHashCode(); } foreach (PartnerDealInfo partnerDealInfo in PartnerDealInfoList) { result += partnerDealInfo.GetHashCode(); } if (DayTimeRestrictions != null) { result += DayTimeRestrictions.GetHashCode(); } return(result); }
public ActionResult SetSysEmailLimitForUpdate(string id) { ViewData["id"] = id; UserLimit limit = SUBLL.GetLimitModel(new UserLimit { Category = 1, UserId = id }); Dictionary <int, string> dic = new Dictionary <int, string>(); if (limit == null || string.IsNullOrEmpty(limit.AccessNo)) { limit = new UserLimit(); limit.AccessNo = ","; dic.Add(1, ""); dic.Add(2, ""); dic.Add(3, ""); dic.Add(4, ""); dic.Add(5, ""); dic.Add(6, ""); } else { string lim = limit.AccessNo; // 1:1,2:22,3:,4: string[] strs = lim.Split(','); for (int i = 0; i < strs.Length; i++) { string[] s = strs[i].Split(':'); dic.Add(Convert.ToInt32(s[0]), s[1]); } limit.AccessNo = "," + limit.AccessNo.Trim(','); } ViewData["dic"] = dic; return(View(limit)); }
public static string GenerateTestToken( LicenseType licenseType, String productId, UserLimit userLimit, ExpirationPeriod expirationDays, String purchaserId) { //Note that the AssetId matches that of the Cheezburgers app on the marketplace. //This is just for TEST purposes so that the storefront URL takes you to a valid app page string hardCodedBaseToken = "<r v=\"0\"><t aid=\"WA103524926\" did=\"{3F47392A-2308-4FC6-BF24-740626612B26}\" ad=\"2012-06-19T21:48:56Z\" te=\"2112-07-15T23:47:42Z\" sd=\"2012-02-01\" test=\"true\"/><d>449JFz+my0wNoCm0/h+Ci9DsF/W0Q8rqEBqjpe44KkY=</d></r>"; string userLimitString = string.Empty; switch (userLimit) { case UserLimit.Ten: userLimitString = "10"; break; case UserLimit.Twenty: userLimitString = "20"; break; case UserLimit.Unlimited: userLimitString = "Unlimited"; break; } int expirationDaysNumber = 0; switch (expirationDays) { case ExpirationPeriod.Month: expirationDaysNumber = 30; break; case ExpirationPeriod.Unlimited: expirationDaysNumber = 9999; break; default: expirationDaysNumber = -1; break; } string tokenXml = hardCodedBaseToken; tokenXml = AddAttributesToToken(tokenXml, "pid", productId); tokenXml = AddAttributesToToken(tokenXml, "et", UppercaseFirst(licenseType.ToString())); tokenXml = AddAttributesToToken(tokenXml, "cid", purchaserId); //Set user limit if (licenseType == LicenseType.Free) { tokenXml = AddAttributesToToken(tokenXml, "ts", "0"); } else { tokenXml = AddAttributesToToken(tokenXml, "ts", userLimitString); } //Set site license == unlimited users if (userLimitString == "Unlimited") { tokenXml = AddAttributesToToken(tokenXml, "sl", "true"); } else { tokenXml = AddAttributesToToken(tokenXml, "sl", "false"); } //Set expiration (only supported for Trials) if (licenseType == LicenseType.Trial) { DateTime expirationDate; if (expirationDaysNumber == -1) { //expired token expirationDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(10)); } else if (expirationDaysNumber == 9999) { //Unlimited trial expirationDate = DateTime.MaxValue; } else { //today + the selected number of days expirationDate = DateTime.UtcNow.AddDays(expirationDaysNumber); } tokenXml = AddAttributesToToken(tokenXml, "ed", expirationDate.ToString("o")); } return(tokenXml); }
public static UserLimit GetLimitModel(UserLimit limit) { return(DAL.SUDAL.GetLimitModel(limit)); }
public static string GenerateTestToken( LicenseType licenseType, String productId, UserLimit userLimit, ExpirationPeriod expirationDays, String purchaserId) { //Note that the AssetId matches that of the Cheezburgers app on the marketplace. //This is just for TEST purposes so that the storefront URL takes you to a valid app page string hardCodedBaseToken = "<r v=\"0\"><t aid=\"WA103524926\" did=\"{3F47392A-2308-4FC6-BF24-740626612B26}\" ad=\"2012-06-19T21:48:56Z\" te=\"2112-07-15T23:47:42Z\" sd=\"2012-02-01\" test=\"true\"/><d>449JFz+my0wNoCm0/h+Ci9DsF/W0Q8rqEBqjpe44KkY=</d></r>"; string userLimitString = string.Empty; switch (userLimit){ case UserLimit.Ten: userLimitString = "10"; break; case UserLimit.Twenty: userLimitString = "20"; break; case UserLimit.Unlimited: userLimitString = "Unlimited"; break; } int expirationDaysNumber = 0; switch (expirationDays) { case ExpirationPeriod.Month: expirationDaysNumber = 30; break; case ExpirationPeriod.Unlimited: expirationDaysNumber = 9999; break; default: expirationDaysNumber = -1; break; } string tokenXml = hardCodedBaseToken; tokenXml = AddAttributesToToken(tokenXml, "pid", productId); tokenXml = AddAttributesToToken(tokenXml, "et", UppercaseFirst(licenseType.ToString())); tokenXml = AddAttributesToToken(tokenXml, "cid", purchaserId); //Set user limit if (licenseType == LicenseType.Free) { tokenXml = AddAttributesToToken(tokenXml, "ts", "0"); } else { tokenXml = AddAttributesToToken(tokenXml, "ts", userLimitString); } //Set site license == unlimited users if (userLimitString == "Unlimited") { tokenXml = AddAttributesToToken(tokenXml, "sl", "true"); } else { tokenXml = AddAttributesToToken(tokenXml, "sl", "false"); } //Set expiration (only supported for Trials) if (licenseType == LicenseType.Trial) { DateTime expirationDate; if (expirationDaysNumber == -1) { //expired token expirationDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(10)); } else if (expirationDaysNumber == 9999) { //Unlimited trial expirationDate = DateTime.MaxValue; } else { //today + the selected number of days expirationDate = DateTime.UtcNow.AddDays(expirationDaysNumber); } tokenXml = AddAttributesToToken(tokenXml, "ed", expirationDate.ToString("o")); } return tokenXml; }