public static TemplateVariables GetVariables(int requestId) { TemplateVariables vars = new TemplateVariables(); using (IDataReader reader = Get(requestId, true, true)) { if (reader != null) { if (reader.Read()) { vars["RequestID"] = requestId.ToString(); vars["CompanyName"] = reader["CompanyName"].ToString(); vars["SizeOfGroup"] = reader["SizeOfGroup"].ToString(); vars["Description"] = reader["Description"].ToString(); vars["Domain"] = reader["Domain"].ToString(); vars["FirstName"] = reader["FirstName"].ToString(); vars["LastName"] = reader["LastName"].ToString(); vars["Email"] = reader["Email"].ToString(); vars["Phone"] = reader["Phone"].ToString(); vars["Country"] = reader["Country"].ToString(); vars["Login"] = reader["Login"].ToString(); vars["Password"] = reader["Password"].ToString(); vars["ResellerTitle"] = reader["ResellerTitle"].ToString(); vars["XML"] = reader["XML"].ToString(); vars["RequestGUID"] = reader["GUID"].ToString(); vars["Locale"] = reader["Locale"].ToString(); vars["Referrer"] = reader["Referrer"].ToString(); } } } return(vars); }
public static TemplateVariables GetVariables(int requestId) { TemplateVariables vars = new TemplateVariables(); using (IDataReader reader = Get(requestId, true, true)) { if (reader != null) { if (reader.Read()) { vars["RequestID"] = requestId.ToString(); vars["CompanyName"] = reader["CompanyName"].ToString(); vars["SizeOfGroup"] = reader["SizeOfGroup"].ToString(); vars["Description"] = reader["Description"].ToString(); vars["Domain"] = reader["Domain"].ToString(); vars["FirstName"] = reader["FirstName"].ToString(); vars["LastName"] = reader["LastName"].ToString(); vars["Email"] = reader["Email"].ToString(); vars["Phone"] = reader["Phone"].ToString(); vars["Country"] = reader["Country"].ToString(); vars["Login"] = reader["Login"].ToString(); vars["Password"] = reader["Password"].ToString(); vars["ResellerTitle"] = reader["ResellerTitle"].ToString(); vars["XML"] = reader["XML"].ToString(); vars["RequestGUID"] = reader["GUID"].ToString(); vars["Locale"] = reader["Locale"].ToString(); vars["Referrer"] = reader["Referrer"].ToString(); } } } return vars; }
public static void AddPayment(Guid companyUid, DateTime dt, decimal amount, decimal bonus, string orderNo, bool checkUnicity) { if (amount + bonus <= 0) { throw new ArgumentException("Wrong value", "amount"); } IConfigurator config = Configurator.Create(); ICompanyInfo company = config.GetCompanyInfo(companyUid.ToString()); if (company == null) { throw new ArgumentException(String.Concat("CompanyUid = ", companyUid, " doesn't exist.")); } if (checkUnicity && !string.IsNullOrEmpty(orderNo) && CheckPaymentOrderNo(companyUid, orderNo) > 0) { throw new Exception(String.Concat("Order # ", orderNo, " already registered.")); } bool newTran = DBHelper.BeginTransaction(); try { DBHelper.RunSP("ASP_PAYMENT_ADD", DBHelper.mp("@companyUid", SqlDbType.UniqueIdentifier, companyUid), DBHelper.mp("@dt", SqlDbType.DateTime, dt), DBHelper.mp("@amount", SqlDbType.Money, amount), DBHelper.mp("@bonus", SqlDbType.Money, bonus), DBHelper.mp("@orderNo", SqlDbType.NVarChar, 50, orderNo)); UpdateBalance(companyUid, amount + bonus); // Activate inactive company if (!company.IsActive) { DBHelper.RunSP("ASP_COMPANY_UPDATE_IS_ACTIVE", DBHelper.mp("@company_uid", SqlDbType.UniqueIdentifier, companyUid), DBHelper.mp("@is_active", SqlDbType.Bit, true)); config.ActivateCompany(companyUid.ToString(), true, false); } #region Change company type from trial to billable if (int.Parse(config.GetCompanyPropertyValue(companyUid.ToString(), CManage.keyCompanyType)) == (int)CompanyType.Trial) { bool tariffIsValid = false; int maxUsers = -1; int maxExternalUsers = -1; int maxDiskSpace = -1; AspSettings settings = AspSettings.Load(); if (settings.UseTariffs && settings.DefaultTariff > 0) { using (IDataReader reader = GetTariff(settings.DefaultTariff, 0)) { if (reader.Read()) { tariffIsValid = true; maxUsers = (int)reader["maxUsers"]; maxExternalUsers = (int)reader["maxExternalUsers"]; maxDiskSpace = (int)reader["maxHdd"]; } } } if (tariffIsValid) { config.SetCompanyPropertyValue(companyUid.ToString(), CManage.keyCompanyMaxUsers, maxUsers.ToString()); config.SetCompanyPropertyValue(companyUid.ToString(), CManage.keyCompanyMaxExternalUsers, maxExternalUsers.ToString()); config.SetCompanyPropertyValue(companyUid.ToString(), CManage.keyCompanyDatabaseSize, maxDiskSpace.ToString()); DBHelper.RunSP("ASP_COMPANY_UPDATE_TARIFF", DBHelper.mp("@companyUid", SqlDbType.UniqueIdentifier, companyUid), DBHelper.mp("@tariffId", SqlDbType.Int, settings.DefaultTariff)); } config.SetCompanyPropertyValue(companyUid.ToString(), CManage.keyCompanyType, ((int)CompanyType.Billable).ToString()); CManage.UpdateCompanyType(companyUid, (byte)CompanyType.Billable); } #endregion // Ensure, that the unpaid period is recalculated RecalculateBalance(); TemplateVariables vars = CManage.CompanyGetVariables(companyUid); if (!string.IsNullOrEmpty(vars["ContactEmail"])) { vars["Amount"] = amount.ToString("f"); vars["Bonus"] = bonus.ToString("f"); vars["Total"] = (amount + bonus).ToString("f"); CManage.SendEmail(vars["ContactEmail"], EmailType.ClientBalanceUp, vars); } DBHelper.Commit(newTran); } catch (Exception) { DBHelper.Rollback(newTran); throw; } }