/// <summary> /// Creates Connection Artifacts on Designspace Server /// </summary> /// <param name="addedConnections">Connections that should be created</param> private void CreateConnections(List<Connection> addedConnections) { foreach (Connection c in addedConnections) { Cloud.Artifact startArtifact = workspace.getArtifactsWithProperty(Fields.DT, FunctionUtils.GetFunctionDT((Function)c.StartSymbolReference)).ElementAt(0); Cloud.Artifact endArtifact = workspace.getArtifactsWithProperty(Fields.DT, FunctionUtils.GetFunctionDT((Function)c.EndSymbolReference)).ElementAt(0); Dictionary<String, Object> inDic = new Dictionary<string, object>(); inDic[Fields.IN] = endArtifact; inDic[Fields.IN_PIN] = c.EndPin.ToString(); List<Cloud.Artifact> conWithExistingIn = workspace.getArtifactsWithProperty(inDic, connectionType).ToList<Cloud.Artifact>(); Dictionary<String, Object> outDic = new Dictionary<string, object>(); outDic[Fields.OUT] = startArtifact; outDic[Fields.OUT_PIN] = c.StartPin.ToString(); List<Cloud.Artifact> conWithExistingOut = workspace.getArtifactsWithProperty(outDic, connectionType).ToList<Cloud.Artifact>(); //Cloud.Artifact existingCon; if (conWithExistingIn.Count > 0) { foreach (Cloud.Artifact existingCon in conWithExistingIn) { //existingCon = conWithExistingIn[0]; existingCon.setPropertyValue(workspace, Fields.OUT, startArtifact); existingCon.setPropertyValue(workspace, Fields.OUT_PIN, c.StartPin.ToString()); } } else if (conWithExistingOut.Count > 0) { foreach (Cloud.Artifact existingCon in conWithExistingOut) { //existingCon = conWithExistingOut[0]; existingCon.setPropertyValue(workspace, Fields.IN, endArtifact); existingCon.setPropertyValue(workspace, Fields.IN_PIN, c.EndPin.ToString()); } } else { Cloud.Artifact connectionArtifact = workspace.createArtifact(connectionType, package); Cloud.Property connOut = connectionArtifact.createProperty(workspace, Fields.OUT); Cloud.Property connOutPin = connectionArtifact.createProperty(workspace, Fields.OUT_PIN); Cloud.Property connIn = connectionArtifact.createProperty(workspace, Fields.IN); Cloud.Property connInPin = connectionArtifact.createProperty(workspace, Fields.IN_PIN); //Cloud.Artifact startArtifact = functionArtifacts.Single<Cloud.Artifact>(x => x.getPropertyValue(Fields.DT).Equals(CommonUtils.GetFunctionDT((Function)c.StartSymbolReference))); //Cloud.Artifact endArtifact = functionArtifacts.Single<Cloud.Artifact>(x => x.getPropertyValue(Fields.DT).Equals(CommonUtils.GetFunctionDT((Function)c.EndSymbolReference))); connOut.setValue(workspace, startArtifact); connOutPin.setValue(workspace, c.StartPin.ToString()); connIn.setValue(workspace, endArtifact); connInPin.setValue(workspace, c.EndPin.ToString()); } } }