Commit 59679ba6 authored by 黄奎's avatar 黄奎

页面修改

parent 823fefce
......@@ -275,104 +275,114 @@ namespace Edu.Module.User
{
var accountModel = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { AccountType = AccountTypeEnum.Assist, AccountId = model.AId })?.FirstOrDefault();
if (string.IsNullOrEmpty(accountModel.WorkUserId) && IsLeave == false) { IsInsert = true; }//走新增方法
if (IsInsert)
{
//成员UserID。对应管理端的帐号,企业内必须唯一。不区分大小写,长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。
string userId = accountModel.Id + "_" + DateTime.Now.ToString("yyyyMMddHHmmssffff@") + (new Random().Next(1000, 9999));//规则生成
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
//新增用户
var inserMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberCreateRequest()
{
to_invite = true,
alias = "",
userid = userId,
name = accountModel.AccountName,
english_name = "",
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
email = "",
enable = 1,
avatar_mediaid = "",
telephone = "",
address = "",
};
try
{
var cmodel = QYWeiXinHelper.CreateMember(model.Token, inserMember);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Account_ViewModel.WorkUserId),userId}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=accountModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + cmodel.errmsg);
}
}
catch (Exception ex)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + ex.Message);
}
}
else
Common.Plugin.LogHelper.WriteInfo(string.Format("SetAssistModule:: AccountUserType {0} Name {1}", model.AccountUserType, model.AssistName));
if (model.AccountUserType == 1)
{
//修改企业微信用户
if (IsLeave)
if (IsInsert)
{
var cmodel = QYWeiXinHelper.DeleteMember(model.Token, accountModel.WorkUserId);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Account_ViewModel.WorkUserId),""}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 删除企业微信失败;" + cmodel.errmsg);
}
}
else
{
//获取部门信息
//成员UserID。对应管理端的帐号,企业内必须唯一。不区分大小写,长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。
string userId = accountModel.Id + "_" + DateTime.Now.ToString("yyyyMMddHHmmssffff@") + (new Random().Next(1000, 9999));//规则生成
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
var updateMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberUpdateRequest()
//新增用户
var inserMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberCreateRequest()
{
userid = accountModel.WorkUserId,
to_invite = true,
alias = "",
userid = userId,
name = accountModel.AccountName,
english_name = "",
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
email = "",
enable = 1,
avatar_mediaid = "",
telephone = "",
address = "",
};
var upmodel = QYWeiXinHelper.UpdateMember(model.Token, updateMember);
if (upmodel.errcode != Senparc.Weixin.ReturnCode_Work.请求成功)
try
{
var cmodel = QYWeiXinHelper.CreateMember(model.Token, inserMember);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Account_ViewModel.WorkUserId),userId}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=accountModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + cmodel.errmsg);
}
}
catch (Exception ex)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 更新企业微信失败;" + upmodel.errmsg);
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + ex.Message);
}
}
else
{
//修改企业微信用户
if (IsLeave)
{
var cmodel = QYWeiXinHelper.DeleteMember(model.Token, accountModel.WorkUserId);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Account_ViewModel.WorkUserId),""}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 删除企业微信失败;" + cmodel.errmsg);
}
}
else
{
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
var updateMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberUpdateRequest()
{
userid = accountModel.WorkUserId,
name = accountModel.AccountName,
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
enable = 1,
};
var upmodel = QYWeiXinHelper.UpdateMember(model.Token, updateMember);
if (upmodel.errcode != Senparc.Weixin.ReturnCode_Work.请求成功)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 更新企业微信失败;" + upmodel.errmsg);
}
}
}
}
......
......@@ -235,120 +235,132 @@ namespace Edu.Module.User
DirectSupervisor = model.DirectSupervisor
});
if (flag && !string.IsNullOrEmpty(model.Token) && IsUpdate) {
System.Threading.Tasks.Task.Run(() =>
{
//用户
var accountModel = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { AccountType = AccountTypeEnum.Admin, AccountId = model.MId })?.FirstOrDefault();
if (string.IsNullOrEmpty(accountModel.WorkUserId) && IsLeave == false) { IsInsert = true; }//走新增方法
if (IsInsert)
Common.Plugin.LogHelper.WriteInfo(string.Format("SetManagerModule:: AccountUserType {0} Name {1}", model.AccountUserType, model.MName));
//甲鹤员工才同步企业微信
if (model.AccountUserType == 1)
{
//新增企业微信用户
//成员UserID。对应管理端的帐号,企业内必须唯一。不区分大小写,长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。
string userId = accountModel.Id + "_" + DateTime.Now.ToString("yyyyMMddHHmmssffff@") + (new Random().Next(1000, 9999));//规则生成
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
wxDeptId = wxDeptId == 0 ? 1 : wxDeptId;//微信 1表示默认部门
//新增用户
var inserMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberCreateRequest()
if (IsInsert)
{
to_invite = true,
alias = "",
userid = userId,
name = accountModel.AccountName,
english_name = "",
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
email = "",
enable = 1,
avatar_mediaid = "",
telephone = "",
address = "",
};
try
{
var cmodel = QYWeiXinHelper.CreateMember(model.Token, inserMember);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
//新增企业微信用户
//成员UserID。对应管理端的帐号,企业内必须唯一。不区分大小写,长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。
string userId = accountModel.Id + "_" + DateTime.Now.ToString("yyyyMMddHHmmssffff@") + (new Random().Next(1000, 9999));//规则生成
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
wxDeptId = wxDeptId == 0 ? 1 : wxDeptId;//微信 1表示默认部门
//新增用户
var inserMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberCreateRequest()
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Account_ViewModel.WorkUserId),userId}
to_invite = true,
alias = "",
userid = userId,
name = accountModel.AccountName,
english_name = "",
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
email = "",
enable = 1,
avatar_mediaid = "",
telephone = "",
address = "",
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=accountModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
try
{
var cmodel = QYWeiXinHelper.CreateMember(model.Token, inserMember);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Account_ViewModel.WorkUserId),userId}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=accountModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + cmodel.errmsg);
}
}
else
catch (Exception ex)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + cmodel.errmsg);
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + ex.Message);
}
}
catch (Exception ex)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + ex.Message);
}
}
else
{
if (!string.IsNullOrEmpty(accountModel.WorkUserId))
else
{
//修改企业微信用户
if (IsLeave)
if (!string.IsNullOrEmpty(accountModel.WorkUserId))
{
try
//修改企业微信用户
if (IsLeave)
{
var cmodel = QYWeiXinHelper.DeleteMember(model.Token, accountModel.WorkUserId);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
try
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Account_ViewModel.WorkUserId),""}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=Id,
OperatorEnum=OperatorEnum.Equal
var cmodel = QYWeiXinHelper.DeleteMember(model.Token, accountModel.WorkUserId);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Account_ViewModel.WorkUserId),""}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + model.MName + "(" + Id + ") 删除企业微信失败;" + cmodel.errmsg);
}
}
};
accountRepository.Update(keyValues, wheres);
}
else
catch (Exception ex)
{
LogHelper.Write("员工 " + model.MName + "(" + Id + ") 删除企业微信失败;" + cmodel.errmsg);
LogHelper.Write(ex, "删除企业微信");
}
}
catch (Exception ex)
else
{
LogHelper.Write(ex, "删除企业微信");
}
}
else
{
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
var updateMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberUpdateRequest()
{
userid = accountModel.WorkUserId,
name = accountModel.AccountName,
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
enable = 1,
};
var upmodel = QYWeiXinHelper.UpdateMember(model.Token, updateMember);
if (upmodel.errcode != Senparc.Weixin.ReturnCode_Work.请求成功)
{
LogHelper.Write("员工 " + model.MName + "(" + Id + ") 更新企业微信失败;" + upmodel.errmsg);
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
var updateMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberUpdateRequest()
{
userid = accountModel.WorkUserId,
name = accountModel.AccountName,
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
enable = 1,
};
var upmodel = QYWeiXinHelper.UpdateMember(model.Token, updateMember);
if (upmodel.errcode != Senparc.Weixin.ReturnCode_Work.请求成功)
{
LogHelper.Write("员工 " + model.MName + "(" + Id + ") 更新企业微信失败;" + upmodel.errmsg);
}
}
}
}
......
......@@ -317,108 +317,118 @@ namespace Edu.Module.User
{
var accountModel = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { AccountType = AccountTypeEnum.Teacher, AccountId = model.TId })?.FirstOrDefault();
if (string.IsNullOrEmpty(accountModel.WorkUserId) && IsLeave == false) { IsInsert = true; }//走新增方法
if (IsInsert)
Common.Plugin.LogHelper.WriteInfo(string.Format("SetTeacherModule:: AccountUserType {0} Name {1}", model.AccountUserType, model.TeacherName));
//甲鹤员工才同步到企业微信
if (model.AccountUserType == 1)
{
//成员UserID。对应管理端的帐号,企业内必须唯一。不区分大小写,长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。
string userId = accountModel.Id + "_" + DateTime.Now.ToString("yyyyMMddHHmmssffff@") + (new Random().Next(1000, 9999));//规则生成
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
//新增用户
var inserMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberCreateRequest()
{
to_invite = true,
alias = "",
userid = userId,
name = accountModel.AccountName,
english_name = "",
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
email = "",
enable = 1,
avatar_mediaid = "",
telephone = "",
address = "",
};
try
{
var cmodel = QYWeiXinHelper.CreateMember(model.Token, inserMember);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Account_ViewModel.WorkUserId),userId}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=accountModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + cmodel.errmsg);
}
}
catch (Exception ex)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + ex.Message);
}
}
else
{
//修改企业微信用户
if (IsLeave)
{
var cmodel = QYWeiXinHelper.DeleteMember(model.Token, accountModel.WorkUserId);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Account_ViewModel.WorkUserId),""}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 删除企业微信失败;" + cmodel.errmsg);
}
}
else
if (IsInsert)
{
//获取部门信息
//成员UserID。对应管理端的帐号,企业内必须唯一。不区分大小写,长度为1~64个字节。只能由数字、字母和“_-@.”四种字符组成,且第一个字符必须是数字或字母。
string userId = accountModel.Id + "_" + DateTime.Now.ToString("yyyyMMddHHmmssffff@") + (new Random().Next(1000, 9999));//规则生成
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
var updateMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberUpdateRequest()
//新增用户
var inserMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberCreateRequest()
{
userid = accountModel.WorkUserId,
to_invite = true,
alias = "",
userid = userId,
name = accountModel.AccountName,
english_name = "",
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
email = "",
enable = 1,
avatar_mediaid = "",
telephone = "",
address = "",
};
var upmodel = QYWeiXinHelper.UpdateMember(model.Token, updateMember);
if (upmodel.errcode != Senparc.Weixin.ReturnCode_Work.请求成功)
try
{
var cmodel = QYWeiXinHelper.CreateMember(model.Token, inserMember);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Account_ViewModel.WorkUserId),userId}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=accountModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + cmodel.errmsg);
}
}
catch (Exception ex)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 更新企业微信失败;" + upmodel.errmsg);
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 创建企业微信失败;" + ex.Message);
}
}
}
});
else
{
//修改企业微信用户
if (IsLeave)
{
var cmodel = QYWeiXinHelper.DeleteMember(model.Token, accountModel.WorkUserId);
if (cmodel.errcode == Senparc.Weixin.ReturnCode_Work.请求成功)
{
//更新账户表企业微信id
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Account_ViewModel.WorkUserId),""}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Account_ViewModel.Id),
FiledValue=Id,
OperatorEnum=OperatorEnum.Equal
}
};
accountRepository.Update(keyValues, wheres);
}
else
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 删除企业微信失败;" + cmodel.errmsg);
}
}
else
{
//获取部门信息
int wxDeptId = departmentRepository.GetEntity(accountModel.Dept_Id)?.WorkDepartId ?? 1;
var updateMember = new Senparc.Weixin.Work.AdvancedAPIs.MailList.Member.MemberUpdateRequest()
{
userid = accountModel.WorkUserId,
name = accountModel.AccountName,
mobile = accountModel.Account,
department = new long[] { wxDeptId },
order = new long[] { 0 },
position = accountModel.PostName,
gender = (model.Sex + 1).ToString(),
enable = 1,
};
var upmodel = QYWeiXinHelper.UpdateMember(model.Token, updateMember);
if (upmodel.errcode != Senparc.Weixin.ReturnCode_Work.请求成功)
{
LogHelper.Write("员工 " + accountModel.AccountName + "(" + accountModel.Id + ") 更新企业微信失败;" + upmodel.errmsg);
}
}
}
} });
}
}
return flag;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment