Exemplo n.º 1
0
        private void treeView2_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            treeView2.SelectedNode = e.Node;
            //MessageBox.Show(Convert.ToString(treeView2.SelectedNode.Text));
            //int temp = treeView2.SelectedNode.Index + 11;

            foreach (FolderInfo fi in BuissnesServiceImpl.folderjihe1.ToArray())                    //存疑,一般的写法有可能引发集合被修改的异常
            {
                if ((fi.pId == Convert.ToInt16(e.Node.Name)) && fi.test == false)
                {
                    fi.test = true;
                    //MessageBox.Show(fi.fName);
                    if (fi.hasChild == true)
                    {
                        GetChildMediaFolderListreqbody childmediafolderlistreqbody = new GetChildMediaFolderListreqbody();    //生成获取子文件夹的请求并发送
                        childmediafolderlistreqbody.parentID = fi.folderId;                                                   //不好理解,待定
                        GetChildMediaFolderListreq childmediafolderlistreq = new GetChildMediaFolderListreq();
                        childmediafolderlistreq.body = childmediafolderlistreqbody;
                        string sGetChildMediaFolderListreq = new JavaScriptSerializer().Serialize(childmediafolderlistreq);
                        Form1.wb.send(sGetChildMediaFolderListreq);
                        Thread.Sleep(200);

                        foreach (FolderInfo fi2 in BuissnesServiceImpl.folderjihe1)
                        {
                            if (fi2.pId > 15 && fi2.add == false)
                            {
                                //this.treeView2.Nodes[(fi2.pId - 11)].Nodes.Add(fi2.fName, fi2.fName, 1, 1);
                                TreeNode newfolder = new TreeNode(fi2.fName, 1, 1);
                                newfolder.Name = Convert.ToString(fi2.folderId);
                                e.Node.Nodes[fi.treeViewIndex].Nodes.Add(newfolder);
                                fi2.treeViewIndex = newfolder.Index;
                                fi2.add           = true;
                            }
                        }
                    }
                    if (fi.hasMedia == true)
                    {
                        GetMediaFileListreqbody id4mediabody = new GetMediaFileListreqbody();
                        id4mediabody.id = fi.folderId;
                        GetMediaFileListreq id4media = new GetMediaFileListreq();
                        id4media.body = id4mediabody;
                        string sGetMediaFileListreq = new JavaScriptSerializer().Serialize(id4media);
                        Form1.wb.send(sGetMediaFileListreq);
                        Thread.Sleep(200);

                        foreach (MediaList medial1 in BuissnesServiceImpl.mediajihe1)
                        {
                            if (medial1.pId > 15 && medial1.add == false)
                            {
                                e.Node.Nodes[fi.treeViewIndex].Nodes.Add(medial1.fileName, medial1.fileName, 6, 6);
                                medial1.add = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void Formxianshiqiang_Load(object sender, EventArgs e)
        {
            this.actimer.Enabled  = true;
            this.actimer.Interval = 8000;
            this.actimer.Tick    += new EventHandler(Actimer_Tick);
            this.actimer.Start();

            Form1.wb.send(@" { ""body"" : """", ""guid"" : ""M-44"", ""type"" : ""LOADVIDEOWALLINFO"" }");

            NewTabControl ntc1 = new NewTabControl();

            ntc1.Location              = new Point(556, 28);
            ntc1.SelectedIndexChanged += new EventHandler(ntc1_SelectedIndexChanged);

            TabPage Newpage1 = new TabPage();

            //Newpage1.Location = new System.Drawing.Point(4, 22);
            Newpage1.Name     = "newPage0";
            Newpage1.Padding  = new System.Windows.Forms.Padding(3);
            Newpage1.Size     = new System.Drawing.Size(187, 444);
            Newpage1.TabIndex = 0;
            Newpage1.Text     = "设备";
            Newpage1.UseVisualStyleBackColor = true;

            TabPage Newpage2 = new TabPage();

            Newpage2.Name     = "newPage1";
            Newpage2.Padding  = new System.Windows.Forms.Padding(3);
            Newpage2.Size     = new System.Drawing.Size(187, 444);
            Newpage2.TabIndex = 1;
            Newpage2.Text     = "媒体";
            Newpage2.UseVisualStyleBackColor = true;

            TabPage Newpage3 = new TabPage();

            Newpage3.Name     = "newPage2";
            Newpage3.Padding  = new System.Windows.Forms.Padding(3);
            Newpage3.Size     = new System.Drawing.Size(187, 444);
            Newpage3.TabIndex = 2;
            Newpage3.Text     = "录像";
            Newpage3.UseVisualStyleBackColor = true;

            TabPage Newpage4 = new TabPage();

            Newpage4.Name     = "newPage3";
            Newpage4.Padding  = new System.Windows.Forms.Padding(3);
            Newpage4.Size     = new System.Drawing.Size(187, 444);
            Newpage4.TabIndex = 3;
            Newpage4.Text     = "分组";
            Newpage4.UseVisualStyleBackColor = true;

            treeView1.Location = new Point(3, 6);
            Newpage1.Controls.Add(treeView1);

            treeView2.Location = new Point(3, 6);
            Newpage2.Controls.Add(treeView2);

            ntc1.Name          = "newtabControl";
            ntc1.SelectedIndex = 0;
            ntc1.Size          = new System.Drawing.Size(195, 470);
            ntc1.TabIndex      = 0;
            ntc1.Controls.Add(Newpage1);
            ntc1.Controls.Add(Newpage2);
            ntc1.Controls.Add(Newpage3);
            ntc1.Controls.Add(Newpage4);
            this.Controls.Add(ntc1);

            //int i = 1;

            for (int id4confirm = 11; id4confirm < 15; id4confirm++)                                      //载入媒体4个根目录的基本信息
            {
                GetMediaFolderInforeqbody id4body = new GetMediaFolderInforeqbody();
                id4body.folderID = id4confirm;
                GetMediaFolderInforeq id4 = new GetMediaFolderInforeq();
                id4.body = id4body;
                string sGetMediaFolderInforeq = new JavaScriptSerializer().Serialize(id4);
                Form1.wb.send(sGetMediaFolderInforeq);

                Thread.Sleep(200);

                if (BuissnesServiceImpl.mediafolderinfobody.hasChild == true)
                {
                    //MessageBox.Show("文件夹" + BuissnesServiceImpl.mediafolderinfobody.folderName + "还有子项(经check此子项是指子文件夹)");

                    GetChildMediaFolderListreqbody childmediafolderlistreqbody = new GetChildMediaFolderListreqbody();    //生成获取子文件夹的请求并发送
                    childmediafolderlistreqbody.parentID = BuissnesServiceImpl.mediafolderinfobody.folderID;
                    GetChildMediaFolderListreq childmediafolderlistreq = new GetChildMediaFolderListreq();
                    childmediafolderlistreq.body = childmediafolderlistreqbody;
                    string sGetChildMediaFolderListreq = new JavaScriptSerializer().Serialize(childmediafolderlistreq);
                    Form1.wb.send(sGetChildMediaFolderListreq);
                    Thread.Sleep(1000);

                    /*
                     * foreach (FolderInfo fi in BuissnesServiceImpl.folderjihe1)
                     * {
                     *  this.treeView2.Nodes[(fi.pId-11)].Nodes.Add(fi.fName);
                     * }
                     */
                }
                else if (BuissnesServiceImpl.mediafolderinfobody.hasChild == false)
                {
                    //MessageBox.Show("文件夹" + BuissnesServiceImpl.mediafolderinfobody.folderName + "没有子项(经check此子项是指子文件夹)!!");
                }

                GetMediaFileListreqbody id4mediabody = new GetMediaFileListreqbody();
                id4mediabody.id = id4confirm;
                GetMediaFileListreq id4media = new GetMediaFileListreq();
                id4media.body = id4mediabody;
                string sGetMediaFileListreq = new JavaScriptSerializer().Serialize(id4media);
                Form1.wb.send(sGetMediaFileListreq);

                Thread.Sleep(200);
            }

            foreach (FolderInfo fi in BuissnesServiceImpl.folderjihe1)
            {
                if (fi.pId > 10 && fi.pId < 15)
                {
                    //this.treeView2.Nodes[(fi.pId - 11)].Nodes.Add(fi.fName, fi.fName, 1, 1);

                    TreeNode newfolder = new TreeNode(fi.fName, 1, 1);
                    newfolder.Name = Convert.ToString(fi.folderId);
                    this.treeView2.Nodes[(fi.pId - 11)].Nodes.Add(newfolder);
                    fi.treeViewIndex = newfolder.Index;                                                     //这里是大坑啊,一定要深刻理解这几句命令的意义和顺序!不然index永远为0
                }
            }

            foreach (MediaList medial in BuissnesServiceImpl.mediajihe1)
            {
                if (medial.pId > 10 && medial.pId < 15)
                {
                    this.treeView2.Nodes[(medial.pId - 11)].Nodes.Add(medial.fileName, medial.fileName, 6, 6);
                }
            }

            Thread.Sleep(200);
            //Thread.Sleep(5000);

            //MessageBox.Show(i.ToString());

            for (int devicerootint = 1; devicerootint < 8; devicerootint++)
            {
                GetDeviceFolderInforeqbody devicefolderinforeqbodyroot = new GetDeviceFolderInforeqbody();               //发送请求,载入设备若干个根目录的基本信息
                devicefolderinforeqbodyroot.typeid = Convert.ToUInt32(devicerootint);
                GetDeviceFolderInforeq devicefolderinforeqroot = new GetDeviceFolderInforeq();
                devicefolderinforeqroot.body = devicefolderinforeqbodyroot;
                string sGetDeviceFolderInforeqroot = new JavaScriptSerializer().Serialize(devicefolderinforeqroot);
                Form1.wb.send(sGetDeviceFolderInforeqroot);

                Thread.Sleep(200);

                if (BuissnesServiceImpl.devicefolderinfobody.hasChild == true)
                {
                    GetDeviceTypeFolderListreqbody childdevicetypefolderlistreqbody = new GetDeviceTypeFolderListreqbody();
                    childdevicetypefolderlistreqbody.typeid = BuissnesServiceImpl.devicefolderinfobody.folderID;
                    GetDeviceTypeFolderListreq childdevicetypefolderlistreq = new GetDeviceTypeFolderListreq();
                    childdevicetypefolderlistreq.body = childdevicetypefolderlistreqbody;
                    string sGetDevicTypeFolderListreq = new JavaScriptSerializer().Serialize(childdevicetypefolderlistreq);
                    Form1.wb.send(sGetDevicTypeFolderListreq);
                    Thread.Sleep(1000);
                }
                else if (BuissnesServiceImpl.devicefolderinfobody.hasChild == false)
                {
                }

                GetDeviceListreqbody devicelistreqbodyroot = new GetDeviceListreqbody();
                devicelistreqbodyroot.id = Convert.ToUInt32(devicerootint);
                GetDeviceListreq devicelistreqroot = new GetDeviceListreq();
                devicelistreqroot.body = devicelistreqbodyroot;
                string sGetDeviceListreqroot = new JavaScriptSerializer().Serialize(devicelistreqroot);
                Form1.wb.send(sGetDeviceListreqroot);

                Thread.Sleep(200);
            }

            foreach (DeviceFolderele dfe in BuissnesServiceImpl.devicefolderjihe1)
            {
                if (dfe.parentID > 0 && dfe.parentID < 11)
                {
                    TreeNode newdevicefolder = new TreeNode(dfe.deviceFolderName, 2, 2);
                    newdevicefolder.Name = Convert.ToString(dfe.folderID);
                    this.treeView1.Nodes[(Convert.ToInt16(dfe.parentID) - 1)].Nodes.Add(newdevicefolder);
                    dfe.treeViewIndex = newdevicefolder.Index;
                }
            }
            foreach (DeviceList devicel in BuissnesServiceImpl.devicejihe1)
            {
                if (devicel.devicepId > 0 && devicel.devicepId < 11)
                {
                    switch (devicel.deviceType)
                    {
                    case 1:
                        TreeNode newcontroller = new TreeNode(devicel.deviceName, 5, 5);
                        newcontroller.Name = Convert.ToString(devicel.deviceId);
                        this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(newcontroller);
                        if (devicel.sourceinfo != null)
                        {
                            for (int i1 = 0; i1 < devicel.sourceinfo.Count; i1++)
                            {
                                TreeNode newapp = new TreeNode(devicel.sourceinfo[i1].sourceName, 3, 3);
                                newapp.Name = Convert.ToString(devicel.sourceinfo[i1].sourceId);
                                newcontroller.Nodes.Add(newapp);

                                /*
                                 * foreach (TreeNode controller1 in this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes)
                                 * {
                                 *  if (controller1.Name == devicel.deviceName)
                                 *  {
                                 *      controller1.Nodes.Add(newapp);
                                 *  }
                                 * }
                                 */
                            }
                        }
                        break;

                    case 2:
                        TreeNode newmatrix = new TreeNode(devicel.deviceName, 9, 9);
                        newmatrix.Name = Convert.ToString(devicel.deviceId);
                        this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(newmatrix);
                        if (devicel.sourceinfo != null)
                        {
                            for (int i2 = 0; i2 < devicel.sourceinfo.Count; i2++)
                            {
                                TreeNode newmatrixsource = new TreeNode(devicel.sourceinfo[i2].sourceName, 10, 10);
                                newmatrixsource.Name = Convert.ToString(devicel.sourceinfo[i2].sourceId);
                                newmatrix.Nodes.Add(newmatrixsource);
                            }
                        }
                        break;

                    case 3:
                        TreeNode newnvr = new TreeNode(devicel.deviceName, 11, 11);
                        newnvr.Name = Convert.ToString(devicel.deviceId);
                        this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(newnvr);
                        if (devicel.sourceinfo != null)
                        {
                            for (int i3 = 0; i3 < devicel.sourceinfo.Count; i3++)
                            {
                                TreeNode newnvrsource = new TreeNode(devicel.sourceinfo[i3].sourceName, 6, 6);
                                newnvrsource.Name = Convert.ToString(devicel.sourceinfo[i3].sourceId);
                                newnvr.Nodes.Add(newnvrsource);
                            }
                        }
                        break;

                    case 4:
                        TreeNode newipc = new TreeNode(devicel.deviceName, 7, 7);
                        newipc.Name = Convert.ToString(devicel.deviceId);
                        this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(newipc);
                        if (devicel.sourceinfo != null)
                        {
                            for (int i4 = 0; i4 < devicel.sourceinfo.Count; i4++)
                            {
                                TreeNode newipcsource = new TreeNode(devicel.sourceinfo[i4].sourceName, 6, 6);
                                newipcsource.Name = Convert.ToString(devicel.sourceinfo[i4].sourceId);
                                newipc.Nodes.Add(newipcsource);
                            }
                        }
                        break;

                    case 5:
                        TreeNode newstreaming = new TreeNode(devicel.deviceName, 8, 8);
                        newstreaming.Name = Convert.ToString(devicel.deviceId);
                        this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(newstreaming);
                        break;

                    case 6:
                        TreeNode newtrans = new TreeNode(devicel.deviceName, 12, 12);
                        newtrans.Name = Convert.ToString(devicel.deviceId);
                        this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(newtrans);
                        break;

                    case 7:
                        TreeNode newprojector = new TreeNode(devicel.deviceName, 1, 1);
                        newprojector.Name = Convert.ToString(devicel.deviceId);
                        this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(newprojector);
                        break;
                    }

                    //this.treeView1.Nodes[Convert.ToInt16(devicel.devicepId) - 1].Nodes.Add(devicel.deviceName, devicel.deviceName, 0, 0);
                }
            }
            Thread.Sleep(200);
        }