Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public ActionResult Index(int account, string session)
        {
            AppState.AccountID = account;
            AppState.SessionID = session == "" ? null : "";

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

            Models.CampaignListModel m = new Models.CampaignListModel();
            using (var client = new OltpLogicClient(session_id))
            {
                //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.Name, Status = m.Statuses[c.StatusID], ChannelName = m.Channels[c.ChannelID] });
            }

            return(View(m));
        }