private bool DetectConflict(IEnumerable<ServiceFlow> serviceFlows, ServiceFlow serviceFlow, out string errorMessage) { errorMessage = "Success"; Block startblock = serviceFlow.Blocks[serviceFlow.FirstBlockGUID]; if (startblock.BlockType == Block.BlockTypes.Service) { if (DetectExistingServiceStartPoint(serviceFlows)) { errorMessage = "Cannot have more than one chain with a service as the starting point"; return true; } } else if (startblock.BlockType == Block.BlockTypes.Condition) { if (DetectExistingConditionStartPoint(serviceFlows, startblock)) { errorMessage = "Cannot have more than one chain with the same condition as a starting point"; return true; } } return false; }
private string SaveServiceFlow(List<ServiceFlow> serviceFlows, ServiceFlow serviceflow) { string errorMessage; //TODO: Re-enable conflict detection //if (DetectConflict(serviceFlows, serviceflow, out errorMessage)) // return "Conflict Detected - " + errorMessage; try { UserProfile profile = UserProfile.GetUserProfile(User.Identity.Name); serviceFlows.Add(serviceflow); profile.ServiceFlows = serviceFlows.SerializeAndZip(); profile.Save(); return "Chain Saved Successfully"; } catch (Exception exception) { return "Problem saving chain - " + exception.Message; } }
public string SaveChain(Object guid, String chain, String name) { var jss = new JavaScriptSerializer(); D3Node rootD3Node = jss.Deserialize<D3Node>(chain); Node rootNode = new Node(rootD3Node); List<ServiceFlow> sfs; String errorMessage; if (GetServiceFlows(out sfs, out errorMessage)) { ServiceFlow serviceflow = new ServiceFlow(rootNode, name); return jss.Serialize(SaveServiceFlow(sfs, serviceflow)); } return jss.Serialize(errorMessage); }