Exemplo n.º 1
0
        internal void renewSession()
        {
            RenewSessionRequest postBody = new RenewSessionRequest()
            {
                oldSessionToken = this.sessionToken,
                requestType     = "RENEW"
            };

            SFRestRequest renewSessionRequest = new SFRestRequest
            {
                jsonBody = postBody,
                uri      = BuildUri(SF_TOKEN_REQUEST_PATH,
                                    new Dictionary <string, string> {
                    { SF_QUERY_REQUEST_ID, Guid.NewGuid().ToString() }
                }),
                authorizationToken   = string.Format(SF_AUTHORIZATION_SNOWFLAKE_FMT, masterToken),
                sfRestRequestTimeout = Timeout.InfiniteTimeSpan
            };

            var response = restRequest.Post <RenewSessionResponse>(renewSessionRequest);

            if (!response.success)
            {
                SnowflakeDbException e = new SnowflakeDbException("",
                                                                  response.code, response.message, "");
                logger.Error("Renew session failed", e);
                throw e;
            }
            else
            {
                sessionToken = response.data.sessionToken;
            }
        }
Exemplo n.º 2
0
        internal void renewSession()
        {
            UriBuilder uriBuilder = new UriBuilder();

            uriBuilder.Scheme = properties[SFSessionProperty.SCHEME];
            uriBuilder.Host   = properties[SFSessionProperty.HOST];
            uriBuilder.Port   = Int32.Parse(properties[SFSessionProperty.PORT]);
            uriBuilder.Path   = SF_TOKEN_REQUEST_PATH;

            var queryString = HttpUtility.ParseQueryString(string.Empty);

            queryString[SF_QUERY_REQUEST_ID] = Guid.NewGuid().ToString();
            uriBuilder.Query = queryString.ToString();

            RenewSessionRequest postBody = new RenewSessionRequest()
            {
                oldSessionToken = this.sessionToken,
                requestType     = "RENEW"
            };

            SFRestRequest renewSessionRequest = new SFRestRequest();

            renewSessionRequest.jsonBody             = postBody;
            renewSessionRequest.uri                  = uriBuilder.Uri;
            renewSessionRequest.authorizationToken   = String.Format(SF_AUTHORIZATION_SNOWFLAKE_FMT, masterToken);
            renewSessionRequest.sfRestRequestTimeout = -1;

            JObject          response             = restRequest.post(renewSessionRequest);
            NullDataResponse sessionRenewResponse = response.ToObject <NullDataResponse>();

            if (!sessionRenewResponse.success)
            {
                SnowflakeDbException e = new SnowflakeDbException("",
                                                                  sessionRenewResponse.code, sessionRenewResponse.message, "");
                logger.Error("Renew session failed", e);
                throw e;
            }
        }