private void ReadComponentAndDBNames(ref int firstRow, ref int firstCol) { object compNameValue, compIdNameValue, linkValue; if ((compNameValue = range[firstRow, firstCol].Value) != null && (compIdNameValue = range[firstRow, firstCol + 1].Value) != null && (linkValue = range[firstRow, firstCol + 2].Value) != null) { string compName = compNameValue.ToString(); string compIdName = compIdNameValue.ToString(); string linkTo = linkValue.ToString(); if (compName.Length > 0 && compIdName.Length > 0) { if (!CompIdNameDict.ContainsKey(compName)) { CompIdNameDict.Add(compName, compIdName); } if (linkTo.Length > 0 && !DataLinksDict.ContainsKey(compName)) { DataLinksDict.Add(compName, linkTo); } } else { firstRow++; } } }
private ResponseMessage DeriveCompIdFromLinkedComponent(string dBAndCompNames) { if (DataLinksDict.ContainsKey(dBAndCompNames)) { //get the component name this is linked to this component string linkedComponentName = DataLinksDict[dBAndCompNames]; //check if the linked component was already loaded if (LoadedCompDict.ContainsKey(linkedComponentName)) { //get the linked component id value //string linkedComponentIdValue = LoadedCompDict[linkedComponentName].GetIdValue(); //get the component id value that is associated to the linked component id's value ResponseMessage response = Common.SplitDBAndCompNames(dBAndCompNames); if (!response.IsSuccessful) { return(response); } string[] split = response.Data as string[]; List <string> componentIdValues; if (split[0].ToLower().CompareTo("cdp") == 0) { //componentIdValues = ProjectLinkProcessor.GetCdpProjectId(linkedComponentIdValue); componentIdValues = new List <string> { "36005" }; //hard-code this for testing purpose } else if (split[0].ToLower().CompareTo("hdb") == 0) { //try //{ // int cdpComponentId = Int32.Parse(linkedComponentIdValue); // componentIdValues = ProjectLinkProcessor.GetHdbProjectId(cdpComponentId); //} //catch (Exception e) //{ // return new ResponseMessage(false, e.Message); //} componentIdValues = new List <string> { "fc6b1c42-865c-472f-ae59-000364028f43" }; //hard-code this value for testing purpose } else { return(new ResponseMessage(false, "Database '" + split[0] + "' is unknown")); } if (componentIdValues == null || componentIdValues.Count == 0) { return(new ResponseMessage(false, "Component '" + linkedComponentName + "' and '" + dBAndCompNames + "' are not linked to each other")); } else if (componentIdValues.Count > 1) { return(new ResponseMessage(false, "Multiple components '" + dBAndCompNames + "' are linked to the same component '" + linkedComponentName + "'")); } return(new ResponseMessage(true, componentIdValues[0])); } } return(new ResponseMessage(false, "Component '" + dBAndCompNames + "' is not linked to any component in the search")); }