Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Kiosk : IKiosk
- {
- //public DC_KIOSK_Properties GetKiosk(List<string> macIds, int locId, int corpId)
- //{
- // DC_KIOSK_Properties result = null;
- // ILogger logger = LogManager.GetCurrentClassLogger();
- // string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId);
- // using (IDebitCardContext db = new DebitCardContext(connectionString))
- // {
- // result = Kiosk.GetKiosk(logger, db, macIds, locId, corpId);
- // }
- // return result;
- //}
- public DataTable GetKiosk(int locId, int corpId)
- {
- SqlConnection connection = new SqlConnection(SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId));
- using (SqlCommand command = new SqlCommand("ST_DC_KIOSK_GetSettings", connection))
- {
- command.CommandType = CommandType.StoredProcedure;
- command.Parameters["@LocId"].Value = locId;
- command.Parameters["@CorpId"].Value = corpId;
- // add any extra parameters and then:
- try
- {
- connection.Open();
- SqlDataReader dr = command.ExecuteReader();
- DataTable dt = new DataTable();
- dt.Load(dr);
- return dt;
- }
- catch { return null; }
- }
- }
- public bool UpdateKiosk1(string dto)
- {
- return true;
- }
- public bool UpdateKiosk(KIOSK_Properties dto)
- {
- return true;
- //bool result = false;
- //ILogger logger = LogManager.GetCurrentClassLogger();
- //string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, dto.CorpId);
- //using (entityDebitCard dbContext = Helper.GetEntityDebitCard(connectionString))
- //{
- // try
- // {
- // int val = dbContext.ST_DC_KIOSK_SettingsUpdate(dto.LocId, dto.CorpId, dto.EmpId,
- // dto.FirstNameEnabled, dto.FirstNameMandatory, dto.LastNameEnabled, dto.LastNameMandatory,
- // dto.EmailEnabled, dto.EmailMandatory, dto.PhoneEnabled, dto.PhoneMandatory,
- // dto.DateOfBirthEnabled, dto.DateOfBirthMandatory, dto.PostalCodeEnabled, dto.PostalCodeMandatory,
- // dto.GenderEnabled, dto.GenderMandatory,
- // dto.DataCenterIp, dto.TransactionServerIPPrimary, dto.TransactionServerIPSecondary,
- // dto.SMTPAddress, dto.SMTPUser, dto.SMTPPassword, dto.PhoneMask,
- // dto.DateOfBirthMask, dto.PostalCodeMask, dto.PresentationLang, dto.VirtualKeyboardLanguages, dto.KioskTimeout);
- // dbContext.SaveChanges();
- // result = true;
- // }
- // catch (Exception ex)
- // {
- // logger.Debug(ex.Message);
- // }
- // return result;
- //}
- }
- //public static bool UpdateKiosk(ILogger logger, entityDebitCard dbContext, string connectionString, List<string> macIds, DC_KIOSK_Properties dto)
- //{
- // bool result = false;
- // try
- // {
- // int val = dbContext.ST_DC_KIOSK_SettingsUpdate(dto.LocId, dto.CorpId, dto.EmpId,
- // dto.FirstNameEnabled, dto.FirstNameMandatory, dto.LastNameEnabled, dto.LastNameMandatory,
- // dto.EmailEnabled, dto.EmailMandatory, dto.PhoneEnabled, dto.PhoneMandatory,
- // dto.DateOfBirthEnabled, dto.DateOfBirthMandatory, dto.PostalCodeEnabled, dto.PostalCodeMandatory,
- // dto.GenderEnabled, dto.GenderMandatory,
- // dto.DataCenterIp, dto.TransactionServerIPPrimary, dto.TransactionServerIPSecondary,
- // dto.SMTPAddress, dto.SMTPUser, dto.SMTPPassword, dto.PhoneMask,
- // dto.DateOfBirthMask, dto.PostalCodeMask, dto.PresentationLang, dto.VirtualKeyboardLanguages, dto.KioskTimeout);
- // dbContext.SaveChanges();
- // result = true;
- // }
- // catch (Exception ex)
- // {
- // logger.Debug(ex.Message);
- // }
- // return result;
- //}
- //Note: It appears CardNumber and AccountNumber are the same thing
- public bool VerifyEmail(List<string> macIds, int locId, int corpId, long acctNumber, string email)
- {
- bool result = false;
- ILogger logger = LogManager.GetCurrentClassLogger();
- string connectionString = SqlManager.FetchConnectionString(SqlManager.CUSTOMER_INFO, corpId);
- using (entityCustomerInfo db = Helper.GetEntityCustomerInfo(connectionString))
- {
- result = RunVerifyEmail(logger, db, macIds, locId, corpId, acctNumber, email);
- }
- return result;
- }
- public bool RunVerifyEmail(ILogger logger, entityCustomerInfo dbContext, List<string> macIds, int locId, int corpId, long acctNumber, string email)
- {
- bool result = false;
- try
- {
- var cardNumber = new SqlParameter("@CardNumber", acctNumber);
- var thisEmail = new SqlParameter("@Email", email);
- dbContext.Database.ExecuteSqlCommand("exec ST_CM_VerifyEmail @CardNumber, @Email", cardNumber, thisEmail);
- result = true;
- }
- catch (Exception ex)
- {
- logger.Debug(ex.Message);
- }
- return result;
- }
- public string EmailInsert(List<string> macIds, int locId, int corpId, string emailAddress, string firstName, string lastName, int frequency, int service, int dayofWeek, int initialSleep, string text, int empID)
- {
- string result = string.Empty;
- ILogger logger = LogManager.GetCurrentClassLogger();
- string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId);
- using (entityDebitCard db = Helper.GetEntityDebitCard(connectionString))
- {
- result = Kiosk.EmailInsert(logger, db, macIds, locId, corpId, emailAddress, firstName, lastName, frequency, service, dayofWeek, initialSleep, text, empID);
- }
- return result;
- }
- public static string EmailInsert(ILogger logger, entityDebitCard dbContext, List<string> macIds, int locId, int corpId, string emailAddress, string firstName, string lastName, int frequency, int service, int dayofWeek, int initialSleep, string text, int empID)
- {
- List<long> corpIds = ServiceMethods.GetCorpIds(macIds);
- List<string> conStrings = ServiceMethods.GetConnectionStrings(corpIds);
- if (corpIds == null || !(corpIds.Count > 0))
- {
- string macString = macIds.Aggregate((i,j) => i+string.Format("MAC ID: {0}{1}", j.ToString(), System.Environment.NewLine));
- string message = string.Format("Connection string was null{0}{1}", System.Environment.NewLine, macString);
- logger.Debug(message);
- return null;
- }
- if (conStrings == null || !(conStrings.Count > 0))
- {
- return null;
- }
- return ServiceMethods.EmailInsert(
- logger,
- dbContext,
- ConfigurationManager.AppSettings["smtpAddress"].ToString(),
- int.Parse(ConfigurationManager.AppSettings["smtpPort"].ToString()),
- ConfigurationManager.AppSettings["smtpUserName"].ToString(),
- ConfigurationManager.AppSettings["smtpDisplayName"].ToString(),
- ConfigurationManager.AppSettings["smtpPass"].ToString(),
- locId,
- corpId,
- emailAddress,
- firstName,
- lastName,
- frequency,
- service,
- dayofWeek,
- initialSleep,
- text,
- empID);
- }
- public bool SendVerificationEmail(List<string> macIds, int locId, int corpId, long acctNumber, string toEmail)
- {
- bool result = false;
- ILogger logger = LogManager.GetCurrentClassLogger();
- string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId);
- result = Kiosk.SendVerificationEmail(logger, macIds, locId, corpId, acctNumber, toEmail);
- return result;
- }
- public static bool SendVerificationEmail(ILogger logger, List<string> macIds, int locId, int corpId, long acctNumber, string toEmail)
- {
- bool result = false;
- string link = ConfigurationManager.AppSettings["link"].ToString();
- string emailBody = "<p>Thank you for registering. Please verify your email by clicking this <a href='"+link+"?a=" + acctNumber+"&l="+locId+"&c="+corpId+"&e="+toEmail+"'>link</a></p>";
- string emailSubject = ConfigurationManager.AppSettings["emailSubject"].ToString();
- string smtpClient = ConfigurationManager.AppSettings["smtpClient"].ToString();
- string smtpAddress = ConfigurationManager.AppSettings["smtpAddress"].ToString();
- string smtpAddressDisplay = ConfigurationManager.AppSettings["smtpDisplayName"].ToString();
- string smtpPort = ConfigurationManager.AppSettings["smtpPort"].ToString();
- string smtpUser = ConfigurationManager.AppSettings["smtpUser"].ToString();
- string smtpPass = ConfigurationManager.AppSettings["smtpPassword"].ToString();
- result = ServiceMethods.SendVerificationEmail(
- logger,
- toEmail,
- emailSubject,
- emailBody,
- smtpClient,
- smtpAddress,
- smtpAddressDisplay,
- int.Parse(smtpPort),
- smtpUser,
- smtpPass);
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement