public HomeController() { _infoModel = new HomeInfoModel(); _infoModel.CpuInfo = new CpuItems(); _infoModel.CpuInfo.items = new List <DeviceModel>(); _infoModel.VideoInfo = new List <DeviceModel>(); }
public ActionResult XiangQingIndex(int Id) { string json = HttpClientHelper.SendRequest("api/HomeInfo/ShowById?id=" + Id, "get"); HomeInfoModel homes = JsonConvert.DeserializeObject <HomeInfoModel>(json); ViewBag.Id = homes.HomeInfo_Id; //根据房屋信息类型判断是出售还是出租 List <HomeInfoModel> house = GetHomeInfos(); //根据房屋信息类型判断是出售还是出租 house = house.Where(C => C.HomeInfo_InfoType == 3).ToList(); ViewBag.homes = house; return(View(homes)); }
private void UpdateSystemInfoFromFile() { _infoModel.CurrentDateTime = DateTime.Now; _infoModel.CpuInfo.items.Clear(); _infoModel.VideoInfo.Clear(); string path = Server.MapPath("~/bin/system_info.json"); FileStream sourceFile = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); if (sourceFile.Length > 0) { byte[] getContent = new byte[(int)sourceFile.Length]; UTF8Encoding temp = new UTF8Encoding(true); sourceFile.Read(getContent, 0, (int)sourceFile.Length); String json = temp.GetString(getContent); //Welcome sysInfo = Welcome.FromJson(json); _infoModel = JsonConvert.DeserializeObject <HomeInfoModel>(json); sourceFile.Close(); } }
public ActionResult Info2() { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; var model = new HomeInfoModel { Aggregates = this.RepositoryService.Aggregates.Select(agg => new AggregateInfoModel { AggregateType = agg.AggregateType.ToString(), ImplementationType = agg.ImplementationType.ToString(), }).ToArray(), TeclynVersion = version, Commands = this.MetadataRepository.Commands, Events = this.MetadataRepository.Events, }; return(this.View(model)); }
public ActionResult ZuFang(HttpPostedFileBase HomeInfo_PhotoPath, HomeInfoModel home) { string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Images\\" + HomeInfo_PhotoPath.FileName); HomeInfo_PhotoPath.SaveAs(path); home.HomeInfo_InfoType = 2; home.HomeInfo_CreateTime = DateTime.Now.ToShortDateString().ToString(); home.HomeInfo_PhotoPath = HomeInfo_PhotoPath.FileName; home.HomeInfo_UserId = Convert.ToInt32(Session["Account_Id"]); string json = JsonConvert.SerializeObject(home); string jsonStr = HttpClientHelper.SendRequest("api/HomeInfo/Create", "post", json); int result = JsonConvert.DeserializeObject <int>(jsonStr); if (result > 0) { return(Content("<script>location.href='/HomeInfo/ChuZuIndex/'</script>")); } else { return(Content("<script>alert('发布失败了!')</script>")); } }
public IActionResult Index() { List <HomeInfoModel> homeInfoes = new List <HomeInfoModel>(); List <Article> articles = new List <Article>(); List <Materials> materialses = new List <Materials>(); List <User> users = new List <User>(); materialses = materialsService.GetLatest10(); users = userService.GetLatest10(); //动态消息 List <DynamicModel> infoes = new List <DynamicModel>(); articles = articleService.GetLatest10(); foreach (var item in articles) { string[] imageUrls = CommonMarkConverter.Convert(item.Description).GetHtmlImageUrlList(); HomeInfoModel homeInfo = new HomeInfoModel(); homeInfo.Title = item.Title; homeInfo.Description = item.Description.SubString(100, "......"); homeInfo.CreateDate = item.CreateDate; homeInfo.Category = "原创文章"; homeInfo.Browses = item.Browses; homeInfo.Url = "/Article/Show/" + item.Id; homeInfo.ImageUrl = imageUrls.Count() > 0 ? imageUrls[0] : null; homeInfoes.Add(homeInfo); } foreach (var item in materialses) { DynamicModel model = new DynamicModel(); HomeInfoModel homeInfo = new HomeInfoModel(); infoes.Add(model); homeInfoes.Add(homeInfo); model.Title = item.Title; model.Id = item.Id; model.CreateDate = item.CreateDate; model.Url = "/Materials/Show/" + item.Id; homeInfo.Title = item.Title; homeInfo.Description = item.Description.SubString(100, "......"); homeInfo.CreateDate = item.CreateDate; homeInfo.Category = "学习资料"; homeInfo.Browses = item.Browses; homeInfo.Url = "/Materials/Show/" + item.Id; } //动态用户信息 List <DynamicModel> userList = new List <DynamicModel>(); foreach (var item in users) { DynamicModel model = new DynamicModel(); userList.Add(model); model.Title = item.UserName; model.Id = item.Id; model.CreateDate = item.CreatedDate; model.Url = "/User/Show/" + item.Id; } ViewBag.Infoes = infoes; ViewBag.Users = userList; ViewBag.HomeInfoes = homeInfoes.OrderByDescending(x => x.CreateDate).ToList(); return(View()); }