Esempio n. 1
0
        private static void PrintPickListValue(PickListValue pickListValue)
        {
            //Get the DisplayValue of each PickListValues
            Console.WriteLine("Field PickListValue DisplayValue: " + pickListValue.DisplayValue);

            if (pickListValue.SequenceNumber != null)
            {
                //Get the SequenceNumber of each PickListValues
                Console.WriteLine(" Field PickListValue SequenceNumber: " + pickListValue.SequenceNumber);
            }

            if (pickListValue.ExpectedDataType != null)
            {
                //Get the ExpectedDataType of each PickListValues
                Console.WriteLine("Field PickListValue ExpectedDataType: " + pickListValue.ExpectedDataType);
            }

            //Get the ActualValue of each PickListValues
            Console.WriteLine("Field PickListValue ActualValue: " + pickListValue.ActualValue);

            if (pickListValue.Maps != null)
            {
                foreach (Maps map in pickListValue.Maps)
                {
                    Console.WriteLine("Field PickListValue Maps APIName: " + map.APIName);

                    //Get the PickListValue of each Maps
                    List <PickListValue> pickListValues = map.PickListValues;

                    //Check if formula is not null
                    if (pickListValues != null)
                    {
                        foreach (PickListValue pickListValue1 in pickListValues)
                        {
                            PrintPickListValue(pickListValue1);
                        }
                    }
                }
            }

            //Get the ActualValue of each PickListValues
            Console.WriteLine("Field PickListValue ActualValue: " + pickListValue.ActualValue);

            //Get the SysRefName of each PickListValues
            Console.WriteLine("Field PickListValue SysRefName: " + pickListValue.SysRefName);

            //Get the Type of each PickListValues
            Console.WriteLine("Field PickListValue Type: " + pickListValue.Type);

            //Get the Id of each PickListValues
            Console.WriteLine("Field PickListValue Id: " + pickListValue.Id);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the label of a picklist when the value is sent
        /// </summary>
        /// <param name="fields">entity fields</param>
        /// <param name="strField">picklick to choose from</param>
        /// <param name="strPickListValue">value ("id") of picklist</param>
        /// <returns>picklist label</returns>
        protected static string PickListLabelFromValue(Field[] fields, string strField, string strPickListValue)
        {
            string strRet = string.Empty;

            Field fldFieldToFind = FindField(fields, strField);

            if (fldFieldToFind == null)
            {
                throw new Exception("Could not get the " + strField + " field from the collection");
            }

            PickListValue plvValueToFind = FindPickListValue(fldFieldToFind.PicklistValues, strPickListValue);

            if (plvValueToFind != null)
            {
                strRet = plvValueToFind.Label;
            }

            return(strRet);
        }
Esempio n. 3
0
        public static void UpdatePipeline(long?layoutId, long?pipelineId)
        {
            //Get instance of PipelineOperations Class
            PipelineOperations pipelineOperations = new PipelineOperations(layoutId);

            API.Pipeline.Pipeline pipeline = new API.Pipeline.Pipeline();

            pipeline.DisplayValue = "Qualification";

            PickListValue pickList = new PickListValue();

            pickList.Id = 34770616801;

            pickList.DisplayValue = "Adfasfsad112";

            pickList.SequenceNumber = 1;

            pipeline.Maps = new List <PickListValue>()
            {
                pickList
            };

            BodyWrapper bodyWrapper = new BodyWrapper();

            bodyWrapper.Pipeline = new List <Pipeline>()
            {
                pipeline
            };

            //Call UpdatePipeline method that takes BodyWrapper instance as parameter
            APIResponse <ActionHandler> response = pipelineOperations.UpdatePipeline(pipelineId, bodyWrapper);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ActionHandler actionHandler = response.Object;

                    if (actionHandler is ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        ActionWrapper actionWrapper = (ActionWrapper)actionHandler;

                        //Get the list of obtained ActionResponse instances
                        List <ActionResponse> actionResponses = actionWrapper.Pipeline;

                        foreach (ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                SuccessResponse successResponse = (SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is APIException)
                            {
                                //Get the received APIException instance
                                APIException exception = (APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) in {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) in <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }