Exemple #1
0
        //配置接口
        private void setInterfaceCofig(String interface_name)
        {
            string cmdText = "select id, interface_name, interface_state, create_time, user_name, check_value, adapter_type, prot, transmission_speed,datalink from a5_interface_config where interface_name = :interface_name";

            OracleParameter[] commandParameters = new OracleParameter[] {
                new OracleParameter(":interface_name", OracleDbType.Varchar2, 60)
            };
            commandParameters[0].Value = interface_name;

            DataTable datatable = Jdbc.ExecuteDataTable(cmdText, commandParameters);

            if (datatable != null && datatable.Rows.Count > 0)
            {
                DataRow dr                 = datatable.Rows[0];
                String  user_name          = dr["user_name"].ToString();                     //
                String  check_value        = dr["check_value"].ToString();                   //
                int     adapter_type       = int.Parse(dr["adapter_type"].ToString());       //
                int     prot               = int.Parse(dr["prot"].ToString());               //
                int     transmission_speed = int.Parse(dr["transmission_speed"].ToString()); //
                int     datalink           = int.Parse(dr["datalink"].ToString());           //

                ClientLogin       = user_name;
                AuthenticationKey = check_value;
                m_ComAdapt        = (T_FLASH_COMADAPTER)adapter_type;
                m_ComPort         = (T_FLASH_COMPORT)prot;
                m_BaudRate        = (T_FLASH_BAUDRATE)transmission_speed;
                m_DataLinks       = (T_FLASH_DATALINK)datalink;
            }
        }
Exemple #2
0
        private void csToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string url      = "http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js";
            string fileName = FileHandler.DownloadFile(url);

            if (!String.IsNullOrEmpty(fileName))
            {
                Console.WriteLine("文件下载成功,文件名称:" + fileName);

                string cmdText = "select * from a5_file where file_name = :file_name";

                OracleParameter[] commandParameters = new OracleParameter[] {
                    new OracleParameter(":file_name", OracleDbType.Varchar2, 40)
                };
                commandParameters[0].Value = "TN00002V69.fls";

                DataTable datatable = Jdbc.ExecuteDataTable(cmdText, commandParameters);
                if (datatable.Rows.Count > 0)
                {
                    DataRow dr          = datatable.Rows[0];
                    String  source_file = dr["source_file"].ToString();//变速箱编号

                    //Console.WriteLine("haha" + source_file);
                    FileHandler.createFile("TN00002V69.fls", source_file);
                }
            }
            else
            {
                Console.WriteLine("文件下载失败");
            }
            Console.ReadLine();
        }
Exemple #3
0
        /// <summary>
        /// 刷机过程写入数据库
        /// </summary>
        /// <param name="step">刷机步骤名称</param>
        /// <param name="str">刷机内容</param>
        /// <param name="isOK">是否成功</param>
        /// <param name="Code">错误代码</param>
        /// <param name="Description">错误描述信息</param>
        private void WriteDBLog(string step, string str, bool isOK = true, int Code = 0, string Description = "")
        {
            string now = DateTime.Now.ToLocalTime().ToString() + ":";

            str = now + str + "。";

            if (Code > 0)
            {
                str = str + "错误码:" + Code.ToString() + ";错误信息:" + Description;
            }

            MsgIndex++;

            Jdbc.insertLogsSide(logsid, step, str, isOK?"成功":"失败", MsgIndex);
            //Jdbc.insertLogsSide(logsid, "连接设备", DateTime.Now.ToLocalTime().ToString() + ":连接设备失败!错误码" + iCode.ToString() + "|" + sDescription, "失败", 1);
        }
Exemple #4
0
        private void 写库ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String sql = "insert into a5_interface_logs" +
                         "(create_date, station_code, pc_name, start_time, end_time, logs_describe, severity, error_msg, transmission_sn, create_user)" +
                         " values (" +
                         " sysdate, :v_station_code, :v_pc_name, sysdate, sysdate, :v_logs_describe, null, null, '01', null)";

            OracleParameter[] commandParameters = new OracleParameter[] {
                new OracleParameter(":v_station_code", OracleDbType.Varchar2, 40),
                new OracleParameter(":v_pc_name", OracleDbType.Varchar2, 40),
                new OracleParameter(":v_logs_describe", OracleDbType.Varchar2, 4000)
            };

            commandParameters[0].Value = "100001";
            commandParameters[1].Value = "第一个工位";
            commandParameters[2].Value = "测试描述";
            int i = Jdbc.ExecuteNonQuery(sql, commandParameters);

            Console.WriteLine("i=" + i);
        }
