public void updateStatus(int tenantId, string[] userMappingInfoId)
        {
            var metaobj             = CloudDataHelper.GetMetaObject(tenantId, UserInfoMappingConstants.MetaName);
            var userMappingInfoList = CloudDataHelper.GetEntityListByIds(UserInfoMappingConstants.MetaName, tenantId, userMappingInfoId).ToList();

            if (userMappingInfoList != null && userMappingInfoList.Any())
            {
                foreach (var item in userMappingInfoList)
                {
                    item["Status"] = (int)BindStatusEnum.unbind;
                    CloudDataHelper.Update(metaobj, new List <ObjectData> {
                        item
                    });

                    //解绑公共租户数据
                    var filter = new BooleanFilter()
                                 .Must(new TermFilter(UserInfoMappingConstants.UserInfo_StaffId, Convert.ToInt32(item["StaffId"])))
                                 .Must(new TermFilter(UserInfoMappingConstants.UserInfo_SuiteKey, SystemInfo.SuiteKey))
                                 .Must(new TermFilter(UserInfoMappingConstants.UserInfo_CorpId, Convert.ToString(item["CorpId"])))
                                 .Must(new TermFilter(UserInfoMappingConstants.UserInfo_AppId, Convert.ToString(item["AppId"])))
                                 .Must(new TermFilter(UserInfoMappingConstants.UserInfo_Status, (int)BindStatusEnum.bind));

                    var sysMetaobj      = CloudDataHelper.GetMetaObject(SystemInfo.ISVSystemTenantId, UserInfoMappingConstants.MetaName);
                    var sysUserInfoList = CloudDataHelper.GetEntityAllList(UserInfoMappingConstants.MetaName, SystemInfo.ISVSystemTenantId, filter).ToList().FirstOrDefault();
                    sysUserInfoList["Status"] = (int)BindStatusEnum.unbind;
                    CloudDataHelper.Update(sysMetaobj, new List <ObjectData> {
                        sysUserInfoList
                    });
                }
            }
        }
Exemplo n.º 2
0
        private static void AddCLoud(int tenantId, int sqlId, AppUserAccountInfo appUserAccountInfo)
        {
            ApplicationContext.Current.ApplicationName = "AppConnect";
            ApplicationContext.Current.TenantId        = tenantId;
            ApplicationContext.Current.UserId          = appUserAccountInfo.UserId;

            var metaObject = CloudDataHelper.GetMetaObject(tenantId, "AppConnect.AppUser");
            List <ObjectData> objectDatas = new List <ObjectData>();
            ObjectData        objectData  = new ObjectData(metaObject);

            objectData.ID                 = Guid.NewGuid();
            objectData.CreatedBy          = appUserAccountInfo.UserId;
            objectData.CreatedTime        = DateTime.Now;
            objectData.ModifiedBy         = appUserAccountInfo.UserId;
            objectData.ModifiedTime       = DateTime.Now;
            objectData["StdIsDeleted"]    = false;
            objectData["TenantId"]        = tenantId;
            objectData["UserId"]          = appUserAccountInfo.UserId;
            objectData["UserEmail"]       = appUserAccountInfo.BeisenAccount;
            objectData["State"]           = (int)appUserAccountInfo.State;
            objectData["ActivateTime"]    = DateTime.Now;
            objectData["OpenId"]          = appUserAccountInfo.OpenId;
            objectData["AppId"]           = appUserAccountInfo.AppId;
            objectData["SqlId"]           = sqlId;
            objectData["LoginType"]       = ((int)appUserAccountInfo.Type).ToString();
            objectData["MasterAccountId"] = appUserAccountInfo.MasterAccountId;
            objectDatas.Add(objectData);
            CloudDataHelper.Add(metaObject, objectDatas);
        }
        /// <summary>
        /// account 人员离职,删除后删除相应人员的绑定信息
        /// </summary>
        /// <param name="tenantId"></param>
        /// <param name="userId"></param>
        public void UnBindInfo(int tenantId, int userId)
        {
            var filter = new BooleanFilter()
                         .Must(new TermFilter(UserInfoMappingConstants.UserInfo_ISVTenantId, tenantId))
                         .Must(new TermFilter(UserInfoMappingConstants.UserInfo_StaffId, userId))
                         .Must(new TermFilter(UserInfoMappingConstants.UserInfo_SuiteKey, SystemInfo.SuiteKey));

            var metaobj      = CloudDataHelper.GetMetaObject(tenantId, UserInfoMappingConstants.MetaName);
            var userInfoList = CloudDataHelper.GetEntityAllList(UserInfoMappingConstants.MetaName, tenantId, filter).ToList();

            if (userInfoList != null && userInfoList.Any())
            {
                userInfoList.ForEach(n =>
                {
                    n["Status"] = (int)BindStatusEnum.unbind;
                });
                CloudDataHelper.Update(metaobj, userInfoList);
            }

            var sysMetaObj      = CloudDataHelper.GetMetaObject(SystemInfo.ISVSystemTenantId, UserInfoMappingConstants.MetaName);
            var sysUserInfoList = CloudDataHelper.GetEntityAllList(UserInfoMappingConstants.MetaName, SystemInfo.ISVSystemTenantId, filter).ToList();

            if (sysUserInfoList != null && sysUserInfoList.Any())
            {
                sysUserInfoList.ForEach(n =>
                {
                    n["Status"] = (int)BindStatusEnum.unbind;
                });
                CloudDataHelper.Update(sysMetaObj, sysUserInfoList);
            }
        }
