Exemple #1
0
 public static void LivingRoomLight(string json)
 {
     byte[] jsonbytes = Encoding.ASCII.GetBytes(json);
     using (var client = new System.Net.WebClient())
     {
         client.UploadData(new Uri("http://192.168.1.2/api/VTNCDYBr0umn6-sZEzgte7A7zED3SgfE-0RxsNy6/lights/3/state"), "PUT", jsonbytes);
         client.UploadData(new Uri("http://192.168.1.2/api/VTNCDYBr0umn6-sZEzgte7A7zED3SgfE-0RxsNy6/lights/4/state"), "PUT", jsonbytes);
         client.UploadData(new Uri("http://192.168.1.2/api/VTNCDYBr0umn6-sZEzgte7A7zED3SgfE-0RxsNy6/lights/5/state"), "PUT", jsonbytes);
     }
 }
Exemple #2
0
 public static void LivingRoomLight(string json, string HueURL)
 {
     byte[] jsonbytes = Encoding.ASCII.GetBytes(json);
     using (var client = new System.Net.WebClient())
     {
         client.UploadData(new Uri(HueURL + "/lights/3/state"), "PUT", jsonbytes);
         client.UploadData(new Uri(HueURL + "/lights/4/state"), "PUT", jsonbytes);
         client.UploadData(new Uri(HueURL + "/lights/5/state"), "PUT", jsonbytes);
     }
 }
Exemple #3
0
		async Task RunUnitTests ()
		{
			var tat = typeof(NUnit.Framework.TestAttribute);
			var tfat = typeof(NUnit.Framework.TestFixtureAttribute);

			var types = typeof (DrawingTest).Assembly.GetTypes ();
			var tfts = types.Where (t => t.GetCustomAttributes (tfat, false).Length > 0);

			var ngd = System.Environment.GetFolderPath (System.Environment.SpecialFolder.MyDocuments);
			PlatformTest.ResultsDirectory = System.IO.Path.Combine (ngd, "TestResults");
			PlatformTest.Platform = Platforms.Current;
			System.IO.Directory.CreateDirectory (PlatformTest.ResultsDirectory);
//			System.Environment.CurrentDirectory = PlatformTest.ResultsDirectory;

			foreach (var t in tfts) {
				var test = Activator.CreateInstance (t);
				var ms = t.GetMethods ().Where (m => m.GetCustomAttributes (tat, true).Length > 0);
				foreach (var m in ms) {
					try {
						var r = m.Invoke (test, null);
						var ta = r as Task;
						if (ta != null)
							await ta;
					} catch (Exception ex) {
						Console.WriteLine (ex);
					}
				}
			}

			var client = new System.Net.WebClient ();
			var pngs = System.IO.Directory.GetFiles (PlatformTest.ResultsDirectory, "*.png");
			foreach (var f in pngs) {
				client.UploadData ("http://10.0.1.8:1234/" + System.IO.Path.GetFileName (f), System.IO.File.ReadAllBytes (f));
			}
		}
        /// <summary>
               /// 获取远程服务器文件字节大小
               /// </summary>
               /// <param name="filePath">待上传的文件全路径名称</param>
               /// <param name="hostURL">服务器的地址</param>
               /// <param name="userID">主机用户ID</param>
               /// <returns>远程文件大小</returns>
        public long GetRemoteFileLength(string filePath, string hostURL, string userID)
        {
            long length = 0;

            System.Net.WebClient WebClientObj = new System.Net.WebClient();

            string fileName = filePath.Substring(filePath.LastIndexOf('/') + 1);

            hostURL = hostURL + "&action=length" + "&filename=" + fileName + "&userid=" + userID + "&npos=0";

            byte[] data         = new byte[0];
            byte[] byRemoteInfo = WebClientObj.UploadData(hostURL, "POST", data);
            string sRemoteInfo  = System.Text.Encoding.Default.GetString(byRemoteInfo);//主系统没有作异常处理

            try
            {
                length = Convert.ToInt64(sRemoteInfo);
            }
            catch (Exception exx)
            {
                LogHelper.WriteErrorMsg("FileLib类GetRemoteFileLength()中length = Convert.ToInt64(sRemoteInfo)语句异常:", exx.Message);
                //我们强制处理异常
                length = 0;
            }
            GC.Collect();

            return(length);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Console.Title = "支付回调代理服务";

            WriteLog("正在启动服务 ..");
            var http = new HttpListener();

            http.StartListen();
            WriteLog("支付回调代理服务启动完成 ..");
            Console.WriteLine();

            while (true)
            {
                WriteLog("按任意键触发一个http模拟请求 ..");
                Console.ReadKey();

                WriteLog("正在模拟Http请求 ..");
                var httpClient = new System.Net.WebClient();
                httpClient.Headers.Add(System.Net.HttpRequestHeader.ContentType, "pplication/x-www-form-urlencoded");
                var postString = "type=test&time=" + DateTime.Now.ToString(@"yyyy\/MM\/dd HH:mm:ss");

                httpClient.UploadData(AppConfig.HttpURL, "post", Encoding.UTF8.GetBytes(postString));
                WriteLog("请检查tcp客户端是否收到模拟请求的参数 ..");
            }
        }
Exemple #6
0
 /// <summary>
 /// HttpPost访问
 /// </summary>
 public string HttpPost(string Url, string Params)
 {
     HTTPERROR = string.Empty;
     System.Net.WebClient webClient = new System.Net.WebClient();
     webClient.Headers.Add("Accept", "*/*");
     webClient.Headers.Add("Accept-Language", "zh-cn");
     webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
     webClient.Headers.Add("User-Agent", "Baiduspider+(+http://www.baidu.com/search/spider.htm)");
     //将字符串转换成字节数组
     byte[] postData = System.Text.Encoding.GetEncoding("utf-8").GetBytes(Params);
     try
     {
         byte[] responseData = webClient.UploadData(Url, "POST", postData);
         return(System.Text.Encoding.GetEncoding("utf-8").GetString(responseData));
     }
     catch (System.Exception Exce)
     {
         HTTPERROR = Exce.ToString();
         return("-1," + Exce.ToString());
     }
     finally
     {
         if (webClient != null)
         {
             webClient.Dispose();
         }
         if (webClient != null)
         {
             webClient = null;
         }
     }
 }
