public async Task <IActionResult> GetDictListByName(Input_GetDictListByName model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_GetDictListByName)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); if (string.IsNullOrEmpty(model.Name)) { _Result.Code = "510"; _Result.Msg = "请按提示输入相关信息"; _Result.Data = ""; return(Json(_Result)); } var list = await dbContext.DataDict.Where(i => i.DictNameEn == model.Name.Trim()).OrderBy(o => o.ShowOrder).Select(s => new { s.ID, s.Code, s.DictValue }).ToListAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = list; return(Json(_Result)); }
public async Task <IActionResult> AddDevice(Input_Device model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); //调用云端接口创建设备 var url = Method.MallSite + "API/IOT/AddDevice"; _Result = Method.PostMothsToObj(url, inputStr); if (_Result.Code == "200") { Pull pull = new Pull(); await pull.PullDevData(); } return(Json(_Result)); }
public async Task <IActionResult> GetMenuInfo([FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); try { var uol = Method.GetLoginUserName(dbContext, this.HttpContext); List <MenuViewModel> menus; if (uol == null || string.IsNullOrEmpty(uol.UserCode)) { _Result.Code = "401"; _Result.Msg = "请先登录"; _Result.Data = ""; return(Json(_Result)); } ArrayList notExixtsTextEn = new ArrayList(); bool isOpenChat = false; var fun = await dbContext.FuncInfo.Where(i => i.Name == "品牌发布端").FirstOrDefaultAsync(); if (fun != null) { var mall = await dbContext.MallFunc.Where(i => i.MallCode == uol.MallCode && i.FuncCode == fun.Code).FirstOrDefaultAsync(); if (mall != null) { isOpenChat = true; } } if (!isOpenChat) { notExixtsTextEn = WebChatMenu; } if (uol.SystemModule == "Manage") { menus = await GetUserMenu(dbContext, 0, notExixtsTextEn); } else { menus = await GetUserMenu(dbContext, uol.ID, notExixtsTextEn); } _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = menus; return(Json(_Result)); } catch (Exception e) { _Result.Code = "500"; _Result.Msg = "Erro: " + e.ToString(); _Result.Data = ""; return(Json(_Result)); } }
private async Task HandleExceptionAsync(HttpContext context, QianMuResult result) { var response = context.Response; response.ContentType = "application/json"; response.StatusCode = (int)HttpStatusCode.InternalServerError; await response.WriteAsync(JsonConvert.SerializeObject(result)); }
public async Task <IActionResult> CancelPublish(Input_SubtitlePublishCancel model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); try { Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_SubtitlePublishCancel)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); if (model.Code.Count() <= 0) { _Result.Code = "510"; _Result.Msg = "编码不可为空"; _Result.Data = ""; return(Json(_Result)); } foreach (var c in model.Code) { var std = await dbContext.SubtitleToDeviceGroup.Where(i => !i.IsDel && i.Code == c).FirstOrDefaultAsync(); if (std != null) { std.IsDel = true; std.UpdateTime = DateTime.Now; dbContext.SubtitleToDeviceGroup.Update(std); } else { _Result.Code = "510"; _Result.Msg = "无效的关联编码:" + c; _Result.Data = ""; return(Json(_Result)); } } if (await dbContext.SaveChangesAsync() > 0) { _Result.Code = "200"; _Result.Msg = "取消成功"; _Result.Data = ""; } } catch (Exception e) { _Result.Code = "500"; _Result.Msg = "代码错误"; _Result.Data = e.ToString(); throw; } return(Json(_Result)); }
/// <summary> /// 获取节目组中的节目 /// </summary> /// <param name="id"></param> /// <param name="dbContext"></param> /// <returns></returns> private async Task <QianMuResult> GetEffectiveProgramListByScreen(string ScreenCode, string OrderBy, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); //判断输入条件 if (string.IsNullOrEmpty(ScreenCode)) { _Result.Code = "510"; _Result.Msg = "未能检测到屏幕类型"; _Result.Data = ""; return(_Result); } try { var list = await dbContext.Programs.Where(i => i.ProgScreenInfo == ScreenCode && i.LaunchTime <= DateTime.Now && i.ExpiryDate >= DateTime.Now).Join(dbContext.ScreenInfo, p => p.ProgScreenInfo, si => si.Code, (p, si) => new { p.ID, p.Code, PreviewSrc = p.PreviewSrc == "" ? "" : Method.OSSServer + p.PreviewSrc, ProgramName = p.ProgramName, ProgType = p.ProgType, ProgScreenInfo = si.SName, ScreenCode = si.Code, LaunchTime = p.LaunchTime.ToString("yyyy-MM-dd "), ExpiryDate = p.ExpiryDate.ToString("yyyy-MM-dd "), SwitchMode = p.SwitchMode, SwitchTime = p.SwitchTime, ScreenMatch = p.ScreenMatch, AddTime = p.AddTime }).AsNoTracking().ToListAsync(); if (!string.IsNullOrEmpty(OrderBy)) { if (OrderBy.ToLower() == "timeasc") { list = list.OrderBy(o => o.AddTime).ToList(); } if (OrderBy.ToLower() == "timedesc") { list = list.OrderByDescending(o => o.AddTime).ToList(); } } _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = list; } catch (Exception e) { _Result.Code = "500"; _Result.Msg = "Erro:" + e.ToString(); _Result.Data = ""; } return(_Result); }
public static bool CreateServerToIOT() { DbContextOptions <ContextString> options = new DbContextOptions <ContextString>(); ContextString dbContext = new ContextString(options); QianMuResult _Result = new QianMuResult(); var serveriot = dbContext.ServerIOT.FirstOrDefault(); if (serveriot == null) { var servermac = Method.GetServerMac().Replace(":", ""); //调用云端接口创建设备 var url = Method.MallSite + "API/IOT/AddFrontServer"; var data = new { ServerMac = servermac, MallCode = Method.CusID }; try { _Result = Method.PostMothsToObj(url, JsonHelper.SerializeJSON(data)); if (_Result.Code == "200") { IOTReturn _IOTReturn = new IOTReturn(); _IOTReturn = (IOTReturn)Newtonsoft.Json.JsonConvert.DeserializeObject(_Result.Data.ToString(), _IOTReturn.GetType()); dbContext.ServerIOT.Add(new Models.ServerIOT { AddTime = DateTime.Now, Code = Guid.NewGuid().ToString(), Key = _IOTReturn.Key, Name = _IOTReturn.UserName, ServerMac = servermac, UpdateTime = DateTime.Now }); } if (dbContext.SaveChanges() >= 0) { return(true); } else { return(false); } } catch (Exception) { return(false); } } else { return(true); } }
public async Task <IActionResult> GetScreensaver(Input_GetDeviceOptionsNew model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_GetDeviceOptionsNew)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); if (model == null || string.IsNullOrEmpty(model.MallCode)) { var uol = Method.GetLoginUserName(dbContext, this.HttpContext); if (string.IsNullOrEmpty(uol.UserName)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } else { model.MallCode = uol.MallCode; } } //else //{ // var mall = await dbContext.Mall.Where(i => i.Code == model.MallCode).FirstOrDefaultAsync(); // if (mall == null) // { // _Result.Code = "510"; // _Result.Msg = "无效的商场编码"; // _Result.Data = ""; // return Json(_Result); // } //} //获取当前时间 var screensaver = await dbContext.Screensaver.Where(i => i.MallCode == model.MallCode).FirstOrDefaultAsync(); if (screensaver == null) { _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = new { Time = 30, ScreenType = 0 }; } else { _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = new { Time = screensaver.Time, ScreenType = screensaver.ScreenType.HasValue ? screensaver.ScreenType.Value : 0 }; } return(Json(_Result)); }
public IActionResult GetMallByRegKey([FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); _Result.Code = "200"; _Result.Msg = ""; _Result.Data = Method.CusID; return(Json(_Result)); }
/// <summary> /// 获取建筑信息 /// </summary> /// <param name="ConstructionInfo"></param> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetConstList(string code, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); ////检测用户登录情况 //string username = Method.GetLoginUserName(dbContext, this.HttpContext); //if (string.IsNullOrEmpty(username)) //{ // _Result.Code = "401"; // _Result.Msg = "请登陆后再进行操作"; // _Result.Data = ""; // return Json(_Result); //} var buildings = await dbContext.Building.Where(i => !i.IsDel).AsNoTracking().ToListAsync(); if (!string.IsNullOrEmpty(code)) { buildings = buildings.Where(i => i.Code == code).ToList(); } ArrayList Buildings = new ArrayList(); foreach (var b in buildings) { var floors = await dbContext.Floor.Where(i => i.BuildingCode == b.Code && !i.IsDel).OrderBy(o => o.Order).AsNoTracking().ToListAsync(); ArrayList arrlist = new ArrayList(); foreach (var f in floors) { string Map = string.Empty; var mapfile = await dbContext.AssetFiles.Where(i => i.Code == f.Map).FirstOrDefaultAsync(); if (mapfile != null) { Map = mapfile.FilePath; } arrlist.Add(new { f.ID, f.Code, f.Name, f.NameEn, Map = Map, f.Order, f.AddTime }); } Buildings.Add(new { b.ID, b.Code, b.Name, b.NameEn, Order = b.Order, b.AddTime, Floors = arrlist }); } _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = Buildings; //var ip = Method.GetUserIp(this.HttpContext); //dbContext.SysLog.Add(new SysLog { AccountName = username, ModuleName = "建筑模块", LogMsg = username + "获取建筑信息", AddTime = DateTime.Now, Code = Guid.NewGuid().ToString(), Type = "查询", IP = ip }); //dbContext.SaveChanges(); return(Json(_Result)); }
/// <summary> /// 获取店铺用户列表 /// </summary> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetStoreList([FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); var list = await dbContext.Mall.ToListAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = list; return(Json(_Result)); }
/// <summary> /// 获取信息 /// </summary> /// <param name="type"></param> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetInfo(Input_GetLiveInfo model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_GetLiveInfo)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); if (string.IsNullOrEmpty(model.Code)) { _Result.Code = "510"; _Result.Msg = "请输入编码"; _Result.Data = ""; return(Json(_Result)); } var live = await dbContext.Live.Where(i => !i.IsDel && i.Code == model.Code).Join(dbContext.ScreenInfo, l => l.ScreenCode, scr => scr.Code, (l, scr) => new { l.AddTime, l.BeingUsed, l.Code, l.ID, l.IsDel, l.Name, l.ScreenCode, l.UpdateTime, l.Url, Screen = scr.SName }).AsNoTracking().FirstOrDefaultAsync(); if (live == null) { _Result.Code = "510"; _Result.Msg = "无效的直播编码"; _Result.Data = ""; } else { _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = live; } return(Json(_Result)); }
/// <summary> /// 获取时间轴--时间段数据 /// </summary> /// <param name="mallCode">商场编码</param> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetInfo(string mallCode, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); if (string.IsNullOrEmpty(mallCode)) { //检测用户登录情况 var uol = Method.GetLoginUserName(dbContext, this.HttpContext); if (string.IsNullOrEmpty(uol.UserName)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } else { mallCode = uol.MallCode; } } if (String.IsNullOrEmpty(mallCode)) { _Result.Code = "510"; _Result.Msg = "请输入店铺编码"; _Result.Data = ""; return(Json(_Result)); } var timeAxis = await dbContext.TimeAxis.Where(i => i.MallCode == mallCode).FirstOrDefaultAsync(); if (timeAxis != null) { var timeRelate = await dbContext.TimeRelate.Where(i => i.TimeAxisCode == timeAxis.Code).Join(dbContext.TimeSlot, tr => tr.TimeSlotCode, ts => ts.Code, (tr, ts) => new { tr.TimeAxisCode, TimeRelateCode = tr.Code, ts.BeginTimeSlot, ts.EndTimeSlot, tr.OpenTime, tr.TimeSlotCode, ts.ID }).OrderBy(i => i.BeginTimeSlot).ToListAsync(); _Result.Data = new { TimeAxis = timeAxis, TimeRelateList = timeRelate }; } else { _Result.Data = null; } _Result.Code = "200"; _Result.Msg = "获取成功"; return(Json(_Result)); }
public async Task <IActionResult> GetListByUnionID(Input_GetBuildingListByUnionID model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_GetBuildingListByUnionID)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); if (String.IsNullOrEmpty(model.UnionID)) { _Result.Code = "510"; _Result.Msg = "请输入有效的身份编码"; _Result.Data = ""; return(Json(_Result)); } var sacount = await dbContext.ShopAccount.Where(i => i.UnionID == model.UnionID).FirstOrDefaultAsync(); if (sacount == null) { _Result.Code = "510"; _Result.Msg = "请输入有效的身份编码"; _Result.Data = ""; return(Json(_Result)); } var mallshop = await dbContext.MallShop.Where(i => i.ShopCode == sacount.ShopCode).FirstOrDefaultAsync(); // var Buildinglist = await dbContext.BuildingInfo.Where(i => i.Code == model.BuildingCode).FirstOrDefaultAsync(); var Buildinglist = await dbContext.MallBuilding.Where(i => i.MallCode == mallshop.MallCode).Join(dbContext.Building.Where(i => !i.IsDel), ma => ma.BuildingCode, ai => ai.Code, (ma, ai) => new { ai.Name, AddTime = ai.AddTime.ToString("yyyy-MM-dd HH:mm:ss"), ai.Code, ai.ID, ai.Order, UpdateTime = ai.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss") }).ToListAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = Buildinglist; return(Json(_Result)); }
/// <summary> /// 获取消息 /// </summary> /// <param name="model"></param> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetAuditInfo(string NewsCode, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); var news = await dbContext.StoreNews.Where(i => i.Code == NewsCode).Join(dbContext.Shops, sn => sn.ShopCode, s => s.Code, (sn, s) => new { sn.AddTime, sn.AduitStatus, sn.Code, sn.ID, sn.MgrCode, sn.News, sn.PlacingNum, sn.Reason, sn.ShopCode, sn.UpdateTime, sn.ValidityPeriod, s.Name, s.HouseNum }).FirstOrDefaultAsync(); var Imgs = await dbContext.NewsImg.Where(i => i.NewsCode == news.Code).Join(dbContext.AssetFiles, ni => ni.Img, af => af.Code, (ni, af) => new { //FilePath = Method.ServerAddr +"/MallSite/"+ af.FilePath, FilePath = Method.OSSServer + af.FilePath, af.Code, ni.IsSuspicious, af.Duration, af.FileSize, af.Height, af.Width }).ToListAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; var curDate = DateTime.Now; _Result.Data = new { news.AddTime, news.AduitStatus, news.Code, news.ID, news.News, news.ShopCode, news.UpdateTime, news.PlacingNum, news.Reason, news.HouseNum, news.Name, ValidityPeriod = news.ValidityPeriod.ToString("yyyy-MM-dd HH:mm"), Imgs, DateState = news.ValidityPeriod.AddDays(1) > curDate ? 5 : 7 }; return(Json(_Result)); }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="ID"></param> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetUserInfo(int?ID, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); if (ID == null) { _Result.Code = "510"; _Result.Msg = "请输入一个ID"; _Result.Data = ""; return(Json(_Result)); } var count = await dbContext.Account.Where(i => i.Activity == true && i.ID == ID).CountAsync(); if (count <= 0) { _Result.Code = "510"; _Result.Msg = "无效的用户ID"; _Result.Data = ""; return(Json(_Result)); } var user = await dbContext.Account.Where(i => i.Activity == true && i.ID == ID).Join(dbContext.UserRoles, ac => ac.Code, ur => ur.UserCode, (ac, ur) => new { ac.ID, ac.AccountName, ac.NickName, ur.RoleCode, ac.AddTime, ac.Phone, ac.Email, ac.Code }).Join(dbContext.Roles, ac => ac.RoleCode, ro => ro.Code, (ac, ro) => new { ac.ID, ac.AccountName, ac.NickName, ac.RoleCode, RoleName = ro.Name, ac.Phone, ac.Email, ac.AddTime, ac.Code }).FirstOrDefaultAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = user; return(Json(_Result)); }
/// <summary> /// 获取业态列表 /// </summary> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetShopFormatList(string mallCode, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); if (string.IsNullOrEmpty(mallCode)) { ////检测用户登录情况 var uol = Method.GetLoginUserName(dbContext, this.HttpContext); if (string.IsNullOrEmpty(uol.UserName)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } else { mallCode = uol.MallCode; } } var sfs = await dbContext.ShopFormat.Where(i => i.ParentCode == string.Empty && i.MallCode == mallCode && !i.IsDel).OrderBy(o => o.AddTime).AsNoTracking().ToListAsync(); ArrayList list = new ArrayList(); foreach (var sf in sfs) { var count = await dbContext.ShopFormat.Where(i => i.ParentCode == sf.Code && !i.IsDel).CountAsync(); var iconFile = await dbContext.AssetFiles.Where(i => i.Code == sf.IconFile).FirstOrDefaultAsync(); string IconFilePath = ""; if (iconFile != null) { //IconFilePath = Method.ServerAddr + "/MallSite/" + iconFile.FilePath; IconFilePath = Method.OSSServer + iconFile.FilePath; } list.Add(new { sf.ID, sf.Name, sf.NameEn, ChildCount = count, sf.AddTime, sf.Color, IconFilePath, sf.Code }); } _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = list; //var ip = Method.GetUserIp(this.HttpContext); //dbContext.SysLog.Add(new SysLog { AccountName = username, ModuleName = "商铺模块", LogMsg = username + "获取业态列表", AddTime = DateTime.Now, Code = Guid.NewGuid().ToString(), Type = "查询", IP = ip }); //dbContext.SaveChanges(); return(Json(_Result)); }
/// <summary> /// 获取角色列表 /// </summary> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetList([FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); var q = await dbContext.Roles.AsNoTracking().ToArrayAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = q; return(Json(_Result)); }
/// <summary> /// 获取所有节目 /// </summary> /// <param name="dbContext"></param> /// <returns></returns> private async Task <QianMuResult> GetEffectiveAllProgramList(string OrderBy, ContextString dbContext) { QianMuResult _Result = new QianMuResult(); try { var list = await dbContext.Programs.Where(i => i.LaunchTime <= DateTime.Now && i.ExpiryDate >= DateTime.Now).Join(dbContext.ScreenInfo, pr => pr.ProgScreenInfo, si => si.Code, (pr, si) => new { ID = pr.ID, pr.Code, PreviewSrc = pr.PreviewSrc == "" ? "" : Method.OSSServer + pr.PreviewSrc, ProgramName = pr.ProgramName, ProgType = pr.ProgType, ProgScreenInfo = si.SName, ScreenCode = si.Code, LaunchTime = pr.LaunchTime.ToString("yyyy-MM-dd "), ExpiryDate = pr.ExpiryDate.ToString("yyyy-MM-dd "), SwitchMode = pr.SwitchMode, SwitchTime = pr.SwitchTime, ScreenMatch = pr.ScreenMatch, AddTime = pr.AddTime }).ToListAsync(); if (!string.IsNullOrEmpty(OrderBy)) { if (OrderBy.ToLower() == "timeasc") { list = list.OrderBy(o => o.AddTime).ToList(); } if (OrderBy.ToLower() == "timedesc") { list = list.OrderByDescending(o => o.AddTime).ToList(); } } _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = list; } catch (Exception e) { _Result.Code = "500"; _Result.Msg = "Erro:" + e.ToString(); _Result.Data = ""; } return(_Result); }
public static string GetCusID(ContextString dbContext, string regkey) { var prj = dbContext.ProjectInfo.Where(i => i.RegKey == regkey).FirstOrDefault(); if (prj == null) { var url = Method.MallSite + "API/CDN/GetCusID"; QianMuResult qianMuResult = new QianMuResult(); var param = new { RegKey = regkey }; try { qianMuResult = Method.PostMothsToObj(url, JsonHelper.SerializeJSON(param)); if (qianMuResult.Code == "200") { dbContext.ProjectInfo.Add(new ProjectInfo { AddTime = DateTime.Now, Code = Guid.NewGuid().ToString(), CusID = qianMuResult.Data.ToString(), RegKey = regkey, UpdateTime = DateTime.Now }); if (dbContext.SaveChanges() > 0) { return(qianMuResult.Data.ToString()); } else { return(string.Empty); } } else { return(string.Empty); } } catch (Exception) { return(string.Empty); } } else { return(prj.CusID); } }
public async Task <IActionResult> GetAreaList(Input_GetAreaList_Local model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); if (string.IsNullOrEmpty(model.MallCode)) { Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_GetAreaList_Local)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); //检测用户登录情况 var uol = Method.GetLoginUserName(dbContext, this.HttpContext); if (string.IsNullOrEmpty(uol.UserName)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } else { model.MallCode = uol.MallCode; } } var Areas = await dbContext.AreaInfo.Where(i => !i.IsDel).Join(dbContext.MallArea.Where(i => i.MallCode == model.MallCode), ai => ai.Code, ma => ma.AreaCode, (ai, ma) => new { ai.ID, ai.Code, ai.AreaName, ai.Order }).AsNoTracking().ToListAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = Areas; //var ip = Method.GetUserIp(this.HttpContext); //dbContext.SysLog.Add(new SysLog { AccountName = username, ModuleName = "建筑模块", LogMsg = username + "获取区域信息", AddTime = DateTime.Now, Code = Guid.NewGuid().ToString(), Type = "查询", IP = ip }); //dbContext.SaveChanges(); return(Json(_Result)); }
public async Task <IActionResult> GetList(Input_MallUserGetList model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_MallUserGetList)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); if (string.IsNullOrEmpty(model.MallCode)) { //检测用户登录情况 var uol = Method.GetLoginUserName(dbContext, this.HttpContext); if (string.IsNullOrEmpty(uol.UserName)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } else { model.MallCode = uol.MallCode; } } var list = await dbContext.Account.Where(i => i.MallCode == model.MallCode && i.Activity).ToListAsync(); _Result.Code = "200"; _Result.Msg = "编辑成功"; _Result.Data = list; return(Json(_Result)); }
public async Task <IActionResult> GetContainerList([FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); var uol = Method.GetLoginUserName(dbContext, this.HttpContext); if (string.IsNullOrEmpty(uol.UserName)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } try { var screenInfo = await dbContext.ScreenInfo.Where(i => i.MallCode == uol.MallCode).OrderBy(i => i.ID).ToListAsync(); var list = new ArrayList(); foreach (var item in screenInfo) { var container = await dbContext.ContainerBG.Where(i => i.MallCode == uol.MallCode && i.ScreenCode == item.Code).Join(dbContext.AssetFiles, c => c.FileCode, af => af.Code, (c, af) => new { FilePath = Method.OSSServer + af.FilePath, c.FileCode, c.ScreenCode }).FirstOrDefaultAsync(); list.Add(new { item.Code, item.SName, FilePath = container == null ? "" : container.FilePath, FileCode = container == null ? "" : container.FileCode, ScreenCode = item.Code }); } _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = list; return(Json(_Result)); } catch (Exception e) { _Result.Code = "500"; _Result.Msg = "" + e.ToString(); _Result.Data = ""; return(Json(_Result)); } }
public async Task <IActionResult> GetGroupInfo(Input_GetDevGroupInfo model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_GetDevGroupInfo)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); //判断输入条件 if (string.IsNullOrEmpty(model.Code)) { _Result.Code = "510"; _Result.Msg = "未能检测到编码"; _Result.Data = ""; return(Json(_Result)); } var grounps = await dbContext.DeviceGroup.Where(i => i.Code == model.Code).Join(dbContext.ScreenInfo, dg => dg.ScreenInfoCode, s => s.Code, (dg, s) => new { dg.GName, dg.ScreenInfoCode, IsSync = dg.Type == 1 ? false : true, s.SName, TypeStr = dg.Type == 1 ? "正常" : "同步" }).FirstOrDefaultAsync(); if (grounps != null) { _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = grounps; } else { _Result.Code = "1"; _Result.Msg = "无效的设备组"; _Result.Data = ""; } return(Json(_Result)); }
/// <summary> /// 获取楼栋列表 /// </summary> /// <param name="id"></param> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetBuildingList([FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); //检测用户登录情况 var uol = Method.GetLoginUserName(dbContext, this.HttpContext); string mallCode = string.Empty; if (string.IsNullOrEmpty(uol.MallCode)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } else { mallCode = uol.MallCode; } var buildings = await dbContext.MallBuilding.Where(i => i.MallCode == mallCode).Join(dbContext.Building.Where(i => !i.IsDel), mb => mb.BuildingCode, bu => bu.Code, (mb, bu) => new { bu.AddTime, bu.Code, bu.ID, bu.Name, bu.NameEn, bu.Order, bu.UpdateTime }).ToListAsync(); // var buildings = await dbContext.Building.ToListAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = buildings; //var ip = Method.GetUserIp(this.HttpContext); //dbContext.SysLog.Add(new SysLog { AccountName = username, ModuleName = "建筑模块", LogMsg = username + "获取楼栋列表", AddTime = DateTime.Now, Code = Guid.NewGuid().ToString(), Type = "查询", IP = ip }); //dbContext.SaveChanges(); return(Json(_Result)); }
/// <summary> /// 获取角色信息 /// </summary> /// <param name="name"></param> /// <param name="dbContext"></param> /// <returns></returns> public async Task <IActionResult> GetInfo(string code, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); try { var count = await dbContext.Roles.Where(i => i.Code == code).AsNoTracking().CountAsync(); if (count <= 0) { _Result.Code = "510"; _Result.Msg = "角色不存在"; _Result.Data = ""; return(Json(_Result)); } //获取角色 var role = await dbContext.Roles.Where(i => i.Code == code).FirstOrDefaultAsync(); //获取权限 var roleper = await dbContext.RolePermissions.Where(i => i.RoleCode == code).Join(dbContext.Permission.Where(i => !string.IsNullOrEmpty(i.ParentCode)), rp => rp.PermissionCode, pe => pe.Code, (rp, pe) => new { pe.Code, pe.Name }).ToListAsync(); _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = new { RoleID = role.ID, role.Name, role.Intro, role.Description, role.Code, role.AddTime, Permission = roleper }; } catch (Exception e) { _Result.Code = "500"; _Result.Msg = "获取失败" + e.ToString(); _Result.Data = ""; } return(Json(_Result)); }
public async Task <IActionResult> GetUserList(Input_QueryUser model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); //检测用户登录情况 UserOnLine userOnLine = Method.GetLoginUserName(dbContext, this.HttpContext); if (userOnLine == null || string.IsNullOrEmpty(userOnLine.UserCode) || string.IsNullOrEmpty(userOnLine.MallCode)) { _Result.Code = "401"; _Result.Msg = "请登陆后再进行操作"; _Result.Data = ""; return(Json(_Result)); } Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_QueryUser)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); var userlist = await dbContext.Output_UserList.FromSql(@"select a.ID,a.AccountName,a.NickName,c.Name as RoleName, CONVERT(varchar(100), a.AddTime, 20) as AddTime, case ISNULL(d.Code, '') when '' then 0 else 1 end as [Status] from Account a left join UserRoles b on a.ID = b.UserID left join Roles c on b.RoleID = c.ID left join UserWarningEmail d on a.ID = d.UserID where a.MallCode=@mallcode and a.Activity = 1", new SqlParameter("@mallcode", userOnLine.MallCode)).ToListAsync(); if (model.Paging == 1) { userlist = userlist.Skip((model.PageIndex - 1) * model.PageSize).Take(model.PageSize).ToList(); } _Result.Code = "200"; _Result.Msg = "获取成功"; _Result.Data = userlist; return(Json(_Result)); }
/// <summary> /// 检测号码 /// </summary> /// <param name="model"></param> /// <param name="dbContext"></param> /// <param name="returnUrl"></param> /// <returns></returns> public IActionResult CheckPhoneNum(string phone, [FromServices] ContextString dbContext, string returnUrl = null) { QianMuResult _Result = new QianMuResult(); //判断系统中是否存在用户 var accnum = dbContext.Account.Where(i => i.Phone == phone && i.Activity == true).Count(); if (accnum <= 0) { _Result.Code = "1"; _Result.Msg = "用户不存在或不可用"; _Result.Data = ""; return(Json(_Result)); } else { _Result.Code = "200"; _Result.Msg = "号码正确"; _Result.Data = ""; } return(Json(_Result)); }
public async Task <IActionResult> SetTimeRelate(Input_TimeRelate model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); //检测用户登录情况 Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_TimeRelate)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); foreach (var item in model.TimeRelateList) { var timeRelate = await dbContext.TimeRelate.Where(t => t.Code == item.TimeRelateCode).FirstOrDefaultAsync(); if (timeRelate != null) { timeRelate.OpenTime = item.OpenTime; timeRelate.UpdateTime = DateTime.Now; dbContext.TimeRelate.Update(timeRelate); } } if (await dbContext.SaveChangesAsync() > 0) { _Result.Code = "200"; _Result.Msg = "设置成功"; _Result.Data = ""; } else { _Result.Code = "501"; _Result.Msg = "设置失败"; _Result.Data = ""; } return(Json(_Result)); }
public async Task <IActionResult> GetContainerBGByScreen(Input_GetContainerBGByScreen model, [FromServices] ContextString dbContext) { QianMuResult _Result = new QianMuResult(); Stream stream = HttpContext.Request.Body; byte[] buffer = new byte[HttpContext.Request.ContentLength.Value]; stream.Read(buffer, 0, buffer.Length); string inputStr = Encoding.UTF8.GetString(buffer); model = (Input_GetContainerBGByScreen)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType()); _Result.Code = "200"; _Result.Msg = "获取成功"; var device = await dbContext.Device.Where(i => i.Code == model.Code).FirstOrDefaultAsync(); if (device == null) { _Result.Data = ""; } else { var container = await dbContext.ContainerBG.Where(i => i.ScreenCode == device.ScreenInfo).Join(dbContext.AssetFiles, c => c.FileCode, af => af.Code, (c, af) => new { FilePath = Method.OSSServer + af.FilePath }).FirstOrDefaultAsync(); if (container == null) { _Result.Data = ""; } else { _Result.Data = container.FilePath; } } return(Json(_Result)); }