Example #1
0
        private void 数据点抄ToolStripMenuItemClick(object sender, EventArgs e)
        {
            this.grid1.EndEdit();
            Program.gList.Clear();
            DataGridView gridV = MainForm.gMainForm.gAddressList.GridV;

            checked
            {
                for (int i = 0; i < gridV.Rows.Count; i++)
                {
                    Program.AddList item = default(Program.AddList);
                    if (!gridV.Rows[i].IsNewRow)
                    {
                        item.Checked = Convert.ToBoolean(gridV.Rows[i].Cells[0].Value);
                        item.A1      = Convert.ToString(gridV.Rows[i].Cells[2].Value);
                        item.A2      = Convert.ToString(gridV.Rows[i].Cells[3].Value);
                        item.Mode    = Program.GetLeiXing(Convert.ToString(gridV.Rows[i].Cells[4].Value));
                        Program.gList.Add(item);
                    }
                }
                if (Program.gList.Count == 0)
                {
                    MessageBox.Show("请先初始化终端列表 !", "失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    int    port = 0;
                    string temp = "";
                    Application.DoEvents();
                    for (int i = 0; i < Program.gList.Count; i++)
                    {
                        Application.DoEvents();
                        if (Program.gList[i].Checked)
                        {
                            if (Program.gList[i].Mode == 0)
                            {
                                this.dlt.FrameDelay = 5;
                                this.dlt.Delay      = Program.gDelay;
                                port = Program.gComPort;
                                temp = Program.gCommSetting;
                            }
                            else
                            {
                                if (Program.gList[i].Mode == ComunicationType.TCPMyisServer)
                                {
                                    this.dlt.FrameDelay = Program.gDelay;
                                    this.dlt.Delay      = Program.gDelay;
                                    this.dlt.m_Port     = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                }
                                else
                                {
                                    if (Program.gList[i].Mode == ComunicationType.TCPMyisClient)
                                    {
                                        this.dlt.FrameDelay = Program.gDelay;
                                        this.dlt.Delay      = Program.gDelay;
                                        port            = Program.RemotePort;
                                        temp            = Program.RemoteIP;
                                        this.dlt.m_Port = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                    }
                                }
                            }
                            this.dlt.OperType = Program.gList[i].Mode;
                            bool flag = this.dlt.Open(port, temp);
                            if (flag)
                            {
                                DataGridViewRow currentRow = this.grid1.CurrentRow;
                                if (currentRow is CollapseDataGridViewRow)
                                {
                                    this.dlt.AFN        = "10";
                                    this.dlt.FN         = "0009";
                                    this.dlt.PN         = InputPN.GetPN("10", "0009");
                                    this.dlt.SendMSG    = this.GetSendText(currentRow);
                                    this.dlt.ListenPort = Program.gPort;
                                    this.dlt.CID        = Program.CID;
                                    this.dlt.Tp         = Program.Tp;
                                    this.dlt.PW         = Program.PW;
                                    this.dlt.Flag       = Program.Flag;
                                    this.dlt.A1         = Program.gList[i].A1;
                                    this.dlt.A2         = Program.gList[i].A2;
                                    this.dlt.MSA        = Program.MSA;
                                    bool   flag2 = this.dlt.SendData();
                                    string text  = this.dlt.ReceiveMSG;
                                    if (flag2)
                                    {
                                        text = this.dlt.ReceiveMSG;
                                    }
                                    else
                                    {
                                        text = "Error";
                                    }
                                    if (!string.IsNullOrEmpty(text))
                                    {
                                        if (string.IsNullOrEmpty(text) | text.ToUpper().IndexOf("ERROR") >= 0 | text.ToUpper().IndexOf("确认") >= 0 | text.ToUpper().IndexOf("否认") >= 0)
                                        {
                                            this.AddData(currentRow as CollapseDataGridViewRow, text, "");
                                        }
                                        else
                                        {
                                            DLT698_Recv dLT698_Recv = new DLT698_Recv();
                                            dLT698_Recv.DoInfo("10", "0009", text, false, "", Convert.ToString(currentRow.Cells[4].Value));
                                            this.AddData(currentRow as CollapseDataGridViewRow, text, dLT698_Recv.AF10_F9_Val);
                                        }
                                    }
                                }
                                Application.DoEvents();
                            }
                        }
                    }
                }
                this.dlt.Close();
            }
        }
Example #2
0
 public void AddRow(string iA1, string iA2, string iAFN, string iFN, string iPN, string iData)
 {
     Thread.Sleep(0);
     checked
     {
         if (base.InvokeRequired)
         {
             base.Invoke(new ActiveReport.AddRowDelegate(this.AddRow), new object[]
             {
                 iA1,
                 iA2,
                 iAFN,
                 iFN,
                 iPN,
                 iData
             });
         }
         else
         {
             Color  backColor = Color.FromArgb(240, 240, 240);
             string empty     = string.Empty;
             string empty2    = string.Empty;
             this.Get_Categories_Name(iAFN, iFN, ref empty, ref empty2);
             CollapseDataGridViewRow collapseDataGridViewRow = new CollapseDataGridViewRow();
             foreach (DataGridViewColumn dataGridViewColumn in this.grid1.Columns)
             {
                 collapseDataGridViewRow.Cells.Add(dataGridViewColumn.CellTemplate.Clone() as DataGridViewCell);
             }
             collapseDataGridViewRow.IsCollapse               = false;
             collapseDataGridViewRow.Cells[0].Value           = empty.Trim();
             collapseDataGridViewRow.Cells[0].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[1].Value           = empty2;
             collapseDataGridViewRow.Cells[1].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[2].Value           = iAFN;
             collapseDataGridViewRow.Cells[2].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[3].Value           = iFN.PadLeft(4, '0');
             collapseDataGridViewRow.Cells[3].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[4].Value           = iPN;
             collapseDataGridViewRow.Cells[4].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[5].Value           = iA1;
             collapseDataGridViewRow.Cells[5].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[6].Value           = iA2;
             collapseDataGridViewRow.Cells[6].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[7].Value           = "";
             collapseDataGridViewRow.Cells[7].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[8].Value           = "";
             collapseDataGridViewRow.Cells[8].Style.BackColor = backColor;
             collapseDataGridViewRow.Cells[9].Value           = DateTime.Now.ToLongTimeString();
             collapseDataGridViewRow.Cells[9].Style.BackColor = backColor;
             this.grid1.Rows.Add(collapseDataGridViewRow);
             DLT698_Recv dLT698_Recv = new DLT698_Recv();
             dLT698_Recv.DoInfo(iAFN, iFN, iData, false, "");
             for (int i = 0; i < dLT698_Recv.ItemData.Count; i++)
             {
                 if (!string.IsNullOrEmpty(dLT698_Recv.ItemData[i].Items))
                 {
                     this.AddData(collapseDataGridViewRow, dLT698_Recv.ItemData[i].Items, dLT698_Recv.ItemData[i].Values);
                 }
             }
         }
     }
 }
Example #3
0
        private void ToolStripButton1Click(object sender, EventArgs e)
        {
            this.toolStripButton1.Enabled = false;
            this.toolStripButton4.Enabled = true;
            this.RunCB = true;
            this.grid1.EndEdit();
            Program.gList.Clear();
            DataGridView gridV = MainForm.gMainForm.gAddressList.GridV;

            checked
            {
                for (int i = 0; i < gridV.Rows.Count; i++)
                {
                    Program.AddList item = default(Program.AddList);
                    if (!gridV.Rows[i].IsNewRow)
                    {
                        item.Checked = Convert.ToBoolean(gridV.Rows[i].Cells[0].Value);
                        item.A1      = Convert.ToString(gridV.Rows[i].Cells[2].Value);
                        item.A2      = Convert.ToString(gridV.Rows[i].Cells[3].Value);
                        item.Mode    = Program.GetLeiXing(Convert.ToString(gridV.Rows[i].Cells[4].Value));
                        Program.gList.Add(item);
                    }
                }
                if (Program.gList.Count == 0)
                {
                    MessageBox.Show("请先初始化终端列表 !", "失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    int    port = 0;
                    string temp = "";
                    Application.DoEvents();
                    for (int i = 0; i < Program.gList.Count; i++)
                    {
                        Application.DoEvents();
                        if (Program.gList[i].Checked)
                        {
                            if (Program.gList[i].Mode == 0)
                            {
                                this.dlt.FrameDelay  = 5;
                                this.dlt.Delay       = Program.gDelay;
                                this.dlt.ReadTimeout = Program.ReadTimeout;
                                port = Program.gComPort;
                                temp = Program.gCommSetting;
                            }
                            else
                            {
                                if (Program.gList[i].Mode == ComunicationType.TCPMyisServer)
                                {
                                    this.dlt.FrameDelay = Program.gDelay;
                                    this.dlt.Delay      = Program.gDelay;
                                    this.dlt.m_Port     = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                }
                                else
                                {
                                    if (Program.gList[i].Mode == ComunicationType.TCPMyisClient)
                                    {
                                        this.dlt.FrameDelay = Program.gDelay;
                                        this.dlt.Delay      = Program.gDelay;
                                        port            = Program.RemotePort;
                                        temp            = Program.RemoteIP;
                                        this.dlt.m_Port = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                    }
                                    else
                                    {
                                        if (Program.gList[i].Mode == ComunicationType.UDP)
                                        {
                                            this.dlt.FrameDelay = 5;
                                            this.dlt.Delay      = Program.gDelay;
                                        }
                                    }
                                }
                            }
                            this.dlt.OperType = Program.gList[i].Mode;
                            bool flag = (this.dlt.OperType == ComunicationType.UDP) ? this.dlt.Open(Program.UdpOpera, Program.UDP_Port_Send, Program.UDP_Port_Recieve, Program.UDP_RemoteAddress) : this.dlt.Open(port, temp);
                            if (flag)
                            {
                                for (int j = 0; j < int.Parse(this.toolStripTextBox1.Text); j++)
                                {
                                    foreach (DataGridViewRow dataGridViewRow in (IEnumerable)this.grid1.Rows)
                                    {
                                        if (dataGridViewRow is CollapseDataGridViewRow)
                                        {
                                            if (!this.RunCB)
                                            {
                                                goto IL_7B3;
                                            }
                                            if (Convert.ToBoolean(dataGridViewRow.Cells[0].Value))
                                            {
                                                this.dlt.AFN        = "10";
                                                this.dlt.FN         = "0009";
                                                this.dlt.PN         = InputPN.GetPN("10", "0009");
                                                this.dlt.SendMSG    = this.GetSendText(dataGridViewRow);
                                                this.dlt.ListenPort = Program.gPort;
                                                this.dlt.CID        = Program.CID;
                                                this.dlt.Tp         = Program.Tp;
                                                this.dlt.PW         = Program.PW;
                                                this.dlt.Flag       = Program.Flag;
                                                this.dlt.A1         = Program.gList[i].A1;
                                                this.dlt.A2         = Program.gList[i].A2;
                                                this.dlt.MSA        = Program.MSA;
                                                bool   flag2 = this.dlt.SendData();
                                                string text  = this.dlt.ReceiveMSG;
                                                if (flag2)
                                                {
                                                    text = this.dlt.ReceiveMSG;
                                                }
                                                else
                                                {
                                                    text = "Error";
                                                }
                                                if (!string.IsNullOrEmpty(text))
                                                {
                                                    if (string.IsNullOrEmpty(text) | text.ToUpper().IndexOf("ERROR") >= 0 | text.ToUpper().IndexOf("确认") >= 0 | text.ToUpper().IndexOf("否认") >= 0)
                                                    {
                                                        this.AddData(dataGridViewRow as CollapseDataGridViewRow, text, "");
                                                        Program.gDBDataBase.InsertDataAF10F9(this.dlt.A1, this.dlt.A2, Convert.ToString(dataGridViewRow.Cells[2].Value), "数据转发", "F9 数据直抄", "00", "0009", "0000", text, text);
                                                        if (text.ToUpper().IndexOf("ERROR") >= 0)
                                                        {
                                                            Thread.Sleep(Program.LC_ERR * 1000);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        DLT698_Recv dLT698_Recv = new DLT698_Recv();
                                                        dLT698_Recv.DoInfo("10", "0009", text, false, "", Convert.ToString(dataGridViewRow.Cells[4].Value));
                                                        this.AddData(dataGridViewRow as CollapseDataGridViewRow, text, dLT698_Recv.AF10_F9_Val);
                                                        Program.gDBDataBase.InsertDataAF10F9(this.dlt.A1, this.dlt.A2, Convert.ToString(dataGridViewRow.Cells[2].Value), "数据转发", "F9 数据直抄", "00", "0009", "0000", text, dLT698_Recv.AF10_F9_Val);
                                                    }
                                                }
                                            }
                                            Application.DoEvents();
                                        }
                                    }
                                    Thread.Sleep(Program.LC_JG * 1000);
                                }
                            }
                        }
                    }
                }
IL_7B3:
                this.dlt.Close();
                this.toolStripButton1.Enabled = true;
                this.toolStripButton4.Enabled = false;
                this.RunCB = false;
            }
        }