コード例 #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));
        }
        public PartialViewResult BatchUpdate()
        {
            Models.TrackersBatchModel m = new Models.TrackersBatchModel();

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

                Oltp.SegmentDataTable segments = client.Service.Segment_Get(acc_id, true);
                foreach (Oltp.SegmentRow segment in segments)
                {
                    bool is_tracker_segment = ((Auxilary.SegmentAssociationFlags)segment.Association).HasFlag(Auxilary.SegmentAssociationFlags.Gateyway);
                    if (is_tracker_segment)
                    {
                        Oltp.SegmentValueDataTable segment_values = client.Service.SegmentValue_Get(acc_id, segment.SegmentID);
                        m.Segments.Add(new Models.SegmentRowModel()
                        {
                            SegmentRow = segment, Values = segment_values.ToList(), SelectedValue = -1
                        });
                    }
                }
                Oltp.ChannelDataTable channels = client.Service.Channel_Get();
                m.Channels     = channels.ToDictionary(c => c.ID, c => c.DisplayName);
                m.LandingPages = client.Service.Page_Get(acc_id, null, true, -1).ToDictionary(p => p.GK, p => p.DisplayName);
            }


            return(PartialView("BatchTrackers", m));
        }
コード例 #3
0
        public ActionResult Index(int account, string session)
        {
            AppState.AccountID = account;
            AppState.SessionID = session;

            acc_id     = AppState.AccountID;
            session_id = AppState.SessionID;

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

                Oltp.CampaignDataTable t = client.Service.Campaign_Get(acc_id, null, null, null, false);
                m.Statuses = client.Service.CampaignStatus_Get().ToDictionary(x => x.ID, x => x.Name);
                m.Channels = client.Service.Channel_Get().ToDictionary(h => h.ID, h => h.DisplayName);

                foreach (Oltp.CampaignRow c in t)
                {
                    m.Campaigns.Add(new Models.CampaignRowModel()
                    {
                        CampaignGK   = c.GK,
                        CampaignName = c.IsNameNull() ? "(no name)" : c.Name,
                        Status       = m.Statuses.ContainsKey(c.StatusID) ? m.Statuses[c.StatusID] : String.Format("Unknown ({0})", c.StatusID),
                        ChannelName  = m.Channels.ContainsKey(c.ChannelID) ? m.Channels[c.ChannelID] : String.Format("Unknown ({0})", c.ChannelID)
                    });
                }
            }

            return(View(m));
        }
        public ActionResult Index(int account, string session)
        {
            AppState.AccountID = account;
            AppState.SessionID = session;

            acc_id     = AppState.AccountID;
            session_id = AppState.SessionID;

            Models.TrackersListModel m = new Models.TrackersListModel();

            using (var client = OltpLogicClient.Open(session_id))
            {
                // Load Channels
                Oltp.ChannelDataTable channels = client.Service.Channel_Get();
                m.Channels = channels.OrderBy(x => x.DisplayName).ToDictionary(c => c.ID, c => c.DisplayName);

                // Load Segments
                Oltp.SegmentDataTable segments = client.Service.Segment_Get(acc_id, true);

                foreach (Oltp.SegmentRow segment in segments)
                {
                    bool is_tracker_segment = ((Auxilary.SegmentAssociationFlags)segment.Association).HasFlag(Auxilary.SegmentAssociationFlags.Gateyway);
                    if (is_tracker_segment)
                    {
                        Oltp.SegmentValueDataTable segment_values = client.Service.SegmentValue_Get(acc_id, segment.SegmentID);
                        m.Segments.Add(new Models.SegmentRowModel()
                        {
                            SegmentRow = segment, Values = segment_values.ToList()
                        });
                    }
                }
            }
            return(View(m));
        }
        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 AddNewSegmentValue(int segmentID, string newValue)
        {
            int newValueID = 0;

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

                Oltp.SegmentValueDataTable t = client.Service.SegmentValue_Get(acc_id, segmentID);
                Oltp.SegmentValueRow       r = t.NewSegmentValueRow();
                r.AccountID = acc_id;
                r.SegmentID = segmentID;
                r.Value     = newValue;
                t.AddSegmentValueRow(r);

                Oltp.SegmentValueDataTable t2 = client.Service.SegmentValue_Save(t);

                Dictionary <int, string> oldcollection = t.ToDictionary(z => z.ValueID, z => z.Value);
                Dictionary <int, string> newcollection = t2.ToDictionary(z => z.ValueID, z => z.Value);

                newValueID = newcollection.Where(n => !oldcollection.ContainsKey(n.Key)).First().Key;
            }

            return(Content(newValueID.ToString()));
        }
        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));
        }