Exemple #5
0
        //开始刷写
        private void ServiceToolFrom_start_button_Click(object sender, EventArgs e)
        {
            string transmission_sn = ServiceToolFrom_Product_Serial_No.Text;

            if (start_on_off)
            {
                logsid     = Jdbc.getNextLogid();                   //获取日志ID
                start_time = DateTime.Now.ToLocalTime().ToString(); //开始时间

                //刷写Flash
                int returnFlash = startFlashProc();

                //成功后刷写参数
                if (returnFlash == 0)
                {
                    //刷写参数
                    int returnConfig = startConfig();
                    if (returnConfig == 0)
                    {
                        WriteMessageText("刷写结束!", true);
                    }
                    else
                    {
                        WriteMessageText("刷写终止!", true);
                    }
                }
                else
                {
                    WriteMessageText("刷写终止!", true);
                }

                //刷写完成写入日志
                end_time = DateTime.Now.ToLocalTime().ToString(); //结束时间
                WriteMessageText("结束时间:" + end_time);
                Jdbc.insertLogs(logsid, station_code, station_name, transmission_sn, start_time, end_time);
            }
            else
            {
                MessageBox.Show("请查询到结果后进行操作!");
            }
        }
Exemple #6
0
 private void ConfigForm_test_button_Click(object sender, EventArgs e)
 {
     try
     {
         ConfigForm_test_button.Enabled   = false;
         ConfigForm_summit_button.Enabled = false;
         ConfigForm_cance_button.Enabled  = false;
         String username = ConfigForm_user_name_textBox.Text;
         String password = ConfigForm_password_textBox.Text;
         String ip       = ConfigForm_ip_textBox.Text;
         String prot     = ConfigForm_prot_textBox.Text;
         String dataname = ConfigForm_data_name_textBox.Text;
         Jdbc.Test(username, password, ip, prot, dataname);
     }
     catch (Exception ex)
     {
         MessageBox.Show("连接失败:" + ex.Message);
     }
     finally {
         ConfigForm_test_button.Enabled   = true;
         ConfigForm_summit_button.Enabled = true;
         ConfigForm_cance_button.Enabled  = true;
     }
 }
Exemple #7
0
        //刷写Flash过程
        private int startFlashProc()
        {
            #region 重置接口变量状态
            bFlashDetectStatus     = false; //设备检测是否完成
            bFlashValidationStatus = false; //文件校验是否完成
            bFlashStatus           = false; //刷写是否完成
            bConnectFlag           = false; //设备是否已连接
            bFileFlag  = false;             //文件是否合法
            bFlashFlag = false;             //刷写是否正确
            #endregion

            toolStripProgressBar1.Value = 0;

            WriteMessageText("开始刷写...", true);
            WriteMessageText("开始时间:" + start_time);

            #region 1.连接设备

            ServiceToolFrom_listView.Items[0].SubItems[1].Text = "执行中";
            WriteMessageText("正在连接设备...");

            //连接设备,并判断是否成功
            connectDevice();
            if (!bConnectFlag)
            {
                //连接失败
                WriteDBLog("连接设备", "设备连接失败", false, iCode, sDescription);
                ServiceToolFrom_listView.Items[0].SubItems[1].Text = "失败";
                return(1);
            }
            else
            {
                WriteDBLog("连接设备", "设备连接成功");
                ServiceToolFrom_listView.Items[0].SubItems[1].Text = "完成";
            }

            #endregion

            #region 2.1 下载服务器的Flash文件

            string path = "";
            try
            {
                ServiceToolFrom_listView.Items[1].SubItems[1].Text = "执行中";
                string cmdText = "select * from a5_file where file_name = :file_name";

                OracleParameter[] commandParameters = new OracleParameter[] {
                    new OracleParameter(":file_name", OracleDbType.Varchar2, 40)
                };
                commandParameters[0].Value = flash_file_name;

                DataTable datatable = Jdbc.ExecuteDataTable(cmdText, commandParameters);
                if (datatable != null && datatable.Rows.Count > 0)
                {
                    DataRow dr          = datatable.Rows[0];
                    String  source_file = dr["source_file"].ToString();//变速箱编号
                    path = FileHandler.createFile(flash_file_name, source_file);
                    WriteDBLog("校验文件", "Flash文件 " + flash_file_name + " 下载成功");
                }
                else
                {
                    WriteMessageText("Flash文件校验失败,没有找到文件:" + flash_file_name, true);
                    WriteDBLog("校验文件", "Flash文件校验失败", false, 1, "没有找到文件 " + flash_file_name);
                    ServiceToolFrom_listView.Items[1].SubItems[1].Text = "失败";
                    return(21);
                }
            }
            catch (Exception ex)
            {
                WriteMessageText("Flash文件校验(下载)异常:" + ex.Message);
                return(100);
            }
            #endregion

            #region 2.2 校验Flash文件

            WriteMessageText("加载Flash文件:" + flash_file_name);
            WriteMessageText("正在校验Flash文件:" + flash_file_name);


            //校验文件,并判断是否成功
            validateFlashFile(path);
            if (!bFileFlag)
            {
                //校验失败
                WriteDBLog("校验文件", "Flash文件校验失败", false, iCode, sDescription);
                ServiceToolFrom_listView.Items[1].SubItems[1].Text = "失败";
                return(22);
            }
            else
            {
                WriteDBLog("校验文件", "Flash文件校验成功");
                ServiceToolFrom_listView.Items[1].SubItems[1].Text = "完成";
            }

            #endregion

            #region 3.刷写FLash文件
            ServiceToolFrom_listView.Items[2].SubItems[1].Text = "执行中";
            WriteMessageText("开始刷写Flash文件...");

            //刷写文件,并判断是否成功
            startFlashFile(path);
            if (!bFlashFlag)
            {
                //刷写失败
                WriteDBLog("刷写Flash", "刷写Flash失败", false, iCode, sDescription);
                ServiceToolFrom_listView.Items[2].SubItems[1].Text = "失败";
                return(3);
            }
            else
            {
                WriteDBLog("刷写Flash", "刷写Flash成功");
                ServiceToolFrom_listView.Items[2].SubItems[1].Text = "完成";
            }
            #endregion

            return(0);
        }
