public string FetchCustomer(string sessionID, string reference) { string value = string.Empty; SAAClientAPI.SetSessionContext(sessionID); Customer customer = CustomerFactory.Factory.Fetch(reference); value = "Ref=" + customer.Reference + ", name=" + customer.Name; return(value); }
/// <summary> /// Checks that site ID and company ID are set on the session /// Executed on all controllers with RequiresValidSiteAttribute /// </summary> /// <param name="filterContext">The ActionExecutingContext</param> public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); string returnurl = string.Empty; try { // Set the return URL to the request URL returnurl = filterContext.HttpContext.Request.Url.AbsolutePath; } catch { } HttpRequestBase request = filterContext.HttpContext.Request; try { // Check the site ID and Company ID are set on the session, // if not then redirect to the index page string sessionID = Startup.GetSessionID(); if (string.IsNullOrEmpty(sessionID)) { filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary( new { controller = "Sites", action = "Index", ReturnUrl = returnurl })); } else { // Use Session to configure SessionContextValues SAAClientAPI.SetSessionContext(sessionID); } } catch (Exception) { { // force re-logon //ContextStore.Reset(filterContext.HttpContext.Session); filterContext.Result = new System.Web.Mvc.HttpUnauthorizedResult(); } } }
public static void CloseSession(string sessionID) { SAAClientAPI.SetSessionContext(sessionID); SAAClientAPI.DisconnectCompany(); SAAClientAPI.Logoff(); }