Exemplo n.º 1
0
        private void BT_ok_Click(object sender, EventArgs e)
        {
            try
            {
                if (db.SaveCs8cConfigure() && File.Exists(Application.StartupPath + "\\Txt\\Configure.txt"))
                {
                    File.Copy(Application.StartupPath + "\\Txt\\Configure.txt", Application.StartupPath + "\\Log\\Configure_" +
                              DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString()
                              + DateTime.Now.Second.ToString() + ".txt", true);
                }
            }
            catch
            {
            }


            if (TC_Edit.SelectedTabPageIndex == 0)
            {
                if (TxtData.DataBase.ToolMode < 1 && TxtData.DataBase.Tool == null && TxtData.DataBase.Home == null)
                {
                    MessageBox.Show("下位机通讯异常!");
                    return;
                }

                if (MessageBox.Show("确定需要把下位机数据导入数据库?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }


                if (EditTool)
                {
                    if (!db.EditTool(TxtData.DataBase.Tool))
                    {
                        MessageBox.Show("操作数据库异常!");
                        return;
                    }
                }
                else
                {
                    if (!db.EditHome(TxtData.DataBase.Home))
                    {
                        MessageBox.Show("操作数据库异常!");
                        return;
                    }
                }
            }
            else
            {
                if (CK_CS8C.Checked && TxtData.DataBase.ToolMode < 1)
                {
                    MessageBox.Show("下位机通讯异常");
                    return;
                }
                if (CK_CS8C.Checked && TxtData.DataBase.InterfaceType != 9)
                {
                    MessageBox.Show("下位机不在空闲状态");
                    return;
                }

                double[] data = EditTool ? TxtData.CS8CConfigure.Tool : TxtData.CS8CConfigure.Home;

                double.TryParse(TE_O1.Text, out data[0]);
                double.TryParse(TE_O2.Text, out data[1]);
                double.TryParse(TE_O3.Text, out data[2]);
                double.TryParse(TE_O4.Text, out data[3]);
                double.TryParse(TE_O5.Text, out data[4]);
                double.TryParse(TE_O6.Text, out data[5]);

                if (EditTool)
                {
                    if (!db.EditTool(data))
                    {
                        MessageBox.Show("操作数据库异常!");
                        return;
                    }
                }
                else
                {
                    if (!db.EditHome(data))
                    {
                        MessageBox.Show("操作数据库异常!");
                        return;
                    }
                }
                if (CK_CS8C.Checked)
                {
                    FtpClient ftp = new FtpClient(TxtData.XMLConfigure.IpAddress);
                    if (db.SaveCs8cConfigure() == false || !ftp.UploadConfigure())
                    {
                        MessageBox.Show("发送配置文件异常!");
                        return;
                    }
                    // ;
                }
            }

            this.Close();
        }
Exemplo n.º 2
0
        private void timer_Refresh_Tick(object sender, EventArgs e)
        {
            Frm_Wait_Load(this, null);
            //  this.Text = TxtData.SoapData.Upload.ToString();
            if (IsUpload)
            {
                PP_process.Caption     = "请等待";
                PP_process.Description = "正在上传...";

                return;
            }
            if (TxtData.PublicData.ErrorCode != 0)
            {
                if (TxtData.PublicData.ErrorCode == 40)
                {
                    if (!NeedUpload)
                    {
                        this.timer_Refresh.Enabled = false;
                        this.Close();
                        return;
                    }
                }
                else
                {
                    PP_process.Caption     = "报错";
                    PP_process.Description = "信息:" + Error[TxtData.PublicData.ErrorCode];//.ToString();
                    timer_Refresh.Enabled  = false;
                    return;
                }
            }

            if (NeedUpload && TxtData.SoapData.InterfaceType == 9)
            {
                PP_process.Caption     = "提示:";
                PP_process.Description = "信息:下位机处在等待界面";
                return;
            }

            PP_process.Caption     = "请等待";
            PP_process.Description = "程序正在运行...";

            #region 需要上传
            if (TxtData.SoapData.Upload && NeedUpload)
            {
                PP_process.Caption     = "请等待";
                PP_process.Description = "正在保存文件...";

                //if (TxtData.PolishData.UploadType==1)
                //{



                //}
                switch (TxtData.PolishData.UploadType)
                {
                case 1:
                {
                    TxtData.PublicData.ErrorCode = (db.EditHome(TxtData.SoapData.Home)) ? 0 : 18;

                    break;
                    ;
                }

                case 2:
                {
                    TxtData.PublicData.ErrorCode = (db.EditPresetList("TOOL", TxtData.SoapData.Tool, TxtData.PolishData.UploadIndex + 1)) ? 0 : 18;

                    break;
                    ;
                }


                case 3:
                {
                    TxtData.PublicData.ErrorCode = (db.EditPresetList("FRAME", TxtData.SoapData.Frame, TxtData.PolishData.UploadIndex + 1)) ? 0 : 18;

                    break;
                    ;
                }
                }


                //if (File.Exists(Application.StartupPath + "\\Txt\\Recipe.txt"))
                //{
                //    File.Delete(Application.StartupPath + "\\Txt\\Recipe.txt");
                //}
                //if (File.Exists(Application.StartupPath + "\\Txt\\Configure.txt"))
                //{
                //    File.Delete(Application.StartupPath + "\\Txt\\Configure.txt");
                //}

                //if (File.Exists(Application.StartupPath + "\\Txt\\Preset.txt"))
                //{
                //    File.Delete(Application.StartupPath + "\\Txt\\Preset.txt");
                //}
                //if (File.Exists(Application.StartupPath + "\\Txt\\Action.txt"))
                //{
                //    File.Delete(Application.StartupPath + "\\Txt\\Action.txt");
                //}

                // ftp = new FtpClient(TxtData.XMLConfigure.IpAddress);
                // string Strdate = "_" + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();

                //switch (TxtData.SoapData.InterfaceType)
                //{
                //     //保存工艺
                //    case 3:
                //        {
                //            TxtData.PublicData.ErrorCode = ftp.DownLoadPreset() ? 0 : 13;
                //            if (TxtData.PublicData.ErrorCode==0)
                //            {

                //                TxtData.PublicData.ErrorCode = (db.ImportPreset(Application.StartupPath + "\\Txt\\Preset.txt","StaubliPreset") == 0) ? 0 : 17;
                //                File.Copy(Application.StartupPath + "\\Txt\\Preset.txt", Application.StartupPath + "\\Log\\Preset" + Strdate + ".txt",true);
                //            }


                //            break;


                //        }


                //        //动作
                //    case 4:
                //        {
                //            TxtData.PublicData.ErrorCode = ftp.DownLoadAction() ? 0 : 14;
                //            if (TxtData.PublicData.ErrorCode == 0)
                //            {
                //                TxtData.PublicData.ErrorCode = (db.ImportAction(Application.StartupPath+"\\Txt\\Action.txt")==0) ? 0 : 18;
                //                File.Copy(Application.StartupPath + "\\Txt\\Action.txt", Application.StartupPath + "\\Log\\Action" + Strdate + ".txt", true);
                //            }


                //            break;


                //        }
                //        //产品
                //    case 5:
                //        {
                //            IsUpload = true;
                //            System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(Poll));
                //            return;

                //        }

                //    case 10:
                //        {
                //            TxtData.Recipe.RecipeFrame = RobotKit.StaubliXML.GetXMLCarten("fFrame", SoapInstance.SoapRead.GetAppdata());
                //            TxtData.PublicData.ErrorCode =(TxtData.Recipe.RecipeFrame!=null) ? 0 : 36;
                //            if (TxtData.PublicData.ErrorCode == 0)
                //            {
                //                TxtData.PublicData.ErrorCode = db.EditRecipeFrame(RecipeName,TxtData.Recipe.RecipeFrame)? 0 : 37;
                //            }


                //            break;


                //        }

                //    case 11:
                //        {
                //            TxtData.Recipe.RecipeFrame = RobotKit.StaubliXML.GetXMLCarten("fOffset",SoapInstance.SoapRead.GetAppdata());
                //            TxtData.PublicData.ErrorCode =(TxtData.Recipe.RecipeFrame != null) ? 0 : 36;
                //            if (TxtData.PublicData.ErrorCode == 0)
                //            {
                //                TxtData.PublicData.ErrorCode = db.EditRecipeOffset(RecipeName, TxtData.Recipe.RecipeFrame) ? 0 : 37;
                //            }
                //            break;


                //        }
                //    case 7:
                //    case 12:
                //    case 14:
                //    case 15:
                //    case 16:
                //    case 17:
                //    case 18:
                //    case 19:
                //        {
                //            TxtData.PublicData.ErrorCode = ftp.DownLoadConfigure() ? 0 : 15;
                //            if (TxtData.PublicData.ErrorCode == 0)
                //            {
                //                TxtData.PublicData.ErrorCode = db.ImportConfigure() == 0 ? 0 : 19;
                //                File.Copy(Application.StartupPath + "\\Txt\\Configure.txt", Application.StartupPath + "\\Log\\Configure" + Strdate + ".txt", true);
                //            }


                //            break;


                //        }



                // }
                if (TxtData.PublicData.ErrorCode == 0)
                {
                    TxtData.PublicData.ErrorCode = RobotKit.SoapInstance.SoapRead.SetAppdata("bUpload", false)?0:12;
                }
                if (TxtData.PublicData.ErrorCode == 0)
                {
                    PP_process.Caption     = "成功";
                    PP_process.Description = "信息:上传成功";

                    while (TxtData.SoapData.Upload)
                    {
                        System.Threading.Thread.Sleep(10);
                    }
                }
            }
            #endregion
        }