コード例 #1
0
 private bool GenerateBIPToken()
 {
     try
     {
         using (BSW.APIToken.Token t = new BSW.APIToken.Token())
         {
             var result = t.GenerateToken("1", "Landsea-XMLAPIService", 10, "Landsea - XMLAPIService", "");
             if (result.Successful)
             {
                 bipToken = result.UserToken;
             }
             else
             {
                 bipToken = string.Empty;
             }
         }
     }
     catch (Exception ex)
     {
         ProcessLogs.logFilePath = logFilePath;
         ProcessLogs.WriteToLogFile("Generating BIP Token:" + ExceptionDetail.GetExceptionFullMessage(ex));
         return(false);
     }
     return(true);
 }
コード例 #2
0
        private void btnGetXML_Click(object sender, EventArgs e)
        {
            try
            {
                string token = string.Empty;
                using (BSW.APIToken.Token t = new BSW.APIToken.Token())
                {
                    var tRes = t.GenerateToken("d3w4ld123", "XMLAPI", 20, "DEWALD", "");
                    if (tRes.Successful)
                    {
                        token = tRes.UserToken;
                    }
                }

                System.Net.ServicePointManager.ServerCertificateValidationCallback += (senderClient, certificate, chain, sslPolicyErrors) => true;
                using (HttpClient client = new HttpClient(new HttpClientHandler {
                    ClientCertificateOptions = ClientCertificateOption.Automatic
                }))
                {
                    try
                    {
                        client.BaseAddress = new Uri("http://localhost:51203/");
                        client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("FlowAsk", token);

                        var res = client.GetAsync("api/XMLDocuments/GetXMLDocs").Result;

                        if (res.IsSuccessStatusCode)
                        {
                            //we convert return the results as is - that we get from calling TLCgo
                            var result = res.Content.ReadAsAsync <RequestReponse>().Result;
                            if (result.Success)
                            {
                                MessageBox.Show(result.Data.ToString(), "Success");
                            }
                            else
                            {
                                MessageBox.Show(result.Message, result.MessageDetail);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Message Failed");
                        }
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("Message Failed", exp.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Message Failed", ex.Message);
            }
        }