示例#1
0
        protected override void GetText()
        {
            this.Data = "";
            string text = string.Empty;

            text     += DataConvert.IpToHexStr(this.textBox3.Text);
            text     += DataConvert.IpToHexStr(this.textBox2.Text);
            text     += DataConvert.IpToHexStr(this.textBox5.Text);
            text     += this.comboBox1.SelectedIndex.ToString("X2");
            text     += DataConvert.IpToHexStr(this.textBox7.Text);
            text     += DataConvert.ReverseStr(int.Parse(this.textBox4.Text).ToString("X4"));
            text     += this.comboBox2.SelectedIndex.ToString("X2");
            text     += this.textBox8.Text.Trim().Length.ToString("X2");
            text     += DataConvert.ReverseStr(DataConvert.ASCIIToHexStr(this.textBox8.Text.Trim()));
            text     += this.textBox9.Text.Trim().Length.ToString("X2");
            text     += DataConvert.ReverseStr(DataConvert.ASCIIToHexStr(this.textBox9.Text.Trim()));
            text     += DataConvert.ReverseStr(int.Parse(this.textBox10.Text).ToString("X4"));
            this.Data = text;
        }
示例#2
0
        public string OperaSend(string Value, int Num, string type)
        {
            checked
            {
                string result;
                if (string.IsNullOrEmpty(Value) & type.Trim().ToUpper() != "ASCII")
                {
                    result = "";
                }
                else
                {
                    string text = string.Empty;
                    Value = Value.Trim();
                    string text2 = type.ToUpper();
                    switch (text2)
                    {
                    case "BIN":
                    {
                        long   num2      = long.Parse(Value);
                        string arg_323_0 = "X";
                        int    num       = Num * 2;
                        string val       = num2.ToString(arg_323_0 + num.ToString());
                        text = DataConvert.ReverseStr(val);
                        break;
                    }

                    case "":
                    case "BCD":
                        text = DataConvert.ReverseStr(Value.PadLeft(Num * 2, '0'));
                        break;

                    case "HEX":
                        text = Value.PadRight(Num * 2, '0');
                        break;

                    case "BS":
                    case "BS8":
                    case "BS16":
                    case "BS24":
                    case "BS32":
                    case "BS64":
                    {
                        string text3 = DataConvert.ReverseStr(Value, 1);
                        string text4 = string.Empty;
                        for (int i = 0; i < text3.Length; i += 8)
                        {
                            text4 += PubFuncHelper.BinToHex(text3.Substring(i, 8)).ToString("X2");
                        }
                        text += DataConvert.ReverseStr(text4);
                        break;
                    }

                    case "ASCII":
                        text = DataConvert.ASCIIToHexStr(Value).PadRight(Num * 2, '0');
                        break;

                    case "A2":
                    case "A3":
                    case "A4":
                    case "A5":
                    case "A6":
                    case "A9":
                    case "A25":
                        text = Value;
                        break;

                    case "A1":
                    {
                        Value = Value.Replace("年", "-");
                        Value = Value.Replace("月", "-");
                        Value = Value.Replace("日", " ");
                        Value = Value.Replace("时", ":");
                        Value = Value.Replace("分", ":");
                        Value = Value.Replace("秒", "");
                        string   text5    = string.Empty;
                        DateTime dateTime = DateTime.Parse(Value);
                        int      num      = dateTime.Second;
                        text5 = num.ToString("00");
                        string arg_49C_0 = text5;
                        num   = dateTime.Minute;
                        text5 = arg_49C_0 + num.ToString("00");
                        string arg_4BA_0 = text5;
                        num   = dateTime.Hour;
                        text5 = arg_4BA_0 + num.ToString("00");
                        string arg_4D8_0 = text5;
                        num   = dateTime.Day;
                        text5 = arg_4D8_0 + num.ToString("00");
                        int num3 = (int)dateTime.DayOfWeek;
                        if (num3 == 0)
                        {
                            num3 = 7;
                        }
                        num    = dateTime.Month;
                        text5 += (int.Parse(num.ToString(), NumberStyles.HexNumber) | num3 << 5).ToString("X2");
                        string arg_54D_0 = text5;
                        num   = dateTime.Year;
                        text5 = arg_54D_0 + num.ToString("0000").Substring(2, 2);
                        text  = text5;
                        break;
                    }

                    case "A7":
                    {
                        string text5 = string.Empty;
                        text5 = string.Format("{0:000.0}", decimal.Parse(Value));
                        text5 = text5.Replace(".", "");
                        text5 = DataConvert.ReverseStr(text5);
                        text  = text5;
                        break;
                    }

                    case "A8":
                    {
                        string text5 = string.Empty;
                        text5 = string.Format("{0:0000}", decimal.Parse(Value));
                        text5 = text5.Replace(".", "");
                        text5 = DataConvert.ReverseStr(text5);
                        text  = text5;
                        break;
                    }

                    case "A10":
                        text = DataConvert.ReverseStr(Value.PadLeft(6, '0'));
                        break;

                    case "A11":
                        text = DataConvert.ReverseStr(Value.PadLeft(8, '0'));
                        break;

                    case "A12":
                        text = DataConvert.ReverseStr(Value.PadLeft(12, '0'));
                        break;

                    case "A13":
                    {
                        string text5 = string.Empty;
                        text5 = string.Format("{0:0000.0000}", decimal.Parse(Value));
                        text5 = text5.Replace(".", "");
                        text5 = DataConvert.ReverseStr(text5);
                        text  = text5;
                        break;
                    }

                    case "A14":
                    {
                        string text5 = string.Empty;
                        text5 = string.Format("{0:000000.0000}", decimal.Parse(Value));
                        text5 = text5.Replace(".", "");
                        text5 = DataConvert.ReverseStr(text5);
                        text  = text5;
                        break;
                    }

                    case "A15":
                        Value = Value.Replace("年", "-");
                        Value = Value.Replace("月", "-");
                        Value = Value.Replace("日", " ");
                        Value = Value.Replace("时", ":");
                        Value = Value.Replace("分", ":");
                        Value = Value.Replace("秒", "");
                        text  = DataConvert.ReverseStr(Convert.ToDateTime(Value).ToString("yyMMddHHmm"));
                        break;

                    case "A16":
                    case "A17":
                    case "A18":
                    case "A19":
                        Value = Value.Replace("年", "-");
                        Value = Value.Replace("月", "-");
                        Value = Value.Replace("日", " ");
                        Value = Value.Replace("时", ":");
                        Value = Value.Replace("分", ":");
                        Value = Value.Replace("秒", "");
                        Value = Value.Replace(" ", "");
                        Value = Value.Replace(":", "");
                        Value = Value.Replace("-", "");
                        Value = Value.Replace(".", "");
                        text  = DataConvert.ReverseStr(Value);
                        break;

                    case "A20":
                        Value = Value.Replace("年", "-");
                        Value = Value.Replace("月", "-");
                        Value = Value.Replace("日", " ");
                        Value = Value.Replace("时", ":");
                        Value = Value.Replace("分", ":");
                        Value = Value.Replace("秒", "");
                        text  = DataConvert.ReverseStr(Convert.ToDateTime(Value).ToString("yyMMdd"));
                        break;

                    case "A21":
                        Value = Value.Replace("年", "-");
                        Value = Value.Replace("月", "-");
                        Value = Value.Replace("日", " ");
                        Value = Value.Replace("时", ":");
                        Value = Value.Replace("分", ":");
                        Value = Value.Replace("秒", "");
                        Value = Convert.ToDateTime(Value).ToString("yy-MM");
                        Value = Value.Replace(" ", "");
                        Value = Value.Replace(":", "");
                        Value = Value.Replace("-", "");
                        Value = Value.Replace(".", "");
                        text  = DataConvert.ReverseStr(Value);
                        break;

                    case "A22":
                    {
                        string text5 = string.Empty;
                        text5 = string.Format("{0:0.0}", float.Parse(Value));
                        text  = text5.Replace(".", "");
                        break;
                    }

                    case "A23":
                    {
                        string text5 = string.Empty;
                        text5 = string.Format("{0:00.0000}", float.Parse(Value));
                        text5 = text5.Replace(".", "");
                        text  = DataConvert.ReverseStr(text5);
                        break;
                    }

                    case "A24":
                        Value = Value.Replace("年", "-");
                        Value = Value.Replace("月", "-");
                        Value = Value.Replace("日", " ");
                        Value = Value.Replace("时", ":");
                        Value = Value.Replace("分", ":");
                        Value = Value.Replace("秒", "");
                        Value = Value.Replace(" ", "");
                        Value = Value.Replace(":", "");
                        Value = Value.Replace("-", "");
                        Value = Value.Replace(".", "");
                        text  = DataConvert.ReverseStr(Value);
                        break;

                    case "A26":
                    {
                        string text5 = string.Empty;
                        text5 = string.Format("{0:0.000}", float.Parse(Value));
                        text5 = text5.Replace(".", "");
                        text  = DataConvert.ReverseStr(text5);
                        break;
                    }

                    case "A27":
                        Value = Value.Replace(" ", "");
                        Value = Value.Replace(":", "");
                        Value = Value.Replace("-", "");
                        Value = Value.Replace(".", "");
                        text  = DataConvert.ReverseStr(Value.PadLeft(8, '0'));
                        break;
                    }
                    result = text;
                }
                return(result);
            }
        }