public void CreateConnection(Pin endPin, Pin startPin, Cloud.Artifact startArtifact, Cloud.Artifact endArtifact) { if (startArtifact != null && endArtifact != null) { Dictionary<String, Object> propertyMap = new Dictionary<string, object>(); propertyMap.Add(Fields.OUT, startArtifact); propertyMap.Add(Fields.OUT_PIN, startPin); propertyMap.Add(Fields.IN, endArtifact); propertyMap.Add(Fields.IN_PIN, endPin); IEnumerable<Cloud.Artifact> connections = workspace.getArtifactsWithProperty(propertyMap, connectionType); List<Cloud.Artifact> connectionsList = connections.ToList<Cloud.Artifact>(); if (connectionsList.Count < 1) { Cloud.Artifact connectionArtifact = workspace.createArtifact(connectionType); 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); connOut.setValue(workspace, startArtifact); connOutPin.setValue(workspace, startPin.ToString()); connIn.setValue(workspace, endArtifact); connInPin.setValue(workspace, endPin.ToString()); } } }
/// <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()); } } }
/// <summary> /// Creates Function Artifact on Designspace Server /// </summary> /// <param name="f">Function that should be created</param> /// <returns></returns> public Cloud.Artifact CreateFunctionArtifact(Function f) { Cloud.Artifact artifact = workspace.createArtifact(functionType, package); Cloud.Property DTProperty = artifact.createProperty(workspace, Fields.DT); DTProperty.setValue(workspace, f.Properties.FUNC_DEVICETAG_FULLNAME.ToString()); Cloud.Property NameProperty = artifact.createProperty(workspace, Fields.NAME); NameProperty.setValue(workspace, FunctionUtils.GetFunctionName(f)); return artifact; }
public Cloud.Artifact CreateFunctionArtifact(String DT) { Cloud.Artifact artifact = workspace.createArtifact(functionType, package); Cloud.Property DTProperty = artifact.createProperty(workspace, Fields.DT); DTProperty.setValue(workspace, DT); return artifact; }