Exemple #7
0
        /// <summary>
        /// 根据经纬度获取地址
        /// </summary>
        /// <param name="lng">经度</param>
        /// <param name="lat">纬度</param>
        public static string GetAddressByLngLat(string lng, string lat)
        {
            string address = string.Empty;
            string url     = "http://api.map.baidu.com/geocoder/v2/?ak=" + BaiduMapKey + "&callback=renderOption&output=json&location=" + lat + "," + lng;

            var wclient = new System.Net.WebClient();

            byte[] jsonbyte = System.Text.Encoding.ASCII.GetBytes(url);
            try
            {
                byte[] ret = wclient.UploadData(url, "POST", jsonbyte);
                if (ret != null)
                {
                    string[] jsons = System.Text.Encoding.UTF8.GetString(ret).Split(',');
                    foreach (string strJson in jsons)
                    {
                        if (strJson.Contains("formatted_address"))
                        {
                            address = strJson.Split(':')[strJson.Split(':').Length - 1].Replace("\"", "");
                        }
                    }
                }
            }
            catch { }
            return(address);
        }
Exemple #8
0
        public static void sendMail2(string smtpserver, string userName, string pwd, string nickName, string strfrom, string strto, string subj, string bodys)
        {
            try
            {
                bodys = bodys.Replace("&gt;", ">");
                bodys = bodys.Replace("&lt;", "<");
                bodys = bodys.Replace("&nbsp;", " ");
                bodys = bodys.Replace("&quot;", "\"");
                bodys = bodys.Replace("&#39;", "\'");
                bodys = bodys.Replace("<br/>", "\n");

                System.Net.WebClient wCient = new System.Net.WebClient();
                wCient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                string data = "content={\"platform\":\"pc\",\"deviceToken\":\"deviceToken\",\"appkey\":\"gdfshgfhdgdf\",\"appCode\":\"1001\",\"language\":\"zh_CN\",'from':'" + strfrom + "','to':'" + strto + "','password':'******','hostName':'" + smtpserver
                              + "','smtpPort':'25','subTitle':'" + subj + "','body':'" + bodys + "','name':'" + nickName + "','maillist':['" + strto
                              + "']}" + "&sign='sign'";
                byte[] buffer = Encoding.UTF8.GetBytes(data);
                //data = Encoding.GetEncoding("GB2312").GetString(buffer);
                //   HttpUtility.UrlEncode
                // HttpUtility.UrlDecode("aa", Encoding.GetEncoding("gbk"));
                byte[] utf8bytes  = System.Text.Encoding.Default.GetBytes(data);
                byte[] utf8bytes2 = System.Text.Encoding.Convert(System.Text.Encoding.Default, System.Text.Encoding.UTF8, utf8bytes);
//data = System.Text.Encoding.Default.GetString(utf8bytes2);
                //    byte[] postData = System.Text.Encoding.ASCII.GetBytes(data);
                //   string URLEncode = HttpHelper.URLEncode(parameters);
                byte[] responseData = wCient.UploadData("http://power_cloud_manager/api/mail/send", "POST", buffer);

                string returnStr = System.Text.Encoding.UTF8.GetString(responseData);//返回接受的数据
            }
            catch (Exception)
            {
                throw new Exception("邮箱设置错误");
                //throw;
            }
        }
Exemple #9
0
        private void btSave_Click(object sender, EventArgs e)
        {
            try
            {
                var client = new System.Net.WebClient();

                client.Headers.Add("Content-Type", "application/json");

                var data = JsonConvert.SerializeObject(new
                {
                    IBANNumber = txtISBN.Text,
                    FirstName  = txtFirstName.Text,
                    LastName   = txtLastName.Text,
                    Email      = txtEmail.Text
                });

                client.UploadData("https://bankdemoapi.azurewebsites.net/api/user/", "PUT", Encoding.UTF8.GetBytes(data));

                MessageBox.Show("Saved successfully!");

                ResetPage();
            }
            catch {
                MessageBox.Show("Saved error!");
            }
        }
Exemple #10
0
        internal static void Turn(string state)
        {
            RegistryKey options = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\Workbench Light");
            string      token   = options.GetValue("token").ToString();
            string      account = options.GetValue("accountid").ToString();
            string      outlet  = options.GetValue("outletid").ToString();

            string url = $"https://smartapi.vesync.com/v1/wifi-switch-1.3/{outlet}/status/{state}";

            using (var client = new System.Net.WebClient())
            {
                client.Headers.Add("tk", token);
                client.Headers.Add("accountid", account);

                bool success = false;
                int  tries   = 0;
                while (success == false && tries < 10)
                {
                    try
                    {
                        success = true;
                        client.UploadData(url, "PUT", Encoding.UTF8.GetBytes("{}"));
                        tries++;
                    }
                    catch (System.Net.WebException)
                    {
                        success = false;
                    }
                    System.Threading.Thread.Sleep(3000);
                }
            }
        }
Exemple #11
0
        static Newtonsoft.Json.Linq.JToken getEmotionForFile(string rawFilePath, string apiKey)
        {
            var cachePath = getCachePath(rawFilePath);
            var mediaPath = cachePath.Substring(cachePath.LastIndexOf("\\") + 1);

            if (!System.IO.Directory.Exists(mediaPath))
            {
                System.IO.Directory.CreateDirectory(mediaPath);
            }

            if (System.IO.File.Exists(cachePath))
            {
                return(Newtonsoft.Json.Linq.JToken.Parse(System.IO.File.ReadAllText(cachePath)));
            }

            using (var client = new System.Net.WebClient())
            {
                var payload = System.IO.File.ReadAllBytes(cachePath);

                client.Headers.Add("content-type", "application/octet-stream");
                client.Headers.Add("Ocp-Apim-Subscription-Key", apiKey);

                var response = client.UploadData("https://api.projectoxford.ai/emotion/v1.0/recognize", payload);
                System.IO.File.WriteAllBytes(cachePath, response);
                return(Newtonsoft.Json.Linq.JObject.Parse(System.Text.Encoding.UTF8.GetString(response)));
            }
        }
