예제 #1
0
 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);
     }
 }
예제 #2
0
 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());
     }
 }
예제 #3
0
 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);
         }
     }
 }
예제 #4
0
 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);
     }
 }
예제 #5
0
 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);
     }
 }
예제 #6
0
        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);
        }
예제 #7
0
 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);
     }
 }
예제 #8
0
 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();
     }
 }
예제 #10
0
 public void Save()
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         context.SimpleMails.InsertOnSubmit(this);
         context.SubmitChanges();
     }
 }
예제 #11
0
        /// <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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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);
        }
예제 #18
0
        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);
        }
예제 #19
0
        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);
        }
예제 #20
0
        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);
        }
예제 #21
0
        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);
        }
예제 #22
0
 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 { }
     }
 }
예제 #23
0
        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);
        }
예제 #24
0
        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);
            }
        }
예제 #25
0
 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);
     }
 }
예제 #26
0
        //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);
        }
예제 #27
0
        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);
        }
예제 #28
0
        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);
        }
예제 #29
0
        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;
            }
        }
예제 #30
0
 //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();
     }
 }