Ejemplo n.º 1
0
        private JObject GetZCRMBulkWriteResourceAsJSONObject(ZCRMBulkWriteResource resourceObj)
        {
            JObject resourceJSON = new JObject();

            if (resourceObj.Type != null)
            {
                resourceJSON.Add("type", resourceObj.Type);
            }
            if (resourceObj.ModuleAPIName != null)
            {
                resourceJSON.Add("module", resourceObj.ModuleAPIName);
            }
            if (resourceObj.FileId > 0)
            {
                resourceJSON.Add("file_id", resourceObj.FileId);
            }
            if ("true".Equals(resourceObj.IgnoreEmpty) || "false".Equals(resourceObj.IgnoreEmpty))
            {
                resourceJSON.Add("ignore_empty", resourceObj.IgnoreEmpty);
            }
            if (resourceObj.FindBy != null)
            {
                resourceJSON.Add("find_by", resourceObj.FindBy);
            }
            if (resourceObj.FieldMapping != null && resourceObj.FieldMapping.Count > 0)
            {
                resourceJSON.Add("field_mappings", this.GetZCRMBulkWriteFieldMappingAsJSONArray(resourceObj.FieldMapping));
            }
            return(resourceJSON);
        }
Ejemplo n.º 2
0
        private ZCRMBulkWriteResource SetZCRMBulkWriteResourceObject(JObject resourceJSON)
        {
            ZCRMBulkWriteResource resourceObj = ZCRMBulkWriteResource.GetInstance();

            if (resourceJSON.ContainsKey("status") && resourceJSON["status"].Type != JTokenType.Null)
            {
                resourceObj.Status = (string)resourceJSON["status"];
            }
            if (resourceJSON.ContainsKey("message") && resourceJSON["message"].Type != JTokenType.Null)
            {
                resourceObj.Message = (string)resourceJSON["message"];
            }
            if (resourceJSON.ContainsKey("type") && resourceJSON["type"].Type != JTokenType.Null)
            {
                resourceObj.Type = (string)resourceJSON["type"];
            }
            if (resourceJSON.ContainsKey("module") && resourceJSON["module"].Type != JTokenType.Null)
            {
                resourceObj.ModuleAPIName = (string)resourceJSON["module"];
            }
            if (resourceJSON.ContainsKey("field_mappings") && resourceJSON["field_mappings"].Type != JTokenType.Null)
            {
                List <ZCRMBulkWriteFieldMapping> fieldMappings = new List <ZCRMBulkWriteFieldMapping>();
                JArray jarr = (JArray)resourceJSON["field_mappings"];
                foreach (JObject fieldJSON in jarr)
                {
                    fieldMappings.Add(this.SetZCRMBulkWriteFieldMappingObject(fieldJSON));
                }
                resourceObj.FieldMapping = fieldMappings;
            }
            if (resourceJSON.ContainsKey("file") && resourceJSON["file"].Type != JTokenType.Null)
            {
                resourceObj.FileStatus = SetZCRMBulkWriteFileObject((JObject)resourceJSON["file"]);
            }
            if (resourceJSON.ContainsKey("ignore_empty") && resourceJSON["ignore_empty"].Type != JTokenType.Null)
            {
                resourceObj.IgnoreEmpty = (bool)resourceJSON["ignore_empty"];
            }
            if (resourceJSON.ContainsKey("find_by") && resourceJSON["find_by"].Type != JTokenType.Null)
            {
                resourceObj.FindBy = (string)resourceJSON["find_by"];
            }
            return(resourceObj);
        }