Exemple #12
0
        /// <summary>
        /// 调用租户接口推送数据
        /// </summary>
        /// <param name="url">租户接口url</param>
        /// <param name="type">修改值</param>
        /// <param name="value">修改类型</param>
        /// <param name="msg">文字说明</param>
        /// <param name="appId">应用接入id</param>
        /// <param name="appSecret">密钥</param>
        /// <returns></returns>
        public string PostDataUrl(string url, int type, int value, string msg, string appSecret, string studentNo, string projectCode, int classId)
        {
            string result     = string.Empty;
            string postString = string.Empty;


            try
            {
                string timeStamp = GetTimeStamp().ToString();                 //时间戳
                string nonce     = new Random().NextDouble().ToString();      //随机数
                string signature = GetSignature(appSecret, timeStamp, nonce); //签名加密字符串


                System.Net.WebClient WebClientObj = new System.Net.WebClient();
                WebClientObj.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                NameValueCollection PostVars = new NameValueCollection();
                postString = "type=" + HttpUtility.UrlEncode(type.ToString(), UTF8Encoding.UTF8) + "&value=" + HttpUtility.UrlEncode(value.ToString(), UTF8Encoding.UTF8) + "&message=" + HttpUtility.UrlEncode(msg, UTF8Encoding.UTF8) + "&signature=" + HttpUtility.UrlEncode(signature, UTF8Encoding.UTF8) + "&timestamp=" + HttpUtility.UrlEncode(timeStamp, UTF8Encoding.UTF8) + "&nonce=" + HttpUtility.UrlEncode(nonce, UTF8Encoding.UTF8) + "&studentno=" + HttpUtility.UrlEncode(studentNo, UTF8Encoding.UTF8) + "&projectcode=" + HttpUtility.UrlEncode(projectCode, UTF8Encoding.UTF8) + "&classsid=" + HttpUtility.UrlEncode(classId.ToString(), UTF8Encoding.UTF8);
                byte[] postData     = Encoding.UTF8.GetBytes(postString);
                byte[] responseData = WebClientObj.UploadData(url, "POST", postData);
                result = Encoding.UTF8.GetString(responseData);

                CommLog.WriteSystemLog("推送结果result=" + result + ";posturl=" + url + "?" + postString);
            }
            catch (Exception ex)
            {
                CommLog.WriteExceptionLog("调用租户接口推送数据时出现异常:" + ex.Message + ";posturl=" + url + "?" + postString);
                result = string.Empty;
            }
            return(result);
        }
Exemple #13
0
        /// <summary>
        /// 通过WebClient类Post数据到远程地址,需要Basic认证;
        /// 调用端自己处理异常
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="paramStr">name=张三&age=20</param>
        /// <param name="encoding">请先确认目标网页的编码方式</param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static string Request_WebClient(string uri, string method, string paramStr, Encoding encoding, string username, string password)
        {
            if (encoding == null)
            {
                encoding = Encoding.UTF8;
            }
            if (string.IsNullOrEmpty(method))
            {
                method = "POST";
            }

            System.Net.WebClient wc = new System.Net.WebClient();

            // 采取POST方式必须加的Header
            wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

            byte[] postData = encoding.GetBytes(paramStr);

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                //wc.Credentials = GetCredentialCache(uri, username, password);
                //wc.Headers.Add("Authorization", GetAuthorization(username, password));
            }

            byte[] responseData = wc.UploadData(uri, method, postData); // 得到返回字符流
            return(encoding.GetString(responseData));                   // 解码
        }
Exemple #14
0
        static void Main(string[] args)
        {
            Console.Title = "支付回调代理服务";

            WriteLog("正在启动服务 ..");
            var http = new HttpListener();
            http.StartListen();
            WriteLog("支付回调代理服务启动完成 ..");
            Console.WriteLine();

            while (true)
            {
                WriteLog("按任意键触发一个http模拟请求 ..");
                Console.ReadKey();

                WriteLog("正在模拟Http请求 ..");
                var httpClient = new System.Net.WebClient();
                httpClient.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
                var postString = "type=test&time=" + DateTime.Now.ToString(@"yyyy\/MM\/dd HH:mm:ss");

                var bytes = httpClient.UploadData(AppConfig.HttpURL, "post", Encoding.UTF8.GetBytes(postString));
                var response = Encoding.UTF8.GetString(bytes);

                WriteLog("服务器收到参数:" + response);
                WriteLog("请检查tcp客户端是否收到模拟请求的参数 ..");
            }
        }
Exemple #15
0
 public override void _Send()
 {
     System.Net.WebClient client = new System.Net.WebClient();
     client.Headers.Add("content-type", "application/json");//set your header here, you can add multiple headers
     byte[] response = client.UploadData("http://192.168.2.1:9393/id0/screenshots/" + this.frame.index, "POST", Encoding.Default.GetBytes("{\"frame\": " + this.frame.index + "}"));
     string s = Encoding.ASCII.GetString(response);
     this._OnWorkerSuccess();
 }
Exemple #16
0
        private void sendQQ()
        {
            System.Net.WebClient _client = new System.Net.WebClient();
            string postValues            = "VER=1.0&amp;CMD=Query_Stat&amp;SEQ=540882930&amp;UIN=2560985023&amp;TN=50&amp;UN=0";

            Byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(postValues);
            Byte[] pageData  = _client.UploadData("Host", "POST", byteArray);
        }
Exemple #17
0
        public override void _Send()
        {
            System.Net.WebClient client = new System.Net.WebClient();
            client.Headers.Add("content-type", "application/json");//set your header here, you can add multiple headers
            byte[] response = client.UploadData("http://192.168.2.1:9393/id0/screenshots/" + this.frame.index, "POST", Encoding.Default.GetBytes("{\"frame\": " + this.frame.index + "}"));
            string s        = Encoding.ASCII.GetString(response);

            this._OnWorkerSuccess();
        }
