// Required for working with SqlBulkCopy
        private DataRow ConvertToDataRow(DeliveryFile file, PpcExampleRow row)
        {
            DataRow data = table.NewRow();

            data["Day_Code"]    = DayCode.ToDayCode(file.TargetDateTime);
            data["AccountID"]   = _delivery.AccountID;
            data["Campaign_GK"] = GKManager.GetCampaignGK(_delivery.AccountID, row.CampaignName);
            data["Adgroup_GK"]  = GKManager.GetAdgroupGK(_delivery.AccountID, row.AdgroupName);
            //etc.
        }
        public void GetDelivery(int deliveryId)
        {
            using (DataManager.Current.OpenConnection())
            {
                SqlCommand EngineCmd = DataManager.CreateCommand("SP_GetDeliveryData(@DeliveryID:int)", CommandType.StoredProcedure);
                EngineCmd.Parameters["@DeliveryID"].Value = deliveryId;
                SqlDataReader reader = EngineCmd.ExecuteReader();
                reader.Read();
                if (!reader["DeliveryID"].Equals(System.DBNull.Value))
                {
                    this.DeliveryID = (int)reader["DeliveryID"];
                }
                if (!reader["Description"].Equals(System.DBNull.Value))
                {
                    this.Description = (string)reader["Description"];
                }
                if (!reader["DeliveryState"].Equals(System.DBNull.Value))
                {
                    this.DeliveryState = (eDeliveryState)reader["DeliveryState"];
                }
                if (!reader["Parameters"].Equals(System.DBNull.Value))
                {
                    this.Description = (string)reader["Parameters"];
                }
                reader.Close();

                EngineCmd = DataManager.CreateCommand("SP_GetDeliveryFileData(@DeliveryID:int)", CommandType.StoredProcedure);
                EngineCmd.Parameters["@DeliveryID"].Value = deliveryId;
                reader = EngineCmd.ExecuteReader();
                while (reader.Read())
                {
                    DeliveryFile df = new DeliveryFile();
                    if (!reader["FileID"].Equals(System.DBNull.Value))
                    {
                        df.FileID = (int)reader["FileID"];
                    }
                    if (!reader["DeliveryID"].Equals(System.DBNull.Value))
                    {
                        df.DeliveryID = (int)reader["DeliveryID"];
                    }
                    if (!reader["FileName"].Equals(System.DBNull.Value))
                    {
                        df.FileName = (string)reader["FileName"];
                    }
                    if (!reader["FilePath"].Equals(System.DBNull.Value))
                    {
                        df.FilePath = (string)reader["FilePath"];
                    }
                    if (!reader["DownloadUrl"].Equals(System.DBNull.Value))
                    {
                        df.DownloadUrl = (string)reader["DownloadUrl"];
                    }
                    if (!reader["TargetDateTime"].Equals(System.DBNull.Value))
                    {
                        df.TargetDateTime = (DateTime)reader["TargetDateTime"];
                    }
                    if (!reader["ReaderType"].Equals(System.DBNull.Value))
                    {
                        df.ReaderType = (string)reader["ReaderType"];
                    }
                    if (!reader["Parameters"].Equals(System.DBNull.Value))
                    {
                        df.Parameters = (string)reader["Parameters"];
                    }
                    if (this.Files == null)
                    {
                        this.Files = new List <DeliveryFile>();
                    }
                    this.Files.Add(df);
                }
                reader.Close();
            }
        }