Example #1
0
        public static int addSingleInfoReturnID <T>(T list, string url) where T : class
        {
            try
            {
                string strSerialResult = JsonConvert.SerializeObject(list);//序列化结果

                Type   type      = typeof(T);
                string className = type.Name;

                // string uri = Config.globalServiceURL + "service/addSingleDataReturnGUID/?tableName=" + className;
                string uri = url + "addSingleDataReturnGUID/?tableName=" + className;
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict.Add(className, strSerialResult);
                str  = strSerialResult;
                urll = uri;
                string responseStr = HttpWebResponseUtility.PostWebResponse(uri, dict, null, null, Encoding.UTF8, null);
                string typeID      = HttpWebResponseUtility.getValueByKeyName_return_id(responseStr, "data"); //reader.ReadToEnd为响应信息,这里为键值对,格式为 "data":5
                return(Convert.ToInt32(typeID));
            }
            catch (Exception ce)
            {
                LogUtil.WriteLog(null, ce.Message);
                return(-1);
            }
        }