Exemple #18
0
        public string GetPostStr(string url, string senddata)
        {
            System.Net.WebClient webc = new System.Net.WebClient();
            var    apiurl             = new Uri(url);
            string sendstr            = senddata;
            var    arr = webc.UploadData(apiurl, Encoding.UTF8.GetBytes(sendstr));

            return(Encoding.UTF8.GetString(arr));
        }
 public void btnSend_Click(object sender, EventArgs e)
 {
     if (System.IO.File.Exists(_filename))
     {
         byte[] contents = System.IO.File.ReadAllBytes(_filename);
         System.Net.WebClient wc = new System.Net.WebClient();
         wc.UploadData("http://localhost:1153/WebTest/bytescout/Default.aspx", contents);
     }
 }
        protected void ButtonUpload_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["DeckId"] == null)
            {
                Response.Redirect("Default");
            }
            string DeckId = Request.QueryString["DeckId"];

            if (!FileUploadCSV.FileName.EndsWith(".csv") && !FileUploadCSV.FileName.EndsWith(".tsv"))
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(),
                                                        "alertMessage", @"alert('" + "File MUST be a .CSV/.TSV (You can save to this from Excel/Sheets)" + "')", true);
                return;
            }

            StreamReader reader   = new StreamReader(FileUploadCSV.FileContent);
            string       Line     = "";
            string       QueryURL = Utilities.ServerDNS + "/InsertCard";

            while ((Line = reader.ReadLine()) != null)
            {
                List <string> LineValues = new List <string>();
                if (FileUploadCSV.FileName.EndsWith(".tsv"))
                {
                    LineValues = Line.Split('\t').ToList();
                }
                else
                {
                    LineValues = Regex.Split(Line, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)").ToList();
                }
                Card Card = new Card();
                Card.VerbatimDeckId = Int32.Parse(DeckId);
                Card.Title          = LineValues[0].ToString();
                Card.Description    = LineValues[1].ToString();
                Card.Category       = LineValues[2].ToString();
                Card.PointValue     = Int32.Parse(LineValues[3].ToString());
                if (LineValues.Count > 4 && LineValues[4] != null)
                {
                    Card.PictureURL = LineValues[4].ToString();
                }

                using (var client = new System.Net.WebClient())
                {
                    try
                    {
                        client.UploadData(QueryURL, "PUT", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Card)));
                    }
                    catch
                    {
                    }
                }
            }
            reader.Close();

            Response.Redirect("DeckCardsView.aspx?DeckId=" + Request.QueryString["DeckId"]);
        }
Exemple #21
0
 public static string AddMenu(string accessToken, string menu)
 {
     using (var wc = new System.Net.WebClient())
     {
         var data = Utities.GetBytesFromString(menu);
         var url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessToken;
         var res = wc.UploadData(url, data);
         return Utities.GetStringFromBytes(res);
     }
 }
Exemple #22
0
 public static string AddMenu(string accessToken, string menu)
 {
     using (var wc = new System.Net.WebClient())
     {
         var data = Utities.GetBytesFromString(menu);
         var url  = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessToken;
         var res  = wc.UploadData(url, data);
         return(Utities.GetStringFromBytes(res));
     }
 }
Exemple #23
0
        public void Execute(params object[] list)
        {
            /*if (Configuration ["provider"] == "google") {
             *
             * } else if (Configuration ["provider"] == "osm") {
             *
             * } else if (Configuration ["provider"] == "bing") {
             *
             * }*/
            FeuerwehrCloud.Helper.Logger.WriteLine("|  +  [Maps] Preparing map...");
            string File = System.IO.File.ReadAllText("map.html");
            string TF   = System.IO.Path.GetTempFileName() + ".html";

            File = File.Replace("{STARTPOS}", Configuration["start"]);
            File = File.Replace("{ZOOM}", Configuration["zoom"]);
            File = File.Replace("{LOCATION}", string.Format("{0},{1}", (string)list[1], (string)list[2]));
            if (((string)list[2]).StartsWith("B"))
            {
                File = File.Replace("##PRE##", "");
                File = File.Replace("##POST##", "");
            }
            else
            {
                File = File.Replace("##PRE##", "/* KEIN BRANDEINSATZ !");
                File = File.Replace("##POST##", "*/");
            }

            System.IO.File.WriteAllText(TF + ".html", File);
            //--disable-smart-shrinking
            FeuerwehrCloud.Helper.Logger.WriteLine("|  +  [Maps] Printing map...: " + TF + ".pdf");

            //string result1 = FeuerwehrCloud.Helper.Helper.exec ("/bin/wkhtmltopdf", " -O landscape --custom-header  \"Accept-Language\" \"de_DE,de;q=0.8,ja;q=0.6,en;q=0.4\" --enable-javascript --no-stop-slow-scripts --javascript-delay 15000 --no-header-line --no-footer-line --print-media-type --margin-top 2 -s A4 -d 300 "+TF+".html "+TF+".pdf");

            using (System.Net.WebClient wc = new System.Net.WebClient())
            {
                wc.Headers[System.Net.HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                string XData = File.Replace("{LOCATION}", (string)list [1] + "," + (string)list [2]);
                XData = "data=" + System.Web.HttpUtility.UrlEncode(XData);
                byte[] Result = wc.UploadData(new Uri("http://apps.soomba.de/api/html2pdf.php"), "POST", System.Text.Encoding.Default.GetBytes(XData));
                System.IO.File.WriteAllBytes(TF + ".pdf", Result);
            }



            if (System.IO.File.Exists(TF + ".pdf"))
            {
                string result2 = FeuerwehrCloud.Helper.Helper.exec("/usr/bin/lpr", " -#" + CopiesConfig["count"] + " -o landscape  -o fit-to-page -o media=A4 " + TF + ".pdf");
            }
            else
            {
                FeuerwehrCloud.Helper.Logger.WriteLine("|  +  [Maps] *** MAP CREATION FAILED! ***");
            }
            //if(System.IO.File.Exists(TF+".html")) System.IO.File.Delete(TF+".html");
            //if(System.IO.File.Exists(TF+".pdf")) System.IO.File.Delete(TF+".pdf");
        }
Exemple #24
0
 static void Main(string[] args)
 {
     if (ConfigurationManager.AppSettings["CheckAWCCall"].Equals("1", StringComparison.OrdinalIgnoreCase))
     {
         using (var client = new System.Net.WebClient())
         {
             var data        = CreateShippingScheduleResponse();
             var requestData = Encoding.ASCII.GetBytes(data);
             client.Headers.Add("Content-Type", "text/xml;charset=utf-8");
             client.Headers.Add("SOAPAction", "ShippingScheduleResponseProcess");
             try
             {
                 var responseData = client.UploadData("https://biztalkprod.woodmark.com/Maestro/WcfService_Maestro.svc", requestData);
                 var response     = Encoding.ASCII.GetString(responseData);
             }
             catch (Exception ex)
             {
             }
             finally
             {
                 client.Dispose();
             }
         }
     }
     else
     {
         Console.BackgroundColor = ConsoleColor.Black;
         var prgObject = new Program();
         prgObject.CallPBSAndUpdateVariable();
         if (prgObject.AllPBSOrder.Count > 0)
         {
             do
             {
                 Console.BackgroundColor = ConsoleColor.Black;
                 Console.WriteLine("Please enter 'n' If you want to stop order search or 'y' if you want to continue");
                 var currentInput = Console.ReadLine();
                 if (currentInput.Trim() == "n")
                 {
                     break;
                 }
                 else
                 {
                     prgObject.GetOrderFromCachedResult(prgObject);
                 }
             } while (true);
         }
         else
         {
             Console.BackgroundColor = ConsoleColor.Red;
             Console.ForegroundColor = ConsoleColor.White;
             Console.WriteLine("NO ORDERS IN CACHE");
         }
     }
 }
Exemple #25
0
        //易班端口调用  易班轻应用
        public void ProcessRequest(HttpContext context)
        {
            //2017 0905   目前使用的易班账户是 15307179930
            var appid  = "28a9bb3bd738ffdb";
            var secret = "415e7189ec176d377fffc3678b732079";

            var code  = context.Request.QueryString["code"];  //code授权码
            var state = context.Request.QueryString["state"]; //state防止拦截攻击

            if (string.IsNullOrEmpty(code))
            {
                var url = string.Format("https://openapi.yiban.cn/oauth/authorize?client_id={0}&redirect_uri=http%3a%2f%2fzhanglidaoyan.com&state=STATE", appid);
                context.Response.Redirect(url);
                return;
            }
            else
            {
                //WebClient 发送 Post请求
                string postString = "client_id=" + appid + "&client_secret=" + secret + "&code=" + code + "&redirect_uri=" + "http://zhanglidaoyan.com";
                byte[] postData   = Encoding.UTF8.GetBytes(postString);//将字符串转换为UTF-8编码
                string url        = "https://openapi.yiban.cn/oauth/access_token";
                System.Net.WebClient webclient = new System.Net.WebClient();
                webclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");        //POST 请求在头部必须添加
                byte[] responseData = webclient.UploadData(url, "POST", postData);                 //发起POST请求、返回byte字节
                string srcString    = Encoding.UTF8.GetString(responseData);                       //将byte字节转换为字符串

                var       serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); //解析JSON数据
                JsonModel obj        = serializer.Deserialize <JsonModel>(srcString);

                if (obj != null)
                {
                    //获取到用户ID  AccessToken
                    Client <qingjia_AccessToken>    client = new Client <qingjia_AccessToken>();
                    ApiResult <qingjia_AccessToken> result = client.GetRequest("YiBanID=" + obj.userid, "/api/oauth/access_token");

                    if (result.result == "success" || result.data != null)
                    {
                        //获取授权
                        context.Response.Redirect("qingjia_WeChat.aspx?access_token=" + result.data.access_token);
                    }
                    else
                    {
                        //qingjia 授权失败 跳转到绑定页面
                        context.Response.Redirect("./SubPage/bind.aspx?YiBanID=" + obj.userid);
                    }
                }
                else
                {
                    //未获取到易班授权授权 跳转到错误页面
                    context.Response.Redirect("Error.aspx");
                }
            }
        }
