Ejemplo n.º 1
0
        /// <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));
            }
        }
Ejemplo n.º 2
0
        /// <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));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Process the Add-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
            {
                string lovId      = null;
                string lovValueId = null;

                // 2. Doing Add
                WriteDebug("Adding");

                // 2a. Add using provided parameters
                if (IshLovValue != null)
                {
                    WriteDebug($"LovId[{IshLovValue.LovId}] LovValueId[{IshLovValue.IshRef}] Label[{IshLovValue.Label}] Description[{IshLovValue.Description}]");
                    if (ShouldProcess(IshLovValue.IshRef))
                    {
                        var response = IshSession.ListOfValues25.CreateValue2(new ListOfValues25ServiceReference.CreateValue2Request(
                                                                                  IshLovValue.LovId,
                                                                                  IshLovValue.IshRef,
                                                                                  IshLovValue.Label,
                                                                                  IshLovValue.Description));
                        lovId      = IshLovValue.LovId;
                        lovValueId = response.lovValueId;
                    }
                }
                else
                {
                    var inlovValueId = LovValueId ?? "";
                    WriteDebug($"LovId[{LovId}] LovValueId[{LovValueId}] Label[{Label}] Description[{Description}]");
                    if (ShouldProcess(inlovValueId))
                    {
                        var response = IshSession.ListOfValues25.CreateValue2(new ListOfValues25ServiceReference.CreateValue2Request(
                                                                                  LovId,
                                                                                  inlovValueId,
                                                                                  Label,
                                                                                  Description));
                        lovId      = LovId;
                        lovValueId = response.lovValueId;
                    }
                }

                // 3a. Retrieve added value and write it out
                WriteDebug("Retrieving");

                string xmlIshLovValues = IshSession.ListOfValues25.RetrieveValues(
                    new string[] { lovId },
                    ListOfValues25ServiceReference.ActivityFilter.None);
                IshLovValues retrievedLovValues = new IshLovValues(xmlIshLovValues);
                // find the value we added in a list of all LovValues within the given LovId
                foreach (IshLovValue ishLovValue in retrievedLovValues.LovValues)
                {
                    if (ishLovValue.IshRef == lovValueId)
                    {
                        WriteObject(ishLovValue);
                        break;
                    }
                }
                WriteVerbose("returned value count[1]");
            }
            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));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Process the Set-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");
                string lovIdToRetrieve;
                string lovValueIdToRetrieve;

                // 2. Doing Update
                WriteDebug("Updating");

                // 2a. Update using provided parameters
                if (IshLovValue != null)
                {
                    // 2b. Update using IshLovValue pipeline
                    WriteDebug($"LovId[{IshLovValue.LovId}] LovValueId[{IshLovValue.IshRef}]");
                    if (ShouldProcess(IshLovValue.IshRef))
                    {
                        IshSession.ListOfValues25.UpdateValue(
                            IshLovValue.LovId,
                            IshLovValue.IshRef,
                            IshLovValue.Label,
                            IshLovValue.Description,
                            IshLovValue.Active);
                    }
                    lovIdToRetrieve      = IshLovValue.LovId;
                    lovValueIdToRetrieve = IshLovValue.IshRef;
                }
                else
                {
                    WriteDebug($"LovId[{LovId}] LovValueId[{LovValueId}]");
                    if (ShouldProcess(LovValueId))
                    {
                        IshSession.ListOfValues25.UpdateValue(
                            LovId,
                            LovValueId,
                            Label,
                            Description,
                            Active);
                    }
                    lovIdToRetrieve      = LovId;
                    lovValueIdToRetrieve = LovValueId;
                }

                // 3a. Retrieve updated value and write to the output
                WriteDebug("Retrieving");

                string xmlIshLovValues = IshSession.ListOfValues25.RetrieveValues(
                    new string[] { lovIdToRetrieve },
                    ListOfValues25ServiceReference.ActivityFilter.None);
                IshLovValues retrievedLovValues = new IshLovValues(xmlIshLovValues);

                // find the value we updated in a list of all LovValues within the given LovId
                foreach (IshLovValue ishLovValue in retrievedLovValues.LovValues)
                {
                    if (ishLovValue.IshRef == lovValueIdToRetrieve)
                    {
                        WriteObject(ishLovValue);
                        break;
                    }
                }
                WriteVerbose("returned value count[1]");
            }
            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));
            }
        }