/// <summary> /// 获取消息 /// </summary> /// <param name="tenantId"></param> /// <param name="id"></param> /// <returns></returns> public MessageInfo Get(int tenantId, int id) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); return(MessageDao.Get(tenantId, id)); }
/// <summary> /// 获取开放平台帐号信息(从多租赁) /// </summary> /// <param name="tenantId"></param> /// <param name="appAccountId"></param> /// <returns></returns> public AppAccountInfo GetMultiTenant(int tenantId, string appAccountId) { ArgumentHelper.AssertIsTrue(tenantId > 0, "TenantId is 0"); ArgumentHelper.AssertIsTrue(!string.IsNullOrWhiteSpace(appAccountId), "appAccountId is null or empty"); return(AppAccountDao.GetMultiTenant(tenantId, appAccountId)); }
public List <AppUserAccountInfo> GetListByUserId(int tenantId, string[] userIds, string appId) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(userIds != null && userIds.Length > 0, "userIds is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(appId, "appId is null"); var result = new List <AppUserAccountInfo>(); if (userIds.Length > 100) { var userIdGroup = new List <string>(); var group = new List <string>(); for (var i = 1; i <= userIds.Length; i++) { group.Add(userIds[i]); if (i % 100 == 0) { userIdGroup.Add(string.Join("|", group)); group = new List <string>(); } } foreach (var ug in userIdGroup) { result.AddRange(AppUserAccountDao.GetListByUserId(tenantId, ug, appId)); } } else { result.AddRange(AppUserAccountDao.GetListByUserId(tenantId, string.Join(",", userIds), appId)); } return(result); }
/// <summary> /// 获取绑定批次 /// </summary> /// <param name="tenantId"></param> /// <param name="id"></param> /// <returns></returns> public BindBatchInfo Get(int tenantId, int id) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); return(BindBatchDao.Get(tenantId, id)); }
/// <summary> /// 更新主账户ID /// </summary> /// <param name="id"></param> /// <param name="masterAccountId"></param> public void UpdateMasterAccountId(int id, int masterAccountId) { ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); ArgumentHelper.AssertIsTrue(masterAccountId > 0, "tenantId is 0"); AppUserAccountDao.UpdateMasterAccountId(id, masterAccountId); }
/// <summary> /// 更新批次状态 /// </summary> /// <param name="tenantId"></param> /// <param name="id"></param> /// <param name="state"></param> public void UpdateState(int tenantId, int id, BindBatchState state) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); BindBatchDao.UpdateState(tenantId, id, state); }
/// <summary> /// 更新用户账户状态 /// </summary> /// <param name="tenantId"></param> /// <param name="id"></param> /// <param name="state"></param> public void UpdateState(int tenantId, int id, AppUserAccountState state) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); AppUserAccountDao.UpdateState(tenantId, id, state); }
public void UpdateSendResult(int tenantId, int id, string messageId, MessageState state, string result) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); MessageDao.UpdateSendResult(tenantId, id, messageId, state, result); }
/// <summary> /// 增加开放平台帐号信息 /// </summary> /// <param name="tenantId"></param> /// <param name="info"></param> /// <param name="isSaveMultiTenant"></param> public string Add(int tenantId, AppAccountInfo info, bool isSaveMultiTenant = true) { ArgumentHelper.AssertIsTrue(tenantId > 0, "TenantId is 0"); ArgumentHelper.AssertIsTrue(info != null, "AppAccountInfo is null"); ArgumentHelper.AssertIsTrue(info.TenantId > 0, "AppAccountInfo.TenantId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.Name, "AppAccountInfo.AppAccountName is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(info.AppId, "AppAccountInfo.AppId is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(info.AppSecret, "AppAccountInfo.AppSecret is null or empty"); AppAccountDao.Insert(info); if (isSaveMultiTenant && info.TenantId > 1) { try { AppAccountDao.SaveMultiTenant(info); } catch (Exception ex) { AppConnectLogHelper.Error("保存多租赁信息出错,AppAccountId=" + info.AppAccountId, ex); } } return(info.AppAccountId); }
public List <AppAccountInfo> GetListByAppId(int tenantId, List <string> appIds) { ArgumentHelper.AssertIsTrue(tenantId > 0, "TenantId is 0"); ArgumentHelper.AssertIsTrue(appIds != null && appIds.Count > 0, "appIds is null or empty"); return(AppAccountDao.GetListByAppId(tenantId, string.Join(",", appIds))); }
public AppAccountInfo GetByTag(int tenantId, string tag) { ArgumentHelper.AssertIsTrue(tenantId > 0, "TenantId is 0"); ArgumentHelper.AssertIsTrue(!string.IsNullOrWhiteSpace(tag), "tag is null or empty"); return(AppAccountDao.GetByTag(tenantId, tag)); }
/// <summary> /// 根据Id获取用户账户 /// </summary> /// <param name="tenantId"></param> /// <param name="id"></param> /// <returns></returns> public AppUserAccountInfo GetById(int tenantId, int id) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); return(AppUserAccountDao.GetById(tenantId, id)); }
/// <summary> /// 根据UserId获取用户 /// </summary> /// <param name="tenantId"></param> /// <param name="userId"></param> /// <param name="appId"></param> /// <returns></returns> public AppUserAccountInfo GetByUserId(int tenantId, int userId, string appId) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(userId > 0, "userId is 0"); ArgumentHelper.AssertNotNullOrEmpty(appId, "appId is null"); return(AppUserAccountDao.GetByUserId(tenantId, userId, appId)); }
/// <summary> /// 增加二维码登录 /// </summary> /// <param name="info"></param> /// <returns></returns> public void Add(QrCodeLoginInfo info) { ArgumentHelper.AssertIsTrue(info != null, "QrCodeLoginInfo is null"); ArgumentHelper.AssertNotNullOrEmpty(info.Code, "QrCodeLoginInfo.Code is null or empty"); ArgumentHelper.AssertIsTrue(info.TitaAppId > 0, "info.TitaAppId is less than 0"); QrCodeLoginDao.Insert(info); }
/// <summary> /// 根据TenantId和状态获取用户 /// </summary> /// <param name="tenantId"></param> /// <param name="appId"></param> /// <param name="states"></param> /// <returns></returns> public List <AppUserAccountInfo> GetByTenantId(int tenantId, string appId, string states) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertNotNullOrEmpty(appId, "appId is null"); ArgumentHelper.AssertNotNullOrEmpty(states, "states is null"); return(AppUserAccountDao.GetByTenantId(tenantId, appId, states)); }
/// <summary> /// 更新邮件、短信发送批次 /// </summary> /// <param name="tenantId"></param> /// <param name="id"></param> /// <param name="batchId"></param> public void UpdateBatchId(int tenantId, int id, string batchId) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(id > 0, "id is 0"); ArgumentHelper.AssertNotNullOrEmpty(batchId, "batchId is null"); BindBatchDao.UpdateBatchId(tenantId, id, batchId); }
/// <summary> /// 更新开放平台帐号信息(多租赁) /// </summary> /// <param name="tenantId"></param> /// <param name="appAccountId"></param> /// <returns></returns> public void UpdateMultiTenant(int tenantId, string appAccountId) { ArgumentHelper.AssertIsTrue(tenantId > 0, "TenantId is 0"); ArgumentHelper.AssertIsTrue(!string.IsNullOrWhiteSpace(appAccountId), "appAccountId is null or empty"); var appAccount = Get(appAccountId); AppAccountDao.SaveMultiTenant(appAccount); }
public List <AppUserAccountInfo> ConvertToUserId(string appAccountId, List <string> openIds) { ArgumentHelper.AssertNotNullOrEmpty(appAccountId, "appId is null"); ArgumentHelper.AssertIsTrue(openIds != null && openIds.Count > 0, "openId is null"); var appAccount = ProviderGateway.AppAccountProvider.Get(appAccountId); return(AppUserAccountDao.ConvertToUserId(appAccount.TenantId, appAccount.AppId, string.Join(",", openIds))); }
/// <summary> /// 获取Ticket /// </summary> /// <param name="account"></param> /// <param name="ticketType"></param> /// <param name="getNewToken"></param> /// <returns></returns> public string GetTicket(AppAccountInfo account, string ticketType, bool getNewToken = false) { ArgumentHelper.AssertIsTrue(account != null, "AppAccountInfo is null"); ArgumentHelper.AssertNotNullOrEmpty(ticketType, "ticketType is null or empty"); var token = ProviderGateway.TokenProvider.GetToken(account); var ticketInstance = TicketFactory.GetTicketIntance(account); return(ticketInstance.GetTicket(account, token, ticketType, getNewToken)); }
/// <summary> /// 增加绑定批次 /// </summary> /// <param name="tenantId"></param> /// <param name="info"></param> /// <returns></returns> public int Add(int tenantId, BindBatchInfo info) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertNotNull(info, "info is null"); ArgumentHelper.AssertIsTrue(info.TenantId > 0, "info.TenantId is 0"); ArgumentHelper.AssertIsTrue(info.AppUserAccountId > 0, "info.AppUserAccountId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.BeisenAccount, "info.BeisenAccount is null"); return(BindBatchDao.Insert(tenantId, info)); }
public int Add(MessageInfo info) { ArgumentHelper.AssertIsTrue(info != null, "MessageInfo is null"); ArgumentHelper.AssertNotNullOrEmpty(info.BatchId, "MessageInfo.BatchId is null or empty"); ArgumentHelper.AssertIsTrue(info.TenantId > 0, "MessageInfo.TenantId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.AppAccountId, "MessageInfo.AppAccountId is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(info.ContentJson, "MessageInfo.ContentJson is null or empty"); return(MessageDao.Insert(info)); }
/// <summary> /// 增加返回信息 /// </summary> /// <param name="content"></param> public void Add(CallbackContentInfo content) { ArgumentHelper.AssertIsTrue(content != null, "content is null"); ArgumentHelper.AssertIsTrue(content.TenantId >= 0, "AppAccountInfo.TenantId is less than 0"); ArgumentHelper.AssertNotNullOrEmpty(content.BatchId, "content.BatchId is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(content.AppAccountPublic, "content.AppAccountPublic is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(content.Content, "content.Content is null or empty"); CallbackContentDao.Insert(content); }
public void Update(int tenantId, MenuInfo info) { ArgumentHelper.AssertIsTrue(info != null, "MenuInfo is null"); ArgumentHelper.AssertNotNullOrEmpty(info.MenuId, "MenuInfo.MenuId is null or empty"); ArgumentHelper.AssertNotNullOrEmpty(info.Name, "MenuInfo.Name is null or empty"); ArgumentHelper.AssertIsTrue(info.TenantId > 0, "MenuInfo.TenantId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.AppAccountId, "MenuInfo.AppAccountId is null or empty"); ArgumentHelper.AssertIsTrue(info.BeisenAppId > 0, "MenuInfo.BeisenAppId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.Url, "MenuInfo.Url is null or empty"); MenuDao.Update(info); }
/// <summary> /// 增加用户账户 /// </summary> /// <param name="tenantId"></param> /// <param name="appUserAccountInfo"></param> public int AddOrUpdate(int tenantId, AppUserAccountInfo appUserAccountInfo) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertNotNull(appUserAccountInfo, "appUserAccountInfo is null"); ArgumentHelper.AssertNotNullOrEmpty(appUserAccountInfo.AppId, "appUserAccountInfo.appId is null"); ArgumentHelper.AssertNotNullOrEmpty(appUserAccountInfo.OpenId, "appUserAccountInfo.openId is null"); ArgumentHelper.AssertIsTrue(appUserAccountInfo.TenantId > 0, "appUserAccountInfo.TenantId is 0"); ArgumentHelper.AssertIsTrue(appUserAccountInfo.UserId > 0, "appUserAccountInfo.UserId is 0"); var sqlId = AppUserAccountDao.InsertOrUpdate(tenantId, appUserAccountInfo); AppUserAccountDao.AddOrUpdateCLoud(tenantId, sqlId, appUserAccountInfo); return(sqlId); }
/// <summary> /// 获取用户身份并返回回调地址 /// </summary> /// <param name="code"></param> /// <param name="state"></param> /// <param name="batch"></param> /// <returns></returns> public string GetRedirectUrl(string code, string state, string batch) { ArgumentHelper.AssertIsTrue(!string.IsNullOrWhiteSpace(batch), "batch is null or empty"); ArgumentHelper.AssertIsTrue(!string.IsNullOrWhiteSpace(state), "state is null or empty"); var callbackContent = ProviderGateway.CallbackContentProvider.GetByBatchId(batch); //获取回调地址 var handler = CallbackStateFactory.GetIntance(callbackContent); var url = handler.GetRedirectUrl(callbackContent, code, state); return(url); }
public string Create(int tenantId, MenuInfo info) { ArgumentHelper.AssertIsTrue(info != null, "MenuInfo is null"); ArgumentHelper.AssertNotNullOrEmpty(info.Name, "MenuInfo.Name is null or empty"); ArgumentHelper.AssertIsTrue(info.TenantId > 0, "MenuInfo.TenantId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.AppAccountId, "MenuInfo.AppAccountId is null or empty"); ArgumentHelper.AssertIsTrue(info.BeisenAppId > 0, "MenuInfo.BeisenAppId is 0"); ArgumentHelper.AssertNotNullOrEmpty(info.Url, "MenuInfo.Url is null or empty"); info.MenuId = Guid.NewGuid().ToString(); MenuDao.Insert(info); return(info.MenuId); }
/// <summary> /// 根据类型获取公共开放平台帐号 /// </summary> /// <param name="type"></param> /// <returns></returns> public AppAccountInfo GetPublicByType(int type) { //公共开放平台帐号 ArgumentHelper.AssertIsTrue(type > 0, "type is null or empty"); switch (type) { case 11: case 13: type = 12; break; } return(AppAccountDao.GetPubilicByType(type)); }
/// <summary> /// 更新二维码用户信息 /// </summary> /// <param name="code"></param> /// <param name="state"></param> /// <param name="tenantId"></param> /// <param name="userId"></param> public void UpdateIdentity(string code, QrCodeLoginState state, int tenantId, int userId) { ArgumentHelper.AssertNotNullOrEmpty(code, "Code is null or empty"); ArgumentHelper.AssertIsTrue(tenantId > 0, "TenantId is less than 0"); ArgumentHelper.AssertIsTrue(userId > 0, "TenantId is less than 0"); var info = GetByCode(code); if (info != null) { info.State = state; info.TenantId = tenantId; info.UserId = userId; QrCodeLoginDao.UpdateIdentity(info); } }
/// <summary> /// 解绑账户 /// </summary> /// <param name="tenantId"></param> /// <param name="userId"></param> /// <param name="ids"></param> public void UnBind(int tenantId, int userId, string ids) { ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0"); ArgumentHelper.AssertIsTrue(userId > 0, "userId is 0"); ArgumentHelper.AssertNotNullOrEmpty(ids, "ids is null"); var appUsers = AppUserAccountDao.GetAppUserList(tenantId, ids); if (appUsers != null && appUsers.Count > 0) { var sqlIds = appUsers.Select(s => s["SqlId"] == null ? "" : s["SqlId"].ToString()).ToList(); if (sqlIds != null && sqlIds.Count > 0) { var convertSqlIds = string.Join <string>(",", sqlIds); AppUserAccountDao.UnbindCloud(tenantId, userId, ids); AppUserAccountDao.UnBind(tenantId, userId, convertSqlIds); } } }
private void VaildMessageType(int tenant_id, int user_id, MessageArgumentForTita message) { ArgumentHelper.AssertIsTrue(tenant_id > 0, "current tenant_id is 0"); ArgumentHelper.AssertIsTrue(user_id > 0, "current user_id is 0"); AppConnectLogHelper.DebugFormat("开始调用消息接口,租户:{0},发送者:{1}", tenant_id, user_id); if (string.IsNullOrWhiteSpace(message.productId)) { throw new Exception("ProductId is null or empty!"); } if (string.IsNullOrWhiteSpace(message.messageType)) { throw new Exception("MessageType is null or empty!"); } if (string.IsNullOrWhiteSpace(message.receiverId)) { throw new Exception("ReceiverId is null or empty!!"); } }