public override void AddItems(List<DataCompareItem> items, IDataSynchronizationStatus status)
        {
            if (items != null && items.Count > 0)
            {
                int currentItem = 0;
                
                foreach (var item in items.Select(p => new DataCompareItemInvariant(p)))
                {
                    if (!status.ContinueProcessing)
                        break;

                    try
                    {
                        //Call the Automation BeforeAddItem
                        if (Automation != null)
                            Automation.BeforeAddItem(this, item, null);

                        if (item.Sync)
                        {
                            #region Add Item

                            foreach (DataCompareColumnItem dcci in item.SourceRow)
                            {
                                if (!Mapping.ColumnMapsToDestination(dcci))
                                    continue;

                                string columnB = Mapping.MapColumnToDestination(dcci);

                                object sourceValue = dcci.BeforeColumnValue;

                                //Ignore Null Values
                                if (sourceValue == null)
                                    continue;

                                //TODO: Add the Item to the Target

                                //Call the Automation AfterAddItem (pass the created identifier if possible)
                                if (Automation != null)
                                    Automation.AfterAddItem(this, item, null);
                            }

                            #endregion
                        }
                    }
                    catch (Exception)
                    {
                        //TODO: Handle Error
                        
                        if (status.FailOnError)
                            throw;
                    }
                    finally
                    {
                        status.Progress(items.Count, ++currentItem);
                    }

                }
            }
        }
        public override void AddItems(List <DataCompareItem> items, IDataSynchronizationStatus status)
        {
            if (items != null && items.Count > 0)
            {
                int currentItem = 0;

                foreach (var item in items)
                {
                    if (!status.ContinueProcessing)
                    {
                        break;
                    }

                    try
                    {
                        var itemInvariant = new DataCompareItemInvariant(item);
                        //Get the Target Item Data
                        Dictionary <string, object> targetItem = AddItemToDictionary(Mapping, itemInvariant);

                        string fileName = DataSchemaTypeConverter.ConvertTo <string>(targetItem["FullFileName"]) ?? DataSchemaTypeConverter.ConvertTo <string>(targetItem["FileName"]);

                        fileName = Utility.CombineWebPath(DataSourceReader.Path, Utility.EnsureWebPath(fileName));

                        Automation?.BeforeAddItem(this, itemInvariant, fileName);

                        if (itemInvariant.Sync)
                        {
                            string tmpFile = System.IO.Path.Combine(Utility.GetTempPath(), $"{Guid.NewGuid()}.tmp");

                            try
                            {
                                System.IO.File.WriteAllBytes(tmpFile, SourceReader.GetBlobData(itemInvariant.ToDataCompareItem(), 0));
                                if (targetItem.TryGetValue("DateModified", out object value))
                                {
                                    System.IO.File.SetLastWriteTimeUtc(tmpFile, DataSchemaTypeConverter.ConvertTo <DateTime>(value).ToUniversalTime());
                                }

                                CreateDirectory(Utility.EnsureWebPath(System.IO.Path.GetDirectoryName(fileName)));

                                Session.PutFiles(tmpFile, fileName, false, new TransferOptions {
                                    PreserveTimestamp = true, TransferMode = TransferMode.Binary
                                }).Check();
                            }
                            catch (Exception e)
                            {
                                Automation?.ErrorItem(this, itemInvariant, fileName, e);
                                throw;
                            }
                            finally
                            {
                                if (System.IO.File.Exists(tmpFile))
                                {
                                    System.IO.File.Delete(tmpFile);
                                }
                            }

                            Automation?.AfterAddItem(this, itemInvariant, null);
                        }

                        ClearSyncStatus(item); //Clear the Sync Flag on Processed Rows
                    }
                    catch (SystemException e)
                    {
                        HandleError(status, e);
                    }
                    finally
                    {
                        status.Progress(items.Count, ++currentItem); //Update the Sync Progress
                    }
                }
            }
        }
        public override void AddItems(List <DataCompareItem> items, IDataSynchronizationStatus status)
        {
            if (items != null && items.Count > 0)
            {
                int currentItem = 0;

                foreach (var item in items)
                {
                    if (!status.ContinueProcessing)
                    {
                        break;
                    }

                    var itemInvariant = new DataCompareItemInvariant(item);

                    try
                    {
                        //Call the Automation BeforeAddItem
                        Automation?.BeforeAddItem(this, itemInvariant, null);

                        if (itemInvariant.Sync)
                        {
                            #region Add Item

                            //Get the Target Item Data
                            var targetItem       = AddItemToDictionary(Mapping, itemInvariant);
                            var targetItemToSend = new Dictionary <string, object>();

                            foreach (var k in targetItem.Keys)
                            {
                                var val = targetItem[k];

                                if (val == null)
                                {
                                    continue;
                                }

                                var pdsi = DataSchema[k];
                                targetItemToSend[pdsi.Key] = pdsi.Parser.ConvertValue(val);
                            }

                            if (targetItemToSend.Any())
                            {
                                var json    = JsonConvert.SerializeObject(targetItemToSend, Formatting.None);
                                var result  = WebRequestHelper.PostRequestAsJson(json, DatasourceInfo.PipedriveEndpointUrl);
                                var item_id = result["data"]["id"].ToObject <int>();

                                //Call the Automation AfterAddItem
                                Automation?.AfterAddItem(this, itemInvariant, item_id);
                            }

                            #endregion
                        }

                        ClearSyncStatus(item); //Clear the Sync Flag on Processed Rows
                    }
                    catch (WebException e)
                    {
                        Automation?.ErrorItem(this, itemInvariant, null, e);
                        HandleError(status, e);
                    }
                    catch (SystemException e)
                    {
                        Automation?.ErrorItem(this, itemInvariant, null, e);
                        HandleError(status, e);
                    }
                    finally
                    {
                        status.Progress(items.Count, ++currentItem); //Update the Sync Progress
                    }
                }
            }
        }
        public override void AddItems(List <DataCompareItem> items, IDataSynchronizationStatus status)
        {
            if (items != null && items.Count > 0)
            {
                int currentItem = 0;

                foreach (var item in items)
                {
                    if (!status.ContinueProcessing)
                    {
                        break;
                    }

                    var itemInvariant = new DataCompareItemInvariant(item);

                    try
                    {
                        //Call the Automation BeforeAddItem (Optional only required if your supporting Automation Item Events)
                        Automation?.BeforeAddItem(this, itemInvariant, null);

                        if (itemInvariant.Sync)
                        {
                            #region Add Item

                            //Get the Target Item Data
                            var targetItem       = AddItemToDictionary(Mapping, itemInvariant);
                            var targetItemToSend = new Dictionary <string, object>();

                            foreach (var k in targetItem.Keys)
                            {
                                if (!MailChimpDataSchema.ContainsKey(k))
                                {
                                    continue;
                                }

                                var mc = MailChimpDataSchema[k];

                                if (mc.ReadOnly)
                                {
                                    continue;
                                }

                                if (mc.IsSubValue)
                                {
                                    if (mc.IsArray)
                                    {
                                        if (mc.ObjectName == "tags")
                                        {
                                            // If Tags - create an array of Tags to add.
                                            targetItemToSend[mc.ObjectName] = DataSchemaTypeConverter.ConvertTo <string[]>(targetItem[k]);
                                        }
                                    }
                                    else
                                    {
                                        if (!targetItemToSend.ContainsKey(mc.ObjectName))
                                        {
                                            targetItemToSend[mc.ObjectName] = new Dictionary <string, object>();
                                        }

                                        var subValue = targetItemToSend[mc.ObjectName] as Dictionary <string, object>;

                                        subValue[mc.FieldName] = targetItem[k];
                                    }
                                }
                                else
                                {
                                    targetItemToSend[mc.FieldName] = targetItem[k];
                                }
                            }

                            var json    = JsonConvert.SerializeObject(targetItemToSend, Formatting.None);
                            var result  = WebRequestHelper.PostRequestAsJson(json, $"{ListServiceUrl}/{DataSourceReader.ListId}/members");
                            var item_id = result["id"].ToObject <string>();

                            //Call the Automation AfterAddItem (pass the created item identifier if possible)
                            Automation?.AfterAddItem(this, itemInvariant, item_id);
                        }

                        #endregion

                        ClearSyncStatus(item); //Clear the Sync Flag on Processed Rows
                    }
                    catch (WebException e)
                    {
                        Automation?.ErrorItem(this, itemInvariant, null, e);
                        HandleError(status, e);
                    }
                    catch (SystemException e)
                    {
                        Automation?.ErrorItem(this, itemInvariant, null, e);
                        HandleError(status, e);
                    }
                    finally
                    {
                        status.Progress(items.Count, ++currentItem); //Update the Sync Progress
                    }
                }
            }
        }