Ejemplo n.º 1
0
        // GET: api/cache/5
        public string Get(int id)
        {
            HttpContext oc = HttpContext.Current;

            if (id == 33197000)
            {
                IDictionaryEnumerator en = oc.Cache.GetEnumerator();

                //string strResult;
                while (en.MoveNext())
                {
                    cacheManager.RemoveFromCache(en.Key.ToString());
                }


                return("Cache removed");
            }
            else if (id == 791975)
            {
                var             x = SettingsCache.GetProvider(1003);
                int             y = SettingsCache.getGeoX(1005, "US", 1003);
                int             c = SettingsCache.getRealPageID(5010, 1003);
                int             d = SettingsCache.getPageByGEO(1000, 1005, "US");
                pixLandingPages f = SettingsCache.GetPage(5502);
                return("Cache populated ");
            }
            else
            {
                log.Fatal("Someone is trying to delete application cache with no proper key");
            }

            return("mmmmm");
        }
Ejemplo n.º 2
0
        protected void btnPopulate_Click(object sender, EventArgs e)
        {
            var x = SettingsCache.GetProvider(1003);
            int y = SettingsCache.getGeoX(1005, "US", 1003);
            int c = SettingsCache.getRealPageID(5010, 1003);
            // pixLandingPagesByGEO d = SettingsCache.GetPageByGEO(5011, "US");
            pixLandingPages f = SettingsCache.GetPage(5502);

            lblStatus.Text = "Done - " + System.DateTime.Today.ToLongTimeString();
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int             intPageId, number;
            string          pageid = Request["pageid"];
            pixLandingPages oPage;

            if (Int32.TryParse(pageid, out number))
            {
                intPageId = Convert.ToInt16(pageid);
                oPage     = SettingsCache.GetPage(intPageId);
                if (oPage != null)
                {
                    Response.Write(oPage.url);
                }
            }
            else
            {
                Response.Write("");
            }
        }
Ejemplo n.º 4
0
        // GET: api/m/5
        public string Get(int id)
        {
            string[] pagesList = SettingsCache.MAC_PAGES.Split(',');

            pixLandingPages macPage         = SettingsCache.GetPage(1005);
            string          currentPageName = macPage.url.Split('/')[4].Split('?')[0];

            //id = 6 will be used to get the new page and change in database
            //any other id will be used to get the curent page

            if (id == 6)
            {
                string macUrl = macPage.url;
                string newPageName;
                newPageName = currentPageName;
                string tmpPageName;
                //getting the new page name
                for (int i = 0; i < pagesList.Length - 1; i++)
                {
                    tmpPageName = pagesList[i].ToString();
                    if (tmpPageName.ToLower() == currentPageName)
                    {
                        newPageName = pagesList[i + 1].ToString();
                    }
                }

                if (!newPageName.Equals(currentPageName))
                {
                    macPage.url = macPage.url.Replace(currentPageName, newPageName);
                    var db = new PetaPoco.Database("myConnectionString");
                    db.Update(macPage);
                }

                return(macPage.url);
            }

            else
            {
                return(currentPageName);
            }
        }
