/// <summary> /// Process the Get-IshLovValue commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="IshLovValue"/> array to the pipeline</remarks> protected override void ProcessRecord() { try { // 1. Validating the input WriteDebug("Validating"); ListOfValues25ServiceReference.ActivityFilter activityFilter = EnumConverter.ToActivityFilter <ListOfValues25ServiceReference.ActivityFilter>(ActivityFilter); // LovValues to write to the ouput List <IshLovValue> returnedLovValues = new List <IshLovValue>(); // 2. Doing Retrieve WriteDebug("Retrieving"); // 2a. Retrieve using provided LovIds array WriteDebug($"LovId[{LovId}]"); string xmlIshLovValues = IshSession.ListOfValues25.RetrieveValues(LovId, activityFilter); IshLovValues retrievedLovValues = new IshLovValues(xmlIshLovValues); returnedLovValues.AddRange(retrievedLovValues.LovValues); // 3a. Write it WriteVerbose("returned value count[" + returnedLovValues.Count + "]"); WriteObject(returnedLovValues, true); } catch (TrisoftAutomationException trisoftAutomationException) { ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null)); } catch (Exception exception) { ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null)); } }
/// <summary> /// Process the Get-IshLovValue commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="IshLovValue"/> array to the pipeline</remarks> protected override void ProcessRecord() { try { // 1. Validating the input WriteDebug("Validating"); ListOfValues25ServiceReference.ActivityFilter activityFilter = EnumConverter.ToActivityFilter <ListOfValues25ServiceReference.ActivityFilter>(ActivityFilter); // LovValues to write to the ouput List <IshLovValue> returnedLovValues = new List <IshLovValue>(); // 2. Doing Retrieve WriteDebug("Retrieving"); // 2a. Retrieve using provided LovIds array WriteDebug($"LovId[{LovId}]"); string xmlIshLovValues = IshSession.ListOfValues25.RetrieveValues(LovId, activityFilter); IshLovValues retrievedLovValues = new IshLovValues(xmlIshLovValues); // 2b. Filter to provided LovValueIds, if any, otherwise return all if (LovValueId != null) { // brute force, I know, but accurate foreach (string lovId in LovId) { foreach (string lovValueId in LovValueId) { IshLovValue foundIshLovValue; if (retrievedLovValues.TryGetIshLovValue(lovId, lovValueId, out foundIshLovValue)) { returnedLovValues.Add(foundIshLovValue); } } } } else { returnedLovValues.AddRange(retrievedLovValues.LovValues); } // 3a. Write it WriteVerbose("returned value count[" + returnedLovValues.Count + "]"); WriteObject(returnedLovValues, true); } catch (TrisoftAutomationException trisoftAutomationException) { ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null)); } catch (Exception exception) { ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null)); } }
/// <summary> /// Returns a list of values given a field. Optionally filter on active or inactive. /// </summary> /// <param name="strFieldName">Ish Fieldname (FRESOLUTIONS)</param> /// <param name="sShowState">Valid values are: All, Active, or Inactive </param> /// <returns></returns> /// <remarks></remarks> public ArrayList GetMetaValues(string strFieldName, string sShowState = "All") { string fieldID = GetMetaFieldID(strFieldName); //pull the list of the values for the specified FieldName as XML from the server: string[] slovIds = { fieldID }; ArrayList ishlovvalueStrings = new ArrayList(); string ValuesInfo = new string(""); try { //Get the Values list with corresponding container fields. ListOfValues25ServiceReference.ActivityFilter myActivityFilter = new ListOfValues25ServiceReference.ActivityFilter(); switch (sShowState) { case "Active": myActivityFilter = ISHModulesNS.ListOfValues25ServiceReference.ActivityFilter.Active; break; case "Inactive": myActivityFilter = ISHModulesNS.ListOfValues25ServiceReference.ActivityFilter.Inactive; break; case "All": myActivityFilter = ISHModulesNS.ListOfValues25ServiceReference.ActivityFilter.None; break; default: return null; } ValuesInfo = oISHAPIObjs.ISHListOfValuesObj.RetrieveValues(slovIds, myActivityFilter); XmlDocument doc = new XmlDocument(); doc.LoadXml(ValuesInfo); //Pull the metadata values out of the selected node. int p = 0; string valueString = new string(""); foreach (XmlNode myxmlnode in doc.SelectNodes("//ishlovvalue")) { valueString = myxmlnode.SelectSingleNode("label").InnerText.ToString(); ishlovvalueStrings.Add(valueString); p = p + 1; } } catch (Exception ex) { return null; } //Return the string array return ishlovvalueStrings; }