void ISoapTransactionLinkExecutor.ExecuteBulkTransactions(Guid sessionId, TransactionalMappingToolServiceClient serviceProxy, ref Service.OPS bulkOperations) { SessionId = sessionId; ServiceProxy = serviceProxy; ResponseParameter = new Service.MP(); ResponseParameter.I = Guid.NewGuid(); ResponseParameter.S = sessionId; ResponseParameter.V = Guid.Empty; ResponseParameter.D = true; ResponseParameter.T = Service.MapParameterType.Node; Service.BMU metadataBulkOperation = new Service.BMU(); metadataBulkOperation.I = TransactionLinkId; metadataBulkOperation.D = DomainParameter.GetParameterValue(sessionId); metadataBulkOperation.M = MetadataParameter.GetParameterValue(sessionId); metadataBulkOperation.MN = Name; metadataBulkOperation.MV = Value; metadataBulkOperation.RI = ResponseParameter.I; bulkOperations.O.Add(metadataBulkOperation); ISoapTransactionLinkExecutor executor = _firstLink as ISoapTransactionLinkExecutor; if (executor == null) { DebugLogger.Instance.LogMsg("Exception: This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor."); throw new NotSupportedException("This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor."); } if (bulkOperations.O.Count < 200) { if (!_onCompletedBound) { executor.TransactionFailed += OnTransactionFailed; executor.TransactionCompleted += OnTransactionCompleted; _onCompletedBound = true; } DebugLogger.Instance.LogMsg("Executing update metadata transaction. Name - '{0}'; Value - '{1}'; MetadataId - '{2}'", Name, Value, Metadata.Id); executor.ExecuteBulkTransactions(SessionId, ServiceProxy, ref bulkOperations); } else { ServiceProxy.BOCCompleted += new EventHandler <BOCCompletedEventArgs>(OnSubmitBulkOperationCompleted); ServiceProxy.SubmitBulkOperationsAsync(CallingUrl.Url, SessionId, bulkOperations, this); } }
private static void ResourceBlock(StringBuilder builder, MetadataParameter[] parameters, int indent) { var isFirstProperty = true; var processed = new List<MetadataParameter>(); foreach (var parameter in parameters) { if (processed.Contains(parameter)) continue; if (!isFirstProperty) builder.AppendLine(","); isFirstProperty = false; var innerObject = parameters.Where(p => p.Name.StartsWith(parameter.Name + ".")); if (innerObject.Any()) { var innerParams = innerObject.Select(o => new MetadataParameter { Name = o.Name.Substring(parameter.Name.Length + 1), Type = o.Type }).ToArray(); builder.AppendFormat("{0}<span class=\"green\">"{1}"</span>: {{\n", new string(' ', 4 * indent), Encode(parameter.Name)); ResourceBlock(builder, innerParams, indent + 1); builder.AppendFormat("{0}}}", new string(' ', 4 * indent)); processed.AddRange(innerObject); continue; } var innerArray = parameters.Where(p => p.Name.StartsWith(parameter.Name + "[].")); if (innerArray.Any()) { var innerParams = innerArray.Select(o => new MetadataParameter { Name = o.Name.Substring(parameter.Name.Length + 3), Type = o.Type }).ToArray(); builder.AppendFormat("{0}<span class=\"green\">"{1}"</span>: [\n", new string(' ', 4 * indent), Encode(parameter.Name)); builder.AppendFormat("{0}{{\n", new string(' ', 4 * (indent + 1))); ResourceBlock(builder, innerParams, indent + 2); builder.AppendFormat("{0}}}\n", new string(' ', 4 * (indent + 1))); builder.AppendFormat("{0}]", new string(' ', 4 * indent)); processed.AddRange(innerArray); continue; } builder.AppendFormat("{0}<span class=\"green\">"{1}"</span>: <span class=\"blue\">{{{2}}}</span>", new string(' ', 4 * indent), Encode(parameter.Name), Encode(parameter.Type)); } builder.AppendLine(); }
private MetadataParameter[] GetTypeParameters(Type type, JsonMapperEntryMode?exclude = null, string prefix = null) { // get JSON mapping manager var mapper = JsonMapperManager.GetMapper(type); if (mapper == null) { return new MetadataParameter[] { } } ; // create parameters from mapping entries var parameters = new List <MetadataParameter>(); foreach (var parameter in mapper.Entries.Where(e => exclude == null || e.Mode != exclude.Value)) { // add parameter that corresponds to the mapped property var isJsonObject = parameter.EntityProperty.IsDefined(typeof(JsonFieldAttribute), false); var param = new MetadataParameter { Name = (prefix == null ? null : prefix + ".") + parameter.JsonProperty, Type = isJsonObject ? "object" : ToJsonType(parameter.EntityProperty.PropertyType), IsRequred = IsRequired(parameter.EntityProperty), Documentation = DataXmlCommentReader.GetPropertyElement(parameter.EntityProperty).ElementContents("summary"), }; parameters.Add(param); // add child object parameters if (param.Type == "object" && !isJsonObject) { parameters.AddRange(GetTypeParameters(parameter.EntityProperty.PropertyType, exclude, param.Name)); } } return(parameters.ToArray()); }
void ISoapTransactionLinkExecutor.ExecuteTransaction(Guid sessionId, Service.TransactionalMappingToolServiceClient serviceProxy) { SessionId = sessionId; ServiceProxy = serviceProxy; ServiceProxy.MDCompleted += OnDeleteMetadataCompleted; ServiceProxy.MDAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), SessionId, DomainParameter.GetParameterValue(sessionId), MetadataParameter.GetParameterValue(sessionId), this); }
void ISoapTransactionLinkExecutor.ExecuteTransaction(Guid sessionId, TransactionalMappingToolServiceClient serviceProxy) { SessionId = sessionId; ServiceProxy = serviceProxy; ServiceProxy.MUCompleted += OnUpdateMetadataCompleted; ServiceProxy.MUAsync(CallingUrl.Url, SessionId, DomainParameter.GetParameterValue(sessionId), MetadataParameter.GetParameterValue(sessionId), Name, Value, this); }
private MetadataParameter[] GetResponseParameters(ReflectedHttpActionDescriptor descriptor) { var methodElement = ApiXmlCommentReader.GetMethodElement(descriptor.MethodInfo); if (methodElement == null) { return(null); } var parameters = new List <MetadataParameter>(); // read cref type on the XML returns element var methodReturnsElement = methodElement.Element("returns"); if (methodReturnsElement != null) { var resourceType = GetCrefType(methodReturnsElement); if (resourceType != null) { parameters.AddRange(GetTypeParameters(resourceType, JsonMapperEntryMode.OneWayToSource)); } } // read XML response element var responseElement = methodElement.Element("response"); if (responseElement != null) { foreach (var parameterElement in responseElement.Elements("parameter") .Where(p => p.Attribute("name") != null)) { var name = (string)parameterElement.Attribute("name"); var type = (string)parameterElement.Attribute("type"); var mode = (string)parameterElement.Attribute("mode"); // remove an existing parameter if (mode == "remove") { parameters.RemoveAll(p => p.Name.StartsWith(name)); continue; } // add or update an existing parameter var param = parameters.FirstOrDefault(p => p.Name == name); if (param == null) { param = new MetadataParameter { Name = name, Type = type }; parameters.Add(param); } if (!string.IsNullOrEmpty(parameterElement.Contents())) { param.Documentation = parameterElement.Contents(); } // if element includes cref - parse the specified type and add parameters from it var cref = GetCrefType(parameterElement); if (cref != null) { if (param.Type == null) { param.Type = "object"; } parameters.AddRange(GetTypeParameters(cref, JsonMapperEntryMode.OneWayToSource, param.Name + (type == "array" ? "[]" : null))); } } } return(parameters.ToArray()); }