Exemple #1
0
        //TODO: Handle exceptions appropriately;
        private ZCRMCustomView GetZCRMCustomView(JObject customViewObject)
        {
            ZCRMCustomView customView = ZCRMCustomView.GetInstance(module.ApiName, Convert.ToInt64(customViewObject["id"]));

            customView.DisplayName = (string)customViewObject["display_value"];
            customView.Isdefault   = Convert.ToBoolean(customViewObject["default"]);
            customView.SystemName  = Convert.ToString(customViewObject["system_name"]);
            customView.Category    = Convert.ToString(customViewObject["category"]);
            if (customViewObject["favourite"] != null)
            {
                customView.Favourite = Convert.ToInt32(customViewObject["favourite"]);
            }
            customView.Name   = Convert.ToString(customViewObject["name"]);
            customView.SortBy = Convert.ToString(customViewObject["sort_by"]);
            if (customViewObject["sort_order"] != null)
            {
                customView.SortOrder = (CommonUtil.SortOrder)Enum.Parse(typeof(CommonUtil.SortOrder), Convert.ToString(customViewObject["sort_order"]));
            }
            List <string> fields = new List <string>();

            if (customViewObject.ContainsKey("fields"))
            {
                JArray fieldsArray = (JArray)customViewObject["fields"];
                foreach (string fieldObject in fieldsArray)
                {
                    fields.Add(fieldObject);
                }
            }
            customView.Fields = fields;
            return(customView);
        }
        private ZCRMCustomView GetZCRMCustomView(string ModuleAPIName, JObject customViewObject)
        {
            ZCRMCustomView customView = ZCRMCustomView.GetInstance(ModuleAPIName, Convert.ToInt64(customViewObject["id"]));

            customView.DisplayName = (string)customViewObject["display_value"];
            if (customViewObject.ContainsKey("shared_type") && customViewObject["shared_type"].Type != JTokenType.Null)
            {
                customView.SharedType = (string)customViewObject["shared_type"];
            }
            if (customViewObject.ContainsKey("criteria") && customViewObject["criteria"].Type != JTokenType.Null)
            {
                JObject jobj = (JObject)customViewObject["criteria"];
                index = 1;
                customView.Criteria          = SetZCRMCriteriaObject(jobj);
                customView.CriteriaPattern   = customView.Criteria.Pattern;
                customView.CriteriaCondition = customView.Criteria.Criteria;
            }
            customView.SystemName = (string)customViewObject["system_name"];
            if (customViewObject.ContainsKey("shared_details") && customViewObject["shared_details"].Type != JTokenType.Null)
            {
                customView.SharedDetails = customViewObject["shared_details"].ToString();
            }
            customView.SortBy = (string)customViewObject["sort_by"];
            if (customViewObject.ContainsKey("offline") && customViewObject["offline"].Type != JTokenType.Null)
            {
                customView.IsOffline = (bool)customViewObject["offline"];
            }
            customView.Isdefault = (bool)customViewObject["default"];
            if (customViewObject.ContainsKey("system_defined") && customViewObject["system_defined"].Type != JTokenType.Null)
            {
                customView.IsSystemDefined = (bool)customViewObject["system_defined"];
            }
            customView.Name     = (string)customViewObject["name"];
            customView.Category = (string)customViewObject["category"];
            if (customViewObject.ContainsKey("fields") && customViewObject["fields"].Type != JTokenType.Null)
            {
                List <string> fields = new List <string>();
                if (customViewObject.ContainsKey("fields") && customViewObject["fields"].Type != JTokenType.Null)
                {
                    JArray fieldsArray = (JArray)customViewObject["fields"];
                    foreach (string fieldObject in fieldsArray)
                    {
                        fields.Add(fieldObject);
                    }
                }
                customView.Fields = fields;
            }
            if (customViewObject.ContainsKey("favorite") && customViewObject["favorite"].Type != JTokenType.Null)
            {
                customView.Favourite = Convert.ToInt32(customViewObject["favourite"]);
            }
            if (customViewObject.ContainsKey("sort_order") && customViewObject["sort_order"].Type != JTokenType.Null)
            {
                customView.SortOrder = (CommonUtil.SortOrder)Enum.Parse(typeof(CommonUtil.SortOrder), (string)customViewObject["sort_order"]);
            }
            return(customView);
        }