public PartialViewResult FindCreatives(string searchText)
        {
            Models.CreativeListModel m = new Models.CreativeListModel();

            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                Oltp.CreativeDataTable creatives = client.Service.Creative_Get(acc_id, searchText.Trim() + "*", true);

                foreach (Oltp.CreativeRow creative in creatives)
                {
                    if (creative.Title.Trim().Length > 0)
                    {
                        m.Creatives.Add(creative);
                    }
                }
            }



            return(PartialView("Table", m));
        }
        public ActionResult EditMultipleCreatives(string creativesGK)
        {
            List <long> CreativesGK = creativesGK.Split(',').Select(s => s.Length > 0 ? long.Parse(s) : 0).ToList();

            Models.MutliCreativeModel m = new Models.MutliCreativeModel();
            m.CreativesGK = creativesGK;

            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                foreach (long creativeGK in CreativesGK)
                {
                    Oltp.CreativeDataTable t = client.Service.Creative_GetSingle(creativeGK);
                    if (t.Count > 0)
                    {
                        m.Creatives.Add(t[0]);
                    }
                }

                Oltp.SegmentDataTable segments = client.Service.Segment_Get(acc_id, false);

                foreach (Oltp.SegmentRow r in segments)
                {
                    bool is_creative_segment = ((Auxilary.SegmentAssociationFlags)r.Association).HasFlag(Auxilary.SegmentAssociationFlags.Creative);
                    if (is_creative_segment)
                    {
                        Oltp.SegmentValueDataTable values = client.Service.SegmentValue_Get(acc_id, r.SegmentID);
                        int value;
                        switch (r.SegmentID)
                        {
                        case 1: value = GetCommonValue(m.Creatives.Select(x => x.Segment1).ToList()); break;

                        case 2: value = GetCommonValue(m.Creatives.Select(x => x.Segment2).ToList()); break;

                        case 3: value = GetCommonValue(m.Creatives.Select(x => x.Segment3).ToList()); break;

                        case 4: value = GetCommonValue(m.Creatives.Select(x => x.Segment4).ToList()); break;

                        case 5: value = GetCommonValue(m.Creatives.Select(x => x.Segment5).ToList()); break;

                        default: value = GetCommonValue(m.Creatives.Select(x => x.Segment1).ToList()); break;
                        }

                        m.Segments.Add(new Models.SegmentRowModel()
                        {
                            SegmentRow = r, Values = values.ToList(), SelectedValue = value
                        });
                    }
                }
            }

            return(PartialView("MultiCreativeDetails", m));
        }
        public ActionResult EditMultipleCreatives(string creativesGK, FormCollection coll)
        {
            List <long> CreativesGK = creativesGK.Split(',').Select(s => s.Length > 0 ? long.Parse(s) : 0).ToList();

            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                Oltp.CreativeDataTable Creatives = new Oltp.CreativeDataTable();
                foreach (long creativeGK in CreativesGK)
                {
                    Creatives.Merge(client.Service.Creative_GetSingle(creativeGK));
                }

                foreach (string key in coll.Keys)
                {
                    if (key.Contains("creativeSegmentValueEdit_"))
                    {
                        if (coll[key] == "1")
                        {
                            string segment_id   = key.Split('_')[1];
                            int    segmentID    = int.Parse(segment_id);
                            int    segmentValue = int.Parse(coll["creativeSegmentValue_" + segment_id]);
                            if (segmentValue != -100)
                            {
                                switch (segmentID)
                                {
                                case 1: Creatives.ToList().ForEach(x => x.Segment1 = segmentValue); break;

                                case 2: Creatives.ToList().ForEach(x => x.Segment2 = segmentValue); break;

                                case 3: Creatives.ToList().ForEach(x => x.Segment3 = segmentValue); break;

                                case 4: Creatives.ToList().ForEach(x => x.Segment4 = segmentValue); break;

                                case 5: Creatives.ToList().ForEach(x => x.Segment5 = segmentValue); break;

                                default: break;
                                }
                            }
                        }
                    }
                }

                client.Service.Creative_Save(Creatives);
            }

            return(Content("OK"));
        }
        private string GetReferenceData(Oltp.GatewayRow tracker, OltpLogicClient client)
        {
            string referenceData = "";

            if (tracker.AdgroupGK < 1)
            {
                return("");
            }

            Oltp.AdgroupDataTable adg = client.Service.Adgroup_GetSingle(tracker.AdgroupGK);
            if (adg.Rows.Count < 1)
            {
                return("");
            }

            Oltp.AdgroupRow adgroup = adg[0];

            Oltp.CampaignDataTable cmpn = client.Service.Campaign_GetSingle(adgroup.CampaignGK);
            if (cmpn.Rows.Count > 0)
            {
                referenceData += "<span>" + (cmpn.Rows[0] as Oltp.CampaignRow).Name + "</span> > ";
            }
            referenceData += "<span>" + adgroup.Name + "</span> > ";


            if (!tracker.IsReferenceTypeNull())
            {
                if (tracker.ReferenceType == Oltp.GatewayReferenceType.Creative)
                {
                    Oltp.CreativeDataTable c = client.Service.Creative_GetSingle(tracker.ReferenceID);
                    if (c.Rows.Count > 0)
                    {
                        referenceData += "Creative: <span>" + (c[0] as Oltp.CreativeRow).Title + "</span>";
                    }
                }
                else
                {
                    Oltp.KeywordDataTable k = client.Service.Keyword_GetSingle(tracker.ReferenceID);
                    if (k.Rows.Count > 0)
                    {
                        referenceData += "Keyword: <span>" + (k[0] as Oltp.KeywordRow).Keyword + "</span>";
                    }
                }
            }

            return(referenceData);
        }
        public PartialViewResult FindCreatives(string searchText)
        {
            Models.CreativeListModel m = new Models.CreativeListModel();

            using (var client = new OltpLogicClient(session_id))
            {
                Oltp.CreativeDataTable creatives = client.Service.Creative_Get(acc_id, searchText + "%", true);

                foreach (Oltp.CreativeRow creative in creatives)
                {
                    m.Creatives.Add(creative);
                }
            }



            return(PartialView("Table", m));
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="include"></param>
        private void GetCreatives(Oltp.AccountRow account, string filter, bool include)
        {
            Oltp.AccountRow currentAccount = account == null ? this.Window.CurrentAccount : account;

            if (currentAccount == null)
            {
                return;
            }

            Window.AsyncOperation(delegate()
            {
                using (OltpProxy proxy = new OltpProxy())
                {
                    _creatives = proxy.Service.Creative_Get(currentAccount.ID, filter, include);
                }
            },
                                  delegate()
            {
                // Get an empty new list
                if (_items == null)
                {
                    _items = new ObservableCollection <DataRow>();
                }
                else
                {
                    _items.Clear();
                }

                // Add all items
                foreach (DataRow r in _creatives.Rows)
                {
                    _items.Add(r);
                }

                _listTable.ListView.ItemsSource = _items;
            });
        }