public void RegisterSession(ISessionData sessionData) { var data = new RegisterSessionRequest { Session = sessionData.ToSessionData() }; ExecuteCommand(data, "session", "register"); }
public void RegisterSession(ISessionData sessionData) { var data = new RegisterSessionRequest { Session = sessionData.ToSessionData() }; var jsonFormatter = new JsonMediaTypeFormatter(); var content = new ObjectContent <RegisterSessionRequest>(data, jsonFormatter); ExecuteCommand(content, "session", "register"); }
private RegisterSessionRequest GetData(object request) { var reqiestString = request.ToString(); var serializer = new JavaScriptSerializer(); RegisterSessionRequest data = null; try { data = serializer.Deserialize <RegisterSessionRequest>(reqiestString); } catch (Exception exception) { exception.AddData("Request", request.ToString()); _issueBusiness.RegisterIssue(exception, IssueLevel.Warning); var dataD = serializer.DeserializeObject(reqiestString) as dynamic; var sessionD = dataD["Session"]; data = new RegisterSessionRequest { Session = DynamicExtensions.ToSession(sessionD) }; } return(data); }
public void RegisterSession(RegisterSessionRequest request) { if (request == null) { throw new ArgumentNullException("request", "No request object provided."); } if (request.Session == null) { throw new ArgumentException("No session object in request was provided. Need object '{ \"Session\":{...} }' in root."); } if (request.Session.SessionGuid == Guid.Empty) { throw new ArgumentException("No valid session guid provided."); } if (string.IsNullOrEmpty(request.Session.ClientToken)) { throw new ArgumentException("No ClientToken provided."); } if (request.Session.Application == null) { throw new ArgumentException("No application object in request was provided. Need object '{ \"Application\":{...} }' in session."); } if (string.IsNullOrEmpty(request.Session.Application.Name)) { throw new ArgumentException("No name provided for application."); } if (request.Session.User == null) { throw new ArgumentException("No user object in request was provided. Need object '{ \"User\":{...} }' in session."); } if (request.Session.Machine == null) { throw new ArgumentException("No machine object in request was provided. Need object '{ \"Machine\":{...} }' in session."); } var callerIp = _membershipAgent.GetUserHostAddress(); var fingerprint = _applicationVersionBusiness.AssureApplicationFingerprint(request.Session.Application.Fingerprint, request.Session.Application.Version, request.Session.Application.SupportToolkitNameVersion, request.Session.Application.BuildTime, request.Session.Application.Name, request.Session.ClientToken); IApplication application; try { application = _initiativeBusiness.RegisterApplication((ClientToken)request.Session.ClientToken, request.Session.Application.Name, request.Session.Application.Fingerprint); } catch (FingerprintException) { throw new ArgumentException("No value for application fingerprint provided. A globally unique identifier should be provided, perhaps a machine sid or a hash of unique data that does not change."); } var applicationVersion = _applicationVersionBusiness.RegisterApplicationVersionUsage(fingerprint, application.Id, request.Session.Application.Version, request.Session.Application.SupportToolkitNameVersion, request.Session.Application.BuildTime, request.Session.Environment); if (applicationVersion.Ignore) { return; } try { _userBusiness.RegisterUser((Fingerprint)request.Session.User.Fingerprint, request.Session.User.UserName); } catch (FingerprintException) { throw new ArgumentException("No value for user fingerprint provided. A globally unique identifier should be provided, perhaps a username and domain or a hash of unique data that does not change."); } try { _machineBusiness.RegisterMachine((Fingerprint)request.Session.Machine.Fingerprint, request.Session.Machine.Name, request.Session.Machine.Data); } catch (FingerprintException) { throw new ArgumentException("No value for machine fingerprint provided. A globally unique identifier should be provided, perhaps a DeviceId, SID or a hash of unique data that does not change."); } RegisterSession(request.Session.ToSession(applicationVersion.Id, application.Id, DateTime.UtcNow, null, null, callerIp)); }