Example #1
0
 public ActionResult NewsDetail(int id)
 {
     using (var db = new yxbonDbContext())
     {
         var model = db.NewsList.SingleOrDefault(o => o.ID == id);
         return View(model);
     }
 }
Example #2
0
 public ActionResult AddComment(CustomerComment model)
 {
     using (var db = new yxbonDbContext())
     {
         model.CommentTime = DateTime.Now;
         model.IsDelete = 0;
         db.CustomerComment.Add(model);
         db.SaveChanges();
         return Json(true, JsonRequestBehavior.AllowGet);
     }
 }
Example #3
0
        private bool CheckAuthorLogon(UserInfo user)
        {

            using (yxbonDbContext con = new yxbonDbContext())
            {
                var curUser = con.Users.Single(o => o.UserLogon == user.UserLogon && o.UserPassword == user.UserPassword);
                if (curUser != null)
                    return true;
                else
                    return false;
            }
        }
Example #4
0
 public ActionResult GetTopNews()
 {
     try
     {
         using (var db = new yxbonDbContext())
         {
             List<NewsList> news = db.NewsList.Where(o => o.IsDeleted == 0).OrderByDescending(i => i.NewsDate).Take(7).ToList<NewsList>();
             return Json(news, JsonRequestBehavior.AllowGet);
         }
     }
     catch
     {
         return null;
     }
 }
Example #5
0
        public ActionResult Loginning(UserInfo user)
        {
            try
            {

                using (yxbonDbContext con = new yxbonDbContext())
                {
                    var md5 = EasyEncryption.MD5.ComputeMD5Hash("ddd");
                    //auth
                    var authString = "";
                    var password = "******";
                    var authKey = "IGwRDzLAr0BCQ6jvIGwRDzLAr0BCQ6jv";
                    //var encryptByte = EasyEncryption.AesThenHmac.SimpleEncrypt(message, Encoding.GetEncoding("utf-8").GetBytes(password), Encoding.GetEncoding("utf-8").GetBytes(authKey));
                    //var result = EasyEncryption.AesThenHmac.SimpleDecrypt(encryptByte, Encoding.GetEncoding("utf-8").GetBytes(password), Encoding.GetEncoding("utf-8").GetBytes(authKey));

                    var logonuser = con.Users.Single(o => o.UserLogon == user.UserLogon && o.UserPassword == user.UserPassword);
                    if (logonuser != null)
                    {
                        authString = logonuser.UserLogon + "&" + logonuser.UserPassword;

                        //授权码
                        var encryptString = EasyEncryption.AesThenHmac.SimpleEncryptWithPassword(authString, SecurityUnity.AuthPassword);
                        //var result2 = EasyEncryption.AesThenHmac.SimpleDecryptWithPassword(encryptString, SecurityUnity.AuthPassword);


                        HttpCookie authCookie = new HttpCookie("AuthToken");
                        //authCookie.Expires = DateTime.Now.AddHours(12);
                        authCookie.Value = encryptString;

                        System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);

                        return RedirectToAction("Index");

                    }
                    else
                    {
                        return RedirectToAction("Index");
                    }
                }
            }
            catch (Exception)
            {

                return RedirectToAction("Logon", "CMSMain");
            }

        }
Example #6
0
        public ActionResult IndexNew()
        {
            using (var db = new yxbonDbContext())
            {
                //首页显示的新闻类型
                int[] newstypes = new int[] { 1, 2 };

                List<NewsList> news = db.NewsList.Where(o => o.IsDeleted == 0 && newstypes.Contains(o.NewsType)).OrderByDescending(i => i.NewsDate).Take(5).ToList<NewsList>();

                List<NewsList> newsnotice = db.NewsList.Where(o => o.IsDeleted == 0 && o.NewsType == 3).OrderByDescending(i => i.NewsDate).Take(5).ToList<NewsList>();

                ViewData["news"] = news;
                ViewData["newsnotice"] = newsnotice;
            }

            return View();
        }
Example #7
0
        public ActionResult GetPageNewsList(int rows, int page, int newstype)
        {
            using (yxbonDbContext con = new yxbonDbContext())
            {
                long recordCount = 0;

                string newsTitle = Request["NewsTitle"] != null ? Request["NewsTitle"].ToString() : "";
                string date1 = Request["date1"] != null ? Request["date1"].ToString() : "";
                string date2 = Request["date2"] != null ? Request["date2"].ToString() : "";
                DateTime ndate1 = !string.IsNullOrWhiteSpace(date1) ? DateTime.Parse(date1) : DateTime.MinValue;
                DateTime ndate2 = !string.IsNullOrWhiteSpace(date2) ? DateTime.Parse(date2) : DateTime.MaxValue;


                Func<NewsList, bool> where = o => (o.NewsType == newstype && o.IsDeleted == 0);
                Func<NewsList, DateTime> order = o => o.NewsDate;
                var list = con.GetListByPage(rows, page, ref recordCount, where, false, order).ToList();

                Dictionary<string, object> grid = new Dictionary<string, object>();
                grid.Add("total", recordCount);
                grid.Add("rows", list);
                return Json(grid, JsonRequestBehavior.AllowGet);
            }
        }
Example #8
0
        public ActionResult GetGoodsList()
        {
            using (yxbonDbContext con = new yxbonDbContext())
            {

                var list = con.ExpList.Where(o => o.IsDeleted == 0).Select(o => new ComboData() { value = o.Goods, text = o.Goods }).Distinct().ToList();

                return Json(list, JsonRequestBehavior.AllowGet);
            }
        }
Example #9
0
        public ActionResult GetExpDetailList(int expid)
        {
            using (yxbonDbContext con = new yxbonDbContext())
            {
                long recordCount = 0;
                Func<ExpContext, bool> where = o => (o.expid == expid && o.isdeleted == 0);
                Func<ExpContext, DateTime> order = o => o.time;
                var list = con.GetListByPage(999, 1, ref recordCount, where, true, order).ToList();

                Dictionary<string, object> grid = new Dictionary<string, object>();
                grid.Add("total", recordCount);
                grid.Add("rows", list);
                return Json(grid, JsonRequestBehavior.AllowGet);
            }
        }
Example #10
0
        public ActionResult GetExpContext(string expnu)
        {
            List<string> expnulist = Regex.Split(expnu, "\n").ToList();

            List<ExpContextInfo> resultList = new List<ExpContextInfo>();

            //Newtonsoft.Json.Converters.IsoDateTimeConverter iso = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            // iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            // object list;
            string jsonresult = string.Empty;
            using (yxbonDbContext con = new yxbonDbContext())
            {
                List<ExpContextInfo> expinfo = (from nu in expnulist
                                                join exp in con.ExpList
                                                on nu equals exp.ExpNo
                                                into joinNuList
                                                from enu in joinNuList.DefaultIfEmpty()
                                                //where enu.IsDeleted == 0
                                                //where expnulist.Contains(exp.ExpNo)
                                                select new ExpContextInfo
                                                {
                                                    expnu = nu,
                                                    message = enu == null ? "noresult" : "success",
                                                    state = enu == null ? (int)ExpStateEnum.NoResult : enu.ExpState,
                                                    status = enu == null ? 0 : 1,
                                                    data = enu == null ? new List<ExpContextData>() : (from d in con.ExpContext
                                                                                                       where d.expid == enu.ExpId && d.isdeleted == 0
                                                                                                       orderby d.time
                                                                                                       select new ExpContextData
                                                                                                       {
                                                                                                           time = d.time, //SqlFunctions.DateName("yyyy-MM-dd",d.time),//( d.time.ToString(),//("yyyy-MM-dd HH:mm:ss"),
                                                                                                           context = d.context
                                                                                                       }).ToList()
                                                }).ToList();
                //resultList.Add(expinfo.FirstOrDefault());
                //jsonresult = JsonConvert.SerializeObject(expinfo, iso);
                //list = JsonConvert.DeserializeObject<List<ExpContextInfo>>(JsonConvert.SerializeObject(expinfo, iso));
                resultList.AddRange(expinfo);

            }
            return Json(resultList, JsonRequestBehavior.AllowGet);
        }