Ejemplo n.º 5
0
        //[FromUri] NameValueCollection formData
        public HttpResponseMessage Get()
        {
            // initialize parameters
            string sParam1, sParam2, sParam3, fullurl, sRedirectURL, ERROR_PAGE_URL, ip_address, countryCode;

            sParam1        = sParam2 = sParam3 = fullurl = ip_address = countryCode = string.Empty;
            ERROR_PAGE_URL = SettingsCache.ERROR_PAGE_URL;
            string platform;

            Boolean isFatal = false;

            HttpResponseMessage response;

            Int32[] intProviderPageId;
            Int32   intProviderId, intPageId;

            //get url from request
            fullurl = Request.RequestUri.AbsoluteUri;
            pixProviders    tmpProvider;
            pixLandingPages tmpPage;

            //get providerid & pageid as array of int from url
            intProviderPageId = Pixel.Web.Models.pixHelpers.getProviderPageID(Request);
            platform          = Pixel.Web.Models.pixHelpers.RunningPlatform();


            if (intProviderPageId != null)
            {
                intProviderId = intProviderPageId[0];
                intPageId     = intProviderPageId[1];

                tmpProvider = SettingsCache.GetProvider(intProviderId);

                if (tmpProvider != null)
                {
                    //look in query string for the query string params names according to what was configured in database
                    sParam1 = Pixel.Web.Models.pixHelpers.GetQueryString(Request, tmpProvider.param1);
                    sParam2 = Pixel.Web.Models.pixHelpers.GetQueryString(Request, tmpProvider.param2);
                    sParam3 = Pixel.Web.Models.pixHelpers.GetQueryString(Request, tmpProvider.param3);
                }

                else
                {
                    log.Fatal("Could not find provider id: " + intProviderId.ToString() + " in: " + fullurl);
                    isFatal = true;
                }


                ip_address  = Pixel.Web.Models.pixHelpers.GetIPAddress();
                countryCode = Pixel.Web.Models.pixHelpers.GetLocationFromIPDB(ip_address);


                intPageId = SettingsCache.getRealPageID(intPageId, intProviderId);

                //see if we have a different page ID for that GEO
                intPageId = SettingsCache.getPageByGEO(intProviderId, intPageId, countryCode);

                tmpPage = SettingsCache.GetPage(intPageId);

                //

                //get page URL

                if (tmpPage != null)
                {
                    /*if ((platform.ToUpper()=="MAC") && (tmpPage.pcmac.ToUpper() =="PC")){
                     *  sRedirectURL = SettingsCache.GetPage(1005).url;
                     * }
                     * else{
                     *   sRedirectURL = tmpPage.url;
                     * }*/
                    sRedirectURL = tmpPage.url;
                }
                else
                {
                    sRedirectURL = ERROR_PAGE_URL;
                    log.Fatal("Could not find page id: " + intPageId.ToString() + " in  " + fullurl);
                    isFatal = true;
                }


                // log to database only good URL's

                if (!isFatal)
                {
                    //get new guid to send landing page
                    Guid   sGuid      = Guid.NewGuid();
                    string stringGuid = sGuid.ToString().Replace("-", "");

                    sRedirectURL = sRedirectURL.Replace("[UID]", stringGuid);

                    //build a request object with all data
                    var myRequest = new pixRequests();
                    myRequest.full_url    = fullurl;
                    myRequest.reqGuid     = sGuid;
                    myRequest.param1      = sParam1;
                    myRequest.param2      = sParam2;
                    myRequest.param3      = sParam3;
                    myRequest.providerid  = intProviderId;
                    myRequest.pageid      = intPageId;
                    myRequest.user_ip     = ip_address;
                    myRequest.redirect_to = sRedirectURL;
                    myRequest.platform    = platform;
                    myRequest.countryCode = countryCode;


                    try
                    {
                        //insert request to database
                        var db = new PetaPoco.Database("myConnectionString");
                        db.Insert(myRequest);
                        db.CloseSharedConnection();
                    }

                    catch (Exception e)
                    {
                        string tmp = " INSERT INTO [dbo].[Requests] ([reqGuid],[full_url],[param1],[user_ip],[redirect_to],[providerid],[pageid],[platform],[countryCode]) VALUES (";
                        tmp += " cast ('" + myRequest.reqGuid + "' as uniqueidentifier),'" + myRequest.full_url + "','" + myRequest.param1 + "'";
                        tmp += ",'" + myRequest.user_ip + "','" + myRequest.redirect_to + "'," + myRequest.providerid.ToString() + "," + myRequest.pageid.ToString();
                        tmp += ",'" + myRequest.platform + "','" + myRequest.countryCode + "')";

                        log.Fatal("failed with insert to database: " + fullurl + " /n" + tmp + " /n " + e.Message, e);


                        sRedirectURL = ERROR_PAGE_URL;
                        //throw e;
                    }
                } //  if (isFatal == false)
            }     //if (intProviderPageId != null)
            else
            {
                ip_address = Pixel.Web.Models.pixHelpers.GetIPAddress();

                log.Fatal("No Providerid or Pageid in Query string: " + fullurl + " , redirecting to error page. IP =  " + ip_address);
                sRedirectURL = ERROR_PAGE_URL;
            }

            // redirect to landing page with guid
            response = Request.CreateResponse();
            switch (SettingsCache.REDIRECT_TYPE)
            {
            case 1:
                response.StatusCode = HttpStatusCode.Moved;
                break;

            case 2:
                response.StatusCode = HttpStatusCode.Redirect;
                break;

            case 3:
                response.StatusCode = HttpStatusCode.RedirectKeepVerb;
                break;

            case 4:
                response.StatusCode = HttpStatusCode.RedirectMethod;
                break;
            }


            response.Headers.Location = new Uri(sRedirectURL);
            log.Info("Redirecting to landing page: " + sRedirectURL);
            return(response);
        }