コード例 #1
0
        public static async Task <Tuple <HttpStatusCode, string> > QuerySessionHistoryByXuidAsync(
            string scid,
            string templateName,
            long xuid,
            DateTime startAt,
            DateTime endAt,
            string continuationToken,
            string eToken)
        {
            string url = string.Format("{0}/serviceconfigs/{1}/sessiontemplates/{2}/query?take={3}", RequestRoot, scid, templateName, TakeSize);

            if (continuationToken != null)
            {
                url += string.Format("&continuationtoken={0}", continuationToken);
            }

            var postBody = new SessionHistoryQueryByXuidRequest
            {
                Xuid    = xuid.ToString(),
                StartAt = startAt,
                EndAt   = endAt
            };

            return(await SessionHistory.RunSessionHistoryRequestAsync(CreateSessionHistoryPostRequest(url, eToken, postBody.SerializeToJsonByteArray())));
        }
コード例 #2
0
        public static async Task <Tuple <HttpStatusCode, string> > QuerySessionHistoryBranches(
            string scid,
            string templateName,
            string sessionName,
            string eToken)
        {
            string url = string.Format("{0}/serviceconfigs/{1}/sessiontemplates/{2}/sessions/{3}/branches", RequestRoot, scid, templateName, sessionName);

            WebRequest webRequest = CreateSessionHistoryGetRequest(url, eToken);

            return(await SessionHistory.RunSessionHistoryRequestAsync(webRequest));
        }
コード例 #3
0
        public static async Task <Tuple <HttpStatusCode, string> > GetSessionHistoryDocumentChangeAsync(
            string scid,
            string templateName,
            string sessionName,
            string branch,
            long changeNumber,
            string eToken)
        {
            string url = string.Format("{0}/serviceconfigs/{1}/sessiontemplates/{2}/sessions/{3}/branches/{4}/changes/{5}", RequestRoot, scid, templateName, sessionName, branch, changeNumber);

            WebRequest webRequest = CreateSessionHistoryGetRequest(url, eToken);

            return(await SessionHistory.RunSessionHistoryRequestAsync(webRequest));
        }
コード例 #4
0
        public static async Task <Tuple <HttpStatusCode, string> > QuerySessionHistoryByCorrelationIdAsync(
            string scid,
            string templateName,
            string correlationId,
            string eToken)
        {
            string url = string.Format("{0}/serviceconfigs/{1}/sessiontemplates/{2}/query", RequestRoot, scid, templateName);

            var postBody = new SessionHistoryQueryByCorrelationIdRequest
            {
                CorrelationId = correlationId,
            };

            return(await SessionHistory.RunSessionHistoryRequestAsync(CreateSessionHistoryPostRequest(url, eToken, postBody.SerializeToJsonByteArray())));
        }
コード例 #5
0
        private async Task <Tuple <string, string> > QueryForDocSessionHistoryChangeAsync(string sessionName, string branch, long changeNumber)
        {
            string snapshot = null;
            string errorMsg = null;

            if (changeNumber == SessionHistory.MaxChangeValue)
            {
                return(new Tuple <string, string>(null, null)); // there is nothing to get, so don't bother trying
            }

            string hashKey = this.snapshotCache.GetHashString(
                sessionName,
                branch,
                changeNumber);

            if (!this.snapshotCache.TryGetSnapshot(hashKey, out snapshot))
            {
                string eToken = await ToolAuthentication.GetDevTokenSilentlyAsync(this.tbScid.Text, this.tbSandbox.Text);

                this.lblExplanation.Text = string.Format("Downloading session snapshot #{0}", changeNumber);

                var response = await SessionHistory.GetSessionHistoryDocumentChangeAsync(
                    this.tbScid.Text,
                    this.tbTemplateName.Text,
                    sessionName,
                    branch,
                    changeNumber,
                    eToken);

                if (response.Item1 == HttpStatusCode.OK)
                {
                    snapshot = response.Item2;
                    this.snapshotCache.AddSnapshotToCache(hashKey, response.Item2);
                }
                else if (response.Item1 != HttpStatusCode.NoContent)
                {
                    errorMsg = response.Item2;
                }
            }

            return(new Tuple <string, string>(snapshot, errorMsg));
        }
