Esempio n. 1
0
        public static List <T> findDataByCondition <T>(string condition, string url)
        {
            try
            {
                Type     type      = typeof(T);
                string   className = type.Name;
                List <T> list      = new List <T>();

                Dictionary <string, object> dict2 = new Dictionary <string, object>();
                dict2.Add("tableName", className);
                dict2.Add("field", "*");
                dict2.Add("condition", condition);

                // string postURL = Config.globalServiceURL + "service/findListByWhere/";
                string          postURL     = url + "findDataByWhere/?tableName=" + className;
                string          userAgent   = "Someone";
                HttpWebResponse webResponse = FormUpload.MultipartFormDataPost(postURL, userAgent, dict2);

                StreamReader responseReader = new StreamReader(webResponse.GetResponseStream());
                string       fullResponse   = responseReader.ReadToEnd();
                bool         successFlag;
                string       val_first = HttpWebResponseUtility.getValueByKeyName(fullResponse, out successFlag);
                if (successFlag == true)
                {
                    list = (List <T>)JsonConvert.DeserializeObject <List <T> >(val_first);
                }
                return(list);
            }
            catch (Exception ce)
            {
                LogUtil.WriteLog(null, ce.Message);
                return(null);
            }
        }
Esempio n. 2
0
 public static int findListWhereCount(string condition, string url, string tableName)
 {
     try
     {
         //Type type = typeof(T);
         string className = tableName;
         // List<T> list = new List<T>();
         Dictionary <string, object> dict2 = new Dictionary <string, object>();
         dict2.Add("tableName", className);
         dict2.Add("field", "*");
         // dict2.Add("field", field);
         if (!string.IsNullOrEmpty(condition))
         {
             dict2.Add("condition", condition);
         }
         // string postURL = Config.globalServiceURL + "service/findListByWhere/";
         string          postURL        = url + "findListWhereCount/?tableName=" + className;
         string          userAgent      = "Someone";
         HttpWebResponse webResponse    = FormUpload.MultipartFormDataPost(postURL, userAgent, dict2);
         StreamReader    responseReader = new StreamReader(webResponse.GetResponseStream());
         string          fullResponse   = responseReader.ReadToEnd();
         bool            successFlag;
         string          val_first = HttpWebResponseUtility.getValueByKeyName(fullResponse, out successFlag);
         if (successFlag == true)
         {
             return(Convert.ToInt32(val_first));
         }
         return(0);
     }
     catch (Exception ce)
     {
         LogUtil.WriteLog(null, ce.Message);
         return(0);
     }
 }
Esempio n. 3
0
        public static bool getFormSave(string uri, Dictionary <string, object> dict2)
        {
            string          userAgent      = "Someone";
            HttpWebResponse webResponse    = FormUpload.MultipartFormDataPost(uri, userAgent, dict2);
            StreamReader    responseReader = new StreamReader(webResponse.GetResponseStream());
            string          fullResponse   = responseReader.ReadToEnd();
            bool            successFlag;
            string          val_first = HttpWebResponseUtility.getValueByKeyName(fullResponse, out successFlag);

            return(successFlag);
        }