コード例 #1
0
        public async Task EditWebhook(HttpSessionStateBase currentSession, string Id)
        {
            string        accessToken   = UserSession.accessToken(currentSession);
            HttpGetObject objHttpObject = new HttpGetObject();

            objHttpObject.accessToken = accessToken;
            objHttpObject.endPoint    = PatchWebhookEndPoint;
            objHttpObject.id          = Id; // webhook Id
            objWebhookPatch.id        = 0;
            APIClient           apiclient = new APIClient();
            HttpResponseMessage dsResp    = await apiclient.postAsync(objHttpObject, apiclient.convertToContent(objWebhookPatch), true);

            if (!dsResp.IsSuccessStatusCode)
            {
                string val = await dsResp.Content.ReadAsStringAsync();

                ResponseErrorView objResponseErrorView = JsonConvert.DeserializeObject <ResponseErrorView>(val);
                if (objResponseErrorView.errorCount != 0)
                {
                    errormsg = objResponseErrorView.responseErrors[0].Message;
                }
                else
                {
                    ResponseErrormessage objResponseErrormessage = JsonConvert.DeserializeObject <ResponseErrormessage>(val);
                    errormsg = objResponseErrormessage.message;
                }
                errorOccurred = true;
            }
        }
コード例 #2
0
        public async Task AddWebhook(HttpSessionStateBase currentSession, string DataSetIndexExpID)
        {
            string accessToken = UserSession.accessToken(currentSession);

            HttpGetObject objHttpObject = new HttpGetObject();

            objHttpObject.accessToken        = accessToken;
            objHttpObject.endPoint           = PostWebhookEndPoint;
            objHttpObject.id                 = DataSetIndexExpID;
            objwebhookPost.DataSetIndexExpID = Convert.ToInt32(DataSetIndexExpID);
            APIClient           apiclient = new APIClient();
            HttpResponseMessage dsResp    = await apiclient.postAsync(objHttpObject, apiclient.convertToContent(objwebhookPost));

            if (!dsResp.IsSuccessStatusCode)
            {
                string val = await dsResp.Content.ReadAsStringAsync();

                ResponseErrorView objResponseErrorView = JsonConvert.DeserializeObject <ResponseErrorView>(val);
                if (objResponseErrorView.errorCount != 0)
                {
                    errormsg = objResponseErrorView.responseErrors[0].Message;
                }
                else
                {
                    ResponseErrormessage objResponseErrormessage = JsonConvert.DeserializeObject <ResponseErrormessage>(val);
                    errormsg = objResponseErrormessage.message;
                }
                errorOccurred = true;
            }
        }
コード例 #3
0
ファイル: SearchViewModel.cs プロジェクト: tscj3490/DataSense
        public async Task PostSearch(HttpSessionStateBase currentsession, int dataSetIndexId)
        {
            string        accessToken   = UserSession.accessToken(currentsession);
            HttpGetObject objHttpObject = new HttpGetObject();

            objHttpObject.accessToken = accessToken;
            searchPost.dataSetIndexId = dataSetIndexId;

            objHttpObject.endPoint = endPointSearchDataSet;
            APIClient           apiclient    = new APIClient();
            HttpResponseMessage dsSearchResp = await apiclient.postAsync(objHttpObject, apiclient.convertToContent(searchPost), false, nodeUrl);

            if (!dsSearchResp.IsSuccessStatusCode)
            {
                string val = await dsSearchResp.Content.ReadAsStringAsync();

                ResponseErrorView objResponseErrorView = JsonConvert.DeserializeObject <ResponseErrorView>(val);
                if (objResponseErrorView.errorCount != 0)
                {
                    errormsg = objResponseErrorView.responseErrors[0].Message;
                }
                else
                {
                    ResponseErrormessage objResponseErrormessage = JsonConvert.DeserializeObject <ResponseErrormessage>(val);
                    errormsg = objResponseErrormessage.message;
                }
                if (dsSearchResp.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    errormsg = "No matches were found";
                }
                errorOccurred = true;
            }
            else
            {
                string val = await dsSearchResp.Content.ReadAsStringAsync();

                searchResults = JsonConvert.DeserializeObject <List <MatchPairView> >(val);
                searchResults = searchResults.OrderByDescending(t => t.JaccardIndex).ToList();

                IsNext = false;
                IsPrev = false;
                if (searchPost.pageNo != 1)
                {
                    IsPrev = true;
                }
                searchPost.pageNo = searchPost.pageNo + 1;

                HttpResponseMessage dsSearchResp1 = await apiclient.postAsync(objHttpObject, apiclient.convertToContent(searchPost), false, nodeUrl);

                if (dsSearchResp1.IsSuccessStatusCode)
                {
                    string val1 = await dsSearchResp1.Content.ReadAsStringAsync();

                    List <MatchPairView> searchResults1 = JsonConvert.DeserializeObject <List <MatchPairView> >(val1);
                    if (searchResults1.Count > 0)
                    {
                        IsNext = true;
                    }
                }
            }

            searchPost.pageNo = searchPost.pageNo - 1;
        }