Exemple #8
0
        //根据序列号查询变速箱信息
        private void ServiceToolFrom_detail_button_Click(object sender, EventArgs e)
        {
            string serialNo = ServiceToolFrom_Serial_No_textbox.Text;

            if (!(serialNo != null && serialNo.Length - 8 == 0))
            {
                MessageBox.Show("变速箱编号必须是8位!");
            }
            else
            {
                string cmdText = "select * from a5_transmission where transmission_model = :transmission_model";

                OracleParameter[] commandParameters = new OracleParameter[] {
                    new OracleParameter(":transmission_model", OracleDbType.Varchar2, 40)
                };
                commandParameters[0].Value = serialNo;

                DataTable datatable = Jdbc.ExecuteDataTable(cmdText, commandParameters);
                if (datatable.Rows.Count > 0)
                {
                    DataRow dr = datatable.Rows[0];
                    String  transmission_model  = dr["transmission_model"].ToString();  //变速箱编号
                    String  torque_converter_sn = dr["torque_converter_sn"].ToString(); //变矩器编号
                    String  arrangement_pn      = dr["arrangement_pn"].ToString();      //总称号

                    String state    = dr["state"].ToString();                           //出库状态 1在库,2出库
                    String order_id = dr["order_id"].ToString();                        //关联订单
                    ServiceToolFrom_Product_Serial_No.Text   = transmission_model;
                    ServiceToolFrom_Product_Arrangement.Text = arrangement_pn;
                    ServiceToolFrom_Product_Engr_Model.Text  = torque_converter_sn;
                    if (state.Equals("2"))
                    {
                        //查询订单信息,加载FLASH文件名称,加载变量信息;
                        if (true)
                        {
                            cmdText           = "select * from a5_order where id = :id";
                            commandParameters = new OracleParameter[] {
                                new OracleParameter(":id", OracleDbType.Long, 10)
                            };
                            commandParameters[0].Value = order_id;

                            DataTable datatableOrder = Jdbc.ExecuteDataTable(cmdText, commandParameters);
                            if (datatableOrder != null && datatableOrder.Rows.Count > 0)
                            {
                                DataRow drorder      = datatableOrder.Rows[0];
                                String  order_number = drorder["order_number"].ToString();
                                string  flash_id     = drorder["flash_id"].ToString();

                                ServiceToolFrom_Product_Order.Text = order_number;

                                cmdText           = "select b.file_name from a5_flash_softw a left join a5_flash_file_relation b on a.id = b.flash_id where b.status = 1 and a.id=:flash_id";
                                commandParameters = new OracleParameter[] {
                                    new OracleParameter(":flash_id", OracleDbType.Long, 10)
                                };
                                commandParameters[0].Value = flash_id;
                                DataTable datatableFlash = Jdbc.ExecuteDataTable(cmdText, commandParameters);
                                if (datatableFlash != null && datatableFlash.Rows.Count > 0)
                                {
                                    DataRow filedrop = datatableFlash.Rows[0];
                                    flash_file_name = filedrop["file_name"].ToString();
                                    start_on_off    = true;
                                }

                                /* cmdText = "select * from A5_ORDER_FLASH_PARAMETER where order_id = :order_id";
                                 * commandParameters = new OracleParameter[]{
                                 *   new OracleParameter(":order_id",OracleDbType.Long,10)
                                 * };
                                 * commandParameters[0].Value = order_id;
                                 * DataTable datatableOrderP = Jdbc.ExecuteDataTable(cmdText, commandParameters);
                                 * foreach (DataRow drop in datatableOrderP.Rows) {
                                 *   String field_name = drop["field_name"].ToString();
                                 *   String v_value = drop["v_value"].ToString();
                                 *   if (field_name.Equals("srcFile")) {
                                 *       flash_file_name = v_value;//设定Flash值
                                 *      // MessageBox.Show("flash_file_name:"+ flash_file_name);
                                 *       start_on_off = true;
                                 *   }
                                 * }*/
                                if (start_on_off)
                                {   //查询订单下变量(过去掉组名)
                                    cmdText           = "select sotr_index,varable_name,trim(v_value) v_value from a5_order_flash_variable where order_id = :order_id and group_id > 1 and group_id <>10  order by sotr_index";
                                    commandParameters = new OracleParameter[] {
                                        new OracleParameter(":id", OracleDbType.Long, 10)
                                    };
                                    commandParameters[0].Value = order_id;
                                    DataTable datatableOrderV = Jdbc.ExecuteDataTable(cmdText, commandParameters);
                                    wr_dic.Clear();
                                    foreach (DataRow drov in datatableOrderV.Rows)
                                    {
                                        int    sotr_index   = int.Parse(drov["sotr_index"].ToString()); //索引
                                        String varable_name = drov["varable_name"].ToString();          //字段名称
                                        String v_value      = drov["v_value"].ToString();               //值

                                        wr_dic.Add(sotr_index, v_value);
                                    }
                                    if (datatableOrderV.Rows.Count > 0)
                                    {
                                        start_on_off = true;//标记可刷机
                                    }
                                }
                            }
                            else
                            {
                                start_on_off = false;
                                MessageBox.Show("没有订单信息!");
                            }
                        }
                    }
                    else
                    {
                        start_on_off = false;
                        MessageBox.Show("设备状态为在库,请出库后再试!");
                    }
                }
                else
                {
                    start_on_off = false;
                    MessageBox.Show("没有查询到结果!");
                }
            }
        }
