질문이 있으십니까?

기본 컨텐츠 및 사용자가 직접 참여하여 만들어진 다양한 내용을 검색합니다.

VB 닷넷 샘플코드

workflow.create.document 호출부문

using RestSharp;

namespace WebAPI.Controllers {
  [ApiController]
  [Route("[controller]")]
  public class GwController : ControllerBase {
    [HttpGet("/api/gw/gwdocument")]
    public async Task<IActionResult> GwDocument(string AuthKey, string SERVER, string GWReqNo) {
      try {
        var tgwApprovalNote = await new GwDao().TgwApprovalNoteGet(SERVER, GWReqNo);
        if (tgwApprovalNote != null) {
          var sGWURL = "http://거래처도메인/mashup/workflow.create.document";
          var sEmpNo = tgwApprovalNote.an_empNo;
          var sHtmlText = tgwApprovalNote.an_HtmlText;
          var sGWDocNo = tgwApprovalNote.an_GWDocNo;
          var sGWReqNo = tgwApprovalNote.an_GWReqNo;
          var sDocSubject = tgwApprovalNote.an_title;
          string sCallbackUrl = "api/gw/approvsta?GWReqNo={1}&status={2}&gwDocKey={3}&corpCd={4}&lossZeroKey=FPv4BapYVHOiVFrOAPjZgw==";
          string sCallBackErpResultUrl = "api/gw/gwdocumentresult?lossZeroKey=FPv4BapYVHOiVFrOAPjZgw==&result={1}&argErpDocKey={2}&corpCd={3}&argViewGubun={4}";

          var client = new RestClient(sGWURL);
          var req = new RestRequest(Method.POST);
          req.AddHeader("Content-Type", "application/x-www-form-urlencoded");
          req.AddHeader("AuthKey", AuthKey); //지오유에서 발급된 인증키
          req.AddHeader("Referer", "http://api.losszero.com");
          req.AddParameter("argErpUserID", sEmpNo);					//그룹웨어에서 매핑한 ERP사용자ID
          req.AddParameter("argFormNo", sGWDocNo);					//그룹웨어 양식번호
          req.AddParameter("argErpDocKey", sGWReqNo);					//ERP에서 지정한 고유한 문서번호ID
          //req.AddParameter("argCallbackErpUrl", sCallbackUrl);				//그룹웨어에서 호출될 콜백URL
          req.AddParameter("argCallbackErpEventUrl", sCallbackUrl);			//그룹웨어에서 호출될 콜백URL
          req.AddParameter("argDocSubject", sDocSubject);				//전자결재문서제목
          req.AddParameter("argCallbackErpResultUrl", sCallBackErpResultUrl);	//전자결재문서제목
          req.AddParameter("argBodyHtml", sHtmlText);					//html코드

          IRestResponse response = await client.ExecutePostAsync(req);

          if (response.StatusCode == HttpStatusCode.OK) {
            return Ok("OK");
            //return Ok(response.Content);
          } else {
            return Ok("ERROR_GwDocumentGet");
          }
        } else {
          return Ok(null);
        }
      } catch (Exception ex) {
        Loggers.GetLogger(ex.Message, "error");
        return Ok("Error_gwdocumentget");
      }
    }
  }
}

workflow.view.document 호출부문

using RestSharp;

namespace WebAPI.Controllers {
  [HttpPost("/api/gw/gwdocviewget")]
  public async Task<IActionResult> GwDocView([FromForm] string AuthKey, string argErpDocKey, string argGwDocKey, string argViewGubun) {
    try {
      var sGWURL = "https://dev.zioyou.com:443/mashup/workflow.view.document";
      var client = new RestClient(sGWURL);
      var req = new RestRequest(Method.POST);
      req.AddHeader("Referer", "http://api.losszero.com");
      req.AddHeader("AuthKey", AuthKey); //지오유에서 발급된 인증키

      req.AddParameter("argErpDocKey", argErpDocKey);
      req.AddParameter("argGwDocKey", argGwDocKey);
      req.AddParameter("argViewGubun", argViewGubun);

      IRestResponse response = await client.ExecutePostAsync(req);

      if (response.StatusCode == HttpStatusCode.OK) { //호출성공
        var data = JsonConvert.DeserializeObject<dynamic>(response.Content); //호출Data
        var sUrl = data.Message.ToString();

        HttpWebRequest request = WebRequest.Create(sUrl) as HttpWebRequest;
        WebResponse response2 = request.GetResponse();
        Stream stream = response2.GetResponseStream();
        StreamReader reader = new StreamReader(stream, Encoding.GetEncoding("utf-8"));
        Encoding encoding = Encoding.UTF8;
        string jsonData = reader.ReadToEnd();

        return Ok(jsonData);
      } else {
        return Ok("ERROR_Data");
      }
    } catch (Exception ex) {
      Loggers.GetLogger(ex.Message, "error");
      return Ok(ex.ToString());
    }
  }
}

