Esempio n. 1
0
        private void Excute(Stopwatch stopwatch = null)
        {
            try
            {
                var stopkey = Guid.NewGuid().ToString();
                txt_stopkey.Text = stopkey;
                rtxt_Result.Text = string.Empty;
                var    timeout = int.Parse(numeric_Timeout.Value.ToString());
                string result  = string.Empty;
                if (radio_local.Checked)
                {
                    //socket
                    result = SocketAccess.Access <string, string>(
                        txtType.Text,
                        rtxt_Param.Text,
                        timeout,
                        stopkey,
                        Convert.ToInt32(txtAddress.Text));
                }
                else
                {
                    //http
                    var url      = txtAddress.Text + txtType.Text;
                    var postData = rtxt_Param.Text.Replace("\n", "");
                    result = HttpHelper.Post(url, postData, null, timeout);
                }

                try
                {
                    rtxt_Result.Text = CommonCla.ConvertJsonString(result);
                }
                catch
                {
                    rtxt_Result.Text = result;
                }
            }
            catch (Exception ex)
            {
                try
                {
                    rtxt_Result.Text = CommonCla.ConvertJsonString(ex.Message);
                }
                catch
                {
                    rtxt_Result.Text = ex.Message;
                }
            }
            finally
            {
                if (stopwatch != null)
                {
                    stopwatch.Stop();
                }
            }
        }
Esempio n. 2
0
 public SocketAttribute(SocketAddresses aDeviceSocketAddr,
                        SocketAccess aAccess)
 {
     SocketAddress = aDeviceSocketAddr;
     Access        = aAccess;
 }