コード例 #8
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));
        }
コード例 #9
0
        public PartialViewResult EditCampaign(long campaignGK)
        {
            Models.CampaignModel m = new Models.CampaignModel();

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

                m.Campaign = client.Service.Campaign_GetSingle(campaignGK)[0];


                Oltp.SegmentDataTable segments = client.Service.Segment_Get(acc_id, true);
                foreach (Oltp.SegmentRow segment in segments)
                {
                    bool is_campaign_segment = ((Auxilary.SegmentAssociationFlags)segment.Association).HasFlag(Auxilary.SegmentAssociationFlags.Campaign);
                    if (is_campaign_segment)
                    {
                        Oltp.SegmentValueDataTable segment_values = client.Service.SegmentValue_Get(acc_id, segment.SegmentID);
                        int value;
                        switch (segment.SegmentID)
                        {
                        case 1: value = m.Campaign.Segment1; break;

                        case 2: value = m.Campaign.Segment2; break;

                        case 3: value = m.Campaign.Segment3; break;

                        case 4: value = m.Campaign.Segment4; break;

                        case 5: value = m.Campaign.Segment5; break;

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

                DataTable t = client.Service.CampaignTargets_Get(acc_id, campaignGK);
                if (t.Rows.Count > 0)
                {
                    m.Target_Customer  = t.Rows[0]["CPA_new_users"] == DBNull.Value ? null : (double?)t.Rows[0]["CPA_new_users"];
                    m.Target_Depositor = t.Rows[0]["CPA_new_activations"] == DBNull.Value ? null : (double?)t.Rows[0]["CPA_new_activations"];
                }
            }


            return(PartialView("CampaignDetails", m));
        }
コード例 #10
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"));
        }
        public PartialViewResult EditTracker(string identifier)
        {
            Models.TrackerModel m = new Models.TrackerModel();

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

                m.Tracker = client.Service.Gateway_GetByIdentifier(acc_id, identifier)[0];

                Oltp.SegmentDataTable segments = client.Service.Segment_Get(acc_id, true);
                foreach (Oltp.SegmentRow segment in segments)
                {
                    bool is_tracker_segment = ((Auxilary.SegmentAssociationFlags)segment.Association).HasFlag(Auxilary.SegmentAssociationFlags.Gateyway);
                    if (is_tracker_segment)
                    {
                        Oltp.SegmentValueDataTable segment_values = client.Service.SegmentValue_Get(acc_id, segment.SegmentID);
                        int value;
                        switch (segment.SegmentID)
                        {
                        case 1: value = m.Tracker.Segment1; break;

                        case 2: value = m.Tracker.Segment2; break;

                        case 3: value = m.Tracker.Segment3; break;

                        case 4: value = m.Tracker.Segment4; break;

                        case 5: value = m.Tracker.Segment5; break;

                        default: value = m.Tracker.Segment1; break;
                        }
                        m.Segments.Add(new Models.SegmentRowModel()
                        {
                            SegmentRow = segment, Values = segment_values.ToList(), SelectedValue = value
                        });
                    }
                }
                Oltp.ChannelDataTable channels = client.Service.Channel_Get();
                m.Channels     = channels.ToDictionary(c => c.ID, c => c.DisplayName);
                m.LandingPages = client.Service.Page_Get(acc_id, null, true, -1).ToDictionary(p => p.GK, p => p.DisplayName);
                m.AppliedTo    = GetReferenceData(m.Tracker, client);
            }


            return(PartialView("TrackerDetails", m));
        }
コード例 #12
0
        public ActionResult EditMultipleCampaign(string campaignsGK)
        {
            List <long> CampaingsGK = campaignsGK.Split(',').Select(s => s.Length > 0 ? long.Parse(s) : 0).ToList();

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

                m.Campaigns = client.Service.Campaign_GetIndividualCampaigns(CampaingsGK.ToArray()).ToList();

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

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

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

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

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

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


            return(PartialView("MultiCampaignDetails", m));
        }
        public ActionResult EditTracker(string identifier, FormCollection coll)
        {
            Oltp.GatewayDataTable trackers;
            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                trackers = client.Service.Gateway_GetByIdentifier(acc_id, identifier);

                trackers[0].Name           = coll["TrackerName"];
                trackers[0].ChannelID      = int.Parse(coll["Channel"]);
                trackers[0].DestinationURL = coll["DestinationURL"];
                trackers[0].PageGK         = long.Parse(coll["LandingPage"]);
                foreach (string key in coll.Keys)
                {
                    if (key.Contains("trackerSegmentValue_"))
                    {
                        string segment_id   = key.Split('_')[1];
                        int    segmentID    = int.Parse(segment_id);
                        int    segmentValue = int.Parse(coll[key]);
                        switch (segmentID)
                        {
                        case 1: trackers[0].Segment1 = segmentValue; break;

                        case 2: trackers[0].Segment2 = segmentValue; break;

                        case 3: trackers[0].Segment3 = segmentValue; break;

                        case 4: trackers[0].Segment4 = segmentValue; break;

                        case 5: trackers[0].Segment5 = segmentValue; break;

                        default: break;
                        }
                    }
                }

                client.Service.Gateway_Save(trackers);
            }

            return(Content("OK"));
        }
        public ActionResult EditCreative(long creativeGK, FormCollection coll)
        {
            Oltp.CreativeDataTable creatives;
            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }
                creatives = client.Service.Creative_GetSingle(creativeGK);
            }

            foreach (string key in coll.Keys)
            {
                if (key.Contains("creativeSegmentValue_"))
                {
                    string segment_id   = key.Split('_')[1];
                    int    segmentID    = int.Parse(segment_id);
                    int    segmentValue = int.Parse(coll[key]);
                    switch (segmentID)
                    {
                    case 1: creatives[0].Segment1 = segmentValue; break;

                    case 2: creatives[0].Segment2 = segmentValue; break;

                    case 3: creatives[0].Segment3 = segmentValue; break;

                    case 4: creatives[0].Segment4 = segmentValue; break;

                    case 5: creatives[0].Segment5 = segmentValue; break;

                    default: break;
                    }
                }
            }
            System.Data.DataTable t = creatives.GetChanges();

            using (var client = OltpLogicClient.Open(session_id))
            {
                client.Service.Creative_Save(creatives);
            }

            return(Content("OK"));
        }
