3月 23

mm

未分类 No Comments »

AMOUNTPRICE: (CLOSE-MA(CLOSE,21))/MA(CLOSE,21)*100, COLORWHITE;

BOLL:MA(CLOSE,N);
UPER:BOLL+2*STD(CLOSE,N);
LOWER:BOLL-2*STD(CLOSE,N);

DIF:EMA(CLOSE,SHORT)-EMA(CLOSE,LONG);
DEA:EMA(DIF,MID);
MACD:(DIF-DEA)*2*20,COLORSTICK;

XG:
CLOSE<20
AND REF(AMOUNTPRICE,1)<-8
AND AMOUNTPRICE>=REF(AMOUNTPRICE,1)

AND MACD>REF(MACD,1)
{AND REF(MACD,1)<REF(MACD,2)}

AND
(LOW<LOWER OR
REF(LOW,1)<REF(LOWER,1)
OR
REF(LOW,2)<REF(LOWER,2)
)
;

written by ocean

3月 16

补一种简单的方法

 

客户端

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.IO; 
using System.Net; 
using System.Collections; 
using System.Collections.Specialized; 
using System.Web; 
  
namespace blog.wx6.org.ConsoleApplication 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            string filePath=@"F:\2\imags\question1.png"; 
            string url = "http://localhost:37778/Upload.aspx"; 
  
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); 
            byte[] byteFile = new byte[fs.Length]; 
            fs.Read(byteFile, 0, Convert.ToInt32(fs.Length)); 
            fs.Close(); 
            string postData = "param1=pwd&UploadFile=" + HttpUtility.UrlEncode(Convert.ToBase64String(byteFile)); 
            var webclient = new WebClient(); 
            webclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); 
            byte[] byteArray = Encoding.UTF8.GetBytes(postData); 
            byte[] buffer = webclient.UploadData(url, "POST", byteArray); 
            var msg = Encoding.UTF8.GetString(buffer); 
        } 
    } 
}

服务器端接收

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.IO; 
  
namespace blog.wx6.org.WebApplication 
{ 
    public partial class Upload : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
  
            string path = @"f:\1\uplod.png"; 
  
  
            string param1 = Request["param1"]; 
            FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write); 
            fs.Write(Convert.FromBase64String(Request["UploadFile"].ToString()), 0, 
                Convert.FromBase64String(Request["UploadFile"].ToString()).Length); 
            fs.Flush(); 
            fs.Close(); 
  
            Response.Write("success");  
        } 
    } 
}

 

  

 

 /// <summary>
        /// 后台上传图片
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <param name="contentType">文件类型</param>
        /// <param name="isMark">是否添加水印</param>
        /// <param name="isThumb">是否生成缩略图</param>
        /// <returns></returns>
        public static string PostImg(string filePath, string contentType, bool isMark, bool isThumb)
        { 
            Hashtable paras = new Hashtable();
            paras.Add("Referrer", "http://www.dianping.com");
            string token = SecurityHelper.EncryptString("CMS|" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            paras.Add("ut", token); 
            if (isMark)
                paras.Add("mark", "1");
            if (isThumb)
                paras.Add("thumb", "1");
            string ImageUrl = "URL"; //上传图片url  
            string result = PostImg(ImageUrl, filePath, contentType, paras); 
            return result;
        }

        private static string PostImg(string imgUploadUrl, string file, string contentType, Hashtable hashtable)
        {
           
            string boundary = "—————————" + DateTime.Now.Ticks.ToString("x");
            byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n–" + boundary + "\r\n");

            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(imgUploadUrl);
            wr.ContentType = "multipart/form-data; boundary=" + boundary;
            wr.Method = "POST";
            wr.KeepAlive = true;
            wr.Credentials = System.Net.CredentialCache.DefaultCredentials; 
            Stream rs = wr.GetRequestStream(); 
            string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
            foreach (DictionaryEntry item in hashtable)
            {
                rs.Write(boundarybytes, 0, boundarybytes.Length);
                string formitem = string.Format(formdataTemplate, item.Key, item.Value);
                byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                rs.Write(formitembytes, 0, formitembytes.Length);
            }
             
            rs.Write(boundarybytes, 0, boundarybytes.Length);

            string headerTemplate = "Content-Disposition: form-data; filename=\"{0}\"\r\nContent-Type: {1}\r\n\r\n";
            string header = string.Format(headerTemplate,  file, contentType);
            byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
            rs.Write(headerbytes, 0, headerbytes.Length);

            FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read);
            byte[] buffer = new byte[4096];
            int bytesRead = 0;
            while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
            {
                rs.Write(buffer, 0, bytesRead);
            }
            fileStream.Close();

            byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n–" + boundary + "–\r\n");
            rs.Write(trailer, 0, trailer.Length);
            rs.Close();

            WebResponse wresp = null;
            try
            {
                wresp = wr.GetResponse();
                Stream stream2 = wresp.GetResponseStream();
                StreamReader reader2 = new StreamReader(stream2);
                string result = reader2.ReadToEnd();
                return result;
            }
            catch (Exception ex)
            { 
                if (wresp != null)
                {
                    wresp.Close();
                    wresp = null;
                }
                return ex.ToString();
            }
            finally
            {
                wr = null;
            }
        }

written by ocean