Exemple #26
0
        /// <summary>
        /// POST WebClient
        /// </summary>
        public static void TestGet()
        {
            Console.Write("download uri: ");
            var inputUri = Console.ReadLine();

            System.Net.WebClient client = new System.Net.WebClient();
            //client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            //var encoding = Encoding.UTF8.GetBytes()
            var resBytes = client.UploadData(inputUri, "GET", new byte[] { });
            var res      = Encoding.UTF8.GetString(resBytes);

            Console.WriteLine(res);
        }
        /// <summary>
        /// 多次调用Post请求返回 HTML信息
        /// </summary>
        /// <param name="url"></param>
        /// <param name="postString"></param>
        /// <returns></returns>
        public static string HttpAspxPostHtmlInfo(string url, string postString, string type)
        {
            byte[] postData = Encoding.UTF8.GetBytes(postString);//编码,事先要看下抓取网页的编码方式
            System.Net.WebClient webClient = new System.Net.WebClient();
            if (type == "post")
            {
                webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); //采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可
            }
            byte[] responseData = webClient.UploadData(url, "POST", postData);              //得到返回字符流
            var    retString    = Encoding.UTF8.GetString(responseData);                    //解码返回请求的html 内容

            return(retString);
        }
Exemple #28
0
        //获取token和ticket
        private async Task <string> GetTicketAsync()
        {
            var tokenUrl = $"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={APP_SECRET}";

            var client = new System.Net.WebClient();

            client.Encoding = Encoding.UTF8;
            client.Headers.Add("Content-Type", "Application/x-www-form-urlencoded");
            var responseData = client.UploadData(tokenUrl, "POST", new byte[0]);
            var responseText = Encoding.UTF8.GetString(responseData);
            var token        = JsonConvert.DeserializeAnonymousType(responseText, new { access_token = "", expires_in = "" });


            Token = token.access_token;
            var ticketUrl       = $"https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={Token}&type=jsapi";
            var ticResponseData = client.UploadData(ticketUrl, "POST", new byte[0]);
            var ticResponseText = Encoding.UTF8.GetString(ticResponseData);
            var ticket          = JsonConvert.DeserializeAnonymousType(ticResponseText, new { errcode = "", errmsg = "", ticket = "", expires_in = "" });

            Ticket = ticket.ticket;
            return("");
        }
Exemple #29
0
        public static string Post(this System.Net.WebClient web, XElement form, Uri baseUrl = null, System.Text.Encoding encoding = null)
        {
            var values = form.SerializeData();
            var action = (string)form.Attribute("action");

            web.Headers[System.Net.HttpRequestHeader.ContentType] = values.Item1;

            var url = action.ToUri(baseUrl ?? web.ResponseHeaders[System.Net.HttpResponseHeader.Location].ToUri());

            var data = web
                       .UploadData(url, ((string)form.Attribute("method")).NotEmpty("post").ToUpper(), values.Item2);

            return((encoding ?? System.Text.Encoding.Default).GetString(data));
        }
Exemple #30
0
        public void UploadMultipart(byte[] file, string filename, string contentType, string url)
        {
            using (var webClient = new System.Net.WebClient())
            {
                string boundary = "------------------------" + DateTime.Now.Ticks.ToString("x");
                webClient.Headers.Add("Content-Type", "multipart/form-data; boundary=" + boundary);
                var fileData = webClient.Encoding.GetString(file);
                var package  = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"file\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n{3}\r\n--{0}--\r\n", boundary, filename, contentType, fileData);

                var nfile = webClient.Encoding.GetBytes(package);

                byte[] resp     = webClient.UploadData(url, "POST", nfile);
                var    response = Encoding.UTF8.GetString(resp);
            }
        }
Exemple #31
0
 /// <summary>
 /// 关闭流对象
 /// </summary>
 public override void Close()
 {
     base.Close();
     if (_BaseStream != null)
     {
         _BaseStream.Close();
     }
     if (string.IsNullOrEmpty(_SaveUrl) == false && _BaseStream is System.IO.MemoryStream)
     {
         byte[] bs = ((System.IO.MemoryStream)_BaseStream).ToArray();
         using (System.Net.WebClient client = new System.Net.WebClient())
         {
             client.UploadData(this._SaveUrl, bs);
         }
     }
 }