Exemplo n.º 4
0
        private static ObjectData IsExistLogin(int tenantId, AppUserAccountInfo appUserAccountInfo)
        {
            ApplicationContext.Current.ApplicationName = AppUserConstants.MetaName;
            ApplicationContext.Current.TenantId        = tenantId;
            ApplicationContext.Current.UserId          = appUserAccountInfo.UserId;
            ObjectData objectData = new ObjectData();
            var        filter     = new BooleanFilter()
                                    .Must(new TermFilter(AppUserConstants.AppUser_AppId, appUserAccountInfo.AppId))
                                    .Must(new TermFilter(AppUserConstants.AppUser_OpenId, appUserAccountInfo.OpenId));
            // .Must(new TermFilter(AppUserConstants.AppUser_UserId, appUserAccountInfo.UserId));
            var result = CloudDataHelper.GetEntityAllList("AppConnect.AppUser", tenantId, filter).ToList();

            if (result != null && result.Count > 0)
            {
                if (result.Count > 1)
                {
                    AppConnectLogHelper.Error("AppId下面的OpenId个数大于一个!appUserAccountInfo:" + JsonConvert.SerializeObject(appUserAccountInfo));
                    objectData = null;
                }
                else
                {
                    objectData = result.First();
                }
            }
            else
            {
                objectData = null;
            }
            return(objectData);
        }
