1、用户导入;
2、用户角色支持多个; 3、单位资质;
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
namespace FineUIPro.Web.SysManage
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using BLL;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||
|
||||
public partial class UserList : PageBase
|
||||
{
|
||||
public partial class UserList : PageBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
@@ -44,13 +44,13 @@
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string strSql = @"SELECT Users.UserId,Users.Account,Users.UserCode,Users.Password,Users.UserName,Depart.DepartName,Users.RoleId,Users.UnitId,Users.IsPost,CASE WHEN Users.IsPost=1 THEN '是' ELSE '否' END AS IsPostName,Users.IdentityCard,Users.Telephone,Users.IsOffice,UnitCode,"
|
||||
+ @"Roles.RoleName,Unit.UnitName,Unit.UnitCode"
|
||||
+ @" From dbo.Sys_User AS Users"
|
||||
+ @" LEFT JOIN Sys_Role AS Roles ON Roles.RoleId=Users.RoleId"
|
||||
+ @" LEFT JOIN Base_Unit AS Unit ON Unit.UnitId=Users.UnitId"
|
||||
+ @" LEFT JOIN Base_Depart AS Depart ON Depart.DepartId=Users.DepartId"
|
||||
+ @" WHERE Users.UserId !='" + Const.sysglyId + "' AND Users.UserId !='" + Const.hfnbdId + "' AND Users.UserId !='" + Const.sedinId + "'";
|
||||
string strSql = $@"SELECT Users.UserId,Users.Account,Users.UserCode,Users.Password,Users.UserName,Depart.DepartName,Users.RoleId,Users.UnitId,Users.IsPost,CASE WHEN Users.IsPost=1 THEN '是' ELSE '否' END AS IsPostName,Users.IdentityCard,Users.Telephone,Users.IsOffice,UnitCode,Unit.UnitName,Unit.UnitCode
|
||||
,RoleName= STUFF(( SELECT ',' + RoleName FROM dbo.Sys_Role where PATINDEX('%,' + RTRIM(RoleId) + ',%',',' +Users.RoleId + ',')>0 FOR XML PATH('')), 1, 1,'')
|
||||
From dbo.Sys_User AS Users
|
||||
LEFT JOIN Sys_Role AS Roles ON Roles.RoleId=Users.RoleId
|
||||
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId=Users.UnitId
|
||||
LEFT JOIN Base_Depart AS Depart ON Depart.DepartId=Users.DepartId
|
||||
WHERE Users.UserId !='{Const.sysglyId}' AND Users.UserId !='{Const.hfnbdId}'";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
//strSql += " AND Users.UnitId = @ThisUnitId";
|
||||
//listStr.Add(new SqlParameter("@ThisUnitId", Const.UnitId_CWCEC));
|
||||
@@ -328,94 +328,94 @@
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnImport1_Click(object sender, EventArgs e)
|
||||
{
|
||||
//同步项目
|
||||
int total = 10;
|
||||
int pageSize = 100;
|
||||
int pageIndex = 0;
|
||||
while (pageSize * pageIndex <= total)
|
||||
{
|
||||
string pushContent = string.Empty;
|
||||
var dictTypeCode = new
|
||||
{
|
||||
criteria = new { _expr = new[] { new { _property = "isusedcode", _value = "0", _op = "=" } } },
|
||||
pageSize = pageSize,
|
||||
pageIndex = pageIndex
|
||||
};
|
||||
Hashtable newToken = new Hashtable
|
||||
{
|
||||
{ "userName", "nuobida_construction" },
|
||||
{ "password", "nuobida@2023" },
|
||||
{ "ClientId", "com.tcc.pm.sggl" },
|
||||
{ "OperationCode", "com.tcc.dm.mdm.ee.basicinfo" }
|
||||
};
|
||||
pushContent = JsonConvert.SerializeObject(dictTypeCode);
|
||||
string returndata = APIGetHttpService.OutsideHttp("https://esb.china-tcc.com:9090/com/tcc/dm/mdm/TCC_TM_EE_BASIC_INFO", "POST", "application/json;charset=utf-8", newToken, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
total = int.Parse(obj["total"].ToString());
|
||||
string datas = obj["datas"].ToString();
|
||||
JArray arr = JArray.Parse(datas);
|
||||
foreach (var item in arr)
|
||||
{
|
||||
string full_name = item["full_name"].ToString();
|
||||
string genderCode = item["gender_code"].ToString();
|
||||
string idcard = item["idcard"].ToString();
|
||||
string data_source_code = item["data_source_code"].ToString();
|
||||
string hrp_personnel_unique_id = item["hrp_personnel_unique_id"].ToString();
|
||||
string cellphone = item["cellphone"].ToString();
|
||||
string domainAccount = item["domain_account"].ToString();
|
||||
|
||||
if (!string.IsNullOrEmpty(idcard))
|
||||
{
|
||||
var sysUser = Funs.DB.Sys_User.FirstOrDefault(x => x.IdentityCard == idcard );
|
||||
if (sysUser != null)
|
||||
{
|
||||
sysUser.UserName = full_name;
|
||||
sysUser.Telephone = cellphone;
|
||||
sysUser.DomainAccount = domainAccount;
|
||||
sysUser.Sex = genderCode;
|
||||
{
|
||||
//同步项目
|
||||
int total = 10;
|
||||
int pageSize = 100;
|
||||
int pageIndex = 0;
|
||||
while (pageSize * pageIndex <= total)
|
||||
{
|
||||
string pushContent = string.Empty;
|
||||
var dictTypeCode = new
|
||||
{
|
||||
criteria = new { _expr = new[] { new { _property = "isusedcode", _value = "0", _op = "=" } } },
|
||||
pageSize = pageSize,
|
||||
pageIndex = pageIndex
|
||||
};
|
||||
Hashtable newToken = new Hashtable
|
||||
{
|
||||
{ "userName", "nuobida_construction" },
|
||||
{ "password", "nuobida@2023" },
|
||||
{ "ClientId", "com.tcc.pm.sggl" },
|
||||
{ "OperationCode", "com.tcc.dm.mdm.ee.basicinfo" }
|
||||
};
|
||||
pushContent = JsonConvert.SerializeObject(dictTypeCode);
|
||||
string returndata = APIGetHttpService.OutsideHttp("https://esb.china-tcc.com:9090/com/tcc/dm/mdm/TCC_TM_EE_BASIC_INFO", "POST", "application/json;charset=utf-8", newToken, pushContent);
|
||||
if (!string.IsNullOrEmpty(returndata))
|
||||
{
|
||||
JObject obj = JObject.Parse(returndata);
|
||||
total = int.Parse(obj["total"].ToString());
|
||||
string datas = obj["datas"].ToString();
|
||||
JArray arr = JArray.Parse(datas);
|
||||
foreach (var item in arr)
|
||||
{
|
||||
string full_name = item["full_name"].ToString();
|
||||
string genderCode = item["gender_code"].ToString();
|
||||
string idcard = item["idcard"].ToString();
|
||||
string data_source_code = item["data_source_code"].ToString();
|
||||
string hrp_personnel_unique_id = item["hrp_personnel_unique_id"].ToString();
|
||||
string cellphone = item["cellphone"].ToString();
|
||||
string domainAccount = item["domain_account"].ToString();
|
||||
|
||||
//sysUser.DataSource = "数据同步";
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
sysUser = new Model.Sys_User
|
||||
{
|
||||
UserId = SQLHelper.GetNewID(),
|
||||
};
|
||||
sysUser.UnitId = BLL.Const.UnitId_XJYJ;
|
||||
sysUser.UserCode = domainAccount;
|
||||
sysUser.UserName = full_name;
|
||||
sysUser.Telephone = cellphone;
|
||||
sysUser.IdentityCard = idcard;
|
||||
sysUser.Account = domainAccount;
|
||||
sysUser.DomainAccount = domainAccount;
|
||||
sysUser.Password = Funs.EncryptionPassword(BLL.Const.Password);
|
||||
sysUser.RawPassword = BLL.Const.Password;
|
||||
sysUser.IsPost = true;
|
||||
sysUser.DataSource = "数据同步";
|
||||
Funs.DB.Sys_User.InsertOnSubmit(sysUser);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(idcard))
|
||||
{
|
||||
var sysUser = Funs.DB.Sys_User.FirstOrDefault(x => x.IdentityCard == idcard);
|
||||
if (sysUser != null)
|
||||
{
|
||||
sysUser.UserName = full_name;
|
||||
sysUser.Telephone = cellphone;
|
||||
sysUser.DomainAccount = domainAccount;
|
||||
sysUser.Sex = genderCode;
|
||||
|
||||
}
|
||||
pageIndex++;
|
||||
}
|
||||
//sysUser.DataSource = "数据同步";
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
sysUser = new Model.Sys_User
|
||||
{
|
||||
UserId = SQLHelper.GetNewID(),
|
||||
};
|
||||
sysUser.UnitId = BLL.Const.UnitId_XJYJ;
|
||||
sysUser.UserCode = domainAccount;
|
||||
sysUser.UserName = full_name;
|
||||
sysUser.Telephone = cellphone;
|
||||
sysUser.IdentityCard = idcard;
|
||||
sysUser.Account = domainAccount;
|
||||
sysUser.DomainAccount = domainAccount;
|
||||
sysUser.Password = Funs.EncryptionPassword(BLL.Const.Password);
|
||||
sysUser.RawPassword = BLL.Const.Password;
|
||||
sysUser.IsPost = true;
|
||||
sysUser.DataSource = "数据同步";
|
||||
Funs.DB.Sys_User.InsertOnSubmit(sysUser);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
pageIndex++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭导入弹出窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭导入弹出窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user