Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 没用
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="updateT"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static bool updateSingleInfo <T>(int id, T updateT, string url) where T : class
        {
            try
            {
                Type   type            = typeof(T);
                string className       = type.Name;
                string strSerialResult = JsonConvert.SerializeObject(updateT);//序列化结果

                //string uri = Config.globalServiceURL + "service/updateSingleInfoByTableName/?tableName=" + className + "&id=" + id;
                string uri = url + "updateSingleInfoByTableName/?tableName=" + className + "&id=" + id;
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict.Add(className, strSerialResult);

                string responseStr = HttpWebResponseUtility.PostWebResponse(uri, dict, null, null, Encoding.UTF8, null);
                string flagStr     = HttpWebResponseUtility.getValueByKeyName(responseStr, "data"); //reader.ReadToEnd为响应信息,这里为键值对,格式为 "data":5


                if (!flagStr.Equals("success"))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ce)
            {
                LogUtil.WriteLog(null, ce.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public static bool addSingleInfoNotReturnID <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/addSingleDataNotReturn/?tableName=" + className;
                string uri = url + "addSingleDataNotReturn/?tableName=" + className;
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict.Add(className, strSerialResult);

                string responseStr = HttpWebResponseUtility.PostWebResponse(uri, dict, null, null, Encoding.UTF8, null);
                string flagStr     = HttpWebResponseUtility.getValueByKeyName_not_return_guid(responseStr, "data"); //reader.ReadToEnd为响应信息,这里为键值对,格式为 "data":5
                return(flagStr.Equals("success"));
            }
            catch (Exception ce)
            {
                LogUtil.WriteLog(null, ce.Message);
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static bool addManyInfoReturnBool <T>(List <T> list, string url) where T : class
        {
            try
            {
                string strSerialResult = JsonConvert.SerializeObject(list);//序列化结果
                Type   type            = typeof(T);
                string className       = type.Name;

                // string uri_add = Config.globalServiceURL + "service/addManyData/?tableName=" + className;
                string uri_add = url + "addManyData/?tableName=" + className;
                Dictionary <string, string> dict_add = new Dictionary <string, string>();
                dict_add.Add(className, strSerialResult);
                string responseStr_add = HttpWebResponseUtility.PostWebResponse(uri_add, dict_add, null, null, Encoding.UTF8, null);
                string flag_add        = HttpWebResponseUtility.getValueByKeyName(responseStr_add, "data");
                return(flag_add.Equals("success"));
            }
            catch (Exception ce)
            {
                LogUtil.WriteLog(null, ce.Message);
                return(false);
            }
        }