Exemplo n.º 1
0
        public ActionResult EditKeyword(long keywordGK)
        {
            Models.KeywordModel m = new Models.KeywordModel();

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

                m.Keyword = client.Service.Keyword_GetSingle(keywordGK)[0];

                Oltp.AdgroupDataTable keyword_adgroups = client.Service.Adgroup_GetByKeyword(keywordGK);
                Dictionary <int, Oltp.CampaignRow> campaings_dictionaty = client.Service.Campaign_GetIndividualCampaigns(keyword_adgroups.Select(f => f.CampaignGK).ToArray()).ToDictionary(f => f.GK, f => f);

                foreach (Oltp.AdgroupRow r in keyword_adgroups)
                {
                    m.Associations.Add(new Models.AssociationRowModel()
                    {
                        AdGroup = r, Campaign = campaings_dictionaty[(int)r.CampaignGK]
                    });
                }
            }

            return(PartialView("~/Views/Keywords/KeywordDetails.cshtml", m));
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        private void TabAssociations_GotFocus(object sender, RoutedEventArgs e)
        {
            if (!(Creative_dialog.TargetContent is Oltp.CreativeRow))
            {
                return;
            }

            // Show
            if (_assoc_Campaigns == null)
            {
                _assoc_Campaigns = VisualTree.GetChild <ItemsControl>(Creative_dialog, "_assoc_Campaigns");
            }

            if (_assoc_Campaigns.ItemsSource != null)
            {
                return;
            }

            Oltp.CreativeRow creative = (Creative_dialog.TargetContent as Oltp.CreativeRow);
            List <CampaignAdgroupCombination> duos = null;

            Window.AsyncOperation(delegate()
            {
                using (OltpProxy proxy = new OltpProxy())
                {
                    duos = new List <CampaignAdgroupCombination>();
                    Oltp.AdgroupDataTable adgroups = proxy.Service.Adgroup_GetByCreative(creative.GK);

                    if (adgroups.Rows.Count > 0)
                    {
                        // Get all parent campaign IDs
                        List <long> campaignGKs = new List <long>();
                        foreach (Oltp.AdgroupRow ag in adgroups.Rows)
                        {
                            if (!campaignGKs.Contains(ag.CampaignGK))
                            {
                                campaignGKs.Add(ag.CampaignGK);
                            }
                        }

                        // Now get the campaigns themselves
                        Oltp.CampaignDataTable campaigns = proxy.Service.Campaign_GetIndividualCampaigns(campaignGKs.ToArray());
                        foreach (Oltp.AdgroupRow ag in adgroups.Rows)
                        {
                            DataRow[] rs = campaigns.Select(String.Format("GK = {0}", ag.CampaignGK));
                            if (rs.Length > 0)
                            {
                                duos.Add(new CampaignAdgroupCombination(rs[0] as Oltp.CampaignRow, ag));
                            }
                        }
                    }
                }
            },
                                  delegate()
            {
                _assoc_Campaigns.ItemsSource = duos;
            });
        }
        public ActionResult EditCreative(long creativeGK)
        {
            Models.CreativeModel m = new Models.CreativeModel();

            using (var client = new OltpLogicClient(session_id))
            {
                Oltp.CreativeRow creative = client.Service.Creative_GetSingle(creativeGK)[0];
                //client.Service.Creative_Get(
                m.Creative = creative;

                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 = creative.Segment1; break;

                        case 2: value = creative.Segment2; break;

                        case 3: value = creative.Segment3; break;

                        case 4: value = creative.Segment4; break;

                        case 5: value = creative.Segment5; break;

                        default: value = creative.Segment1; break;
                        }


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

                Oltp.AdgroupDataTable creative_adgroups = client.Service.Adgroup_GetByCreative(creativeGK);
                Dictionary <int, Oltp.CampaignRow> campaings_dictionaty = client.Service.Campaign_GetIndividualCampaigns(creative_adgroups.Select(f => f.CampaignGK).ToArray()).ToDictionary(f => f.GK, f => f);

                foreach (Oltp.AdgroupRow r in creative_adgroups)
                {
                    m.Associations.Add(new Models.AssociationRowModel()
                    {
                        AdGroup = r, Campaign = campaings_dictionaty[(int)r.CampaignGK]
                    });
                }

                m.Creative = creative;
            }

            return(PartialView("~/Views/Creatives/CreativeDetails.cshtml", m));
        }