Exemple #32
0
        private Model ReadValues(Model requestModel)
        {
            string url     = "http://" + Ip + "/cgi-bin/ILRReadValues.cgi";
            var    request = Serialize(requestModel);
            Model  model;

            using (var client = new System.Net.WebClient())
            {
                client.Headers.Add("Content-Type", "text/xml");
                client.Headers.Add("User-Agent", "SpiderControl/1.0(iniNet-Solutions GmbH)");
                var response = client.UploadData(url, "POST", request);
                model = Deserialize(response);
            }

            return(model);
        }
        public string putSnapshot()
        {
            List <RequestValue> seznam = new List <RequestValue>();
            RequestValue        x      = new RequestValue();

            x.tableName  = "tabulka";
            x.columnName = "iSF1_Mass";
            x.valueType  = tValueType.integer;
            x.iValue     = 12345;
            x.iQoS       = 100;
            seznam.Add(x);

            BinaryFormatter     bf             = new BinaryFormatter();
            MemoryStream        memStreamReq   = new MemoryStream();
            object              responseObject = new object();
            List <RequestValue> responseList   = new List <RequestValue>();

            responseList.Add(new RequestValue {
                tableName = "Data Not solved", columnName = "Response is bad"
            });
            string url = @"https://users-dev.diosna.cz/api/ValuesApi/putSnapshot/164017/123456789/";

            url = "https://localhost:44385/api/ValuesApi/putSnapshot/164017/123456789/";
            //var byteArray = Encoding.UTF8.GetBytes("Neco desne zajimave3h0oweg");


            bf.Serialize(memStreamReq, seznam);

            byte[] listBytes = memStreamReq.ToArray();
            using (var client = new System.Net.WebClient())
            {
                byte[] responseData = client.UploadData(url, "PUT", listBytes);

                /*
                 *
                 * MemoryStream memStreamResp = new MemoryStream(responseData);
                 * responseObject = bf.Deserialize(memStreamResp);
                 *
                 * if (responseObject is List<RequestValue>)
                 * {
                 *   responseList = (List<RequestValue>)responseObject;
                 * }
                 */
            }

            return(responseList[0].tableName + " " + responseList[0].columnName);
        }
Exemple #34
0
    private void Page_Load(object sender, System.EventArgs e)
    {
        //put user code to initialise page here
        var client = new System.Net.WebClient();

        client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

        var data = System.Text.Encoding.ASCII.GetBytes(
            "clientid=[clientid]&password=[password]&oid=[orderid]&" +
            "chargetype=PreAuth&currencycode=826&total=[total]");

        var response = client.UploadData(
            "https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdqEncTool.e",
            "POST", data);

        Session["Response"] = System.Text.Encoding.ASCII.GetString(response);
    }
Exemple #35
0
        async Task RunUnitTests()
        {
            var tat  = typeof(NUnit.Framework.TestAttribute);
            var tfat = typeof(NUnit.Framework.TestFixtureAttribute);

            var types = typeof(DrawingTest).Assembly.GetTypes();
            var tfts  = types.Where(t => t.GetCustomAttributes(tfat, false).Length > 0);

            var ngd = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);

            PlatformTest.ResultsDirectory = System.IO.Path.Combine(ngd, "TestResults");
            PlatformTest.Platform         = Platforms.Current;
            System.IO.Directory.CreateDirectory(PlatformTest.ResultsDirectory);