コード例 #15
0
        public PartialViewResult Find(FormCollection colls)
        {
            Models.CampaignListModel m = new Models.CampaignListModel();
            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                m.Statuses = client.Service.CampaignStatus_Get().ToDictionary(x => x.ID, x => x.Name);
                m.Channels = client.Service.Channel_Get().ToDictionary(h => h.ID, h => h.DisplayName);

                int?   channelID       = colls["Channel"] == "0" ? null : (int?)int.Parse(colls["Channel"]);
                int?   statusID        = colls["Status"] == "0" ? null : (int?)int.Parse(colls["Status"]);
                string textToSearch    = colls["searchText"].Trim().Equals("") ? null : colls["searchText"].Trim() + "*";
                bool   filterByAdgroup = colls["typeOfSearch"] == "adgroup";

                Oltp.CampaignDataTable t = client.Service.Campaign_Get(acc_id, channelID, statusID, textToSearch, filterByAdgroup);
                foreach (Oltp.CampaignRow c in t)
                {
                    m.Campaigns.Add(new Models.CampaignRowModel()
                    {
                        CampaignGK = c.GK, CampaignName = c.Name, Status = m.Statuses[c.StatusID], ChannelName = m.Channels[c.ChannelID]
                    });
                }

                DataTable targets = client.Service.CampaignTargets_Get(acc_id, null);
                Dictionary <long, Models.CampaignRowModel> dic = m.Campaigns.ToDictionary(q => q.CampaignGK, q => q);

                foreach (DataRow r in targets.Rows)
                {
                    long campaignGK = (long)(int)r["CampaignGK"];
                    if (dic.ContainsKey(campaignGK))
                    {
                        dic[campaignGK].CPA1 = r["CPA_new_users"] == DBNull.Value ? null : (double?)r["CPA_new_users"];
                        dic[campaignGK].CPA2 = r["CPA_new_activations"] == DBNull.Value ? null : (double?)r["CPA_new_activations"];
                    }
                }
            }

            return(PartialView("Table", m.Campaigns));
        }
コード例 #16
0
        public PartialViewResult FindKeywords(string searchText)
        {
            List <Oltp.KeywordRow> L = new List <Oltp.KeywordRow>();

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

                string str = searchText.Trim().Length > 0 ? searchText.Trim() + "*" : null;
                Oltp.KeywordDataTable keywords = client.Service.Keyword_Get(acc_id, true, str, true);

                foreach (Oltp.KeywordRow keyword in keywords)
                {
                    L.Add(keyword);
                }
            }

            return(PartialView("Table", L));
        }
コード例 #17
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));
        }
        public ActionResult BatchUpdate(FormCollection coll)
        {
            List <long[]> ranges = new List <long[]>();

            string[] rangeStrings = coll["Range"].Split(',');
            bool     error        = false;

            foreach (string rangeString in rangeStrings)
            {
                string[] boundStrings = rangeString.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                if (boundStrings.Length == 1 || boundStrings.Length == 2)
                {
                    long[] bounds = new long[boundStrings.Length];
                    for (int i = 0; i < bounds.Length; i++)
                    {
                        if (!long.TryParse(boundStrings[i], out bounds[i]))
                        {
                            error = true;
                            break;
                        }
                    }
                    if (bounds.Length == 2)
                    {
                        if (bounds[0] >= bounds[1])
                        {
                            error = true;
                            break;
                        }
                    }
                    ranges.Add(bounds);
                }
                else
                {
                    error = true;
                    break;
                }
            }

            if (error)
            {
                return(Content("Error"));
            }

            int? channelID = coll["Channel"] == "-1" ? null : (int?)int.Parse(coll["Channel"]);
            long?pageGK    = coll["LandingPage"] == "-1" ? null : (long?)long.Parse(coll["LandingPage"]);

            int?[] segments = new int?[5];
            for (int i = 1; i < 6; i++)
            {
                if (coll.AllKeys.Contains("batchtrackersSegmentValue_" + i))
                {
                    segments[i - 1] = int.Parse(coll["batchtrackersSegmentValue_" + i]);
                }
                else
                {
                    segments[i - 1] = null;
                }
                if (segments[i - 1] == -1)
                {
                    segments[i - 1] = null;
                }
            }

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

                result = client.Service.Gateway_BatchProperties(acc_id, ranges.ToArray(), channelID, pageGK, segments);
            }

            return(Content(result[0] + "," + (result[0] - result[1])));
        }
        public PartialViewResult FindTrackers(FormCollection colls)
        {
            List <EdgeBiUI.Models.TrackerRowModel> L = new List <Models.TrackerRowModel>();

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

                int?channelID = colls["Channel"] == "0" ? null : (int?)int.Parse(colls["Channel"]);

                int?[] segments = new int?[5];

                for (int i = 1; i < 6; i++)
                {
                    if (colls.AllKeys.Contains("Segment" + i))
                    {
                        segments[i - 1] = int.Parse(colls["Segment" + i]);
                    }
                    else
                    {
                        segments[i - 1] = null;
                    }
                    if (segments[i - 1] == 0)
                    {
                        segments[i - 1] = null;
                    }
                }

                string Identifier = colls["Identifier"];

                Oltp.GatewayDataTable t;
                if (Identifier.Equals(""))
                {
                    t = client.Service.Gateway_GetGateways(acc_id, channelID, segments);
                }
                else
                {
                    t = client.Service.Gateway_GetByIdentifier(acc_id, Identifier);
                }

                Dictionary <int, string> Channels = client.Service.Channel_Get().ToDictionary(c => c.ID, c => c.DisplayName);

                foreach (Oltp.GatewayRow g in t)
                {
                    Models.TrackerRowModel m1 = new Models.TrackerRowModel();
                    m1.TrackerID   = g.GK;
                    m1.ChannelName = Channels[g.ChannelID];
                    if (g.IsNameNull())
                    {
                        m1.TrackerName = "";
                    }
                    else
                    {
                        m1.TrackerName = g.Name;
                    }
                    m1.Identifier = g.Identifier;

                    L.Add(m1);
                }
            }

            return(PartialView("Table", L));
        }
