public Result <CheckResult> Verify(ConfigedInfo appInfo, TargetInfoObject targetInfo, Result <CheckResult> result) { base.Init(result); if (targetInfo.Users == null || !targetInfo.Users.Any()) { if (result.Status == 0) { result.Status = 200; } result.Data.Success.ToUsers = new List <string>(); return(result); } if (!appInfo.AssignedUserIds.Any()) { result.Status = 99; result.Data.Error.ErrorUsers = targetInfo.Users; return(result); } //including under tag var allAssignedUsers = appInfo.AssignedUserIds; var errorUsers = targetInfo.Users.Where(targetUser => { var user = WeChatCommonService.lstUser.FirstOrDefault(x => string.Equals(x.userid, targetUser, StringComparison.CurrentCultureIgnoreCase)); return (allAssignedUsers.All( assignedUser => string.Compare(assignedUser, targetUser, StringComparison.OrdinalIgnoreCase) != 0) || user == null || user.status == 4); }).ToList(); if (errorUsers.Any()) { result.Status = 99; } else { if (result.Status == 0) { result.Status = 200; } result.Data.Success.ToUsers = targetInfo.Users; return(result); } var successUsers = targetInfo.Users.Where(x => errorUsers.All(y => x.ToUpper() != y.ToUpper())).ToList(); result.Data.Error.ErrorUsers = errorUsers; result.Data.Success.ToUsers = successUsers; return(result); }
public Result <CheckResult> Verify(ConfigedInfo appInfo, TargetInfoObject targetInfo, Result <CheckResult> result) { base.Init(result); if (targetInfo.Tags == null || !targetInfo.Tags.Any()) { if (result.Status == 0) { result.Status = 200; } return(result); } if (result.Status == 0) { result.Status = 200; } result.Data.Success.ToTags = targetInfo.Tags.ConvertTagIdToObject(); return(result); //if (!appInfo.AppInfoResult.allow_tags.tagid.Any()) //{ // result.Status = 99; // result.Data.Error.ErrorTags = targetInfo.Tags.ConvertTagIdToObject(); // return result; //} //var allAssignedTags = appInfo.AppInfoResult.allow_tags.tagid; //var errorTags = targetInfo.Tags.Where(x => !allAssignedTags.Any(y => x == y)).ToList(); //if (errorTags.Any()) //{ // result.Status = 99; //} //else //{ // if (result.Status == 0) // { // result.Status = 200; // } // result.Data.Success.ToTags = targetInfo.Tags.ConvertTagIdToObject(); // return result; //} //var successTags = targetInfo.Tags.Where(x => errorTags.Any(y => x == y)).ToList(); //result.Data.Success.ToTags = successTags.ConvertTagIdToObject(); //result.Data.Error.ErrorTags = errorTags.ConvertTagIdToObject(); //return result; }
public Result <CheckResult> Verify(ConfigedInfo appInfo, TargetInfoObject targetInfo, Result <CheckResult> result) { base.Init(result); if (targetInfo.Departments == null || !targetInfo.Departments.Any()) { if (result.Status == 0) { result.Status = 200; } result.Data.Success.ToDepartments = new List <Desc>(); return(result); } if (!appInfo.AssignedDepartmentIds.Any()) { result.Status = 99; result.Data.Error.ErrorDepartments = targetInfo.Departments.ConvertDepartmentIdToObject(); return(result); } var allAssignedDepartments = WeChatCommonService.GetSubDepartments(appInfo.AssignedDepartmentIds); var errorDepartments = targetInfo.Departments.Where(depart => allAssignedDepartments.All(x => x.id != depart)).ToList(); if (errorDepartments.Any()) { result.Status = 99; } else { if (result.Status == 0) { result.Status = 200; } result.Data.Success.ToDepartments = targetInfo.Departments.ConvertDepartmentIdToObject(); return(result); } var successDepartments = targetInfo.Departments.Where(x => errorDepartments.All(y => x != y)).ToList(); result.Data.Error.ErrorDepartments = errorDepartments.ConvertDepartmentIdToObject(); result.Data.Success.ToDepartments = successDepartments.ConvertDepartmentIdToObject(); return(result); }
public Result <object> PushCheck(TargetInfoObject entity, int appId, ContentType contentType) { if (entity == null) { throw new ArgumentNullException("entity"); } if (appId < 0) { throw new ArgumentException("appId"); } var result = new Result <object> { Status = 200, }; var history = new PushHistoryEntity { ContentId = entity.ContentId, AppId = appId, ContentType = contentType.ToString(), TargetType = entity.IsToAllUsers ? TargetType.AllUser.ToString() : TargetType.Config.ToString() }; _pushHistoryService.Repository.Insert(history); result.Data = history.Id; if (entity.IsToAllUsers) { return(result); } var appInfo = WeChatCommonService.GetAppInfo(appId); var verifyResult = _pushFacadeService.Verify(new ConfigedInfo(appInfo), entity, contentType); var passPart = verifyResult.Data.Success; //string.Join(",", passPart.ToDepartments.Select(JsonHelper.ToJson)) string.Join(",", passPart.ToTags.Select(JsonHelper.ToJson)) history.ToDepartments = (passPart.ToDepartments != null && passPart.ToDepartments.Any()) ? JsonHelper.ToJson(passPart.ToDepartments) : null; history.ToTags = passPart.ToTags != null?JsonHelper.ToJson(passPart.ToTags) : null; history.ToUsers = passPart.ToUsers != null?string.Join("|", passPart.ToUsers) : null; //updated _pushHistoryService.Repository.Update(history, new List <string> { "ToDepartments", "ToTags", "ToUsers" }); if (verifyResult.Status == 200) { return(result); } result.Status = verifyResult.Status; var errorResult = verifyResult.Data.Error; _historyDetailService.Repository.Insert(new PushHistoryDetailEntity { HistoryId = history.Id, ErrorDepartments = errorResult.ErrorDepartments != null ? JsonHelper.ToJson(errorResult.ErrorDepartments) : null, ErrorTags = errorResult.ErrorTags != null ? JsonHelper.ToJson(errorResult.ErrorTags) : null, ErrorUsers = errorResult.ErrorUsers != null ? string.Join("|", errorResult.ErrorUsers) : null, ErrorType = ErrorType.Checked.ToString(), }); return(result); }