Exemple #9
0
        private void ServiceToolFrom_Load(object sender, EventArgs e)
        {
            //线程能安全的访问窗体控件
            Control.CheckForIllegalCrossThreadCalls = false;

            string hostInfo = Dns.GetHostName();
            String ip       = "";

            System.Net.IPAddress[] addressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            for (int i = 0; i < addressList.Length; i++)
            {
                ip = addressList[i].ToString();
            }
            ServiceToolFrom_station_toolStripStatusLabel.Text = "工位IP:" + ip + "|机器名:" + Common.pc_name;

            string cmdText = "select* from a5_station where station_pc = :station_pc";

            OracleParameter[] commandParameters = new OracleParameter[] {
                new OracleParameter(":station_pc", OracleDbType.Varchar2, 40)
            };
            commandParameters[0].Value = Common.pc_name;
            string    station_id = "";
            DataTable datatable  = Jdbc.ExecuteDataTable(cmdText, commandParameters);

            if (datatable != null && datatable.Rows.Count > 0)
            {
                DataRow dr = datatable.Rows[0];
                station_code = dr["station_code"].ToString(); //
                station_name = dr["station_name"].ToString(); //
                station_id   = dr["id"].ToString();
                ServiceToolFrom_station_toolStripStatusLabel.Text += "|" + station_name;
            }

            ServiceToolFrom_login_toolStripStatusLabel.Text = "操作员:" + Common.login_user;
            ServiceToolFrom_statusStrip_msg.Text            = "加载完成";

            string cmdText2 = "select distinct a.station_id,a.power_code,b.name from a5_station_power a join a5_dictionary b on a.power_code = b.code and " +
                              "b.pid IN (select id from a5_dictionary where code = 'stationRole2') and b.state = 1 where station_id = :station_id";

            OracleParameter[] commandParameters2 = new OracleParameter[] {
                new OracleParameter(":station_id", OracleDbType.Varchar2, 40)
            };
            commandParameters2[0].Value = station_id;

            DataTable datatable2 = Jdbc.ExecuteDataTable(cmdText2, commandParameters2);

            foreach (DataRow drop in datatable2.Rows)
            {
                String        power_code = drop["power_code"].ToString();
                String        name       = drop["name"].ToString();
                ToolStripItem item       = new ToolStripMenuItem();
                item.Name   = "temp_role" + power_code + "_ToolStripMenuItem";
                item.Size   = new System.Drawing.Size(153, 22);
                item.Text   = name;
                item.Click += new System.EventHandler(this.dcbg_ToolStripMenuItem_Click);
                this.gjgn_ToolStripMenuItem.DropDownItems.Add(item);
            }

            string cmdText1 = "select * from a5_interface_config";

            DataTable datatable1 = Jdbc.ExecuteDataTable(cmdText1, null);
            int       x          = 0;

            foreach (DataRow drop in datatable1.Rows)
            {
                String        id             = drop["id"].ToString();
                String        interface_name = drop["interface_name"].ToString();
                ToolStripItem item           = new ToolStripMenuItem();
                item.Name   = "temp_" + id + "_ToolStripMenuItem";
                item.Size   = new System.Drawing.Size(153, 22);
                item.Text   = interface_name;
                item.Click += new System.EventHandler(this.lanMenu1_UserControlMenuItemClick);
                this.jkpz_ToolStripMenuItem.DropDownItems.Add(item);
                if (x == 0)
                {
                    setInterfaceCofig(interface_name);
                    ((ToolStripMenuItem)item).Checked    = true;
                    ((ToolStripMenuItem)item).CheckState = System.Windows.Forms.CheckState.Checked;
                    x++;
                }
            }
        }
