public string CreateJavaScriptClickCode(Record record, string sid = null)
        {
            if (String.IsNullOrEmpty(sid))
                sid = HttpContextFactory.Current.Session.SessionID;

            string query = FFParameters.Query.Replace(@"'", @"\'");

            int position = record.Position;

            string clickCode = "";

            if (position != 0 && query != "")
            {
                string channel = FFParameters.Channel;

                int currentPageNumber = SearchAdapter.Paging.CurrentPage;
                string originalPageSize = SearchAdapter.ProductsPerPageOptions.DefaultOption.Label;

                int originalPosition = record.OriginalPosition;
                if (originalPosition == 0) originalPosition = position;

                string campaign = record.Campaign;
                bool instoreAds = record.InstoreAds;

                string id = record.ID;
                string masterId = (string)record.GetFieldValue(FieldsSection.GetInstance().MasterProductNumber);

                sid = Regex.Replace(sid, "['\"\\\0]", @"\$&");

                clickCode = String.Format("tracking.click('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}');",
                    channel, sid, id, masterId, query, position, originalPosition, currentPageNumber, originalPageSize, campaign, instoreAds);
            }

            return clickCode;
        }
 public void AddPreviewRecord(Record record)
 {
     PreviewRecords.Add(record);
 }
        protected void FillCampaignWithPushedProducts(Campaign campaign, dynamic campaignData)
        {
            if (campaignData.pushedProductsRecords.Count > 0)
            {
                var pushedProducts = new List<Record>();

                foreach (var recordData in campaignData.pushedProductsRecords)
                {
                    var record = new Record((string)recordData.id);
                    record.SetFieldValues(recordData.record.AsDictionary());
                    pushedProducts.Add(record);
                }

                campaign.AddPushedProducts(pushedProducts);
            }
        }