protected override void ExecuteWorkflowLogic() { var publicView = PublicView.Get(Context.ExecutionContext); var privateView = PrivateView.Get(Context.ExecutionContext); var fetchXml = FetchXmlQuery.Get(Context.ExecutionContext); if (publicView == null && privateView == null && fetchXml == null) { throw new InvalidPluginExecutionException("One of 'Public View', 'Private View' or 'Fetch Xml Query' inputs has to be populated!"); } if (publicView != null) { fetchXml = Context.SystemService.Retrieve(publicView.LogicalName, publicView.Id, new ColumnSet("fetchxml")).GetAttributeValue <string>("fetchxml"); } else if (privateView != null) { fetchXml = Context.SystemService.Retrieve(privateView.LogicalName, privateView.Id, new ColumnSet("fetchxml")).GetAttributeValue <string>("fetchxml"); } var allRecords = QueryWithPaging(new FetchExpression(fetchXml)); ProcessRecords(allRecords); }
public async Task <JsonResult> GetUserList(PublicQuery query) { try { PublicView publicView = await _userService.GetListByPage(query); foreach (var item in publicView.UserList) { if (item.Role != null) { item.RoleName = item.Role.CName; } if (item.Department != null) { item.DepartmentName = item.Department.Name; } if (item.Area != null) { item.AreaName = item.Area.Name; } } return(Json(new { total = publicView.TotalCount, rows = publicView.UserList })); } catch (Exception ex) { _logService.Error(string.Format("获取用户列表失败!query = 【{0}】", query.ToJSON()), ex); return(Json(new { total = 0, data = "" })); } }
public async Task <JsonResult> GetRoleList(PublicQuery query) { try { PublicView publicView = await _roleService.GetListByPage(query); return(Json(new { total = publicView.TotalCount, rows = publicView.RoleList })); } catch (Exception ex) { _logService.Error(string.Format("获取角色列表失败!query = 【{0}】", query.ToJSON()), ex); return(Json(new { total = 0, data = "" })); } }
public async Task <JsonResult> GetAppLogList(PublicQuery query) { try { PublicView publicView = await _applogService.GetAppLogs(query); return(Json(new { total = publicView.TotalCount, rows = publicView.ApplicationLogList })); } catch (Exception ex) { _logService.Error(string.Format("获取异常日志列表失败!query = 【{0}】", query.ToJSON()), ex); return(Json(new { total = 0, data = "" })); } }
protected override void ExecuteWorkflowLogic() { List<Entity> records; var recordUrl = Record.Get(Context.ExecutionContext); if (!string.IsNullOrEmpty(recordUrl)) { var record = ConvertToEntityReference(Record.Get(Context.ExecutionContext)); var relationshipName = RelationshipName.Get(Context.ExecutionContext); if (string.IsNullOrEmpty(relationshipName)) { throw new InvalidPluginExecutionException("Reationship Name Parameter is empty!"); } var relationship = new Relationship(relationshipName); var retrieveEntityRequest = new RetrieveEntityRequest() { LogicalName = record.LogicalName, EntityFilters = EntityFilters.Relationships, RetrieveAsIfPublished = true }; var retrieveEntityResponse = (RetrieveEntityResponse) Context.SystemService.Execute(retrieveEntityRequest); string childEntityName = null; var ntonRelationship = retrieveEntityResponse.EntityMetadata.ManyToManyRelationships.FirstOrDefault( r => r.SchemaName == relationshipName); if (ntonRelationship != null) { childEntityName = ntonRelationship.Entity1LogicalName == record.LogicalName ? ntonRelationship.Entity2LogicalName : ntonRelationship.Entity1LogicalName; } else { var onetonRelationship = retrieveEntityResponse.EntityMetadata.OneToManyRelationships.FirstOrDefault( r => r.SchemaName == relationshipName); if (onetonRelationship == null) throw new Exception( $"Relationship {relationshipName} is not available for {record.LogicalName} entity"); childEntityName = onetonRelationship.ReferencingEntity; } var childRecordsFetchXml = $@" <fetch> <entity name='{childEntityName}'> <attribute name='{childEntityName}id' />"; var additionalConditions = AdditionalFilterArgument.Get(Context.ExecutionContext); if (!string.IsNullOrEmpty(additionalConditions)) childRecordsFetchXml += $"<filter type='and'>{additionalConditions.Replace('"', '\'')}</filter>"; childRecordsFetchXml += @" </entity> </fetch>"; var retrieveRequest = new RetrieveRequest() { ColumnSet = new ColumnSet(false), Target = record, RelatedEntitiesQuery = new RelationshipQueryCollection { {relationship, new FetchExpression(childRecordsFetchXml)} } }; var retrieveResponse = (RetrieveResponse) Context.UserService.Execute(retrieveRequest); records = retrieveResponse.Entity.RelatedEntities[relationship].Entities.ToList(); } else { var publicView = PublicView.Get(Context.ExecutionContext); var privateView = PrivateView.Get(Context.ExecutionContext); var fetchXml = FetchXmlQuery.Get(Context.ExecutionContext); if (publicView == null && privateView == null && fetchXml == null) throw new InvalidPluginExecutionException("One of 'Record Reference'/'Relationship Name', 'Public View', 'Private View' or 'Fetch Xml Query' inputs has to be populated!"); if (publicView != null) { fetchXml = Context.SystemService.Retrieve(publicView.LogicalName, publicView.Id, new ColumnSet("fetchxml")).GetAttributeValue<string>("fetchxml"); } else if (privateView != null) { fetchXml = Context.SystemService.Retrieve(privateView.LogicalName, privateView.Id, new ColumnSet("fetchxml")).GetAttributeValue<string>("fetchxml"); } records = QueryWithPaging(new FetchExpression(fetchXml)); } var isContinueOnError = IsContinueOnError.Get(Context.ExecutionContext); foreach (var childRecord in records) { try { var recordForOperation = new Entity(childRecord.LogicalName, childRecord.Id); PerformOperation(recordForOperation); } catch { if (!isContinueOnError || Context.IsSyncMode) throw; } } }