public void Generate_otTaggedValues_content(Repository m_Repository, string TOI_GUID, string TOI_Name, out EA_TaggedValueStore myTVS) { EA.Element ParentElement = (EA.Element)m_Repository.GetElementByGuid(TOI_GUID); myTVS = new Models.EA_TaggedValueStore(); myTVS.ParentElementName = ParentElement.Name; myTVS.ParentElementGUID = ParentElement.ElementGUID; for (short i = 0; i < ParentElement.TaggedValues.Count; i++) { EA.TaggedValue TagValue = (EA.TaggedValue)ParentElement.TaggedValues.GetAt(i); if (TagValue.Name == TOI_Name) { if (myTVS.TaggedDictionary.ContainsKey(TagValue.Name) == false) { myTVS.TaggedDictionary.Add(TagValue.Name, TagValue.Value); } } } }
//Get a "thing" from inside the rest service public ActionResult ServiceProviderContent() { //Stuff we use later EA.Repository m_Repository = new EA.Repository(); EA_Data_Manipulator EDM = new EA_Data_Manipulator(); //TODO - Investigate if we really need this. string RootURL = EDM.GetBaseURL(Request, Url); //TODO - Tidy up all this array stuff //Get the URL that was posted. var UrlAppended = this.Url.Action(); string UrlAppendage = UrlAppended.ToString(); UrlAppendage = UrlAppendage.Remove(0, 1); var URLArray = UrlAppendage.Split('/'); //parse the URL string[] BaseURL = URLArray.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //Clean emptycells var ThingArrary = BaseURL[2].Split('|'); string TOI_Name = ThingArrary[0]; string TOI_Type = ThingArrary[1]; string TOI_GUID = ThingArrary[2]; string SP_Root_URL = RootURL + BaseURL[0] + "/" + BaseURL[1]; ViewBag.TOI_Name = TOI_Name; ViewBag.TOI_Type = TOI_Type; ViewBag.TOI_GUID = TOI_GUID; ViewBag.CurrentURL = BaseURL[0] + "/" + BaseURL[1]; //Get the master repo which is needed by all things that have been clicked. m_Repository = getEA_Repos(URLArray[1]); //otPackage Lists List <string> ListOfPackages = new List <string>(); List <string> ListOfDiagrams = new List <string>(); List <string> ListOfElements = new List <string>(); List <string> ListOfPackagesNames = new List <string>(); List <string> ListOfDiagramsNames = new List <string>(); List <string> ListOfElementsNames = new List <string>(); //otDiagram Lists Dictionary <string, string> DiagramDictionary = new Dictionary <string, string>(); //otElement Lists List <string> ListOfConnectors = new List <string>(); List <string> ListOfConnectorNames = new List <string>(); Dictionary <string, string> ElementAttributes = new Dictionary <string, string>(); RestfulEA.Models.EA_TaggedValueStore myTVS = new Models.EA_TaggedValueStore(); //otConnector //EA.Connector MyLink = new EA.Connector(); EA.Connector Mycon; Dictionary <string, string> ConnectorDictionary = new Dictionary <string, string>(); //Objects for the JSON EA_Diagram EA_JSON_Diagram = new EA_Diagram(); //Generate the content for the viewbag depending on type of object that the //user last clicked on. switch (ThingArrary[1]) { case "otPackage": EA.Package PackageToShow = (EA.Package)m_Repository.GetPackageByGuid(ThingArrary[2]); EDM.Generate_otPackage_content(PackageToShow, out ListOfPackages, out ListOfDiagrams, out ListOfElements, out ListOfPackagesNames, out ListOfDiagramsNames, out ListOfElementsNames); ViewBag.ListOfPackages = ListOfPackages; ViewBag.ListOfDiagrams = ListOfDiagrams; ViewBag.ListOfElements = ListOfElements; ViewBag.ListOfPackagesNames = ListOfPackagesNames; ViewBag.ListOfDiagramsNames = ListOfDiagramsNames; ViewBag.ListOfElementsNames = ListOfElementsNames; break; case "otDiagram": //HTML Content EDM.Generate_otDiagram_content(m_Repository, ThingArrary[2], SP_Root_URL, out ListOfElements, out ListOfElementsNames, out ListOfConnectors, out ListOfConnectorNames, out DiagramDictionary); ViewBag.ListOfElements = ListOfElements; ViewBag.ListOfElementsNames = ListOfElementsNames; ViewBag.ListOfLinkURLs = ListOfConnectors; ViewBag.ListOfLinkNames = ListOfConnectorNames; ViewBag.CurrentURL += "/" + TOI_Name + "|" + TOI_Type + "|" + TOI_GUID; ViewData["CurrentURL"] = TOI_Name + "|" + TOI_Type + "|" + TOI_GUID; ViewData["SP_URL"] = BaseURL[0] + "/" + BaseURL[1]; ViewBag.DiagramName = ThingArrary[0]; //JSON Conten break; case "otElement": EDM.Generate_otElement_content(m_Repository, ThingArrary[2], out ListOfDiagrams, out ListOfDiagramsNames, out ListOfConnectors, out ListOfConnectorNames, out ElementAttributes, out myTVS); ViewBag.TG_Store = myTVS; ViewBag.ListOfConnectors = ListOfConnectors; ViewBag.ListOfConnectorNames = ListOfConnectorNames; ViewBag.ListOfDiagramsNames = ListOfDiagramsNames; ViewBag.ListOfDiagrams = ListOfDiagrams; ViewBag.ElementName = ElementAttributes["Name"]; ViewBag.notes = ElementAttributes["Name"]; ViewBag.Author = ElementAttributes["Author"]; ViewData["CurrentURL"] = TOI_Name + "|" + TOI_Type + "|" + TOI_GUID; break; case "otTaggedValue": EDM.Generate_otTaggedValues_content(m_Repository, TOI_GUID, TOI_Name, out myTVS); ViewBag.TG_Store = myTVS; break; case "otConnector": EDM.Generate_otConnector_content(m_Repository, TOI_GUID, TOI_Name, TOI_Type, out Mycon, out ConnectorDictionary); ViewBag.TOI_Name = TOI_Name; ViewBag.TOI_Type = TOI_Type; ViewBag.TOI_GUID = TOI_GUID; ViewBag.Alias = Mycon.Alias; ViewBag.Colour = Mycon.Color; ViewBag.Direction = Mycon.Direction; ViewBag.Notes = Mycon.Notes; ViewBag.Type = Mycon.Type; ViewBag.ConnectorID = Mycon.ConnectorID; ViewBag.Sterotype = Mycon.Stereotype; break; default: break; } //RETURN HTML string header = Request.Headers.Get("Accept"); if (header.Contains("html")) { switch (TOI_Type) { case "otPackage": return(View("EA_ShowPackage")); case "otDiagram": return(View("EA_ShowDiagram")); case "otElement": return(View("EA_ShowElement")); case "otTaggedValue": return(View("EA_ShowTaggedValues")); case "otConnector": return(View("EA_ShowConnector")); default: break; } } //RETURN JSON if (header.Contains("json")) { string DiagramRoot = RootURL + BaseURL[0] + "/" + BaseURL[1]; string headerText = "application/json"; switch (ThingArrary[1]) { case "otPackage": JObject JotPackageToReturn = EA_JsonBuilder.JsonCreatePackage(DiagramRoot, ListOfPackages, ListOfDiagrams, ListOfElements); return(Content(JotPackageToReturn.ToString(), headerText)); case "otDiagram": JObject JotDiagramToReturn = EA_JsonBuilder.JsonCreateDiagram(DiagramRoot, ListOfElements, DiagramDictionary, ListOfConnectors); return(Content(JotDiagramToReturn.ToString(), headerText)); case "otElement": JObject JotElemenet = EA_JsonBuilder.JsonCreateElement(DiagramRoot, ElementAttributes, myTVS, ListOfDiagrams); return(Content(JotElemenet.ToString(), headerText)); case "otTaggedValue": JObject jotTaggedValue = EA_JsonBuilder.JsonCreateTaggedValues(myTVS); return(Content(jotTaggedValue.ToString(), headerText)); case "otConnector": JObject jotConnector = EA_JsonBuilder.JsonCreateConnector(DiagramRoot, ConnectorDictionary); return(Content(jotConnector.ToString(), headerText)); default: break; } } return(null); }