Пример #1
0
 /// <summary>
 /// To add the pick list value based on ZCRMPickListValue class instance.
 /// </summary>
 /// <param name="value">ZCRMPickListValue class instance</param>
 public void AddPickListValue(ZCRMPickListValue value)
 {
     PickListValues.Add(value);
 }
Пример #2
0
        private ZCRMField GetZCRMField(JObject fieldJSON)
        {
            ZCRMField field = ZCRMField.GetInstance(Convert.ToString(fieldJSON["api_name"]));

            field.DefaultValue  = (object)fieldJSON["default_value"];
            field.Mandatory     = (bool?)fieldJSON["required"];
            field.Id            = Convert.ToInt64(fieldJSON["id"]);
            field.CustomField   = Convert.ToBoolean(fieldJSON["custom_field"]);
            field.DataType      = Convert.ToString(fieldJSON["data_type"]);
            field.DisplayName   = Convert.ToString(fieldJSON["field_label"]);
            field.MaxLength     = (int?)fieldJSON["length"];
            field.Precision     = (int?)fieldJSON["decimal_place"];
            field.ReadOnly      = Convert.ToBoolean(fieldJSON["read_only"]);
            field.Visible       = Convert.ToBoolean(fieldJSON["visible"]);
            field.SequenceNo    = (int?)fieldJSON["sequence_number"];
            field.ToolTip       = Convert.ToString(fieldJSON["tooltip"]);
            field.Webhook       = Convert.ToBoolean(fieldJSON["webhook"]);
            field.CreatedSource = Convert.ToString(fieldJSON["created_source"]);
            field.JsonType      = Convert.ToString(fieldJSON["json_type"]);
            JToken tempJSONObect = fieldJSON["formula"];

            if (tempJSONObect.HasValues)
            {
                field.FormulaReturnType = Convert.ToString(fieldJSON["return_type"]);
            }
            tempJSONObect = fieldJSON["currency"];
            if (tempJSONObect.HasValues)
            {
                field.Precision = (int?)fieldJSON["precision"];
            }
            JObject subLayouts = (JObject)fieldJSON["view_type"];

            if (subLayouts.Type != JTokenType.Null)
            {
                List <string> layoutsPresent = new List <string>();
                if ((bool)subLayouts["create"])
                {
                    layoutsPresent.Add("CREATE");
                }
                if ((bool)subLayouts["view"])
                {
                    layoutsPresent.Add("VIEW");
                }
                if ((bool)subLayouts["quick_create"])
                {
                    layoutsPresent.Add("QUICK_CREATE");
                }
                field.SubLayoutsPresent = layoutsPresent;
            }

            JArray pickList = (JArray)fieldJSON["pick_list_values"];

            foreach (JObject pickListObject in pickList)
            {
                ZCRMPickListValue pickListValue = ZCRMPickListValue.GetInstance();
                pickListValue.DisplayName    = (string)pickListObject["display_value"];
                pickListValue.ActualName     = (string)pickListObject["actual_value"];
                pickListValue.SequenceNumber = Convert.ToInt32(pickListObject["sequence_number"]);
                pickListValue.Maps           = (JArray)pickListObject["maps"];
                field.AddPickListValue(pickListValue);
            }
            JObject lookup = (JObject)fieldJSON["lookup"];

            foreach (KeyValuePair <string, JToken> lookupObject in lookup)
            {
                field.SetLookupDetails(lookupObject.Key, (object)lookupObject.Value);
            }
            JObject multilookup = (JObject)fieldJSON["multiselectlookup"];

            foreach (KeyValuePair <string, JToken> multiLookupObject in multilookup)
            {
                field.SetMultiselectLookup(multiLookupObject.Key, (object)multiLookupObject.Value);
            }
            if (fieldJSON.ContainsKey("subformtabId") && fieldJSON["subformtabId"].Type != JTokenType.Null)
            {
                field.SubFormTabId = Convert.ToInt64(fieldJSON["subformtabid"]);
            }
            if (fieldJSON.ContainsKey("subform") && fieldJSON["subform"].Type != JTokenType.Null)
            {
                JObject subformDetails = (JObject)fieldJSON["subform"];
                foreach (KeyValuePair <string, JToken> subformDetail in subformDetails)
                {
                    field.SetSubformDetails(subformDetail.Key, (object)subformDetail.Value);
                }
            }
            return(field);
        }