Exemple #10
0
        //登录事件
        private void login_submit_button_Click(object sender, EventArgs e)
        {
            Boolean flg = false;

            if (Common.Language.Equals("zh-CN"))
            {
                login_msg_label.Text = "正在登录中,请稍候...";
            }
            else
            {
                login_msg_label.Text = "Logging, please wait...";
            }
            login_submit_button.Enabled = false;
            login_cancel_button.Enabled = false;
            Application.DoEvents();
            byte[] result = Encoding.Default.GetBytes(this.login_password_textBox.Text.Trim());    //tbPass为输入密码的文本框
            MD5    md5    = new MD5CryptoServiceProvider();

            byte[] output  = md5.ComputeHash(result);
            String pwd     = BitConverter.ToString(output).Replace("-", "");
            String account = this.login_account_textBox.Text.Trim();

            string cmdText = "select * from wp_person where wp_account = :wp_account and upper(wp_password)=upper(:wp_password)";

            OracleParameter[] commandParameters = new OracleParameter[] {
                new OracleParameter(":wp_account", OracleDbType.Varchar2, 40),
                new OracleParameter(":wp_password", OracleDbType.Varchar2, 40)
            };
            commandParameters[0].Value = account;
            commandParameters[1].Value = pwd;

            DataTable datatable = Jdbc.ExecuteDataTable(cmdText, commandParameters);

            if (datatable != null && datatable.Rows.Count > 0)
            {
                flg = true;
            }

            if (flg)
            {
                string cmdText1 = "select* from a5_station where station_pc = :station_pc";

                OracleParameter[] commandParameters1 = new OracleParameter[] {
                    new OracleParameter(":station_pc", OracleDbType.Varchar2, 40)
                };
                commandParameters1[0].Value = Common.pc_name;

                DataTable datatable1 = Jdbc.ExecuteDataTable(cmdText1, commandParameters1);
                if (datatable1 != null && datatable1.Rows.Count > 0)
                {
                    flg = true;
                }
                else
                {
                    flg = false;
                }
                if (flg)
                {
                    Common.login_user = datatable.Rows[0]["wp_name"].ToString();
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    login_msg_label.Text        = Common.pc_name + " 没有配置工位信息!";
                    login_submit_button.Enabled = true;
                    login_cancel_button.Enabled = true;
                }
            }
            else
            {
                if (Common.Language.Equals("zh-CN"))
                {
                    login_msg_label.Text = "账号或密码错误!";
                }
                else
                {
                    login_msg_label.Text = "Account or password error!";
                }
                login_submit_button.Enabled = true;
                login_cancel_button.Enabled = true;
            }
        }