Пример #1
0
        // logs an exception with relevant context data to the error table

        void LogException(Exception exception)
        {
            // try-catch because database itself could be down or Request context is unknown.

            try
            {
                GLCEmasModel db     = new GLCEmasModel();
                string       userId = null;
                try { userId = User.Identity.GetUserId(); /*CurrentUser.Id;*/ }
                catch { /* do nothing */ }

                // ** Prototype pattern. the Error object has it default values initialized

                var error = new Error
                {
                    UserId       = userId,
                    Exception    = exception.GetType().FullName,
                    ErrorDate    = DateTime.UtcNow,
                    Message      = exception.Message,
                    Everything   = exception.ToString(),
                    IpAddress    = HttpContext.Current.Request.UserHostAddress,
                    UserAgent    = HttpContext.Current.Request.UserAgent,
                    PathAndQuery = HttpContext.Current.Request.Url == null ? "" : HttpContext.Current.Request.Url.PathAndQuery,
                    HttpReferer  = HttpContext.Current.Request.UrlReferrer == null ? "" : HttpContext.Current.Request.UrlReferrer.PathAndQuery
                };

                //ArtContext.Errors.Insert(error);
                db.Error.Add(error);
                db.SaveChanges();
            }
            catch { /* do nothing, or send email to webmaster*/ }
        }
Пример #2
0
 protected static List <string> GetCountryList()
 {
     using (var db = new GLCEmasModel())
     {
         return(db.AddressGuide
                .Select(x => new { x.Priority, x.Country })
                .Distinct().OrderBy(a => a.Priority)
                .ThenBy(x => x.Country).Select(b => b.Country).ToList());
     }
 }
Пример #3
0
        private static List <SelectListItem> GetBankNames()
        {
            GLCEmasModel db = new GLCEmasModel();

            return((from tx in db.TermTaxonomy
                    join te in db.Term
                    on tx.TermId equals te.Id
                    where tx.TaxonomyId == (int)TaxonomyType.BankName && tx.CompanyId == Guid.Empty.ToString() && te.CompanyId == Guid.Empty.ToString() && te.TaxonomyId == (int)TaxonomyType.BankName
                    select new SelectListItem
            {
                Text = te.Name,
                Value = te.Id.ToString() + "|" + te.Name,
                //Selected = termId != 0 && termId == te.Id
            }).ToList().OrderBy(x => x.Text).ToList());
        }
Пример #4
0
 public EntityTermServices(GLCEmasModel db, string entityId, string companyId)
 {
     _entityId  = entityId;
     _companyId = companyId;
     _db        = db;
 }