Пример #1
0
        //全选列表文件
        private void OnSelectAllFiles(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;

            if (cb.IsChecked == true)
            {
                if ("AllLocalFilesCheckBox" == cb.Name)
                {
                    List <FileDetailInfo> List = dcLocal.Collection.ToList();
                    foreach (var obj in List)
                    {
                        if ("" == obj.FileName)
                        {
                            continue;
                        }

                        TransFilesInfo info = new TransFilesInfo();
                        info.Path = obj.LocalDir;
                        info.Type = obj.IsDir ? 0 : 1;
                        SelectLocalList.Add(info);
                    }
                    dcLocal.Collection.ToList().ForEach(p => p.IsSelectedLocal = true);
                }
                else if ("AllRemoteFilesCheckBox" == cb.Name)
                {
                    List <FileDetailInfo> List = dcRemote.Collection.ToList();
                    foreach (var obj in List)
                    {
                        if ("" == obj.FileName)
                        {
                            continue;
                        }

                        TransFilesInfo info = new TransFilesInfo();
                        info.Path = obj.RemoteDir;
                        info.Type = obj.IsDir ? 0 : 1;
                        SelectRemoteList.Add(info);
                    }
                    dcRemote.Collection.ToList().ForEach(p => p.IsSelectedRemote = true);
                }
            }
            else
            {
                if ("AllLocalFilesCheckBox" == cb.Name)
                {
                    SelectLocalList.Clear();
                    dcLocal.Collection.ToList().ForEach(p => p.IsSelectedLocal = false);
                }
                else if ("AllRemoteFilesCheckBox" == cb.Name)
                {
                    SelectRemoteList.Clear();
                    dcRemote.Collection.ToList().ForEach(p => p.IsSelectedRemote = false);
                }
            }
        }
Пример #2
0
        //选择列表文件
        private void OnSelectFiles(object sender, RoutedEventArgs e)
        {
            CheckBox       cb  = sender as CheckBox;
            FileDetailInfo obj = (FileDetailInfo)cb.DataContext;

            TransFilesInfo info = new TransFilesInfo();

            if (true == cb.IsChecked)
            {
                if ("LocalFilesCheckBox" == cb.Name)
                {
                    info.Path = obj.LocalDir;
                    info.Type = obj.IsDir ? 0 : 1;
                    SelectLocalList.Add(info);
                }
                else if ("RemoteFilesCheckBox" == cb.Name)
                {
                    info.Path = obj.RemoteDir;
                    info.Type = obj.IsDir ? 0 : 1;
                    SelectRemoteList.Add(info);
                }
            }
            else
            {
                if ("LocalFilesCheckBox" == cb.Name)
                {
                    info.Path = obj.LocalDir;
                    info.Type = obj.IsDir ? 0 : 1;
                    SelectLocalList.Remove(SelectLocalList.Where(p => p.Path == obj.LocalDir).FirstOrDefault());
                }
                else if ("RemoteFilesCheckBox" == cb.Name)
                {
                    info.Path = obj.RemoteDir;
                    info.Type = obj.IsDir ? 0 : 1;
                    SelectRemoteList.Remove(SelectRemoteList.Where(p => p.Path == obj.RemoteDir).FirstOrDefault());
                }
            }
        }
Пример #3
0
        //校验选择文件列表
        private void CheckSelFileList(ref List <TransFilesInfo> list)
        {
            FileDetailInfo item = (FileDetailInfo)PointItem;

            if (null == item)
            {
                list = SelectRemoteList;
            }

            else
            {
                if (item.IsSelectedRemote)
                {
                    list = SelectRemoteList;
                }
                else
                {
                    TransFilesInfo info = new TransFilesInfo();
                    info.Path = item.RemoteDir;
                    info.Type = item.IsDir ? 0 : 1;
                    list.Add(info);
                }
            }
        }
Пример #4
0
        //双击列表文件夹
        private void OnDoubleClickFileList(object sender, MouseButtonEventArgs e)
        {
            ListView list = sender as ListView;

            if (null == list)
            {
                return;
            }

            if (null == PointItem)
            {
                return;
            }

            FileDetailInfo item = ((FileDetailInfo)PointItem);

            if (item.IsDir)
            {
                string strRelativeDir = "";
                if ("RemoteListView" == list.Name)
                {
                    string splitstr = IP;
                    if (null == item.RemoteDir)
                    {
                        return;
                    }
                    int pos = item.RemoteDir.IndexOf(IP);
                    strRelativeDir = item.RemoteDir;
                }
                else if ("LocalListView" == list.Name)
                {
                    if (null == item.LocalDir)
                    {
                        return;
                    }

                    strRelativeDir = item.LocalDir;
                }
                NodeOperationInitList(strRelativeDir);
            }
            else
            {
                if ("" == item.FileName)
                {
                    return;
                }

                string pathRemote = "";
                if (item.RemoteDir != null)
                {
                    pathRemote = item.RemoteDir.Substring(1, item.RemoteDir.Length - 1);
                }


                String dir = null;
                Tool.Setting.ConfigRead.ReadLocalDir(ref dir);
                string pathLocal = "";
                if (item.LocalDir != null)
                {
                    pathLocal = dir + item.LocalDir.Substring(1, item.LocalDir.Length - 1);
                }


                if ("RemoteListView" == list.Name)
                {
                    if (item.FileSize > 1024 * 1024)
                    {
                        NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "文件大于1M,无法显示", "提示");
                        return;
                    }

                    TransFilesInfo info = new TransFilesInfo();
                    info.Path = ((FileDetailInfo)PointItem).RemoteDir;
                    info.Type = ((FileDetailInfo)PointItem).IsDir ? 0 : 1;
                    List <TransFilesInfo> tmpList = new List <TransFilesInfo>();
                    tmpList.Add(info);

                    int retval = -1;
                    this.Dispatcher.Invoke(() => {
                        this.WaitEvent(() => {
                            unsafe
                            {
                                retval = Tool.FileHandle.FTS.DownLoadFile(EP, tmpList, BaseDir);
                            }
                        }, true, true);
                    });

                    if (retval < 0)
                    {
                        NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "下载文件失败!", "错误");
                        return;
                    }
                }
                else if ("LocalListView" == list.Name)
                {
                    if (!CheckFileSize(pathLocal))
                    {
                        return;
                    }

                    if (item.FileSize > 1024 * 1024)
                    {
                        NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "文件大于1M,无法显示", "提示");
                        return;
                    }

                    TransFilesInfo info = new TransFilesInfo();
                    info.Path = ((FileDetailInfo)PointItem).RemoteDir;
                    info.Type = ((FileDetailInfo)PointItem).IsDir ? 0 : 1;
                    List <TransFilesInfo> tmpList = new List <TransFilesInfo>();
                    tmpList.Add(info);

                    int retval = -1;
                    this.Dispatcher.Invoke(() => {
                        this.WaitEvent(() => {
                            unsafe
                            {
                                retval = Tool.FileHandle.FTS.DownLoadFile(EP, tmpList, BaseDir);
                            }
                        }, true, true);
                    });

                    if (retval < 0)
                    {
                        NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "下载文件失败!", "错误");
                        return;
                    }
                }
                WidCompareListEx.Show(Tool.MainWindow.This, EP, pathLocal, pathRemote, DirRelative);
            }
        }
Пример #5
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;
            }
        }