コード例 #6
0
        private async Task <Tuple <SessionHistoryDocumentResponse, string> > QueryForDocSessionHistoryAsync(string eToken, string sessionName, string branch)
        {
            SessionHistoryDocumentResponse queryResponse = null;
            string errMsg = null;

            var response = await SessionHistory.GetSessionHistoryDocumentDataAsync(
                this.tbScid.Text,
                this.tbTemplateName.Text,
                sessionName,
                branch,
                eToken);

            if (response.Item1 != System.Net.HttpStatusCode.OK)
            {
                errMsg = response.Item2;
            }
            else
            {
                queryResponse = new SessionHistoryDocumentResponse(response.Item2);
            }

            return(new Tuple <SessionHistoryDocumentResponse, string>(queryResponse, errMsg));
        }
コード例 #7
0
        private async Task <Tuple <HttpStatusCode, string> > QueryForHistoricalSessionDocuments(string eToken, QueryBundle queryBundle, string continuationToken)
        {
            if (continuationToken == null)
            {
                this.InitViews();
                this.listView1.Items.Clear();
            }

            Tuple <System.Net.HttpStatusCode, string> response = null;

            switch (this.cmbQueryType.SelectedIndex)
            {
            case (int)QueryBy.SessionName:
            {
                response = await SessionHistory.QuerySessionHistoryBranches(
                    queryBundle.Scid,
                    queryBundle.TemplateName,
                    queryBundle.QueryKey,
                    eToken);
            }

            break;

            case (int)QueryBy.GamerTag:
            {
                response = await SessionHistory.QuerySessionHistoryByGamertagAsync(
                    queryBundle.Scid,
                    queryBundle.TemplateName,
                    queryBundle.QueryKey,
                    queryBundle.QueryStartDate,
                    queryBundle.QueryEndDate,
                    continuationToken,
                    eToken);
            }

            break;

            case (int)QueryBy.GamerXuid:
            {
                response = await SessionHistory.QuerySessionHistoryByXuidAsync(
                    queryBundle.Scid,
                    queryBundle.TemplateName,
                    long.Parse(queryBundle.QueryKey),
                    queryBundle.QueryStartDate,
                    queryBundle.QueryEndDate,
                    continuationToken,
                    eToken);
            }

            break;

            case (int)QueryBy.CorrelationId:
            {
                response = await SessionHistory.QuerySessionHistoryByCorrelationIdAsync(
                    queryBundle.Scid,
                    queryBundle.TemplateName,
                    this.tbQueryKey.Text,
                    eToken);
            }

            break;
            }

            if (response.Item1 != HttpStatusCode.OK)
            {
                return(response);
            }

            SessionHistoryQueryResponse queryResponse = new SessionHistoryQueryResponse(response.Item2);

            foreach (var item in queryResponse.Results)
            {
                string[] arr = new string[QueryResultColumnCount]
                {
                    item.SessionName,
                    item.Branch,
                    item.Changes.ToString(),
                    this.displayDateTimesAsUTCToolStripMenuItem.Checked ? item.LastModified.ToString() : item.LastModified.ToLocalTime().ToString(),
                    item.IsExpired.ToString(),
                    item.ActivityId
                };

                ListViewItem lvi = new ListViewItem(arr);
                this.listView1.Items.Add(lvi);
            }

            this.lblDocCount.Text  = string.Format("{0} session{1}", this.listView1.Items.Count, (this.listView1.Items.Count != 1) ? "s" : string.Empty);
            this.lblDocCount.Text += "      [" + SaveInstructions + "]";

            if (this.queryCancelled)
            {
                return(new Tuple <HttpStatusCode, string>(HttpStatusCode.OK, null)); // ignore continuation token if user cancelled the query
            }
            else
            {
                return(new Tuple <HttpStatusCode, string>(HttpStatusCode.OK, queryResponse.ContinuationToken));
            }
        }