Advertisement
Guest User

Untitled

a guest
Feb 8th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.16 KB | None | 0 0
  1. public class Kiosk : IKiosk
  2. {
  3. //public DC_KIOSK_Properties GetKiosk(List<string> macIds, int locId, int corpId)
  4. //{
  5. // DC_KIOSK_Properties result = null;
  6. // ILogger logger = LogManager.GetCurrentClassLogger();
  7. // string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId);
  8.  
  9. // using (IDebitCardContext db = new DebitCardContext(connectionString))
  10. // {
  11. // result = Kiosk.GetKiosk(logger, db, macIds, locId, corpId);
  12. // }
  13.  
  14. // return result;
  15. //}
  16.  
  17. public DataTable GetKiosk(int locId, int corpId)
  18. {
  19.  
  20. SqlConnection connection = new SqlConnection(SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId));
  21. using (SqlCommand command = new SqlCommand("ST_DC_KIOSK_GetSettings", connection))
  22. {
  23. command.CommandType = CommandType.StoredProcedure;
  24.  
  25. command.Parameters["@LocId"].Value = locId;
  26. command.Parameters["@CorpId"].Value = corpId;
  27. // add any extra parameters and then:
  28.  
  29. try
  30. {
  31. connection.Open();
  32. SqlDataReader dr = command.ExecuteReader();
  33. DataTable dt = new DataTable();
  34. dt.Load(dr);
  35. return dt;
  36. }
  37. catch { return null; }
  38. }
  39. }
  40.  
  41. public bool UpdateKiosk1(string dto)
  42. {
  43. return true;
  44. }
  45.  
  46. public bool UpdateKiosk(KIOSK_Properties dto)
  47. {
  48. return true;
  49. //bool result = false;
  50. //ILogger logger = LogManager.GetCurrentClassLogger();
  51. //string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, dto.CorpId);
  52.  
  53. //using (entityDebitCard dbContext = Helper.GetEntityDebitCard(connectionString))
  54. //{
  55. // try
  56. // {
  57. // int val = dbContext.ST_DC_KIOSK_SettingsUpdate(dto.LocId, dto.CorpId, dto.EmpId,
  58. // dto.FirstNameEnabled, dto.FirstNameMandatory, dto.LastNameEnabled, dto.LastNameMandatory,
  59. // dto.EmailEnabled, dto.EmailMandatory, dto.PhoneEnabled, dto.PhoneMandatory,
  60. // dto.DateOfBirthEnabled, dto.DateOfBirthMandatory, dto.PostalCodeEnabled, dto.PostalCodeMandatory,
  61. // dto.GenderEnabled, dto.GenderMandatory,
  62. // dto.DataCenterIp, dto.TransactionServerIPPrimary, dto.TransactionServerIPSecondary,
  63. // dto.SMTPAddress, dto.SMTPUser, dto.SMTPPassword, dto.PhoneMask,
  64. // dto.DateOfBirthMask, dto.PostalCodeMask, dto.PresentationLang, dto.VirtualKeyboardLanguages, dto.KioskTimeout);
  65.  
  66. // dbContext.SaveChanges();
  67. // result = true;
  68. // }
  69. // catch (Exception ex)
  70. // {
  71. // logger.Debug(ex.Message);
  72. // }
  73.  
  74. // return result;
  75. //}
  76.  
  77. }
  78. //public static bool UpdateKiosk(ILogger logger, entityDebitCard dbContext, string connectionString, List<string> macIds, DC_KIOSK_Properties dto)
  79. //{
  80. // bool result = false;
  81.  
  82. // try
  83. // {
  84. // int val = dbContext.ST_DC_KIOSK_SettingsUpdate(dto.LocId, dto.CorpId, dto.EmpId,
  85. // dto.FirstNameEnabled, dto.FirstNameMandatory, dto.LastNameEnabled, dto.LastNameMandatory,
  86. // dto.EmailEnabled, dto.EmailMandatory, dto.PhoneEnabled, dto.PhoneMandatory,
  87. // dto.DateOfBirthEnabled, dto.DateOfBirthMandatory, dto.PostalCodeEnabled, dto.PostalCodeMandatory,
  88. // dto.GenderEnabled, dto.GenderMandatory,
  89. // dto.DataCenterIp, dto.TransactionServerIPPrimary, dto.TransactionServerIPSecondary,
  90. // dto.SMTPAddress, dto.SMTPUser, dto.SMTPPassword, dto.PhoneMask,
  91. // dto.DateOfBirthMask, dto.PostalCodeMask, dto.PresentationLang, dto.VirtualKeyboardLanguages, dto.KioskTimeout);
  92.  
  93. // dbContext.SaveChanges();
  94. // result = true;
  95. // }
  96. // catch (Exception ex)
  97. // {
  98. // logger.Debug(ex.Message);
  99. // }
  100.  
  101. // return result;
  102. //}
  103.  
  104. //Note: It appears CardNumber and AccountNumber are the same thing
  105. public bool VerifyEmail(List<string> macIds, int locId, int corpId, long acctNumber, string email)
  106. {
  107. bool result = false;
  108. ILogger logger = LogManager.GetCurrentClassLogger();
  109. string connectionString = SqlManager.FetchConnectionString(SqlManager.CUSTOMER_INFO, corpId);
  110.  
  111. using (entityCustomerInfo db = Helper.GetEntityCustomerInfo(connectionString))
  112. {
  113. result = RunVerifyEmail(logger, db, macIds, locId, corpId, acctNumber, email);
  114. }
  115.  
  116. return result;
  117. }
  118.  
  119. public bool RunVerifyEmail(ILogger logger, entityCustomerInfo dbContext, List<string> macIds, int locId, int corpId, long acctNumber, string email)
  120. {
  121. bool result = false;
  122.  
  123. try
  124. {
  125. var cardNumber = new SqlParameter("@CardNumber", acctNumber);
  126. var thisEmail = new SqlParameter("@Email", email);
  127. dbContext.Database.ExecuteSqlCommand("exec ST_CM_VerifyEmail @CardNumber, @Email", cardNumber, thisEmail);
  128.  
  129. result = true;
  130. }
  131. catch (Exception ex)
  132. {
  133. logger.Debug(ex.Message);
  134. }
  135.  
  136. return result;
  137. }
  138.  
  139. 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)
  140. {
  141. string result = string.Empty;
  142. ILogger logger = LogManager.GetCurrentClassLogger();
  143. string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId);
  144.  
  145. using (entityDebitCard db = Helper.GetEntityDebitCard(connectionString))
  146. {
  147. result = Kiosk.EmailInsert(logger, db, macIds, locId, corpId, emailAddress, firstName, lastName, frequency, service, dayofWeek, initialSleep, text, empID);
  148. }
  149.  
  150. return result;
  151. }
  152. 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)
  153. {
  154. List<long> corpIds = ServiceMethods.GetCorpIds(macIds);
  155. List<string> conStrings = ServiceMethods.GetConnectionStrings(corpIds);
  156.  
  157. if (corpIds == null || !(corpIds.Count > 0))
  158. {
  159. string macString = macIds.Aggregate((i,j) => i+string.Format("MAC ID: {0}{1}", j.ToString(), System.Environment.NewLine));
  160. string message = string.Format("Connection string was null{0}{1}", System.Environment.NewLine, macString);
  161. logger.Debug(message);
  162. return null;
  163. }
  164. if (conStrings == null || !(conStrings.Count > 0))
  165. {
  166. return null;
  167. }
  168.  
  169. return ServiceMethods.EmailInsert(
  170. logger,
  171. dbContext,
  172. ConfigurationManager.AppSettings["smtpAddress"].ToString(),
  173. int.Parse(ConfigurationManager.AppSettings["smtpPort"].ToString()),
  174. ConfigurationManager.AppSettings["smtpUserName"].ToString(),
  175. ConfigurationManager.AppSettings["smtpDisplayName"].ToString(),
  176. ConfigurationManager.AppSettings["smtpPass"].ToString(),
  177. locId,
  178. corpId,
  179. emailAddress,
  180. firstName,
  181. lastName,
  182. frequency,
  183. service,
  184. dayofWeek,
  185. initialSleep,
  186. text,
  187. empID);
  188. }
  189.  
  190. public bool SendVerificationEmail(List<string> macIds, int locId, int corpId, long acctNumber, string toEmail)
  191. {
  192. bool result = false;
  193. ILogger logger = LogManager.GetCurrentClassLogger();
  194. string connectionString = SqlManager.FetchConnectionString(SqlManager.DEBITCARD_DATA, corpId);
  195. result = Kiosk.SendVerificationEmail(logger, macIds, locId, corpId, acctNumber, toEmail);
  196.  
  197. return result;
  198. }
  199. public static bool SendVerificationEmail(ILogger logger, List<string> macIds, int locId, int corpId, long acctNumber, string toEmail)
  200. {
  201. bool result = false;
  202. string link = ConfigurationManager.AppSettings["link"].ToString();
  203. 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>";
  204.  
  205. string emailSubject = ConfigurationManager.AppSettings["emailSubject"].ToString();
  206. string smtpClient = ConfigurationManager.AppSettings["smtpClient"].ToString();
  207. string smtpAddress = ConfigurationManager.AppSettings["smtpAddress"].ToString();
  208. string smtpAddressDisplay = ConfigurationManager.AppSettings["smtpDisplayName"].ToString();
  209. string smtpPort = ConfigurationManager.AppSettings["smtpPort"].ToString();
  210. string smtpUser = ConfigurationManager.AppSettings["smtpUser"].ToString();
  211. string smtpPass = ConfigurationManager.AppSettings["smtpPassword"].ToString();
  212.  
  213. result = ServiceMethods.SendVerificationEmail(
  214. logger,
  215.  
  216. toEmail,
  217. emailSubject,
  218. emailBody,
  219. smtpClient,
  220. smtpAddress,
  221. smtpAddressDisplay,
  222. int.Parse(smtpPort),
  223.  
  224. smtpUser,
  225. smtpPass);
  226.  
  227. return result;
  228. }
  229.  
  230.  
  231. }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement