Exemplo n.º 1
0
        static void Main(string[] args)
        {
            using (var client = new OltpLogicClient(null))
            {
                // To be retrieved from iFrame URL parameter.
                // Validation is currently disabled in MorWebOTLP database
                //string sessionID = null;

                // Logging in is required otherwise all other service operations will fail (comment out these lines to see how)
                //Oltp.UserDataTable user = client.Service.User_LoginBySessionID(sessionID);
                Console.WriteLine("Logged in as {0}", client.CurrentUser.Name);

                // Get all campaigns for every account
                Oltp.AccountDataTable accounts = client.Service.Account_Get();
                foreach (Oltp.AccountRow account in accounts.Rows)
                {
                    Console.WriteLine();
                    Console.WriteLine("Campaigns for account {0} - {1}:", account.ID, account.Name);
                    Console.WriteLine("--------------------------------------------");
                    Oltp.CampaignDataTable campaigns = client.Service.Campaign_Get(account.ID, null, null, null, false);
                    foreach (Oltp.CampaignRow campaign in campaigns.Rows)
                    {
                        Console.WriteLine("{0} - {1}", campaign.GK, campaign.Name);
                    }
                }

                Console.ReadLine();
            }
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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;
            });
        }
        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.º 5
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));
        }