Ejemplo n.º 1
0
        public AudienceDocument GetAudienceById(string IdAudience)
        {
            AudienceManager  repository = new AudienceManager();
            AudienceDocument audience   = repository.GetAudienceById(IdAudience);

            return(audience);
        }
Ejemplo n.º 2
0
        public FileStreamResult CreateScriptFile(Guid IdAudience)
        {
            AudienceManager  repository = new AudienceManager();
            AudienceDocument _audience  = repository.GetAudienceById(IdAudience.ToString());

            if (_audience != null)
            {
                string datafile = CreateScriptGtm(IdAudience);

                if (datafile.Length > 0)
                {
                    var byteArray = System.Text.Encoding.ASCII.GetBytes(datafile);
                    var stream    = new System.IO.MemoryStream(byteArray);

                    System.Web.Mvc.FileStreamResult _sfile = new System.Web.Mvc.FileStreamResult(stream, "text/plain");
                    _sfile.FileDownloadName = "scriptGTM.txt";

                    return(_sfile);
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public ActionResult CreateChannel([FromBody] string audienceId)
        {
            audienceManager.audienceId = audienceId;
            AudienceDocument audience = audienceManager.GetAudienceById(audienceManager.audienceId);

            TempData["tdIdAudience"]   = audienceManager.audienceId;
            ViewBag.ImageSrcPreview    = audience.ImageUrl;
            ViewBag.descriptionPreview = audience.Description;
            ViewBag.site = audience.WebSiteUrl;
            AudienceChannelViewModel model = new AudienceChannelViewModel();

            if (!string.IsNullOrEmpty(audienceId))
            {
                TempData["tdIdAudience"] = audienceId;
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult VerifyWebSite(string audienceId)
        {
            //cargar el script y mostralo en la vista
            AudienceDocument        audience = new AudienceDocument();
            VerifyAudienceViewModel model    = new VerifyAudienceViewModel();

            model.gtm.Script       = siteViewModelManager.CreateScriptGtm(new Guid(audienceId));
            model.gtm.ScriptByRows = siteViewModelManager.CreateScriptGtmByRows(new Guid(audienceId));

            if (audienceId != null)
            {
                AudienceDocument ad = audienceManager.GetAudienceById(audienceId);
                ViewBag.site             = ad.WebSiteUrl;
                TempData["tdIdAudience"] = audienceId;
                audience       = ad;
                model.audience = audience;
            }

            return(View(model));
        }
Ejemplo n.º 5
0
        public bool SiteWithTxtVerified(Guid IdAudience)
        {
            bool             result     = false;
            AudienceManager  repository = new AudienceManager();
            AudienceDocument audience   = repository.GetAudienceById(IdAudience.ToString());

            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(audience.WebSiteUrl + "/kindads.txt");
            request.Method = "GET";

            try
            {
                System.Net.WebResponse webResponse = request.GetResponse();
                using (System.IO.Stream webStream = webResponse.GetResponseStream())
                {
                    if (webStream != null)
                    {
                        using (System.IO.StreamReader responseReader = new System.IO.StreamReader(webStream))
                        {
                            var _response = responseReader.ReadToEnd();
                            if (_response != null)
                            {
                                if (_response.Trim() == audience.VerificationString.Trim())
                                {
                                    //Verify Site
                                    audience.Verified = true;
                                    repository.UpdateAudience(audience);
                                    result = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                //Do nothing
            }
            return(result);
        }