baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
+726
@@ -0,0 +1,726 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Opsoft.Data;
|
||||
using Opsoft.Data.Model;
|
||||
using Opsoft.NetCore.O3App.Shared;
|
||||
using Opsoft.NetCore.O3App.WebApi.Filters;
|
||||
using Opsoft.NetCore.O3App.WebApi.Model;
|
||||
using Opsoft.NetCore.O3App.WebApi.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Opsoft.NetCore.O3App.WebApi.Controllers
|
||||
{
|
||||
[EnableCors("any")]
|
||||
public partial class ServiceController : BaseApiController<ServiceController>
|
||||
{
|
||||
private static List<string> _testList = new List<string>();
|
||||
|
||||
private readonly IUserService userService;
|
||||
public ServiceController(
|
||||
IMapper mapper,
|
||||
ILogger<ServiceController> logger,
|
||||
IUserService service)
|
||||
: base(mapper, logger)
|
||||
{
|
||||
userService = service;
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult version_update([FromBody] CVersionIno request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//读取最新版本
|
||||
JsonFileHelper JHelper = new JsonFileHelper("LastAppVersionInfo");
|
||||
LastVersion myVer = JHelper.Read<LastVersion>("LastVersion");
|
||||
if (request.version.CompareTo(myVer.version) < 0)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
isUpdate = true,
|
||||
downloadIOSUrl = myVer.downloadIOSUrl,
|
||||
downloadAndroidUrl = myVer.downloadAndroidUrl
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
isUpdate = false,
|
||||
downloadIOSUrl = "",
|
||||
downloadAndroidUrl = "",
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
isUpdate = false,
|
||||
downloadIOSUrl = "",
|
||||
downloadAndroidUrl = "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult GetDBInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<CDBInfo> dbInfo = DBConnectionInfo.GetDBInfo();
|
||||
return Ok(new { ErrCode = 0, Data = dbInfo });
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new { ErrCode = 400, Data = ex.Message });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按人员获取组织
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public IActionResult GetUserInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = userService.GetUser(LoginInfo.UserID, LoginInfo.DBAias);
|
||||
if (user == null)
|
||||
{
|
||||
throw new ApplicationException($"cannot find current user with id : {LoginInfo.UserID}");
|
||||
}
|
||||
return Ok(new { ErrCode = 0, Data = user });
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new { ErrCode = 400, Data = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public IActionResult GetNews()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
List<SYS_ENANNOU> myArr = DBContext.SYS_ENANNOUS.Where(o => o.FSTATUS == 40).OrderByDescending(o => o.FCHECKDATE).Take(5).ToList();
|
||||
|
||||
return Ok(new { ErrCode = 0, Data = myArr });
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
ErrCode = 400,
|
||||
Data = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#region ============处理我的收藏 =========================================
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public IActionResult GetAllMenu([FromBody] JObject request)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
string wUserID = LoginInfo.UserID;
|
||||
// 第一步,得到此用户的所有功能权限
|
||||
List<PermissionInfo> AllPermissionInfo = this.GetPermissionsAll(wUserID, DBContext);
|
||||
//1=WinForm;2=WebForm;3=App;4=TV;5=Win+Web
|
||||
string FieldNmae = "[KEY]";
|
||||
if (DBContext.IsOracle)
|
||||
FieldNmae = "KEY";
|
||||
string sqlQuery =
|
||||
" select T2.FNUMBER as " + FieldNmae + ",T2.FNAME as NAME,T2.FINTERID as ID, " + "\r\n" +
|
||||
" T3.FWEBBILL, T2.FTYPE AS PrgType " + "\r\n" +
|
||||
" from SYS_PRGWORKBENCH T1 " + "\r\n" +
|
||||
" JOIN SYS_PROGRAMCYCLE T2 on T1.FID = T2.FINTERID " + "\r\n" +
|
||||
" JOIN SYS_BILLTEMPLATE T3 on T2.FNUMBER = T3.FNUMBER " + "\r\n" +
|
||||
" where T2.FPRTYPE in ( '3') and T1.USER_ID=" + DBContext.GetDBParName("@PA1") + " " + "\r\n";
|
||||
// 测试先用 '1' 后面用 3
|
||||
sqlQuery +=
|
||||
" and ( T2.SHOW_YN='Y' ) " + "\r\n ";
|
||||
|
||||
sqlQuery +=
|
||||
" Order by T2.RO_CSEQ ";
|
||||
|
||||
// 所有我的收藏
|
||||
List<ODKMenu> MainMenu = DBContext.Database.SqlQuery<ODKMenu>(
|
||||
sqlQuery,
|
||||
DBContext.CreateParameter("@PA1", wUserID));
|
||||
// 取得有权限的我的收藏的资料
|
||||
List<ODKMenu> FavoritesList = new List<ODKMenu>();
|
||||
foreach (ODKMenu sub in MainMenu)
|
||||
{
|
||||
//判断循环,模组,程式都有权限,才可以有限权
|
||||
if (AllPermissionInfo.Any(o => o.Code == sub.ID.ToUpper() && o.HasPermission && o.Type == "Program"))
|
||||
{
|
||||
FavoritesList.Add(sub);
|
||||
}
|
||||
}
|
||||
// 所有菜单
|
||||
List<string> fPRTypes = new List<string>();
|
||||
if (request!=null&&request["fPRTypes"] != null)
|
||||
{
|
||||
foreach (JToken token in request["fPRTypes"])
|
||||
{
|
||||
fPRTypes.Add(token.ToStringEx());
|
||||
}
|
||||
}
|
||||
MainMenu = this.GetSystemMenu(DBContext, fPRTypes);
|
||||
|
||||
List<ODKMenu> MainMenuList = GetMenuWithPermission(MainMenu, AllPermissionInfo);
|
||||
|
||||
return Ok(
|
||||
new
|
||||
{
|
||||
ErrCode = 0,
|
||||
Data = new { Favorites = FavoritesList, MainMenu = MainMenuList }
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
ErrCode = 400,
|
||||
Data = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按账套信息获取组织
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult GetSysOrgForDB([FromBody] string DBAias)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(DBAias, ""))
|
||||
{
|
||||
var mArr = DBContext.SYS_ORGSTRUCTURE.Select(o => new
|
||||
{
|
||||
o.FINTERID,
|
||||
o.FNUMBER,
|
||||
o.FNAME
|
||||
}).ToList();
|
||||
return Ok(new { ErrCode = 0, Data = mArr });
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new { ErrCode = 400, Data = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按人员获取组织
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public IActionResult GetSysOrgForUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
var mArr = DBContext.Database.SqlQuery(@$" SELECT
|
||||
S2.FINTERID
|
||||
,S2.FNUMBER
|
||||
,S2.FNAME
|
||||
FROM SYS_USERORG S
|
||||
LEFT JOIN SYS_ORGSTRUCTURE S2 ON S2.FINTERID=S.FORGID
|
||||
WHERE S.USER_ID='{LoginInfo.UserID}'
|
||||
ORDER BY S2.FNUMBER");
|
||||
return Ok(new { ErrCode = 0, Data = mArr });
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new { ErrCode = 400, Data = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询全部组织
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public IActionResult GetSysOrg()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
var mArr = DBContext.SYS_ORGSTRUCTURE.Select(o => new
|
||||
{
|
||||
o.FINTERID,
|
||||
o.FNUMBER,
|
||||
o.FNAME
|
||||
}).ToList();
|
||||
return Ok(new { ErrCode = 0, Data = mArr });
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new { ErrCode = 400, Data = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据权限取得菜单,且只返回两层菜单
|
||||
/// </summary>
|
||||
/// <param name="MainMenu"></param>
|
||||
/// <param name="AllPermissionInfo"></param>
|
||||
/// <returns></returns>
|
||||
private List<ODKMenu> GetMenuWithPermission(List<ODKMenu> MainMenu, List<PermissionInfo> AllPermissionInfo)
|
||||
{
|
||||
List<ODKMenu> MainMenuList = new List<ODKMenu>();
|
||||
for (int i = 0; i < MainMenu.Count; i++)
|
||||
{
|
||||
ODKMenu CYMenu = MainMenu[i].Copy();
|
||||
for (int i2 = 0; i2 < MainMenu[i].SubMenus.Count; i2++) //
|
||||
{
|
||||
ODKMenu sub2 = MainMenu[i].SubMenus[i2];
|
||||
if (AllPermissionInfo.Any(o => o.Code == sub2.ID.ToUpper() && o.HasPermission && o.Type.ToUpperEx() == "PROGRAM"))
|
||||
{
|
||||
CYMenu.SubMenus.Add(sub2.Copy());
|
||||
}
|
||||
}
|
||||
// 只增加最底层菜单,因为PDA 只考虑两阶菜单
|
||||
if (CYMenu.SubMenus.Count > 0)
|
||||
{
|
||||
MainMenuList.Add(CYMenu);
|
||||
}
|
||||
}
|
||||
return MainMenuList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public IActionResult GetMainMenu()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
string wUserID = LoginInfo.UserID;
|
||||
// 第一步,得到此用户的所有功能权限
|
||||
List<PermissionInfo> AllPermissionInfo = this.GetPermissionsAll(wUserID, DBContext);
|
||||
//1=WinForm;2=WebForm;3=App;4=TV;5=Win+Web
|
||||
// 所有菜单
|
||||
List<ODKMenu> MainMenu = this.GetSystemMenu(DBContext);
|
||||
|
||||
List<ODKMenu> MainMenuList = GetMenuWithPermission(MainMenu, AllPermissionInfo);
|
||||
return Ok(new { ErrCode = 0, Data = MainMenuList });
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
ErrCode = 400,
|
||||
Data = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public IActionResult GetFavoritesMenu()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
string wUserID = LoginInfo.UserID;
|
||||
// 第一步,得到此用户的所有功能权限
|
||||
List<PermissionInfo> AllPermissionInfo = this.GetPermissionsAll(wUserID, DBContext);
|
||||
//1=WinForm;2=WebForm;3=App;4=TV;5=Win+Web
|
||||
string FieldNmae = "[KEY]";
|
||||
if (DBContext.IsOracle)
|
||||
FieldNmae = "KEY";
|
||||
string sqlQuery =
|
||||
" select T2.FNUMBER as " + FieldNmae + ",T2.FNAME as NAME,T2.FINTERID as ID, " + "\r\n" +
|
||||
" T3.FWEBBILL, T2.FTYPE AS PrgType " + "\r\n" +
|
||||
" from SYS_PRGWORKBENCH T1 " + "\r\n" +
|
||||
" JOIN SYS_PROGRAMCYCLE T2 on T1.FID = T2.FINTERID " + "\r\n" +
|
||||
" JOIN SYS_BILLTEMPLATE T3 on T2.FNUMBER = T3.FNUMBER " + "\r\n" +
|
||||
" where T2.FPRTYPE in ( '3') and T1.USER_ID=" + DBContext.GetDBParName("@PA1") + " " + "\r\n";
|
||||
// 测试先用 '1' 后面用 3
|
||||
sqlQuery +=
|
||||
" and ( T2.SHOW_YN='Y' ) " + "\r\n ";
|
||||
|
||||
sqlQuery +=
|
||||
" Order by T2.RO_CSEQ ";
|
||||
|
||||
// 所有我的收藏
|
||||
List<ODKMenu> MainMenu = DBContext.Database.SqlQuery<ODKMenu>(
|
||||
sqlQuery,
|
||||
DBContext.CreateParameter("@PA1", wUserID));
|
||||
// 取得有权限的我的收藏的资料
|
||||
List<ODKMenu> FavoritesList = new List<ODKMenu>();
|
||||
foreach (ODKMenu sub in MainMenu)
|
||||
{
|
||||
//判断循环,模组,程式都有权限,才可以有限权
|
||||
if (AllPermissionInfo.Any(o => o.Code == sub.ID.ToUpper() && o.HasPermission && o.Type == "Program"))
|
||||
{
|
||||
FavoritesList.Add(sub);
|
||||
}
|
||||
}
|
||||
return Ok(new { ErrCode = 0, Data = FavoritesList });
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
ErrCode = 400,
|
||||
Data = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="UserID"></param>
|
||||
/// <returns></returns>
|
||||
private List<PermissionInfo> GetPermissionsAll(string UserID, APPServerContext DBContext)
|
||||
{
|
||||
List<PermissionInfo> mArr = new List<PermissionInfo>();
|
||||
string sqlQuery = "";
|
||||
byte[] PR_MAP1 = ConvertByte(new byte[] { 0x00 });
|
||||
|
||||
|
||||
#region =========== 程序权限 ======================================
|
||||
sqlQuery = "SELECT FNUMBER,FNAME,FINTERID FROM SYS_PROGRAMCYCLE";
|
||||
DataTable TT = DBContext.Database.SqlQuery(sqlQuery);
|
||||
foreach (DataRow reader in TT.Rows)
|
||||
{
|
||||
mArr.Add(new PermissionInfo()
|
||||
{
|
||||
Type = "Program",
|
||||
Key = reader["FNUMBER"].ToString().ToUpper(),
|
||||
Code = reader["FINTERID"].ToString().ToUpper(),
|
||||
Name = reader["FNAME"].ToString(),
|
||||
PrgKey = reader["FNUMBER"].ToString().ToUpper(),
|
||||
HasPermission = false,
|
||||
});
|
||||
}
|
||||
|
||||
sqlQuery =
|
||||
"SELECT UPPER(PRG_ID) AS PRG_ID FROM SYS_USERPERMISSION " +
|
||||
" WHERE FROLEID IN (SELECT FROLEID FROM SYS_USERROLERELATION WHERE UPPER(USER_ID) ='" + UserID.ToUpper() + "') AND PR_CODE='P' ";
|
||||
|
||||
//再来更新有没有权限
|
||||
TT = DBContext.Database.SqlQuery(sqlQuery);
|
||||
IEnumerable<string> PrgList = TT.AsEnumerable().Select(r => r["PRG_ID"].ToString()).ToList();
|
||||
string[] strArr = PrgList.ToArray();
|
||||
for (int i = 0; i < mArr.Count; i++)
|
||||
{
|
||||
if (mArr[i].Type != "Program")
|
||||
continue;
|
||||
if (strArr.Contains(mArr[i].Key))
|
||||
{
|
||||
mArr[i].HasPermission = true;
|
||||
}
|
||||
}
|
||||
#endregion =========== 程序权限 ======================================
|
||||
|
||||
return mArr;
|
||||
}
|
||||
|
||||
byte[] ConvertByte(byte[] bytes)
|
||||
{
|
||||
//if (bytes.Length >= 32) return bytes;
|
||||
byte[] tempByte = new byte[] {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //1
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //2
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //3
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //4
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //5
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //6
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //7
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //8
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //9
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //10
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //11
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //12
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/*0x00, 0x00, //13
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //14
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //15
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //16
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //17
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //18
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //19
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //20
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //21
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //22
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //23
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //24
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //25
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
*/
|
||||
for (int i = 0; (i < tempByte.Length && i < bytes.Length); i++)
|
||||
{
|
||||
tempByte[i] = bytes[i];
|
||||
}
|
||||
return tempByte;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只得到两阶菜单(带参数筛选)
|
||||
/// </summary>
|
||||
/// <param name="DBContext"></param>
|
||||
/// <returns></returns>
|
||||
private List<ODKMenu> GetSystemMenu(APPServerContext DBContext, List<string> fPRTypes = null)
|
||||
{
|
||||
string strWhere1 = "";
|
||||
//1=WinForm;2=WebForm;3=App;4=TV;5=Win+Web
|
||||
|
||||
if (fPRTypes ==null|| fPRTypes.Count <= 0)
|
||||
{
|
||||
strWhere1 = " where T1.FPRTYPE in ( '3') and T1.SHOW_YN='Y' ";//数据看板和其它界面显示在菜单上
|
||||
}
|
||||
else
|
||||
{
|
||||
strWhere1 = $" where T1.FPRTYPE in ({string.Join(",", fPRTypes.Select(o => "'"+o+"'"))}) and T1.SHOW_YN='Y' ";//数据看板和其它界面显示在菜单上
|
||||
}
|
||||
List<string> mArr = new List<string>();
|
||||
|
||||
mArr.Add(
|
||||
" select T1.*, " + "\r\n" +
|
||||
" case T1.FGNAME when N'' then T1.FNAME else T1.FGNAME end FGROUPNAME, " + "\r\n" +
|
||||
" T2.FTNAME, T2.FCNAME, T2.FENAME, " + "\r\n" +
|
||||
" T2.FASNAME, T2.FASBILLNAME, T2.FASLISTNAME, " + "\r\n" +
|
||||
" T2.FWEBBILL, T2.FWEBLIST " + "\r\n" +
|
||||
" from SYS_PROGRAMCYCLE T1 " + "\r\n" +
|
||||
" join SYS_BILLTEMPLATE T2 on T1.FNUMBER = T2.FNUMBER " + "\r\n" +
|
||||
strWhere1); //明细功能及分组
|
||||
|
||||
DataSet MainDataSet = DBContext.Database.SqlQuery(mArr);
|
||||
|
||||
List<ODKMenu> MainMenu = new List<ODKMenu>();
|
||||
string wName = "FNAME";
|
||||
// 主模块
|
||||
var Query = MainDataSet.Tables[0].AsEnumerable().GroupBy(o => new
|
||||
{
|
||||
KEY = o["FPARENT"].ToStringEx(),
|
||||
NAME = o["FPARENTNA"].ToStringEx(),
|
||||
SEQ = o["FPARENTSEQ"].ToStringEx(),
|
||||
}).OrderBy(p => p.Key.SEQ);
|
||||
foreach (var sub in Query)
|
||||
{
|
||||
//主模块
|
||||
ODKMenu Menu1 = new ODKMenu()
|
||||
{
|
||||
KEY = sub.Key.KEY,
|
||||
NAME = sub.Key.NAME,
|
||||
MenuType = "Rotate",
|
||||
PrgType = "NormalMenu",
|
||||
ID = sub.Key.KEY,
|
||||
FIMAGE = "",
|
||||
};
|
||||
foreach (DataRow SubRow in MainDataSet.Tables[0].AsEnumerable().Where(o =>
|
||||
o["FPARENT"].ToStringEx().Equals(sub.Key.KEY)).OrderBy(o => o["RO_CSEQ"].ToStringEx()))
|
||||
{
|
||||
string wFWEBBILL = SubRow["FWEBBILL"].ToStringEx(), wFWEBBILL1 = "";
|
||||
string wFWEBLIST = SubRow["FWEBLIST"].ToStringEx(), wFWEBLIST1 = "";
|
||||
//2021/09/23 陆磊,自定义看板,需通过单据URL这个字段获取全部轮播的看板编号,注释掉暂时无用的代码,
|
||||
//string[] arrURL = wFWEBBILL.Split(',');
|
||||
//if (arrURL.Length > 1)
|
||||
//{
|
||||
// wFWEBBILL = arrURL[0].Trim();
|
||||
// wFWEBBILL1 = arrURL[1].Trim();
|
||||
//}
|
||||
//arrURL = wFWEBLIST.Split(',');
|
||||
//if (arrURL.Length > 1)
|
||||
//{
|
||||
// wFWEBLIST = arrURL[0].Trim();
|
||||
// wFWEBLIST1 = arrURL[1].Trim();
|
||||
//}
|
||||
ODKMenu Menu4 = new ODKMenu()
|
||||
{
|
||||
KEY = SubRow["FNUMBER"].ToStringEx(),
|
||||
NAME = SubRow[wName].ToStringEx(),
|
||||
MenuType = "Program",
|
||||
FTYPE = SubRow["FTYPE"].ToStringEx(),
|
||||
PrgType = SubRow["FPRTYPE"].ToStringEx(),
|
||||
//FTYPE = SubRow2["FTYPE"].ToStringEx(),
|
||||
//FASNAME = SubRow2["FASNAME"].ToStringEx(),
|
||||
//FASBILLNAME = SubRow2["FASBILLNAME"].ToStringEx(),
|
||||
//FASLISTNAME = SubRow2["FASLISTNAME"].ToStringEx(),
|
||||
FWEBBILL = wFWEBBILL,
|
||||
//FWEBBILL1 = wFWEBBILL1,
|
||||
//FWEBLIST = wFWEBLIST,
|
||||
//FWEBLIST1 = wFWEBLIST1,
|
||||
ID = SubRow["FINTERID"].ToStringEx(),
|
||||
//FSHOWTYPE = SubRow2["FSHOWTYPE"].ToStringEx()
|
||||
};
|
||||
if (Menu4.KEY.Split('-')[0].ToUpper().Equals("AUTO"))//检测是否是自定义看板,如果是的话,从T_AUTOKB_HEAD获得缩略图的URL
|
||||
{
|
||||
DataTable autoKanBan = DBContext.Database.SqlQuery(string.Format("SELECT FTHUMBNAIL FROM T_AUTOKB_HEAD WHERE FBILLNO='{0}'", Menu4.KEY));
|
||||
if (autoKanBan != null && autoKanBan.Rows.Count > 0)
|
||||
Menu4.FIMAGE = autoKanBan.Rows[0]["FTHUMBNAIL"].ToStringEx();
|
||||
}
|
||||
//Menu4.ParentMenu = Menu3.KEY;
|
||||
Menu1.SubMenus.Add(Menu4);
|
||||
}
|
||||
if (Menu1.SubMenus.Count > 0)
|
||||
MainMenu.Add(Menu1);
|
||||
}
|
||||
return MainMenu;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public IActionResult SetFavorites([FromBody] string ID)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
string UserID = LoginInfo.UserID;
|
||||
try
|
||||
{
|
||||
bool IsAdd = true;
|
||||
sysPrgWorkbench IAPRecordSet = DBContext.SYS_PRGWORKBENCH.SingleOrDefault(o => o.USER_ID.Equals(UserID) && o.FID.Equals(ID));
|
||||
if (IAPRecordSet == null)
|
||||
{
|
||||
IAPRecordSet = new sysPrgWorkbench();
|
||||
IAPRecordSet.UID = Guid.NewGuid().ToString();
|
||||
IAPRecordSet.C_USER = UserID;
|
||||
IAPRecordSet.USER_ID = UserID;
|
||||
IAPRecordSet.M_USER = UserID;
|
||||
IAPRecordSet.FINTERID = IAPRecordSet.UID;
|
||||
IAPRecordSet.FID = ID;
|
||||
IAPRecordSet.FBILLNO = this.CreateBilllNO(JsonConvert.SerializeObject(IAPRecordSet), "WESYSA05", "SYS_PRGWORKBENCH", "FBILLNO", "", "");
|
||||
IsAdd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsAdd = false;
|
||||
IAPRecordSet.M_USER = UserID;
|
||||
IAPRecordSet.M_YMD = DateTime.Now;
|
||||
}
|
||||
if (IsAdd)
|
||||
DBContext.Add(IAPRecordSet);
|
||||
else
|
||||
DBContext.Update(IAPRecordSet);
|
||||
|
||||
DBContext.SaveChanges();
|
||||
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return Ok(new { ErrCode = 0, Data = "" });
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
ErrCode = 400,
|
||||
Data = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public IActionResult DelFavorites([FromBody] string ID)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (APPServerContext DBContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID))
|
||||
{
|
||||
try
|
||||
{
|
||||
sysPrgWorkbench myEntity = DBContext.SYS_PRGWORKBENCH.SingleOrDefault(o => o.USER_ID.Equals(LoginInfo.UserID) && o.FID.Equals(ID));
|
||||
if (myEntity != null)
|
||||
DBContext.Remove(myEntity);
|
||||
DBContext.SaveChanges();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
return Ok(new { ErrCode = 0, Data = "" });
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
ErrCode = 400,
|
||||
Data = ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion ============处理我的收藏 =========================================
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
//var client = new RestSharpClient("http://localhost:51211/");
|
||||
//IRestResponse<AA> myMsg = await client.ExecuteAsync<AA>(new RestRequest("DataService/Index",Method.GET));
|
||||
return Ok("你看到的是一个WebApi");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Idempotent]
|
||||
public async Task<BaseResponse<object>> IdempotentTest()
|
||||
{
|
||||
_testList.Add(DateTime.Now.ToString());
|
||||
await Task.Delay(5000);
|
||||
return new BaseResponse<object>
|
||||
{
|
||||
Success = true,
|
||||
StatusCode = StatusCodes.Status200OK,
|
||||
Message = "幂等性测试!!!",
|
||||
Data = _testList
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user