示例#1
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);
            }
        }
示例#2
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);
     }
 }
示例#3
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;
         }
     }
 }