Exemplo n.º 4
0
        public PartialViewResult EditMultipleAdgroups(string adgroupsGK)
        {
            Oltp.AdgroupDataTable adgroups;
            List <long>           AdgroupsGK = adgroupsGK.Split(',').Select(s => s.Length > 0 ? long.Parse(s) : 0).ToList();

            Models.MultipleAdgroupModel m = new Models.MultipleAdgroupModel();
            m.AdgroupsGK = adgroupsGK;

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

                foreach (long adgroupGK in AdgroupsGK)
                {
                    Oltp.AdgroupDataTable t = client.Service.Adgroup_GetSingle(adgroupGK);
                    if (t.Count > 0)
                    {
                        m.Adgroups.Add(t[0]);
                    }
                }


                Oltp.SegmentDataTable segments = client.Service.Segment_Get(acc_id, true);
                foreach (Oltp.SegmentRow segment in segments)
                {
                    bool is_adgroup_segment = ((Auxilary.SegmentAssociationFlags)segment.Association).HasFlag(Auxilary.SegmentAssociationFlags.Adgroup);
                    if (is_adgroup_segment)
                    {
                        Oltp.SegmentValueDataTable segment_values = client.Service.SegmentValue_Get(acc_id, segment.SegmentID);
                        int value;
                        switch (segment.SegmentID)
                        {
                        case 1: value = GetCommonValue(m.Adgroups.Select(x => x.Segment1).ToList()); break;

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

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

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

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

                        default: value = GetCommonValue(m.Adgroups.Select(x => x.Segment1).ToList()); break;
                        }
                        m.Segments.Add(new Models.SegmentRowModel()
                        {
                            SegmentRow = segment, Values = segment_values.ToList(), SelectedValue = value
                        });
                    }
                }
            }

            return(PartialView("MultipleAdgroupDetails", m));
        }
Exemplo n.º 5
0
        public ActionResult EditMultipleAdgroups(string adgroupsGK, FormCollection coll)
        {
            List <long> AdgroupsGK = adgroupsGK.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.AdgroupDataTable adgroups = new Oltp.AdgroupDataTable();
                foreach (long adgroupGK in AdgroupsGK)
                {
                    adgroups.Merge(client.Service.Adgroup_GetSingle(adgroupGK));
                }

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

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

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

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

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

                                default: break;
                                }
                            }
                        }
                    }
                }

                client.Service.Adgroup_Save(adgroups, false);
            }

            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);
        }
Exemplo n.º 7
0
        public PartialViewResult GetAdgroupsForCampaign(long campaignGK)
        {
            List <Models.AdgroupRowModel> L = new List <Models.AdgroupRowModel>();

            using (var client = new OltpLogicClient(session_id))
            {
                Oltp.AdgroupDataTable t = client.Service.Adgroup_Get(campaignGK, null);

                foreach (Oltp.AdgroupRow a in t)
                {
                    L.Add(new Models.AdgroupRowModel()
                    {
                        AdgroupGK = a.GK, AdgroupName = a.Name
                    });
                }
            }

            return(PartialView("TableAdgroups", L));
        }
Exemplo n.º 8
0
        public PartialViewResult GetAdgroupsForCampaign(long campaignGK)
        {
            List <Models.AdgroupRowModel> L = new List <Models.AdgroupRowModel>();

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

                Oltp.AdgroupDataTable t = client.Service.Adgroup_Get(campaignGK, null);

                foreach (Oltp.AdgroupRow a in t)
                {
                    L.Add(new Models.AdgroupRowModel()
                    {
                        AdgroupGK = a.GK, AdgroupName = a.Name
                    });
                }
            }

            return(PartialView("TableAdgroups", L));
        }