VB.NET 샘플

Dim url As String = "http://localhost:60059/api/gw/gwdocumentGet"

url += "?AuthKey=" + v_sAuthKey + "&SERVER=" + v_ServerDbNo + "&GWReqNo=" + sGWReqNo
url += "&lossZeroKey=FPv4BapYVHOiVFrOAPjZgw=="

Dim request As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
request.Method = "GET"
request.ContentType = "application/json"
request.Headers.Add("Authorization", "11111111111111111111111111")
request.Timeout = (30 * 1000)

Dim sBrwName As String = ClassLib.RegistryGet(Me.Name, "DefBrowser", "")

Dim responseText As String = String.Empty
Dim respStream As Stream = Nothing
Try
  Using resp As WebResponse = request.GetResponse()
    respStream = resp.GetResponseStream()
    Using sr As StreamReader = New StreamReader(respStream)
      responseText = sr.ReadToEnd()

      If responseText <> "OK" Then
        responseText = "결재요청중 오류가 발생하였습니다."
        MsgBox(responseText)
      End If
    End Using
  End Using
Catch ex As Exception

End Try
using RestSharp;

namespace WebAPI.Controllers {
  [ApiController]
  [Route("[controller]")]
  public class GwController : ControllerBase {
    [HttpGet("/api/gw/gwdocument")]
    public async Task<IActionResult> GwDocument(string AuthKey, string SERVER, string GWReqNo) {
      try {
        var tgwApprovalNote = await new GwDao().TgwApprovalNoteGet(SERVER, GWReqNo);
        if (tgwApprovalNote != null) {
          var sGWURL = "http://거래처도메인/mashup/workflow.create.document";
          var sEmpNo = tgwApprovalNote.an_empNo;
          var sHtmlText = tgwApprovalNote.an_HtmlText;
          var sGWDocNo = tgwApprovalNote.an_GWDocNo;
          var sGWReqNo = tgwApprovalNote.an_GWReqNo;
          var sDocSubject = tgwApprovalNote.an_title;
          string sCallbackUrl = "api/gw/approvsta?GWReqNo={1}&status={2}&gwDocKey={3}&corpCd={4}&lossZeroKey=FPv4BapYVHOiVFrOAPjZgw==";
          string sCallBackErpResultUrl = "api/gw/gwdocumentresult?lossZeroKey=FPv4BapYVHOiVFrOAPjZgw==&result={1}&argErpDocKey={2}&corpCd={3}&argViewGubun={4}";

          var client = new RestClient(sGWURL);
          var req = new RestRequest(Method.POST);
          req.AddHeader("Content-Type", "application/x-www-form-urlencoded");
          req.AddHeader("AuthKey", AuthKey); //지오유에서 발급된 인증키
          req.AddHeader("Referer", "http://api.losszero.com");

          req.AddParameter("argErpUserID", sEmpNo);					//그룹웨어에서 매핑한 ERP사용자ID
          req.AddParameter("argFormNo", sGWDocNo);					//그룹웨어 양식번호
          req.AddParameter("argErpDocKey", sGWReqNo);					//ERP에서 지정한 고유한 문서번호ID
          //req.AddParameter("argCallbackErpUrl", sCallbackUrl);				//그룹웨어에서 호출될 콜백URL
          req.AddParameter("argCallbackErpEventUrl", sCallbackUrl);			//그룹웨어에서 호출될 콜백URL
          req.AddParameter("argDocSubject", sDocSubject);				//전자결재문서제목
          req.AddParameter("argCallbackErpResultUrl", sCallBackErpResultUrl);	//전자결재문서제목
          req.AddParameter("argBodyHtml", sHtmlText);					//html코드

          IRestResponse response = await client.ExecutePostAsync(req);

          if (response.StatusCode == HttpStatusCode.OK) {
            return Ok("OK");
            //return Ok(response.Content);
          } else {
            return Ok("ERROR_GwDocumentGet");
          }
        } else {
          return Ok(null);
        }
      } catch (Exception ex) {
        Loggers.GetLogger(ex.Message, "error");
        return Ok("Error_gwdocumentget");
      }
    }
  }
}

댓글을 작성하세요

문서 이력

  • 2022-12-28 날짜로 신달수 님으로 부터 컨텐츠명이 변경 되었습니다.
  • 2024-02-28 날짜로 신달수 님으로 부터 컨텐츠명이 변경 되었습니다.