コード例 #20
0
        public ActionResult EditAdgroup(long adgroupGK, FormCollection coll)
        {
            Oltp.AdgroupDataTable adgroups;
            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                adgroups = client.Service.Adgroup_GetSingle(adgroupGK);

                foreach (string key in coll.Keys)
                {
                    if (key.Contains("adgroupSegmentValue_"))
                    {
                        string segment_id   = key.Split('_')[1];
                        int    segmentID    = int.Parse(segment_id);
                        int    segmentValue = int.Parse(coll[key]);
                        switch (segmentID)
                        {
                        case 1: adgroups[0].Segment1 = segmentValue; break;

                        case 2: adgroups[0].Segment2 = segmentValue; break;

                        case 3: adgroups[0].Segment3 = segmentValue; break;

                        case 4: adgroups[0].Segment4 = segmentValue; break;

                        case 5: adgroups[0].Segment5 = segmentValue; break;

                        default: break;
                        }
                    }
                }

                client.Service.Adgroup_Save(adgroups, false);

                Oltp.AdgroupCreativeDataTable adgroupcreatives = client.Service.AdgroupCreative_Get(adgroupGK);
                foreach (Oltp.AdgroupCreativeRow r in adgroupcreatives)
                {
                    foreach (string key in coll.Keys)
                    {
                        if (key.Contains("adgroupcreative" + r.AdgroupCreativeGK + "_SegmentValue_"))
                        {
                            string segment_id   = key.Split('_')[2];
                            int    segmentID    = int.Parse(segment_id);
                            int    segmentValue = int.Parse(coll[key]);
                            switch (segmentID)
                            {
                            case 1: r.Segment1 = segmentValue; break;

                            case 2: r.Segment2 = segmentValue; break;

                            case 3: r.Segment3 = segmentValue; break;

                            case 4: r.Segment4 = segmentValue; break;

                            case 5: r.Segment5 = segmentValue; break;

                            case 999: r.PageGK = segmentValue; break;

                            default: break;
                            }
                        }
                    }
                }
                client.Service.AdgroupCreative_Save(adgroupcreatives);
            }
            return(Content("OK"));
        }
コード例 #21
0
        public PartialViewResult EditAdgroup(long adgroupGK)
        {
            Models.AdgroupModel m = new Models.AdgroupModel();

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

                m.Adgroup = client.Service.Adgroup_GetSingle(adgroupGK)[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 = m.Adgroup.Segment1; break;

                        case 2: value = m.Adgroup.Segment2; break;

                        case 3: value = m.Adgroup.Segment3; break;

                        case 4: value = m.Adgroup.Segment4; break;

                        case 5: value = m.Adgroup.Segment5; break;

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

                Oltp.AdgroupKeywordDataTable k = client.Service.AdgroupKeyword_Get(adgroupGK);
                foreach (Oltp.AdgroupKeywordRow r in k)
                {
                    Models.AdgroupKeywordModel m1 = new Models.AdgroupKeywordModel();
                    m1.DestinationURL = r.DestinationUrlDisplay;
                    m1.KeywordGK      = r.KeywordGK;
                    m1.KeywordName    = r.KeywordDisplay;
                    m1.MatchType      = r.MatchTypeDisplay;
                    m.Keywords.Add(m1);
                }

                Oltp.AdgroupCreativeDataTable c = client.Service.AdgroupCreative_Get(adgroupGK);
                foreach (Oltp.AdgroupCreativeRow r in c)
                {
                    Models.AdgroupCreativeModel m1 = new Models.AdgroupCreativeModel();
                    m1.AdgroupCreativeGK = r.AdgroupCreativeGK;
                    m1.CreativeGK        = r.CreativeGK;
                    m1.Desc1             = r.Desc1;
                    m1.Desc2             = r.Desc2;
                    m1.DestinationURL    = r.DestinationURL;
                    m1.DisplayURL        = r.DisplayURL;
                    m1.Title             = r.Title;

                    foreach (Oltp.SegmentRow segment in segments)
                    {
                        bool is_adgroupcreative_segment = ((Auxilary.SegmentAssociationFlags)segment.Association).HasFlag(Auxilary.SegmentAssociationFlags.AdgroupCreative);
                        if (is_adgroupcreative_segment)
                        {
                            Oltp.SegmentValueDataTable segment_values = client.Service.SegmentValue_Get(acc_id, segment.SegmentID);
                            long value;
                            switch (segment.SegmentID)
                            {
                            case 1: value = r.Segment1; break;

                            case 2: value = r.Segment2; break;

                            case 3: value = r.Segment3; break;

                            case 4: value = r.Segment4; break;

                            case 5: value = r.Segment5; break;

                            case 999: value = r.PageGK; break;

                            default: value = r.Segment1; break;
                            }
                            m1.Segments.Add(new Models.SegmentRowModel()
                            {
                                SegmentRow = segment, Values = segment_values.ToList(), SelectedValue = value
                            });
                        }
                    }

                    m.Creatives.Add(m1);
                }
            }


            return(PartialView("AdgroupDetails", m));
        }
コード例 #22
0
        public ActionResult EditMultipleCampaign(string campaignsGK, FormCollection coll)
        {
            Oltp.CampaignDataTable campaigns;
            List <long>            CampaingsGK = campaignsGK.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"));
                }

                campaigns = client.Service.Campaign_GetIndividualCampaigns(CampaingsGK.ToArray());
                foreach (string key in coll.Keys)
                {
                    if (key.Contains("campaignSegmentValueEdit_"))
                    {
                        if (coll[key] == "1")
                        {
                            string segment_id   = key.Split('_')[1];
                            int    segmentID    = int.Parse(segment_id);
                            int    segmentValue = int.Parse(coll["campaignSegmentValue_" + segment_id]);
                            if (segmentValue != -100)
                            {
                                switch (segmentID)
                                {
                                case 1: campaigns.ToList().ForEach(x => x.Segment1 = segmentValue); break;

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

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

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

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

                                default: break;
                                }
                            }
                        }
                    }
                }

                client.Service.Campaign_Save(campaigns, false);

                double?target1, target2;
                if (coll["Target1"] == null || coll["Target1"].Equals(""))
                {
                    target1 = null;
                }
                else
                {
                    target1 = double.Parse(coll["Target1"]);
                }

                if (coll["Target2"] == null || coll["Target2"].Equals(""))
                {
                    target2 = null;
                }
                else
                {
                    target2 = double.Parse(coll["Target2"]);
                }

                bool editTarget1 = coll["EditTarget1"] == "1";
                bool editTarget2 = coll["EditTarget2"] == "1";

                if (editTarget1 || editTarget1)
                {
                    DataTable      t            = client.Service.CampaignTargets_Get(acc_id, null);
                    List <DataRow> RowsToRemove = new List <DataRow>();
                    foreach (DataRow r in t.Rows)
                    {
                        if (!CampaingsGK.Contains((long)(int)r["CampaignGK"]))
                        {
                            RowsToRemove.Add(r);
                        }
                        else
                        {
                            if (editTarget1)
                            {
                                if (target1 != null)
                                {
                                    r["CPA_new_users"] = target1;
                                }
                                else
                                {
                                    r["CPA_new_users"] = DBNull.Value;
                                }
                            }
                            if (editTarget2)
                            {
                                if (target2 != null)
                                {
                                    r["CPA_new_activations"] = target2;
                                }
                                else
                                {
                                    r["CPA_new_activations"] = DBNull.Value;
                                }
                            }
                        }
                    }
                    RowsToRemove.ForEach(x => t.Rows.Remove(x));

                    List <DataRow> RowsToAdd = new List <DataRow>();
                    foreach (Oltp.CampaignRow c in campaigns)
                    {
                        bool f = false;
                        foreach (DataRow r in t.Rows)
                        {
                            if ((long)(int)r["CampaignGK"] == c.GK)
                            {
                                f = true;
                            }
                        }

                        if (!f)
                        {
                            DataRow r = t.NewRow();
                            r["CampaignGK"] = c.GK;
                            r["AdgroupGK"]  = -1;
                            if (editTarget1)
                            {
                                if (target1 != null)
                                {
                                    r["CPA_new_users"] = target1;
                                }
                                else
                                {
                                    r["CPA_new_users"] = DBNull.Value;
                                }
                            }
                            if (editTarget2)
                            {
                                if (target2 != null)
                                {
                                    r["CPA_new_activations"] = target2;
                                }
                                else
                                {
                                    r["CPA_new_activations"] = DBNull.Value;
                                }
                            }
                            RowsToAdd.Add(r);
                        }
                    }

                    RowsToAdd.ForEach(x => t.Rows.Add(x));

                    client.Service.CampaignTargets_Save(acc_id, t);
                }
            }

            return(Content("OK"));
        }
コード例 #23
0
        public ActionResult EditCampaign(long campaignGK, FormCollection coll)
        {
            Oltp.CampaignDataTable campaigns;
            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                campaigns = client.Service.Campaign_GetSingle(campaignGK);

                foreach (string key in coll.Keys)
                {
                    if (key.Contains("campaignSegmentValue_"))
                    {
                        string segment_id   = key.Split('_')[1];
                        int    segmentID    = int.Parse(segment_id);
                        int    segmentValue = int.Parse(coll[key]);
                        switch (segmentID)
                        {
                        case 1: campaigns[0].Segment1 = segmentValue; break;

                        case 2: campaigns[0].Segment2 = segmentValue; break;

                        case 3: campaigns[0].Segment3 = segmentValue; break;

                        case 4: campaigns[0].Segment4 = segmentValue; break;

                        case 5: campaigns[0].Segment5 = segmentValue; break;

                        default: break;
                        }
                    }
                }

                client.Service.Campaign_Save(campaigns, false);

                double?target1, target2;
                if (coll["Target1"].Equals(""))
                {
                    target1 = null;
                }
                else
                {
                    target1 = double.Parse(coll["Target1"]);
                }

                if (coll["Target2"].Equals(""))
                {
                    target2 = null;
                }
                else
                {
                    target2 = double.Parse(coll["Target2"]);
                }

                DataTable t = client.Service.CampaignTargets_Get(acc_id, campaignGK);
                DataRow   r;

                if (t.Rows.Count > 0)
                {
                    r = t.Rows[0];
                }
                else
                {
                    r = t.NewRow();
                }

                r["CampaignGK"] = campaignGK;
                r["AdgroupGK"]  = -1;
                if (target1 == null)
                {
                    r["CPA_new_users"] = DBNull.Value;
                }
                else
                {
                    r["CPA_new_users"] = target1;
                }

                if (target2 == null)
                {
                    r["CPA_new_activations"] = DBNull.Value;
                }
                else
                {
                    r["CPA_new_activations"] = target2;
                }

                if (t.Rows.Count > 0 && target1 == null && target2 == null)
                {
                    r.Delete();
                }
                else if (t.Rows.Count == 0 && (target1 != null || target2 != null))
                {
                    t.Rows.Add(r);
                }

                client.Service.CampaignTargets_Save(acc_id, t);
            }

            return(Content("OK"));
        }
