private ZCRMModule GetZCRMModule(JObject moduleDetails) { try { ZCRMModule module = ZCRMModule.GetInstance((string)moduleDetails["api_name"]); if (moduleDetails.ContainsKey("global_search_supported") && moduleDetails["global_search_supported"].Type != JTokenType.Null) { module.GlobalSearchSupported = (bool)moduleDetails["global_search_supported"]; } if (moduleDetails.ContainsKey("kanban_view") && moduleDetails["kanban_view"].Type != JTokenType.Null) { module.KanbanView = (bool)moduleDetails["kanban_view"]; } module.Deletable = (bool)moduleDetails["deletable"]; module.Creatable = (bool)moduleDetails["creatable"]; if (moduleDetails.ContainsKey("filter_status") && moduleDetails["filter_status"].Type != JTokenType.Null) { module.FilterStatus = (bool)moduleDetails["filter_status"]; } if (moduleDetails.ContainsKey("inventory_template_supported") && moduleDetails["inventory_template_supported"].Type != JTokenType.Null) { module.InventoryTemplateSupported = (bool)moduleDetails["inventory_template_supported"]; } if (moduleDetails.ContainsKey("modified_time") && moduleDetails["modified_time"].Type != JTokenType.Null) { module.ModifiedTime = CommonUtil.RemoveEscaping((string)JsonConvert.SerializeObject(moduleDetails["modified_time"])); } module.PluralLabel = (string)moduleDetails["plural_label"]; if (moduleDetails.ContainsKey("presence_sub_menu") && moduleDetails["presence_sub_menu"].Type != JTokenType.Null) { module.PresenceSubMenu = (bool)moduleDetails["presence_sub_menu"]; } module.Id = Convert.ToInt64(moduleDetails["id"]); if (moduleDetails.ContainsKey("related_list_properties") && moduleDetails["related_list_properties"].Type != JTokenType.Null) { module.RelatedListProperties = GetRelatedListProperties((JObject)moduleDetails["related_list_properties"]); } if (moduleDetails.ContainsKey("$properties") && moduleDetails["$properties"].Type != JTokenType.Null) { List <string> properties = new List <string>(); foreach (string property in (JArray)moduleDetails["$properties"]) { properties.Add(property); } module.Properties = properties; } if (moduleDetails.ContainsKey("per_page") && moduleDetails["per_page"].Type != JTokenType.Null) { module.PerPage = (int)moduleDetails["per_page"]; } if (moduleDetails.ContainsKey("visibility") && moduleDetails["visibility"].Type != JTokenType.Null) { module.Visibility = (int)moduleDetails["visibility"]; } module.Convertable = (bool)moduleDetails["convertable"]; module.Editable = (bool)moduleDetails["editable"]; if (moduleDetails.ContainsKey("emailTemplate_support") && moduleDetails["emailTemplate_support"].Type != JTokenType.Null) { module.EmailTemplateSupport = (bool)moduleDetails["emailTemplate_support"]; } if (moduleDetails["profiles"].HasValues) { JArray accessibleProfilesArray = (JArray)moduleDetails["profiles"]; foreach (JObject accessibleProfiles in accessibleProfilesArray) { ZCRMProfile profile = ZCRMProfile.GetInstance(Convert.ToInt64(accessibleProfiles["id"]), (string)accessibleProfiles["name"]); module.AddAccessibleProfile(profile); } } if (moduleDetails.ContainsKey("filter_supported") && moduleDetails["filter_supported"].Type != JTokenType.Null) { module.FilterSupported = (bool)moduleDetails["filter_supported"]; } if (moduleDetails.ContainsKey("display_field") && moduleDetails["display_field"].Type != JTokenType.Null) { module.DisplayField = (string)moduleDetails["display_field"]; } if (moduleDetails.ContainsKey("search_layout_fields") && moduleDetails["search_layout_fields"].Type != JTokenType.Null) { List <string> layout_Fields = new List <string>(); foreach (string layout_Field in (JArray)moduleDetails["search_layout_fields"]) { layout_Fields.Add(layout_Field); } module.SearchLayoutFields = layout_Fields; } if (moduleDetails.ContainsKey("kanban_view_supported") && moduleDetails["kanban_view_supported"].Type != JTokenType.Null) { module.KanbanViewSupported = (bool)moduleDetails["kanban_view_supported"]; } module.WebLink = (string)moduleDetails["web_link"]; module.SequenceNumber = (int)moduleDetails["sequence_number"]; module.SingularLabel = (string)moduleDetails["singular_label"]; module.Viewable = (bool)moduleDetails["viewable"]; module.ApiSupported = (bool)(moduleDetails["api_supported"]); if (moduleDetails.ContainsKey("quick_create") && moduleDetails["quick_create"].Type != JTokenType.Null) { module.QuickCreate = (bool)(moduleDetails["quick_create"]); } if (moduleDetails["modified_by"].HasValues) { JObject modifiedByObject = (JObject)moduleDetails["modified_by"]; ZCRMUser modifiedUser = ZCRMUser.GetInstance(Convert.ToInt64(modifiedByObject["id"]), (string)modifiedByObject["name"]); module.ModifiedBy = modifiedUser; } module.CustomModule = (bool)(moduleDetails["generated_type"].ToString().Equals("custom")); if (moduleDetails.ContainsKey("feeds_required") && moduleDetails["feeds_required"].Type != JTokenType.Null) { module.FeedsRequired = (bool)(moduleDetails["feeds_required"]); } if (moduleDetails.ContainsKey("scoring_supported") && moduleDetails["scoring_supported"].Type != JTokenType.Null) { module.ScoringSupported = (bool)(moduleDetails["scoring_supported"]); } if (moduleDetails.ContainsKey("webform_supported") && moduleDetails["webform_supported"].Type != JTokenType.Null) { module.WebformSupported = (bool)(moduleDetails["webform_supported"]); } if (moduleDetails.ContainsKey("arguments") && moduleDetails["arguments"].Type != JTokenType.Null) { if (moduleDetails["arguments"].HasValues) { List <ZCRMWebTabArguments> argumentsList = new List <ZCRMWebTabArguments>(); JArray argumentsJArr = (JArray)moduleDetails["arguments"]; foreach (JObject argumentsJObj in argumentsJArr) { ZCRMWebTabArguments argumentsIns = ZCRMWebTabArguments.GetInstance(); if (argumentsJObj.ContainsKey("name") && argumentsJObj["name"].Type != JTokenType.Null) { argumentsIns.Name = (string)argumentsJObj["name"]; } if (argumentsJObj.ContainsKey("value") && argumentsJObj["value"].Type != JTokenType.Null) { argumentsIns.Value = (string)argumentsJObj["value"]; } argumentsList.Add(argumentsIns); } module.WebTabArguments = argumentsList; } } module.SystemName = (string)moduleDetails["module_name"]; if (moduleDetails.ContainsKey("business_card_field_limit") && moduleDetails["business_card_field_limit"].Type != JTokenType.Null) { module.BusinessCardFieldLimit = (int)moduleDetails["business_card_field_limit"]; } if (moduleDetails.ContainsKey("custom_view") && moduleDetails["custom_view"].Type != JTokenType.Null) { module.CustomView = GetZCRMCustomView((string)moduleDetails["api_name"], (JObject)moduleDetails["custom_view"]); } if (moduleDetails.ContainsKey("parent_module") && moduleDetails["parent_module"].Type != JTokenType.Null) { if (moduleDetails["parent_module"].HasValues) { JObject parent_module = (JObject)moduleDetails["parent_module"]; ZCRMModule parentModuleIns = ZCRMModule.GetInstance((string)parent_module["api_name"]); parentModuleIns.Id = Convert.ToInt64(parent_module["id"]); module.ParentModule = parentModuleIns; } } if (moduleDetails.ContainsKey("territory") && moduleDetails["territory"].Type != JTokenType.Null) { JObject territoryJobj = (JObject)moduleDetails["territory"]; ZCRMTerritory territoryIns = ZCRMTerritory.GetInstance(Convert.ToInt64(territoryJobj["id"])); territoryIns.Name = (string)territoryJobj["name"]; territoryIns.Subordinates = (bool)territoryJobj["subordinates"]; module.Territory = territoryIns; } if (moduleDetails.ContainsKey("related_lists") && moduleDetails["related_lists"].Type != JTokenType.Null) { List <ZCRMModuleRelation> relatedLists = new List <ZCRMModuleRelation>(); JArray relatedListsArray = (JArray)moduleDetails["related_lists"]; foreach (JObject relatedListDetails in relatedListsArray) { ZCRMModuleRelation relatedList = ZCRMModuleRelation.GetInstance(module.ApiName, (string)relatedListDetails["api_name"]); SetRelatedListProperties(relatedList, relatedListDetails); relatedLists.Add(relatedList); } module.RelatedLists = relatedLists; } if (moduleDetails.ContainsKey("fields") && moduleDetails["fields"].Type != JTokenType.Null) { JArray fieldArray = (JArray)moduleDetails["fields"]; module.Fields = ModuleAPIHandler.GetInstance(ZCRMModule.GetInstance((string)moduleDetails["api_name"])).GetFields(fieldArray); } if (moduleDetails.ContainsKey("business_card_fields") && moduleDetails.Type != JTokenType.Null) { List <string> bcFields = new List <string>(); JArray bcFieldsArray = (JArray)moduleDetails["business_card_fields"]; foreach (JObject bcField in bcFieldsArray) { bcFields.Add(bcField.ToString()); } module.BussinessCardFields = bcFields; } if (moduleDetails.ContainsKey("layouts")) { module.Layouts = ModuleAPIHandler.GetInstance(module).GetAllLayouts(moduleDetails); } return(module); } catch (Exception e) when(!(e is ZCRMException)) { ZCRMLogger.LogError(e); throw new ZCRMException(APIConstants.SDK_ERROR, e); } }
private ZCRMModule GetZCRMModule(JObject moduleDetails) { try { ZCRMModule module = ZCRMModule.GetInstance((string)moduleDetails["api_name"]); module.Id = Convert.ToInt64(moduleDetails["id"]); module.SystemName = (string)moduleDetails["module_name"]; module.SingularLabel = (string)moduleDetails["singular_label"]; module.PluralLabel = (string)moduleDetails["plural_label"]; module.Creatable = (bool)moduleDetails["creatable"]; module.Viewable = (bool)moduleDetails["viewable"]; module.Editable = (bool)moduleDetails["editable"]; module.Convertable = (bool)moduleDetails["convertable"]; module.Deletable = (bool)moduleDetails["deletable"]; module.CustomModule = (bool)(moduleDetails["generated_type"].ToString().Equals("custom")); module.ApiSupported = (bool)(moduleDetails["api_supported"]); JArray accessibleProfilesArray = (JArray)moduleDetails["profiles"]; foreach (JObject accessibleProfiles in accessibleProfilesArray) { ZCRMProfile profile = ZCRMProfile.GetInstance(Convert.ToInt64(accessibleProfiles["id"]), (string)accessibleProfiles["name"]); module.AddAccessibleProfile(profile); } if (moduleDetails["modified_by"].HasValues) { JObject modifiedByObject = (JObject)moduleDetails["modified_by"]; ZCRMUser modifiedUser = ZCRMUser.GetInstance(Convert.ToInt64(modifiedByObject["id"]), (string)modifiedByObject["name"]); module.ModifiedBy = modifiedUser; module.ModifiedTime = CommonUtil.removeEscaping((string)JsonConvert.SerializeObject(moduleDetails["modified_time"])); } if (moduleDetails.ContainsKey("related_lists") && moduleDetails["related_lists"].Type != JTokenType.Null) { List <ZCRMModuleRelation> relatedLists = new List <ZCRMModuleRelation>(); JArray relatedListsArray = (JArray)moduleDetails["related_lists"]; foreach (JObject relatedListDetails in relatedListsArray) { ZCRMModuleRelation relatedList = ZCRMModuleRelation.GetInstance(module.ApiName, (string)relatedListDetails["api_name"]); SetRelatedListProperties(relatedList, relatedListDetails); relatedLists.Add(relatedList); } module.RelatedLists = relatedLists; } if (moduleDetails.ContainsKey("business_card_fields") && moduleDetails.Type != JTokenType.Null) { List <string> bcFields = new List <string>(); JArray bcFieldsArray = (JArray)moduleDetails["business_card_fields"]; foreach (JObject bcField in bcFieldsArray) { bcFields.Add(bcField.ToString()); } module.BussinessCardFields = bcFields; } if (moduleDetails.ContainsKey("layouts")) { module.Layouts = ModuleAPIHandler.GetInstance(module).GetAllLayouts(moduleDetails); } return(module); } catch (Exception e) when(!(e is ZCRMException)) { ZCRMLogger.LogError(e); throw new ZCRMException(APIConstants.SDK_ERROR, e); } }