using Gdsi.Config; using Gdsi.Helper; using Gdsi.Model; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Gdsi.Domain { public class GdsiApi { private static string api_9001() { string result = ""; var req = new { infno = "9001", msgid = GdsiConfig.fixmedins_code + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(1, 10000).ToString().PadLeft(4, '0'), mdtrtarea_admvs = GdsiConfig.city_code, insuplc_admdvs = GdsiConfig.city_code, recer_sys_code = "FD0001", dev_no = "", dev_safe_info = "", cainfo = "", signtype = "SM3", infver = "V1.0", opter_type = "2", opter = GdsiConfig.opter, opter_name = GdsiConfig.opter_name, inf_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), fixmedins_code = GdsiConfig.fixmedins_code, fixmedins_name = GdsiConfig.fixmedins_name, sign_no = "", app_id = "", enc_type = "", input = new { signIn = new { opter_no = GdsiConfig.opter, mac = "00-50-56-82-8B-F4", ip = "192.168.30.33" } } }; string strReq = JsonConvert.SerializeObject(req); string strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "9001", strReq); try { JObject jObject = JsonConvert.DeserializeObject(strRes) as JObject; if (jObject["infcode"].ToString() == "0") { if (jObject["output"]["signinoutb"]["sign_no"] == null) { return result; } result = jObject["output"]["signinoutb"]["sign_no"].ToString(); return result; } return result; } catch { return result; } } public static Info api_1101(string qrCode) { Info info = new Info(); string signNo = api_9001(); if ("".Equals(signNo)) { info.Msg = "签到出错"; return info; } var req = new { infno = "1101", msgid = GdsiConfig.fixmedins_code + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(1, 10000).ToString().PadLeft(4, '0'), mdtrtarea_admvs = GdsiConfig.city_code, insuplc_admdvs = GdsiConfig.city_code, recer_sys_code = "FD0001", dev_no = "", dev_safe_info = "", cainfo = "", signtype = "SM3", infver = "V1.0", opter_type = "2", opter = GdsiConfig.opter, opter_name = GdsiConfig.opter_name, inf_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), fixmedins_code = GdsiConfig.fixmedins_code, fixmedins_name = GdsiConfig.fixmedins_name, sign_no = "", app_id = "", enc_type = "", input = new { data = new { mdtrt_cert_type = "01", mdtrt_cert_no = qrCode, card_sn = "", begntime = "", psn_cert_type = "", certno = "", psn_name = "" } } }; string strReq = JsonConvert.SerializeObject(req); string strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "1101", strReq); try { JObject jObject = JsonConvert.DeserializeObject(strRes) as JObject; if (jObject["infcode"].ToString() == "0") { info.Code = 0; info.Msg = "SUCCESS"; info.Data = new Info.BaseInfo(); info.Data.Name = jObject["output"]["baseinfo"]["psn_name"].ToString(); info.Data.IDNo = jObject["output"]["baseinfo"]["certno"].ToString(); } else { info.Msg = jObject["err_msg"].ToString(); } } catch (Exception ex) { info.Msg = ex.Message; } return info; } } }