コード例 #24
0
        public ActionResult SaveTargets(FormCollection coll)
        {
            using (var client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                string a1 = coll["campaignsGK"];
                Dictionary <long, long> campaignsGK = a1.Split(',').Select(x => long.Parse(x)).ToDictionary(d => d, d => d);
                DataTable targetsTable = client.Service.CampaignTargets_Get(acc_id, null);

                List <DataRow> RowsToRemove = new List <DataRow>();
                foreach (DataRow r in targetsTable.Rows)
                {
                    long gk = long.Parse(r["CampaignGK"].ToString());
                    if (!campaignsGK.ContainsKey(gk))
                    {
                        RowsToRemove.Add(r);
                    }
                }
                RowsToRemove.ForEach(x => targetsTable.Rows.Remove(x));

                List <DataRow> RowsToAdd = new List <DataRow>();
                foreach (long gk in campaignsGK.Keys)
                {
                    bool f = false;
                    foreach (DataRow r in targetsTable.Rows)
                    {
                        if (long.Parse(r["CampaignGK"].ToString()) == gk)
                        {
                            f = true;
                        }
                    }

                    if (!f)
                    {
                        DataRow r = targetsTable.NewRow();
                        r["CampaignGK"] = gk;
                        r["AdgroupGK"]  = -1;
                        RowsToAdd.Add(r);
                    }
                }

                RowsToAdd.ForEach(x => targetsTable.Rows.Add(x));

                foreach (DataRow r in targetsTable.Rows)
                {
                    long   gk = long.Parse(r["CampaignGK"].ToString());
                    double?target1, target2;

                    if (coll["campaigntarget_" + gk + "_CPA1"].Equals(""))
                    {
                        target1 = null;
                    }
                    else
                    {
                        target1 = double.Parse(coll["campaigntarget_" + gk + "_CPA1"]);
                    }

                    if (coll["campaigntarget_" + gk + "_CPA2"].Equals(""))
                    {
                        target2 = null;
                    }
                    else
                    {
                        target2 = double.Parse(coll["campaigntarget_" + gk + "_CPA2"]);
                    }

                    if (target1 == null)
                    {
                        r["CPA_new_users"] = DBNull.Value;
                    }
                    else
                    {
                        r["CPA_new_users"] = target1;
                    }

                    if (target2 == null)
                    {
                        r["CPA_new_activations"] = DBNull.Value;
                    }
                    else
                    {
                        r["CPA_new_activations"] = target2;
                    }
                }


                client.Service.CampaignTargets_Save(acc_id, targetsTable);
            }

            return(Content("OK"));
        }
        public ActionResult EditCreative(long creativeGK)
        {
            Models.CreativeModel m = new Models.CreativeModel();

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

                Oltp.CreativeRow creative = client.Service.Creative_GetSingle(creativeGK)[0];
                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));
        }