Пример #1
0
        private void OnClickSend(object sender, RoutedEventArgs e)
        {
            string msg = TBMSG.Text.ToString();

            if (msg == String.Empty)
            {
                NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请输入脚本", "提示");
                return;
            }

            Tool.Proto.ProtoMSG protomsg = new Proto.ProtoMSG();
            protomsg.MSG.value_ = msg;
            byte[] b_msg  = new byte[protomsg.length()];
            Int32  offset = 0;

            protomsg.serialize(b_msg, ref offset);

            var array_ip = RobotList.Split('|');

            foreach (string robot_id in array_ip)
            {
                if (robot_id == String.Empty)
                {
                    continue;
                }

                unsafe
                {
                    fixed(byte *l_msg = b_msg)
                    {
                        NetInterface.NetPostAsyncPackage(Convert.ToInt32(robot_id), (int)NetInterface.PKTTYPE.kAgvShellProto_RunScript, l_msg, protomsg.length());
                    }
                }
            }
            TipsMessageEx.ShowTips(Tool.MainWindow.This, "执行脚本完成", 18, 5, Colors.Green);

            Task.Run(() =>
            {
                this.Dispatcher.Invoke(() => { Close(); });
            });
        }
Пример #2
0
        private void SaveFile()
        {
            if (null == DirRemote)
            {
                return;
            }
            if (Directory.Exists(DirRemote))
            {
                return;
            }

            string text = TBRemote.Text.ToString();

            FileStream fs = new FileStream(DirRemote, FileMode.Create);

            byte[] data = System.Text.Encoding.Default.GetBytes(text);
            fs.Write(data, 0, data.Length);
            fs.Flush();
            fs.Close();

            List <TransFilesInfo> tmpList = new List <TransFilesInfo>();
            TransFilesInfo        info    = new TransFilesInfo();

            info.Path = SendFilePath;
            info.Type = 1;
            tmpList.Add(info);

            int retval = 0;

            string dir_path = ToDir + DirRemote.Substring(DirRemote.LastIndexOf("\\"));

            Tool.Proto.ProtoMSG protomsg = new Proto.ProtoMSG();
            protomsg.MSG.value_ = dir_path;
            byte[] b_msg  = new byte[protomsg.length()];
            Int32  offset = 0;

            protomsg.serialize(b_msg, ref offset);

            this.WaitEvent(() =>
            {
                unsafe
                {
                    void *r_data = null;
                    int r_len    = 0;
                    int net_id   = Tool.RobotsHome.RobotInfoCollect.GetInstance().FindNetIdByfts(EP);

                    unsafe
                    {
                        fixed(byte *l_msg = b_msg)
                        {
                            retval = NetInterface.NetPostSyncPackage(net_id, (int)NetInterface.PKTTYPE.kAgvShellProto_ProtoBackFiles, l_msg, protomsg.length(), &r_data, &r_len);
                        }
                    }
                }
            }, true, true);

            if (retval < 0)
            {
                NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "备份失败!", "错误");
                return;
            }

            retval = Tool.FileHandle.FTS.SaveFile(EP, tmpList, ToDir);

            if (retval < 0 && -2 == retval)
            {
                NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "保存文件失败,目标IP已有其他任务正在运行!", "错误");
                return;
            }

            if (retval < 0 && -1 == retval)
            {
                NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "保存文件失败!", "错误");
                return;
            }
        }