Exemplo n.º 5
0
        private static void AddCloudData(int tenantId, List <AppUserAccountInfo> appUserAccountInfos, ref string message)
        {
            try
            {
                message += string.Format("租户:{0} 开始处理数据\r\n", tenantId);
                BeisenUserDao.SetContext(tenantId);
                //先删除该租户数据
                List <string> delObjectIds = new List <string>();
                var           multiDataDic = GetMultiTenantData(tenantId);
                foreach (var item in multiDataDic)
                {
                    if (!delObjectIds.Contains(Convert.ToString(item.ID)))
                    {
                        delObjectIds.Add(Convert.ToString(item.ID));
                    }
                }
                CloudDataHelper.Delete("AppConnect.AppUser", tenantId, delObjectIds.ToArray());

                message += string.Format("租户:{0} 开始删除{1}条数据\r\n", tenantId, delObjectIds.Count);

                var metaObject = CloudDataHelper.GetMetaObject(tenantId, "AppConnect.AppUser");
                List <ObjectData> objectDatas = new List <ObjectData>();
                foreach (var appUserAccountInfo in appUserAccountInfos)
                {
                    ObjectData objectData = new ObjectData(metaObject);
                    objectData.ID                 = Guid.NewGuid();
                    objectData.CreatedBy          = appUserAccountInfo.UserId;
                    objectData.CreatedTime        = appUserAccountInfo.CreateTime;
                    objectData.ModifiedBy         = appUserAccountInfo.UserId;
                    objectData.ModifiedTime       = appUserAccountInfo.ModifyTime;
                    objectData["StdIsDeleted"]    = false;
                    objectData["TenantId"]        = appUserAccountInfo.TenantId;
                    objectData["UserId"]          = appUserAccountInfo.UserId;
                    objectData["UserEmail"]       = appUserAccountInfo.BeisenAccount;
                    objectData["State"]           = appUserAccountInfo.StateNotEnum;
                    objectData["ActivateTime"]    = appUserAccountInfo.CreateTime;
                    objectData["OpenId"]          = appUserAccountInfo.OpenId;
                    objectData["AppId"]           = appUserAccountInfo.AppId;
                    objectData["SqlId"]           = appUserAccountInfo.Id;
                    objectData["LoginType"]       = appUserAccountInfo.TypeNotEnum;
                    objectData["SqlId"]           = appUserAccountInfo.Id;
                    objectData["MasterAccountId"] = appUserAccountInfo.MasterAccountId;
                    objectDatas.Add(objectData);
                }
                CloudDataHelper.Add(metaObject, objectDatas);
                message += string.Format("租户:{0} 处理完毕,共处理{1}条数据 \r\n", tenantId, objectDatas.Count);
            }
            catch (Exception ex)
            {
                message += string.Format("租户:{0} 修复数据失败!\r\n", tenantId);
                AppConnectLogHelper.ErrorFormat(message, ex);
                Froms.MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 删除数据记录(Cloud)
        /// </summary>
        /// <param name="tenantId"></param>
        /// <param name="userId"></param>
        internal static void DeleteCLoud(int tenantId, int userId)
        {
            ApplicationContext.Current.ApplicationName = "AppConnect";
            ApplicationContext.Current.TenantId        = tenantId;
            ApplicationContext.Current.UserId          = userId;
            var filter = new BooleanFilter()
                         .Must(new TermFilter(AppUserConstants.AppUser_UserId, userId));
            var resultList    = CloudDataHelper.GetEntityAllList("AppConnect.AppUser", tenantId, filter);
            var objectDataIds = resultList.Select(t => Convert.ToString(t.ID));

            CloudDataHelper.Delete("AppConnect.AppUser", tenantId, objectDataIds.ToArray());
        }
        public void DeletedUIBuilderComponentTest()
        {
            ApplicationContext.Current.ApplicationName = AppUserConstants.ApplicationName;
            ApplicationContext.Current.TenantId        = 100002;
            ApplicationContext.Current.UserId          = 112737565;
            var aa      = CloudDataHelper.GetEntityAllList(AppUserConstants.MetaName, 100002).ToList();
            var oidList = CloudDataHelper.GetEntityAllList(AppUserConstants.MetaName, 100002).Select(s => s.ID.ToString()).ToArray();

            CloudDataHelper.Delete(AppUserConstants.MetaName, 100002, oidList.ToArray());

            //  var oidList = CloudDataHelper.GetEntityAllList(UPaasPortalApp.UIBuilderComponentMetaName, TenantId).ToArray();
            // CloudDataHelper.Delete(AppUserConstants.MetaName, 100002, "1cfedd2b-2035-46c3-8a30-9e126ed681c4");
        }
Exemplo n.º 8
0
        private static List <ObjectData> GetMultiTenantData(int tenantId)
        {
            var sortString = string.Format("{0}.{1}", "AppConnect.AppUser", "SqlId");
            Dictionary <string, SortDirection> sortFields = new Dictionary <string, SortDirection>();

            sortFields.Add(sortString, SortDirection.Asc);
            var list = CloudDataHelper.GetEntityAllList("AppConnect.AppUser", tenantId, sortFields: sortFields);

            if (list == null)
            {
                return(null);
            }
            return(list.ToList());
        }
Exemplo n.º 9
0
 internal static List <ObjectData> GetAppUserList(int tenantId, string ids)
 {
     if (!string.IsNullOrWhiteSpace(ids))
     {
         var filter = new BooleanFilter()
                      .Must(new TermsFilter("_id", ids.Split(',').ToArray()))
                      .Must(new TermFilter("AppConnect.AppUser.StdIsDeleted", false));
         var result = CloudDataHelper.GetEntityAllList("AppConnect.AppUser", tenantId, filter);
         return(result.ToList());
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 10
0
 internal static void UpdateCLoud(int tenantId, int sqlId, ObjectData objectData, AppUserAccountInfo appUserAccountInfo)
 {
     ApplicationContext.Current.ApplicationName = "AppConnect";
     ApplicationContext.Current.TenantId        = tenantId;
     ApplicationContext.Current.UserId          = appUserAccountInfo.UserId;
     objectData["AppId"]           = appUserAccountInfo.AppId;
     objectData["OpenId"]          = appUserAccountInfo.OpenId;
     objectData["UserId"]          = appUserAccountInfo.UserId;
     objectData["UserEmail"]       = appUserAccountInfo.BeisenAccount;
     objectData["State"]           = (int)appUserAccountInfo.State;
     objectData["LoginType"]       = ((int)appUserAccountInfo.Type).ToString();
     objectData["ActivateTime"]    = DateTime.Now;
     objectData["MasterAccountId"] = appUserAccountInfo.MasterAccountId;
     objectData["SqlId"]           = sqlId;
     objectData.ModifiedBy         = appUserAccountInfo.UserId;
     objectData.ModifiedTime       = DateTime.Now;
     CloudDataHelper.Update(objectData);
 }
Exemplo n.º 11
0
 private static void AddCLoud(int tenantId, List <AppUserAccountInfo> appUserAccountInfos, ref string message)
 {
     try
     {
         BeisenUserDao.SetContext(tenantId);
         message += string.Format("租户:{0} 开始处理\r\n", tenantId);
         var metaObject = CloudDataHelper.GetMetaObject(tenantId, "AppConnect.AppUser");
         List <ObjectData> objectDatas    = new List <ObjectData>();
         var appUserAccountInfos_tenantId = appUserAccountInfos.Where(w => w.TenantId == tenantId).ToList();
         if (appUserAccountInfos_tenantId != null && appUserAccountInfos_tenantId.Count > 0)
         {
             appUserAccountInfos_tenantId.ForEach(appUserAccountInfo =>
             {
                 ObjectData objectData         = new ObjectData(metaObject);
                 objectData.ID                 = Guid.NewGuid();
                 objectData.CreatedBy          = appUserAccountInfo.UserId;
                 objectData.CreatedTime        = DateTime.Now;
                 objectData.ModifiedBy         = appUserAccountInfo.UserId;
                 objectData.ModifiedTime       = DateTime.Now;
                 objectData["StdIsDeleted"]    = false;
                 objectData["TenantId"]        = appUserAccountInfo.TenantId;
                 objectData["UserId"]          = appUserAccountInfo.UserId;
                 objectData["UserEmail"]       = appUserAccountInfo.BeisenAccount;
                 objectData["State"]           = appUserAccountInfo.StateNotEnum;
                 objectData["ActivateTime"]    = DateTime.Now;
                 objectData["OpenId"]          = appUserAccountInfo.OpenId;
                 objectData["AppId"]           = appUserAccountInfo.AppId;
                 objectData["SqlId"]           = appUserAccountInfo.Id;
                 objectData["LoginType"]       = appUserAccountInfo.TypeNotEnum;
                 objectData["SqlId"]           = appUserAccountInfo.Id;
                 objectData["MasterAccountId"] = appUserAccountInfo.MasterAccountId;
                 objectDatas.Add(objectData);
             });
         }
         CloudDataHelper.Add(metaObject, objectDatas);
         message += string.Format("租户:{0} 处理完毕,共处理{objectDatas.Count}条数据 \r\n", tenantId);
     }
     catch (Exception ex)
     {
         message += string.Format("租户:{0} 修复数据失败!\r\n", tenantId);
         AppConnectLogHelper.ErrorFormat(message, ex);
         Froms.MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 12
0
        internal static void UnbindCloud(int tenantId, int userId, string ids)
        {
            ApplicationContext.Current.ApplicationName = "AppConnect";
            ApplicationContext.Current.TenantId        = tenantId;
            ApplicationContext.Current.UserId          = userId;
            var appUsers = GetAppUserList(tenantId, ids);

            if (appUsers != null && appUsers.Count > 0)
            {
                var metaObject = CloudDataHelper.GetMetaObject(tenantId, "AppConnect.AppUser");
                appUsers.ForEach(appUser =>
                {
                    appUser["State"]     = (int)AppUserAccountState.Unbind;
                    appUser.ModifiedBy   = userId;
                    appUser.ModifiedTime = DateTime.Now;
                });
                CloudDataHelper.Update(metaObject, appUsers);
            }
        }
Exemplo n.º 13
0
        public void DeletedAllTenantId()
        {
            var appUserAccountInfos = GetAppUserAccountInSql();

            if (appUserAccountInfos != null && appUserAccountInfos.Count > 0)
            {
                var tenantIds = GetTenantId(appUserAccountInfos);
                if (tenantIds != null && tenantIds.Count > 0)
                {
                    foreach (var tenantId in tenantIds)
                    {
                        ApplicationContext.Current.ApplicationName = AppUserConstants.ApplicationName;
                        ApplicationContext.Current.TenantId        = tenantId;
                        ApplicationContext.Current.UserId          = 112737565;
                        var oidList = CloudDataHelper.GetEntityAllList(AppUserConstants.MetaName, tenantId).Select(s => s.ID.ToString()).ToArray();
                        CloudDataHelper.Delete(AppUserConstants.MetaName, tenantId, oidList.ToArray());
                    }
                }
            }
        }
Exemplo n.º 14
0
        internal static void AddOrUpdateCLoud(int tenantId, int userId, AppAccountInfo info)
        {
            var metaObject = CloudDataHelper.GetMetaObject(tenantId, "AppConnect.AppUser");
            List <ObjectData> objectDatas = new List <ObjectData>();
            ObjectData        objectdata  = new ObjectData(metaObject);

            objectdata.ID              = Guid.NewGuid();
            objectdata.CreatedBy       = userId;
            objectdata.CreatedTime     = DateTime.Now;
            objectdata.ModifiedBy      = userId;
            objectdata.ModifiedTime    = DateTime.Now;
            objectdata["StdIsDeleted"] = false;
            objectdata["TenantId"]     = tenantId;
            objectdata["StaffID"]      = info.CreateBy;
            objectdata["UserEmail"]    = info.CreateBy;


            objectDatas.Add(objectdata);
            CloudDataHelper.Add(metaObject, objectDatas);
        }
Exemplo n.º 15
0
        public static void MigrationUserInfoMapping(string metaObjectName, ref string message)
        {
            try
            {
                var appId     = SqlHelper.GetAppIdByType();
                var appIdList = appId.Select(n => Convert.ToString(n.AppId)).ToList();
                var appIdStr  = string.Join(",", appIdList.ToArray());

                var userInfoList            = SqlHelper.GetInfoByAppId(appIdStr);
                var userInfoGroupByTenantId = userInfoList.GroupBy(n => n.TenantId);

                foreach (var item in userInfoGroupByTenantId)
                {
                    //存储到各个租户
                    var metaObj = CloudDataHelper.GetMetaObject(item.Key, metaObjectName);
                    List <ObjectData> objectDataList = new List <ObjectData>();
                    foreach (var info in item)
                    {
                        var data = saveCloud(metaObj, info);
                        objectDataList.Add(data);
                    }
                    CloudDataHelper.Add(metaObj, objectDataList);
                    //存储到公共租户
                    var sysMetaObj = CloudDataHelper.GetMetaObject(SystemInfo.ISVSystemTenantId, metaObjectName);
                    List <ObjectData> sysObjectDataList = new List <ObjectData>();
                    foreach (var info in item)
                    {
                        var data = saveCloud(sysMetaObj, info);
                        objectDataList.Add(data);
                    }
                    CloudDataHelper.Add(sysMetaObj, sysObjectDataList);
                }
            }
            catch (Exception ex)
            {
                message += string.Format("租户:{tenantId} 修复数据失败!\r\n");
                logger.ErrorFormat(message, ex);
                MessageBox.Show(message);
                return;
            }
        }
        public bool VerifyAppAccount(int tenantId, string agentId, string appSecret)
        {
            var result = false;
            //添加去重条件:AgentId、AppSecret
            //思路:根据AgentId过滤多租赁,数据为空,继续根据AppSecret过滤多租赁,数据为空,则没有重复,继续之后的保存、更新操作
            var agentIdFilter = new BooleanFilter()
                                .Must(new TermFilter(AppAccount.AppAccount_AgentId, agentId));
            var appAccountList = CloudDataHelper.GetEntityAllList(AppAccount.MetaName, tenantId, agentIdFilter).ToList();

            if (appAccountList.Count <= 0)
            {
                var appSecretFilter = new BooleanQuery()
                                      .Must(new MatchQuery(AppAccount.AppAccount_AppSecret, appSecret));
                var appAccount = CloudDataHelper.GetEntityAllList(AppAccount.MetaName, tenantId, queryJson: ElasticSearchSerialization.Serialize(appSecretFilter)).ToList();
                if (appAccount.Count <= 0)
                {
                    result = true;
                }
            }

            return(result);
        }
Exemplo n.º 17
0
 public static void RunRepair_UserId(List <int> tenantIdList, string metaObjectName, ref string message)
 {
     foreach (var tenantId in tenantIdList)
     {
         try
         {
             BeisenUserDao.SetContext(tenantId);
             message += string.Format("租户:{tenantId} 开始处理\r\n");
             var userInfoMappingList = CloudDataHelper.GetEntityAllList(metaObjectName, tenantId).ToList();
             var count = userInfoMappingList.Count;
             if (!userInfoMappingList.Any())
             {
                 message += string.Format("租户:{tenantId} 处理完毕,共处理{0}条数据 \r\n");
                 continue;
             }
             int tempId = 0;
             foreach (var item in userInfoMappingList)
             {
                 item["StaffId"] = item["UserId"];
                 tempId++;
             }
             if (tempId > 0)
             {
                 var metaobj = CloudDataHelper.GetMetaObject(tenantId, metaObjectName);
                 CloudDataHelper.Update(metaobj, userInfoMappingList);
             }
             message += string.Format("租户:{tenantId} 处理完毕,UserInfo映射信息共{count}条记录,处理{tempId}条数据 \r\n");
         }
         catch (Exception ex)
         {
             message += string.Format("租户:{tenantId} 修复数据失败!\r\n");
             logger.ErrorFormat(message, ex);
             MessageBox.Show(message);
             return;
         }
     }
 }
Exemplo n.º 18
0
        private void AddCLoud(int tenantId, List <AppUserAccountInfo> appUserAccountInfos)
        {
            ApplicationContext.Current.ApplicationName = "AppConnect";
            ApplicationContext.Current.TenantId        = tenantId;
            ApplicationContext.Current.UserId          = 100000;
            var metaObject = CloudDataHelper.GetMetaObject(tenantId, "AppConnect.AppUser");
            List <ObjectData> objectDatas    = new List <ObjectData>();
            var appUserAccountInfos_tenantId = appUserAccountInfos.Where(w => w.TenantId == tenantId).ToList();

            if (appUserAccountInfos_tenantId != null && appUserAccountInfos_tenantId.Count > 0)
            {
                appUserAccountInfos_tenantId.ForEach(appUserAccountInfo =>
                {
                    ObjectData objectData         = new ObjectData(metaObject);
                    objectData.ID                 = Guid.NewGuid();
                    objectData.CreatedBy          = appUserAccountInfo.UserId;
                    objectData.CreatedTime        = DateTime.Now;
                    objectData.ModifiedBy         = appUserAccountInfo.UserId;
                    objectData.ModifiedTime       = DateTime.Now;
                    objectData["StdIsDeleted"]    = false;
                    objectData["TenantId"]        = appUserAccountInfo.TenantId;
                    objectData["UserId"]          = appUserAccountInfo.UserId;
                    objectData["UserEmail"]       = appUserAccountInfo.BeisenAccount;
                    objectData["State"]           = appUserAccountInfo.StateNotEnum;
                    objectData["ActivateTime"]    = DateTime.Now;
                    objectData["OpenId"]          = appUserAccountInfo.OpenId;
                    objectData["AppId"]           = appUserAccountInfo.AppId;
                    objectData["SqlId"]           = appUserAccountInfo.Id;
                    objectData["LoginType"]       = appUserAccountInfo.TypeNotEnum;
                    objectData["SqlId"]           = appUserAccountInfo.Id;
                    objectData["MasterAccountId"] = appUserAccountInfo.MasterAccountId;
                    objectDatas.Add(objectData);
                });
            }
            CloudDataHelper.Add(metaObject, objectDatas);
        }