示例#1
0
        public static int GetUnUploadCountFromSqlite()
        {
            try
            {
                string sql = string.Format("SELECT count(*) FROM UploadData where IsUpload=0");
                object re  = SqliteDBHelp.GetValue(sql);
                if (re != null)
                {
                    int reint = 0;
                    int.TryParse(re.ToString(), out reint);
                    return(reint);
                }
            }
            catch (Exception e)
            {
                Log4netHelper.LogError(e);
            }

            return(0);
        }
示例#2
0
        public static string Submit(string postData, string serviceType, CPPInfo ppinfo)
        {
            string requestTime = DateTime.Now.ToString("yyyyMMddHHmmss");

            string str      = "bizData=" + postData + "&msgId=424&msgType=sync&notifyUrl=&partnerId=" + ppinfo.Inerfae_key + "&partnerKey=" + ppinfo.Secret + "&serviceType=" + serviceType + "&serviceVersion=1.0";
            string qm       = USerMd5(str);
            string binzdata = StrToUrlEncode(postData);
            string str2     = "bizData=" + binzdata + "&serviceType=" + serviceType + "&msgId=424&msgType=sync&partnerId=" + ppinfo.Inerfae_key + "&partnerKey=" + ppinfo.Secret + "&serviceVersion=1.0&notifyUrl=&sign=" + qm + "&";


            byte[]         bytePostData = Encoding.UTF8.GetBytes(str2);
            HttpWebRequest req          = (HttpWebRequest)WebRequest.Create(ppinfo.Interface_url);

            req.Method = "POST";

            req.Timeout       = connectTimeout;
            req.ContentType   = "application/x-www-form-urlencoded";;
            req.ContentLength = bytePostData.Length;
            try
            {
                using (System.IO.Stream reqStream = req.GetRequestStream())
                {
                    reqStream.Write(bytePostData, 0, bytePostData.Length);
                }
                using (WebResponse wr = req.GetResponse())
                {
                    System.IO.StreamReader reader = new System.IO.StreamReader(wr.GetResponseStream(), System.Text.Encoding.UTF8);

                    string responseFromServer = reader.ReadToEnd();
                    return(responseFromServer);
                }
            }
            catch (Exception ex)
            {
                Log4netHelper.LogError(ex);
            }

            return("");
        }
示例#3
0
        /// <summary>
        /// 执行不带参数sql语句,返回所影响的行数
        /// </summary>
        /// <param name="cmdstr">增,删,改sql语句</param>
        /// <returns>返回所影响的行数</returns>
        public static int ExecuteNonQuery(string cmdText)
        {
            int count = 0;

            SqlConnection conn = new SqlConnection(ConnStr);

            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(cmdText, conn);
                count = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Log4netHelper.LogError(cmdText, ex);
                count = 0;
            }
            finally
            {
                conn.Close();
            }
            return(count);
        }