Exemplo n.º 1
0
 private void SetBulkWriteRecordProperties(JObject recordJSON)
 {
     foreach (KeyValuePair <string, JToken> bulkRecord in recordJSON)
     {
         if (bulkRecord.Key.Equals("id") && bulkRecord.Value.Type != JTokenType.Null)
         {
             this.writeRecord.JobId = (long)bulkRecord.Value;
         }
         else if (bulkRecord.Key.Equals("created_by") && bulkRecord.Value.Type != JTokenType.Null)
         {
             JObject  createdByObj = (JObject)bulkRecord.Value;
             ZCRMUser createdBy    = ZCRMUser.GetInstance((long)createdByObj["id"], (string)createdByObj["name"]);
             this.writeRecord.CreatedBy = createdBy;
         }
         else if (bulkRecord.Key.Equals("created_time") && bulkRecord.Value.Type != JTokenType.Null)
         {
             this.writeRecord.CreatedTime = CommonUtil.RemoveEscaping((string)JsonConvert.SerializeObject(bulkRecord.Value));
         }
         else if (bulkRecord.Key.Equals("status") && bulkRecord.Value.Type != JTokenType.Null)
         {
             this.writeRecord.Status = (string)bulkRecord.Value;
         }
         else if (bulkRecord.Key.Equals("character_encoding") && bulkRecord.Value.Type != JTokenType.Null)
         {
             this.writeRecord.CharacterEncoding = (string)bulkRecord.Value;
         }
         else if (bulkRecord.Key.Equals("resource") && bulkRecord.Value.Type != JTokenType.Null)
         {
             this.SetZCRMBulkWriteResourceListofObject((JArray)bulkRecord.Value);
         }
         else if (bulkRecord.Key.Equals("result") && bulkRecord.Value.Type != JTokenType.Null)
         {
             JObject        createdObject = (JObject)bulkRecord.Value;
             ZCRMBulkResult result        = ZCRMBulkResult.GetInstance();
             if (createdObject.ContainsKey("download_url"))
             {
                 result.DownloadUrl = (string)createdObject["download_url"];
             }
             this.writeRecord.Result = result;
         }
         else if (bulkRecord.Key.Equals("operation") && bulkRecord.Value.Type != JTokenType.Null)
         {
             this.writeRecord.Operation = (string)bulkRecord.Value;
         }
         else if (bulkRecord.Key.Equals("callback") && bulkRecord.Value.Type != JTokenType.Null)
         {
             ZCRMBulkCallBack callback = ZCRMBulkCallBack.GetInstance();
             JObject          jsonObj  = (JObject)bulkRecord.Value;
             if (jsonObj.ContainsKey("url"))
             {
                 callback.Url = (string)jsonObj["url"];
             }
             if (jsonObj.ContainsKey("method"))
             {
                 callback.Method = (string)jsonObj["method"];
             }
             this.writeRecord.Callback = callback;
         }
     }
 }
Exemplo n.º 2
0
        private ZCRMBulkCallBack SetZCRMBulkCallBackObject(JObject callbackJSON)
        {
            ZCRMBulkCallBack callback = ZCRMBulkCallBack.GetInstance();

            if (callbackJSON.ContainsKey("url") && callbackJSON["url"].Type != JTokenType.Null)
            {
                callback.Url = (string)callbackJSON["url"];
            }
            if (callbackJSON.ContainsKey("method") && callbackJSON["method"].Type != JTokenType.Null)
            {
                callback.Method = (string)callbackJSON["method"];
            }
            return(callback);
        }