public bool SendEmail(string username, string password, string subject, string fromaddress, string toaddress, string cc, string bcc, string body, bool isbodyhtml, string smtp) { if (username == ConfigurationManager.AppSettings["mailserviceuser"] && password == ConfigurationManager.AppSettings["mailservicepwd"]) { HarperLINQ.SimpleMail mail = new SimpleMail(); try { mail.bccemail = bcc; mail.body = body; mail.ccemail = cc; mail.datecreated = DateTime.Now; mail.fromemail = fromaddress; mail.isHtml = isbodyhtml; mail.ishtml = isbodyhtml; mail.smtpAddress = smtp; mail.subject = subject; mail.toemail = toaddress; using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { context.SimpleMails.InsertOnSubmit(mail); context.SubmitChanges(); } return(true); } catch { return(false); } } else { return(false); } }
public static SFG_ProdCode GetFromIntCode(string intcode) { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { return((from a in context.SFG_ProdCodes where a.IntCode == intcode select a).Single()); } }
public tbl_Customer(string username_or_emailaddress, bool isusername) { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { tbl_Customer customer; if (isusername) { this.cusUserName = username_or_emailaddress; customer = (from a in context.tbl_Customers where a.cusUserName == this.cusUserName select a).SingleOrDefault(); } else { this.cusEmail = username_or_emailaddress; customer = (from a in context.tbl_Customers where a.cusEmail == this.cusEmail select a).SingleOrDefault(); } if (customer != null) { SetData(customer); } var sfgid = (from a in context.SFG_CustomerNumbers where a.cusID == this.cusID select a.SFGCustNum).SingleOrDefault(); if (sfgid != null) { string s = sfgid.ToString(); this.SfgId = long.Parse(s); } } }
public void Save() { try { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { tbl_CustomerSource source = (from a in context.tbl_CustomerSources where a.csoCode == this.csoCode select a).SingleOrDefault(); this.csoCode = source == null ? null : source.csoCode; if (this.cusID > 0) { tbl_Customer customer = (from a in context.tbl_Customers where a.cusID == this.cusID select a).SingleOrDefault(); GetData(customer); context.SubmitChanges(); } else { context.tbl_Customers.InsertOnSubmit(this); context.SubmitChanges(); } } } catch (Exception ex) { throw new ObjectSaveException(ex.Message); } }
public ReferralOffer(string keycode_in, string pubcode_in) { try { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { ReferralOffer offer = (from a in context.ReferralOffers where a.keycode == keycode_in && a.pubcode == pubcode_in && a.isactive == true select a).SingleOrDefault(); if (offer != null) { SetData(offer); } } } catch (Exception ex) { LogEntry = new tbl_AppEventLog(string.Empty, "BusinessLogic", "DataLoadException", "Error loading tbl_ReferralOffer object", string.Format("keycode_in is '{0}', pubcode_in is '{1}'", new object[] { keycode_in, pubcode_in }), ex.Message, string.Empty, "Constructor: tbl_ReferralOffer(string keycode_in, string pubcode_in) "); LogEntry.Save(); throw new DataLoadException(ex.Message); } }
public static bool IsUserNameAvailable(string username, int?cusid) { int u = 0; using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { if (cusid.HasValue) { u = (from a in context.tbl_Customers where a.cusIsDeleted == false && (a.cusUserName == username || a.cusEmail == username || a.cusDisplayName == username) && a.cusID != cusid.Value select a).Count(); } else { u = (from a in context.tbl_Customers where a.cusIsDeleted == false && (a.cusUserName == username || a.cusEmail == username || a.cusDisplayName == username) select a).Count(); } } return(u > 0 ? false : true); }
public static List <string> GetRegions(string countryname) { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { List <string> response = new List <string>(); if (countryname.ToUpper() == "U.S.A.") { var states = (from a in context.States where a.staIsActive == true select a.staName); foreach (var state in states) { response.Add(state); } } else { var regions = (from a in context.Nodes where a.nodName == countryname join b in context.Relations on a.nodID equals b.nodParentID join c in context.Nodes on b.nodChildID equals c.nodID select c.nodName); foreach (var region in regions) { response.Add(region); } } return(response); } }
public void Save() { try { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { if (this.id > 0) { Referral referral = (from a in context.Referrals where a.id == this.id select a).SingleOrDefault(); GetData(referral); } else { context.Referrals.InsertOnSubmit(this); } context.SubmitChanges(); } } catch (Exception ex) { throw new ObjectSaveException(ex.Message); } }
private void RecordError(string method, string message1, Exception ex) { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { int col_len = 2500; string msg = ex.Message; if (msg.Length > col_len) { msg = msg.Substring(0, col_len); } string stack_trace = ex.StackTrace; if (stack_trace.Length > col_len) { stack_trace = stack_trace.Substring(0, col_len); } if (message1.Length > col_len) { message1 = message1.Substring(0, col_len); } string message2 = string.Format("Exception Message: {0}", msg); string message3 = string.Format("Exception Stack Trace: {0}", stack_trace); tbl_AppEventLog ael = new tbl_AppEventLog(); ael.aelAppName = "CustomerWebService"; ael.aelSection = method; ael.aelSeverity = "ERROR"; ael.aelEvent = "Unknown Error"; ael.aelMessage1 = message1.Length > 2500 ? message1.Substring(0, 2499) : message1; ael.aelMessage2 = message2.Length > 2500 ? message2.Substring(0, 2499) : message2; ael.aelMessage3 = message3.Length > 2500 ? message3.Substring(0, 2499) : message3; ael.aelDateCreated = DateTime.Now; context.tbl_AppEventLogs.InsertOnSubmit(ael); context.SubmitChanges(); } }
public void Save() { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { context.SimpleMails.InsertOnSubmit(this); context.SubmitChanges(); } }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="limit">If zero, defaults to 100</param> /// <returns></returns> public static List <tbl_AppEventLog> GetByUserName(string username, int limit) { limit = limit == 0 ? 100 : limit; List <tbl_AppEventLog> logs = new List <tbl_AppEventLog>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { logs = (from a in context.tbl_AppEventLogs where a.aelUserName == username select a).OrderByDescending(x => x.aelID).Take(limit).ToList <tbl_AppEventLog>(); } return(logs); }
public static List <string> GetEventNames() { List <string> eventnames = new List <string>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { eventnames = (from a in context.tbl_AppEventLogs select a.aelEvent).Distinct <string>().ToList <string>(); } eventnames.Sort(); return(eventnames); }
public static Prefix GetPrefixBySFGCode(string sfgcode) { Prefix prefix = new Prefix(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { prefix = (from a in context.Prefixes where a.sfgcode == sfgcode select a).SingleOrDefault(); } return(prefix); }
public static List <Prefix> GetPrefixes() { List <Prefix> prefixes = new List <Prefix>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { prefixes = (from a in context.Prefixes where a.displayname != null select a).ToList <Prefix>(); } return(prefixes); }
public static List <tbl_NetMembership> GetNetMemberships(int cusid) { List <tbl_NetMembership> subs = new List <tbl_NetMembership>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { subs = (from a in context.tbl_NetMemberships where a.cusID == cusid orderby a.nmbDateStart descending select a).ToList(); } return(subs); }
public static List <Suffix> GetSFGSuffixes() { List <Suffix> suffixes = new List <Suffix>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { suffixes = (from a in context.Suffixes where a.sfgcode != null && a.displayname != null select a).ToList <Suffix>(); } return(suffixes); }
public static List <ISO3166> GetCountries() { List <ISO3166> response = new List <ISO3166>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { response = (from a in context.ISO3166s where a.ParentId == null orderby a.DisplayName, a.Name select a).ToList(); } return(response); }
public static List <tbl_Customer> GetAllCustomers() { List <tbl_Customer> u = new List <tbl_Customer>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { u = (from a in context.tbl_Customers where a.cusIsDeleted == false && a.cusUserName != null && a.cusEncryptedPassword != null select a).ToList <tbl_Customer>(); } return(u); }
public static List <int> GetAllCusIds() { List <int> customers = new List <int>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { customers = (from a in context.tbl_Customers where a.cusIsDeleted == false //&& a.cusPassword != null && a.cusUserName != null select a.cusID).ToList <int>(); } return(customers); }
public static int CountCustomersWithPwdSfgidMembership() { int count; using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { count = (from a in context.tbl_Customers join b in context.SFG_CustomerNumbers on a.cusID equals b.cusID join c in context.tbl_NetMemberships on a.cusID equals c.cusID where a.cusPassword != null select a).Count(); } return(count); }
public static List <Referral> GetNonRedeemedList() { List <Referral> referrals = new List <Referral>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { referrals = (from a in context.Referrals where a.friendid == null && a.testrecord == false orderby a.id select a).ToList <Referral>(); } return(referrals); }
public void SaveSfgId() { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { try { SFG_CustomerNumber sfg = (from a in context.SFG_CustomerNumbers where a.cusID == this.cusID select a).Single(); sfg.SFGCustNum = this.SfgId.ToString(); context.SubmitChanges(); } catch { } } }
public static List <Country> GetCountries() { List <Country> response = new List <Country>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { var countries = (from a in context.Countries select a); foreach (var country in countries) { response.Add(country); } } return(response); }
public tbl_AddressCustomer(int id_in) { tbl_AddressCustomer address; using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { address = (from a in context.tbl_AddressCustomers where a.addID == id_in select a).SingleOrDefault(); } if (address != null) { SetData(address); } }
public void Save() { try { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { context.tbl_AppEventLogs.InsertOnSubmit(this); context.SubmitChanges(); } } catch (Exception ex) { throw new ObjectSaveException(ex.Message); } }
//public List<ISO3166> GetAll() { } //public List<ISO3166> GetAllOfType(GeographicType geographictype) { } public static List <ISO3166> GetRegions(string ParentAlpha2) { List <ISO3166> response = new List <ISO3166>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { response = (from a in context.ISO3166s join b in context.ISO3166s on a.ParentId equals b.Id where b.Alpha2 == ParentAlpha2 orderby a.DisplayWeight, a.DisplayName, a.Name select a).ToList(); } return(response); }
public static List <int> GetCustomersWithoutNewPwd() { List <int> customers = new List <int>(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { customers = (from a in context.tbl_Customers join b in context.SFG_CustomerNumbers on a.cusID equals b.cusID join c in context.tbl_NetMemberships on a.cusID equals c.cusID where (a.cusPassword == null || a.cusPassword.Trim() == string.Empty) && a.cusEncryptedPassword != null && a.cusIsDeleted == false select a.cusID).ToList <int>(); } return(customers); }
public static int CountCustomersWithoutMembership() { int count; using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { count = (from a in context.tbl_Customers join b in context.SFG_CustomerNumbers on a.cusID equals b.cusID into ab from c in ab.DefaultIfEmpty() where c == null && //no sfgid a.cusPassword != null select a).Count(); } return(count); }
public tbl_MembershipType(string mtyCode) { tbl_MembershipType membershiptype = new tbl_MembershipType(); using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { membershiptype = (from a in context.tbl_MembershipTypes where a.mtyCode == mtyCode select a).SingleOrDefault(); } if (membershiptype != null) { this.mtyCode = membershiptype.mtyCode; this.mtyGUID = membershiptype.mtyGUID; this.mtyName = membershiptype.mtyName; } }
//needed for C360 public void DeleteUser() { using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { tbl_Customer me = (from a in context.tbl_Customers where a.cusID == this.cusID select a).Single(); me.cusIsDeleted = true; me.cusArchiveEmail = me.cusEmail; me.cusArchiveUsername = me.cusUserName; me.cusArchiveDisplayName = me.cusDisplayName; me.cusEmail = string.Empty; me.cusUserName = string.Empty; me.cusDisplayName = string.Empty; context.SubmitChanges(); } }