//			System.Environment.CurrentDirectory = PlatformTest.ResultsDirectory;

            foreach (var t in tfts)
            {
                var test = Activator.CreateInstance(t);
                var ms   = t.GetMethods().Where(m => m.GetCustomAttributes(tat, true).Length > 0);
                foreach (var m in ms)
                {
                    try {
                        var r  = m.Invoke(test, null);
                        var ta = r as Task;
                        if (ta != null)
                        {
                            await ta;
                        }
                    } catch (Exception ex) {
                        Console.WriteLine(ex);
                    }
                }
            }

            var client = new System.Net.WebClient();
            var pngs   = System.IO.Directory.GetFiles(PlatformTest.ResultsDirectory)
                         .Where(p => {
                var e = System.IO.Path.GetExtension(p);
                return(e == ".svg" || e == ".png");
            });

            foreach (var f in pngs)
            {
                client.UploadData("http://192.168.1.142:1234/" + System.IO.Path.GetFileName(f), System.IO.File.ReadAllBytes(f));
            }
        }
        //private string timestampPrefix()
        //{
        //    return DateTime.Now.ToString("yyyyMMddHHmmssFFFFFFF");
        //}
        private Message sendMessage(Message request, bool encryptMessage)
        {
            lock (request)
            {
                //TODO: learn how to use compile flags
                //request.ToFile(timestampPrefix() + "_request.xml");

                //calibrate
                if (nextCalibrate == null || nextCalibrate < DateTime.Now)
                {
                    request.ReplaceControlValue(Message.LibraryVersionControlValueName, InternalLibraryVersion.GetLibraryVersion().ToString());

                    nextCalibrate = DateTime.Now.Add(calibrateFrequency);
                }

                System.Net.WebClient webClient = new System.Net.WebClient();

                if (accessKey != null)
                    webClient.QueryString[Message.AccessKeyHeaderName] = accessKey;

                //set encryption is using...
                Aes aes = null;
                if (encryptionKey != null)
                {
                    try
                    {
                        aes = StreamUtilities.GetAesCryptoTransform(encryptionKey, null);
                    }
                    catch (CryptographicException exception)
                    {
                        throw new Exceptions.CommunicationException("Encryption exception.  Is the encryption key the right length?", exception);
                    }
                }

                //message is all ready to go.
                MemoryStream outgoingStream = new MemoryStream();
                Common.WriteMessageStream(outgoingStream, request, sessionKey, aes, encryptMessage);

                //TODO: fix these last-minute converstions to/from arrays
                byte[] responseBytes;
                try
                {
                    responseBytes = webClient.UploadData(url, outgoingStream.ToArray());
                }
                catch (System.Net.WebException exception)
                {
                    throw new Exceptions.CommunicationException(exception.Message);
                }
                MemoryStream responseStream = StreamUtilities.ToMemoryStream(responseBytes);

                Message response = responseStream.ToMessage(aes);

                //update sessionKey
                if (response.controlValues.ContainsKey(Message.NewSessionKeyControlValueName))
                    sessionKey = response.controlValues[Message.NewSessionKeyControlValueName];

                //response.ToFile(timestampPrefix() + "_response.xml");
                return response;
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            strCollCode = this.cmbCollName.SelectedValue.ToString();
            strCoalKindCode = this.cmbCoalKind.SelectedValue.ToString();
            #region
            //------------�жϺ���-����-2010-3-12-----
            if (1 == CMainForm.IsHaveRed)
            {
                if (!CMainForm.IsRightPosition)
                {
                    alarmSound.Alarm("����������");
                    return;
                }
            }
            //----------------------------------------
            #endregion

            CoalTraffic.Model.TT_LoadWeight model = new CoalTraffic.Model.TT_LoadWeight();

            if (strCurrentMenu != "Person")
            {
                model.LoadWeight = Convert.ToDecimal(lblDigital.Text);
                model.NetWeight = Convert.ToDecimal(lblDigital.Text) - Convert.ToDecimal(txtEmptyWeight.Text.Trim());
            }
            else
            {
                #region ��֤���ݵ���ȷ��
                if (txtHandDigital.Text.Trim() != "" && CommonMethod.IsDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())))
                {
                    if (Convert.ToDecimal(CommonMethod.ToDBC(txtHandDigital.Text.Trim())) < Convert.ToDecimal(lblDigital.Text.Trim()))
                    {
                        alarmSound.Alarm("��������س���������С�ڰ�������");
                        txtHandDigital.Text = "";
                        return;
                    }
                    else
                    {
                        model.LoadWeight = Convert.ToDecimal(CommonMethod.ToDBC(this.txtHandDigital.Text.Trim()));
                        model.NetWeight = Convert.ToDecimal(CommonMethod.ToDBC(this.txtHandDigital.Text.Trim())) - Convert.ToDecimal(txtEmptyWeight.Text.Trim());
                    }
                }
                else
                {
                    alarmSound.Alarm("��������س�������ʽ����");
                    txtHandDigital.Text = "";
                    return;
                }
                #endregion
            }
            if (model.NetWeight > 0.00m)
            {

                #region ��ȡ����ҵ��ص���Ϣ
                SqlParameter[] parameter =
                {
                    new SqlParameter("@CollCode", SqlDbType.VarChar,10),
                    new SqlParameter("@CoalKindCode", SqlDbType.VarChar,4)
                };

                parameter[0].Value = strCollCode;
                parameter[1].Value = strCoalKindCode;
                DataSet dstColieryAccount = DbHelperSQL.RunProcedure("PT_ColieryAccountJudge", parameter, "ColieryAccount");
                #endregion

                string strLeastValue = dstColieryAccount.Tables["ColieryAccount"].Rows[0]["ReturnValue"].ToString();

                if (strLeastValue == "0") //0���������ɹ���
                {
                    #region ��Ƶץͼ
                    if (StaticParameter.IsVideo == "1")
                    {
                        if (byteFrontImage == null && byteBackImage == null && byteUpImage == null && byteRoomImage == null)
                        {
                            //strFrontImage = Guid.NewGuid().ToString().Replace("-", "");
                            //strBackImage = Guid.NewGuid().ToString().Replace("-", "");
                            //strUpImage = Guid.NewGuid().ToString().Replace("-", "");
                            //strRoomImage = Guid.NewGuid().ToString().Replace("-", "");

                            byteFrontImage = this.videoFrontImage.CapturePic();
                            byteBackImage = this.videoBackImage.CapturePic();
                            byteUpImage = this.videoUpImage.CapturePic();
                            byteRoomImage = this.videoRoomImage.CapturePic();
                        }
                    }
                    #endregion

                    #region ʵ�����س�
                    string strWeightCode = strRoomCode + DateTime.Now.ToString("yyyyMMddHHmmss");
                    model.WeightCode = strWeightCode;
                    model.TrafficCode = cementName;//strWeightCode;
                    model.NavicertCode = strNavicertCode;
                    model.MarkedCardCode = strMardedCardCode;
                    model.RemoteCardCode = strRemoteCode;

                    model.CollCode = strCollCode;
                    model.CollName = this.cmbCollName.Text;
                    model.CoalKindCode = this.strCoalKindCode;
                    //���� 2010-05-19 ѡ���Ʒ�ij�������
                    model.CoalKindName = this.cmbCoalKind.Text;
                    //model.CoalKindName = this.txtKindName.Text.Trim();
                    model.CarOwnerName = strCarOwnerName;

                    model.CarNo = txtCarNo.Text;
                    model.CarType = txtCarType.Text;
                    model.EmptyWeight = Convert.ToDecimal(txtEmptyWeight.Text);

                    model.OverWeight = 0;
                    model.RoomCode = strRoomCode;
                    model.RoomName = strRoomName;
                    model.BangType = strBangType;
                    model.Operator = StaticParameter.UserName;

                    model.WeightTime = DateTime.Now;
                    model.RandomCode = CommonMethod.getRandom(4);
                    model.CustomerName = "ˮ��ȥ��";
                    model.IsFirstSite = "1";
                    model.TaxType = "�س�������˰";

                    model.FrontImage = strFrontImage;
                    model.BackImage = strBackImage;
                    model.UpImage = strUpImage;
                    model.RoomImage = strRoomImage;
                    model.FrontImageContent = byteFrontImage;

                    model.BackImageContent = byteBackImage;
                    model.UpImageContent = byteUpImage;
                    model.RoomImageContent = byteRoomImage;
                    model.TaxObject = ConfigurationManager.AppSettings["TaxObject"].ToString();
                    model.EmptyCode = strEmptyCode;
                    #endregion

                    if (bll.Add(model) != "")
                    {
                        if (bll.Add(model) != "-1")
                        {
                            #region ��ӳɹ���������ͬ��
                            try
                            {
                                string strSql = "PT_LoadWeight '" + model.WeightCode + "','" + model.TrafficCode + "','" + model.NavicertCode + "','" + model.MarkedCardCode + "','" + model.RemoteCardCode + "',"
                                 + "'" + model.CollCode + "','" + model.CollName + "','" + model.CoalKindCode + "','" + model.CoalKindName + "','" + model.CarOwnerName + "',"
                                 + "'" + model.CarNo + "','" + model.CarType + "','" + model.LoadWeight + "','" + model.EmptyWeight + "','" + model.NetWeight + "',"
                                 + "'" + model.OverWeight + "','" + model.RoomCode + "','" + model.RoomName + "','" + model.BangType + "','" + model.Operator + "',"
                                 + "'" + model.WeightTime + "','" + model.RandomCode + "','" + model.CustomerName + "','" + model.TaxType + "','" + model.TaxObject + "',"
                                 + "'" + model.IsFirstSite + "','" + model.FrontImage + "','" + model.BackImage + "','" + model.UpImage + "','" + model.RoomImage + "',"
                                 + "null,null,null,null,'" + model.EmptyCode + "'";
                                mq.AddNewSqlText(mq.CheckStation + mq.Prefix + "TT_LoadWeight" + mq.Prefix + mq.AddFlg + mq.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm;ss") + mq.Prefix + strSql);

                                //����ͼƬ
                                try
                                {
                                    //����ͼƬ ����ashx���ϴ�ͼƬ
                                    System.Net.WebClient webclient = new System.Net.WebClient();
                                    if (byteFrontImage != null)
                                    {
                                        webclient.UploadData(ini.IniReadValue("PicterRoute", "PRoute")+ model.WeightCode + "&filename=1", byteFrontImage);
                                    }
                                    if (byteBackImage != null)
                                    {
                                        webclient.UploadData(ini.IniReadValue("PicterRoute", "PRoute") + model.WeightCode + "&filename=2", byteBackImage);
                                    }
                                    if (byteUpImage != null)
                                    {
                                        webclient.UploadData(ini.IniReadValue("PicterRoute", "PRoute") + model.WeightCode + "&filename=3", byteUpImage);
                                    }
                                    if (byteRoomImage != null)
                                    {
                                        webclient.UploadData(ini.IniReadValue("PicterRoute", "PRoute") + model.WeightCode + "&filename=4", byteRoomImage);
                                    }
                                }
                                catch
                                {

                                }
                                /********************************************************/
                                //Add By ����ӭ ��BSʵʱ��ط�������Ϣ���з����س�������Ϣ
                                /********************************************************/
                                string loadMessage = model.EmptyWeight.ToString() + "," + model.LoadWeight.ToString() + "," + model.NetWeight.ToString() + "," + model.OverWeight.ToString() + "," + model.TaxAmount.ToString() + "," + model.FundAmount.ToString() + "," + model.Operator.ToString() + "," + model.WeightTime.ToString()
                                + "," + model.CarNo.ToString() + "," + model.CarOwnerName.ToString() + "," + model.RoomName.ToString() + "," + model.CollName.ToString() + "," + model.CoalKindName.ToString() + "," +
                                model.NavicertCode.ToString() + "," + model.MarkedCardCode.ToString() + "," + model.RemoteCardCode.ToString() + "," + model.WeightCode.ToString();//������Ϣ��ʽ���ճ�����,�س�����,����,����,˰��,����,������,����ʱ��,���ƺ�,��������,��������,ú������,ú������,׼�˿���,��ʶ����,Զ�̿���,��������
                                RealTimeMonitor monitor = new RealTimeMonitor();//������Ϣ
                                monitor.SendLoadWeightMessage(loadMessage);
                                /********************************************************/

                            }
                            catch { }
                            #endregion

                            string strErro = "";
                            if (StaticParameter.IsHaveMarkedCard == "1")
                            {
                                strErro = "�����ձ�ʶ��";
                            }
                            if (StaticParameter.FormType == "2")  //��Ʊվ�޴�ӡ�� �����ӡ
                            {
                                alarmSound.Alarm("�����ɹ�");
                                CommonMethod.MessageBox("�����ɹ�", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            }
                            else
                            {
                                alarmSound.Alarm("�����ɹ�,���ȷ����ӡ�س�������" + strErro + "");
                                CommonMethod.MessageBox("�����ɹ�,���ȷ����ӡ�س�������" + strErro + "!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                                //�������ó�ر�־λ
                                this.isks = true;

                                Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                                string strFileName = "";

                                strFileName = StaticParameter.ReportFile;

                                Type type = assembly.GetType("CoalTraffic.Report." + strFileName + "LoadWeightPrint");
                                object obj = Activator.CreateInstance(type, strWeightCode, true); Form formToShow = (Form)obj; formToShow.ShowDialog();
                            }
                        }
                        else
                        {
                            alarmSound.Alarm("�˻�����Ѳ��㱾���Ŀۿ��֪ͨ" + this.cmbCollName.Text.Trim() + "��������");
                        }
                    }
                    else
                    {
                        this.alarmSound.Alarm("��վ�����ݿ��쳣");
                        InsertState = 0;
                        InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), strRoomName + "�����ݿ��쳣");
                    }
                }
                else if (strLeastValue == "1")
                {
                    alarmSound.Alarm("��ҵ����������,���ܼ�������");
                }
                else if (strLeastValue == "2")
                {
                    alarmSound.Alarm("����ҵ�������ò�Ʒ,���ܼ�������");
                    InsertState = 0;
                    InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), strCollName + "������" + strCoalKindName);
                }
                else if (strLeastValue == "-1")
                {
                    alarmSound.Alarm("����ҵ������,���ܼ�������");
                    InsertState = 0;
                    InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), "���Ϊ��" + strCollCode + "����ҵ������");
                }

                btnOK.Enabled = false;
                ClearAll();
                if (StaticParameter.CardType == "IC")
                    icCard.FactoryCodeInitValue = "";
            }
            else
            {
                alarmSound.Alarm("ˮ�ྻ���쳣");
                InsertState = 0;
                InsertBadReCordInfo("�쳣", txtCarNo.Text.Trim(), "���ƺ�Ϊ��" + txtCarNo.Text.Trim() + "������ˮ�ྻ���쳣");
            }
        }
        protected XmlDocument GetCcAuth(XmlDocument xDoc, string URL)
        {
            try
            {
                // get the data from the xml document into a byte stream
                var bdata = System.Text.Encoding.UTF8.GetBytes(xDoc.OuterXml);

                // instantiate a web client
                var wc = new System.Net.WebClient();

                // add appropriate headers
                wc.Headers.Add("Content-Type", "text/xml");

                // send data to server, and wait for a response
                var bresp = wc.UploadData(URL, bdata);

                // read the response
                var resp = System.Text.Encoding.ASCII.GetString(bresp);

                var xresp = new XmlDocument();

                xresp.LoadXml(resp);

                // return the xml document response from the server
                return xresp;
            }
            catch
            {
                // your error handler
                return null;
            }
        }