123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using ProjectManagementSystem.Common.Logger;
- using ProjectManagementSystem.Common.Models.Crms;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ProjectManagementSystem.Common.Service
- {
- public class PmsCustomApi
- {
- private static RestApi restApi = new RestApi();
- public static WebMgrResponse<T> Get<T>(string apiName, object pars)
- {
- try
- {
- string url = Common.Function.AppSetting.GetPmsApiCustomUrl(apiName);
- var res = restApi.Get<WebMgrResponse<T>>(url, pars, null, out string content);
- //CLog.Instance.SystemLog.WriteDebug($"Get {url}{Environment.NewLine} {JsonConvert.SerializeObject(pars)}{Environment.NewLine} {content}");
- return res;
- }
- catch (Exception ex)
- {
- CLog.Instance.SystemLog.WriteError(ex.Message);
- return new WebMgrResponse<T>() { message = ex.Message };
- }
- }
- public static WebMgrResponse<T> Post<T>(string apiName, object body)
- {
- try
- {
- string url = Common.Function.AppSetting.GetPmsApiCustomUrl(apiName);
- var res = restApi.Post<WebMgrResponse<T>>(url, null, body, out string content);
- //CLog.Instance.SystemLog.WriteDebug($"Post {url}{Environment.NewLine} {JsonConvert.SerializeObject(body)}{Environment.NewLine} {content}");
- return res;
- }
- catch (Exception ex)
- {
- CLog.Instance.SystemLog.WriteError(ex.Message);
- return new WebMgrResponse<T>() { message = ex.Message };
- }
- }
- }
- }
|