Пример #1
0
        //@"ftp://*****:*****@192.168.42.6/"
        //只能支持单个FTP站点
        public bool InitHttpRoot(DataModel.VideoSupplierDeviceInfo item)
        {
            string strformat = string.IsNullOrEmpty(item.UserName) ? "{0}://{3}:{4}/{5}" : "{0}://{1}:{2}@{3}:{4}/{5}";
            string urlroot   = string.Format(strformat
                                             , (item.ProtocolType == DataModel.E_VDA_NET_STORE_DEV_PROTOCOL_TYPE.E_DEV_PROTOCOL_CONTYPE_FTP_FILE) ? "ftp" : "http"
                                             , item.UserName
                                             , item.Password
                                             , item.IP
                                             , item.Port
                                             , item.Rest);

            ftproot          = urlroot.TrimEnd('/') + "/";
            GetDirectoryList = GetFtpDirectoryList;
            GetFileList      = GetFtpFileList;
            ClearRoot();
            InitRoot(ftproot, ftproot);

            //string ftproot = @"ftp://*****:*****@192.168.42.6/";

            m_ftpService = new FtpLib.FtpConnection(item.IP, (int)item.Port, item.UserName, item.Password);
            m_ftpService.Open();
            try
            {
                m_ftpService.Login();
                //m_ftpService.SetCurrentDirectory(textBoxPath.Text);
                SaveFtpInfo();
                return(true);
            }
            catch (Exception ex)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("无法连接FTP服务器,请检查地址及用户名密码。 " + ex.Message, Framework.Environment.PROGRAM_NAME);
                return(false);
            }
        }
Пример #2
0
        private void InitCameraList(DevComponents.AdvTree.Node pNode)
        {
            if (pNode.Cells[3].Text != "Plat")
            {
                return;
            }

            if (pNode.Tag is ConfigServices.DIOService)
            {
                return;
            }

            DataModel.VideoSupplierDeviceInfo info = pNode.Tag as DataModel.VideoSupplierDeviceInfo;
            if (info == null)
            {
                return;
            }

            ConfigServices.DIOService server = new ConfigServices.DIOService(Framework.Container.Instance.IVXProtocol);
            server.Login(info.ProtocolType, info.IP, (ushort)info.Port, info.UserName, info.Password);

            //ConfigServices.DIOService server = pNode.Tag as ConfigServices.DIOService;
            pNode.Tag = server;
            treeListFtpFile.SuspendLayout();

            try
            {
                var list = server.GetChannelList();
                pNode.Nodes.Clear();

                foreach (IVX.Live.ConfigServices.Interop.TDIO_ChannelInfo item in list)
                {
                    DevComponents.AdvTree.Node snode = new DevComponents.AdvTree.Node();
                    snode.Expanded   = false;
                    snode.Name       = "Camera";
                    snode.ImageIndex = 1;
                    snode.Text       = item.szChannelName;
                    snode.Cells.Add(new DevComponents.AdvTree.Cell(item.szChannelId));
                    snode.Cells.Add(new DevComponents.AdvTree.Cell("0"));
                    snode.Cells.Add(new DevComponents.AdvTree.Cell("Camera"));
                    snode.Nodes.Add(new DevComponents.AdvTree.Node(NullValue));
                    snode.NodeDoubleClick += new EventHandler(snode_NodeDoubleClick);

                    snode.Tag = item;
                    pNode.Nodes.Add(snode);
                }
            }
            catch (Exception)
            {
                //Framework.Container.Instance.InteractionService.ShowMessageBox("无法连接FTP服务器,或获取HTTP文件列表失败。", Framework.Environment.PROGRAM_NAME);
                return;
            }
            treeListFtpFile.ResumeLayout();
        }