Exemplo n.º 1
0
        public static void CheckPartnerSession(Controller controller, IPartnerParam param)
        {
            HttpCookie cookie;

            if (param.PartnerSessionID != null)
            {
                cookie = new HttpCookie("partnerSessionID")
                {
                    Path    = controller.Url.Content("~"),
                    Expires = DateTime.Now.AddDays(1.0),
                    Value   = param.PartnerSessionID
                };
                controller.HttpContext.Response.Cookies.Set(cookie);
            }
            else if (controller.HttpContext.Request["psid"] != null)
            {
                cookie = new HttpCookie("partnerSessionID")
                {
                    Path    = controller.Url.Content("~"),
                    Expires = DateTime.Now.AddDays(-1.0)
                };
                controller.HttpContext.Response.Cookies.Set(cookie);
            }
            else if (param.PartnerAlias == null)
            {
                cookie = controller.HttpContext.Request.Cookies["partnerSessionID"];
                if (cookie != null)
                {
                    param.psid = cookie.Value;
                }
            }
        }
 public static void CheckPartnerSession(Controller controller, IPartnerParam param)
 {
     HttpCookie cookie;
     if (param.PartnerSessionID != null)
     {
         cookie = new HttpCookie("partnerSessionID") {
             Path = controller.Url.Content("~"),
             Expires = DateTime.Now.AddDays(1.0),
             Value = param.PartnerSessionID
         };
         controller.HttpContext.Response.Cookies.Set(cookie);
     }
     else if (controller.HttpContext.Request["psid"] != null)
     {
         cookie = new HttpCookie("partnerSessionID") {
             Path = controller.Url.Content("~"),
             Expires = DateTime.Now.AddDays(-1.0)
         };
         controller.HttpContext.Response.Cookies.Set(cookie);
     }
     else if (param.PartnerAlias == null)
     {
         cookie = controller.HttpContext.Request.Cookies["partnerSessionID"];
         if (cookie != null)
         {
             param.psid = cookie.Value;
         }
     }
 }
Exemplo n.º 3
0
        public static WebPartner GetPartner(IPartnerParam param)
        {
            WebPartner partner;

            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (!string.IsNullOrEmpty(param.PartnerSessionID))
            {
                partner = FindPartnerByOnlineSID(param.PartnerSessionID);
                if (partner == null)
                {
                    throw new ExceptionWithCode(0xd5, string.Format("invalid sid '{0}'", param.PartnerSessionID));
                }
                return(partner);
            }
            if (!string.IsNullOrEmpty(param.PartnerAlias))
            {
                partner = FindPartnerForPublicWeb(param.PartnerAlias);
                if (partner == null)
                {
                    throw new ArgumentExceptionWithCode(0xd4, string.Format("invalid partner alias '{0}'", param.PartnerAlias));
                }
                return(partner);
            }
            string excursionDefaultPartnerAlias = Settings.ExcursionDefaultPartnerAlias;

            if (string.IsNullOrEmpty(excursionDefaultPartnerAlias))
            {
                throw new ExceptionWithCode(210, "partner authentication required: use 'pa' or 'psid' params");
            }
            partner = FindPartnerForPublicWeb(excursionDefaultPartnerAlias);
            if (partner == null)
            {
                throw new ArgumentExceptionWithCode(0xd3, string.Format("invalid default partner alias '{0}'", excursionDefaultPartnerAlias));
            }
            return(partner);
        }
 public static WebPartner GetPartner(IPartnerParam param)
 {
     WebPartner partner;
     if (param == null)
     {
         throw new ArgumentNullException("param");
     }
     if (!string.IsNullOrEmpty(param.PartnerSessionID))
     {
         partner = FindPartnerByOnlineSID(param.PartnerSessionID);
         if (partner == null)
         {
             throw new ExceptionWithCode(0xd5, string.Format("invalid sid '{0}'", param.PartnerSessionID));
         }
         return partner;
     }
     if (!string.IsNullOrEmpty(param.PartnerAlias))
     {
         partner = FindPartnerForPublicWeb(param.PartnerAlias);
         if (partner == null)
         {
             throw new ArgumentExceptionWithCode(0xd4, string.Format("invalid partner alias '{0}'", param.PartnerAlias));
         }
         return partner;
     }
     string excursionDefaultPartnerAlias = Settings.ExcursionDefaultPartnerAlias;
     if (string.IsNullOrEmpty(excursionDefaultPartnerAlias))
     {
         throw new ExceptionWithCode(210, "partner authentication required: use 'pa' or 'psid' params");
     }
     partner = FindPartnerForPublicWeb(excursionDefaultPartnerAlias);
     if (partner == null)
     {
         throw new ArgumentExceptionWithCode(0xd3, string.Format("invalid default partner alias '{0}'", excursionDefaultPartnerAlias));
     }
     return partner;
 }