public void Dispose() { if (this.DB.Database.Connection.State == System.Data.ConnectionState.Open) { this.DB.Database.Connection.Close(); } this.DB.Dispose(); this.DB = null; }
public string SaveProductInfo(FormCollection form) { bool status = form["Status"] == "Y" ? true : false; string content = form["contenttext"]; PublicMethodRepository.FilterXss(content); using (var db = new REDOXDB()) { ModelInitProperty saveModel = ModelInitProperty.NotSet; LISTEDITOR entity = db.LISTEDITOR.Where(s => s.OBJ_NAME == _actionName).FirstOrDefault(); if (entity == null) { entity = new LISTEDITOR { OBJ_NAME = _actionName, BUD_DT = DateTime.UtcNow.AddHours(8), BUD_ID = UserProvider.Instance.User.ID }; saveModel = ModelInitProperty.New; } else { saveModel = ModelInitProperty.FromDB; } entity.STATUS = status; entity.OBJ_CONTENT = content; entity.UP_DT = DateTime.UtcNow.AddHours(8); entity.UP_ID = UserProvider.Instance.User.ID; if (saveModel == ModelInitProperty.New) { db.LISTEDITOR.Add(entity); } else { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; } try { db.SaveChanges(); } catch (Exception ex) { throw ex; } } return(_actionName); }
public Dictionary <bool, string> GetProductInfo() { Dictionary <bool, string> result = new Dictionary <bool, string>(); using (var db = new REDOXDB()) { result = db.LISTEDITOR .Where(s => s.OBJ_NAME == _actionName) .ToDictionary(d => d.STATUS, d => d.OBJ_CONTENT); } if (result.Count > 0) { PublicMethodRepository.HtmlDecode(result.Values.First()); } return(result); }
public ActionResult NewsAdd() { NewsDetailsDataModel defaultModel = new NewsDetailsDataModel(); defaultModel.Data.BUD_DT = DateTime.UtcNow.AddHours(8); defaultModel.Data.HOME_PAGE_DISPLAY = true; using (var db = new REDOXDB()) { if (db.NEWS.Count() > 0) { defaultModel.Data.SQ = db.NEWS.Max(s => s.SQ) + 1; } else { defaultModel.Data.SQ = 1; } } return(View(defaultModel)); }
public override void OnException(ExceptionContext filterContext) { base.OnException(filterContext); Exception exception = filterContext.Exception; int logGuId = new System.Random().Next(0, 32767); LOGERR Log = new LOGERR(); Log.ERR_GID = logGuId; Log.ERR_SRC = exception.Source; Log.ERR_SMRY = string.Format("messages:{0} 。 innerException:{1}", exception.Message, exception.InnerException); Log.ERR_DESC = exception.StackTrace; Log.LOG_DTM = DateTime.UtcNow.AddHours(8); REDOXDB DB = new REDOXDB(); DB.LOGERR.Add(Log); DB.SaveChanges(); var typedResult = filterContext.Result as ViewResult; if (typedResult != null) { var tmpModel = typedResult.ViewData.Model; typedResult.ViewData = filterContext.Controller.ViewData; typedResult.ViewData.Model = tmpModel; typedResult.ViewData.Add("LogGuId", logGuId); filterContext.Result = typedResult; } //if (filterContext.HttpContext.Request.IsAjaxRequest()) //{ // var urlHelper = new UrlHelper(filterContext.RequestContext); // filterContext.HttpContext.Response.StatusCode = 500; // filterContext.Result = new JsonResult // { // JsonRequestBehavior = JsonRequestBehavior.AllowGet, // Data = new // { // filterContext.Exception.Message, // filterContext.Exception.StackTrace, // Error = "ErrorHandler", // LogOnUrl = urlHelper.Action("SignInFail", "SignIn") // } // }; // filterContext.ExceptionHandled = true; //} //else //{ // base.OnException(filterContext); // Exception exception = filterContext.Exception; // int logGuId = new System.Random().Next(0, 32767); // LOGERR Log = new LOGERR(); // Log.ERR_GID = logGuId; // Log.ERR_SRC = exception.Source; // Log.ERR_SMRY = string.Format("messages:{0} 。 innerException:{1}", exception.Message, exception.InnerException); // Log.ERR_DESC = exception.StackTrace; // Log.LOG_DTM = DateTime.UtcNow.AddHours(8); // DBEnergy DB = new DBEnergy(); // DB.LOGERR.Add(Log); // DB.SaveChanges(); // var typedResult = filterContext.Result as ViewResult; // if (typedResult != null) // { // var tmpModel = typedResult.ViewData.Model; // typedResult.ViewData = filterContext.Controller.ViewData; // typedResult.ViewData.Model = tmpModel; // typedResult.ViewData.Add("LogGuId", logGuId); // filterContext.Result = typedResult; // } //} }