Esempio n. 1
0
        private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            treeView1.SelectedNode = e.Node;

            foreach (DeviceFolderele dfe2 in BuissnesServiceImpl.devicefolderjihe1.ToArray())
            {
                if ((dfe2.parentID == Convert.ToInt16(e.Node.Name)) && dfe2.test == false)
                {
                    dfe2.test = true;
                    if (dfe2.hasChild == true)
                    {
                        GetDeviceTypeFolderListreqbody childdevicetypefolderlistreqbody = new GetDeviceTypeFolderListreqbody();
                        childdevicetypefolderlistreqbody.typeid = dfe2.folderID;
                        GetDeviceTypeFolderListreq childdevicetypefolderlistreq = new GetDeviceTypeFolderListreq();
                        childdevicetypefolderlistreq.body = childdevicetypefolderlistreqbody;
                        string sGetDeviceTypeFolderListreq = new JavaScriptSerializer().Serialize(childdevicetypefolderlistreq);
                        Form1.wb.send(sGetDeviceTypeFolderListreq);
                        Thread.Sleep(200);

                        foreach (DeviceFolderele dfe3 in BuissnesServiceImpl.devicefolderjihe1)
                        {
                            if (dfe3.parentID > 10 && dfe3.add == false)
                            {
                                TreeNode newdevicefolder = new TreeNode(dfe3.deviceFolderName, 2, 2);
                                newdevicefolder.Name = Convert.ToString(dfe3.folderID);
                                e.Node.Nodes[dfe3.treeViewIndex].Nodes.Add(newdevicefolder);
                                dfe3.treeViewIndex = newdevicefolder.Index;
                                dfe3.add           = true;
                            }
                        }
                    }
                    if (dfe2.hasDevice == true)
                    {
                        GetDeviceListreqbody devicelistreqbody = new GetDeviceListreqbody();
                        devicelistreqbody.id = Convert.ToUInt32(dfe2.folderID);
                        GetDeviceListreq devicelistreq = new GetDeviceListreq();
                        devicelistreq.body = devicelistreqbody;
                        string sGetDeviceListreq = new JavaScriptSerializer().Serialize(devicelistreq);
                        Form1.wb.send(sGetDeviceListreq);

                        Thread.Sleep(200);

                        foreach (DeviceList devicel1 in BuissnesServiceImpl.devicejihe1)
                        {
                            if (devicel1.devicepId > 10 && devicel1.add == false)
                            {
                                //e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(devicel1.deviceName, devicel1.deviceName, 6, 6);
                                //devicel1.add = true;

                                switch (devicel1.deviceType)
                                {
                                case 1:
                                    TreeNode newcontroller = new TreeNode(devicel1.deviceName, 5, 5);
                                    newcontroller.Name = Convert.ToString(devicel1.deviceId);
                                    e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(newcontroller);
                                    if (devicel1.sourceinfo != null)
                                    {
                                        for (int i1 = 0; i1 < devicel1.sourceinfo.Count; i1++)
                                        {
                                            TreeNode newapp = new TreeNode(devicel1.sourceinfo[i1].sourceName, 3, 3);
                                            newapp.Name = Convert.ToString(devicel1.sourceinfo[i1].sourceId);
                                            newcontroller.Nodes.Add(newapp);
                                        }
                                    }
                                    devicel1.add = true;
                                    break;

                                case 2:
                                    TreeNode newmatrix = new TreeNode(devicel1.deviceName, 9, 9);
                                    newmatrix.Name = Convert.ToString(devicel1.deviceId);
                                    e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(newmatrix);
                                    if (devicel1.sourceinfo != null)
                                    {
                                        for (int i1 = 0; i1 < devicel1.sourceinfo.Count; i1++)
                                        {
                                            TreeNode newmatrixsource = new TreeNode(devicel1.sourceinfo[i1].sourceName, 10, 10);
                                            newmatrixsource.Name = Convert.ToString(devicel1.sourceinfo[i1].sourceId);
                                            newmatrix.Nodes.Add(newmatrixsource);
                                        }
                                    }
                                    devicel1.add = true;
                                    break;

                                case 3:
                                    TreeNode newnvr = new TreeNode(devicel1.deviceName, 11, 11);
                                    newnvr.Name = Convert.ToString(devicel1.deviceId);
                                    e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(newnvr);
                                    if (devicel1.sourceinfo != null)
                                    {
                                        for (int i1 = 0; i1 < devicel1.sourceinfo.Count; i1++)
                                        {
                                            TreeNode newnvrsource = new TreeNode(devicel1.sourceinfo[i1].sourceName, 6, 6);
                                            newnvrsource.Name = Convert.ToString(devicel1.sourceinfo[i1].sourceId);
                                            newnvr.Nodes.Add(newnvrsource);
                                        }
                                    }
                                    devicel1.add = true;
                                    break;

                                case 4:
                                    TreeNode newipc = new TreeNode(devicel1.deviceName, 7, 7);
                                    newipc.Name = Convert.ToString(devicel1.deviceId);
                                    e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(newipc);
                                    if (devicel1.sourceinfo != null)
                                    {
                                        for (int i1 = 0; i1 < devicel1.sourceinfo.Count; i1++)
                                        {
                                            TreeNode newipcsource = new TreeNode(devicel1.sourceinfo[i1].sourceName, 6, 6);
                                            newipcsource.Name = Convert.ToString(devicel1.sourceinfo[i1].sourceId);
                                            newipc.Nodes.Add(newipcsource);
                                        }
                                    }
                                    devicel1.add = true;
                                    break;

                                case 5:
                                    TreeNode newstreaming = new TreeNode(devicel1.deviceName, 8, 8);
                                    newstreaming.Name = Convert.ToString(devicel1.deviceId);
                                    e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(newstreaming);
                                    devicel1.add = true;
                                    break;

                                case 6:
                                    TreeNode newtrans = new TreeNode(devicel1.deviceName, 12, 12);
                                    newtrans.Name = Convert.ToString(devicel1.deviceId);
                                    e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(newtrans);
                                    devicel1.add = true;
                                    break;

                                case 7:
                                    TreeNode newprojector = new TreeNode(devicel1.deviceName, 1, 1);
                                    newprojector.Name = Convert.ToString(devicel1.deviceId);
                                    e.Node.Nodes[dfe2.treeViewIndex].Nodes.Add(newprojector);
                                    devicel1.add = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio 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);
        }