public static string FxtApi_GetJson(this FxtApi_SYSCity obj) { obj = JsonHelp.EncodeField <FxtApi_SYSCity>(obj); string jsonStr = JsonHelp.ToJSONjss(obj); return(jsonStr); }
public static void trest() { HttpClient client = new HttpClient(); string date = DateTime.Now.ToString("20140611195856"); var para = new { sinfo = JsonHelp.ToJSONjss(new { functionname = "getallotsurveyingproject", appid = "1003106", apppwd = "1300558927", signname = "4106DEF5-A760-4CD7-A6B2-8250420FCB18", time = date, code = GetCode("4106DEF5-A760-4CD7-A6B2-8250420FCB18", date, "getallotsurveyingproject") }), info = JsonHelp.ToJSONjss(new { uinfo = new { username = "******", token = "" }, appinfo = new { splatype = "android", stype = "yck", version = "4.26", vcode = "1", systypecode = "1003034", channel = "360" }, funinfo = new { username = "******", cityid = 1 }// new { userid = "3", cityid = 1, allotid = 1, data =obj2.ToJSONjss()} }) }; string strD = para.ToJSONjss(); HttpResponseMessage hrm = client.PostAsJsonAsync("http://localhost:50887/mobileapi/runflats", para).Result; string str = hrm.Content.ReadAsStringAsync().Result; }
/// <summary> /// 调用数据中心接口(用于上传文件) /// </summary> /// <param name="userName"></param> /// <param name="signName"></param> /// <param name="functionName"></param> /// <param name="parasObj"></param> /// <param name="data"></param> /// <param name="appList"></param> /// <returns></returns> public static DataCenterResult PostDataCenter(string userName, string signName, string functionName, object parasObj, byte[] data, List <Apps> appList) { string appPwd = ""; string appKey = ""; string apiUrl = ""; FxtApiCommon.GetNowApiInfo(Common.appId, appList, out apiUrl, out appPwd, out appKey); //apiUrl = "http://192.168.1.104:8100/dc/active"; string nowTime = DateTime.Now.ToString("yyyyMMddHHmmss"); string sinfo = JsonHelp.ToJSONjss(new { functionname = functionName, appid = Common.appId, apppwd = appPwd, signname = signName, time = nowTime, code = Common.GetCode(signName, nowTime, functionName, appList) }); string info = JsonHelp.ToJSONjss(new { uinfo = new { username = userName, token = "" }, appinfo = new { splatype = "win", platVer = "2007", stype = "",//验证 version = "4.26", vcode = "1", systypecode = Common.systypeCode.ToString(), //验证 channel = "360" }, funinfo = parasObj }); string url = apiUrl + "/upload"; url = url + "?sinfo=" + sinfo.EncodeField() + "&info=" + info.EncodeField(); HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url); webrequest.ContentType = "application/octet-stream"; webrequest.Method = "POST"; Stream requestStream = webrequest.GetRequestStream(); byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n–—————————7d930d1a850658–\r\n"); requestStream.Write(data, 0, data.Length); // 输入尾部数据 requestStream.Write(boundaryBytes, 0, boundaryBytes.Length); WebResponse responce = webrequest.GetResponse(); Stream s = responce.GetResponseStream(); StreamReader sr = new StreamReader(s); // 返回数据流(源码) string str = sr.ReadToEnd(); DataCenterResult result = Common.GetDataCenterResult(str); return(result); }
/// <summary> /// 调用数据中心接口 /// </summary> /// <param name="userName"></param> /// <param name="signName"></param> /// <param name="functionName"></param> /// <param name="parasObj"></param> /// <returns></returns> public static DataCenterResult PostDataCenter(string userName, string signName, string functionName, object parasObj, List <Apps> appList) { try { string appPwd = ""; string appKey = ""; string apiUrl = ""; FxtApiCommon.GetNowApiInfo(Common.appId, appList, out apiUrl, out appPwd, out appKey); apiUrl = "http://localhost:40455/dc/active"; string nowTime = DateTime.Now.ToString("yyyyMMddHHmmss"); var para = new { sinfo = JsonHelp.ToJSONjss(new { functionname = functionName, appid = Common.appId, apppwd = appPwd, signname = signName, time = nowTime, code = Common.GetCode(signName, nowTime, functionName, appList) }), info = JsonHelp.ToJSONjss(new { uinfo = new { username = userName, token = "" }, appinfo = new { splatype = "win", platVer = "2007", stype = "",//验证 version = "4.26", vcode = "1", systypecode = Common.systypeCode.ToString(),//验证 channel = "360" }, funinfo = parasObj }) }; HttpClient client = new HttpClient(); //client.BaseAddress = new Uri(apiUrl); client.Timeout = new TimeSpan(0, 10, 0); HttpResponseMessage hrm = client.PostAsJsonAsync(new Uri(apiUrl), para).Result; string str = hrm.Content.ReadAsStringAsync().Result; DataCenterResult result = Common.GetDataCenterResult(str); return(result); } catch (AggregateException ex) { throw ex; } }
/// <summary> /// 调用用户中心接口 /// </summary> /// <param name="userName"></param> /// <param name="signName"></param> /// <param name="functionName"></param> /// <param name="parasObj"></param> /// <param name="appList">当前用户所拥有的api信息集合</param> /// <returns></returns> public static DataCenterResult PostUserCenter(string userName, string signName, string functionName, object parasObj, List <UserCenter_Apps> appList) { string appPwd = ""; string appKey = ""; string apiUrl = ""; FxtApiCommon.GetNowApiInfo(Common.appId, appList, out apiUrl, out appPwd, out appKey); string nowTime = DateTime.Now.ToString("yyyyMMddHHmmss"); var para = new { sinfo = JsonHelp.ToJSONjss(new { functionname = functionName, appid = Common.appId, apppwd = appPwd, signname = signName, time = nowTime, code = Common.GetCode(signName, nowTime, functionName, appList) }), info = JsonHelp.ToJSONjss(new { uinfo = new { username = userName, token = "" }, appinfo = new { splatype = "win", platVer = "2007", stype = "",//验证 version = "4.26", vcode = "1", systypecode = Common.systypeCode.ToString(),//验证 channel = "360" }, funinfo = parasObj }) }; HttpClient client = new HttpClient(); //apiUrl = "http://192.168.1.104:8200/uc/active"; HttpResponseMessage hrm = client.PostAsJsonAsync(apiUrl, para).Result; string str = hrm.Content.ReadAsStringAsync().Result; DataCenterResult result = Common.GetDataCenterResult(str); return(result); }
public static DataCenterResult PostUserCenter_Login(string userName, string password) { //LogHelper.Info("Common.apiUrl_Login="******"yyyyMMddHHmmss"); string _password = GetCode(password, appKey_LoginPwd); //string _password = EncryptHelper.GetMd5("Cmbfxtproduct*&2014");// GetCode(password, appKey_LoginPwd); var para = new { sinfo = JsonHelp.ToJSONjss(new { time = nowTime, code = Common.GetCode(nowTime, appKey_Login) }), info = JsonHelp.ToJSONjss(new { uinfo = new { username = userName, token = "", password = _password }, appinfo = new { splatype = "win", platVer = "2007", stype = "",//验证 version = "4.26", vcode = "1", systypecode = Common.systypeCode.ToString(),//验证 channel = "360" }, funinfo = new { } }) }; string test = para.ToJSONjss(); //LogHelper.Info("test=" + test); HttpClient client = new HttpClient(); HttpResponseMessage hrm = client.PostAsJsonAsync(new Uri(Common.apiUrl_Login), para).Result; //HttpResponseMessage hrm = client.PostAsJsonAsync(new Uri("http://192.168.0.7:9994/uc/active"), para).Result; string str = hrm.Content.ReadAsStringAsync().Result; //LogHelper.Info("str=" + str); DataCenterResult result = Common.GetDataCenterResult(str); return(result); }
public void HttpGetTest() { //return; List <FxtApi_DATProjectAvgPrice> listtest = ProjectAvgPriceApi.GetCrossByCompanyId(45606, 6, 1002001, "2014-4", 25); //ProjectApi.testcross(); return; //FxtApi_SYSCode aa = new FxtApi_SYSCode { Code = 1, CodeName = "aaa", CodeType = "sdf", ID = 22, Remark = "fdf", SubCode = 1 }; //FxtApi_SYSCode bb =new FxtApi_SYSCode (); //string bbb = aa.Remark; ; // bbb = "哈哈"; //bb = aa; //bb.Remark = "哈哈"; //string aaa = aa.Remark; #region 示例 var obj = new { x = "(decimal?,null,物业精度)", y = "(decimal?,null,物业纬度)", allotflowx = "(decimal?,not null,查勘员现场经度(插入表Dat_AllotFlow))", allotflowy = "(decimal?,not null,查勘员现场纬度(插入表Dat_AllotFlow))", projectname = "(string,not null,楼盘名称)", cityid = "(int,not null,城市ID(选择))", areaid = "(int,not null,行政区ID(选择))", address = "(string,not null,物业地址)", enddate = "(DateTime?,not null,竣工时间)", east = "(string,null,四至朝向-东)", west = "(string,null,四至朝向-西)", south = "(string,null,四至朝向-南)", north = "(string,null,四至朝向-北)", buildingarea = "(decimal?,not null,建筑面积)", landarea = "(decimal?,not null,占地面积)", cubagerate = "(decimal?,not null,容积率)", greenrate = "(decimal?,not null,绿化率)", manager_company = "(string,null,物业管理公司(插入表LNK_P_Company)", managerprice = "(nvarchar,not null,物业管理费)", developers = "(string,null,开发商(插入表LNK_P_Company)", parkingnumber = "(int,not null,车位数)", totalnum = "(int,not null,总户数or总套数)", saledate = "(DateTime?,not null,开盘时间)", buildingdate = "(DateTime?,not null,开工时间)", statedate = "(DateTime,not null,采集时间)", buildingnum = "(int,not null,总栋数)", detail = "(string,null,楼盘备注)", allotflowremark = "(string,null,任务备注(插入表Dat_AllotFlow))", fxtprojectid = "(int,null,正式库的楼盘ID)", photocount = "(int,not null,照片个数)", appendage = new[] { new { appendagecode = "(int,not null,配套类型(学校;医院..)(选择)", p_aname = "(string,not null,配套名字)", classcode = "(int,not null,配套等级)(选择)" } }, buildingList = new[] { new { buildingid = 0, buildingname = "(string,not null,楼栋名称)", doorplate = "(string,null,门牌号)", othername = "(string,null,楼栋别称)", structurecode = "(int?,not null,建筑结构(选择))", locationcode = "(int?,not null,位置(选择))", averageprice = "(decimal?,not null,楼栋均价)", builddate = "(DateTime?,not null,楼栋竣工时间(建筑时间))", iselevator = "(int,not null,是否带电梯)", elevatorrate = "(string,null,梯户数(梯户比))", pricedetail = "(string,null,价格说明)", remark = "(string,null,备注)", fxtbuildingid = "(int,null,正式库的楼栋ID)", sightcode = "(int,null,景观(选择))", totalfloor = "(int,not null,总层数)", houseList = new[] { new { houseid = "(int,null,ID)", unitno = "(string,null,单元名称)", floorno = "(int,not null,所在层)", housename = "(string,not null,房号)", frontcode = "(string,not null,朝向(选择))", buildarea = "(decimal?,not null,面积)", housetypecode = "(int?,not null,户型(选择))", remark = "(string,null,备注)", fxthouseid = "(int,null,正式库的房号ID)", sightcode = "(int,null,景观)", } } } } }; #endregion var obj2 = new { x = 212.1212, y = 212.121, allotflowx = "212.1212", allotflowy = "212.121", projectname = "测试提交楼盘", cityid = 1, areaid = 1, address = "测试提交楼盘物业地址)", enddate = "2004-1-1", east = "山", west = "河", south = "湖", north = "海", buildingarea = 10000, landarea = 20000, cubagerate = 0.2, greenrate = 0.5, manager_company = "测试提交楼盘物业管理公司", managerprice = "122", developers = "测试提交楼盘", parkingnumber = "1", totalnum = 10, saledate = "2012-3-3", buildingdate = "2000-1-1", buildingnum = "2", statedate = DateTime.Now.ToString(), detail = "楼盘备注", allotflowremark = "(string,null,任务备注(插入表Dat_AllotFlow))", photocount = "(int,not null,照片个数)", fxtprojectid = "", appendage = new List <object> { new { appendagecode = 2008007, p_aname = "东城区人民医院修改", classcode = 1012003 }, new { appendagecode = 2008005, p_aname = "修改广东发展银行、中国建设银行、东莞银行、东莞市农村商业银行", classcode = 1012003 }, new { appendagecode = 2008006, p_aname = "修改东莞市岭南学校、莞城英文实验学校", classcode = 1012003 }, new { appendagecode = 2008002, p_aname = "新增超市", classcode = 1012003 } }, buildinglist = new List <object> { new { buildingid = 0, buildingname = "1-楼栋", doorplate = "(string,null,门牌号)", othername = "(string,null,楼栋别称)", structurecode = 2010003, locationcode = 2011001, //(int?,not null,位置(选择)) averageprice = 12121, builddate = "2012-1-1", iselevator = 1, elevatorrate = "(string,null,梯户数(梯户比))", pricedetail = "(string,null,价格说明)", remark = "(string,null,备注)", fxtbuildingid = "", sightcode = "2006007", totalfloor = 22, houselist = new List <object> { new { houseid = 0, unitno = "单元名称1", floorno = 1, housename = "测试房号1", frontcode = 2004004, buildarea = "145.2", housetypecode = 4001007, remark = "(string,null,备注)", fxthouseid = "", sightcode = 2006002 }, new { houseid = 0, unitno = "单元名称2", floorno = 1, housename = "测试房号2", frontcode = 2004004, buildarea = "145.2", housetypecode = 4001007, remark = "(string,null,备注)", fxthouseid = "", sightcode = 2006002 } } }, new { buildingid = 5, buildingname = "1-楼栋", doorplate = "(string,null,门牌号)", othername = "(string,null,楼栋别称)", structurecode = 2010003, locationcode = 2011001, //(int?,not null,位置(选择)) averageprice = 12121, builddate = "2012-1-1", iselevator = 1, elevatorrate = "(string,null,梯户数(梯户比))", pricedetail = "(string,null,价格说明)", remark = "(string,null,备注)", fxtbuildingid = "", sightcode = "2006007", totalfloor = 22, houselist = new List <object> { new { houseid = 0, unitno = "单元名称3", floorno = 1, housename = "测试房号3", frontcode = 2004004, buildarea = "145.2", housetypecode = 4001007, remark = "(string,null,备注)", fxthouseid = "", sightcode = 2006002 }, new { houseid = 58, unitno = "单元名称4", floorno = 1, housename = "测试房号4", frontcode = 2004004, buildarea = "145.2", housetypecode = 4001007, remark = "(string,null,备注)", fxthouseid = "", sightcode = 2006002 }, new { houseid = 59, unitno = "单元名称5", floorno = 1, housename = "1-1201", frontcode = 2004004, buildarea = "145.2", housetypecode = 4001007, remark = "(string,null,备注)", fxthouseid = "", sightcode = 2006002 } } } } }; //http://localhost:50887/mobileapi/runflats string url = "http://192.168.0.128:6400/mobileapi/runflats"; HttpClient client = new HttpClient(); //client.Headers.Add( 添加头部 string date = DateTime.Now.ToString("yyyyMMddHHmmss"); var para = new { sinfo = JsonHelp.ToJSONjss(new { functionname = "getallotsurveyingproject", appid = "1003106", apppwd = "1300558927", signname = "4106DEF5-A760-4CD7-A6B2-8250420FCB18", time = date, code = "aabbccddeeffgg" }), info = JsonHelp.ToJSONjss(new { uinfo = new { username = "******", token = "" }, appinfo = new { splatype = "android", stype = "yck", version = "4.26", vcode = "1", systypecode = "1003034", channel = "360" }, funinfo = new { username = "******", cityid = 1 }// new { userid = "3", cityid = 1, allotid = 1, data =obj2.ToJSONjss()} }) }; HttpResponseMessage hrm = client.PostAsJsonAsync(url, para).Result; string str = hrm.Content.ReadAsStringAsync().Result; }