Пример #1
0
        FileTreeNode[] GetServer(string startpath = "", bool showdownload = false)
        {
            Log = "Идет загрузка...";
            if (showdownload)
            {
                new Thread(() => ld.ShowDialog()).Start();
            }

            var web = (Downloading.GetHTML(DownloadingPaths.ToPath(setting.URLToHTTPPort) + DownloadingPaths.SD + startpath, setting.Name, setting.Password));

            var list = new List <FileTreeNode>();

            HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
            html.LoadHtml(web);

            var table   = html.DocumentNode.SelectSingleNode("/html/body/pre/table");
            var tabletr = table.ChildNodes.Where(x => x.Name == "tr").ToList();

            tabletr.RemoveRange(0, 3);

            foreach (var item in tabletr)
            {
                if (item.ChildNodes.Count > 2)
                {
                    var path = item.ChildNodes[0].ChildNodes[0].InnerHtml.Replace("&nbsp;", "");
                    var date = item.ChildNodes[1].ChildNodes[0].InnerHtml.Replace("&nbsp;", "");
                    var size = item.ChildNodes[2].ChildNodes[0].InnerHtml.Replace("&nbsp;", "");

                    //Console.WriteLine(path);
                    //Console.WriteLine(date);
                    //Console.WriteLine(type);
                    //Console.WriteLine("----------");

                    FileTreeNode tr;

                    if (size == "[DIRECTORY]")
                    {
                        tr = new FileTreeNode(path, /*GetServer(startpath + "" + path),*/ FileTreeNode.TypeNode.Directory, startpath + "" + path);
                        tr.SelectedImageKey = "f";
                        tr.ImageKey         = "f";
                        tr.Nodes.Add("");
                    }
                    else
                    {
                        tr = new FileTreeNode(path, FileTreeNode.TypeNode.File, startpath + "" + path);
                        tr.SelectedImageKey = "v";
                        tr.ImageKey         = "v";
                    }
                    tr.ContextMenuStrip = contextMenuStrip1;
                    tr.ToolTipText      = date + " (" + (size) + ")";
                    list.Add(tr);
                }
            }
            if (showdownload)
            {
                ld.Invoke(new Action(() => ld.Close())); Log = "Загрузка завершена";
            }
            return(list.ToArray());
        }
Пример #2
0
        void UpdateServer(string startpath = "")
        {
            Log = "Идет загрузка...";
            treeView1.Nodes.Clear();
            new Thread(() => ld.ShowDialog()).Start();

            var DeviceInfo = Downloading.GetDeviceParams(setting.URLToHTTPPort, setting.Name, setting.Password);

            label1.Text          = "Свободно места на SD (" + formatFileSize(int.Parse(DeviceInfo["sdfreespace"])) + ") из " + formatFileSize(int.Parse(DeviceInfo["sdtotalspace"]));
            progressBar2.Maximum = int.Parse(DeviceInfo["sdtotalspace"]);
            progressBar2.Value   = int.Parse(DeviceInfo["sdtotalspace"]) - int.Parse(DeviceInfo["sdfreespace"]);
            label2.Text          = (DeviceInfo["sdstatus"].Contains("Ready")) ? "SD карта работает исправно" : "Ошибка SD карты";
            label3.Text          = "Камера запущенна: " + DeviceInfo["startdate"];
            label6.Text          = "Камера работает: " + (DateTime.Now - DateTime.Parse(DeviceInfo["startdate"])).ToString().Split('.')[0];

            checkBox1.Checked       = DeviceInfo["planrec_enable"].Contains("1");
            numericUpDown1.Value    = int.Parse(DeviceInfo["planrec_time"]);
            comboBox1.SelectedIndex = DeviceInfo["planrec_chn"] == "11" ? 1 : 0;

            var web = (Downloading.GetHTML(DownloadingPaths.ToPath(setting.URLToHTTPPort) + DownloadingPaths.SD + startpath, setting.Name, setting.Password));

            HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
            html.LoadHtml(web);

            var table   = html.DocumentNode.SelectSingleNode("/html/body/pre/table");
            var tabletr = table.ChildNodes.Where(x => x.Name == "tr").ToList();

            tabletr.RemoveRange(0, 3);

            foreach (var item in tabletr)
            {
                if (item.ChildNodes.Count > 2)
                {
                    var path = item.ChildNodes[0].ChildNodes[0].InnerHtml.Replace("&nbsp;", "");
                    var date = item.ChildNodes[1].ChildNodes[0].InnerHtml.Replace("&nbsp;", "");
                    var size = item.ChildNodes[2].ChildNodes[0].InnerHtml.Replace("&nbsp;", "");

                    //Console.WriteLine(path);
                    //Console.WriteLine(date);
                    //Console.WriteLine(type);
                    //Console.WriteLine("----------");

                    FileTreeNode tr = new FileTreeNode(path, GetServer(startpath + "" + path), FileTreeNode.TypeNode.Directory, startpath + "" + path);
                    tr.ToolTipText      = date + " (" + size + ")";
                    tr.ContextMenuStrip = contextMenuStrip1;
                    treeView1.Nodes.Add(tr);
                }
            }
            if (backgroundWorker1.IsBusy)
            {
                backgroundWorker1.CancelAsync();
            }
            if (!backgroundWorker1.IsBusy)
            {
                backgroundWorker1.RunWorkerAsync(DateTime.Now - DateTime.Parse(DeviceInfo["startdate"]));
            }
            ld.Invoke(new Action(() => ld.Close()));
            Log = "Загрузка завершена";
        }
Пример #3
0
 private void ParseChild(FileTreeNode fs, string pathdown)
 {
     if (fs.typeNode == FileTreeNode.TypeNode.File & fs.Checked)
     {
         progressBar1.Maximum += 100;
         //Directory.CreateDirectory(pathdown + fs.URL);
         BtnDownload(DownloadingPaths.ToPath(setting.URLToHTTPPort) + DownloadingPaths.SD + fs.URL, pathdown + "\\" + fs.URL.Split('/').Where(x => x.Contains(".")).ToArray()[0]);
     }
     else if (fs.typeNode == FileTreeNode.TypeNode.Directory)
     {
         foreach (var item in fs.Nodes)
         {
             var nods = item as FileTreeNode;
             ParseChild(nods, pathdown);
         }
     }
 }
Пример #4
0
 private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     selected = (FileTreeNode)e.Node;
     просмотрToolStripMenuItem.Enabled = selected.typeNode == FileTreeNode.TypeNode.File /*&& selected.URL.EndsWith(".jpg")*/;
 }